Skip to content

Commit 7e0dc55

Browse files
author
Boopathi
committed
Update MSME dashboard component
1 parent 1b97c7c commit 7e0dc55

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

src/components/views/msme-dashboard.tsx

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,9 @@ const profileFormSchema = z.object({
3939
description: z.string().min(1, "A short description is required"),
4040
details: z.object({
4141
about: z.string().min(1, "About section is required"),
42-
scope: z.array(z.string().min(1, "Scope item cannot be empty")).min(1, "At least one scope item is required"),
42+
scope: z.array(z.object({ value: z.string().min(1, "Scope item cannot be empty")})).min(1, "At least one scope item is required"),
4343
lookingFor: z.string().min(1, "This field is required"),
44-
benefits: z.array(z.string().min(1, "Benefit cannot be empty")).min(1, "At least one benefit is required"),
44+
benefits: z.array(z.object({ value: z.string().min(1, "Benefit cannot be empty")})).min(1, "At least one benefit is required"),
4545
contact: z.object({
4646
name: z.string().min(1, "Contact name is required"),
4747
title: z.string().min(1, "Contact title is required"),
@@ -125,6 +125,11 @@ export default function MsmeDashboardView({ isOpen, onOpenChange, user, authProv
125125
const token = localStorage.getItem('token');
126126
const profileData = {
127127
...data,
128+
details: {
129+
...data.details,
130+
scope: data.details.scope.map(item => item.value),
131+
benefits: data.details.benefits.map(item => item.value),
132+
},
128133
logo: 'https://placehold.co/100x100.png',
129134
hint: 'company building',
130135
};
@@ -306,22 +311,22 @@ export default function MsmeDashboardView({ isOpen, onOpenChange, user, authProv
306311
<h4 className="text-md font-medium mb-2">Scope of Collaboration</h4>
307312
{scopeFields.map((field, index) => (
308313
<div key={field.id} className="flex items-center gap-2 mb-2">
309-
<FormField control={profileForm.control} name={`details.scope.${index}`} render={({ field }) => (<FormItem className="flex-grow"><FormControl><Input placeholder="e.g., E-commerce Strategy" {...field} /></FormControl><FormMessage /></FormItem>)} />
314+
<FormField control={profileForm.control} name={`details.scope.${index}.value`} render={({ field }) => (<FormItem className="flex-grow"><FormControl><Input placeholder="e.g., E-commerce Strategy" {...field} /></FormControl><FormMessage /></FormItem>)} />
310315
<Button type="button" variant="ghost" size="icon" onClick={() => removeScope(index)}><Trash2 className="h-4 w-4 text-destructive"/></Button>
311316
</div>
312317
))}
313-
<Button type="button" variant="outline" size="sm" onClick={() => appendScope('')}><PlusCircle className="mr-2 h-4 w-4" />Add Scope Item</Button>
318+
<Button type="button" variant="outline" size="sm" onClick={() => appendScope({value: ''})}><PlusCircle className="mr-2 h-4 w-4" />Add Scope Item</Button>
314319
</div>
315320

316321
<div>
317322
<h4 className="text-md font-medium mb-2">Benefits of Partnership</h4>
318323
{benefitFields.map((field, index) => (
319324
<div key={field.id} className="flex items-center gap-2 mb-2">
320-
<FormField control={profileForm.control} name={`details.benefits.${index}`} render={({ field }) => (<FormItem className="flex-grow"><FormControl><Input placeholder="e.g., Access to our distribution network" {...field} /></FormControl><FormMessage /></FormItem>)} />
325+
<FormField control={profileForm.control} name={`details.benefits.${index}.value`} render={({ field }) => (<FormItem className="flex-grow"><FormControl><Input placeholder="e.g., Access to our distribution network" {...field} /></FormControl><FormMessage /></FormItem>)} />
321326
<Button type="button" variant="ghost" size="icon" onClick={() => removeBenefit(index)}><Trash2 className="h-4 w-4 text-destructive"/></Button>
322327
</div>
323328
))}
324-
<Button type="button" variant="outline" size="sm" onClick={() => appendBenefit('')}><PlusCircle className="mr-2 h-4 w-4" />Add Benefit</Button>
329+
<Button type="button" variant="outline" size="sm" onClick={() => appendBenefit({value: ''})}><PlusCircle className="mr-2 h-4 w-4" />Add Benefit</Button>
325330
</div>
326331

327332
<Separator />
@@ -413,4 +418,4 @@ const msmeChartConfig = {
413418
},
414419
};
415420

416-
421+

0 commit comments

Comments
 (0)