change 13 api forgot password render

This commit is contained in:
pawan-dot 2025-05-09 10:44:24 +05:30
parent f4c2383675
commit ad00bd4c2d
13 changed files with 102 additions and 114 deletions

View File

@ -19,8 +19,8 @@ const setupAxios = () => {
//Old render deploy //Old render deploy
// axios.defaults.baseURL = "https://cheminova-api-2.onrender.com"; // axios.defaults.baseURL = "https://cheminova-api-2.onrender.com";
//latest render deploy //latest render deploy
axios.defaults.baseURL = "https://cheminova-api1.onrender.com" //axios.defaults.baseURL = "https://cheminova-api1.onrender.com"
//axios.defaults.baseURL = "https://api.cnapp.co.in"; axios.defaults.baseURL = "https://api.cnapp.co.in";
axios.defaults.headers = { axios.defaults.headers = {
"Cache-Control": "no-cache,no-store", "Cache-Control": "no-cache,no-store",

View File

@ -18,7 +18,7 @@ const AddMultiplePd = () => {
if ( if (
selectedFile && selectedFile &&
selectedFile.type === selectedFile.type ===
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
) { ) {
setFile(selectedFile); setFile(selectedFile);
} else { } else {
@ -44,7 +44,7 @@ const AddMultiplePd = () => {
formData.append("file", file); formData.append("file", file);
const { data } = await axios.post( const { data } = await axios.post(
"/api/v1/principaldistributor/upload", "https://cheminova-api1.onrender.com/api/v1/principaldistributor/upload",
formData, formData,
{ {
headers: { headers: {
@ -94,8 +94,7 @@ const AddMultiplePd = () => {
console.error("Upload error:", error); console.error("Upload error:", error);
swal( swal(
"Error", "Error",
`Failed to upload Principal Distributor: ${ `Failed to upload Principal Distributor: ${error.response?.data?.message || "An unexpected error occurred"
error.response?.data?.message || "An unexpected error occurred"
}`, }`,
"error" "error"
); );

View File

@ -121,7 +121,7 @@ const AddPrincipalDistributor = () => {
setLoading(true); setLoading(true);
// Attempt to register user // Attempt to register user
const userResponse = await axios.post("/api/v1/user/register", { const userResponse = await axios.post("https://cheminova-api1.onrender.com/api/v1/user/register", {
...user, ...user,
role: "principal-Distributor", role: "principal-Distributor",
}); });
@ -455,8 +455,8 @@ const AddPrincipalDistributor = () => {
fullWidth fullWidth
variant="outlined" variant="outlined"
label="Select State" label="Select State"
// error={!selectedState} // error={!selectedState}
// helperText={!selectedState ? "Select a state" : null} // helperText={!selectedState ? "Select a state" : null}
/> />
)} )}
/> />
@ -499,8 +499,8 @@ const AddPrincipalDistributor = () => {
fullWidth fullWidth
variant="outlined" variant="outlined"
label="Select City" label="Select City"
// error={!selectedCity} // error={!selectedCity}
// helperText={!selectedCity ? "Select a city" : null} // helperText={!selectedCity ? "Select a city" : null}
/> />
)} )}
/> />

View File

@ -161,7 +161,7 @@ const principalDistributor = () => {
const handleReset = async (id) => { const handleReset = async (id) => {
try { try {
const response = await axios.put( const response = await axios.put(
`/api/v1/user/reset-password/${id}`, `https://cheminova-api1.onrender.com/api/v1/user/reset-password/${id}`,
{}, // No body content required for this request {}, // No body content required for this request
{ {
headers: { headers: {
@ -178,7 +178,7 @@ const principalDistributor = () => {
} catch (error) { } catch (error) {
toast.error( toast.error(
error.response?.data?.message || error.response?.data?.message ||
"Failed to reset the password. Please try again." "Failed to reset the password. Please try again."
); );
} }
}; };
@ -369,13 +369,13 @@ const principalDistributor = () => {
<td className="text-start"> <td className="text-start">
{user.lastOrderDate {user.lastOrderDate
? new Date(user.lastOrderDate).toLocaleString( ? new Date(user.lastOrderDate).toLocaleString(
"en-IN", "en-IN",
{ {
month: "short", month: "short",
day: "numeric", day: "numeric",
year: "numeric", year: "numeric",
} }
) )
: "No purchase"} : "No purchase"}
</td> </td>
<td className="text-start"> <td className="text-start">
@ -527,35 +527,35 @@ const principalDistributor = () => {
</Link> </Link>
</div> </div>
<div className="d-flex flex-column flex-md-row"> <div className="d-flex flex-column flex-md-row">
<Link <Link
to={`/principaldistributor/Liqudation/${user?._id}`} to={`/principaldistributor/Liqudation/${user?._id}`}
> >
<button <button
type="button" type="button"
className="btn btn-info btn-sm waves-effect waves-light btn-table mt-1 mr-1" className="btn btn-info btn-sm waves-effect waves-light btn-table mt-1 mr-1"
> >
Liqudation Liqudation
</button> </button>
</Link> </Link>
<Link> <Link>
<button <button
type="button" type="button"
className="btn btn-info btn-sm waves-effect waves-light btn-table mt-1" className="btn btn-info btn-sm waves-effect waves-light btn-table mt-1"
onClick={() => handleReset(user._id)} onClick={() => handleReset(user._id)}
> >
Reset Reset
</button> </button>
</Link> </Link>
</div> </div>
<Link <Link
to={`/update-principal-distributor/${user?._id}`} to={`/update-principal-distributor/${user?._id}`}
>
<button
type="button"
className="btn btn-info btn-sm waves-effect waves-light btn-table mt-1 mr-1"
> >
Edit <button
</button> type="button"
className="btn btn-info btn-sm waves-effect waves-light btn-table mt-1 mr-1"
>
Edit
</button>
</Link> </Link>
</td> </td>
</tr> </tr>
@ -587,9 +587,8 @@ const principalDistributor = () => {
<div className="dataTables_paginate paging_simple_numbers"> <div className="dataTables_paginate paging_simple_numbers">
<ul className="pagination"> <ul className="pagination">
<li <li
className={`paginate_button page-item previous ${ className={`paginate_button page-item previous ${currentPage === 1 ? "disabled" : ""
currentPage === 1 ? "disabled" : "" }`}
}`}
> >
<a <a
className="page-link" className="page-link"
@ -604,9 +603,8 @@ const principalDistributor = () => {
{Array.from({ length: totalPages }, (_, index) => ( {Array.from({ length: totalPages }, (_, index) => (
<li <li
key={index} key={index}
className={`paginate_button page-item ${ className={`paginate_button page-item ${currentPage === index + 1 ? "active" : ""
currentPage === index + 1 ? "active" : "" }`}
}`}
> >
<a <a
className="page-link" className="page-link"
@ -618,9 +616,8 @@ const principalDistributor = () => {
</li> </li>
))} ))}
<li <li
className={`paginate_button page-item next ${ className={`paginate_button page-item next ${currentPage === totalPages ? "disabled" : ""
currentPage === totalPages ? "disabled" : "" }`}
}`}
> >
<a <a
className="page-link" className="page-link"

View File

@ -18,7 +18,7 @@ const AddMultiplerd = () => {
if ( if (
selectedFile && selectedFile &&
selectedFile.type === selectedFile.type ===
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
) { ) {
setFile(selectedFile); setFile(selectedFile);
} else { } else {
@ -44,7 +44,7 @@ const AddMultiplerd = () => {
formData.append("file", file); formData.append("file", file);
const { data } = await axios.post( const { data } = await axios.post(
"/api/retaildistributor/upload", "https://cheminova-api1.onrender.com/api/retaildistributor/upload",
formData, formData,
{ {
headers: { headers: {
@ -95,8 +95,7 @@ const AddMultiplerd = () => {
console.error("Upload error:", error); console.error("Upload error:", error);
swal( swal(
"Error", "Error",
`Failed to upload Retailers: ${ `Failed to upload Retailers: ${error.response?.data?.message || "An unexpected error occurred"
error.response?.data?.message || "An unexpected error occurred"
}`, }`,
"error" "error"
); );

View File

@ -122,7 +122,7 @@ const RetailDistributor = () => {
const handleReset = async (id) => { const handleReset = async (id) => {
try { try {
const response = await axios.put( const response = await axios.put(
`/api/rd/reset-password/${id}`, `https://cheminova-api1.onrender.com/api/rd/reset-password/${id}`,
{}, // No body content required for this request {}, // No body content required for this request
{ {
headers: { headers: {
@ -137,7 +137,7 @@ const RetailDistributor = () => {
} catch (error) { } catch (error) {
toast.error( toast.error(
error.response?.data?.message || error.response?.data?.message ||
"Failed to reset the password. Please try again." "Failed to reset the password. Please try again."
); );
} }
}; };
@ -448,9 +448,8 @@ const RetailDistributor = () => {
<div className="dataTables_paginate paging_simple_numbers"> <div className="dataTables_paginate paging_simple_numbers">
<ul className="pagination"> <ul className="pagination">
<li <li
className={`paginate_button page-item previous ${ className={`paginate_button page-item previous ${currentPage === 1 ? "disabled" : ""
currentPage === 1 ? "disabled" : "" }`}
}`}
> >
<a <a
className="page-link" className="page-link"
@ -494,9 +493,8 @@ const RetailDistributor = () => {
return ( return (
<li <li
key={index} key={index}
className={`paginate_button page-item ${ className={`paginate_button page-item ${currentPage === page + index ? "active" : ""
currentPage === page + index ? "active" : "" }`}
}`}
> >
<a <a
className="page-link" className="page-link"
@ -510,9 +508,8 @@ const RetailDistributor = () => {
} }
)} )}
<li <li
className={`paginate_button page-item next ${ className={`paginate_button page-item next ${currentPage === totalPages ? "disabled" : ""
currentPage === totalPages ? "disabled" : "" }`}
}`}
> >
<a <a
className="page-link" className="page-link"

View File

@ -50,29 +50,29 @@ const AddRetailDistributor = () => {
const [selectedCity, setSelectedCity] = useState(null); const [selectedCity, setSelectedCity] = useState(null);
const [errors, setErrors] = useState({}); const [errors, setErrors] = useState({});
// Fetch all available states on mount // Fetch all available states on mount
useEffect(() => { useEffect(() => {
const states = State.getStatesOfCountry("IN").map((state) => ({ const states = State.getStatesOfCountry("IN").map((state) => ({
label: state.name, label: state.name,
value: state.isoCode, value: state.isoCode,
})); }));
setStateOptions(states); setStateOptions(states);
}, []); }, []);
// Fetch city options whenever selected state changes // Fetch city options whenever selected state changes
useEffect(() => { useEffect(() => {
if (selectedState) { if (selectedState) {
const cities = City.getCitiesOfState("IN", selectedState.value).map( const cities = City.getCitiesOfState("IN", selectedState.value).map(
(city) => ({ (city) => ({
label: city.name, label: city.name,
value: city.name, value: city.name,
}) })
); );
setCityOptions(cities); setCityOptions(cities);
} else { } else {
setCityOptions([]); // Reset cities if no state selected setCityOptions([]); // Reset cities if no state selected
} }
}, [selectedState]); }, [selectedState]);
const handleInputChange = (e) => { const handleInputChange = (e) => {
setUser({ ...user, [e.target.name]: e.target.value }); setUser({ ...user, [e.target.name]: e.target.value });
@ -180,7 +180,7 @@ useEffect(() => {
}); });
// Attempt to create distributor // Attempt to create distributor
const response = await axios.post("/api/kyc/create-admin/", formData, { const response = await axios.post("https://cheminova-api1.onrender.com/api/kyc/create-admin/", formData, {
headers: { headers: {
"Content-Type": "multipart/form-data", "Content-Type": "multipart/form-data",
Authorization: `Bearer ${token}`, Authorization: `Bearer ${token}`,

View File

@ -18,7 +18,7 @@ const AddMultiplesc = () => {
if ( if (
selectedFile && selectedFile &&
selectedFile.type === selectedFile.type ===
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
) { ) {
setFile(selectedFile); setFile(selectedFile);
} else { } else {
@ -44,7 +44,7 @@ const AddMultiplesc = () => {
formData.append("file", file); formData.append("file", file);
const { data } = await axios.post( const { data } = await axios.post(
"/api/salescoordinator/upload", "https://cheminova-api1.onrender.com/api/salescoordinator/upload",
formData, formData,
{ {
headers: { headers: {
@ -98,8 +98,7 @@ const AddMultiplesc = () => {
console.error("Upload error:", error); console.error("Upload error:", error);
swal( swal(
"Error", "Error",
`Failed to upload Sales Coordinators: ${ `Failed to upload Sales Coordinators: ${error.response?.data?.message || "An unexpected error occurred"
error.response?.data?.message || "An unexpected error occurred"
}`, }`,
"error" "error"
); );

View File

@ -135,7 +135,7 @@ const AddSalesCoOrdinator = () => {
if (!validateForm()) return; if (!validateForm()) return;
try { try {
await axios.post("/api/salescoordinator/register", formData, { await axios.post("https://cheminova-api1.onrender.com/api/salescoordinator/register", formData, {
headers: { headers: {
Authorization: `Bearer ${token}`, Authorization: `Bearer ${token}`,
}, },

View File

@ -114,7 +114,7 @@ const SalesCoOrdinator = () => {
const handleReset = async (id) => { const handleReset = async (id) => {
try { try {
const response = await axios.put( const response = await axios.put(
`/api/salescoordinator/reset-password/${id}`, `https://cheminova-api1.onrender.com/api/salescoordinator/reset-password/${id}`,
{}, // No body content required for this request {}, // No body content required for this request
{ {
headers: { headers: {
@ -131,7 +131,7 @@ const SalesCoOrdinator = () => {
} catch (error) { } catch (error) {
toast.error( toast.error(
error.response?.data?.message || error.response?.data?.message ||
"Failed to reset the password. Please try again." "Failed to reset the password. Please try again."
); );
} }
}; };
@ -314,11 +314,10 @@ const SalesCoOrdinator = () => {
</td> </td>
<td className="text-start"> <td className="text-start">
<span <span
className={`badge text-white ${ className={`badge text-white ${salescoordinator?.isVerified === true
salescoordinator?.isVerified === true
? "text-bg-success" ? "text-bg-success"
: "text-bg-danger" : "text-bg-danger"
}`} }`}
> >
{salescoordinator?.isVerified {salescoordinator?.isVerified
? "YES" ? "YES"

View File

@ -18,7 +18,7 @@ const AddMultipletm = () => {
if ( if (
selectedFile && selectedFile &&
selectedFile.type === selectedFile.type ===
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
) { ) {
setFile(selectedFile); setFile(selectedFile);
} else { } else {
@ -44,7 +44,7 @@ const AddMultipletm = () => {
formData.append("file", file); formData.append("file", file);
const { data } = await axios.post( const { data } = await axios.post(
"/api/territorymanager/upload", "https://cheminova-api1.onrender.com/api/territorymanager/upload",
formData, formData,
{ {
headers: { headers: {
@ -98,8 +98,7 @@ const AddMultipletm = () => {
console.error("Upload error:", error); console.error("Upload error:", error);
swal( swal(
"Error", "Error",
`Failed to upload Territory Managers: ${ `Failed to upload Territory Managers: ${error.response?.data?.message || "An unexpected error occurred"
error.response?.data?.message || "An unexpected error occurred"
}`, }`,
"error" "error"
); );

View File

@ -51,7 +51,7 @@ const AddTerritoryManager = () => {
e.preventDefault(); e.preventDefault();
if (!validateForm()) return; if (!validateForm()) return;
try { try {
await axios.post("/api/territorymanager/register", formData, { await axios.post("https://cheminova-api1.onrender.com/api/territorymanager/register", formData, {
headers: { headers: {
Authorization: `Bearer ${token}`, Authorization: `Bearer ${token}`,
}, },
@ -128,7 +128,7 @@ const AddTerritoryManager = () => {
<div className="card"> <div className="card">
<div className="card-body"> <div className="card-body">
<form onSubmit={handleRegister}> <form onSubmit={handleRegister}>
<div className="form-group"> <div className="form-group">
<label>Employee Code *</label> <label>Employee Code *</label>
<input <input
type="text" type="text"
@ -218,7 +218,7 @@ const AddTerritoryManager = () => {
</Modal.Body> </Modal.Body>
<Modal.Footer> <Modal.Footer>
<Button variant="secondary" onClick={() => setShowModal(false)}> <Button variant="secondary" onClick={() => setShowModal(false)}>
Close Close
</Button> </Button>
<Button variant="primary" onClick={handleVerifyOTP}> <Button variant="primary" onClick={handleVerifyOTP}>
Verify OTP Verify OTP

View File

@ -114,7 +114,7 @@ const TerritoryManager = () => {
const handleReset = async (id) => { const handleReset = async (id) => {
try { try {
const response = await axios.put( const response = await axios.put(
`/api/territorymanager/reset-password/${id}`, `https://cheminova-api1.onrender.com/api/territorymanager/reset-password/${id}`,
{}, // No body content required for this request {}, // No body content required for this request
{ {
headers: { headers: {
@ -131,7 +131,7 @@ const TerritoryManager = () => {
} catch (error) { } catch (error) {
toast.error( toast.error(
error.response?.data?.message || error.response?.data?.message ||
"Failed to reset the password. Please try again." "Failed to reset the password. Please try again."
); );
} }
}; };
@ -312,11 +312,10 @@ const TerritoryManager = () => {
</td> </td>
<td className="text-start"> <td className="text-start">
<span <span
className={`badge text-white ${ className={`badge text-white ${territorymanager?.isVerified === true
territorymanager?.isVerified === true
? "text-bg-success" ? "text-bg-success"
: "text-bg-danger" : "text-bg-danger"
}`} }`}
> >
{territorymanager?.isVerified {territorymanager?.isVerified
? "YES" ? "YES"