diff --git a/alimento-nextjs/components/multistepForm/components/formControl.tsx b/alimento-nextjs/components/multistepForm/components/formControl.tsx new file mode 100644 index 0000000..ce96561 --- /dev/null +++ b/alimento-nextjs/components/multistepForm/components/formControl.tsx @@ -0,0 +1,55 @@ +import React from 'react'; + +// Define the type for the props +interface FormControlProps { + type: string; + id: string; + label: string; + placeholder: string; + value: string; + onchange: (e: React.ChangeEvent) => void; + valid: boolean; +} + +const FormControl: React.FC = ({ + type, + id, + label, + placeholder, + value, + onchange, + valid, +}) => { + return ( +
+
+
+ +
+ {valid ? null : ( +
+ +
+ )} +
+ +
+ ); +}; + +export default FormControl; diff --git a/alimento-nextjs/components/multistepForm/components/sidebarConstants.tsx b/alimento-nextjs/components/multistepForm/components/sidebarConstants.tsx index cd48a76..bb2a25a 100644 --- a/alimento-nextjs/components/multistepForm/components/sidebarConstants.tsx +++ b/alimento-nextjs/components/multistepForm/components/sidebarConstants.tsx @@ -11,7 +11,7 @@ export const data = [ }, { id: 3, - step: 'step 4', + step: 'step 3', title: 'select tags', }, ]; diff --git a/alimento-nextjs/components/multistepForm/components/tagSelector.tsx b/alimento-nextjs/components/multistepForm/components/tagSelector.tsx new file mode 100644 index 0000000..e506703 --- /dev/null +++ b/alimento-nextjs/components/multistepForm/components/tagSelector.tsx @@ -0,0 +1,66 @@ +import { + Select, + SelectTrigger, + SelectValue, + SelectContent, + SelectItem, + } from "@/components/ui/select"; +import { useGlobalDish } from "@/context/dishFormContext"; + import { Tag } from "@prisma/client"; + import { useState } from "react"; + + const TagSelector = () => { + const tags = Object.values(Tag) + const {dishTags,setDishTags} = useGlobalDish() + + const handleTagSelect = (tag:Tag) => { + if (!dishTags.includes(tag)) { + setDishTags([...dishTags, tag]); + } + }; + + const handleRemoveTag = (tag:Tag) => { + setDishTags(dishTags.filter((t) => t !== tag)); + }; + + return ( +
+
+ +
+ + {/* Selected Tags */} +
+ {dishTags.map((tag) => ( + + {tag} + + + ))} +
+
+ ); + }; + + export default TagSelector; + \ No newline at end of file diff --git a/alimento-nextjs/components/multistepForm/pages/formPage1.tsx b/alimento-nextjs/components/multistepForm/pages/formPage1.tsx new file mode 100644 index 0000000..8b2ab7b --- /dev/null +++ b/alimento-nextjs/components/multistepForm/pages/formPage1.tsx @@ -0,0 +1,81 @@ +import React from 'react'; +import { useGlobalDish } from '@/context/dishFormContext'; +import FormControl from '../components/formControl'; + +const FormPage1 = () => { + const { + dishName, + setDishName, + dishPrice, + setDishPrice, + dishDescription, + setDishDescription, + + validDishName, + setValidDishName, + validDishPrice, + setValidDishPrice, + validDishDescription, + setValidDishDescription, + } = useGlobalDish(); + + const setDishNameLogic = (e: React.ChangeEvent) => { + setDishName(e.target.value); + setValidDishName(e.target.value.length >= 1); + }; + + const setDishDescriptionLogic = ( + e: React.ChangeEvent + ) => { + setDishDescription(e.target.value); + setValidDishDescription(e.target.value.length >= 1); + }; + + const setDishPriceLogic = (e: React.ChangeEvent) => { + setDishPrice(Number(e.target.value)); + setValidDishPrice(e.target.value.length >= 1); + }; + + return ( +
+

+ Dish Info +

+

+ Please provide your Dish name, description and price +

+ +
+ + + +
+
+ ); +}; + +export default FormPage1; diff --git a/alimento-nextjs/components/multistepForm/pages/formPage2.tsx b/alimento-nextjs/components/multistepForm/pages/formPage2.tsx new file mode 100644 index 0000000..89cdd7f --- /dev/null +++ b/alimento-nextjs/components/multistepForm/pages/formPage2.tsx @@ -0,0 +1,47 @@ +import { + DropdownMenu, + DropdownMenuContent, + DropdownMenuItem, + DropdownMenuLabel, + DropdownMenuSeparator, + DropdownMenuTrigger, + } from '@/components/ui/dropdown-menu'; +import { useGlobalDish } from '@/context/dishFormContext'; +import { Category, Prisma } from '@prisma/client'; + import { ChevronDown } from 'lucide-react'; + + const categories =Object.values(Category) + + const FormPage2 = () => { + const { dishCategory,setDishCategory } = useGlobalDish(); + + return ( +
+

+ Select Category +

+

+ Please select the most appropriate category for your dish +

+ + + {dishCategory || 'Category'} + + + + Select the Category for your dish + + + {categories.map((category)=>( + setDishCategory(category)}> + {category} + + ))} + + +
+ ); + }; + + export default FormPage2; + \ No newline at end of file diff --git a/alimento-nextjs/components/multistepForm/pages/formPage3.tsx b/alimento-nextjs/components/multistepForm/pages/formPage3.tsx new file mode 100644 index 0000000..a7bf4e4 --- /dev/null +++ b/alimento-nextjs/components/multistepForm/pages/formPage3.tsx @@ -0,0 +1,19 @@ +import TagSelector from '../components/tagSelector'; + + const FormPage3 = () => { + + return ( +
+

+ Select Tags +

+

+ Please select the most appropriate tags for your dish +

+ +
+ ); + }; + + export default FormPage3; + \ No newline at end of file diff --git a/alimento-nextjs/components/multistepForm/pages/main.tsx b/alimento-nextjs/components/multistepForm/pages/main.tsx index 560c430..194431a 100644 --- a/alimento-nextjs/components/multistepForm/pages/main.tsx +++ b/alimento-nextjs/components/multistepForm/pages/main.tsx @@ -2,8 +2,11 @@ import { useGlobalDish } from '@/context/dishFormContext'; import { MouseEventHandler, useEffect } from 'react'; import { Toaster } from 'react-hot-toast'; +import FormPage1 from './formPage1'; +import FormPage2 from './formPage2'; +import TagSelector from './formPage3'; -const Main = ({ sellerId }: { sellerId: string }) => { +const Main = ({ VendorId }: { VendorId: string }) => { const { dishName, @@ -19,6 +22,8 @@ const Main = ({ sellerId }: { sellerId: string }) => { formCompleted, completed, setCompleted, + + submitListingForm } = useGlobalDish(); // Use useEffect to update completed based on currentStep @@ -70,7 +75,9 @@ const Main = ({ sellerId }: { sellerId: string }) => {
- {currentStep === 1 && < div> The Forms will go Here
} + {currentStep === 1 && } + {currentStep === 2 && } + {currentStep === 3 && } {!formCompleted && (