mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-09-09 00:08:18 +00:00
feat: add eTrade fields to company entity and onboarding process
- Added new fields to the Company entity: licenceNumber, statusDescription, dateRegistered, renewedFrom, renewalDate, renewedTo, region, zone, woreda, kebele, houseNo, and etradePhone. - Updated onboarding wizard to include a new contact step and fetch company information from eTrade using TIN. - Created ETradeInfo component to handle fetching and displaying eTrade data. - Implemented ETradeService to interact with eTrade API and extract relevant company registration data. - Added new DTOs for fetching eTrade data and handling responses. - Updated CompanyProfileForm to integrate new fields and handle eTrade data. - Created hooks for managing eTrade data fetching and error handling.
This commit is contained in:
@@ -0,0 +1,96 @@
|
||||
import {
|
||||
Alert,
|
||||
Button,
|
||||
Group,
|
||||
Loader,
|
||||
SimpleGrid,
|
||||
Stack,
|
||||
Text,
|
||||
TextInput,
|
||||
} from "@mantine/core";
|
||||
import { AlertCircle, CheckCircle2, RefreshCw } from "lucide-react";
|
||||
import { useETradeData } from "@/hooks/useETradeData";
|
||||
import type { CompanyRegistrationData } from "@edr/types";
|
||||
|
||||
interface ETradeInfoProps {
|
||||
tin: string;
|
||||
onDataLoaded: (data: CompanyRegistrationData) => void;
|
||||
}
|
||||
|
||||
export default function ETradeInfo({ tin, onDataLoaded }: ETradeInfoProps) {
|
||||
const mutation = useETradeData();
|
||||
const isLoading = mutation.isPending;
|
||||
const hasError = mutation.isError;
|
||||
const hasData = mutation.data;
|
||||
|
||||
const handleFetch = async () => {
|
||||
if (!tin || tin.length !== 10) return;
|
||||
const result = await mutation.mutateAsync(tin);
|
||||
if (result) {
|
||||
onDataLoaded(result);
|
||||
}
|
||||
};
|
||||
|
||||
const errorMessage =
|
||||
hasError && mutation.error
|
||||
? (mutation.error as any).message ||
|
||||
"Failed to fetch company information. Please try again."
|
||||
: null;
|
||||
|
||||
return (
|
||||
<Stack gap="md">
|
||||
<Group grow>
|
||||
<TextInput
|
||||
label="TIN Number"
|
||||
placeholder="1234567890"
|
||||
value={tin}
|
||||
disabled
|
||||
readOnly
|
||||
/>
|
||||
<Button
|
||||
variant="filled"
|
||||
color="edr-green"
|
||||
onClick={handleFetch}
|
||||
disabled={!tin || tin.length !== 10 || isLoading}
|
||||
leftSection={isLoading ? <Loader size={16} /> : <RefreshCw size={16} />}
|
||||
mt="24px"
|
||||
>
|
||||
{isLoading ? "Fetching..." : "Fetch Info from eTrade"}
|
||||
</Button>
|
||||
</Group>
|
||||
|
||||
{hasError && errorMessage && (
|
||||
<Alert
|
||||
icon={<AlertCircle size={16} />}
|
||||
color="red"
|
||||
title="Failed to fetch data"
|
||||
>
|
||||
{errorMessage}
|
||||
</Alert>
|
||||
)}
|
||||
|
||||
{hasData && (
|
||||
<Alert
|
||||
icon={<CheckCircle2 size={16} />}
|
||||
color="green"
|
||||
title="Company information loaded"
|
||||
>
|
||||
<Stack gap={0}>
|
||||
<Text size="sm">
|
||||
<strong>License:</strong> {hasData.licenceNumber}
|
||||
</Text>
|
||||
<Text size="sm">
|
||||
<strong>Status:</strong> {hasData.statusDescription}
|
||||
</Text>
|
||||
{hasData.region && (
|
||||
<Text size="sm">
|
||||
<strong>Location:</strong> {hasData.kebele}, {hasData.woreda},{" "}
|
||||
{hasData.zone}, {hasData.region}
|
||||
</Text>
|
||||
)}
|
||||
</Stack>
|
||||
</Alert>
|
||||
)}
|
||||
</Stack>
|
||||
);
|
||||
}
|
||||
@@ -20,10 +20,17 @@ import NationalitySelect from "@/pages/settings/NationalitySelect";
|
||||
import OnboardingRoleSelect from "@/pages/settings/OnboardingRoleSelect";
|
||||
|
||||
/** Form steps shared by CompanyProfileForm and ForwarderForm. */
|
||||
type FormStep = "company" | "personnel" | "poa" | "documents" | "additional";
|
||||
type FormStep =
|
||||
| "company"
|
||||
| "personnel"
|
||||
| "contact"
|
||||
| "poa"
|
||||
| "documents"
|
||||
| "additional";
|
||||
const FORM_STEPS: FormStep[] = [
|
||||
"company",
|
||||
"personnel",
|
||||
"contact",
|
||||
"poa",
|
||||
"documents",
|
||||
"additional",
|
||||
|
||||
Reference in New Issue
Block a user