From 23d752d1ccb28bde25a6285cf58a2ba4a70f9a62 Mon Sep 17 00:00:00 2001 From: Nathnael Date: Tue, 18 Aug 2026 08:45:29 +0000 Subject: [PATCH] feat(portal): let an investor company switch back to eTrade registration MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A company that ticked the investment-licence box by mistake, or that has since been registered with the trade registry, had no way back — the flag is chosen once, on a step onboarding never returns to. The Company tab now carries a Registration source card for those companies. It is a re-application rather than a settings edit, so the confirmation says so outright: the typed registration is cleared, the company returns to pending and the wizard reopens on the company step, while documents, owner and contact details stay. Hidden for everyone else, and disabled while a profile change request is under review — switching then would strand it. --- .../portal/src/pages/SettingsPage.tsx | 2 + .../pages/settings/RegistrationSourceCard.tsx | 149 ++++++++++++++++++ 2 files changed, 151 insertions(+) create mode 100644 apps/edr-freight-web/portal/src/pages/settings/RegistrationSourceCard.tsx diff --git a/apps/edr-freight-web/portal/src/pages/SettingsPage.tsx b/apps/edr-freight-web/portal/src/pages/SettingsPage.tsx index 13b0d4025..53e0cf0a3 100644 --- a/apps/edr-freight-web/portal/src/pages/SettingsPage.tsx +++ b/apps/edr-freight-web/portal/src/pages/SettingsPage.tsx @@ -47,6 +47,7 @@ import useAuth from "@/hooks/useAuth"; import { rolesForCompanyType } from "./settings/companyRoles"; import TabAccount from "./settings/TabAccount"; import TabCompanyProfile from "./settings/TabCompanyProfile"; +import RegistrationSourceCard from "./settings/RegistrationSourceCard"; import TabContactPerson from "./settings/TabContactPerson"; import TabDocuments from "./settings/TabDocuments"; import TabOwner from "./settings/TabOwner"; @@ -398,6 +399,7 @@ export default function SettingsPage() { /> + diff --git a/apps/edr-freight-web/portal/src/pages/settings/RegistrationSourceCard.tsx b/apps/edr-freight-web/portal/src/pages/settings/RegistrationSourceCard.tsx new file mode 100644 index 000000000..09f4e7195 --- /dev/null +++ b/apps/edr-freight-web/portal/src/pages/settings/RegistrationSourceCard.tsx @@ -0,0 +1,149 @@ +import { useState } from "react"; +import { useMutation, useQueryClient } from "@tanstack/react-query"; +import { + Alert, + Button, + Card, + Group, + List, + Modal, + Stack, + Text, + Title, +} from "@mantine/core"; +import { AlertCircle, FileSearch } from "lucide-react"; + +import { api } from "@/services/api"; +import type { ProfileResponse } from "@/types/profile"; +import { extractApiError } from "@/utils/result"; + +/** + * Leave the foreign investment-licence route and go back to the ordinary eTrade + * one — for a company that has since been registered with the trade registry, + * or that ticked the box by mistake. + * + * It is a re-application, not a settings edit: the API clears the registration + * the customer typed (nothing on file was ever checked against a licence) and + * puts the company back to pending, so the wizard reopens on the company step + * and the TIN goes through eTrade this time. Said plainly here rather than + * discovered afterwards. + */ +export default function RegistrationSourceCard({ + profile, + disabled = false, +}: { + profile: ProfileResponse; + /** A change request is under review — switching now would strand it. */ + disabled?: boolean; +}) { + const queryClient = useQueryClient(); + const [confirming, setConfirming] = useState(false); + const [error, setError] = useState(null); + + const revert = useMutation({ + mutationFn: () => api.companies.revertToRegularCompany.call(), + onSuccess: async () => { + setConfirming(false); + // getInfo is what the onboarding gate reads, so refreshing it is what + // reopens the wizard. + await Promise.all([ + queryClient.invalidateQueries({ + queryKey: api.companies.getInfo.queryKey(), + }), + queryClient.invalidateQueries({ + queryKey: api.companies.getProfile.queryKey(), + }), + queryClient.invalidateQueries({ + queryKey: api.companies.onboardingRequirements.queryKey(), + }), + ]); + }, + onError: (err) => setError(extractApiError(err).message), + }); + + if (!profile.investorLicence) return null; + + return ( + <> + + + + Registration source + + + + Your company is registered on a foreign investment licence, so your + registration details were entered by hand instead of being read from + eTrade. Our team reviews them against the documents you uploaded. + + + If your company now holds an eTrade trade licence, you can switch + over and have your registration verified automatically. + + + + + {disabled && ( + + Not available while your profile changes are under review. + + )} + + + + setConfirming(false)} + title="Switch to eTrade registration?" + centered + radius="lg" + > + + This re-opens your application: + + + The registration details you typed are cleared — eTrade supplies + them once your TIN is found. + + + Your company goes back to pending and is reviewed again. + + + Your documents, owner and contact details stay as they are. + + + }> + If eTrade holds no record for your TIN you won't be able to finish — + come back here and re-select the investment licence in the wizard. + + {error && ( + + {error} + + )} + + + + + + + + ); +}