@@ -3,6 +3,10 @@ import { ChevronRight } from "lucide-react";
33import React , { useState } from "react" ;
44import { set , useForm } from "react-hook-form" ;
55import ImagePlaceHolder from "../../../shared/components/image-placeholder" ;
6+ import Input from "packages/components/input" ;
7+ import ColorSelector from "packages/components/color-selector" ;
8+ import CustomSpecifications from "packages/components/custom-specifications" ;
9+ import CustomProperties from "packages/components/custom-properties" ;
610
711const CreateProduct = ( ) => {
812 const {
@@ -74,27 +78,144 @@ const CreateProduct = () => {
7478 onRemove = { handleRemoveImage }
7579 />
7680 ) }
81+ < div className = "grid grid-cols-2 gap-3 mt-4 " >
82+ { images . slice ( 1 ) . map ( ( _ , index ) => (
83+ < ImagePlaceHolder
84+ key = { index + 1 }
85+ setOpenImageModal = { setOpenImageModal }
86+ size = "150 x 150"
87+ small = { true }
88+ index = { index + 1 }
89+ onImageChange = { handleImageChange }
90+ onRemove = { handleRemoveImage }
91+ />
92+ ) ) }
93+ </ div >
7794 </ div >
7895
79- < div className = "grid grid-cols-2 gap-3 mt-4 " >
80- { images . slice ( 1 ) . map ( ( _ , index ) => (
81- < ImagePlaceHolder
82- key = { index + 1 }
83- setOpenImageModal = { setOpenImageModal }
84- size = "150 x 150"
85- small = { true }
86- index = { index + 1 }
87- onImageChange = { handleImageChange }
88- onRemove = { handleRemoveImage }
89- />
90- ) ) }
91- </ div >
92- </ div >
93- { /* Right Side - Form Input */ }
94- < div className = "md:w-[65%]" >
95- < div className = "w-full flex gap-6" >
96- { /* Product Title Input */ }
97- < div className = "w-2/4" > </ div >
96+ { /* Right Side - Form Input */ }
97+ < div className = "md:w-[65%]" >
98+ < div className = "w-full flex gap-6" >
99+ { /* Product Title Input */ }
100+ < div className = "w-2/4" >
101+ < Input
102+ label = "Product Title *"
103+ placeholder = "Enter product title"
104+ { ...register ( "title" , { required : "Title is required" } ) }
105+ />
106+ { errors . title && (
107+ < p className = "text-red-500 text-xs mt-1" >
108+ { errors . title . message as string }
109+ </ p >
110+ ) }
111+ < div className = "mt-2" >
112+ < Input
113+ type = "textarea"
114+ rows = { 7 }
115+ cols = { 10 }
116+ label = "Product Description * (max 150 words)"
117+ placeholder = "Enter product description"
118+ { ...register ( "description" , {
119+ required : "Description is required" ,
120+ validate : ( value ) => {
121+ const wordCount = value . trim ( ) . split ( / \s + / ) . length ;
122+ return (
123+ wordCount <= 150 ||
124+ `Description must be less than 150 words (Currently ${ wordCount } words)`
125+ ) ;
126+ } ,
127+ } ) }
128+ />
129+ { errors . description && (
130+ < p className = "text-red-500 text-xs mt-1" >
131+ { errors . description . message as string }
132+ </ p >
133+ ) }
134+ </ div >
135+ { /* Tags */ }
136+ < div className = "mt-2" >
137+ < Input
138+ label = "Tags *"
139+ placeholder = "Apple, Flagship, iPhone"
140+ { ...register ( "tags" , {
141+ required : "separate related product tags with commas , " ,
142+ } ) }
143+ />
144+ { errors . tags && (
145+ < p className = "text-red-500 text-xs mt-1" >
146+ { errors . tags . message as string }
147+ </ p >
148+ ) }
149+ </ div >
150+ { /* Warranty */ }
151+ < div className = "mt-2" >
152+ < Input
153+ label = "Warranty *"
154+ placeholder = "1year / No Warranty"
155+ { ...register ( "warranty" , {
156+ required : "Warranty is required" ,
157+ } ) }
158+ />
159+ { errors . warranty && (
160+ < p className = "text-red-500 text-xs mt-1" >
161+ { errors . warranty . message as string }
162+ </ p >
163+ ) }
164+ </ div >
165+ { /* Slug */ }
166+ < div className = "mt-2" >
167+ < Input
168+ label = "Slug *"
169+ placeholder = "product-slug-example"
170+ { ...register ( "slug" , {
171+ required : "Slug is required" ,
172+ pattern : {
173+ value : / ^ [ a - z 0 - 9 ] + (?: - [ a - z 0 - 9 ] + ) * $ / ,
174+ message :
175+ "Slug can only contain lowercase letters, numbers, and hyphens" ,
176+ } ,
177+ minLength : {
178+ value : 3 ,
179+ message : "Slug must be at least 3 characters long" ,
180+ } ,
181+ maxLength : {
182+ value : 50 ,
183+ message : "Slug cannot exceed 50 characters" ,
184+ } ,
185+ } ) }
186+ />
187+ { errors . slug && (
188+ < p className = "text-red-500 text-xs mt-1" >
189+ { errors . slug . message as string }
190+ </ p >
191+ ) }
192+ </ div >
193+ { /* Brand */ }
194+ < div className = "mt-2" >
195+ < Input
196+ label = "Brand"
197+ placeholder = "Apple, Samsung, Xiaomi"
198+ { ...register ( "brand" ) }
199+ />
200+ { errors . brand && (
201+ < p className = "text-red-500 text-xs mt-1" >
202+ { errors . brand . message as string }
203+ </ p >
204+ ) }
205+ </ div >
206+ < div className = "mt-2" >
207+ < ColorSelector control = { control } errors = { errors } />
208+ </ div >
209+
210+ < div className = "mt-2" >
211+ < CustomSpecifications control = { control } errors = { errors } />
212+ </ div >
213+
214+ < div className = "mt-2" >
215+ < CustomProperties control = { control } errors = { errors } />
216+ </ div >
217+ </ div >
218+ </ div >
98219 </ div >
99220 </ div >
100221 </ form >
0 commit comments