{author.name}
+{trimText(author.name, 333)}
Joined on {dayjs(author.join_date).format('MMMM DD, YYYY')}
{props.author.name}
+{trimText(props.author.name, 30)}
{dateToShow()}
diff --git a/src/features/Posts/pages/CreatePostPage/Components/StoryForm/StoryForm.tsx b/src/features/Posts/pages/CreatePostPage/Components/StoryForm/StoryForm.tsx index 85b61c2..8b4d6b7 100644 --- a/src/features/Posts/pages/CreatePostPage/Components/StoryForm/StoryForm.tsx +++ b/src/features/Posts/pages/CreatePostPage/Components/StoryForm/StoryForm.tsx @@ -1,3 +1,4 @@ +import { useState } from 'react' import { yupResolver } from "@hookform/resolvers/yup"; import { Controller, FormProvider, NestedValue, Resolver, SubmitHandler, useForm } from "react-hook-form"; import Button from "src/Components/Button/Button"; @@ -5,52 +6,117 @@ import FilesInput from "src/Components/Inputs/FilesInput/FilesInput"; import TagsInput from "src/Components/Inputs/TagsInput/TagsInput"; import * as yup from "yup"; import ContentEditor from "../ContentEditor/ContentEditor"; +import { Topic, useCreateStoryMutation } from 'src/graphql' +import { useNavigate } from 'react-router-dom' +import TopicsInput from '../TopicsInput/TopicsInput' +import { useAppDispatch, useAppSelector } from 'src/utils/hooks'; +import { stageStory } from 'src/redux/features/staging.slice' +import { Override } from 'src/utils/interfaces'; +const FileSchema = yup.lazy((value: string | File[]) => { + + switch (typeof value) { + case 'object': + return yup.mixed() + .test("fileSize", "File Size is too large", file => file.size <= 5242880) + .test("fileType", "Unsupported File Format, only png/jpg/jpeg images are allowed", + (file: File) => + ["image/jpeg", "image/png", "image/jpg"].includes(file.type)) + case 'string': + return yup.string().url(); + default: + return yup.mixed() + } +}) const schema = yup.object({ title: yup.string().required().min(10), + topic: yup.object().nullable().required(), tags: yup.array().required().min(1), body: yup.string().required().min(50, 'you have to write at least 10 words'), - cover_image: yup.lazy((value: string | File[]) => { - switch (typeof value) { - case 'object': - return yup.array() - .test("fileSize", "File Size is too large", (files) => (files as File[]).every(file => file.size <= 5242880)) - .test("fileType", "Unsupported File Format, only png/jpg/jpeg images are allowed", - (files) => (files as File[]).every((file: File) => - ["image/jpeg", "image/png", "image/jpg"].includes(file.type))) - case 'string': - return yup.string().url(); - default: - return yup.mixed() - } - }) + cover_image: yup.array().of(FileSchema as any) + }).required(); + interface IFormInputs { + id: number | null title: string - tags: NestedValue
} - ++ Topic +
++ {errors.topic.message} +
}Tags
@@ -113,11 +197,18 @@ export default function StoryForm() { }{author.name}
+{trimText(author.name, 333)}
Joined on {dayjs(author.join_date).format('MMMM DD, YYYY')}