diff --git a/src/features/Posts/pages/CreatePostPage/Components/ErrorsContainer/ErrorsContainer.tsx b/src/features/Posts/pages/CreatePostPage/Components/ErrorsContainer/ErrorsContainer.tsx index 8c56db2..f5be324 100644 --- a/src/features/Posts/pages/CreatePostPage/Components/ErrorsContainer/ErrorsContainer.tsx +++ b/src/features/Posts/pages/CreatePostPage/Components/ErrorsContainer/ErrorsContainer.tsx @@ -10,6 +10,7 @@ const ErrorsContainer = forwardRef((props, ref) => { const { formState: { isValid, isSubmitted, errors } } = useFormContext(); + const hasErrors = Object.values(errors).length > 0 return ( diff --git a/src/features/Posts/pages/CreatePostPage/Components/TemplatesCard/TemplatesCard.tsx b/src/features/Posts/pages/CreatePostPage/Components/TemplatesCard/TemplatesCard.tsx index db8c95c..44d58d3 100644 --- a/src/features/Posts/pages/CreatePostPage/Components/TemplatesCard/TemplatesCard.tsx +++ b/src/features/Posts/pages/CreatePostPage/Components/TemplatesCard/TemplatesCard.tsx @@ -1,12 +1,15 @@ import React from 'react' import { useFormContext } from 'react-hook-form'; +import Skeleton from 'react-loading-skeleton'; import Card from 'src/Components/Card/Card' -import { IStoryFormInputs } from '../../CreateStoryPage/CreateStoryPage'; +import { useOfficialTagsQuery } from 'src/graphql'; +import { CreateStoryType } from '../../CreateStoryPage/CreateStoryPage'; export default function TemplatesCard() { - const { formState: { isDirty }, reset } = useFormContext(); + const { formState: { isDirty }, reset } = useFormContext(); + const officalTags = useOfficialTagsQuery(); const clickTemplate = (template: typeof templates[number]) => { if (!isDirty || window.confirm("Your current unsaved changes will be lost, are you sure you want to continue?")) { @@ -15,15 +18,25 @@ export default function TemplatesCard() { is_published: false, title: template.value.title, body: template.value.body, + tags: officalTags.data?.officialTags.filter(tag => template.value.tags.includes(tag.title)) ?? [] }) } } + + return (

Story templates

    - {templates.map(template => + {officalTags.loading && Array(3).fill(0).map((_, idx) =>
  • +

    + +

    +

    +
  • )} + {!officalTags.loading && templates.map(template =>
  • v.replace(/(\r\n|\n|\r)/gm, "")), tags: yup.array().of(tagSchema).required().min(1, 'Add at least one tag'), body: yup.string().required("Write some content in the post").min(50, 'Post must contain at least 10+ words'), - cover_image: imageSchema.nullable(true), + cover_image: imageSchema.default(null).nullable(), }).required(); diff --git a/src/features/Projects/pages/ListProjectPage/Components/ProjectListedModal/ProjectListedModal.tsx b/src/features/Projects/pages/ListProjectPage/Components/ProjectListedModal/ProjectListedModal.tsx index 0964b6c..8ca2904 100644 --- a/src/features/Projects/pages/ListProjectPage/Components/ProjectListedModal/ProjectListedModal.tsx +++ b/src/features/Projects/pages/ListProjectPage/Components/ProjectListedModal/ProjectListedModal.tsx @@ -82,7 +82,7 @@ export default function ProjectListedModal({ onClose, direction, project, ...pro color='primary' fullWidth newTab - href={createRoute({ type: "edit-story" })} + href={createRoute({ type: "write-story" })} >✍️ Write a story