From 2e76504088a4dde6024ebb6334ef005597f123e7 Mon Sep 17 00:00:00 2001 From: ap-justin <89639563+ap-justin@users.noreply.github.com> Date: Mon, 23 Sep 2024 22:50:05 +0800 Subject: [PATCH] done use registration package --- package.json | 2 +- src/pages/Registration/Steps/OrgDetails/Form/index.tsx | 10 +--------- .../Registration/Steps/OrgDetails/Form/useSubmit.ts | 4 +++- src/pages/Registration/Steps/OrgDetails/index.tsx | 4 ++-- src/pages/Registration/Steps/OrgDetails/types.ts | 3 +-- src/pages/Registration/Welcome.tsx | 1 + yarn.lock | 10 +++++----- 7 files changed, 14 insertions(+), 20 deletions(-) diff --git a/package.json b/package.json index 77e5fd51c4..c1743f2b2f 100644 --- a/package.json +++ b/package.json @@ -32,7 +32,7 @@ }, "dependencies": { "@better-giving/assets": "1.0.18", - "@better-giving/registration": "1.0.11", + "@better-giving/registration": "1.0.13", "@gsap/react": "2.1.1", "@headlessui/react": "2.1.0", "@hookform/error-message": "2.0.1", diff --git a/src/pages/Registration/Steps/OrgDetails/Form/index.tsx b/src/pages/Registration/Steps/OrgDetails/Form/index.tsx index fedc91e41e..ce2e251b3d 100644 --- a/src/pages/Registration/Steps/OrgDetails/Form/index.tsx +++ b/src/pages/Registration/Steps/OrgDetails/Form/index.tsx @@ -1,3 +1,4 @@ +import { endowDesignations } from "@better-giving/registration/models"; import countries from "assets/countries/all.json"; import ActivityCountries from "components/ActivityCountries"; import CountrySelector from "components/CountrySelector"; @@ -8,20 +9,11 @@ import { Field, Label, Radio } from "components/form"; import { unsdgs } from "constants/unsdgs"; import { TERMS_OF_USE_NPO } from "constants/urls"; import { Link } from "react-router-dom"; -import type { EndowDesignation } from "types/aws"; import { steps } from "../../../routes"; import { useRegState } from "../../StepGuard"; import type { FormValues as FV } from "../types"; import useSubmit from "./useSubmit"; -const endowDesignations: EndowDesignation[] = [ - "Charity", - "Religious Organization", - "University", - "Hospital", - "Other", -]; - export default function Form() { const { data } = useRegState<2>(); const { submit, isSubmitting } = useSubmit(); diff --git a/src/pages/Registration/Steps/OrgDetails/Form/useSubmit.ts b/src/pages/Registration/Steps/OrgDetails/Form/useSubmit.ts index 5a621a7686..b184ff2d8b 100644 --- a/src/pages/Registration/Steps/OrgDetails/Form/useSubmit.ts +++ b/src/pages/Registration/Steps/OrgDetails/Form/useSubmit.ts @@ -2,6 +2,7 @@ import { useErrorContext } from "contexts/ErrorContext"; import { type SubmitHandler, useFormContext } from "react-hook-form"; import { useNavigate } from "react-router-dom"; import { useUpdateRegMutation } from "services/aws/registration"; +import type { EndowDesignation } from "types/aws"; import { steps } from "../../../routes"; import { useRegState } from "../../StepGuard"; import type { FormValues } from "../types"; @@ -35,7 +36,8 @@ export default function useSubmit() { ) /**TODO: AWS update to accept number[] */, kyc_donors_only: fv.isAnonymousDonationsAllowed === "no", hq_country: fv.hq_country.name, - designation: fv.designation.value, + // required in schema + designation: fv.designation.value as EndowDesignation, active_in_countries: fv.active_in_countries.map((opt) => opt.value), }); diff --git a/src/pages/Registration/Steps/OrgDetails/index.tsx b/src/pages/Registration/Steps/OrgDetails/index.tsx index f14752f6d6..ce098fcb2b 100644 --- a/src/pages/Registration/Steps/OrgDetails/index.tsx +++ b/src/pages/Registration/Steps/OrgDetails/index.tsx @@ -1,8 +1,8 @@ +import type { Org } from "@better-giving/registration/models"; import { yupResolver } from "@hookform/resolvers/yup"; import { country } from "components/CountrySelector"; import { unsdgs } from "constants/unsdgs"; import { FormProvider, useForm } from "react-hook-form"; -import type { RegV2 } from "types/aws"; import { useRegState, withStepGuard } from "../StepGuard"; import Form from "./Form"; import { schema } from "./schema"; @@ -39,7 +39,7 @@ function OrgDetails() { export default withStepGuard(OrgDetails); -function formFomat(org: RegV2.Org): FormValues { +function formFomat(org: Org): FormValues { return { //level 1 website: org.website, diff --git a/src/pages/Registration/Steps/OrgDetails/types.ts b/src/pages/Registration/Steps/OrgDetails/types.ts index 6043470e6c..e8fcd84e23 100644 --- a/src/pages/Registration/Steps/OrgDetails/types.ts +++ b/src/pages/Registration/Steps/OrgDetails/types.ts @@ -1,6 +1,5 @@ -import type { Org } from "@better-giving/registration/models"; +import type { EndowDesignation, Org } from "@better-giving/registration/models"; import type { Except, OverrideProperties } from "type-fest"; -import type { EndowDesignation } from "types/aws"; import type { Country, OptionType } from "types/components"; import type { UNSDG_NUMS } from "types/lists"; diff --git a/src/pages/Registration/Welcome.tsx b/src/pages/Registration/Welcome.tsx index 339cac5643..ba8ad6f826 100644 --- a/src/pages/Registration/Welcome.tsx +++ b/src/pages/Registration/Welcome.tsx @@ -20,6 +20,7 @@ export function Component() { data: reg, isLoading, isError, + /** @ts-ignore: TODO: simplify step type */ } = useApplicationNewQuery({ registrant_id: email, claim }); useEffect(() => { diff --git a/yarn.lock b/yarn.lock index c4731e0e72..de178e1c76 100644 --- a/yarn.lock +++ b/yarn.lock @@ -822,12 +822,12 @@ __metadata: languageName: node linkType: hard -"@better-giving/registration@npm:1.0.11": - version: 1.0.11 - resolution: "@better-giving/registration@npm:1.0.11" +"@better-giving/registration@npm:1.0.13": + version: 1.0.13 + resolution: "@better-giving/registration@npm:1.0.13" peerDependencies: valibot: 0.42.0 - checksum: 10/4dad40bdb768c78a67a627218afecd5fad57b57197f1eb5f0a7b72995fc231fdcc66b1fa67fabeb464497776707acc334a837990e8f1863ecf920e4d995359c4 + checksum: 10/5af3dde366c19cdd39a96938dd0fed0d34c4ca4b230ffc401a7075c6871a48790c25980316a7e330c9989b9899619973e63bae51c4af1dbc8f742610552ff6d1 languageName: node linkType: hard @@ -3080,7 +3080,7 @@ __metadata: resolution: "angelprotocol-web-app@workspace:." dependencies: "@better-giving/assets": "npm:1.0.18" - "@better-giving/registration": "npm:1.0.11" + "@better-giving/registration": "npm:1.0.13" "@biomejs/biome": "npm:1.8.1" "@gsap/react": "npm:2.1.1" "@headlessui/react": "npm:2.1.0"