mirror of
https://github.com/aljazceru/landscape-template.git
synced 2025-12-26 18:54:21 +01:00
fix: add validation message to missing story field in createStory
This commit is contained in:
@@ -35,7 +35,7 @@ export default function StoryCard({ story }: Props) {
|
||||
|
||||
return (
|
||||
<div className="bg-white rounded-12 overflow-hidden border-2 border-gray-200">
|
||||
<img src={story.cover_image} className='h-[200px] w-full object-cover' alt="" />
|
||||
{story.cover_image && <img src={story.cover_image} className='h-[200px] w-full object-cover' alt="" />}
|
||||
<div className="p-24">
|
||||
<Header author={story.author} date={story.createdAt} />
|
||||
<Link to={createRoute({ type: 'story', id: story.id, title: story.title })}>
|
||||
|
||||
@@ -34,7 +34,7 @@ const schema = yup.object({
|
||||
title: yup.string().trim().required().min(10, 'the title is too short'),
|
||||
tags: yup.array().required().min(1, 'please pick at least one relevant tag'),
|
||||
body: yup.string().required().min(50, 'stories should have a minimum of 10 words'),
|
||||
cover_image: yup.array().of(FileSchema as any)
|
||||
cover_image: yup.array().of(FileSchema as any).min(1, "You need to add a cover image")
|
||||
|
||||
}).required();
|
||||
|
||||
@@ -110,7 +110,7 @@ export default function StoryForm() {
|
||||
title: data.title,
|
||||
body: data.body,
|
||||
tags: data.tags.map(t => t.title),
|
||||
cover_image: data.cover_image[0] as string,
|
||||
cover_image: (data.cover_image[0] ?? '') as string,
|
||||
},
|
||||
}
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user