Skip to content

Commit 3e390f5

Browse files
committed
refactor(wizard-implementation): streamline onboarding update logic and enhance UI components
- Replaced separate onboarding creation and update calls with a single upsert operation for efficiency. - Updated the CompanyDetailsWizardForm to improve layout with Card components and adjusted input fields for better user experience. - Enhanced WizardQuestion and WizardStepper components for improved styling and responsiveness. - Refined TrustPortalSwitch component by adding descriptions for compliance frameworks and optimizing layout. - Updated input and select components for better prefix handling and visual consistency.
1 parent 6f18606 commit 3e390f5

File tree

7 files changed

+126
-128
lines changed

7 files changed

+126
-128
lines changed

apps/app/src/app/[locale]/(app)/(dashboard)/[orgId]/implementation/wizard/[wizardId]/actions/updateWizard.ts

Lines changed: 18 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -53,31 +53,26 @@ export const updateWizard = async ({
5353
where: { organizationId: orgId },
5454
});
5555

56-
if (!onboarding) {
57-
await db.onboarding.create({
58-
data: {
59-
organizationId: orgId,
60-
[dbColumn]: {
61-
version: parsed.version || companyDetailsLatestVersion,
62-
isCompleted: parsed.isCompleted,
63-
data: parsed.data,
64-
},
56+
await db.onboarding.upsert({
57+
where: {
58+
organizationId: orgId,
59+
},
60+
create: {
61+
organizationId: orgId,
62+
[dbColumn]: {
63+
version: parsed.version || companyDetailsLatestVersion,
64+
isCompleted: parsed.isCompleted,
65+
data: parsed.data,
6566
},
66-
});
67-
} else {
68-
await db.onboarding.update({
69-
where: {
70-
organizationId: orgId,
67+
},
68+
update: {
69+
[dbColumn]: {
70+
version: parsed.version || companyDetailsLatestVersion,
71+
isCompleted: parsed.isCompleted,
72+
data: parsed.data,
7173
},
72-
data: {
73-
[dbColumn]: {
74-
version: parsed.version || companyDetailsLatestVersion,
75-
isCompleted: parsed.isCompleted,
76-
data: parsed.data,
77-
},
78-
},
79-
});
80-
}
74+
},
75+
});
8176

8277
revalidatePath(`/${orgId}/implementation/wizard/${wizardId}`);
8378

apps/app/src/app/[locale]/(app)/(dashboard)/[orgId]/implementation/wizard/[wizardId]/components/CompanyDetailsWizardForm.tsx

Lines changed: 24 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,7 @@ import {
2929
SelectValue,
3030
} from "@comp/ui/select";
3131
import { useParams, useRouter } from "next/navigation";
32-
import {
33-
Breadcrumb,
34-
BreadcrumbItem,
35-
BreadcrumbLink,
36-
BreadcrumbPage,
37-
BreadcrumbSeparator,
38-
} from "@comp/ui/breadcrumb";
39-
import PageWithBreadcrumb from "@/components/pages/PageWithBreadcrumb";
32+
import { Card, CardContent, CardHeader, CardTitle } from "@comp/ui/card";
4033

4134
const steps = [
4235
"Company identity",
@@ -220,14 +213,14 @@ export const CompanyDetailsWizardForm = ({
220213
return (
221214
<div className="flex flex-col gap-2">
222215
<Label htmlFor="companyWebsite">
223-
Public website URL
216+
Website
224217
</Label>
225218
<Input
226219
id="companyWebsite"
227-
type="url"
228220
value={displayValue}
229221
onChange={handleChange}
230222
placeholder="acme.com"
223+
prefix="https://"
231224
/>
232225
{errors.companyWebsite && (
233226
<span className="text-destructive text-sm">
@@ -274,9 +267,9 @@ export const CompanyDetailsWizardForm = ({
274267
);
275268
return found
276269
? {
277-
value: found.value,
278-
label: found.label,
279-
}
270+
value: found.value,
271+
label: found.label,
272+
}
280273
: { value: v, label: v };
281274
})}
282275
placeholder="Select or add one..."
@@ -592,16 +585,24 @@ export const CompanyDetailsWizardForm = ({
592585
}
593586
}}
594587
>
595-
<WizardStepper steps={steps} currentStep={step} />
596-
<WizardQuestion
597-
step={step}
598-
totalSteps={steps.length}
599-
question={questionNodes[step]}
600-
onNext={handleNext}
601-
onBack={handleBack}
602-
nextDisabled={false}
603-
showBack={step > 0}
604-
/>
588+
<Card>
589+
<CardHeader>
590+
<CardTitle>
591+
<WizardStepper steps={steps} currentStep={step} />
592+
</CardTitle>
593+
</CardHeader>
594+
<CardContent>
595+
<WizardQuestion
596+
step={step}
597+
totalSteps={steps.length}
598+
question={questionNodes[step]}
599+
onNext={handleNext}
600+
onBack={handleBack}
601+
nextDisabled={false}
602+
showBack={step > 0}
603+
/>
604+
</CardContent>
605+
</Card>
605606
</form>
606607
</FormProvider>
607608
);

apps/app/src/app/[locale]/(app)/(dashboard)/[orgId]/implementation/wizard/[wizardId]/components/WizardQuestion.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ export function WizardQuestion({
3535
</Button>
3636
)}
3737
</div>
38-
<div className="flex-1 flex justify-center">
39-
<span className="text-muted-foreground text-sm select-none">
38+
<div className="flex items-center justify-center">
39+
<span className="text-muted-foreground text-xs select-none">
4040
Step {step + 1} / {totalSteps}
4141
</span>
4242
</div>

apps/app/src/app/[locale]/(app)/(dashboard)/[orgId]/implementation/wizard/[wizardId]/components/WizardStepper.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ interface WizardStepperProps {
77

88
export function WizardStepper({ steps, currentStep }: WizardStepperProps) {
99
return (
10-
<div className="mb-8">
11-
<div className="text-3xl font-semibold">{steps[currentStep]}</div>
12-
</div>
10+
<div>
11+
<div>{steps[currentStep]}</div>
12+
</div >
1313
);
1414
}

0 commit comments

Comments
 (0)