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
// axios.defaults.baseURL = "https://cheminova-api-2.onrender.com";
//latest render deploy
axios.defaults.baseURL = "https://cheminova-api1.onrender.com"
//axios.defaults.baseURL = "https://api.cnapp.co.in";
//axios.defaults.baseURL = "https://cheminova-api1.onrender.com"
axios.defaults.baseURL = "https://api.cnapp.co.in";
axios.defaults.headers = {
"Cache-Control": "no-cache,no-store",

View File

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

View File

@ -121,7 +121,7 @@ const AddPrincipalDistributor = () => {
setLoading(true);
// 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,
role: "principal-Distributor",
});
@ -455,8 +455,8 @@ const AddPrincipalDistributor = () => {
fullWidth
variant="outlined"
label="Select State"
// error={!selectedState}
// helperText={!selectedState ? "Select a state" : null}
// error={!selectedState}
// helperText={!selectedState ? "Select a state" : null}
/>
)}
/>
@ -499,8 +499,8 @@ const AddPrincipalDistributor = () => {
fullWidth
variant="outlined"
label="Select City"
// error={!selectedCity}
// helperText={!selectedCity ? "Select a city" : null}
// error={!selectedCity}
// helperText={!selectedCity ? "Select a city" : null}
/>
)}
/>

View File

@ -161,7 +161,7 @@ const principalDistributor = () => {
const handleReset = async (id) => {
try {
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
{
headers: {
@ -178,7 +178,7 @@ const principalDistributor = () => {
} catch (error) {
toast.error(
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">
{user.lastOrderDate
? new Date(user.lastOrderDate).toLocaleString(
"en-IN",
{
month: "short",
day: "numeric",
year: "numeric",
}
)
"en-IN",
{
month: "short",
day: "numeric",
year: "numeric",
}
)
: "No purchase"}
</td>
<td className="text-start">
@ -527,35 +527,35 @@ const principalDistributor = () => {
</Link>
</div>
<div className="d-flex flex-column flex-md-row">
<Link
<Link
to={`/principaldistributor/Liqudation/${user?._id}`}
>
<button
type="button"
className="btn btn-info btn-sm waves-effect waves-light btn-table mt-1 mr-1"
>
Liqudation
</button>
</Link>
<Link>
<button
type="button"
className="btn btn-info btn-sm waves-effect waves-light btn-table mt-1"
onClick={() => handleReset(user._id)}
>
Reset
</button>
</Link>
<button
type="button"
className="btn btn-info btn-sm waves-effect waves-light btn-table mt-1 mr-1"
>
Liqudation
</button>
</Link>
<Link>
<button
type="button"
className="btn btn-info btn-sm waves-effect waves-light btn-table mt-1"
onClick={() => handleReset(user._id)}
>
Reset
</button>
</Link>
</div>
<Link
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"
to={`/update-principal-distributor/${user?._id}`}
>
Edit
</button>
<button
type="button"
className="btn btn-info btn-sm waves-effect waves-light btn-table mt-1 mr-1"
>
Edit
</button>
</Link>
</td>
</tr>
@ -587,9 +587,8 @@ const principalDistributor = () => {
<div className="dataTables_paginate paging_simple_numbers">
<ul className="pagination">
<li
className={`paginate_button page-item previous ${
currentPage === 1 ? "disabled" : ""
}`}
className={`paginate_button page-item previous ${currentPage === 1 ? "disabled" : ""
}`}
>
<a
className="page-link"
@ -604,9 +603,8 @@ const principalDistributor = () => {
{Array.from({ length: totalPages }, (_, index) => (
<li
key={index}
className={`paginate_button page-item ${
currentPage === index + 1 ? "active" : ""
}`}
className={`paginate_button page-item ${currentPage === index + 1 ? "active" : ""
}`}
>
<a
className="page-link"
@ -618,9 +616,8 @@ const principalDistributor = () => {
</li>
))}
<li
className={`paginate_button page-item next ${
currentPage === totalPages ? "disabled" : ""
}`}
className={`paginate_button page-item next ${currentPage === totalPages ? "disabled" : ""
}`}
>
<a
className="page-link"

View File

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

View File

@ -122,7 +122,7 @@ const RetailDistributor = () => {
const handleReset = async (id) => {
try {
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
{
headers: {
@ -137,7 +137,7 @@ const RetailDistributor = () => {
} catch (error) {
toast.error(
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">
<ul className="pagination">
<li
className={`paginate_button page-item previous ${
currentPage === 1 ? "disabled" : ""
}`}
className={`paginate_button page-item previous ${currentPage === 1 ? "disabled" : ""
}`}
>
<a
className="page-link"
@ -494,9 +493,8 @@ const RetailDistributor = () => {
return (
<li
key={index}
className={`paginate_button page-item ${
currentPage === page + index ? "active" : ""
}`}
className={`paginate_button page-item ${currentPage === page + index ? "active" : ""
}`}
>
<a
className="page-link"
@ -510,9 +508,8 @@ const RetailDistributor = () => {
}
)}
<li
className={`paginate_button page-item next ${
currentPage === totalPages ? "disabled" : ""
}`}
className={`paginate_button page-item next ${currentPage === totalPages ? "disabled" : ""
}`}
>
<a
className="page-link"

View File

@ -50,29 +50,29 @@ const AddRetailDistributor = () => {
const [selectedCity, setSelectedCity] = useState(null);
const [errors, setErrors] = useState({});
// Fetch all available states on mount
useEffect(() => {
const states = State.getStatesOfCountry("IN").map((state) => ({
label: state.name,
value: state.isoCode,
}));
setStateOptions(states);
}, []);
// Fetch all available states on mount
useEffect(() => {
const states = State.getStatesOfCountry("IN").map((state) => ({
label: state.name,
value: state.isoCode,
}));
setStateOptions(states);
}, []);
// Fetch city options whenever selected state changes
useEffect(() => {
if (selectedState) {
const cities = City.getCitiesOfState("IN", selectedState.value).map(
(city) => ({
label: city.name,
value: city.name,
})
);
setCityOptions(cities);
} else {
setCityOptions([]); // Reset cities if no state selected
}
}, [selectedState]);
// Fetch city options whenever selected state changes
useEffect(() => {
if (selectedState) {
const cities = City.getCitiesOfState("IN", selectedState.value).map(
(city) => ({
label: city.name,
value: city.name,
})
);
setCityOptions(cities);
} else {
setCityOptions([]); // Reset cities if no state selected
}
}, [selectedState]);
const handleInputChange = (e) => {
setUser({ ...user, [e.target.name]: e.target.value });
@ -180,7 +180,7 @@ useEffect(() => {
});
// 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: {
"Content-Type": "multipart/form-data",
Authorization: `Bearer ${token}`,

View File

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

View File

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

View File

@ -114,7 +114,7 @@ const SalesCoOrdinator = () => {
const handleReset = async (id) => {
try {
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
{
headers: {
@ -131,7 +131,7 @@ const SalesCoOrdinator = () => {
} catch (error) {
toast.error(
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 className="text-start">
<span
className={`badge text-white ${
salescoordinator?.isVerified === true
className={`badge text-white ${salescoordinator?.isVerified === true
? "text-bg-success"
: "text-bg-danger"
}`}
}`}
>
{salescoordinator?.isVerified
? "YES"

View File

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

View File

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

View File

@ -114,7 +114,7 @@ const TerritoryManager = () => {
const handleReset = async (id) => {
try {
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
{
headers: {
@ -131,7 +131,7 @@ const TerritoryManager = () => {
} catch (error) {
toast.error(
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 className="text-start">
<span
className={`badge text-white ${
territorymanager?.isVerified === true
className={`badge text-white ${territorymanager?.isVerified === true
? "text-bg-success"
: "text-bg-danger"
}`}
}`}
>
{territorymanager?.isVerified
? "YES"