step 1 api

This commit is contained in:
Meenadeveloper 2026-02-28 17:35:28 +05:30
parent 32b1347223
commit 13b17037c9
20 changed files with 1997 additions and 143 deletions

1
.env Normal file
View File

@ -0,0 +1 @@
VITE_THIRUKALYANAM_API_BASE_URL=https://www.thirukalyanam.amrithaa.net/backend/api/

1018
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -22,8 +22,10 @@
"@mui/x-date-pickers": "^8.19.0", "@mui/x-date-pickers": "^8.19.0",
"@reduxjs/toolkit": "^2.11.0", "@reduxjs/toolkit": "^2.11.0",
"@tailwindcss/vite": "^4.1.17", "@tailwindcss/vite": "^4.1.17",
"@tanstack/react-query": "^5.90.21",
"axios": "^1.13.2", "axios": "^1.13.2",
"date-fns": "^4.1.0", "date-fns": "^4.1.0",
"firebase": "^12.10.0",
"framer-motion": "^12.23.24", "framer-motion": "^12.23.24",
"lightswind": "^3.1.18", "lightswind": "^3.1.18",
"lucide-react": "^0.553.0", "lucide-react": "^0.553.0",

View File

@ -0,0 +1,43 @@
// Give the service worker access to Firebase Messaging.
// Note that you can only use Firebase Messaging here. Other Firebase libraries
// are not available in the service worker.
// Replace 10.13.2 with latest version of the Firebase JS SDK.
importScripts('https://www.gstatic.com/firebasejs/10.13.2/firebase-app-compat.js');
importScripts('https://www.gstatic.com/firebasejs/10.13.2/firebase-messaging-compat.js');
// Initialize the Firebase app in the service worker by passing in
// your app's Firebase config object.
// https://firebase.google.com/docs/web/setup#config-object
firebase.initializeApp({
apiKey: "AIzaSyC14hS0_idUIRS9JEigObmT-_CGl3zb8Fo",
authDomain: "thirukalyanam-c8e1c.firebaseapp.com",
projectId: "thirukalyanam-c8e1c",
storageBucket: "thirukalyanam-c8e1c.firebasestorage.app",
messagingSenderId: "433615056618",
appId: "1:433615056618:web:309a920f408ba826907193",
measurementId: "G-1L93F6DS7K"
});
// Retrieve an instance of Firebase Messaging so that it can handle background
// messages.
const messaging = firebase.messaging();
messaging.onBackgroundMessage((payload) => {
console.log(
'[firebase-messaging-sw.js] Received background message ',
payload
);
// Customize notification here
const notificationTitle = payload.notification.title;
const notificationOptions = {
body: payload.notification.body,
icon: payload.notification.image || "/favicon.ico",
data: {
url: "/notification" // 👈 set target URL
}
};
self.registration.showNotification(notificationTitle, notificationOptions);
});

View File

@ -2,7 +2,15 @@ import "./App.css";
import { BrowserRouter as Router } from "react-router-dom"; import { BrowserRouter as Router } from "react-router-dom";
import AppRoutes from "./routes/AppRoutes"; import AppRoutes from "./routes/AppRoutes";
import { Toaster } from "react-hot-toast"; import { Toaster } from "react-hot-toast";
import { useEffect } from "react";
import { generateToken, listenToMessages } from "./notifications/firebase";
function App() { function App() {
useEffect(()=>{
generateToken();
listenToMessages(); // foreground notifications
},[]);
return ( return (
<> <Toaster position="top-center" /> <> <Toaster position="top-center" />
<Router> <Router>

28
src/api/apiEndpoints.js Normal file
View File

@ -0,0 +1,28 @@
export const API_ENDPOINTS = {
LOGOUT: "logout",
TERMS_AND_POLICIES_PRIVACY:"terms-and-policies",
// registration api's
PERSONAL_DETAILS_MASTER :"personal_details_masters",
CASTE_MASTER : "get_caste_masters",
SUB_CASTE_MASTER : "get_sub_caste_masters",
CITY_MASTER : "get_district_masters",
STAR_MASTER : "get_star_masters",
MOBILE_SEND_OTP: "send_otp",
MOBILE_VERIFY_OTP: "verify_otp",
EDUCATION_DETAILS_MASTER: "educational_details_masters",
EDUCATION_LIST_API:"get_education",
FAMILY_DETAILS_MASTER: "family_details_masters", // family details master api
LIFESTYLE_DETAILS_MASTER:"lifetstyle_details_masters",
PREFERED_PARTNER_DETAILS_MASTER:"prefered_details_masters",
REGISTER_STEP1: "register", // register api
REGISTER_STEP2:"update_educational_details", // educational details updated api
REGSITER_STEP3:"update_family_details", // family details updated api
REGISTER_STEP4:"update_lifestyle_details", // lifestyle details updated api
REGISTER_STEP5:"update_preferred_details", // partner preference details updated api
};

22
src/api/auth.api.js Normal file
View File

@ -0,0 +1,22 @@
import axiosInstance from "./axiosInstance";
import { API_ENDPOINTS } from "./apiEndpoints";
export const sendOtpAPI = async (mobile) => {
const res = await axiosInstance.post(API_ENDPOINTS.MOBILE_SEND_OTP, {
mobile,
});
return res.data;
};
export const verifyOtpAPI = async ({ mobile, otp }) => {
const res = await axiosInstance.post(API_ENDPOINTS.MOBILE_VERIFY_OTP, {
mobile,
otp,
});
return res.data;
};
export const logoutAPI = async () => {
const res = await axiosInstance.post(API_ENDPOINTS.LOGOUT);
return res.data;
};

View File

@ -7,8 +7,8 @@ import { API_ENDPOINTS } from "./apiEndpoints";
* and default headers for JSON communication. * and default headers for JSON communication.
*/ */
const axiosInstance = axios.create({ const axiosInstance = axios.create({
baseURL: import.meta.env.VITE_UNICORN_API_BASE_URL || baseURL: import.meta.env.VITE_THIRUKALYANAM_API_BASE_URL ||
"https://www.unicorn.amrithaa.net/backend/api/" , "https://www.thirukalyanam.amrithaa.net/backend/api/" ,
headers: { headers: {
"Content-Type": "application/json", "Content-Type": "application/json",
}, },
@ -19,7 +19,7 @@ const axiosInstance = axios.create({
* while sharing the same base URL and authorization mechanism. * while sharing the same base URL and authorization mechanism.
*/ */
const apiForFiles = axios.create({ const apiForFiles = axios.create({
baseURL: import.meta.env.VITE_UNICORN_API_BASE_URL, baseURL: import.meta.env.VITE_THIRUKALYANAM_API_BASE_URL,
headers: { headers: {
"Content-Type": "multipart/form-data", "Content-Type": "multipart/form-data",
}, },
@ -69,7 +69,8 @@ const addErrorInterceptor = (instance) => {
console.error("Unauthorized access - logging out..."); console.error("Unauthorized access - logging out...");
localStorage.removeItem("access_token"); localStorage.removeItem("access_token");
// window.location.href = "/"; // window.location.href = "/";
navigate("/"); // SAFE redirect (works outside React)
window.location.replace("/");
} else if (error.response && error.response.status === 403) { } else if (error.response && error.response.status === 403) {
window.location.href = "/"; window.location.href = "/";
// navigate("/"); // navigate("/");
@ -178,7 +179,8 @@ export const logoutAPI = async () => {
console.log("Clearing local storage..."); console.log("Clearing local storage...");
// always clear local storage // always clear local storage
localStorage.removeItem("access_token"); localStorage.removeItem("access_token");
// clearFcmToken(); clearFcmToken();
window.location.replace("/");
} }
}; };

57
src/api/masters.api.js Normal file
View File

@ -0,0 +1,57 @@
import axiosInstance from "./axiosInstance";
import { API_ENDPOINTS } from "./apiEndpoints";
export const getPersonalDetailsMasters = async () => {
const res = await axiosInstance.get(API_ENDPOINTS.PERSONAL_DETAILS_MASTER);
return res.data;
};
export const getCasteMasters = async (religion_id) => {
const res = await axiosInstance.get(API_ENDPOINTS.CASTE_MASTER, {
params: { religion_id },
});
return res.data;
};
export const getSubCasteMasters = async (caste_id) => {
const res = await axiosInstance.get(API_ENDPOINTS.SUB_CASTE_MASTER, {
params: { caste_id },
});
return res.data;
};
export const getCityMasters = async (state_id) => {
const res = await axiosInstance.get(API_ENDPOINTS.CITY_MASTER, {
params: { state_id },
});
return res.data;
};
export const getStarMasters = async (raasi_id) => {
const res = await axiosInstance.get(API_ENDPOINTS.STAR_MASTER, {
params: { raasi_id },
});
return res.data;
};
export const getEducationMasters = async () => {
const res = await axiosInstance.get(API_ENDPOINTS.EDUCATION_DETAILS_MASTER);
return res.data;
};
export const getFamilyMasters = async () => {
const res = await axiosInstance.get(API_ENDPOINTS.FAMILY_DETAILS_MASTER);
return res.data;
};
export const getLifestyleMasters = async () => {
const res = await axiosInstance.get(API_ENDPOINTS.LIFESTYLE_DETAILS_MASTER);
return res.data;
};
export const getPartnerPreferenceMasters = async () => {
const res = await axiosInstance.get(
API_ENDPOINTS.PREFERED_PARTNER_DETAILS_MASTER
);
return res.data;
};

34
src/api/register.api.js Normal file
View File

@ -0,0 +1,34 @@
import axiosInstance from "./axiosInstance";
import { API_ENDPOINTS } from "./apiEndpoints";
/**
* STEP 1 Personal Details
*/
export const registerStep1API = async (payload) => {
const res = await axiosInstance.post(API_ENDPOINTS.REGISTER_STEP1, payload);
return res.data;
};
/**
* STEP 2 Education Details
*/
export const registerStep2API = async (payload) => {
const res = await axiosInstance.post(API_ENDPOINTS.REGISTER_STEP2, payload);
return res.data;
};
/**
* STEP 3 Family Details
*/
export const registerStep3API = async (payload) => {
const res = await axiosInstance.post(API_ENDPOINTS.REGSITER_STEP3, payload);
return res.data;
};
/**
* STEP 4 Lifestyle Details
*/
export const registerStep4API = async (payload) => {
const res = await axiosInstance.post(API_ENDPOINTS.REGISTER_STEP4, payload);
return res.data;
};

View File

@ -59,10 +59,10 @@ const AdvancedDropzone = ({ value, onChange }) => {
onChange={updateFiles} onChange={updateFiles}
minHeight="195px" minHeight="195px"
value={extFiles} value={extFiles}
accept="image/*, video/*" accept="image/*"
maxFiles={3} maxFiles={3}
maxFileSize={2 * 1024 * 1024} maxFileSize={10 * 1024 * 1024}
label="Drag'n drop files here or click to browse" label="Drag'n drop up to 3 images (max 10 MB each)"
uploadConfig={{ uploadConfig={{
url: BASE_URL + "/file", url: BASE_URL + "/file",
cleanOnUpload: true, cleanOnUpload: true,

View File

@ -1,4 +1,4 @@
import React, { useCallback, useEffect, useRef, useState } from "react"; import React, { useCallback, useEffect, useMemo, useRef, useState } from "react";
import { useDispatch, useSelector } from "react-redux"; import { useDispatch, useSelector } from "react-redux";
import { updatePersonalDetails } from "../redux/registrationFormSlice"; import { updatePersonalDetails } from "../redux/registrationFormSlice";
import { import {
@ -12,19 +12,31 @@ import {
Box, Box,
Typography, Typography,
Link, Link,
InputAdornment,
} from "@mui/material"; } from "@mui/material";
import CheckCircleIcon from "@mui/icons-material/CheckCircle";
import AdvancedDropzone from "./AdvancedDropzone"; import AdvancedDropzone from "./AdvancedDropzone";
import { DatePicker } from "@mui/x-date-pickers/DatePicker"; import { DatePicker } from "@mui/x-date-pickers/DatePicker";
import toast from "react-hot-toast";
import { LocalizationProvider } from "@mui/x-date-pickers"; import { LocalizationProvider } from "@mui/x-date-pickers";
import { AdapterDateFns } from "@mui/x-date-pickers/AdapterDateFns"; import { AdapterDateFns } from "@mui/x-date-pickers/AdapterDateFns";
import {
usePersonalDetailsMasters,
useCasteMasters,
useSubCasteMasters,
useCityMasters,
useStarMasters,
} from "../hooks/useDependentMasters";
import { useSendOtp, useVerifyOtp } from "../hooks/useAuth";
const OTP_LENGTH = 4; const OTP_LENGTH = 4;
const OTP_TIMER_SEC = 120; // 2 minutes const OTP_TIMER_SEC = 120; // 2 minutes
const PersonalDetailsForm = ({ onSubmitStep, onSkipStep, errors }) => { const PersonalDetailsForm = ({ onSubmitStep, errors }) => {
const dispatch = useDispatch(); const dispatch = useDispatch();
const data = useSelector((state) => state.registerform.personalDetails); const data = useSelector((state) => state.registerform.personalDetails);
const nameInputRef = useRef(null); const nameInputRef = useRef(null);
const requiredMark = <span style={{ color: "#d32f2f" }}> *</span>;
const [showOtp, setShowOtp] = useState(false); const [showOtp, setShowOtp] = useState(false);
const [otp, setOtp] = useState(new Array(OTP_LENGTH).fill("")); const [otp, setOtp] = useState(new Array(OTP_LENGTH).fill(""));
@ -32,6 +44,93 @@ const PersonalDetailsForm = ({ onSubmitStep, onSkipStep, errors }) => {
const [otpError, setOtpError] = useState(""); const [otpError, setOtpError] = useState("");
const [mobileOtpVerified, setMobileOtpVerified] = useState(false); const [mobileOtpVerified, setMobileOtpVerified] = useState(false);
const [mobileNumberError, setMobileNumberError] = useState(""); const [mobileNumberError, setMobileNumberError] = useState("");
const sendOtp = useSendOtp();
const verifyOtp = useVerifyOtp();
const { data: personalMasters, isLoading: isPersonalMastersLoading } =
usePersonalDetailsMasters();
const genderOptions = useMemo(
() => personalMasters?.gender ?? [],
[personalMasters]
);
const maritalStatusOptions = useMemo(
() => personalMasters?.marital_status ?? [],
[personalMasters]
);
const religionOptions = useMemo(
() => personalMasters?.religion ?? [],
[personalMasters]
);
const profileCreatedForOptions = useMemo(
() => personalMasters?.profileCreatedFor ?? [],
[personalMasters]
);
const gothramOptions = useMemo(
() => personalMasters?.gothram ?? [],
[personalMasters]
);
const raasiOptions = useMemo(
() => personalMasters?.raasi ?? [],
[personalMasters]
);
const stateOptions = useMemo(
() => personalMasters?.state ?? [],
[personalMasters]
);
const casteQuery = useCasteMasters(data.religion);
const subCasteQuery = useSubCasteMasters(data.caste);
const cityQuery = useCityMasters(data.state);
const starQuery = useStarMasters(data.raasi);
const casteOptions = useMemo(() => {
const raw = casteQuery.data;
if (!raw) return [];
if (Array.isArray(raw)) return raw;
return raw.caste || raw.data || [];
}, [casteQuery.data]);
const subCasteOptions = useMemo(() => {
const raw = subCasteQuery.data;
if (!raw) return [];
if (Array.isArray(raw)) return raw;
return raw.sub_caste || raw.subCaste || raw.data || [];
}, [subCasteQuery.data]);
const cityOptions = useMemo(() => {
const raw = cityQuery.data;
if (!raw) return [];
if (Array.isArray(raw)) return raw;
return raw.city || raw.district || raw.data || [];
}, [cityQuery.data]);
const starOptions = useMemo(() => {
const raw = starQuery.data;
if (!raw) return [];
if (Array.isArray(raw)) return raw;
return raw.star || raw.data || [];
}, [starQuery.data]);
const getOptionLabel = useCallback((item, fallback = "") => {
if (!item) return fallback;
if (typeof item === "string") return item;
return (
item.name ||
item.caste_name ||
item.sub_caste_name ||
item.district_name ||
item.city_name ||
item.state_name ||
item.religion_name ||
item.marital_status_name ||
item.gothram_name ||
item.raasi_name ||
item.profile_for_name ||
item.star_name ||
fallback
);
}, []);
const startOtpTimer = useCallback(() => { const startOtpTimer = useCallback(() => {
setOtpTimer(OTP_TIMER_SEC); setOtpTimer(OTP_TIMER_SEC);
@ -60,27 +159,60 @@ const PersonalDetailsForm = ({ onSubmitStep, onSkipStep, errors }) => {
} }
}; };
const handleOtpKeyDown = (index, event) => {
if (event.key !== "Backspace") return;
event.preventDefault();
const newOtp = [...otp];
if (newOtp[index]) {
newOtp[index] = "";
setOtp(newOtp);
return;
}
if (index > 0) {
newOtp[index - 1] = "";
setOtp(newOtp);
const prev = document.getElementById(`otp-${index - 1}`);
if (prev) prev.focus();
}
};
const resetOtp = () => { const resetOtp = () => {
setOtp(new Array(OTP_LENGTH).fill("")); setOtp(new Array(OTP_LENGTH).fill(""));
setOtpError(""); setOtpError("");
startOtpTimer(); startOtpTimer();
}; };
const handleMobileSubmit = () => { const handleMobileSubmit = async () => {
if (!data.mobileNumber || data.mobileNumber.length !== 10) { if (!data.mobileNumber || data.mobileNumber.length !== 10) {
setMobileNumberError( setMobileNumberError(
"Please enter a valid 10-digit mobile number before sending OTP" "Please enter a valid 10-digit mobile number before sending OTP"
); );
return; return;
} }
try {
setMobileNumberError(""); setMobileNumberError("");
const res = await sendOtp.mutateAsync(data.mobileNumber);
const successMessage =
res?.message ||
res?.status ||
"OTP sent successfully";
toast.success(successMessage);
setShowOtp(true); setShowOtp(true);
resetOtp(); resetOtp();
setMobileOtpVerified(false); setMobileOtpVerified(false);
} catch (error) {
setMobileNumberError("Failed to send OTP. Please try again.");
const message =
error?.response?.data?.message ||
error?.response?.data?.otp ||
error?.message ||
"Failed to send OTP";
toast.error(message);
}
}; };
const handleChange = (field, value) => { const handleChange = (field, value) => {
dispatch(updatePersonalDetails({ [field]: value })); const updates = { [field]: value };
if (field === "mobileNumber") { if (field === "mobileNumber") {
setMobileNumberError(""); setMobileNumberError("");
setShowOtp(false); setShowOtp(false);
@ -89,31 +221,50 @@ const PersonalDetailsForm = ({ onSubmitStep, onSkipStep, errors }) => {
setOtpTimer(0); setOtpTimer(0);
setMobileOtpVerified(false); setMobileOtpVerified(false);
} }
if (field === "religion") {
updates.caste = "";
updates.subCaste = "";
}
if (field === "caste") {
updates.subCaste = "";
}
if (field === "state") {
updates.city = "";
}
if (field === "raasi") {
updates.star = "";
}
dispatch(updatePersonalDetails(updates));
}; };
const isOtpComplete = otp.every((digit) => digit !== ""); const isOtpComplete = otp.every((digit) => digit !== "");
// Simulated API OTP verification (replace with actual)
const verifyOtpApi = async (mobile, otpValue) => {
return new Promise((resolve, reject) => {
setTimeout(() => {
if (otpValue === "1234") resolve(true);
else reject("Invalid OTP");
}, 1000);
});
};
const handleOtpSubmit = async () => { const handleOtpSubmit = async () => {
if (!isOtpComplete) { if (!isOtpComplete) {
setOtpError("Complete OTP is required"); setOtpError("Complete OTP is required");
return; return;
} }
try { try {
await verifyOtpApi(data.mobileNumber, otp.join("")); const res = await verifyOtp.mutateAsync({
mobile: data.mobileNumber,
otp: otp.join(""),
});
const successMessage =
res?.message ||
res?.status ||
"OTP verified successfully";
toast.success(successMessage);
setMobileOtpVerified(true); setMobileOtpVerified(true);
setMobileNumberError(""); setMobileNumberError("");
setOtpError("");
} catch (error) { } catch (error) {
setOtpError(error || "OTP verification failed"); const message =
error?.response?.data?.otp ||
error?.response?.data?.message ||
error?.message ||
"Invalid or expired OTP";
setOtpError(message);
toast.error(message);
} }
}; };
@ -159,7 +310,10 @@ const PersonalDetailsForm = ({ onSubmitStep, onSkipStep, errors }) => {
if (showOtp && !mobileOtpVerified) { if (showOtp && !mobileOtpVerified) {
try { try {
await verifyOtpApi(data.mobileNumber, otp.join("")); await verifyOtp.mutateAsync({
mobile: data.mobileNumber,
otp: otp.join(""),
});
setMobileOtpVerified(true); setMobileOtpVerified(true);
setOtpError(""); setOtpError("");
console.log("Submitting personal details:", data); // log here console.log("Submitting personal details:", data); // log here
@ -193,7 +347,7 @@ const PersonalDetailsForm = ({ onSubmitStep, onSkipStep, errors }) => {
{/* Name */} {/* Name */}
<div className="flex flex-col gap-4"> <div className="flex flex-col gap-4">
<label className="text-gray-900 text-[17px]"> <label className="text-gray-900 text-[17px]">
Enter the Name Enter the Name{requiredMark}
</label> </label>
<TextField <TextField
fullWidth fullWidth
@ -212,7 +366,7 @@ const PersonalDetailsForm = ({ onSubmitStep, onSkipStep, errors }) => {
{/* Gender */} {/* Gender */}
<div className="flex flex-col gap-6"> <div className="flex flex-col gap-6">
<label className="text-gray-900 text-[17px]"> <label className="text-gray-900 text-[17px]">
Enter the Gender Enter the Gender{requiredMark}
</label> </label>
<FormControl <FormControl
fullWidth fullWidth
@ -227,8 +381,11 @@ const PersonalDetailsForm = ({ onSubmitStep, onSkipStep, errors }) => {
value={data.gender} value={data.gender}
onChange={(e) => handleChange("gender", e.target.value)} onChange={(e) => handleChange("gender", e.target.value)}
> >
<MenuItem value="Male">Male</MenuItem> {genderOptions.map((gender) => (
<MenuItem value="Female">Female</MenuItem> <MenuItem key={gender} value={gender}>
{gender}
</MenuItem>
))}
</Select> </Select>
{errors.gender && ( {errors.gender && (
<p <p
@ -246,6 +403,10 @@ const PersonalDetailsForm = ({ onSubmitStep, onSkipStep, errors }) => {
{/* Mobile Number and Send OTP Button */} {/* Mobile Number and Send OTP Button */}
<div className="flex flex-col gap-6 relative"> <div className="flex flex-col gap-6 relative">
<label className="text-gray-900 text-[17px]">
Mobile Number{requiredMark}
</label>
<Box sx={{ display: "flex", alignItems: "start", gap: 2 }}>
<TextField <TextField
fullWidth fullWidth
name="mobileNumber" name="mobileNumber"
@ -259,23 +420,43 @@ const PersonalDetailsForm = ({ onSubmitStep, onSkipStep, errors }) => {
helperText={mobileNumberError || errors.mobileNumber} helperText={mobileNumberError || errors.mobileNumber}
placeholder="Enter Mobile Number" placeholder="Enter Mobile Number"
inputProps={{ maxLength: 10 }} inputProps={{ maxLength: 10 }}
variant="outlined" InputProps={{
disabled={mobileOtpVerified} endAdornment: mobileOtpVerified ? (
// sx={{ maxWidth: "430px" }} <InputAdornment position="end">
<CheckCircleIcon
sx={{
color: "#2e7d32",
animation: "verifiedPulse 1.2s ease-in-out infinite",
"@keyframes verifiedPulse": {
"0%": { transform: "scale(1)", opacity: 0.8 },
"50%": { transform: "scale(1.08)", opacity: 1 },
"100%": { transform: "scale(1)", opacity: 0.8 },
},
}}
/>
</InputAdornment>
) : null,
}}
variant="outlined"
sx={{
"& .MuiInputBase-input.Mui-disabled": {
cursor: "not-allowed",
},
}}
/> />
<Box sx={{ position: "absolute", right: 0 }}>
{!showOtp && !mobileOtpVerified && ( {!showOtp && !mobileOtpVerified && (
<Button <Button
variant="outlined" variant="outlined"
color="primary" color="primary"
onClick={handleMobileSubmit} onClick={handleMobileSubmit}
sx={{ sx={{
padding: "15px 10px", whiteSpace: "nowrap",
height: "56px",
background: "green", background: "green",
color: "#fff", color: "#fff",
}} }}
> >
Send OTP Verify
</Button> </Button>
)} )}
</Box> </Box>
@ -296,10 +477,16 @@ const PersonalDetailsForm = ({ onSubmitStep, onSkipStep, errors }) => {
textAlign: "center", textAlign: "center",
width: 40, width: 40,
fontSize: 20, fontSize: 20,
borderRadius: 4,
backgroundColor: digit
? "#028f02"
: "transparent",
color: digit ? "#fff" : "#000",
}, },
}} }}
value={digit} value={digit}
onChange={(e) => handleOtpChange(index, e.target.value)} onChange={(e) => handleOtpChange(index, e.target.value)}
onKeyDown={(e) => handleOtpKeyDown(index, e)}
error={Boolean(otpError)} error={Boolean(otpError)}
autoFocus={index === 0} autoFocus={index === 0}
variant="outlined" variant="outlined"
@ -340,22 +527,7 @@ const PersonalDetailsForm = ({ onSubmitStep, onSkipStep, errors }) => {
</> </>
)} )}
{mobileOtpVerified && (
<Typography
color="primary"
variant="body2"
sx={{
background: "green",
padding: "17px 15px",
width: "fit-content",
borderRadius: "5px",
color: "#fff",
fontSize: "18px",
}}
>
Mobile number verified
</Typography>
)}
</div> </div>
{/* Other fields like DOB, height, marital status, etc. */} {/* Other fields like DOB, height, marital status, etc. */}
@ -378,7 +550,9 @@ const PersonalDetailsForm = ({ onSubmitStep, onSkipStep, errors }) => {
{/* DOB with MUI DatePicker */} {/* DOB with MUI DatePicker */}
<div className="flex flex-col gap-2"> <div className="flex flex-col gap-2">
<label className="text-gray-900 text-[15px]">Date of Birth</label> <label className="text-gray-900 text-[15px]">
Date of Birth{requiredMark}
</label>
<LocalizationProvider dateAdapter={AdapterDateFns}> <LocalizationProvider dateAdapter={AdapterDateFns}>
<DatePicker <DatePicker
format="dd/MM/yyyy" format="dd/MM/yyyy"
@ -411,10 +585,12 @@ const PersonalDetailsForm = ({ onSubmitStep, onSkipStep, errors }) => {
fullWidth fullWidth
name="height" name="height"
label="Enter Height" label="Enter Height"
type="number"
value={data.height} value={data.height}
onChange={(e) => handleChange("height", e.target.value)} onChange={(e) => handleChange("height", e.target.value)}
error={Boolean(errors.height)} error={Boolean(errors.height)}
helperText={errors.height} helperText={errors.height}
inputProps={{ min: 0, max: 10, step: "0.1" }}
variant="outlined" variant="outlined"
/> />
</div> </div>
@ -426,17 +602,21 @@ const PersonalDetailsForm = ({ onSubmitStep, onSkipStep, errors }) => {
fullWidth fullWidth
name="weight" name="weight"
label="Enter Weight" label="Enter Weight"
type="number"
value={data.weight} value={data.weight}
onChange={(e) => handleChange("weight", e.target.value)} onChange={(e) => handleChange("weight", e.target.value)}
error={Boolean(errors.weight)} error={Boolean(errors.weight)}
helperText={errors.weight} helperText={errors.weight}
inputProps={{ min: 0, max: 300, step: "0.1" }}
variant="outlined" variant="outlined"
/> />
</div> </div>
{/* Marital Status */} {/* Marital Status */}
<div className="flex flex-col gap-2"> <div className="flex flex-col gap-2">
<label className="text-gray-900 text-[15px]">Marital Status</label> <label className="text-gray-900 text-[15px]">
Marital Status{requiredMark}
</label>
<FormControl <FormControl
fullWidth fullWidth
variant="outlined" variant="outlined"
@ -454,9 +634,11 @@ const PersonalDetailsForm = ({ onSubmitStep, onSkipStep, errors }) => {
handleChange("maritalStatus", e.target.value) handleChange("maritalStatus", e.target.value)
} }
> >
<MenuItem value="Single">Single</MenuItem> {maritalStatusOptions.map((status) => (
<MenuItem value="Divorced">Divorced</MenuItem> <MenuItem key={status.id} value={status.id}>
<MenuItem value="Widowed">Widowed</MenuItem> {status.marital_status_name}
</MenuItem>
))}
</Select> </Select>
{errors.maritalStatus && ( {errors.maritalStatus && (
<Typography <Typography
@ -472,7 +654,9 @@ const PersonalDetailsForm = ({ onSubmitStep, onSkipStep, errors }) => {
{/* Religion */} {/* Religion */}
<div className="flex flex-col gap-2"> <div className="flex flex-col gap-2">
<label className="text-gray-900 text-[15px]">Religion</label> <label className="text-gray-900 text-[15px]">
Religion
</label>
<FormControl <FormControl
fullWidth fullWidth
variant="outlined" variant="outlined"
@ -486,10 +670,11 @@ const PersonalDetailsForm = ({ onSubmitStep, onSkipStep, errors }) => {
value={data.religion} value={data.religion}
onChange={(e) => handleChange("religion", e.target.value)} onChange={(e) => handleChange("religion", e.target.value)}
> >
<MenuItem value="Hindu">Hindu</MenuItem> {religionOptions.map((religion) => (
<MenuItem value="Muslim">Muslim</MenuItem> <MenuItem key={religion.id} value={religion.id}>
<MenuItem value="Christian">Christian</MenuItem> {religion.religion_name}
<MenuItem value="Others">Others</MenuItem> </MenuItem>
))}
</Select> </Select>
{errors.religion && ( {errors.religion && (
<Typography <Typography
@ -503,10 +688,48 @@ const PersonalDetailsForm = ({ onSubmitStep, onSkipStep, errors }) => {
</FormControl> </FormControl>
</div> </div>
{/* Profile Created For */}
<div className="flex flex-col gap-2">
<label className="text-gray-900 text-[15px]">
Profile Created For{requiredMark}
</label>
<FormControl
fullWidth
variant="outlined"
error={Boolean(errors.profileFor)}
>
<InputLabel id="profileFor-label">
Select Profile Created For
</InputLabel>
<Select
labelId="profileFor-label"
label="Select Profile Created For"
name="profileFor"
value={data.profileFor}
onChange={(e) => handleChange("profileFor", e.target.value)}
>
{profileCreatedForOptions.map((profileFor) => (
<MenuItem key={profileFor.id} value={profileFor.id}>
{profileFor.profile_for_name}
</MenuItem>
))}
</Select>
{errors.profileFor && (
<Typography
color="error"
variant="caption"
sx={{ mt: 0.5, ml: 1.8 }}
>
{errors.profileFor}
</Typography>
)}
</FormControl>
</div>
{/* Caste / Community */} {/* Caste / Community */}
<div className="flex flex-col gap-2"> <div className="flex flex-col gap-2">
<label className="text-gray-900 text-[15px]"> <label className="text-gray-900 text-[15px]">
Caste / Community Caste / Community{requiredMark}
</label> </label>
<FormControl <FormControl
fullWidth fullWidth
@ -520,10 +743,18 @@ const PersonalDetailsForm = ({ onSubmitStep, onSkipStep, errors }) => {
name="caste" name="caste"
value={data.caste} value={data.caste}
onChange={(e) => handleChange("caste", e.target.value)} onChange={(e) => handleChange("caste", e.target.value)}
disabled={!data.religion || casteQuery.isLoading}
sx={{
"& .MuiSelect-select.Mui-disabled": {
cursor: "not-allowed",
},
}}
> >
<MenuItem value="Agamudayar">Agamudayar</MenuItem> {casteOptions.map((caste) => (
<MenuItem value="Brahmin">Brahmin</MenuItem> <MenuItem key={caste.id} value={caste.id}>
<MenuItem value="Others">Others</MenuItem> {getOptionLabel(caste, "Caste")}
</MenuItem>
))}
</Select> </Select>
{errors.caste && ( {errors.caste && (
<Typography <Typography
@ -552,11 +783,21 @@ const PersonalDetailsForm = ({ onSubmitStep, onSkipStep, errors }) => {
name="subCaste" name="subCaste"
value={data.subCaste} value={data.subCaste}
onChange={(e) => handleChange("subCaste", e.target.value)} onChange={(e) => handleChange("subCaste", e.target.value)}
disabled={!data.caste || subCasteQuery.isLoading}
sx={{
"& .MuiSelect-select.Mui-disabled": {
cursor: "not-allowed",
},
}}
> >
<MenuItem value=""> <MenuItem value="">
<em>None</em> <em>None</em>
</MenuItem> </MenuItem>
<MenuItem value="Thuluva vellala">Thuluva vellala</MenuItem> {subCasteOptions.map((subCaste) => (
<MenuItem key={subCaste.id} value={subCaste.id}>
{getOptionLabel(subCaste, "Sub Caste")}
</MenuItem>
))}
</Select> </Select>
</FormControl> </FormControl>
</div> </div>
@ -580,41 +821,91 @@ const PersonalDetailsForm = ({ onSubmitStep, onSkipStep, errors }) => {
<MenuItem value=""> <MenuItem value="">
<em>None</em> <em>None</em>
</MenuItem> </MenuItem>
<MenuItem value="Siva Gotheram">Siva Gotheram</MenuItem> {gothramOptions.map((gothram) => (
<MenuItem key={gothram.id} value={gothram.id}>
{gothram.gothram_name}
</MenuItem>
))}
</Select> </Select>
</FormControl> </FormControl>
</div> </div>
{/* Blood Group (optional) */} {/* Raasi */}
<div className="flex flex-col gap-2"> <div className="flex flex-col gap-2">
<label className="text-gray-900 text-[15px]"> <label className="text-gray-900 text-[15px]">Raasi</label>
Blood Group (optional) <FormControl
</label> fullWidth
<FormControl fullWidth variant="outlined"> variant="outlined"
<InputLabel id="blood-label"> error={Boolean(errors.raasi)}
Select Blood Group (optional)
</InputLabel>
<Select
labelId="blood-label"
label="Select Blood Group (optional)"
name="bloodGroup"
value={data.bloodGroup}
onChange={(e) => handleChange("bloodGroup", e.target.value)}
> >
<MenuItem value=""> <InputLabel id="raasi-label">Select Raasi</InputLabel>
<em>None</em> <Select
labelId="raasi-label"
label="Select Raasi"
name="raasi"
value={data.raasi}
onChange={(e) => handleChange("raasi", e.target.value)}
>
{raasiOptions.map((raasi) => (
<MenuItem key={raasi.id} value={raasi.id}>
{raasi.raasi_name}
</MenuItem> </MenuItem>
<MenuItem value="O+">O+</MenuItem> ))}
<MenuItem value="A+">A+</MenuItem>
<MenuItem value="B+">B+</MenuItem>
<MenuItem value="AB+">AB+</MenuItem>
</Select> </Select>
{errors.raasi && (
<Typography
color="error"
variant="caption"
sx={{ mt: 0.5, ml: 1.8 }}
>
{errors.raasi}
</Typography>
)}
</FormControl> </FormControl>
</div> </div>
{/* Star */}
<div className="flex flex-col gap-2">
<label className="text-gray-900 text-[15px]">Star</label>
<FormControl
fullWidth
variant="outlined"
error={Boolean(errors.star)}
>
<InputLabel id="star-label">Select Star</InputLabel>
<Select
labelId="star-label"
label="Select Star"
name="star"
value={data.star}
onChange={(e) => handleChange("star", e.target.value)}
disabled={!data.raasi || starQuery.isLoading}
>
{starOptions.map((star) => (
<MenuItem key={star.id} value={star.id}>
{getOptionLabel(star, "Star")}
</MenuItem>
))}
</Select>
{errors.star && (
<Typography
color="error"
variant="caption"
sx={{ mt: 0.5, ml: 1.8 }}
>
{errors.star}
</Typography>
)}
</FormControl>
</div>
{/* Email Id */} {/* Email Id */}
<div className="flex flex-col gap-2"> <div className="flex flex-col gap-2">
<label className="text-gray-900 text-[15px]">Email Id</label> <label className="text-gray-900 text-[15px]">
Email Id{requiredMark}
</label>
<TextField <TextField
fullWidth fullWidth
name="email" name="email"
@ -627,9 +918,47 @@ const PersonalDetailsForm = ({ onSubmitStep, onSkipStep, errors }) => {
/> />
</div> </div>
{/* Password */}
<div className="flex flex-col gap-2">
<label className="text-gray-900 text-[15px]">
Password{requiredMark}
</label>
<TextField
fullWidth
type="password"
name="password"
label="Enter Password"
value={data.password}
onChange={(e) => handleChange("password", e.target.value)}
error={Boolean(errors.password)}
helperText={errors.password}
variant="outlined"
/>
</div>
{/* Confirm Password */}
<div className="flex flex-col gap-2">
<label className="text-gray-900 text-[15px]">
Confirm Password{requiredMark}
</label>
<TextField
fullWidth
type="password"
name="confirmPassword"
label="Confirm Password"
value={data.confirmPassword}
onChange={(e) => handleChange("confirmPassword", e.target.value)}
error={Boolean(errors.confirmPassword)}
helperText={errors.confirmPassword}
variant="outlined"
/>
</div>
{/* State */} {/* State */}
<div className="flex flex-col gap-2"> <div className="flex flex-col gap-2">
<label className="text-gray-900 text-[15px]">State</label> <label className="text-gray-900 text-[15px]">
State{requiredMark}
</label>
<FormControl <FormControl
fullWidth fullWidth
variant="outlined" variant="outlined"
@ -642,10 +971,18 @@ const PersonalDetailsForm = ({ onSubmitStep, onSkipStep, errors }) => {
name="state" name="state"
value={data.state} value={data.state}
onChange={(e) => handleChange("state", e.target.value)} onChange={(e) => handleChange("state", e.target.value)}
disabled={isPersonalMastersLoading}
sx={{
"& .MuiSelect-select.Mui-disabled": {
cursor: "not-allowed",
},
}}
> >
<MenuItem value="Tamil Nadu">Tamil Nadu</MenuItem> {stateOptions.map((state) => (
<MenuItem value="Kerala">Kerala</MenuItem> <MenuItem key={state.id} value={state.id}>
<MenuItem value="Karnataka">Karnataka</MenuItem> {state.state_name}
</MenuItem>
))}
</Select> </Select>
{errors.state && ( {errors.state && (
<Typography <Typography
@ -661,7 +998,9 @@ const PersonalDetailsForm = ({ onSubmitStep, onSkipStep, errors }) => {
{/* City */} {/* City */}
<div className="flex flex-col gap-2"> <div className="flex flex-col gap-2">
<label className="text-gray-900 text-[15px]">City</label> <label className="text-gray-900 text-[15px]">
City{requiredMark}
</label>
<FormControl <FormControl
fullWidth fullWidth
variant="outlined" variant="outlined"
@ -674,10 +1013,18 @@ const PersonalDetailsForm = ({ onSubmitStep, onSkipStep, errors }) => {
name="city" name="city"
value={data.city} value={data.city}
onChange={(e) => handleChange("city", e.target.value)} onChange={(e) => handleChange("city", e.target.value)}
disabled={!data.state || cityQuery.isLoading}
sx={{
"& .MuiSelect-select.Mui-disabled": {
cursor: "not-allowed",
},
}}
> >
<MenuItem value="Chennai">Chennai</MenuItem> {cityOptions.map((city) => (
<MenuItem value="Coimbatore">Coimbatore</MenuItem> <MenuItem key={city.id} value={city.id}>
<MenuItem value="Madurai">Madurai</MenuItem> {getOptionLabel(city, "City")}
</MenuItem>
))}
</Select> </Select>
{errors.city && ( {errors.city && (
<Typography <Typography
@ -693,7 +1040,9 @@ const PersonalDetailsForm = ({ onSubmitStep, onSkipStep, errors }) => {
{/* Pin code */} {/* Pin code */}
<div className="flex flex-col gap-2"> <div className="flex flex-col gap-2">
<label className="text-gray-900 text-[15px]">Pin code</label> <label className="text-gray-900 text-[15px]">
Pin code{requiredMark}
</label>
<TextField <TextField
fullWidth fullWidth
name="pincode" name="pincode"
@ -722,7 +1071,7 @@ const PersonalDetailsForm = ({ onSubmitStep, onSkipStep, errors }) => {
<div className="flex flex-col gap-2 md:col-span-2 w-full"> <div className="flex flex-col gap-2 md:col-span-2 w-full">
<label className="text-gray-900 text-[15px]"> <label className="text-gray-900 text-[15px]">
Upload Profile (Multi - Select) Upload Profile (Max 3 images, 10 MB each)
</label> </label>
<AdvancedDropzone <AdvancedDropzone
value={data.profiles || []} value={data.profiles || []}
@ -752,13 +1101,7 @@ const PersonalDetailsForm = ({ onSubmitStep, onSkipStep, errors }) => {
justifyContent: "center", justifyContent: "center",
}} }}
> >
<Button
variant="outlined"
onClick={onSkipStep}
disabled={mobileOtpVerified}
>
Skip
</Button>
<Button <Button
variant="contained" variant="contained"
color="primary" color="primary"

View File

@ -16,6 +16,7 @@ import LifestyleDetailsForm from "./LifestyleDetailsForm";
import PartnerPreferencesForm from "./PartnerPreferencesForm"; import PartnerPreferencesForm from "./PartnerPreferencesForm";
import PreviewScreen from "./PreviewScreen"; import PreviewScreen from "./PreviewScreen";
import { useLocation } from "react-router-dom"; import { useLocation } from "react-router-dom";
import { useRegisterStep1 } from "../hooks/useRegister";
const Stepper = ({ currentStep, onStepClick }) => { const Stepper = ({ currentStep, onStepClick }) => {
@ -82,6 +83,7 @@ const StepperForm = () => {
const [currentStep, setCurrentStep] = useState(initialStep); const [currentStep, setCurrentStep] = useState(initialStep);
const [errors, setErrors] = useState({}); const [errors, setErrors] = useState({});
const registerStep1 = useRegisterStep1();
useEffect(() => { useEffect(() => {
@ -104,12 +106,12 @@ const StepperForm = () => {
"mobileNumber", "mobileNumber",
"gender", "gender",
"dob", "dob",
"height",
"weight",
"maritalStatus", "maritalStatus",
"religion", "profileFor",
"caste", "caste",
"email", "email",
"password",
"confirmPassword",
"state", "state",
"city", "city",
"pincode", "pincode",
@ -133,6 +135,19 @@ const StepperForm = () => {
) { ) {
newErrors.mobileNumber = "Mobile number must be 10 digits"; newErrors.mobileNumber = "Mobile number must be 10 digits";
} }
if (personalDetails.height && Number(personalDetails.height) > 10) {
newErrors.height = "Height must be 10 or less";
}
if (personalDetails.weight && Number(personalDetails.weight) > 300) {
newErrors.weight = "Weight must be 300 or less";
}
if (
personalDetails.password &&
personalDetails.confirmPassword &&
personalDetails.password !== personalDetails.confirmPassword
) {
newErrors.confirmPassword = "Passwords do not match";
}
} else if (step === 2) { } else if (step === 2) {
const required = [ const required = [
"qualification", "qualification",
@ -199,18 +214,38 @@ const StepperForm = () => {
return Object.keys(newErrors).length === 0; return Object.keys(newErrors).length === 0;
}; };
// API call simulation for each step submit const buildRegisterStep1Payload = () => ({
const submitStepAPI = async (step) => { name: personalDetails.name,
// Replace with actual API call mobile: personalDetails.mobileNumber,
return new Promise((resolve) => setTimeout(resolve, 500)); email: personalDetails.email,
}; pincode: personalDetails.pincode,
gender: personalDetails.gender,
dob: personalDetails.dob,
height: personalDetails.height || "",
weight: personalDetails.weight || "",
marital_status: personalDetails.maritalStatus,
religion: personalDetails.religion,
profile_for: personalDetails.profileFor || "",
caste: personalDetails.caste,
sub_caste: personalDetails.subCaste || "",
gothram: personalDetails.gothram || "",
raasi: personalDetails.raasi || "",
star: personalDetails.star || "",
state: personalDetails.state,
district: personalDetails.city,
password: personalDetails.password || "",
fcm_token: localStorage.getItem("fcm_token") || "",
});
const handleStepSubmit = async () => { const handleStepSubmit = async () => {
const isValid = validateStep(currentStep); const isValid = validateStep(currentStep);
if (!isValid) return; if (!isValid) return;
try { try {
await submitStepAPI(currentStep); if (currentStep === 1) {
const payload = buildRegisterStep1Payload();
await registerStep1.mutateAsync(payload);
}
setCurrentStep((prev) => Math.min(prev + 1, 6)); setCurrentStep((prev) => Math.min(prev + 1, 6));
window.scrollTo(0, 0); window.scrollTo(0, 0);
} catch (e) { } catch (e) {
@ -260,7 +295,6 @@ const StepperForm = () => {
return ( return (
<PersonalDetailsForm <PersonalDetailsForm
onSubmitStep={handleStepSubmit} onSubmitStep={handleStepSubmit}
onSkipStep={handleSkip}
errors={errors} errors={errors}
/> />
); );

34
src/hooks/useAuth.js Normal file
View File

@ -0,0 +1,34 @@
import { useMutation, useQueryClient } from "@tanstack/react-query";
import { sendOtpAPI, verifyOtpAPI, logoutAPI } from "../api/auth.api";
/**
* Send OTP
*/
export const useSendOtp = () =>
useMutation({
mutationFn: sendOtpAPI,
});
/**
* Verify OTP
*/
export const useVerifyOtp = () =>
useMutation({
mutationFn: verifyOtpAPI,
});
/**
* Logout
*/
export const useLogout = () => {
const queryClient = useQueryClient();
return useMutation({
mutationFn: logoutAPI,
onSuccess: () => {
queryClient.clear(); // 🔥 clear all cached APIs
localStorage.clear();
window.location.href = "/login";
},
});
};

View File

@ -0,0 +1,48 @@
import { useQuery } from "@tanstack/react-query";
import {
getPersonalDetailsMasters,
getCasteMasters,
getSubCasteMasters,
getCityMasters,
getStarMasters,
} from "../api/masters.api";
/** Personal details masters (gender, marital status, religion, gothram, raasi, state, etc.) */
export const usePersonalDetailsMasters = () =>
useQuery({
queryKey: ["personal-details-masters"],
queryFn: getPersonalDetailsMasters,
staleTime: 1000 * 60 * 60, // 1 hour
});
/** Caste depends on religion */
export const useCasteMasters = (religion_id) =>
useQuery({
queryKey: ["caste-masters", religion_id],
queryFn: () => getCasteMasters(religion_id),
enabled: !!religion_id, // 🚫 prevents unwanted call
});
/** Sub caste depends on caste */
export const useSubCasteMasters = (caste_id) =>
useQuery({
queryKey: ["sub-caste-masters", caste_id],
queryFn: () => getSubCasteMasters(caste_id),
enabled: !!caste_id,
});
/** City depends on state */
export const useCityMasters = (state_id) =>
useQuery({
queryKey: ["city-masters", state_id],
queryFn: () => getCityMasters(state_id),
enabled: !!state_id,
});
/** Star depends on raasi */
export const useStarMasters = (raasi_id) =>
useQuery({
queryKey: ["star-masters", raasi_id],
queryFn: () => getStarMasters(raasi_id),
enabled: !!raasi_id,
});

43
src/hooks/useMasters.js Normal file
View File

@ -0,0 +1,43 @@
import { useQuery } from "@tanstack/react-query";
import {
getPersonalDetailsMasters,
getEducationMasters,
getFamilyMasters,
getLifestyleMasters,
getPartnerPreferenceMasters,
} from "../api/masters.api";
/** Personal details master */
export const usePersonalMasters = () =>
useQuery({
queryKey: ["personal-masters"],
queryFn: getPersonalDetailsMasters,
});
/** Education master */
export const useEducationMasters = () =>
useQuery({
queryKey: ["education-masters"],
queryFn: getEducationMasters,
});
/** Family master */
export const useFamilyMasters = () =>
useQuery({
queryKey: ["family-masters"],
queryFn: getFamilyMasters,
});
/** Lifestyle master */
export const useLifestyleMasters = () =>
useQuery({
queryKey: ["lifestyle-masters"],
queryFn: getLifestyleMasters,
});
/** Partner preference master */
export const usePartnerPreferenceMasters = () =>
useQuery({
queryKey: ["partner-masters"],
queryFn: getPartnerPreferenceMasters,
});

39
src/hooks/useRegister.js Normal file
View File

@ -0,0 +1,39 @@
import { useMutation } from "@tanstack/react-query";
import {
registerStep1API,
registerStep2API,
registerStep3API,
registerStep4API,
} from "../api/register.api";
/**
* Register - Step 1
*/
export const useRegisterStep1 = () =>
useMutation({
mutationFn: registerStep1API,
});
/**
* Register - Step 2
*/
export const useRegisterStep2 = () =>
useMutation({
mutationFn: registerStep2API,
});
/**
* Register - Step 3
*/
export const useRegisterStep3 = () =>
useMutation({
mutationFn: registerStep3API,
});
/**
* Register - Step 4
*/
export const useRegisterStep4 = () =>
useMutation({
mutationFn: registerStep4API,
});

View File

@ -8,12 +8,33 @@ import theme from "./theme";
import { Provider } from "react-redux"; import { Provider } from "react-redux";
import { store } from "./redux/store.js"; import { store } from "./redux/store.js";
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
// Disable noisy logs in production while keeping warnings/errors.
if (import.meta.env.PROD) {
console.log = () => {};
console.info = () => {};
console.debug = () => {};
}
const queryClient = new QueryClient({
defaultOptions: {
queries: {
staleTime: 1000 * 60 * 30, // 30 mins masters don't change often
cacheTime: 1000 * 60 * 60, // 1 hour
refetchOnWindowFocus: false,
retry: 1,
},
},
});
ReactDOM.createRoot(document.getElementById("root")).render( ReactDOM.createRoot(document.getElementById("root")).render(
<React.StrictMode>
<ThemeProvider theme={theme}> <ThemeProvider theme={theme}>
<Provider store={store}> <Provider store={store}>
<QueryClientProvider client={queryClient}>
<App /> <App />
</QueryClientProvider>
</Provider> </Provider>
</ThemeProvider> </ThemeProvider>
</React.StrictMode>
); );

View File

@ -0,0 +1,78 @@
// Import the functions you need from the SDKs you need
import { initializeApp } from "firebase/app";
import { getMessaging , getToken,onMessage } from "firebase/messaging";
// import { getAnalytics } from "firebase/analytics";
// TODO: Add SDKs for Firebase products that you want to use
// https://firebase.google.com/docs/web/setup#available-libraries
// Your web app's Firebase configuration
// For Firebase JS SDK v7.20.0 and later, measurementId is optional
const firebaseConfig = {
apiKey: "AIzaSyC14hS0_idUIRS9JEigObmT-_CGl3zb8Fo",
authDomain: "thirukalyanam-c8e1c.firebaseapp.com",
projectId: "thirukalyanam-c8e1c",
storageBucket: "thirukalyanam-c8e1c.firebasestorage.app",
messagingSenderId: "433615056618",
appId: "1:433615056618:web:309a920f408ba826907193",
measurementId: "G-1L93F6DS7K"
};
// Initialize Firebase
const app = initializeApp(firebaseConfig);
// const analytics = getAnalytics(app);
// Initialize Firebase Cloud Messaging and get a reference to the service
export const messaging = getMessaging(app);
// 🔔 Foreground notification handler
export const listenToMessages = () => {
onMessage(messaging, (payload) => {
console.log("🔥 Foreground FCM:", payload);
if (Notification.permission === "granted" && payload.notification) {
const notification = new Notification(
payload.notification.title,
{
body: payload.notification.body,
icon: "/favicon.ico",
data: {
url: "/notification",
},
}
);
// ✅ Handle click
notification.onclick = () => {
window.focus();
window.location.href = "/notification";
};
}
});
};
export const generateToken = async () => {
try {
const permission = await Notification.requestPermission();
console.log("Notification permission:", permission);
if (permission !== "granted") {
return null;
}
const token = await getToken(messaging, {
vapidKey: "BK8tzfEX7yITqrGmWXH-GFYZMXLbVntdfPiOqosyTgCLtHDZm6Rp-K1ro6CPbdMLFgmTa4Fwtc8F2HGFp4Hex7A",
});
console.log("FCM Token:", token);
localStorage.setItem("fcm_token", token);
return token; // ✅ MUST return
} catch (error) {
console.error("FCM error:", error);
return null;
}
};

View File

@ -12,11 +12,16 @@ const registrationformSlice = createSlice({
weight: "", weight: "",
maritalStatus: "", maritalStatus: "",
religion: "", religion: "",
profileFor: "",
caste: "", caste: "",
subCaste: "", subCaste: "",
gothram: "", gothram: "",
raasi: "",
star: "",
bloodGroup: "", bloodGroup: "",
email: "", email: "",
password: "",
confirmPassword: "",
state: "", state: "",
city: "", city: "",
pincode: "", pincode: "",