Move request demo api to separate market controller

This commit is contained in:
Vikas Nale 2025-04-19 12:38:29 +05:30
parent ad449d6e5c
commit 2f09c947a0
3 changed files with 267 additions and 258 deletions

View File

@ -7,7 +7,7 @@ import { zodResolver } from "@hookform/resolvers/zod";
import { z } from "zod"; import { z } from "zod";
import showToast from "../../services/toastService"; import showToast from "../../services/toastService";
import AuthRepository from "../../repositories/AuthRepository"; import AuthRepository from "../../repositories/AuthRepository";
import { MasterRespository } from "../../repositories/MastersRepository"; import { MarketRespository } from "../../repositories/MarketRepository";
const mobileNumberRegex = /^(?:\d{10}|\d{3}[-\s]?\d{3}[-\s]?\d{4})$/; const mobileNumberRegex = /^(?:\d{10}|\d{3}[-\s]?\d{3}[-\s]?\d{4})$/;
@ -35,7 +35,7 @@ const registerSchema = z.object({
}); });
const RegisterPage = () => { const RegisterPage = () => {
const [registered,setRegristered] = useState(false); const [registered, setRegristered] = useState(false);
const [industries, setIndustries] = useState([]); const [industries, setIndustries] = useState([]);
const { const {
register, register,
@ -47,7 +47,7 @@ const RegisterPage = () => {
const onSubmit = async (data) => { const onSubmit = async (data) => {
try { try {
const response = await AuthRepository.requestDemo(data); const response = await MarketRespository.requestDemo(data);
showToast("Your Registration SuccessFully !"); showToast("Your Registration SuccessFully !");
setRegristered(true); setRegristered(true);
} catch (error) { } catch (error) {
@ -59,12 +59,11 @@ const RegisterPage = () => {
fetchIndustries(); fetchIndustries();
}, []); }, []);
useEffect(() => { useEffect(() => {}, [industries]);
}, [industries]);
const fetchIndustries = async () => { const fetchIndustries = async () => {
try { try {
const response = await MasterRespository.getIndustries(); const response = await MarketRespository.getIndustries();
const industry = response.data; const industry = response.data;
setIndustries(industry); setIndustries(industry);
} catch (error) { } catch (error) {
@ -73,254 +72,259 @@ const RegisterPage = () => {
}; };
return ( return (
<> <>
{!registered && (<AuthWrapper> {!registered && (
<h4 className="mb-2">Adventure starts here 🚀</h4> <AuthWrapper>
<p className="mb-3">Make your app management easy and fun!</p> <h4 className="mb-2">Adventure starts here 🚀</h4>
<p className="mb-3">Make your app management easy and fun!</p>
<form <form
id="formAuthentication" id="formAuthentication"
className="mb-3" className="mb-3"
onSubmit={handleSubmit(onSubmit)} onSubmit={handleSubmit(onSubmit)}
> >
<div className="mb-3"> <div className="mb-3">
<label htmlFor="organizatioinName" className="form-label"> <label htmlFor="organizatioinName" className="form-label">
Organization Name Organization Name
</label> </label>
<input <input
type="text" type="text"
className="form-control" className="form-control"
id="organizatioinName" id="organizatioinName"
{...register("organizatioinName")} {...register("organizatioinName")}
name="organizatioinName" name="organizatioinName"
placeholder="Enter your Organization Name" placeholder="Enter your Organization Name"
autoFocus autoFocus
/> />
{errors.organizatioinName && ( {errors.organizatioinName && (
<div <div
className="danger-text text-start" className="danger-text text-start"
style={{ fontSize: "12px" }} style={{ fontSize: "12px" }}
> >
{errors.organizatioinName.message} {errors.organizatioinName.message}
</div> </div>
)}
</div>
<div className="mb-3">
<label htmlFor="email" className="form-label">
Email
</label>
<input
type="text"
className="form-control"
id="email"
name="email"
placeholder="Enter your email"
{...register("email")}
/>
{errors.email && (
<div
className="danger-text text-start"
style={{ fontSize: "12px" }}
>
{errors.email.message}
</div>
)}
</div>
<div className="mb-3 form-password-toggle">
<label className="form-label" htmlFor="contactperson">
Contact Person
</label>
<div className="input-group input-group-merge">
<input
type="text"
id="contactperson"
{...register("contactPerson")}
className="form-control"
name="contactPerson"
placeholder="Contact Person"
aria-describedby="contactperson"
/>
</div>
{errors.contactPerson && (
<div
className="danger-text text-start"
style={{ fontSize: "12px" }}
>
{errors.contactPerson.message}
</div>
)}
</div>
<div className="mb-3 form-password-toggle">
<label className="form-label" htmlFor="contactnumber">
Contact Number
</label>
<div className="input-group input-group-merge">
<input
type="text"
id="contactnumber"
{...register("contactNumber")}
className="form-control"
name="contactNumber"
placeholder="Contact Number"
aria-describedby="contactnumber"
/>
</div>
{errors.contactNumber && (
<div
className="danger-text text-start"
style={{ fontSize: "12px" }}
>
{errors.contactNumber.message}
</div>
)}
</div>
<div className="mb-3 form-password-toggle">
<label className="form-label" htmlFor="contactnumber">
About Organization
</label>
<div className="input-group input-group-merge">
<textarea
id="about"
className="form-control"
placeholder="about"
aria-label="about"
aria-describedby="about"
{...register("about")}
></textarea>
</div>
{errors.about && (
<div
className="danger-text text-start"
style={{ fontSize: "12px" }}
>
{errors.about.message}
</div>
)}
</div>
<div className="mb-3 form-password-toggle">
<label className="form-label" htmlFor="oragnizationSize">
Organization Size
</label>
<div className="input-group input-group-merge">
<select
className="form-select"
id="oragnizationSize"
name="oragnizationSize"
{...register("oragnizationSize")}
aria-label="Default select example"
>
<option value="">Number of Employees</option>
<option value="1-10">1-10</option>
<option value="10-50">10-50</option>
<option value="50-100">50-100</option>
<option value="100-200">100-200</option>
<option value="more than 200">more than 200</option>
</select>
</div>
{errors.oragnizationSize && (
<div
className="danger-text text-start"
style={{ fontSize: "12px" }}
>
{errors.oragnizationSize.message}
</div>
)}
</div>
<div className="mb-3 form-password-toggle">
<label className="form-label" htmlFor="industryId">
Industry
</label>
<div className="input-group input-group-merge">
<select
className="form-select"
id="industryId"
name="industryId"
{...register("industryId")}
aria-label="Default select example"
>
<option value="">
Select Industry
</option>
{industries.length > 0 ? (
industries.map((item) => (
<option value={item.id} key={item.id}>
{item.name}
</option>
))
) : (
<option disabled>Loading industries...</option>
)} )}
</select>
</div>
{errors.industryId && (
<div
className="danger-text text-start"
style={{ fontSize: "12px" }}
>
{errors.industryId.message}
</div> </div>
)} <div className="mb-3">
</div> <label htmlFor="email" className="form-label">
<div className="mb-3"> Email
<div className="form-check"> </label>
<input <input
className="form-check-input" type="text"
type="checkbox" className="form-control"
id="terms-conditions" id="email"
name="terms" name="email"
{...register("terms")} placeholder="Enter your email"
/> {...register("email")}
<label className="form-check-label" htmlFor="terms-conditions"> />
I agree to {errors.email && (
<Link <div
aria-label="Go to Login Page" className="danger-text text-start"
to="/legal-info" style={{ fontSize: "12px" }}
className="d-flex align-items-center justify-content-center" >
> {errors.email.message}
<a aria-label="pricacy policy and terms" href="#"> </div>
{" "} )}
privacy policy & terms
</a>
</Link>
</label>
</div>
{errors.terms && (
<div
className="danger-text text-start"
style={{ fontSize: "12px" }}
>
{errors.terms.message}
</div> </div>
)} <div className="mb-3 form-password-toggle">
</div> <label className="form-label" htmlFor="contactperson">
<button aria-label="Click me" className="btn btn-primary d-grid w-100"> Contact Person
Request Demo </label>
</button> <div className="input-group input-group-merge">
</form> <input
type="text"
id="contactperson"
{...register("contactPerson")}
className="form-control"
name="contactPerson"
placeholder="Contact Person"
aria-describedby="contactperson"
/>
</div>
{errors.contactPerson && (
<div
className="danger-text text-start"
style={{ fontSize: "12px" }}
>
{errors.contactPerson.message}
</div>
)}
</div>
<div className="mb-3 form-password-toggle">
<label className="form-label" htmlFor="contactnumber">
Contact Number
</label>
<div className="input-group input-group-merge">
<input
type="text"
id="contactnumber"
{...register("contactNumber")}
className="form-control"
name="contactNumber"
placeholder="Contact Number"
aria-describedby="contactnumber"
/>
</div>
{errors.contactNumber && (
<div
className="danger-text text-start"
style={{ fontSize: "12px" }}
>
{errors.contactNumber.message}
</div>
)}
</div>
<div className="mb-3 form-password-toggle">
<label className="form-label" htmlFor="contactnumber">
About Organization
</label>
<div className="input-group input-group-merge">
<textarea
id="about"
className="form-control"
placeholder="about"
aria-label="about"
aria-describedby="about"
{...register("about")}
></textarea>
</div>
{errors.about && (
<div
className="danger-text text-start"
style={{ fontSize: "12px" }}
>
{errors.about.message}
</div>
)}
</div>
<div className="mb-3 form-password-toggle">
<label className="form-label" htmlFor="oragnizationSize">
Organization Size
</label>
<div className="input-group input-group-merge">
<select
className="form-select"
id="oragnizationSize"
name="oragnizationSize"
{...register("oragnizationSize")}
aria-label="Default select example"
>
<option value="">Number of Employees</option>
<option value="1-10">1-10</option>
<option value="10-50">10-50</option>
<option value="50-100">50-100</option>
<option value="100-200">100-200</option>
<option value="more than 200">more than 200</option>
</select>
</div>
{errors.oragnizationSize && (
<div
className="danger-text text-start"
style={{ fontSize: "12px" }}
>
{errors.oragnizationSize.message}
</div>
)}
</div>
<div className="mb-3 form-password-toggle">
<label className="form-label" htmlFor="industryId">
Industry
</label>
<div className="input-group input-group-merge">
<select
className="form-select"
id="industryId"
name="industryId"
{...register("industryId")}
aria-label="Default select example"
>
<option value="">Select Industry</option>
{industries.length > 0 ? (
industries.map((item) => (
<option value={item.id} key={item.id}>
{item.name}
</option>
))
) : (
<option disabled>Loading industries...</option>
)}
</select>
</div>
{errors.industryId && (
<div
className="danger-text text-start"
style={{ fontSize: "12px" }}
>
{errors.industryId.message}
</div>
)}
</div>
<div className="mb-3">
<div className="form-check">
<input
className="form-check-input"
type="checkbox"
id="terms-conditions"
name="terms"
{...register("terms")}
/>
<label className="form-check-label" htmlFor="terms-conditions">
I agree to
<Link
aria-label="Go to Login Page"
to="/legal-info"
className="d-flex align-items-center justify-content-center"
>
<a aria-label="pricacy policy and terms" href="#">
{" "}
privacy policy & terms
</a>
</Link>
</label>
</div>
{errors.terms && (
<div
className="danger-text text-start"
style={{ fontSize: "12px" }}
>
{errors.terms.message}
</div>
)}
</div>
<button
aria-label="Click me"
className="btn btn-primary d-grid w-100"
>
Request Demo
</button>
</form>
<p className="text-center"> <p className="text-center">
<span>Already have an account?</span> <span>Already have an account?</span>
<Link <Link
aria-label="Go to Login Page" aria-label="Go to Login Page"
to="/auth/login" to="/auth/login"
className="d-flex align-items-center justify-content-center" className="d-flex align-items-center justify-content-center"
> >
<i className="bx bx-chevron-left scaleX-n1-rtl bx-sm"></i> <i className="bx bx-chevron-left scaleX-n1-rtl bx-sm"></i>
Back to login Back to login
</Link> </Link>
</p> </p>
</AuthWrapper>)} </AuthWrapper>
{registered && (<AuthWrapper> )}
<h6 className="mb-2">Thank you for contacting us</h6> {registered && (
<h4 className="mb-3">We will get back to you soon</h4> <AuthWrapper>
<Link <h6 className="mb-2">Thank you for contacting us</h6>
aria-label="Go to Login Page" <h4 className="mb-3">We will get back to you soon</h4>
to="/auth/login" <Link
className="d-flex align-items-center justify-content-center" aria-label="Go to Login Page"
> to="/auth/login"
<i className="bx bx-chevron-left scaleX-n1-rtl bx-sm"></i> className="d-flex align-items-center justify-content-center"
Back to login >
</Link> <i className="bx bx-chevron-left scaleX-n1-rtl bx-sm"></i>
</AuthWrapper>)} Back to login
</Link>
</AuthWrapper>
)}
</> </>
); );
}; };

View File

@ -2,15 +2,14 @@ import { api } from "../utils/axiosClient";
const AuthRepository = { const AuthRepository = {
login: (data) => api.post("/api/auth/login", data), login: (data) => api.post("/api/auth/login", data),
refreshToken: ( data ) => api.post( "/api/auth/refresh-token", data ), refreshToken: (data) => api.post("/api/auth/refresh-token", data),
logout: ( data ) => api.post( "/api/auth/logout", data ), logout: (data) => api.post("/api/auth/logout", data),
profile: () => api.get( `/api/user/profile` ), profile: () => api.get(`/api/user/profile`),
register: ( data ) => api.post( 'api/auth/register', data ), register: (data) => api.post("api/auth/register", data),
resetPassword: ( data ) => api.post( '/api/auth/reset-password', data ), resetPassword: (data) => api.post("/api/auth/reset-password", data),
forgotPassword: (data) => api.post( '/api/auth/forgot-password', data), forgotPassword: (data) => api.post("/api/auth/forgot-password", data),
requestDemo: (data) => api.post('/api/auth/inquiry',data), sendMail: (data) => api.post("/api/auth/sendmail", data),
sendMail:(data)=>api.post("/api/auth/sendmail",data)
}; };
export default AuthRepository; export default AuthRepository;

View File

@ -0,0 +1,6 @@
import { api } from "../utils/axiosClient";
export const MarketRepository = {
requestDemo: (data) => api.post("/api/market/inquiry", data),
getIndustries: () => api.get("api/market/industries"),
};