diff --git a/apps/edr-freight-web/portal/src/pages/SettingsPage.tsx b/apps/edr-freight-web/portal/src/pages/SettingsPage.tsx index 71f9f7bc9..50d55f478 100644 --- a/apps/edr-freight-web/portal/src/pages/SettingsPage.tsx +++ b/apps/edr-freight-web/portal/src/pages/SettingsPage.tsx @@ -1,12 +1,27 @@ import { useSearchParams } from "react-router-dom"; import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query"; +import { + Container, + Group, + Stack, + Title, + Text, + Tabs, + Card, + TextInput, + Button, + Badge, + Alert, + Center, + Loader, + Grid, +} from "@mantine/core"; import { AlertCircle, Building2, Briefcase, CheckCircle2, FileCheck, - Loader2, Save, User, UserCheck, @@ -16,43 +31,22 @@ import { useForm } from "react-hook-form"; import { zodResolver } from "@hookform/resolvers/zod"; import { z } from "zod"; import { api } from "@/services/api"; -import { - Badge, - Button, - Card, - CardContent, - CardDescription, - CardFooter, - CardHeader, - CardTitle, - Field, - FieldError, - FieldGroup, - FieldLabel, - Input, -} from "@edr/ui-common"; -import { cn } from "@/lib/utils"; -import PhoneInput from "@/components/auth/PhoneInput"; import type { CreateCompanyPayload } from "@/services/companies.service"; +import PhoneInput from "@/components/auth/PhoneInput"; import TabCompanyProfile from "./settings/TabCompanyProfile"; import TabContactPerson from "./settings/TabContactPerson"; import TabGeneralManager from "./settings/TabGeneralManager"; import TabPowerOfAttorney from "./settings/TabPowerOfAttorney"; import TabDocuments from "./settings/TabDocuments"; -type SettingsTab = - | "company" - | "contact" - | "gm" - | "poa" - | "documents"; +type SettingsTab = "company" | "contact" | "gm" | "poa" | "documents"; const TABS: { id: SettingsTab; label: string; icon: React.ReactNode }[] = [ - { id: "company", label: "Company Profile", icon: }, - { id: "contact", label: "Contact Person", icon: }, - { id: "gm", label: "General Manager", icon: }, - { id: "poa", label: "Power of Attorney", icon: }, - { id: "documents", label: "Documents", icon: }, + { id: "company", label: "Company Profile", icon: }, + { id: "contact", label: "Contact Person", icon: }, + { id: "gm", label: "General Manager", icon: }, + { id: "poa", label: "Power of Attorney", icon: }, + { id: "documents", label: "Documents", icon: }, ]; export default function SettingsPage() { @@ -60,16 +54,17 @@ export default function SettingsPage() { const [searchParams, setSearchParams] = useSearchParams(); const tab = (searchParams.get("tab") as SettingsTab) || "company"; const setTab = (t: SettingsTab) => { - setSearchParams((prev) => { - const next = new URLSearchParams(prev); - next.set("tab", t); - return next; - }, { replace: true }); + setSearchParams( + (prev) => { + const next = new URLSearchParams(prev); + next.set("tab", t); + return next; + }, + { replace: true }, + ); }; - const profileQuery = useQuery( - api.companies.getProfile.queryOptions(), - ); + const profileQuery = useQuery(api.companies.getProfile.queryOptions()); const profile = profileQuery.data; @@ -123,93 +118,80 @@ export default function SettingsPage() { if (profileQuery.isPending) { return ( -
-
-
+
+ +
); } return ( -
-
+ +
-

+ Account Settings - </h1> - <p className="mt-1 text-sm text-muted-foreground"> + + Manage your company profile, personnel, and documents -

+

- {profile && ( - - Verified - - )} -
+ {profile && Verified} + - {/* Tab Bar */} -
- {TABS.map((t) => ( - - ))} -
+ { + if (!value) return; + if (!profile && value !== "company") return; + setTab(value as SettingsTab); + }} + > + + {TABS.map((t) => ( + + {t.label} + + ))} + - {/* Tab Content */} - {!profile ? ( - <> - {tab === "company" ? ( - - - - - Company Profile - - + + {!profile ? ( + + + + + Company Profile + + Enter your company registration details to get started - - + + +
- - - - Company Name - + + + + + - - - -
- - Company Email - - - - + + -
+ + -
- - Location - - - + + + + + + + + - - Address - - - -
+ + + + + + + + + -
- - TIN Number (10 digits) - - - - - - FAN Number (16 digits) - - - -
-
-
- -
+ + {createCompanyMutation.isSuccess && ( - - - Profile created successfully - + + + + Profile created successfully + + )} {createCompanyMutation.isError && ( - - - Failed to create profile - - )} -
- -
+
) : ( - - -
- -

- Please complete the company profile first. -

-
-
+ + )} + + + + {profile ? ( + + ) : ( + +
+ } + color="gray" + variant="light" + > + Please complete the company profile first. + +
)} - - ) : ( - <> - {tab === "company" && } - {tab === "contact" && } - {tab === "gm" && } - {tab === "poa" && } - {tab === "documents" && } - - )} -
+ + + + {profile ? ( + + ) : ( + +
+ } + color="gray" + variant="light" + > + Please complete the company profile first. + +
+
+ )} +
+ + + {profile ? ( + + ) : ( + +
+ } + color="gray" + variant="light" + > + Please complete the company profile first. + +
+
+ )} +
+ + + {profile ? ( + + ) : ( + +
+ } + color="gray" + variant="light" + > + Please complete the company profile first. + +
+
+ )} +
+ + ); } -// \ No newline at end of file diff --git a/apps/edr-freight-web/portal/src/pages/settings/TabCompanyProfile.tsx b/apps/edr-freight-web/portal/src/pages/settings/TabCompanyProfile.tsx index b64419565..0ba3d99a2 100644 --- a/apps/edr-freight-web/portal/src/pages/settings/TabCompanyProfile.tsx +++ b/apps/edr-freight-web/portal/src/pages/settings/TabCompanyProfile.tsx @@ -3,23 +3,19 @@ import { useMutation, useQueryClient } from "@tanstack/react-query"; import { useForm } from "react-hook-form"; import { zodResolver } from "@hookform/resolvers/zod"; import { z } from "zod"; -import { Building2, CheckCircle2, Loader2, Save, XCircle } from "lucide-react"; -import { api } from "@/services/api"; -import PhoneInput from "@/components/auth/PhoneInput"; +import { Building2, CheckCircle2, Save, XCircle } from "lucide-react"; import { Card, - CardHeader, - CardTitle, - CardDescription, - CardContent, - CardFooter, + Group, + Stack, + Title, + Text, + TextInput, Button, - Input, - Field, - FieldLabel, - FieldError, - FieldGroup, -} from "@edr/ui-common"; + Grid, +} from "@mantine/core"; +import { api } from "@/services/api"; +import PhoneInput from "@/components/auth/PhoneInput"; import type { ProfileResponse } from "@/types/profile"; const schema = z.object({ @@ -88,114 +84,107 @@ export default function TabCompanyProfile({ profile }: { profile: ProfileRespons const onSubmit = (data: FormData) => mutation.mutate(data); return ( - - - - - Company Profile - - Edit your company registration details - + + + + Company Profile + + + Edit your company registration details + +
- - - - Company Name - + + + + + - - - -
- - Company Email - - - - + + -
+ + -
- - Location - - - + + + + + + + + - - Address - - - -
+ + + + + + + + + -
- - TIN Number (10 digits) - - - - - - FAN Number (16 digits) - - - -
-
-
- -
+ + {mutation.isSuccess && ( - - - Saved successfully - + + + Saved successfully + )} {mutation.isError && ( - - - Save failed - + + + Save failed + )} -
-
+ + - -
-
+ +
); diff --git a/apps/edr-freight-web/portal/src/pages/settings/TabContactPerson.tsx b/apps/edr-freight-web/portal/src/pages/settings/TabContactPerson.tsx index bb2401be8..837307a87 100644 --- a/apps/edr-freight-web/portal/src/pages/settings/TabContactPerson.tsx +++ b/apps/edr-freight-web/portal/src/pages/settings/TabContactPerson.tsx @@ -3,23 +3,18 @@ import { useMutation, useQueryClient } from "@tanstack/react-query"; import { useForm } from "react-hook-form"; import { zodResolver } from "@hookform/resolvers/zod"; import { z } from "zod"; -import { CheckCircle2, Loader2, Save, User, XCircle } from "lucide-react"; -import { api } from "@/services/api"; -import PhoneInput from "@/components/auth/PhoneInput"; +import { CheckCircle2, Save, User, XCircle } from "lucide-react"; import { Card, - CardHeader, - CardTitle, - CardDescription, - CardContent, - CardFooter, + Group, + Stack, + Title, + Text, + TextInput, Button, - Input, - Field, - FieldLabel, - FieldError, - FieldGroup, -} from "@edr/ui-common"; +} from "@mantine/core"; +import { api } from "@/services/api"; +import PhoneInput from "@/components/auth/PhoneInput"; import type { ProfileResponse } from "@/types/profile"; const schema = z.object({ @@ -73,55 +68,54 @@ export default function TabContactPerson({ profile }: { profile: ProfileResponse const onSubmit = (data: FormData) => mutation.mutate(data); return ( - - - - - Contact Person - - Manage the primary contact person for your account - -
- - - - Full Name - - - + + + + Contact Person + + + Manage the primary contact person for your account + - - - - -
+ + + + + + + + + {mutation.isSuccess && ( - - - Saved successfully - + + + Saved successfully + )} {mutation.isError && ( - - - Save failed - + + + Save failed + )} -
-
+ + - -
-
+ +
); diff --git a/apps/edr-freight-web/portal/src/pages/settings/TabDocuments.tsx b/apps/edr-freight-web/portal/src/pages/settings/TabDocuments.tsx index 298f7ad7c..e9b458060 100644 --- a/apps/edr-freight-web/portal/src/pages/settings/TabDocuments.tsx +++ b/apps/edr-freight-web/portal/src/pages/settings/TabDocuments.tsx @@ -7,17 +7,17 @@ import { UploadCloud, XCircle, } from "lucide-react"; -import { api } from "@/services/api"; -import { companiesService } from "@/services/companies.service"; import { Card, - CardHeader, - CardTitle, - CardDescription, - CardContent, + Group, + Title, + Text, Button, - SmartFileInput, -} from "@edr/ui-common"; + Center, +} from "@mantine/core"; +import { api } from "@/services/api"; +import { companiesService } from "@/services/companies.service"; +import { SmartFileInput } from "@edr/ui-common"; import type { ProfileResponse } from "@/types/profile"; export default function TabDocuments({ profile }: { profile: ProfileResponse }) { @@ -39,69 +39,62 @@ export default function TabDocuments({ profile }: { profile: ProfileResponse }) }); return ( - - - - - Documents - - - Upload and manage required business documents - - - - {docSettingQuery.isLoading ? ( -
- -
- ) : !docSettingQuery.data ? ( -

- No document requirements configured for your account. -

- ) : ( - - )} + + + + Documents + + + Upload and manage required business documents + - {docSettingQuery.data && ( -
-
- {docUploadMutation.isSuccess && ( - - - Documents uploaded successfully - - )} - {docUploadMutation.isError && ( - - - Upload failed - - )} -
- -
- )} -
+ {docSettingQuery.isLoading ? ( +
+ +
+ ) : !docSettingQuery.data ? ( + + No document requirements configured for your account. + + ) : ( + + )} + + {docSettingQuery.data && ( + + + {docUploadMutation.isSuccess && ( + + + Documents uploaded successfully + + )} + {docUploadMutation.isError && ( + + + Upload failed + + )} + + + + )}
); } diff --git a/apps/edr-freight-web/portal/src/pages/settings/TabGeneralManager.tsx b/apps/edr-freight-web/portal/src/pages/settings/TabGeneralManager.tsx index 7c7f0d4d3..84f365d5d 100644 --- a/apps/edr-freight-web/portal/src/pages/settings/TabGeneralManager.tsx +++ b/apps/edr-freight-web/portal/src/pages/settings/TabGeneralManager.tsx @@ -3,23 +3,19 @@ import { useMutation, useQueryClient } from "@tanstack/react-query"; import { useForm } from "react-hook-form"; import { zodResolver } from "@hookform/resolvers/zod"; import { z } from "zod"; -import { Briefcase, CheckCircle2, Loader2, Save, XCircle } from "lucide-react"; -import { api } from "@/services/api"; -import PhoneInput from "@/components/auth/PhoneInput"; +import { Briefcase, CheckCircle2, Save, XCircle } from "lucide-react"; import { Card, - CardHeader, - CardTitle, - CardDescription, - CardContent, - CardFooter, + Group, + Stack, + Title, + Text, + TextInput, Button, - Input, - Field, - FieldLabel, - FieldError, - FieldGroup, -} from "@edr/ui-common"; + Grid, +} from "@mantine/core"; +import { api } from "@/services/api"; +import PhoneInput from "@/components/auth/PhoneInput"; import type { ProfileResponse } from "@/types/profile"; const schema = z.object({ @@ -76,68 +72,67 @@ export default function TabGeneralManager({ profile }: { profile: ProfileRespons const onSubmit = (data: FormData) => mutation.mutate(data); return ( - - - - - General Manager - - Manage the general manager information - + + + + General Manager + + + Manage the general manager information + +
- - - - Full Name - + + + + + - - - -
- - Email Address - - - - + + -
-
-
- -
+ + + + + + {mutation.isSuccess && ( - - - Saved successfully - + + + Saved successfully + )} {mutation.isError && ( - - - Save failed - + + + Save failed + )} -
-
+ + - -
-
+ +
); diff --git a/apps/edr-freight-web/portal/src/pages/settings/TabPowerOfAttorney.tsx b/apps/edr-freight-web/portal/src/pages/settings/TabPowerOfAttorney.tsx index e5d977e2d..00ecbfdf6 100644 --- a/apps/edr-freight-web/portal/src/pages/settings/TabPowerOfAttorney.tsx +++ b/apps/edr-freight-web/portal/src/pages/settings/TabPowerOfAttorney.tsx @@ -4,22 +4,18 @@ import { useForm } from "react-hook-form"; import { zodResolver } from "@hookform/resolvers/zod"; import { z } from "zod"; import { CheckCircle2, Loader2, Save, UserCheck, XCircle } from "lucide-react"; -import { api } from "@/services/api"; -import PhoneInput from "@/components/auth/PhoneInput"; import { Card, - CardHeader, - CardTitle, - CardDescription, - CardContent, - CardFooter, + Group, + Stack, + Title, + Text, + TextInput, Button, - Input, - Field, - FieldLabel, - FieldError, - FieldGroup, -} from "@edr/ui-common"; + Grid, +} from "@mantine/core"; +import { api } from "@/services/api"; +import PhoneInput from "@/components/auth/PhoneInput"; import type { ProfileResponse } from "@/types/profile"; const schema = z.object({ @@ -66,7 +62,6 @@ export default function TabPowerOfAttorney({ formState: { errors, isDirty }, } = useForm({ resolver: zodResolver(schema), - values: defaultValues, }); @@ -92,47 +87,41 @@ export default function TabPowerOfAttorney({ const onSubmit = (data: FormData) => mutation.mutate(data); return ( - - - - - Power of Attorney - - - Power of Attorney details are optional. Fill them in if you have an - authorized representative, or leave blank. - - + + + + Power of Attorney + + + Power of Attorney details are optional. Fill them in if you have an + authorized representative, or leave blank. + +
- - -

- Power of Attorney details are optional. Fill them in if you have - an authorized representative, or leave blank. -

+ + + Power of Attorney details are optional. Fill them in if you have + an authorized representative, or leave blank. + - - PoA Full Name - + + + + - - - -
- - PoA Email - - - - + + -
+ + -
- - PoA Location - - - + + + + + + + + + - - PoA Address - - - -
-
-
- -
+ + {mutation.isSuccess && ( - - - Saved successfully - + + + Saved successfully + )} {mutation.isError && ( - - - Save failed - + + + Save failed + )} -
-
+ + - -
-
+ +
);