diff --git a/apps/edr-freight-web/portal/src/pages/MyPortalPage/components/SetupPrompt.tsx b/apps/edr-freight-web/portal/src/pages/MyPortalPage/components/SetupPrompt.tsx index cb29865e2..adb3c65ef 100644 --- a/apps/edr-freight-web/portal/src/pages/MyPortalPage/components/SetupPrompt.tsx +++ b/apps/edr-freight-web/portal/src/pages/MyPortalPage/components/SetupPrompt.tsx @@ -1,31 +1,61 @@ import { Box, Group, Text } from "@mantine/core"; -import { ArrowRight, Truck } from "lucide-react"; +import { useQuery } from "@tanstack/react-query"; +import { ArrowRight, Truck, AlertTriangle } from "lucide-react"; import { memo } from "react"; import { Link } from "react-router-dom"; +import { api } from "@/services/api"; +import type { ProfileResponse } from "@/types/profile"; import { cv } from "../constants"; +const REQUIRED_FIELDS: (keyof ProfileResponse)[] = [ + "companyEmail", + "companyPhone", + "companyAddress", + "fanNumber", + "contactPersonName", + "contactPersonPhone", + "generalManagerName", + "generalManagerEmail", + "generalManagerPhone", +]; + +function isProfileIncomplete(profile?: ProfileResponse | null): boolean { + if (!profile) return true; + return REQUIRED_FIELDS.some((field) => !profile[field]); +} + interface SetupPromptProps { show: boolean; } export const SetupPrompt = memo(function SetupPrompt({ show }: SetupPromptProps) { - if (!show) return null; + const profileQuery = useQuery( + api.companies.getProfile.queryOptions({ retry: false }), + ); + + const incomplete = !profileQuery.isPending && isProfileIncomplete(profileQuery.data); + + if (!show && !incomplete) return null; return ( - - Setup your Company Profile - + + {incomplete && } + + {incomplete ? "Complete Your Profile" : "Setup your Company Profile"} + + - Complete your company information to unlock all features and start - booking shipments. + {incomplete + ? "Your company profile is incomplete. Fill in the missing details to unlock all features." + : "Complete your company information to unlock all features and start booking shipments."} - Complete Setup + {incomplete ? "Complete Profile" : "Complete Setup"} diff --git a/apps/edr-freight-web/portal/src/pages/MyPortalPage/components/StatsSection.tsx b/apps/edr-freight-web/portal/src/pages/MyPortalPage/components/StatsSection.tsx index 006907eeb..8a0545fb7 100644 --- a/apps/edr-freight-web/portal/src/pages/MyPortalPage/components/StatsSection.tsx +++ b/apps/edr-freight-web/portal/src/pages/MyPortalPage/components/StatsSection.tsx @@ -1,10 +1,5 @@ -import { Box, SimpleGrid } from "@mantine/core"; -import { - CheckCircle2, - Clock3, - Truck, - Wallet, -} from "lucide-react"; +import { SimpleGrid } from "@mantine/core"; +import { CheckCircle2, Clock3, Truck, Wallet } from "lucide-react"; import { memo } from "react"; import { formatCurrency } from "@/pages/billing/invoices.mock"; import { formatPct } from "../constants"; @@ -34,7 +29,6 @@ export const StatsSection = memo(function StatsSection({ completionRate, spendYtd, spendYtdChangePct, - dashboardLoading, }: StatsSectionProps) { return ( diff --git a/apps/edr-freight-web/portal/src/pages/MyPortalPage/constants.ts b/apps/edr-freight-web/portal/src/pages/MyPortalPage/constants.ts index c08b5e73a..d1231406c 100644 --- a/apps/edr-freight-web/portal/src/pages/MyPortalPage/constants.ts +++ b/apps/edr-freight-web/portal/src/pages/MyPortalPage/constants.ts @@ -9,7 +9,7 @@ import { Wallet, type LucideIcon, } from "lucide-react"; -import type { Currency, InvoiceStatus } from "@/pages/billing/invoices.mock"; +import type { InvoiceStatus } from "@/pages/billing/invoices.mock"; export const cv = (token: string) => { const [name, shade] = token.split("."); @@ -319,12 +319,14 @@ export const STATUS_CONFIG: Record = { }, }; -export const ACTION_PROPS: Record = - { - dark: { bg: "edr-ink", c: "white" }, - amber: { bg: "edr-accent", c: "white" }, - outline: { bg: "edr-card", c: "edr-text", bd: "1px solid edr-border" }, - }; +export const ACTION_PROPS: Record< + string, + { bg: string; c: string; bd?: string } +> = { + dark: { bg: "edr-ink", c: "white" }, + amber: { bg: "edr-accent", c: "white" }, + outline: { bg: "edr-card", c: "edr-text", bd: "1px solid edr-border" }, +}; export const INVOICE_BADGE: Record< InvoiceStatus, diff --git a/apps/edr-freight-web/portal/src/pages/SettingsPage.tsx b/apps/edr-freight-web/portal/src/pages/SettingsPage.tsx index 50d55f478..6f0b17022 100644 --- a/apps/edr-freight-web/portal/src/pages/SettingsPage.tsx +++ b/apps/edr-freight-web/portal/src/pages/SettingsPage.tsx @@ -1,46 +1,51 @@ -import { useSearchParams } from "react-router-dom"; -import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query"; +import { api } from "@/services/api"; +import type { ProfileResponse } from "@/types/profile"; import { + Alert, + Card, + Center, Container, Group, - Stack, - Title, - Text, - Tabs, - Card, - TextInput, - Button, - Badge, - Alert, - Center, Loader, - Grid, + Tabs, + Text, + Title, } from "@mantine/core"; +import { useQuery, useQueryClient } from "@tanstack/react-query"; import { AlertCircle, - Building2, Briefcase, - CheckCircle2, + Building2, FileCheck, - Save, User, UserCheck, - XCircle, } from "lucide-react"; -import { useForm } from "react-hook-form"; -import { zodResolver } from "@hookform/resolvers/zod"; -import { z } from "zod"; -import { api } from "@/services/api"; -import type { CreateCompanyPayload } from "@/services/companies.service"; -import PhoneInput from "@/components/auth/PhoneInput"; +import { useCallback, useEffect, useState } from "react"; +import { useNavigate, useSearchParams } from "react-router-dom"; import TabCompanyProfile from "./settings/TabCompanyProfile"; import TabContactPerson from "./settings/TabContactPerson"; +import TabDocuments from "./settings/TabDocuments"; import TabGeneralManager from "./settings/TabGeneralManager"; import TabPowerOfAttorney from "./settings/TabPowerOfAttorney"; -import TabDocuments from "./settings/TabDocuments"; type SettingsTab = "company" | "contact" | "gm" | "poa" | "documents"; +function tabIncomplete(tabId: SettingsTab, profile?: ProfileResponse | null): boolean { + if (!profile) return false; + switch (tabId) { + case "company": + return !profile.companyEmail || !profile.companyPhone || !profile.companyAddress || !profile.fanNumber; + case "contact": + return !profile.contactPersonName || !profile.contactPersonPhone; + case "gm": + return !profile.generalManagerName || !profile.generalManagerEmail || !profile.generalManagerPhone; + case "poa": + return false; + case "documents": + return false; + } +} + const TABS: { id: SettingsTab; label: string; icon: React.ReactNode }[] = [ { id: "company", label: "Company Profile", icon: }, { id: "contact", label: "Contact Person", icon: }, @@ -50,71 +55,68 @@ const TABS: { id: SettingsTab; label: string; icon: React.ReactNode }[] = [ ]; export default function SettingsPage() { + const navigate = useNavigate(); const queryClient = useQueryClient(); 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 }, - ); - }; + const setTab = useCallback( + (t: SettingsTab) => { + setSearchParams( + (prev) => { + const next = new URLSearchParams(prev); + next.set("tab", t); + return next; + }, + { replace: true }, + ); + }, + [setSearchParams], + ); - const profileQuery = useQuery(api.companies.getProfile.queryOptions()); + const profileQuery = useQuery( + api.companies.getProfile.queryOptions({ + retry: false, + refetchOnWindowFocus: false, + }), + ); const profile = profileQuery.data; - const createCompanyMutation = useMutation({ - mutationFn: (payload: CreateCompanyPayload) => - api.companies.create.call(payload), - onSuccess: () => { + useEffect(() => { + if (profileQuery.dataUpdatedAt > 0) { queryClient.invalidateQueries({ - queryKey: api.companies.getProfile.queryKey(), + queryKey: api.companies.getInfo.queryKey(), }); - }, - }); + } + }, [profileQuery.dataUpdatedAt, queryClient]); - const onboardingSchema = z.object({ - companyName: z.string().min(1, "Company name is required"), - companyEmail: z.string().email("Invalid email address"), - companyPhone: z.string().min(1, "Company phone is required"), - companyPhoneCountryCode: z.string().min(1, "Country code is required"), - companyLocation: z.string().min(1, "Location is required"), - companyAddress: z.string().min(1, "Address is required"), - tinNumber: z.string().length(10, "TIN must be exactly 10 digits"), - fanNumber: z.string().length(16, "FAN must be exactly 16 digits"), - }); + const [isOnboarding, setIsOnboarding] = useState(null); - type OnboardingFormData = z.infer; + useEffect(() => { + if (profileQuery.isFetched && isOnboarding === null) { + setIsOnboarding(!profileQuery.data); + } + }, [profileQuery.isFetched, profileQuery.data, isOnboarding]); - const { - register, - handleSubmit, - formState: { errors }, - } = useForm({ - resolver: zodResolver(onboardingSchema), - defaultValues: { - companyPhoneCountryCode: "+251", - }, - }); + const handleOnboardingSuccess = useCallback(() => { + setTab("contact"); + }, [setTab]); - const onSubmitOnboarding = (data: OnboardingFormData) => { - const payload: CreateCompanyPayload = { - companyType: "customer", - companyName: data.companyName, - companyEmail: data.companyEmail, - companyPhone: `${data.companyPhoneCountryCode}${data.companyPhone}`, - companyLocation: data.companyLocation, - companyAddress: data.companyAddress, - tin: data.tinNumber, - fanNumber: data.fanNumber, - }; - createCompanyMutation.mutate(payload); - }; + const handleContactContinue = useCallback(() => { + setTab("gm"); + }, [setTab]); + + const handleGMContinue = useCallback(() => { + setTab("poa"); + }, [setTab]); + + const handlePOAContinue = useCallback(() => { + setTab("documents"); + }, [setTab]); + + const handleDocumentsContinue = useCallback(() => { + navigate("/portal"); + }, [navigate]); if (profileQuery.isPending) { return ( @@ -124,25 +126,54 @@ export default function SettingsPage() { ); } + const onboarding = isOnboarding === true; + + const renderProfileContent = (children: React.ReactNode) => { + if (onboarding && tab !== "company" && !profile) { + return ( +
+ +
+ ); + } + if (!profile) { + return ( + +
+ } + color="gray" + variant="light" + > + Please complete the company profile first. + +
+
+ ); + } + return children; + }; + return ( - +
- Account Settings + {onboarding ? "Complete Your Profile" : "Account Settings"} - Manage your company profile, personnel, and documents + {onboarding + ? "Set up your company profile, personnel, and documents to get started" + : "Manage your company profile, personnel, and documents"}
- {profile && Verified}
{ if (!value) return; - if (!profile && value !== "company") return; + // if (onboarding) return; setTab(value as SettingsTab); }} > @@ -152,7 +183,12 @@ export default function SettingsPage() { key={t.id} value={t.id} leftSection={t.icon} - disabled={!profile && t.id !== "company"} + disabled={!onboarding && !profile && t.id !== "company"} + rightSection={ + !onboarding && profile && tabIncomplete(t.id, profile) ? ( + + ) : undefined + } > {t.label} @@ -161,201 +197,52 @@ export default function SettingsPage() { {!profile ? ( - - - - - Company Profile - - - Enter your company registration details to get started - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - {createCompanyMutation.isSuccess && ( - - - - Profile created successfully - - - )} - {createCompanyMutation.isError && ( - - - - Failed to create profile - - - )} - - - -
-
+ ) : ( - + )}
- {profile ? ( - - ) : ( - -
- } - color="gray" - variant="light" - > - Please complete the company profile first. - -
-
+ {renderProfileContent( + , )}
- {profile ? ( - - ) : ( - -
- } - color="gray" - variant="light" - > - Please complete the company profile first. - -
-
+ {renderProfileContent( + , )}
- {profile ? ( - - ) : ( - -
- } - color="gray" - variant="light" - > - Please complete the company profile first. - -
-
+ {renderProfileContent( + , )}
- {profile ? ( - - ) : ( - -
- } - color="gray" - variant="light" - > - Please complete the company profile first. - -
-
+ {renderProfileContent( + , )}
diff --git a/apps/edr-freight-web/portal/src/pages/bookings/BookingDetailPage/components/StatusHero.tsx b/apps/edr-freight-web/portal/src/pages/bookings/BookingDetailPage/components/StatusHero.tsx index 2ba282fa2..31bbca748 100644 --- a/apps/edr-freight-web/portal/src/pages/bookings/BookingDetailPage/components/StatusHero.tsx +++ b/apps/edr-freight-web/portal/src/pages/bookings/BookingDetailPage/components/StatusHero.tsx @@ -105,7 +105,6 @@ export function StatusHero({ function ProgressTracker({ current, tone = "green", - negative, }: { current: number; tone?: "green" | "ink"; @@ -114,7 +113,6 @@ function ProgressTracker({ const last = PROGRESS_STAGES.length - 1; const activeFill = tone === "ink" ? "#0C1A2B" : "#0EA371"; const activeRing = tone === "ink" ? "#D9E0E7" : "#BFE8D4"; - const activeSub = tone === "ink" ? "#475569" : "#0A6F4D"; return ( /* Scrollable on mobile so 5 stages never overflow */ diff --git a/apps/edr-freight-web/portal/src/pages/bookings/NewBookingPage.tsx b/apps/edr-freight-web/portal/src/pages/bookings/NewBookingPage.tsx index 6ccf34362..a7b3cab11 100644 --- a/apps/edr-freight-web/portal/src/pages/bookings/NewBookingPage.tsx +++ b/apps/edr-freight-web/portal/src/pages/bookings/NewBookingPage.tsx @@ -16,12 +16,18 @@ import { Title, } from "@mantine/core"; import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query"; -import { AlertCircle, Check, ChevronLeft, ChevronRight, Send, XCircle } from "lucide-react"; +import { + AlertCircle, + Check, + ChevronLeft, + ChevronRight, + Send, + XCircle, +} from "lucide-react"; import { useMemo, useState } from "react"; import { useForm } from "react-hook-form"; import { useNavigate } from "react-router-dom"; import useAuth from "@/hooks/useAuth"; -import type { Freight } from "@/types"; import { BookingFormInputValues, STEPS, @@ -191,8 +197,12 @@ export default function NewBookingPage() { [docValues], ); - const [pricingPhase, setPricingPhase] = useState<"idle" | "generating" | "ready">("idle"); - const [pricingData, setPricingData] = useState(null); + const [pricingPhase, setPricingPhase] = useState< + "idle" | "generating" | "ready" + >("idle"); + const [pricingData, setPricingData] = useState( + null, + ); const [priceBookingId, setPriceBookingId] = useState(null); const [cancelDialogOpen, setCancelDialogOpen] = useState(false); const [cancelReason, setCancelReason] = useState(""); @@ -444,7 +454,9 @@ export default function NewBookingPage() { pricingData={pricingData} onConfirm={() => confirmMutation.mutate()} onContinueLater={ - priceBookingId ? () => navigate(`/bookings/${priceBookingId}`) : undefined + priceBookingId + ? () => navigate(`/bookings/${priceBookingId}`) + : undefined } onAbort={() => setCancelDialogOpen(true)} confirmPending={confirmMutation.isPending} @@ -502,7 +514,9 @@ export default function NewBookingPage() { createMutation.isPending ? undefined : } > - {createMutation.isPending ? "Saving Draft..." : "Save as Draft"} + {createMutation.isPending + ? "Saving Draft..." + : "Save as Draft"} {hasDocuments && ( )}
) : pricingPhase === "generating" ? ( - ) : null} 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 0ba3d99a2..f2ad48f2c 100644 --- a/apps/edr-freight-web/portal/src/pages/settings/TabCompanyProfile.tsx +++ b/apps/edr-freight-web/portal/src/pages/settings/TabCompanyProfile.tsx @@ -17,8 +17,9 @@ import { import { api } from "@/services/api"; import PhoneInput from "@/components/auth/PhoneInput"; import type { ProfileResponse } from "@/types/profile"; +import type { CreateCompanyPayload } from "@/services/companies.service"; -const schema = z.object({ +export const COMPANY_PROFILE_SCHEMA = z.object({ companyName: z.string().min(1, "Company name is required"), companyEmail: z.string().email("Invalid email address"), companyPhone: z.string().min(1, "Company phone is required"), @@ -29,29 +30,52 @@ const schema = z.object({ fanNumber: z.string().length(16, "FAN must be exactly 16 digits"), }); -type FormData = z.infer; +export type CompanyProfileFormData = z.infer; -function splitPhone(fullPhone?: string | null) { +export function splitPhone(fullPhone?: string | null) { if (!fullPhone) return { code: "+251", number: "" }; const match = fullPhone.match(/^(\+\d{1,3})(.*)$/); if (match) return { code: match[1], number: match[2] }; return { code: "+251", number: fullPhone }; } -export default function TabCompanyProfile({ profile }: { profile: ProfileResponse }) { - const queryClient = useQueryClient(); +interface TabCompanyProfileProps { + profile?: ProfileResponse; + mode?: "edit" | "create"; + onCreateSuccess?: () => void; +} - const defaultValues = useMemo((): FormData => { - const phone = splitPhone(profile.companyPhone); +export default function TabCompanyProfile({ + profile, + mode = "edit", + onCreateSuccess, +}: TabCompanyProfileProps) { + const queryClient = useQueryClient(); + const isCreate = mode === "create"; + + const defaultValues = useMemo((): CompanyProfileFormData => { + if (profile) { + const phone = splitPhone(profile.companyPhone); + return { + companyName: profile.companyName, + companyEmail: profile.companyEmail ?? "", + companyPhone: phone.number, + companyPhoneCountryCode: phone.code, + companyLocation: profile.companyLocation, + companyAddress: profile.companyAddress ?? "", + tinNumber: profile.tinNumber, + fanNumber: profile.fanNumber ?? "", + }; + } return { - companyName: profile.companyName, - companyEmail: profile.companyEmail ?? "", - companyPhone: phone.number, - companyPhoneCountryCode: phone.code, - companyLocation: profile.companyLocation, - companyAddress: profile.companyAddress ?? "", - tinNumber: profile.tinNumber, - fanNumber: profile.fanNumber ?? "", + companyName: "", + companyEmail: "", + companyPhone: "", + companyPhoneCountryCode: "+251", + companyLocation: "", + companyAddress: "", + tinNumber: "", + fanNumber: "", }; }, [profile]); @@ -60,14 +84,15 @@ export default function TabCompanyProfile({ profile }: { profile: ProfileRespons handleSubmit, reset, formState: { errors, isDirty }, - } = useForm({ - resolver: zodResolver(schema), + } = useForm({ + resolver: zodResolver(COMPANY_PROFILE_SCHEMA), values: defaultValues, }); const mutation = useMutation({ - mutationFn: (data: FormData) => - api.companies.updateProfile.call({ + mutationFn: async (data: CompanyProfileFormData) => { + const payload: CreateCompanyPayload = { + companyType: "customer", companyName: data.companyName, companyEmail: data.companyEmail, companyPhone: `${data.companyPhoneCountryCode}${data.companyPhone}`, @@ -75,13 +100,25 @@ export default function TabCompanyProfile({ profile }: { profile: ProfileRespons companyAddress: data.companyAddress, tin: data.tinNumber, fanNumber: data.fanNumber, - }), + }; + + if (isCreate) { + return api.companies.create.call(payload); + } else { + return api.companies.updateProfile.call(payload); + } + }, onSuccess: () => { - queryClient.invalidateQueries({ queryKey: api.companies.getProfile.queryKey() }); + queryClient.invalidateQueries({ + queryKey: api.companies.getProfile.queryKey(), + }); + if (isCreate) { + onCreateSuccess?.(); + } }, }); - const onSubmit = (data: FormData) => mutation.mutate(data); + const onSubmit = (data: CompanyProfileFormData) => mutation.mutate(data); return ( @@ -90,7 +127,9 @@ export default function TabCompanyProfile({ profile }: { profile: ProfileRespons Company Profile - Edit your company registration details + {isCreate + ? "Enter your company registration details to get started" + : "Edit your company registration details"}
@@ -115,7 +154,10 @@ export default function TabCompanyProfile({ profile }: { profile: ProfileRespons - {mutation.isSuccess && ( + {mutation.isSuccess && !isCreate && ( - Saved successfully + + Saved successfully + )} {mutation.isError && ( - Save failed + + {isCreate ? "Failed to create profile" : "Save failed"} + )} - + {!isCreate && ( + + )} 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 837307a87..7a2d9b931 100644 --- a/apps/edr-freight-web/portal/src/pages/settings/TabContactPerson.tsx +++ b/apps/edr-freight-web/portal/src/pages/settings/TabContactPerson.tsx @@ -32,7 +32,13 @@ function splitPhone(fullPhone?: string | null) { return { code: "+251", number: fullPhone }; } -export default function TabContactPerson({ profile }: { profile: ProfileResponse }) { +interface TabContactPersonProps { + profile: ProfileResponse; + mode?: "edit" | "onboarding"; + onContinue?: () => void; +} + +export default function TabContactPerson({ profile, mode = "edit", onContinue }: TabContactPersonProps) { const queryClient = useQueryClient(); const defaultValues = useMemo((): FormData => { @@ -62,6 +68,7 @@ export default function TabContactPerson({ profile }: { profile: ProfileResponse }), onSuccess: () => { queryClient.invalidateQueries({ queryKey: api.companies.getProfile.queryKey() }); + if (mode === "onboarding") onContinue?.(); }, }); @@ -116,20 +123,22 @@ export default function TabContactPerson({ profile }: { profile: ProfileResponse )} - + {mode === "edit" && ( + + )} 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 e9b458060..4425c513e 100644 --- a/apps/edr-freight-web/portal/src/pages/settings/TabDocuments.tsx +++ b/apps/edr-freight-web/portal/src/pages/settings/TabDocuments.tsx @@ -1,6 +1,7 @@ import { useState } from "react"; import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query"; import { + ArrowRight, CheckCircle2, FileCheck, Loader2, @@ -20,7 +21,13 @@ 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 }) { +interface TabDocumentsProps { + profile: ProfileResponse; + mode?: "edit" | "onboarding"; + onContinue?: () => void; +} + +export default function TabDocuments({ profile, mode = "edit", onContinue }: TabDocumentsProps) { const queryClient = useQueryClient(); const [documentFiles, setDocumentFiles] = useState>({}); @@ -75,7 +82,9 @@ export default function TabDocuments({ profile }: { profile: ProfileResponse }) {docUploadMutation.isSuccess && ( - Documents uploaded successfully + + {mode === "onboarding" ? "Saved successfully" : "Documents uploaded successfully"} + )} {docUploadMutation.isError && ( @@ -85,14 +94,37 @@ export default function TabDocuments({ profile }: { profile: ProfileResponse }) )} - + {mode === "onboarding" ? ( + + ) : ( + + )} )} 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 84f365d5d..80fb5f721 100644 --- a/apps/edr-freight-web/portal/src/pages/settings/TabGeneralManager.tsx +++ b/apps/edr-freight-web/portal/src/pages/settings/TabGeneralManager.tsx @@ -34,7 +34,13 @@ function splitPhone(fullPhone?: string | null) { return { code: "+251", number: fullPhone }; } -export default function TabGeneralManager({ profile }: { profile: ProfileResponse }) { +interface TabGeneralManagerProps { + profile: ProfileResponse; + mode?: "edit" | "onboarding"; + onContinue?: () => void; +} + +export default function TabGeneralManager({ profile, mode = "edit", onContinue }: TabGeneralManagerProps) { const queryClient = useQueryClient(); const defaultValues = useMemo((): FormData => { @@ -66,6 +72,7 @@ export default function TabGeneralManager({ profile }: { profile: ProfileRespons }), onSuccess: () => { queryClient.invalidateQueries({ queryKey: api.companies.getProfile.queryKey() }); + if (mode === "onboarding") onContinue?.(); }, }); @@ -133,20 +140,22 @@ export default function TabGeneralManager({ profile }: { profile: ProfileRespons )} - + {mode === "edit" && ( + + )} 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 07f3b7720..f5f9a8210 100644 --- a/apps/edr-freight-web/portal/src/pages/settings/TabPowerOfAttorney.tsx +++ b/apps/edr-freight-web/portal/src/pages/settings/TabPowerOfAttorney.tsx @@ -36,11 +36,17 @@ function splitPhone(fullPhone?: string | null) { return { code: "+251", number: fullPhone }; } +interface TabPowerOfAttorneyProps { + profile: ProfileResponse; + mode?: "edit" | "onboarding"; + onContinue?: () => void; +} + export default function TabPowerOfAttorney({ profile, -}: { - profile: ProfileResponse; -}) { + mode = "edit", + onContinue, +}: TabPowerOfAttorneyProps) { const queryClient = useQueryClient(); const defaultValues = useMemo((): FormData => { @@ -49,7 +55,7 @@ export default function TabPowerOfAttorney({ poaName: profile.poaName ?? "", poaEmail: profile.poaEmail ?? "", poaPhone: phone.number, - poaPhoneCountryCode: profile.poaPhone ? phone.code : "", + poaPhoneCountryCode: profile.poaPhone ? phone.code : "+251", poaLocation: profile.poaLocation ?? "", poaAddress: profile.poaAddress ?? "", }; @@ -81,6 +87,7 @@ export default function TabPowerOfAttorney({ queryClient.invalidateQueries({ queryKey: api.companies.getProfile.queryKey(), }); + if (mode === "onboarding") onContinue?.(); }, }); @@ -99,11 +106,6 @@ export default function TabPowerOfAttorney({ - - Power of Attorney details are optional. Fill them in if you have an - authorized representative, or leave blank. - - - + {mode === "edit" && ( + + )}