diff --git a/package.json b/package.json index 4014270ea7..77e5fd51c4 100644 --- a/package.json +++ b/package.json @@ -32,7 +32,7 @@ }, "dependencies": { "@better-giving/assets": "1.0.18", - "@better-giving/registration": "1.0.8", + "@better-giving/registration": "1.0.11", "@gsap/react": "2.1.1", "@headlessui/react": "2.1.0", "@hookform/error-message": "2.0.1", diff --git a/src/pages/Applications/Filter/index.tsx b/src/pages/Applications/Filter/index.tsx index d7a941041a..9b5221bf76 100644 --- a/src/pages/Applications/Filter/index.tsx +++ b/src/pages/Applications/Filter/index.tsx @@ -1,3 +1,4 @@ +import type { QueryParams } from "@better-giving/registration/approval"; import { Popover, PopoverButton } from "@headlessui/react"; import { yupResolver } from "@hookform/resolvers/yup"; import Icon, { DrawerIcon } from "components/Icon"; @@ -6,14 +7,13 @@ import { cleanObject } from "helpers/cleanObject"; import { weeksAgo } from "helpers/weeksAgo"; import { type FormEventHandler, useRef } from "react"; import { FormProvider, useForm } from "react-hook-form"; -import type { ApplicationsQueryParams } from "types/aws"; import Form from "./Form"; import { schema } from "./schema"; import type { FormValues as FV } from "./types"; type Props = { classes?: string; - setParams: React.Dispatch>; + setParams: React.Dispatch>; isDisabled: boolean; }; @@ -29,7 +29,7 @@ export default function Filter({ setParams, classes = "", isDisabled }: Props) { startDate: dateToFormFormat(weeksAgo("now", 1)), endDate: dateToFormFormat(new Date()), hqCountry: { name: "", flag: "", code: "" }, - status: { label: "Under Review", value: "Under Review" }, + status: { label: "Under Review", value: "02" }, }, }); @@ -48,10 +48,10 @@ export default function Filter({ setParams, classes = "", isDisabled }: Props) { async function submit(data: FV) { setParams( cleanObject({ - regDateStart: ISOdate(data.startDate), - regDateEnd: ISOdate(data.endDate, true), - regStatus: data.status.value, - hqCountry: data.hqCountry.name, + startDate: ISOdate(data.startDate), + endDate: ISOdate(data.endDate, true), + status: data.status.value, + country: data.hqCountry.name, }) ); buttonRef.current?.click(); @@ -59,10 +59,7 @@ export default function Filter({ setParams, classes = "", isDisabled }: Props) { const onReset: FormEventHandler = () => { reset(); - setParams({ - limit: 10, - regStatus: "Under Review", - }); + setParams({ status: "02" }); buttonRef.current?.click(); }; return ( diff --git a/src/pages/Profile/Body/GeneralInfo/DetailsColumn/DetailsColumn.tsx b/src/pages/Profile/Body/GeneralInfo/DetailsColumn/DetailsColumn.tsx index 3f19caec7a..83a99eac54 100644 --- a/src/pages/Profile/Body/GeneralInfo/DetailsColumn/DetailsColumn.tsx +++ b/src/pages/Profile/Body/GeneralInfo/DetailsColumn/DetailsColumn.tsx @@ -1,8 +1,8 @@ +import type { EndowClaim } from "@better-giving/registration/models"; import { appRoutes, regRoutes } from "constants/routes"; import { isEmpty } from "helpers"; import type { PropsWithChildren } from "react"; import { Link } from "react-router-dom"; -import type { EndowClaim } from "types/aws"; import { useProfileContext } from "../../../ProfileContext"; import DonateButton from "../../DonateButton"; import Socials from "./Socials"; diff --git a/src/pages/Registration/Steps/ContactDetails/Form/index.tsx b/src/pages/Registration/Steps/ContactDetails/Form/index.tsx index 8a9248ded3..1d1e6dda89 100644 --- a/src/pages/Registration/Steps/ContactDetails/Form/index.tsx +++ b/src/pages/Registration/Steps/ContactDetails/Form/index.tsx @@ -1,8 +1,8 @@ +import type { ReferralMethod, Role } from "@better-giving/registration/models"; import LoadText from "components/LoadText"; import { Selector } from "components/Selector"; import { Field, Label } from "components/form"; import { APP_NAME } from "constants/env"; -import type { ContactRoles, ReferralMethods } from "types/aws"; import { referralOptions, roleOptions } from "../constants"; import type { FormValues as FV } from "../types"; import useSubmit from "./useSubmit"; @@ -60,7 +60,7 @@ export default function Form({ classes = "" }: { classes?: string }) { - + name="org_role" options={roleOptions} classes={{ options: "text-sm" }} @@ -81,7 +81,7 @@ export default function Form({ classes = "" }: { classes?: string }) { - + name="referral_method" options={referralOptions} classes={{ options: "text-sm" }} diff --git a/src/pages/Registration/Steps/ContactDetails/constants.ts b/src/pages/Registration/Steps/ContactDetails/constants.ts index f737a02dcf..acb195ac32 100644 --- a/src/pages/Registration/Steps/ContactDetails/constants.ts +++ b/src/pages/Registration/Steps/ContactDetails/constants.ts @@ -1,7 +1,7 @@ -import type { ContactRoles, ReferralMethods } from "types/aws"; +import type { ReferralMethod, Role } from "@better-giving/registration/models"; import type { OptionType } from "types/components"; -export const roles: { [key in ContactRoles]: string } = { +export const roles: { [key in Role]: string } = { "": "", president: "Chairperson / President", "vice-president": "Vice-chairperson / Vice president", @@ -16,7 +16,7 @@ export const roles: { [key in ContactRoles]: string } = { communications: "Communications", other: "Other", }; -export const referralMethods: { [key in ReferralMethods]: string } = { +export const referralMethods: { [key in ReferralMethod]: string } = { "": "", "better-giving-alliance": "Better Giving Alliance", discord: "Discord", diff --git a/src/pages/Registration/Steps/ContactDetails/index.tsx b/src/pages/Registration/Steps/ContactDetails/index.tsx index abc41b0cb8..89ecc4d746 100644 --- a/src/pages/Registration/Steps/ContactDetails/index.tsx +++ b/src/pages/Registration/Steps/ContactDetails/index.tsx @@ -1,7 +1,7 @@ +import type { ReferralMethod, Role } from "@better-giving/registration/models"; import { yupResolver } from "@hookform/resolvers/yup"; import { useAuthenticatedUser } from "contexts/Auth"; import { FormProvider, useForm } from "react-hook-form"; -import type { ContactRoles, ReferralMethods } from "types/aws"; import type { OptionType } from "types/components"; import { useRegState, withStepGuard } from "../StepGuard"; import Form from "./Form"; @@ -54,10 +54,10 @@ function ContactDetails() { export default withStepGuard(ContactDetails); -function toRoleOption(value: ContactRoles): OptionType { +function toRoleOption(value: Role): OptionType { return { value, label: roles[value] }; } -function toReferralOption(value: ReferralMethods): OptionType { +function toReferralOption(value: ReferralMethod): OptionType { return { value, label: referralMethods[value] }; } diff --git a/src/pages/Registration/Steps/ContactDetails/schema.ts b/src/pages/Registration/Steps/ContactDetails/schema.ts index d09bb3cca4..30b83f2ef5 100644 --- a/src/pages/Registration/Steps/ContactDetails/schema.ts +++ b/src/pages/Registration/Steps/ContactDetails/schema.ts @@ -1,7 +1,7 @@ +import type { ReferralMethod, Role } from "@better-giving/registration/models"; import { optionType } from "schemas/shape"; import { requiredString } from "schemas/string"; import type { SchemaShape } from "schemas/types"; -import type { ContactRoles, ReferralMethods } from "types/aws"; import type { OptionType } from "types/components"; import { type ObjectSchema, object, string } from "yup"; import type { FormValues } from "./types"; @@ -13,16 +13,16 @@ const referralMethodKey: Key = "referral_method"; const otherRole = string() .trim() .when(roleKey, ([option], schema) => - (option as OptionType).value === "other" + (option as OptionType).value === "other" ? schema.required("required") : schema ); -const otherReferralMethod = (referralMethod: ReferralMethods) => +const otherReferralMethod = (referralMethod: ReferralMethod) => string() .trim() .when(referralMethodKey, ([option], schema) => - (option as OptionType).value === referralMethod + (option as OptionType).value === referralMethod ? schema.required("required") : schema ); diff --git a/src/pages/Registration/Steps/ContactDetails/types.ts b/src/pages/Registration/Steps/ContactDetails/types.ts index 50f2612c4d..5c3fb801e8 100644 --- a/src/pages/Registration/Steps/ContactDetails/types.ts +++ b/src/pages/Registration/Steps/ContactDetails/types.ts @@ -1,11 +1,16 @@ +import type { + Contact, + Init, + ReferralMethod, + Role, +} from "@better-giving/registration/models"; import type { OverrideProperties } from "type-fest"; -import type { ContactRoles, ReferralMethods, RegV2 } from "types/aws"; import type { OptionType } from "types/components"; export type FormValues = OverrideProperties< - RegV2.Contact & Pick, + Contact & Pick, { - org_role: OptionType; - referral_method: OptionType; + org_role: OptionType; + referral_method: OptionType; } >; diff --git a/src/pages/Registration/Steps/Dashboard/EndowmentStatus.tsx b/src/pages/Registration/Steps/Dashboard/EndowmentStatus.tsx index 81b3ee3e60..3b19123a8a 100644 --- a/src/pages/Registration/Steps/Dashboard/EndowmentStatus.tsx +++ b/src/pages/Registration/Steps/Dashboard/EndowmentStatus.tsx @@ -1,14 +1,15 @@ +import type { Submission } from "@better-giving/registration/models"; +import { isRejected } from "@reduxjs/toolkit"; import Icon from "components/Icon"; import LoadText from "components/LoadText"; import { steps } from "pages/Registration/routes"; import type { MouseEventHandler } from "react"; import { Link } from "react-router-dom"; -import type { RegV2 } from "types/aws"; import { useRegState } from "../StepGuard"; type Props = { isSubmitting: boolean; - status: Exclude; + status?: Exclude; onSubmit: MouseEventHandler; classes?: string; }; @@ -21,67 +22,66 @@ export default function EndowmentStatus({ }: Props) { const { data } = useRegState<3>(); - switch (status) { - case "rejected": - return ( -
-

- - - Your nonprofit's application has been rejected. - -

- -
- ); - - case "in-review": - return ( -
+ if (isRejected(status)) { + return ( +
+

- Your application has been submitted for review + Your nonprofit's application has been rejected. -

- ); +

+ +
+ ); + } - default: - return ( -
- - Back - - -
- ); + if (status === "in-review") { + return ( +
+ + + Your application has been submitted for review + +
+ ); } + + return ( +
+ + Back + + +
+ ); } diff --git a/src/pages/Registration/Steps/Dashboard/index.tsx b/src/pages/Registration/Steps/Dashboard/index.tsx index 1f8343483c..db7f32d2cf 100644 --- a/src/pages/Registration/Steps/Dashboard/index.tsx +++ b/src/pages/Registration/Steps/Dashboard/index.tsx @@ -2,9 +2,9 @@ import Prompt from "components/Prompt"; import { regRoutes } from "constants/routes"; import { useErrorContext } from "contexts/ErrorContext"; import { useModalContext } from "contexts/ModalContext"; -import type { CompleteReg } from "pages/Registration/types"; import { Navigate } from "react-router-dom"; import { useSubmitMutation } from "services/aws/registration"; +import type { Step6Data } from "../../types"; import { useRegState, withStepGuard } from "../StepGuard"; import EndowmentStatus from "./EndowmentStatus"; import Step from "./Step"; @@ -16,7 +16,7 @@ function Dashboard() { const { showModal } = useModalContext(); const { handleError } = useErrorContext(); - const submit = async ({ init }: CompleteReg) => { + const submit = async ({ init }: Step6Data) => { try { await submitApplication(init.id).unwrap(); if (window.hasOwnProperty("lintrk")) { @@ -40,7 +40,11 @@ function Dashboard() { const { submission } = data; const isStepDisabled = isSubmitting || submission === "in-review"; - if (typeof submission === "object") { + if ( + submission && + typeof submission !== "string" && + "endowment_id" in submission + ) { return ; } diff --git a/src/pages/Registration/Steps/Documentation/Documentation.tsx b/src/pages/Registration/Steps/Documentation/Documentation.tsx index df507722a6..e4c627f61f 100644 --- a/src/pages/Registration/Steps/Documentation/Documentation.tsx +++ b/src/pages/Registration/Steps/Documentation/Documentation.tsx @@ -1,4 +1,4 @@ -import { isIrs501c3 } from "types/aws"; +import { isIrs501c3 } from "@better-giving/registration/models"; import { useRegState, withStepGuard } from "../StepGuard"; import FSADocumentation from "./FSA"; import NonFSA from "./NonFSA"; diff --git a/src/pages/Registration/Steps/Documentation/FSA/index.tsx b/src/pages/Registration/Steps/Documentation/FSA/index.tsx index 4c1d040601..2e8c28e9b3 100644 --- a/src/pages/Registration/Steps/Documentation/FSA/index.tsx +++ b/src/pages/Registration/Steps/Documentation/FSA/index.tsx @@ -1,6 +1,7 @@ +import type { FsaDocs } from "@better-giving/registration/models"; import { yupResolver } from "@hookform/resolvers/yup"; import { FormProvider, useForm } from "react-hook-form"; -import type { FileObject, RegV2 } from "types/aws"; +import type { FileObject } from "types/aws"; import type { FileDropzoneAsset } from "types/components"; import Form from "./Form"; import { schema } from "./schema"; @@ -28,7 +29,7 @@ export default function FSADocumentation(props: Props) { ); } -function formFormat(doc: RegV2.FsaDocs): FormValues { +function formFormat(doc: FsaDocs): FormValues { return { //level 1 outdated: doc.outdated, diff --git a/src/pages/Registration/Steps/Documentation/FSA/types.ts b/src/pages/Registration/Steps/Documentation/FSA/types.ts index fd610dc682..0469842f46 100644 --- a/src/pages/Registration/Steps/Documentation/FSA/types.ts +++ b/src/pages/Registration/Steps/Documentation/FSA/types.ts @@ -1,9 +1,9 @@ +import type { FsaDocs } from "@better-giving/registration/models"; import type { Except, OverrideProperties } from "type-fest"; -import type { RegV2 } from "types/aws"; import type { FileDropzoneAsset } from "types/components"; export type FormValues = OverrideProperties< - Except, + Except, { proof_of_identity: FileDropzoneAsset; proof_of_reg: FileDropzoneAsset; @@ -11,5 +11,5 @@ export type FormValues = OverrideProperties< >; export type Props = { - doc: RegV2.FsaDocs | undefined; + doc: FsaDocs | undefined; }; diff --git a/src/pages/Registration/Steps/Documentation/NonFSA/types.ts b/src/pages/Registration/Steps/Documentation/NonFSA/types.ts index e265c801e5..d4759ef5ea 100644 --- a/src/pages/Registration/Steps/Documentation/NonFSA/types.ts +++ b/src/pages/Registration/Steps/Documentation/NonFSA/types.ts @@ -1,8 +1,8 @@ +import type { TaxDeductibleDocs } from "@better-giving/registration/models"; import type { Except } from "type-fest"; -import type { RegV2 } from "types/aws"; -export type FormValues = Except; +export type FormValues = Except; export type Props = { - doc: RegV2.TaxDeductibleDocs | undefined; + doc: TaxDeductibleDocs | undefined; }; diff --git a/src/pages/Registration/Steps/FSAInquiry/types.ts b/src/pages/Registration/Steps/FSAInquiry/types.ts index 98eef65a2f..030a7f1da7 100644 --- a/src/pages/Registration/Steps/FSAInquiry/types.ts +++ b/src/pages/Registration/Steps/FSAInquiry/types.ts @@ -1,4 +1,4 @@ +import type { FsaInq } from "@better-giving/registration/models"; import type { OverrideProperties } from "type-fest"; -import type { RegV2 } from "types/aws"; -export type FV = OverrideProperties; +export type FV = OverrideProperties; diff --git a/src/pages/Registration/Steps/OrgDetails/types.ts b/src/pages/Registration/Steps/OrgDetails/types.ts index 212072c18e..6043470e6c 100644 --- a/src/pages/Registration/Steps/OrgDetails/types.ts +++ b/src/pages/Registration/Steps/OrgDetails/types.ts @@ -1,10 +1,11 @@ +import type { Org } from "@better-giving/registration/models"; import type { Except, OverrideProperties } from "type-fest"; -import type { EndowDesignation, RegV2 } from "types/aws"; +import type { EndowDesignation } from "types/aws"; import type { Country, OptionType } from "types/components"; import type { UNSDG_NUMS } from "types/lists"; export type FormValues = OverrideProperties< - Except, + Except, { hq_country: Country; designation: OptionType; diff --git a/src/pages/Registration/Steps/StepGuard.tsx b/src/pages/Registration/Steps/StepGuard.tsx index 783284ccea..bb56bc984c 100644 --- a/src/pages/Registration/Steps/StepGuard.tsx +++ b/src/pages/Registration/Steps/StepGuard.tsx @@ -1,11 +1,10 @@ import { isEmpty } from "helpers"; import { type FC, createContext, useContext, useEffect } from "react"; import { useNavigate, useOutletContext } from "react-router-dom"; -import type { RegV2 } from "types/aws"; -import type { RegStep, RegistrationState } from "../types"; +import type { InitState, RegStep, RegistrationState } from "../types"; export type StepGuardProps = { - init: RegV2.Init; + init: InitState; state: RegistrationState; }; diff --git a/src/pages/Registration/Steps/getRegistrationState.ts b/src/pages/Registration/Steps/getRegistrationState.ts index c6a7d70f36..a52a676641 100644 --- a/src/pages/Registration/Steps/getRegistrationState.ts +++ b/src/pages/Registration/Steps/getRegistrationState.ts @@ -1,8 +1,9 @@ -import { type RegV2, isDone } from "types/aws"; +import type { Init } from "@better-giving/registration/models"; +import { type Reg, isDone } from "@better-giving/registration/step"; import { steps } from "../routes"; import type { RegistrationState } from "../types"; -export function getRegistrationState(reg: RegV2.Record): { +export function getRegistrationState(reg: Reg): { state: RegistrationState; nextStep: steps; } { @@ -32,17 +33,26 @@ export function getRegistrationState(reg: RegV2.Record): { return { state: { step: 1, data: toData(reg) }, nextStep: steps.contact }; } -function toData({ +function toData({ id, registrant_id, hubspot_contact_id, created_at, env, claim, + status, ...rest -}: T): { init: RegV2.Init } & Omit { +}: T): { init: Init } & Omit { return { - init: { id, registrant_id, hubspot_contact_id, created_at, env, claim }, + init: { + id, + registrant_id, + hubspot_contact_id, + created_at, + env, + claim, + status, + }, ...rest, }; } diff --git a/src/pages/Registration/Steps/index.tsx b/src/pages/Registration/Steps/index.tsx index 9d9fa044ea..68a351b07b 100644 --- a/src/pages/Registration/Steps/index.tsx +++ b/src/pages/Registration/Steps/index.tsx @@ -1,3 +1,4 @@ +import { isIrs501c3 } from "@better-giving/registration/models"; import ExtLink from "components/ExtLink"; import { ErrorStatus, LoadingStatus } from "components/Status"; import { appRoutes, regRoutes } from "constants/routes"; @@ -8,9 +9,8 @@ import { useLocation, } from "react-router-dom"; import { useRegQuery } from "services/aws/registration"; -import { type RegV2, isIrs501c3 } from "types/aws"; import { steps } from "../routes"; -import type { RegStep4, RegistrationState } from "../types"; +import type { InitState, RegStep4, RegistrationState } from "../types"; import Banking from "./Banking"; import ContactDetails from "./ContactDetails"; import Dashboard from "./Dashboard"; @@ -24,7 +24,7 @@ import { getRegistrationState } from "./getRegistrationState"; function Layout() { const { state } = useLocation(); - const initReg = state as RegV2.Init | undefined; + const initReg = state as InitState | undefined; const ref = initReg?.id || ""; const { data, isLoading, isError } = useRegQuery(ref, { diff --git a/src/pages/Registration/Success.tsx b/src/pages/Registration/Success.tsx index 1493fbd036..481682cdd7 100644 --- a/src/pages/Registration/Success.tsx +++ b/src/pages/Registration/Success.tsx @@ -1,8 +1,9 @@ +import type { Submission } from "@better-giving/registration/models"; +import type { CompleteReg } from "@better-giving/registration/step"; import Icon from "components/Icon"; import { adminRoutes, appRoutes } from "constants/routes"; import { Navigate, useLocation } from "react-router-dom"; import { Link } from "react-router-dom"; -import type { CompleteReg } from "./types"; export function Component({ classes = "" }: { classes?: string }) { const { state } = useLocation(); @@ -24,7 +25,10 @@ export function Component({ classes = "" }: { classes?: string }) { ) + .endowment_id + }/${adminRoutes.edit_profile}`} > Start filling out {contact.org_name}’s profile and attract donors! Thank you! diff --git a/src/pages/Registration/Welcome.tsx b/src/pages/Registration/Welcome.tsx index ccb4868524..339cac5643 100644 --- a/src/pages/Registration/Welcome.tsx +++ b/src/pages/Registration/Welcome.tsx @@ -1,3 +1,4 @@ +import type { EndowClaim } from "@better-giving/registration/models"; import Icon from "components/Icon"; import LoadText from "components/LoadText"; import { GENERIC_ERROR_MESSAGE } from "constants/common"; @@ -7,9 +8,9 @@ import { useAuthenticatedUser } from "contexts/Auth"; import { storeRegistrationReference } from "helpers"; import { useEffect } from "react"; import { Link, useLocation } from "react-router-dom"; -import { useNewApplicationQuery } from "services/aws/registration"; -import type { EndowClaim, RegV2 } from "types/aws"; +import { useApplicationNewQuery } from "services/aws/registration"; import { steps } from "./routes"; +import type { InitState } from "./types"; export function Component() { const { email } = useAuthenticatedUser(); @@ -19,11 +20,11 @@ export function Component() { data: reg, isLoading, isError, - } = useNewApplicationQuery({ email, claim }); + } = useApplicationNewQuery({ registrant_id: email, claim }); useEffect(() => { if (!reg) return; - storeRegistrationReference(reg.ContactPerson.PK); + storeRegistrationReference(reg.id); }, [reg]); return ( @@ -43,9 +44,9 @@ export function Component() { state={ { //link is disabled if no reg - registrant_id: reg?.ContactPerson.Email!, - id: reg?.ContactPerson.PK!, - } satisfies RegV2.Init + registrant_id: reg?.registrant_id!, + id: reg?.id!, + } satisfies InitState } > diff --git a/src/pages/Registration/types.ts b/src/pages/Registration/types.ts index 8edaf4481d..b9d99d5dd9 100644 --- a/src/pages/Registration/types.ts +++ b/src/pages/Registration/types.ts @@ -1,15 +1,20 @@ -import type { RegV2 } from "types/aws"; +import type { + FsaDocs, + Init, + TaxDeductibleDocs, +} from "@better-giving/registration/models"; +import type { CompleteReg } from "@better-giving/registration/step"; -type InitKeys = keyof RegV2.Init; -export type CompleteReg = Omit & { - init: RegV2.Init; -}; +export interface Reg extends Omit { + init: Init; +} +export interface InitState extends Pick {} type Data< - Done extends keyof CompleteReg, - Pending extends Exclude, -> = Pick & { - [key in Pending]?: CompleteReg[key]; + Done extends keyof Reg, + Pending extends Exclude, +> = Pick & { + [key in Pending]?: Reg[key]; }; type Step1Data = Data<"init", "contact">; @@ -19,13 +24,17 @@ type Step4Data = Omit< Data<"init" | "contact" | "org" | "irs501c3", "docs">, "docs" > & { - // override fsa docs required in step 5 member - docs?: RegV2.FsaDocs | RegV2.TaxDeductibleDocs; + docs?: FsaDocs | TaxDeductibleDocs; }; + type Step5Data = Data< "init" | "contact" | "org" | "irs501c3" | "docs", "banking" >; +export type Step6Data = Data< + "init" | "contact" | "org" | "irs501c3" | "docs" | "banking", + "submission" +>; /** contact details */ type RegStep1 = { @@ -57,9 +66,9 @@ type RegStep5 = { data: Step5Data; }; -type RegStep6 = { +export type RegStep6 = { step: 6; - data: CompleteReg; + data: Step6Data; }; export type RegistrationState = diff --git a/src/services/aws/registration/registration.ts b/src/services/aws/registration/registration.ts index b13884a8f6..7055813eda 100644 --- a/src/services/aws/registration/registration.ts +++ b/src/services/aws/registration/registration.ts @@ -1,25 +1,24 @@ +import type { FsaPayload } from "@better-giving/registration/fsa"; +import type { Submission } from "@better-giving/registration/models"; +import type { Reg } from "@better-giving/registration/step"; +import type { NewReg, Update } from "@better-giving/registration/update"; import { TEMP_JWT } from "constants/auth"; import { EMAIL_SUPPORT } from "constants/env"; import { logger } from "helpers"; -import type { EndowClaim, InitApplication, RegV2 } from "types/aws"; import { version as v } from "../../helpers"; -import type { FSASigner } from "../../types"; import { aws } from "../aws"; const registration_api = aws.injectEndpoints({ endpoints: (builder) => ({ - newApplication: builder.query< - Pick, - { email: string; claim?: EndowClaim } - >({ - query: ({ email, claim }) => ({ + applicationNew: builder.query({ + query: (payload) => ({ url: `${v(6)}/registration`, method: "POST", - body: { Email: email, ...(claim && { InitClaim: claim }) }, + body: payload, headers: { authorization: TEMP_JWT }, }), }), - reg: builder.query({ + reg: builder.query({ providesTags: ["registration"], query: (uuid) => { return { @@ -28,13 +27,13 @@ const registration_api = aws.injectEndpoints({ headers: { authorization: TEMP_JWT }, }; }, - transformResponse(res: RegV2.Record) { + transformResponse(res: Reg) { return { ...res, reqId: 0 }; }, }), fiscalSponsorshipAgreementSigningURL: builder.mutation< { url: string }, - FSASigner + FsaPayload["signer"] >({ //no need to invalidate registration as latest would be fetched on redirect/success query: (signer) => { @@ -48,12 +47,12 @@ const registration_api = aws.injectEndpoints({ }; }, }), - updateReg: builder.mutation({ - query: ({ id, type, ...val }) => { + updateReg: builder.mutation({ + query: ({ id, ...payload }) => { return { url: `${v(7)}/registration/${id}`, method: "PATCH", - body: { type, val }, + body: payload, headers: { authorization: TEMP_JWT }, }; }, @@ -78,7 +77,7 @@ const registration_api = aws.injectEndpoints({ } }, }), - submit: builder.mutation({ + submit: builder.mutation({ invalidatesTags: ["registration"], query: (referenceID) => ({ url: `${v(5)}/registration/${referenceID}/submit`, @@ -101,6 +100,6 @@ export const { //mutations useUpdateRegMutation, - useNewApplicationQuery, + useApplicationNewQuery, useSubmitMutation, } = registration_api; diff --git a/yarn.lock b/yarn.lock index 2eb3f9494e..c4731e0e72 100644 --- a/yarn.lock +++ b/yarn.lock @@ -822,12 +822,12 @@ __metadata: languageName: node linkType: hard -"@better-giving/registration@npm:1.0.8": - version: 1.0.8 - resolution: "@better-giving/registration@npm:1.0.8" +"@better-giving/registration@npm:1.0.11": + version: 1.0.11 + resolution: "@better-giving/registration@npm:1.0.11" peerDependencies: valibot: 0.42.0 - checksum: 10/bde23e708805ec33c9b8924fcc068a2d9ebfad2e38f255cc33ce9df1cbc4fcae05c661cb3d452502c89f6718a2d44504c910be0c1a5adc145eff9ea06c9051eb + checksum: 10/4dad40bdb768c78a67a627218afecd5fad57b57197f1eb5f0a7b72995fc231fdcc66b1fa67fabeb464497776707acc334a837990e8f1863ecf920e4d995359c4 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.8" + "@better-giving/registration": "npm:1.0.11" "@biomejs/biome": "npm:1.8.1" "@gsap/react": "npm:2.1.1" "@headlessui/react": "npm:2.1.0" @@ -5676,9 +5676,9 @@ __metadata: linkType: hard "reselect@npm:^5.0.1": - version: 5.1.0 - resolution: "reselect@npm:5.1.0" - checksum: 10/657c379d9461781b7cb5f0a32133e23b4266886660c94fcc77c102bec8abe484b32bf43a911b99b747ecf7439f157696561d744d40dc920024611beb1a0d921f + version: 5.1.1 + resolution: "reselect@npm:5.1.1" + checksum: 10/1fdae11a39ed9c8d85a24df19517c8372ee24fefea9cce3fae9eaad8e9cefbba5a3d4940c6fe31296b6addf76e035588c55798f7e6e147e1b7c0855f119e7fa5 languageName: node linkType: hard