PD updated with new field SBU

This commit is contained in:
Sibunnayak 2024-08-23 11:29:11 +05:30
parent 185bda1261
commit ab8a468c0b
6 changed files with 461 additions and 230 deletions

View File

@ -52,7 +52,7 @@ const AddMultiplePd = () => {
}, },
} }
); );
// console.log(data); console.log(data);
if (data.errors && data.errors.length > 0) { if (data.errors && data.errors.length > 0) {
setErrors(data.errors); setErrors(data.errors);
} }
@ -211,8 +211,8 @@ const AddMultiplePd = () => {
<td>{distributor.name || "N/A"}</td> <td>{distributor.name || "N/A"}</td>
<td>{distributor.email || "N/A"}</td> <td>{distributor.email || "N/A"}</td>
<td>{distributor.phone || "N/A"}</td> <td>{distributor.phone || "N/A"}</td>
<td>{distributor.panNumber || "N/A"}</td> <td>{distributor?.address?.panNumber || "N/A"}</td>
<td>{distributor.gstNumber || "N/A"}</td> <td>{distributor?.address?.gstNumber || "N/A"}</td>
</tr> </tr>
))} ))}
</tbody> </tbody>

View File

@ -8,6 +8,8 @@ import {
FormHelperText, FormHelperText,
Autocomplete, Autocomplete,
CircularProgress, CircularProgress,
FormControl,
InputLabel,
} from "@mui/material"; } from "@mui/material";
import { useNavigate } from "react-router-dom"; import { useNavigate } from "react-router-dom";
import { toast } from "react-hot-toast"; import { toast } from "react-hot-toast";
@ -21,6 +23,7 @@ const AddPrincipalDistributor = () => {
const [user, setUser] = useState({ const [user, setUser] = useState({
PD_ID: "", PD_ID: "",
SBU: "",
name: "", name: "",
email: "", email: "",
phone: "", phone: "",
@ -165,189 +168,357 @@ const AddPrincipalDistributor = () => {
Add Principal Distributor Add Principal Distributor
</Typography> </Typography>
<form onSubmit={handleFormSubmit}> <form onSubmit={handleFormSubmit}>
<Typography variant="h6" sx={{ mb: 2 }}> <Typography variant="h5" sx={{ mb: 2 }}>
Basic Information Basic Information
</Typography> </Typography>
<Grid container spacing={2} sx={{ mb: 2 }}> <Grid container spacing={2} sx={{ mb: 2 }}>
<Grid item xs={6}> {/* Principal Distributor ID */}
<TextField <Grid item xs={12} className="d-flex align-items-center">
id="PD_ID" <Grid item xs={2}>
required <Typography
type="text" variant="body1"
fullWidth htmlFor="PD_ID"
name="PD_ID" className="form-label"
value={user.PD_ID} >
label="Principal Distributor ID" Principal Distributor ID*
variant="outlined" </Typography>
onChange={handleInputChange} </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> </Grid>
<Grid item xs={6}>
<TextField {/* Principal Distributor SBU */}
id="name" <Grid item xs={12} className="d-flex align-items-center">
required <Grid item xs={2}>
type="text" <Typography
fullWidth variant="body1"
name="name" htmlFor="SBU"
value={user.name} className="form-label"
label="Name" >
variant="outlined" Principal Distributor SBU*
onChange={handleInputChange} </Typography>
/> </Grid>
<Grid item xs={10}>
<TextField
id="SBU"
required
type="text"
fullWidth
name="SBU"
value={user.SBU}
variant="outlined"
onChange={handleInputChange}
/>
</Grid>
</Grid> </Grid>
<Grid item xs={6}>
<TextField {/* Name */}
id="email" <Grid item xs={12} className="d-flex align-items-center">
required <Grid item xs={2}>
type="email" <Typography
fullWidth variant="body1"
name="email" htmlFor="name"
value={user.email} className="form-label"
label="Email" >
variant="outlined" Name*
onChange={handleInputChange} </Typography>
/> </Grid>
<Grid item xs={10}>
<TextField
id="name"
required
type="text"
fullWidth
name="name"
value={user.name}
variant="outlined"
onChange={handleInputChange}
/>
</Grid>
</Grid> </Grid>
<Grid item xs={6}>
<TextField {/* Email */}
id="phone" <Grid item xs={12} className="d-flex align-items-center">
required <Grid item xs={2}>
type="text" <Typography
fullWidth variant="body1"
name="phone" htmlFor="email"
value={user.phone} className="form-label"
label="Phone Number" >
variant="outlined" Email*
onChange={handleInputChange} </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>
</Grid> </Grid>
<Typography variant="h6" sx={{ mb: 2 }}> <Typography variant="h5" sx={{ mb: 2 }}>
Business Details Business Details
</Typography> </Typography>
<Grid container spacing={2} sx={{ mb: 2 }}> <Grid container spacing={2} sx={{ mb: 2 }}>
<Grid item xs={12} sm={4}> {/* PAN Number */}
<TextField <Grid item xs={12} className="d-flex align-items-center">
id="panNumber" <Grid item xs={2}>
required <Typography
type="text" variant="body1"
fullWidth htmlFor="panNumber"
name="panNumber" className="form-label"
value={data.panNumber} >
label="PAN Number" PAN Number*
variant="outlined" </Typography>
onChange={handleDataChange} </Grid>
/> <Grid item xs={10}>
<TextField
id="panNumber"
required
type="text"
fullWidth
name="panNumber"
value={data.panNumber}
variant="outlined"
onChange={handleDataChange}
/>
</Grid>
</Grid> </Grid>
<Grid item xs={12} sm={4}>
<TextField {/* Trade Name */}
id="tradeName" <Grid item xs={12} className="d-flex align-items-center">
required <Grid item xs={2}>
type="text" <Typography
fullWidth variant="body1"
name="tradeName" htmlFor="tradeName"
value={data.tradeName} className="form-label"
label="Trade Name" >
variant="outlined" Trade Name*
onChange={handleDataChange} </Typography>
/> </Grid>
<Grid item xs={10}>
<TextField
id="tradeName"
required
type="text"
fullWidth
name="tradeName"
value={data.tradeName}
variant="outlined"
onChange={handleDataChange}
/>
</Grid>
</Grid> </Grid>
<Grid item xs={12} sm={4}>
<TextField {/* GST Number */}
id="gstNumber" <Grid item xs={12} className="d-flex align-items-center">
required <Grid item xs={2}>
type="text" <Typography
fullWidth variant="body1"
name="gstNumber" htmlFor="gstNumber"
value={data.gstNumber} className="form-label"
label="GST Number" >
variant="outlined" GST Number*
onChange={handleDataChange} </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>
</Grid> </Grid>
<Typography variant="h6" sx={{ mb: 2 }}> <Typography variant="h5" sx={{ mb: 2 }}>
Address Address
</Typography> </Typography>
<Grid container spacing={2} sx={{ mb: 2 }}> <Grid container spacing={2} sx={{ mb: 2 }}>
<Grid item xs={12} sm={4}> {/* Country */}
<TextField <Grid item xs={12} className="d-flex align-items-center">
id="country" <Grid item xs={2}>
required <Typography
type="text" variant="body1"
fullWidth htmlFor="country"
name="country" className="form-label"
value={data.country} >
label="Country" Country*
variant="outlined" </Typography>
disabled </Grid>
/> <Grid item xs={10}>
<TextField
id="country"
required
type="text"
fullWidth
name="country"
value={data.country}
variant="outlined"
disabled
/>
</Grid>
</Grid> </Grid>
<Grid item xs={12} sm={4}>
<Autocomplete {/* State */}
id="state" <Grid item xs={12} className="d-flex align-items-center">
options={stateOptions} <Grid item xs={2}>
getOptionLabel={(option) => option.label} <Typography
value={selectedState} variant="body1"
onChange={handleStateChange} htmlFor="state"
renderInput={(params) => ( className="form-label"
<TextField >
{...params} State*
fullWidth </Typography>
label="State" </Grid>
variant="outlined" <Grid item xs={10}>
error={!selectedState} <Autocomplete
helperText={!selectedState ? "Select a state" : null} 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> </Grid>
<Grid item xs={12} sm={4}>
<Autocomplete {/* City */}
id="city" <Grid item xs={12} className="d-flex align-items-center">
options={cityOptions} <Grid item xs={2}>
getOptionLabel={(option) => option.label} <Typography
value={selectedCity} variant="body1"
onChange={handleCityChange} htmlFor="city"
renderInput={(params) => ( className="form-label"
<TextField >
{...params} City*
fullWidth </Typography>
label="City" </Grid>
variant="outlined" <Grid item xs={10}>
error={!selectedCity} <Autocomplete
helperText={!selectedCity ? "Select a city" : null} id="city"
/> options={cityOptions}
)} getOptionLabel={(option) => option.label}
/> value={selectedCity}
onChange={handleCityChange}
renderInput={(params) => (
<TextField
{...params}
fullWidth
variant="outlined"
label="Select City"
error={!selectedCity}
helperText={!selectedCity ? "Select a city" : null}
/>
)}
/>
</Grid>
</Grid> </Grid>
<Grid item xs={6}>
<TextField {/* Street */}
id="street" <Grid item xs={12} className="d-flex align-items-center">
required <Grid item xs={2}>
type="text" <Typography
fullWidth variant="body1"
name="street" htmlFor="street"
value={data.street} className="form-label"
label="Street" >
variant="outlined" Street*
onChange={handleDataChange} </Typography>
/> </Grid>
<Grid item xs={10}>
<TextField
id="street"
required
type="text"
fullWidth
name="street"
value={data.street}
variant="outlined"
onChange={handleDataChange}
/>
</Grid>
</Grid> </Grid>
<Grid item xs={6}>
<TextField {/* Postal Code */}
id="postalCode" <Grid item xs={12} className="d-flex align-items-center">
required <Grid item xs={2}>
type="text" <Typography
fullWidth variant="body1"
name="postalCode" htmlFor="postalCode"
value={data.postalCode} className="form-label"
label="Postal Code" >
variant="outlined" Postal Code*
onChange={handleDataChange} </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>
</Grid> </Grid>

View File

@ -136,7 +136,7 @@ const principalDistributor = () => {
<Button <Button
variant="contained" variant="contained"
color="primary" color="primary"
className="font-bold mb-2 capitalize mr-2" className="font-bold mb-2 capitalize mr-2"
onClick={() => { onClick={() => {
navigate("/add-principal-distributor"); navigate("/add-principal-distributor");
}} }}
@ -148,7 +148,9 @@ const principalDistributor = () => {
color="primary" color="primary"
className="font-bold mb-2 capitalize" className="font-bold mb-2 capitalize"
onClick={() => onClick={() =>
navigate("/add-principal-distributor/multiple", { replace: true }) navigate("/add-principal-distributor/multiple", {
replace: true,
})
} }
> >
Upload Spreadsheet Upload Spreadsheet
@ -198,7 +200,8 @@ const principalDistributor = () => {
style={{ background: "rgb(140, 213, 213)" }} style={{ background: "rgb(140, 213, 213)" }}
> >
<tr> <tr>
<th>Unique Id </th> <th>Unique Id </th>
<th>SBU</th>
<th>Name</th> <th>Name</th>
<th>Email</th> <th>Email</th>
{/* <th>Profile Image</th> */} {/* <th>Profile Image</th> */}
@ -228,6 +231,7 @@ const principalDistributor = () => {
return ( return (
<tr key={i}> <tr key={i}>
<td>{user.uniqueId}</td> <td>{user.uniqueId}</td>
<td>{user.SBU?user.SBU:"N/A"}</td>
<td className="text-start">{user.name}</td> <td className="text-start">{user.name}</td>
<td>{user.email}</td> <td>{user.email}</td>
<td className="text-start"> <td className="text-start">

View File

@ -112,7 +112,7 @@ const SinglePrincipalDistributorAllDetails = () => {
" "
> >
<div style={{ fontSize: "22px" }} className="fw-bold"> <div style={{ fontSize: "22px" }} className="fw-bold">
Principal Distributor All Details Principal Distributor All Details
</div> </div>
<div style={{ display: "flex", gap: "1rem" }}> <div style={{ display: "flex", gap: "1rem" }}>
<h4 className="mb-0"></h4> <h4 className="mb-0"></h4>
@ -137,65 +137,122 @@ const SinglePrincipalDistributorAllDetails = () => {
</div> </div>
</div> </div>
<div className="card" style={{ padding: "1rem" }}> <div className="card" style={{ padding: "1rem" }}>
<h5 style={{ fontWeight: "bold" }}>&bull; Principal Distributor Profile </h5> <h5 style={{ fontWeight: "bold" }}>
&bull; Principal Distributor Profile{" "}
</h5>
<div style={{ marginLeft: "1rem", marginTop: "1rem" }}> <div style={{ marginLeft: "1rem", marginTop: "1rem" }}>
<Typography style={{ fontWeight: "bold", fontSize: "1.2rem" }}> <Typography style={{ fontWeight: "bold", fontSize: "1.2rem" }}>
Principal Distributor ID: Principal Distributor ID:
<Typography component="span" style={{ fontWeight: "normal", fontSize: "1.2rem",marginLeft: "0.5rem" }}> <Typography
{user?.uniqueId} component="span"
</Typography> style={{
</Typography> fontWeight: "normal",
<Typography style={{ fontWeight: "bold", fontSize: "1.2rem" }}> fontSize: "1.2rem",
Name: marginLeft: "0.5rem",
<Typography component="span" style={{ fontWeight: "normal", fontSize: "1.2rem",marginLeft: "0.5rem"}}> }}
{user?.name} >
</Typography> {user?.uniqueId}
</Typography> </Typography>
<Typography style={{ fontWeight: "bold", fontSize: "1.2rem" }}> </Typography>
Email: <Typography style={{ fontWeight: "bold", fontSize: "1.2rem" }}>
<Typography component="span" style={{ fontWeight: "normal", fontSize: "1.2rem" ,marginLeft: "0.5rem"}}> Principal Distributor SBU:
{user?.email} <Typography
</Typography> component="span"
</Typography> style={{
<Typography style={{ fontWeight: "bold", fontSize: "1.2rem" }}> fontWeight: "normal",
Mobile Number: fontSize: "1.2rem",
<Typography component="span" style={{ fontWeight: "normal", fontSize: "1.2rem" ,marginLeft: "0.5rem"}}> marginLeft: "0.5rem",
{user?.phone} }}
</Typography> >
</Typography> {user?.SBU}
<Typography style={{ fontWeight: "bold", fontSize: "1.2rem" }}> </Typography>
Date Registered: </Typography>
<Typography component="span" style={{ fontWeight: "normal", fontSize: "1.2rem" ,marginLeft: "0.5rem"}}> <Typography style={{ fontWeight: "bold", fontSize: "1.2rem" }}>
{new Date(user?.createdAt).toLocaleString("en-IN", { Name:
weekday: "short", <Typography
month: "short", component="span"
day: "numeric", style={{
year: "numeric", fontWeight: "normal",
hour: "numeric", fontSize: "1.2rem",
minute: "numeric", marginLeft: "0.5rem",
hour12: true, }}
})} >
</Typography> {user?.name}
</Typography> </Typography>
<Typography style={{ fontWeight: "bold", fontSize: "1.2rem" }}> </Typography>
Last Purchase: <Typography style={{ fontWeight: "bold", fontSize: "1.2rem" }}>
<Typography component="span" style={{ fontWeight: "normal", fontSize: "1.2rem", marginLeft: "1.5rem" }}> Email:
{userOrder?.length > 0 <Typography
? new Date(userOrder[0]?.createdAt).toLocaleString("en-IN", { component="span"
weekday: "short", style={{
month: "short", fontWeight: "normal",
day: "numeric", fontSize: "1.2rem",
year: "numeric", marginLeft: "0.5rem",
hour: "numeric", }}
minute: "numeric", >
hour12: true, {user?.email}
}) </Typography>
: userOrder </Typography>
? "No Purchase" <Typography style={{ fontWeight: "bold", fontSize: "1.2rem" }}>
: "Loading"} Mobile Number:
</Typography> <Typography
</Typography> component="span"
</div> style={{
fontWeight: "normal",
fontSize: "1.2rem",
marginLeft: "0.5rem",
}}
>
{user?.phone}
</Typography>
</Typography>
<Typography style={{ fontWeight: "bold", fontSize: "1.2rem" }}>
Date Registered:
<Typography
component="span"
style={{
fontWeight: "normal",
fontSize: "1.2rem",
marginLeft: "0.5rem",
}}
>
{new Date(user?.createdAt).toLocaleString("en-IN", {
weekday: "short",
month: "short",
day: "numeric",
year: "numeric",
hour: "numeric",
minute: "numeric",
hour12: true,
})}
</Typography>
</Typography>
<Typography style={{ fontWeight: "bold", fontSize: "1.2rem" }}>
Last Purchase:
<Typography
component="span"
style={{
fontWeight: "normal",
fontSize: "1.2rem",
marginLeft: "1.5rem",
}}
>
{userOrder?.length > 0
? new Date(userOrder[0]?.createdAt).toLocaleString("en-IN", {
weekday: "short",
month: "short",
day: "numeric",
year: "numeric",
hour: "numeric",
minute: "numeric",
hour12: true,
})
: userOrder
? "No Purchase"
: "Loading"}
</Typography>
</Typography>
</div>
<div style={{ marginTop: "2rem" }}> <div style={{ marginTop: "2rem" }}>
<h5 style={{ fontWeight: "bold", marginBottom: "1rem" }}> <h5 style={{ fontWeight: "bold", marginBottom: "1rem" }}>
@ -234,14 +291,13 @@ const SinglePrincipalDistributorAllDetails = () => {
<td className="text-start">{i + 1}</td> <td className="text-start">{i + 1}</td>
<td style={{ maxWidth: "400px" }}> <td style={{ maxWidth: "400px" }}>
<strong> <strong>
{address?.first_Name} {address?.last_name} {address?.first_Name} {address?.last_name}
{address.tradeName {address.tradeName
? `${address.tradeName},` ? `${address.tradeName},`
: "No tradeName "} : "No tradeName "}
{address.gstNumber ? `${address.gstNumber},` : ""} {address.gstNumber ? `${address.gstNumber},` : ""}
{address?.street}, {address?.street},{address?.city},{address?.state},
{address?.city},{address?.state},{address?.country}, {address?.country},{address?.postalCode}
{address?.postalCode}
</strong> </strong>
</td> </td>
</tr> </tr>

View File

@ -25,7 +25,7 @@ const AddProduct = () => {
price: "", price: "",
GST: "", GST: "",
HSN_Code: "", HSN_Code: "",
product_Status: "", product_Status: "Active",
}); });
const getCategories = () => { const getCategories = () => {

View File

@ -185,7 +185,7 @@ const ProductDetails = (props) => {
</div> </div>
<div className="mb-3 row d-flex align-items-center"> <div className="mb-3 row d-flex align-items-center">
<label htmlFor="product_Status" className="form-label col-sm-3"> <label htmlFor="product_Status" className="form-label col-sm-3">
Product Status * Product Status
</label> </label>
<div className="col-sm-9"> <div className="col-sm-9">
<select <select