liqudation

This commit is contained in:
Sibunnayak 2025-01-11 16:39:32 +05:30
parent 43b913d450
commit 0f7110108a
6 changed files with 1232 additions and 3 deletions

View File

@ -175,6 +175,8 @@ import TaskSalesCoordinator from "./views/Tasks/TaskSalesCoordinator";
import TaskTerritoryManager from "./views/Tasks/TaskTerritoryManager";
import SingleUserTask from "./views/Tasks/SingleUserTask";
import Tasks from "./views/Tasks/Task";
import DistributorLiqudations from "./views/PrincipalDistributors/DistributorLiqudation";
import UpdatePrincipalDistributor from "./views/PrincipalDistributors/updateprincipaldistributor";
const routes = [
//dashboard
@ -457,6 +459,12 @@ const routes = [
element: DistributorStocks,
navName: "Distributor",
},
{
path: "/:distributortype/Liqudation/:id",
name: " Distributor Liqudation",
element: DistributorLiqudations,
navName: "Distributor",
},
{
path: "/:distributortype/opening-inventory/:id",
name: " Distributor Opening Inventory",
@ -526,6 +534,12 @@ const routes = [
element: addPrincipalDistributor,
navName: "PrincipalDistributor",
},
{
path: "/update-principal-distributor/:id",
name: "PrincipalDistributor",
element: UpdatePrincipalDistributor,
navName: "PrincipalDistributor",
},
{
path: "/add-principal-distributor/multiple",
name: "PrincipalDistributor",

View File

@ -0,0 +1,479 @@
import React, { useState, useEffect, useRef, useCallback } from "react";
import { Link, useParams } from "react-router-dom";
import axios from "axios";
import Button from "@material-ui/core/Button";
import { useNavigate } from "react-router-dom";
import { isAutheticated } from "src/auth";
import swal from "sweetalert";
import debounce from "lodash.debounce";
import { Typography, Paper } from "@mui/material";
const DistributorLiqudations = () => {
const token = isAutheticated();
const navigate = useNavigate();
const { id } = useParams();
const { distributortype } = useParams();
const { stocks } = useParams();
const [loading, setLoading] = useState(false);
const [productsData, setProductsData] = useState([]);
const [categories, setCategories] = useState([]);
const [brands, setBrands] = useState([]);
const [user, setUser] = useState(null);
const nameRef = useRef();
const categoryRef = useRef();
const brandRef = useRef();
const [currentPage, setCurrentPage] = useState(1);
const [itemPerPage, setItemPerPage] = useState(10);
const [totalData, setTotalData] = useState(0);
// Fetch User Details
const getUserDetails = useCallback(async () => {
try {
const response = await axios.get(
distributortype === "principaldistributor"
? `/api/v1/admin/user/${id}`
: `/api/getRD/${id}`,
{
headers: {
Authorization: `Bearer ${token}`,
},
}
);
distributortype === "principaldistributor"
? setUser(response.data.user)
: setUser(response.data);
} catch (error) {
swal({
title: "Warning",
text: error.message,
icon: "error",
button: "Close",
dangerMode: true,
});
}
}, [id, token]);
// Call getUserDetails on component mount
useEffect(() => {
getUserDetails();
}, [getUserDetails]);
const getProductsData = async () => {
setLoading(true);
try {
const response = await axios.get(
distributortype === "principaldistributor"
? `/api/pd/stock/${id}`
: `/api/rd/stock/${id}`,
{
headers: {
Authorization: `Bearer ${token}`,
},
params: {
page: currentPage,
show: itemPerPage,
name: nameRef.current?.value || "",
category: categoryRef.current?.value || "",
brand: brandRef.current?.value || "",
},
}
);
// console.log(response.data);
setProductsData(response.data?.products || []);
setTotalData(response.data?.totalProducts || 0);
} catch (err) {
const msg = err?.response?.data?.msg || "Something went wrong!";
swal({
title: "Error",
text: msg,
icon: "error",
button: "Retry",
dangerMode: true,
});
} finally {
setLoading(false);
}
};
const getCatagories = () => {
axios
.get(`/api/category/getCategories`, {
headers: {
"Access-Control-Allow-Origin": "*",
Authorization: `Bearer ${token}`,
},
})
.then((res) => {
// console.log(res?.data?.categories);
setCategories(res?.data?.categories);
});
};
const getBrands = () => {
axios
.get(`/api/brand/getBrands`, {
headers: {
"Access-Control-Allow-Origin": "*",
Authorization: `Bearer ${token}`,
},
})
.then((res) => {
// console.log(res?.data?.brands);
setBrands(res?.data?.brands);
});
};
const [currencyDetails, setCurrencyDetails] = useState(null);
const getCurrency = async () => {
try {
const response = await axios.get("/api/currency/getall", {
// headers: {
// Authorization: `Bearer ${token}`,
// },
});
if (response.status === 200) {
setCurrencyDetails(response?.data?.currency[0]);
}
} catch (error) {
console.log(error);
}
};
useEffect(() => {
getCatagories();
getCurrency();
getBrands();
}, []);
useEffect(() => {
getProductsData();
}, [itemPerPage, currentPage]);
const debouncedSearch = useCallback(
debounce(() => {
setCurrentPage(1);
getProductsData();
}, 500),
[]
);
const handleSearchChange = () => {
debouncedSearch();
};
const handleCancel = () => {
navigate(
distributortype === "principaldistributor"
? // ? stocks==="stocks"?"/principal-distributor":"/opening-inventory"
"/principal-distributor"
: "/retail-distributor"
);
};
return (
<div className="main-content">
<div className="page-content">
<div className="container-fluid">
<div className="row">
<div className="col-12">
<Paper sx={{ p: 2 }}>
<div
className="
page-title-box
d-flex
align-items-center
justify-content-between
"
>
<div style={{ flex: 1 }}>
<Typography>
<strong>Name:</strong> {user?.name}
</Typography>
<Typography>
<strong>Mobile Number:</strong>{" "}
{distributortype === "principaldistributor"
? user?.phone
: user?.mobile_number}
</Typography>
<Typography>
<strong>Email:</strong> {user?.email}
</Typography>
</div>
{/* Back Button on the right */}
<div className="page-title-right">
<Button
variant="contained"
color="secondary"
style={{
fontWeight: "bold",
textTransform: "capitalize",
}}
onClick={handleCancel}
>
Back
</Button>
</div>
</div>
</Paper>
{/* Section Heading: Product Stocks */}
<div className="row mt-2 mb-1">
<div className="col-12">
<div style={{ fontSize: "22px" }} className="fw-bold">
Monthly Product Details Report
</div>
</div>
</div>
</div>
</div>
<div className="row">
<div className="col-lg-12">
<div className="card">
<div className="card-body">
<div className="row ml-0 mr-0 mb-10">
<div className="col-lg-1">
<div className="dataTables_length">
<label className="w-100">
Show
<select
onChange={(e) => {
setItemPerPage(e.target.value);
setCurrentPage(1);
}}
className="form-control"
disabled={loading}
>
<option value="10">10</option>
<option value="25">25</option>
<option value="50">50</option>
<option value="100">100</option>
</select>
entries
</label>
</div>
</div>
<div className="col-lg-3">
<label>Product Name:</label>
<input
type="text"
placeholder="product name"
className="form-control"
ref={nameRef}
onChange={handleSearchChange}
disabled={loading}
/>
</div>
<div className="col-lg-3">
<label>Filter by Category:</label>
<select
className="form-control"
ref={categoryRef}
onChange={handleSearchChange}
disabled={loading}
>
<option value="">All</option>
{categories?.map((e, i) => (
<option key={i} value={e._id}>
{e?.categoryName}
</option>
))}
</select>
</div>
<div className="col-lg-3">
<label>Filter by Brand:</label>
<select
className="form-control"
ref={brandRef}
onChange={handleSearchChange}
disabled={loading}
>
<option value="">All</option>
{brands?.map((e, i) => (
<option key={i} value={e._id}>
{e?.brandName}
</option>
))}
</select>
</div>
</div>
<div className="table-responsive table-shoot mt-3">
<table
className="table table-centered table-nowrap"
style={{ border: "1px solid" }}
>
<thead
className="thead-light"
style={{ background: "#ecdddd" }}
>
<tr>
<th className="text-start">SKU Code</th>
<th className="text-start">SKU Description</th>
<th className="text-start">Category Name</th>
<th className="text-start">Brand Name</th>
<th className="text-start">Opn. Stocks</th>
<th className="text-start">Liqudation</th>
<th className="text-start">Order Quantity</th>
<th className="text-start">Closing stocks</th>
</tr>
</thead>
<tbody>
{loading ? (
<tr>
<td className="text-center" colSpan="6">
Loading...
</td>
</tr>
) : productsData?.length > 0 ? (
productsData?.map((product, i) => {
return (
<tr key={i}>
<td className="text-start">{product.SKU}</td>
<td className="text-start">{product.name}</td>
<td className="text-start">
{product.category !== ""
? product.category
: "Category Not selected "}
</td>
<td className="text-start">
{product.brand !== ""
? product.brand
: "Brand Not selected "}
</td>
<td className="text-start">
{product.monthstartstock}
</td>
<td className="text-start">
{product.liquidation}
</td>
<td className="text-start">
{product.monthlyorderquantity}
</td>
<td className="text-start">{product.stock}</td>
</tr>
);
})
) : (
!loading &&
productsData?.length === 0 && (
<tr className="text-center">
<td colSpan="8">
<h5>No Product Available...</h5>
</td>
</tr>
)
)}
</tbody>
</table>
</div>
<div className="row mt-20">
<div className="col-sm-12 col-md-6 mb-20">
<div
className="dataTables_info"
id="datatable_info"
role="status"
aria-live="polite"
>
Showing {currentPage * itemPerPage - itemPerPage + 1} to{" "}
{Math.min(currentPage * itemPerPage, totalData)} of{" "}
{totalData} entries
</div>
</div>
<div className="col-sm-12 col-md-6">
<div className="d-flex">
<ul className="pagination ms-auto">
<li
className={
currentPage === 1
? "paginate_button page-item previous disabled"
: "paginate_button page-item previous"
}
>
<span
className="page-link"
style={{ cursor: "pointer" }}
onClick={() => setCurrentPage((prev) => prev - 1)}
disabled={loading}
>
Previous
</span>
</li>
{!(currentPage - 1 < 1) && (
<li className="paginate_button page-item">
<span
className="page-link"
style={{ cursor: "pointer" }}
onClick={(e) =>
setCurrentPage((prev) => prev - 1)
}
disabled={loading}
>
{currentPage - 1}
</span>
</li>
)}
<li className="paginate_button page-item active">
<span
className="page-link"
style={{ cursor: "pointer" }}
>
{currentPage}
</span>
</li>
{!(
(currentPage + 1) * itemPerPage - itemPerPage >
totalData - 1
) && (
<li className="paginate_button page-item ">
<span
className="page-link"
style={{ cursor: "pointer" }}
onClick={() => {
setCurrentPage((prev) => prev + 1);
}}
disabled={loading}
>
{currentPage + 1}
</span>
</li>
)}
<li
className={
!(
(currentPage + 1) * itemPerPage - itemPerPage >
totalData - 1
)
? "paginate_button page-item next"
: "paginate_button page-item next disabled"
}
>
<span
className="page-link"
style={{ cursor: "pointer" }}
onClick={() => setCurrentPage((prev) => prev + 1)}
disabled={loading}
>
Next
</span>
</li>
</ul>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
);
};
export default DistributorLiqudations;

View File

@ -172,7 +172,7 @@ const principalDistributor = () => {
if (response.data.success) {
toast.success(
"Password reset successfully! Email sent to Territory Manager."
"Password reset successfully! Email sent to Principal Distributor."
);
}
} catch (error) {
@ -526,6 +526,18 @@ const principalDistributor = () => {
</button>
</Link>
</div>
<div className="d-flex flex-column flex-md-row">
<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"
@ -533,6 +545,18 @@ const principalDistributor = () => {
>
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"
>
Edit
</button>
</Link> */}
</td>
</tr>
))

View File

@ -0,0 +1,712 @@
import React, { useState, useEffect, useCallback } from "react";
import {
TextField,
Button,
Card,
Grid,
Typography,
FormHelperText,
Autocomplete,
CircularProgress,
FormControl,
InputLabel,
} from "@mui/material";
import { useNavigate, useParams } from "react-router-dom";
import { toast } from "react-hot-toast";
import axios from "axios";
import { isAutheticated } from "src/auth";
import { City, State } from "country-state-city";
const UpdatePrincipalDistributor = () => {
const navigate = useNavigate();
const token = isAutheticated();
const { id } = useParams();
const [user, setUser] = useState({
PD_ID: "",
SBU: "",
name: "",
email: "",
phone: "",
});
const [data, setData] = useState({
street: "",
city: "",
state: "",
postalCode: "",
country: "India",
tradeName: "",
gstNumber: "",
panNumber: "",
});
const [loading, setLoading] = useState(false);
const [stateOptions, setStateOptions] = useState([]);
const [cityOptions, setCityOptions] = useState([]);
const [selectedState, setSelectedState] = useState(null);
const [selectedCity, setSelectedCity] = useState(null);
const [currentAddressid, setCurrentAddressid] = useState(null);
// Fetch User Details
const getUserDetails = useCallback(async () => {
try {
const response = await axios.get(`/api/v1/admin/user/${id}`, {
headers: {
Authorization: `Bearer ${token}`,
},
});
// console.log(response.data);
// setUser(response.data.user);
setUser((prev) => ({
...prev,
PD_ID: response.data.user.uniqueId,
SBU: response.data.user.SBU,
name: response.data.user.name,
email: response.data.user.email,
phone: response.data.user.phone,
}));
} catch (error) {
swal({
title: "Warning",
text: error.message,
icon: "error",
button: "Close",
dangerMode: true,
});
}
}, [id, token]);
// Fetch Shipping address of the individual user
const getUserAddress = useCallback(async () => {
try {
const response = await axios.get(
`/api/shipping/address/user/address/${id}`,
{
headers: {
Authorization: `Bearer ${token}`,
},
}
);
// console.log(response.data);
const defaultAddress =
response.data?.UserShippingAddress.find(
(address) => address.isDefault
) ||
response.data?.UserShippingAddress[0] ||
{};
// console.log(defaultAddress);
setCurrentAddressid(defaultAddress._id);
setData((prev) => ({
...prev,
street: defaultAddress.street || "",
city: defaultAddress.city || "",
state: defaultAddress.state || "",
postalCode: defaultAddress.postalCode || "",
country: defaultAddress.country || "India",
tradeName: defaultAddress.tradeName || "",
gstNumber: defaultAddress.gstNumber || "",
panNumber: defaultAddress.panNumber || "",
}));
// Fetch city options based on the state from the backend
if (defaultAddress.state) {
const state =
stateOptions.find(
(option) => option.label === defaultAddress.state
) || null;
// Set selected state from backend address
setSelectedState(state);
// Fetch cities if state is found
if (state) {
const cities = City.getCitiesOfState("IN", state.value).map(
(city) => ({
label: city.name,
value: city.name,
})
);
setCityOptions(cities);
// Set selected city if it exists in the fetched city options
const city =
cities.find((option) => option.label === defaultAddress.city) ||
null;
setSelectedCity(city); // Set the selected city
}
} else {
setSelectedState(null);
setSelectedCity(null);
setCityOptions([]); // Clear city options if no address is provided
}
} catch (error) {
swal({
title: "Warning",
text: error.message,
icon: "error",
button: "Close",
dangerMode: true,
});
}
}, [id, token, stateOptions]);
useEffect(() => {
getUserAddress();
getUserDetails();
}, [id, getUserAddress, getUserDetails]);
// Fetch states when the component mounts
useEffect(() => {
const fetchStates = () => {
const states = State.getStatesOfCountry("IN").map((state) => ({
label: state.name,
value: state.isoCode,
}));
setStateOptions(states);
};
fetchStates();
}, []);
useEffect(() => {
if (stateOptions.length > 0) {
getUserAddress();
}
}, [stateOptions, getUserAddress]);
// Fetch cities when a state is selected
useEffect(() => {
const fetchCities = () => {
if (selectedState) {
const cities = City.getCitiesOfState("IN", selectedState.value).map(
(city) => ({
label: city.name,
value: city.name,
})
);
setCityOptions(cities);
} else {
setCityOptions([]); // Clear cities if no state is selected
}
};
fetchCities();
}, [selectedState]);
const handleInputChange = (e) => {
setUser({ ...user, [e.target.name]: e.target.value });
};
const handleDataChange = (e) => {
setData({ ...data, [e.target.name]: e.target.value });
};
const handleStateChange = (event, newValue) => {
setSelectedState(newValue);
setData((prev) => ({
...prev,
state: newValue ? newValue.label : "",
city: "",
}));
setSelectedCity(null); // Clear city when state changes
setCityOptions([]); // Reset city options
};
const handleCityChange = (event, newValue) => {
setSelectedCity(newValue);
setData((prev) => ({
...prev,
city: newValue ? newValue.label : "",
}));
};
const handleFormSubmit = async (e) => {
e.preventDefault();
try {
// Validate input fields
if (
!user.PD_ID ||
!user.name ||
!user.email ||
!user.phone ||
!data.panNumber ||
!data.tradeName ||
!data.gstNumber ||
!data.country ||
!data.state ||
!data.city ||
!data.street ||
!data.postalCode
) {
throw new Error("Fill all fields!");
}
setLoading(true);
// Attempt to register user
const userResponse = await axios.put(`/api/v1/user/update/${id}`, {
...user,
role: "principal-Distributor",
});
if (userResponse.status === 201 || userResponse.status === 200) {
// const userId = userResponse.data.userId;
// console.log(userId);
// Add address details for the user
const addressResponse = await axios.patch(
`/api/shipping/address/update/${currentAddressid}`,
{
...data,
Name: user.name,
phoneNumber: user.phone,
isDefault: true,
state: data.state,
city: data.city,
// state: selectedState.label, // Send selected state label
// city: selectedCity.label, // Send selected city label
},
{
headers: {
Authorization: `Bearer ${token}`,
},
}
);
setLoading(false);
if (addressResponse.status === 201) {
toast.success("Principal Distributor and Address updated Successfully");
navigate("/principal-distributor");
}
}
} catch (error) {
setLoading(false);
if (error.response && error.response?.data) {
toast.error(error.response?.data.message || "Something went wrong!");
} else {
toast.error("Something went wrong!");
}
}
};
const handleCancel = () => {
navigate("/principal-distributor");
};
return (
<div>
<Card
sx={{ padding: "1rem", marginBottom: "1rem", position: "relative" }}
>
<Button
variant="outlined"
color="secondary"
style={{
fontWeight: "bold",
textTransform: "capitalize",
position: "absolute",
top: "10px",
right: "10px",
}}
onClick={handleCancel}
>
Cancel
</Button>
<Typography variant="h5" sx={{ mb: 3 }}>
Update Principal Distributor
</Typography>
<form onSubmit={handleFormSubmit}>
<Typography variant="h5" sx={{ mb: 2 }}>
Basic Information
</Typography>
<Grid container spacing={2} sx={{ mb: 2 }}>
{/* Principal Distributor ID */}
<Grid item xs={12} className="d-flex align-items-center">
<Grid item xs={2}>
<Typography
variant="body1"
htmlFor="PD_ID"
className="form-label"
>
Principal Distributor ID*
</Typography>
</Grid>
<Grid item xs={10}>
<TextField
id="PD_ID"
required
type="text"
fullWidth
name="PD_ID"
value={user.PD_ID}
variant="outlined"
onChange={handleInputChange}
/>
</Grid>
</Grid>
{/* Principal Distributor SBU */}
<Grid item xs={12} className="d-flex align-items-center">
<Grid item xs={2}>
<Typography
variant="body1"
htmlFor="SBU"
className="form-label"
>
SBU*
</Typography>
</Grid>
<Grid item xs={10}>
<TextField
id="SBU"
required
type="text"
fullWidth
name="SBU"
value={user.SBU}
variant="outlined"
onChange={handleInputChange}
/>
</Grid>
</Grid>
{/* Name */}
<Grid item xs={12} className="d-flex align-items-center">
<Grid item xs={2}>
<Typography
variant="body1"
htmlFor="name"
className="form-label"
>
Name*
</Typography>
</Grid>
<Grid item xs={10}>
<TextField
id="name"
required
type="text"
fullWidth
name="name"
value={user.name}
variant="outlined"
onChange={handleInputChange}
/>
</Grid>
</Grid>
{/* Email */}
<Grid item xs={12} className="d-flex align-items-center">
<Grid item xs={2}>
<Typography
variant="body1"
htmlFor="email"
className="form-label"
>
Email*
</Typography>
</Grid>
<Grid item xs={10}>
<TextField
id="email"
required
type="email"
fullWidth
name="email"
value={user.email}
variant="outlined"
onChange={handleInputChange}
/>
</Grid>
</Grid>
{/* Phone Number */}
<Grid item xs={12} className="d-flex align-items-center">
<Grid item xs={2}>
<Typography
variant="body1"
htmlFor="phone"
className="form-label"
>
Phone Number*
</Typography>
</Grid>
<Grid item xs={10}>
<TextField
id="phone"
required
type="text"
fullWidth
name="phone"
value={user.phone}
variant="outlined"
onChange={handleInputChange}
/>
</Grid>
</Grid>
</Grid>
<Typography variant="h5" sx={{ mb: 2 }}>
Business Details
</Typography>
<Grid container spacing={2} sx={{ mb: 2 }}>
{/* PAN Number */}
<Grid item xs={12} className="d-flex align-items-center">
<Grid item xs={2}>
<Typography
variant="body1"
htmlFor="panNumber"
className="form-label"
>
PAN Number*
</Typography>
</Grid>
<Grid item xs={10}>
<TextField
id="panNumber"
required
type="text"
fullWidth
name="panNumber"
value={data.panNumber}
variant="outlined"
onChange={handleDataChange}
/>
</Grid>
</Grid>
{/* Trade Name */}
<Grid item xs={12} className="d-flex align-items-center">
<Grid item xs={2}>
<Typography
variant="body1"
htmlFor="tradeName"
className="form-label"
>
Trade Name*
</Typography>
</Grid>
<Grid item xs={10}>
<TextField
id="tradeName"
required
type="text"
fullWidth
name="tradeName"
value={data.tradeName}
variant="outlined"
onChange={handleDataChange}
/>
</Grid>
</Grid>
{/* GST Number */}
<Grid item xs={12} className="d-flex align-items-center">
<Grid item xs={2}>
<Typography
variant="body1"
htmlFor="gstNumber"
className="form-label"
>
GST Number*
</Typography>
</Grid>
<Grid item xs={10}>
<TextField
id="gstNumber"
required
type="text"
fullWidth
name="gstNumber"
value={data.gstNumber}
variant="outlined"
onChange={handleDataChange}
/>
</Grid>
</Grid>
</Grid>
<Typography variant="h5" sx={{ mb: 2 }}>
Address
</Typography>
<Grid container spacing={2} sx={{ mb: 2 }}>
{/* Country */}
<Grid item xs={12} className="d-flex align-items-center">
<Grid item xs={2}>
<Typography
variant="body1"
htmlFor="country"
className="form-label"
>
Country*
</Typography>
</Grid>
<Grid item xs={10}>
<TextField
id="country"
required
type="text"
fullWidth
name="country"
value={data.country}
variant="outlined"
disabled
/>
</Grid>
</Grid>
{/* State */}
<Grid item xs={12} className="d-flex align-items-center">
<Grid item xs={2}>
<Typography
variant="body1"
htmlFor="state"
className="form-label"
>
State*
</Typography>
</Grid>
<Grid item xs={5}>
<Autocomplete
id="state"
options={stateOptions}
// getOptionLabel={(option) => option.label}
value={selectedState}
onChange={handleStateChange}
renderInput={(params) => (
<TextField
{...params}
fullWidth
variant="outlined"
label="Select State"
// error={!selectedState}
// helperText={!selectedState ? "Select a state" : null}
/>
)}
/>
</Grid>
<Grid item xs={5}>
<TextField
id="state"
required
type="text"
fullWidth
name="state"
value={data.state}
variant="outlined"
onChange={handleDataChange}
/>
</Grid>
</Grid>
{/* City */}
<Grid item xs={12} className="d-flex align-items-center">
<Grid item xs={2}>
<Typography
variant="body1"
htmlFor="city"
className="form-label"
>
City*
</Typography>
</Grid>
<Grid item xs={5}>
<Autocomplete
id="city"
options={cityOptions}
// getOptionLabel={(option) => option.label}
value={selectedCity}
onChange={handleCityChange}
isOptionEqualToValue={(option, value) =>
option.value === value.value
}
renderInput={(params) => (
<TextField
{...params}
fullWidth
variant="outlined"
label="Select City"
// error={!selectedCity}
// helperText={!selectedCity ? "Select a city" : null}
/>
)}
/>
</Grid>
<Grid item xs={5}>
<TextField
id="city"
required
type="text"
fullWidth
name="city"
value={data.city}
variant="outlined"
onChange={handleDataChange}
/>
</Grid>
</Grid>
{/* Street */}
<Grid item xs={12} className="d-flex align-items-center">
<Grid item xs={2}>
<Typography
variant="body1"
htmlFor="street"
className="form-label"
>
Street*
</Typography>
</Grid>
<Grid item xs={10}>
<TextField
id="street"
required
type="text"
fullWidth
name="street"
value={data.street}
variant="outlined"
onChange={handleDataChange}
/>
</Grid>
</Grid>
{/* Postal Code */}
<Grid item xs={12} className="d-flex align-items-center">
<Grid item xs={2}>
<Typography
variant="body1"
htmlFor="postalCode"
className="form-label"
>
Postal Code*
</Typography>
</Grid>
<Grid item xs={10}>
<TextField
id="postalCode"
required
type="text"
fullWidth
name="postalCode"
value={data.postalCode}
variant="outlined"
onChange={handleDataChange}
/>
</Grid>
</Grid>
</Grid>
<Button
type="submit"
disabled={loading}
variant="contained"
color="primary"
>
{loading ? (
<CircularProgress size={24} />
) : (
"Create Principal Distributor"
)}
</Button>
</form>
</Card>
</div>
);
};
export default UpdatePrincipalDistributor;

View File

@ -133,7 +133,7 @@ const RetailDistributor = () => {
if (response.data.success) {
toast.success(
"Password reset successfully! Email sent to Territory Manager."
"Password reset successfully! Email sent to Retailer."
);
}
} catch (error) {

View File

@ -125,7 +125,7 @@ const SalesCoOrdinator = () => {
if (response.data.success) {
toast.success(
"Password reset successfully! Email sent to Territory Manager."
"Password reset successfully! Email sent to Sales Coordinator."
);
}
} catch (error) {