fix: remove signup code
This commit is contained in:
@@ -1,67 +0,0 @@
|
|||||||
"use server"
|
|
||||||
|
|
||||||
import { parsePhoneNumber } from "libphonenumber-js"
|
|
||||||
import { z } from "zod"
|
|
||||||
|
|
||||||
import { serviceServerActionProcedure } from "@/server/trpc"
|
|
||||||
|
|
||||||
import { phoneValidator } from "@/utils/phoneValidator"
|
|
||||||
|
|
||||||
const registerUserPayload = z.object({
|
|
||||||
firstName: z.string(),
|
|
||||||
lastName: z.string(),
|
|
||||||
dateOfBirth: z.string(),
|
|
||||||
address: z.object({
|
|
||||||
countryCode: z.string(),
|
|
||||||
zipCode: z.string(),
|
|
||||||
}),
|
|
||||||
email: z.string(),
|
|
||||||
phoneNumber: phoneValidator("Phone is required"),
|
|
||||||
})
|
|
||||||
|
|
||||||
export const registerUserBookingFlow = serviceServerActionProcedure
|
|
||||||
.input(registerUserPayload)
|
|
||||||
.mutation(async function ({ ctx, input }) {
|
|
||||||
const payload = {
|
|
||||||
...input,
|
|
||||||
language: ctx.lang,
|
|
||||||
phoneNumber: parsePhoneNumber(input.phoneNumber)
|
|
||||||
.formatNational()
|
|
||||||
.replace(/\s+/g, ""),
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO: Consume the API to register the user as soon as passwordless signup is enabled.
|
|
||||||
// let apiResponse
|
|
||||||
// try {
|
|
||||||
// apiResponse = await api.post(api.endpoints.v1.Profile.profile, {
|
|
||||||
// body: payload,
|
|
||||||
// headers: {
|
|
||||||
// Authorization: `Bearer ${ctx.serviceToken}`,
|
|
||||||
// },
|
|
||||||
// })
|
|
||||||
// } catch (error) {
|
|
||||||
// console.error("Unexpected error", error)
|
|
||||||
// return { success: false, error: "Unexpected error" }
|
|
||||||
// }
|
|
||||||
|
|
||||||
// if (!apiResponse.ok) {
|
|
||||||
// const text = await apiResponse.text()
|
|
||||||
// console.error(text)
|
|
||||||
// console.error(
|
|
||||||
// "registerUserBookingFlow api error",
|
|
||||||
// JSON.stringify({
|
|
||||||
// query: input,
|
|
||||||
// error: {
|
|
||||||
// status: apiResponse.status,
|
|
||||||
// statusText: apiResponse.statusText,
|
|
||||||
// error: text,
|
|
||||||
// },
|
|
||||||
// })
|
|
||||||
// )
|
|
||||||
// return { success: false, error: "API error" }
|
|
||||||
// }
|
|
||||||
// const json = await apiResponse.json()
|
|
||||||
// console.log("registerUserBookingFlow: json", json)
|
|
||||||
|
|
||||||
return { success: true, data: payload }
|
|
||||||
})
|
|
||||||
@@ -6,7 +6,6 @@ import { useIntl } from "react-intl"
|
|||||||
|
|
||||||
import { useEnterDetailsStore } from "@/stores/enter-details"
|
import { useEnterDetailsStore } from "@/stores/enter-details"
|
||||||
|
|
||||||
import { registerUserBookingFlow } from "@/actions/registerUserBookingFlow"
|
|
||||||
import Button from "@/components/TempDesignSystem/Button"
|
import Button from "@/components/TempDesignSystem/Button"
|
||||||
import CountrySelect from "@/components/TempDesignSystem/Form/Country"
|
import CountrySelect from "@/components/TempDesignSystem/Form/Country"
|
||||||
import Input from "@/components/TempDesignSystem/Form/Input"
|
import Input from "@/components/TempDesignSystem/Form/Input"
|
||||||
@@ -59,36 +58,8 @@ export default function Details({ user }: DetailsProps) {
|
|||||||
|
|
||||||
const completeStep = useEnterDetailsStore((state) => state.completeStep)
|
const completeStep = useEnterDetailsStore((state) => state.completeStep)
|
||||||
|
|
||||||
// const errorMessage = intl.formatMessage({
|
|
||||||
// id: "An error occurred. Please try again.",
|
|
||||||
// })
|
|
||||||
|
|
||||||
const onSubmit = useCallback(
|
const onSubmit = useCallback(
|
||||||
async function (values: DetailsSchema) {
|
async function (values: DetailsSchema) {
|
||||||
if (values.join) {
|
|
||||||
const signupVals = {
|
|
||||||
firstName: values.firstName,
|
|
||||||
lastName: values.lastName,
|
|
||||||
email: values.email,
|
|
||||||
phoneNumber: values.phoneNumber,
|
|
||||||
address: {
|
|
||||||
zipCode: values.zipCode,
|
|
||||||
countryCode: values.countryCode,
|
|
||||||
},
|
|
||||||
dateOfBirth: values.dateOfBirth,
|
|
||||||
}
|
|
||||||
|
|
||||||
const res = await registerUserBookingFlow(signupVals)
|
|
||||||
if (!res.success) {
|
|
||||||
// if (res.error) {
|
|
||||||
// toast.error(res.error)
|
|
||||||
// } else {
|
|
||||||
// toast.error(errorMessage)
|
|
||||||
// }
|
|
||||||
return
|
|
||||||
}
|
|
||||||
console.log("Signed up user: ", res)
|
|
||||||
}
|
|
||||||
completeStep(values)
|
completeStep(values)
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user