Skip to content

Commit

Permalink
feat(FSADT1-1347): updated dto and functions
Browse files Browse the repository at this point in the history
  • Loading branch information
paulushcgcj committed Jul 11, 2024
1 parent fd36c57 commit 4970ffe
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 14 deletions.
47 changes: 33 additions & 14 deletions frontend/src/dto/ApplyClientNumberDto.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import type { CodeDescrType } from "@/dto/CommonTypesDto";

export interface Address {
locationName: string;
streetAddress: string;
complementaryAddressOne?: string;
complementaryAddressTwo?: string;
Expand All @@ -14,31 +13,39 @@ export interface Address {
faxNumber?: string;
emailAddress?: string;
notes?: string;
index: number;
locationName: string;
}

export interface Contact {
locationNames: CodeDescrType[];
contactType: CodeDescrType;
firstName: string;
lastName: string;
phoneNumber: string;
secondaryPhoneNumber?: string;
faxNumber?: string;
email: string;
index: number;
locationNames: CodeDescrType[];
}

export interface FormDataDto {
businessInformation: {
district: string;
businessType: string;
legalType: string;
clientType: string;
registrationNumber: string;
businessName: string;
businessType: string;
clientType: string;
goodStandingInd: string;
legalType: string;
birthdate: string;
address: Address;
district: string;
workSafeBcNumber?: string;
doingBusinessAs?: string;
clientAcronym?: string;
firstName?: string;
middleName?: string;
lastName?: string;
notes?: string;
identificationType?: string;
clientIdentification?: string;
identificationCountry?: string;
Expand All @@ -58,7 +65,7 @@ export interface ForestClientDetailsDto {
contacts: Contact[];
}

export const emptyAddress = (): Address =>
export const indexedEmptyAddress = (index: number): Address =>
JSON.parse(
JSON.stringify({
locationName: "",
Expand All @@ -74,6 +81,22 @@ export const emptyAddress = (): Address =>
faxNumber: "",
emailAddress: "",
notes: "",
index,
}),
);

export const emptyAddress = (): Address => indexedEmptyAddress(0);

export const indexedEmptyContact = (index: number): Contact =>
JSON.parse(
JSON.stringify({
locationNames: [],
contactType: { value: "", text: "" },
firstName: "",
lastName: "",
phoneNumber: "",
email: "",
index,
}),
);

Expand All @@ -88,12 +111,7 @@ export const formDataDto: FormDataDto = {
registrationNumber: "",
businessName: "",
goodStandingInd: "",
birthdate: "",
address: {
...emptyAddress(),
country: { value: "", text: "" },
province: { value: "", text: "" },
},
birthdate: ""
},
location: {
addresses: [emptyAddress()],
Expand All @@ -108,6 +126,7 @@ export const emptyContact: Contact = {
lastName: "",
phoneNumber: "",
email: "",
index: 0,
};

export const newFormDataDto = (): FormDataDto => JSON.parse(JSON.stringify(formDataDto));
Expand Down
2 changes: 2 additions & 0 deletions frontend/src/services/ForestClientService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export const addNewAddress = (addresses: Address[]): number => {
province: { value: "", text: "" } as CodeDescrType,
city: "",
postalCode: "",
index: addresses.length,
};

const newAddresses = addresses.push(blankAddress);
Expand All @@ -24,6 +25,7 @@ export const addNewContact = (contacts: Contact[]): number => {
lastName: "",
phoneNumber: "",
email: "",
index: contacts.length,
};

const newContacts = contacts.push(blankContact);
Expand Down

0 comments on commit 4970ffe

Please sign in to comment.