From fffacce28821cbf2b0d3e7f5643ce2b88cfceb38 Mon Sep 17 00:00:00 2001 From: ngure1 Date: Thu, 30 May 2024 22:25:37 +0300 Subject: [PATCH 1/4] fix: rename authentication form titles --- src/app/auth/activate/resend/page.tsx | 7 ++----- src/app/auth/password-reset-confirm/[uid]/[token]/page.tsx | 4 ++-- src/app/auth/username-reset-confirm/[uid]/[token]/page.tsx | 2 +- 3 files changed, 5 insertions(+), 8 deletions(-) diff --git a/src/app/auth/activate/resend/page.tsx b/src/app/auth/activate/resend/page.tsx index d7b801d..3c42068 100644 --- a/src/app/auth/activate/resend/page.tsx +++ b/src/app/auth/activate/resend/page.tsx @@ -56,12 +56,9 @@ const Page = () => { // return (
-

Reset

+

Resend Email

- + { return (
-

Reset

+

Reset Password

{ name="new_password" render={({ field }) => ( - New Password + New Password { // return (
-

Reset

+

Reset Email

Date: Thu, 30 May 2024 22:50:00 +0300 Subject: [PATCH 2/4] fix: fix innovation fields to match backend fields --- src/app/dashboard/bookmarks/page.tsx | 16 +- src/app/dashboard/innovation/[id]/page.tsx | 18 +- .../dashboard/innovation/edit/[id]/page.tsx | 100 +++- src/app/dashboard/innovation/new/page.tsx | 459 ++++++++++-------- src/app/dashboard/my-profile/page.tsx | 2 +- src/app/dashboard/page.tsx | 68 +-- src/components/SearchComponent.tsx | 63 +-- src/components/ui/projectcard.tsx | 24 +- src/lib/types.ts | 50 +- .../innovations/innovationsApiSlice.ts | 50 +- 10 files changed, 484 insertions(+), 366 deletions(-) diff --git a/src/app/dashboard/bookmarks/page.tsx b/src/app/dashboard/bookmarks/page.tsx index ca67ef7..41b82c3 100644 --- a/src/app/dashboard/bookmarks/page.tsx +++ b/src/app/dashboard/bookmarks/page.tsx @@ -1,12 +1,12 @@ -"use client" -import React from 'react' -import { useInnovationsBookmarksListQuery } from '@/redux/features/innovations/innovationsApiSlice'; -import ProjectCard from '@/components/ui/projectcard'; +"use client"; +import React from "react"; +import { useInnovationsBookmarksListQuery } from "@/redux/features/innovations/innovationsApiSlice"; +import ProjectCard from "@/components/ui/projectcard"; const BookmarkPage = () => { const { data: bookmarksList, isLoading: bookmarkIsLoading } = useInnovationsBookmarksListQuery(null); console.log(bookmarksList); - return ( + return (
{bookmarkIsLoading ? ( @@ -25,7 +25,7 @@ const BookmarkPage = () => { author_last_name={user.last_name} project_title={innovation.title} project_description={innovation.description} - dashboard_banner_image_url={innovation.banner_image} + dashboard_image_url={innovation.dashboard_image} likes_count={innovation.likes_number} comments_count={innovation.comments_number} is_liked={innovation.is_liked} @@ -37,6 +37,6 @@ const BookmarkPage = () => {
); -} +}; -export default BookmarkPage +export default BookmarkPage; diff --git a/src/app/dashboard/innovation/[id]/page.tsx b/src/app/dashboard/innovation/[id]/page.tsx index be4a449..834bb63 100644 --- a/src/app/dashboard/innovation/[id]/page.tsx +++ b/src/app/dashboard/innovation/[id]/page.tsx @@ -188,21 +188,18 @@ const InnovationDetailPage = ({ params }: InnovationDetailPageProps) => {
- { - innovation?.dashboard_link && + {innovation?.dashboard_link && ( - } - { - innovation?.dashboard_definition && - + )} + {innovation?.dashboard_definitions && ( + - } - + )}
@@ -237,12 +234,12 @@ const InnovationDetailPage = ({ params }: InnovationDetailPageProps) => {
- {innovation?.banner_image ? ( + {innovation?.dashboard_image ? ( Innovation Image ) : ( <> @@ -325,7 +322,6 @@ const InnovationDetailPage = ({ params }: InnovationDetailPageProps) => { onNext={handleNext} />
- ); }; diff --git a/src/app/dashboard/innovation/edit/[id]/page.tsx b/src/app/dashboard/innovation/edit/[id]/page.tsx index 5d91c5d..404c5c1 100644 --- a/src/app/dashboard/innovation/edit/[id]/page.tsx +++ b/src/app/dashboard/innovation/edit/[id]/page.tsx @@ -55,10 +55,11 @@ const InnovationSchema = z.object({ }) .min(1) .max(3), - banner_image: z - .instanceof(FileListType) - .optional() - .refine((file) => file == null || file?.length == 1, "File is required."), + dashboard_type: z.string().min(1).max(3).optional(), + // banner_image: z + // .instanceof(FileListType) + // .optional() + // .refine((file) => file == null || file?.length == 1, "File is required."), //banner_image dashboard_link: z @@ -66,11 +67,12 @@ const InnovationSchema = z.object({ required_error: "Dashboard Link is required", }) .url(), + dashboard_id: z.string().url().optional(), dashboard_image: z .instanceof(FileListType) .optional() .refine((file) => file == null || file?.length == 1, "File is required."), - dashboard_definition: z + dashboard_definitions: z .instanceof(FileListType) .optional() .refine((file) => file == null || file?.length == 1, "File is required."), @@ -81,7 +83,7 @@ interface Params { id: string; } -const EditInnovationPage = ({ params }: { params: Params }) => { +const InnovationPage = ({ params }: { params: Params }) => { const id = params.id; const { @@ -94,18 +96,19 @@ const EditInnovationPage = ({ params }: { params: Params }) => { title: innovationData?.title, description: innovationData?.description, status: innovationData?.status, + dashboard_type: innovationData?.dashboard_type, dashboard_link: innovationData?.dashboard_link || "", - banner_image: undefined, + // banner_image: undefined, dashboard_image: undefined, - dashboard_definition: undefined, + dashboard_definitions: undefined, }; const form = useForm({ defaultValues: { ...defaultValues, - banner_image: undefined as FileList | undefined, + // banner_image: undefined as FileList | undefined, dashboard_image: undefined as FileList | undefined, - dashboard_definition: undefined as FileList | undefined, + dashboard_definitions: undefined as FileList | undefined, }, resolver: zodResolver(InnovationSchema), }); @@ -114,20 +117,24 @@ const EditInnovationPage = ({ params }: { params: Params }) => { if (innovationData) { form.reset({ ...InnovationSchema.omit({ - banner_image: true, + // banner_image: true, + dashboard_image: true, + dashboard_definitions: true, + dashboard_type: true, status: true, }).parse({ title: innovationData.title, description: innovationData.description, dashboard_link: innovationData.dashboard_link, }), - banner_image: undefined, // or set a default value if needed + // banner_image: undefined, // or set a default value if needed dashboard_image: undefined, - dashboard_definition: undefined, + dashboard_definitions: undefined, }); setTimeout(() => { - form.setValue("status",innovationData.status); + form.setValue("status", innovationData.status); + form.setValue("dashboard_type", innovationData.dashboard_type); }, 0); } }, [innovationData]); @@ -166,7 +173,7 @@ const EditInnovationPage = ({ params }: { params: Params }) => { //

- Create a New Innovation + Edit Innovation

@@ -222,17 +229,45 @@ const EditInnovationPage = ({ params }: { params: Params }) => { ( - Banner image - + Dashboard Type + )} /> + {/* ( + + Banner image + + + + + )} + /> */} + { )} /> + ( + + Dashboard Embed id + + + + + + + )} + /> + ( - Dashboard image + Dashboard image @@ -289,11 +343,11 @@ const EditInnovationPage = ({ params }: { params: Params }) => { ( - Dashboard Definition - + Dashboard Definition + @@ -310,4 +364,4 @@ const EditInnovationPage = ({ params }: { params: Params }) => { ); }; -export default EditInnovationPage; +export default InnovationPage; diff --git a/src/app/dashboard/innovation/new/page.tsx b/src/app/dashboard/innovation/new/page.tsx index a04199e..da7a7ce 100644 --- a/src/app/dashboard/innovation/new/page.tsx +++ b/src/app/dashboard/innovation/new/page.tsx @@ -5,20 +5,20 @@ import { z } from "zod"; // Import Zod import { zodResolver } from "@hookform/resolvers/zod"; import { Button } from "@/components/ui/button"; import { - Form, - FormControl, - FormDescription, - FormField, - FormItem, - FormLabel, - FormMessage, + Form, + FormControl, + FormDescription, + FormField, + FormItem, + FormLabel, + FormMessage, } from "@/components/ui/form"; import { - Select, - SelectContent, - SelectItem, - SelectTrigger, - SelectValue, + Select, + SelectContent, + SelectItem, + SelectTrigger, + SelectValue, } from "@/components/ui/select"; import { Input } from "@/components/ui/input"; import { Textarea } from "@/components/ui/textarea"; @@ -34,126 +34,166 @@ const FileListType = isBrowser ? FileList : Array; //Define the schema for the form const MAX_UPLOAD_SIZE = 1024 * 1024 * 3; // 3MB const InnovationSchema = z.object({ - title: z.string({ - required_error: "Title is required", - }).min(2).max(50), - description: z.string({ - required_error: "Description is required", - }).min(2), - status: z.string({ - required_error: "Status is required", - }).min(1).max(3), - banner_image: z - .instanceof(FileListType) - .optional() - .refine((file) => file == null || file?.length == 1, "File is required."), - - //banner_image - dashboard_link: z.string({ - required_error: "Dashboard Link is required", - }).url(), - dashboard_image: z - .instanceof(FileListType) - .optional() - .refine((file) => file == null || file?.length == 1, "File is required."), - dashboard_definition: z - .instanceof(FileListType) - .optional() - .refine((file) => file == null || file?.length == 1, "File is required."), + title: z + .string({ + required_error: "Title is required", + }) + .min(2) + .max(50), + description: z + .string({ + required_error: "Description is required", + }) + .min(2), + status: z + .string({ + required_error: "Status is required", + }) + .min(1) + .max(3), + dashboard_type: z.string().min(1).max(3).optional(), + // banner_image: z + // .instanceof(FileListType) + // .optional() + // .refine((file) => file == null || file?.length == 1, "File is required."), + + //banner_image + dashboard_link: z + .string({ + required_error: "Dashboard Link is required", + }) + .url(), + dashboard_id: z.string().url().optional(), + dashboard_image: z + .instanceof(FileListType) + .optional() + .refine((file) => file == null || file?.length == 1, "File is required."), + dashboard_definitions: z + .instanceof(FileListType) + .optional() + .refine((file) => file == null || file?.length == 1, "File is required."), }); type Innovation = z.infer; -const CreateInnovationPage = () => { - const router = useRouter(); - - const form = useForm({ - resolver: zodResolver(InnovationSchema), - }); - - const [createInovation, { isLoading }] = useInnovationsCreateMutation(); - - //initialize toast - const { toast } = useToast(); - - //Function that handles submision of validated data - const onSubmit = async (data: Innovation) => { - // Submit the data to your API or perform any other action - createInovation(data) - .unwrap() - .then((response) => { - // toast created successfully - toast({ - title: "Innovation Created successfully", - description: "redirecting you to the home page", - }); - form.reset(); - router.push("/dashboard"); - console.log(response); - }) - .catch((error) => { - console.log(error); - }); - }; - - return ( - // -
-

- Create a New Innovation -

- - - - ( - - Title - - - - - - - )} - /> +const InnovationPage = () => { + const router = useRouter(); - ( - - Status - - - - - )} - /> + const form = useForm({ + resolver: zodResolver(InnovationSchema), + }); + + const [createInovation, { isLoading }] = useInnovationsCreateMutation(); + + //initialize toast + const { toast } = useToast(); + + //Function that handles submision of validated data + const onSubmit = async (data: Innovation) => { + // Submit the data to your API or perform any other action + createInovation(data) + .unwrap() + .then((response) => { + // toast created successfully + toast({ + title: "Innovation Created successfully", + description: "redirecting you to the home page", + }); + form.reset(); + router.push("/dashboard"); + console.log(response); + }) + .catch((error) => { + console.log(error); + }); + }; + + return ( + // +
+

+ Create a New Innovation +

+ + + + ( + + Title + + + + + + + )} + /> - ( + + Status + + + + + )} + /> + + ( + + Dashboard Type + + + + + )} + /> + + {/* ( @@ -164,83 +204,102 @@ const CreateInnovationPage = () => { )} - /> + /> */} - ( - - Description - -