Commit dd1800d3 by Arjun Jhukal

updated the propell visitor id logic

parent 7c9fce23
import DashboardLayout from '@/components/layouts/DashboardLayout'
import AgeVerificationModal from '@/components/organism/dialog'
import React from 'react'
"use client";
import DashboardLayout from '@/components/layouts/DashboardLayout';
import AgeVerificationModal from '@/components/organism/dialog';
import { useSearchParams } from 'next/navigation';
import React from 'react';
export default function DashboardRootLayout({ children }: { children: React.ReactNode }) {
const searchParams = useSearchParams();
const visitorId = searchParams.get("visitor_id");
localStorage.setItem("visitor_id", visitorId || "");
return (
<DashboardLayout>
{children}
......
......@@ -116,7 +116,8 @@ export default function RegisterPage() {
dob: null as Dayjs | null,
city: '',
pob: '',
agree: true
agree: true,
visitor_id: undefined,
}
const { deviceId } = useSeon();
const { handleSubmit, handleBlur, handleChange, errors, dirty, values, touched, setFieldValue, setFieldTouched } = useFormik(
......@@ -125,6 +126,7 @@ export default function RegisterPage() {
validationSchema,
onSubmit: async (values) => {
const formattedDob = values.dob ? dayjs(values.dob).format('YYYY-MM-DD') : '';
const userFromPropeelVisitorId = localStorage.getItem("visitor_id");
try {
const response = await registerUser({
email: values.emailAddress,
......@@ -140,7 +142,8 @@ export default function RegisterPage() {
city: values.city,
pob: values.pob,
agree: values.agree,
device_id: deviceId
device_id: deviceId,
visitor_id: userFromPropeelVisitorId || undefined,
}).unwrap();
dispatch(
......@@ -151,6 +154,7 @@ export default function RegisterPage() {
}),
);
router.replace(`${PATH.AUTH.VERIFY_EMAIL.ROOT}?email=${values.emailAddress}`);
localStorage.removeItem("visitor_id");
}
catch (e: any) {
dispatch(
......
......@@ -8,19 +8,11 @@ export const authApi = createApi({
baseQuery: baseQuery,
endpoints: (builder) => ({
registerUser: builder.mutation<{ success: boolean, data: LoginResponse | null, message: string }, RegisterProps>({
query: ({ email,
username,
password,
password_confirmation, first_name, middle_name, last_name, phone, photoid_number, dob, city, pob, agree,device_id }) => ({
url: `/api/auth/register`,
method: "POST",
body: {
email,
username,
password,
password_confirmation, first_name, middle_name, last_name, phone, photoid_number, dob, city, pob, agree,device_id
},
}),
query: (body) => ({
url: `/api/auth/register`,
method: "POST",
body
}),
}),
login: builder.mutation<LoginResponse, LoginProps>({
......@@ -37,11 +29,11 @@ export const authApi = createApi({
body: { email },
})
}),
verifyEmail: builder.mutation<GlobalResponse, { id: string; hash: string,device_id:string }>({
query: ({ id, hash ,device_id}) => ({
verifyEmail: builder.mutation<GlobalResponse, { id: string; hash: string, device_id: string }>({
query: ({ id, hash, device_id }) => ({
url: "/api/auth/verify-email",
method: "POST",
body: { id, hash,device_id},
body: { id, hash, device_id },
})
}),
forgotPassword: builder.mutation<GlobalResponse, { email: string }>({
......
......@@ -41,4 +41,5 @@ export interface RegisterProps extends LoginProps {
pob: string;
agree: boolean;
device_id?: string;
visitor_id?: string;
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment