Skip to content

Commit

Permalink
feat: [#187194162] add profile address to dakota persona
Browse files Browse the repository at this point in the history
  • Loading branch information
AnJuHyppolite committed Dec 13, 2024
1 parent a3b3f96 commit b54b439
Show file tree
Hide file tree
Showing 28 changed files with 1,918 additions and 674 deletions.
10 changes: 8 additions & 2 deletions api/src/api/userRouter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { getCurrentDate, getCurrentDateISOString, parseDate } from "@shared/date
import { determineIfNexusDbaNameNeeded } from "@shared/domain-logic/businessPersonaHelpers";
import { getCurrentBusiness } from "@shared/domain-logic/getCurrentBusiness";
import { modifyCurrentBusiness } from "@shared/domain-logic/modifyCurrentBusiness";
import { createEmptyFormationFormData } from "@shared/formationData";
import { createEmptyFormationFormData, FormationAddress } from "@shared/formationData";
import { LicenseName, LicenseSearchNameAndAddress } from "@shared/license";
import { Business, createEmptyUserData, UserData } from "@shared/userData";
import { Request, Response, Router } from "express";
Expand Down Expand Up @@ -254,13 +254,19 @@ export const userRouterFactory = (

const formationFormData =
userData.businesses[userData.currentBusinessId].formationData.formationFormData;
const address = {

const address: FormationAddress = {
addressLine1: formationFormData.addressLine1,
addressLine2: formationFormData.addressLine2,
addressCity: formationFormData.addressCity,
addressMunicipality: formationFormData.addressMunicipality,
addressState: formationFormData.addressState,
addressCountry: formationFormData.addressCountry,
addressZipCode: formationFormData.addressZipCode,
addressProvince: formationFormData.addressProvince,
businessLocationType: formationFormData.businessLocationType,
};

return modifyCurrentBusiness(userData, (business) => ({
...business,
formationData: {
Expand Down
4 changes: 3 additions & 1 deletion content/src/fieldConfig/profile.json
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,9 @@
},
"businessAddress": {
"default": {
"header": "Business Address"
"header": "Business Address",
"usAddress": "U.S. address",
"intlAddress": "International address"
}
},
"isChildcareForSixOrMore": {
Expand Down
8 changes: 8 additions & 0 deletions shared/src/formationData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,14 @@ export const emptyAddressData: Address = {
addressZipCode: "",
};

export const emptyFormationAddressData: FormationAddress = {
...emptyAddressData,
addressCity: undefined,
addressProvince: undefined,
addressCountry: undefined,
businessLocationType: undefined,
};

export interface FormationSigner {
readonly name: string;
readonly signature: boolean;
Expand Down
2 changes: 2 additions & 0 deletions web/public/mgmt/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4879,6 +4879,8 @@ collections:
widget: object
fields:
- { label: "Header", name: "header", widget: "string" }
- { label: "U.S. Address", name: "usAddress", widget: "string" }
- { label: "International Address", name: "intlAddress", widget: "string" }
- label: Business Name
name: "businessName"
collapsed: true
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { AddressMunicipalityDropdown } from "@/components/data-fields/address/AddressMunicipalityDropdown";
import { generateAddress } from "@/test/factories";
import { WithStatefulAddressData } from "@/test/mock/withStatefulAddressData";
import { Address, emptyAddressData, Municipality } from "@businessnjgovnavigator/shared/";
import { emptyFormationAddressData, FormationAddress, Municipality } from "@businessnjgovnavigator/shared/";
import { generateMunicipality } from "@businessnjgovnavigator/shared/test";
import { fireEvent, render, screen, within } from "@testing-library/react";

Expand All @@ -10,12 +10,12 @@ describe("<AddressMunicipalityDropdown />", () => {
addressData,
municipalities,
}: {
addressData?: Address;
addressData?: FormationAddress;
municipalities?: Municipality[];
}): void => {
render(
<WithStatefulAddressData
initialData={addressData || emptyAddressData}
initialData={addressData || emptyFormationAddressData}
municipalities={municipalities || [generateMunicipality({})]}
>
<AddressMunicipalityDropdown onValidation={() => {}} />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { MunicipalityDropdown } from "@/components/data-fields/MunicipalityDropd
import { AddressContext } from "@/contexts/addressContext";
import { MunicipalitiesContext } from "@/contexts/municipalitiesContext";
import { useAddressErrors } from "@/lib/data-hooks/useAddressErrors";
import { Address, Municipality } from "@businessnjgovnavigator/shared/";
import { FormationAddress, Municipality } from "@businessnjgovnavigator/shared/";
import { ReactElement, useContext } from "react";

interface Props {
Expand All @@ -15,7 +15,7 @@ export const AddressMunicipalityDropdown = (props: Props): ReactElement => {
const { doesFieldHaveError, getFieldErrorLabel } = useAddressErrors();

const onSelect = (value: Municipality | undefined): void => {
setAddressData((previousAddressData: Address): Address => {
setAddressData((previousAddressData: FormationAddress): FormationAddress => {
return { ...previousAddressData, addressMunicipality: value };
});
};
Expand All @@ -26,7 +26,7 @@ export const AddressMunicipalityDropdown = (props: Props): ReactElement => {
municipalities={municipalities}
fieldName={"addressMunicipality"}
error={doesFieldHaveError("addressMunicipality")}
value={state.addressData.addressMunicipality}
value={state.formationAddressData.addressMunicipality}
onSelect={onSelect}
helperText={getFieldErrorLabel("addressMunicipality")}
/>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { AddressTextField } from "@/components/data-fields/address/AddressTextField";
import { generateAddress } from "@/test/factories";
import { WithStatefulAddressData } from "@/test/mock/withStatefulAddressData";
import { Address, emptyAddressData, Municipality } from "@businessnjgovnavigator/shared/";
import { emptyFormationAddressData, FormationAddress, Municipality } from "@businessnjgovnavigator/shared/";
import { generateMunicipality } from "@businessnjgovnavigator/shared/test";
import { fireEvent, render, screen } from "@testing-library/react";

Expand All @@ -11,13 +11,13 @@ describe("<AddressTextField />", () => {
addressData,
municipalities,
}: {
fieldName: keyof Address;
addressData?: Address;
fieldName: keyof FormationAddress;
addressData?: FormationAddress;
municipalities?: Municipality[];
}): void => {
render(
<WithStatefulAddressData
initialData={addressData || emptyAddressData}
initialData={addressData || emptyFormationAddressData}
municipalities={municipalities || [generateMunicipality({})]}
>
<AddressTextField fieldName={fieldName} errorBarType={"ALWAYS"} />
Expand Down
6 changes: 3 additions & 3 deletions web/src/components/data-fields/address/AddressTextField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ import { ModifiedContent } from "@/components/ModifiedContent";
import { WithErrorBar } from "@/components/WithErrorBar";
import { AddressContext } from "@/contexts/addressContext";
import { useAddressErrors } from "@/lib/data-hooks/useAddressErrors";
import { Address } from "@businessnjgovnavigator/shared/";
import { FormationAddress } from "@businessnjgovnavigator/shared/formationData";
import { ReactElement, useContext } from "react";

export interface Props extends Omit<GenericTextFieldProps, "value" | "error" | "inputWidth"> {
fieldName: keyof Address;
fieldName: keyof FormationAddress;
label?: string;
secondaryLabel?: string;
errorBarType: "ALWAYS" | "MOBILE-ONLY" | "DESKTOP-ONLY" | "NEVER";
Expand All @@ -34,7 +34,7 @@ export const AddressTextField = ({ className, ...props }: Props): ReactElement =
{props.secondaryLabel && <span className="margin-left-1">{props.secondaryLabel}</span>}
<GenericTextField
inputWidth={"full"}
value={state.addressData[props.fieldName] as string}
value={state.formationAddressData[props.fieldName] as string}
onValidation={props.onValidation}
{...props}
handleChange={handleChange}
Expand Down
Loading

0 comments on commit b54b439

Please sign in to comment.