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,11 +168,22 @@ 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 */}
<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 <TextField
id="PD_ID" id="PD_ID"
required required
@ -177,12 +191,49 @@ const AddPrincipalDistributor = () => {
fullWidth fullWidth
name="PD_ID" name="PD_ID"
value={user.PD_ID} value={user.PD_ID}
label="Principal Distributor ID"
variant="outlined" variant="outlined"
onChange={handleInputChange} onChange={handleInputChange}
/> />
</Grid> </Grid>
<Grid item xs={6}> </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"
>
Principal Distributor 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 <TextField
id="name" id="name"
required required
@ -190,12 +241,24 @@ const AddPrincipalDistributor = () => {
fullWidth fullWidth
name="name" name="name"
value={user.name} value={user.name}
label="Name"
variant="outlined" variant="outlined"
onChange={handleInputChange} onChange={handleInputChange}
/> />
</Grid> </Grid>
<Grid item xs={6}> </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 <TextField
id="email" id="email"
required required
@ -203,12 +266,24 @@ const AddPrincipalDistributor = () => {
fullWidth fullWidth
name="email" name="email"
value={user.email} value={user.email}
label="Email"
variant="outlined" variant="outlined"
onChange={handleInputChange} onChange={handleInputChange}
/> />
</Grid> </Grid>
<Grid item xs={6}> </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 <TextField
id="phone" id="phone"
required required
@ -216,18 +291,29 @@ const AddPrincipalDistributor = () => {
fullWidth fullWidth
name="phone" name="phone"
value={user.phone} value={user.phone}
label="Phone Number"
variant="outlined" variant="outlined"
onChange={handleInputChange} 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 */}
<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 <TextField
id="panNumber" id="panNumber"
required required
@ -235,12 +321,24 @@ const AddPrincipalDistributor = () => {
fullWidth fullWidth
name="panNumber" name="panNumber"
value={data.panNumber} value={data.panNumber}
label="PAN Number"
variant="outlined" variant="outlined"
onChange={handleDataChange} onChange={handleDataChange}
/> />
</Grid> </Grid>
<Grid item xs={12} sm={4}> </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 <TextField
id="tradeName" id="tradeName"
required required
@ -248,12 +346,24 @@ const AddPrincipalDistributor = () => {
fullWidth fullWidth
name="tradeName" name="tradeName"
value={data.tradeName} value={data.tradeName}
label="Trade Name"
variant="outlined" variant="outlined"
onChange={handleDataChange} onChange={handleDataChange}
/> />
</Grid> </Grid>
<Grid item xs={12} sm={4}> </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 <TextField
id="gstNumber" id="gstNumber"
required required
@ -261,18 +371,29 @@ const AddPrincipalDistributor = () => {
fullWidth fullWidth
name="gstNumber" name="gstNumber"
value={data.gstNumber} value={data.gstNumber}
label="GST Number"
variant="outlined" variant="outlined"
onChange={handleDataChange} 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 */}
<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 <TextField
id="country" id="country"
required required
@ -280,12 +401,24 @@ const AddPrincipalDistributor = () => {
fullWidth fullWidth
name="country" name="country"
value={data.country} value={data.country}
label="Country"
variant="outlined" variant="outlined"
disabled disabled
/> />
</Grid> </Grid>
<Grid item xs={12} sm={4}> </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={10}>
<Autocomplete <Autocomplete
id="state" id="state"
options={stateOptions} options={stateOptions}
@ -296,15 +429,28 @@ const AddPrincipalDistributor = () => {
<TextField <TextField
{...params} {...params}
fullWidth fullWidth
label="State"
variant="outlined" variant="outlined"
label="Select State"
error={!selectedState} error={!selectedState}
helperText={!selectedState ? "Select a state" : null} helperText={!selectedState ? "Select a state" : null}
/> />
)} )}
/> />
</Grid> </Grid>
<Grid item xs={12} sm={4}> </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={10}>
<Autocomplete <Autocomplete
id="city" id="city"
options={cityOptions} options={cityOptions}
@ -315,15 +461,28 @@ const AddPrincipalDistributor = () => {
<TextField <TextField
{...params} {...params}
fullWidth fullWidth
label="City"
variant="outlined" variant="outlined"
label="Select City"
error={!selectedCity} error={!selectedCity}
helperText={!selectedCity ? "Select a city" : null} helperText={!selectedCity ? "Select a city" : null}
/> />
)} )}
/> />
</Grid> </Grid>
<Grid item xs={6}> </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 <TextField
id="street" id="street"
required required
@ -331,12 +490,24 @@ const AddPrincipalDistributor = () => {
fullWidth fullWidth
name="street" name="street"
value={data.street} value={data.street}
label="Street"
variant="outlined" variant="outlined"
onChange={handleDataChange} onChange={handleDataChange}
/> />
</Grid> </Grid>
<Grid item xs={6}> </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 <TextField
id="postalCode" id="postalCode"
required required
@ -344,12 +515,12 @@ const AddPrincipalDistributor = () => {
fullWidth fullWidth
name="postalCode" name="postalCode"
value={data.postalCode} value={data.postalCode}
label="Postal Code"
variant="outlined" variant="outlined"
onChange={handleDataChange} onChange={handleDataChange}
/> />
</Grid> </Grid>
</Grid> </Grid>
</Grid>
<Button <Button
type="submit" type="submit"

View File

@ -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
@ -199,6 +201,7 @@ const principalDistributor = () => {
> >
<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

@ -137,35 +137,85 @@ 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
component="span"
style={{
fontWeight: "normal",
fontSize: "1.2rem",
marginLeft: "0.5rem",
}}
>
{user?.uniqueId} {user?.uniqueId}
</Typography> </Typography>
</Typography> </Typography>
<Typography style={{ fontWeight: "bold", fontSize: "1.2rem" }}>
Principal Distributor SBU:
<Typography
component="span"
style={{
fontWeight: "normal",
fontSize: "1.2rem",
marginLeft: "0.5rem",
}}
>
{user?.SBU}
</Typography>
</Typography>
<Typography style={{ fontWeight: "bold", fontSize: "1.2rem" }}> <Typography style={{ fontWeight: "bold", fontSize: "1.2rem" }}>
Name: Name:
<Typography component="span" style={{ fontWeight: "normal", fontSize: "1.2rem",marginLeft: "0.5rem"}}> <Typography
component="span"
style={{
fontWeight: "normal",
fontSize: "1.2rem",
marginLeft: "0.5rem",
}}
>
{user?.name} {user?.name}
</Typography> </Typography>
</Typography> </Typography>
<Typography style={{ fontWeight: "bold", fontSize: "1.2rem" }}> <Typography style={{ fontWeight: "bold", fontSize: "1.2rem" }}>
Email: Email:
<Typography component="span" style={{ fontWeight: "normal", fontSize: "1.2rem" ,marginLeft: "0.5rem"}}> <Typography
component="span"
style={{
fontWeight: "normal",
fontSize: "1.2rem",
marginLeft: "0.5rem",
}}
>
{user?.email} {user?.email}
</Typography> </Typography>
</Typography> </Typography>
<Typography style={{ fontWeight: "bold", fontSize: "1.2rem" }}> <Typography style={{ fontWeight: "bold", fontSize: "1.2rem" }}>
Mobile Number: Mobile Number:
<Typography component="span" style={{ fontWeight: "normal", fontSize: "1.2rem" ,marginLeft: "0.5rem"}}> <Typography
component="span"
style={{
fontWeight: "normal",
fontSize: "1.2rem",
marginLeft: "0.5rem",
}}
>
{user?.phone} {user?.phone}
</Typography> </Typography>
</Typography> </Typography>
<Typography style={{ fontWeight: "bold", fontSize: "1.2rem" }}> <Typography style={{ fontWeight: "bold", fontSize: "1.2rem" }}>
Date Registered: Date Registered:
<Typography component="span" style={{ fontWeight: "normal", fontSize: "1.2rem" ,marginLeft: "0.5rem"}}> <Typography
component="span"
style={{
fontWeight: "normal",
fontSize: "1.2rem",
marginLeft: "0.5rem",
}}
>
{new Date(user?.createdAt).toLocaleString("en-IN", { {new Date(user?.createdAt).toLocaleString("en-IN", {
weekday: "short", weekday: "short",
month: "short", month: "short",
@ -179,7 +229,14 @@ const SinglePrincipalDistributorAllDetails = () => {
</Typography> </Typography>
<Typography style={{ fontWeight: "bold", fontSize: "1.2rem" }}> <Typography style={{ fontWeight: "bold", fontSize: "1.2rem" }}>
Last Purchase: Last Purchase:
<Typography component="span" style={{ fontWeight: "normal", fontSize: "1.2rem", marginLeft: "1.5rem" }}> <Typography
component="span"
style={{
fontWeight: "normal",
fontSize: "1.2rem",
marginLeft: "1.5rem",
}}
>
{userOrder?.length > 0 {userOrder?.length > 0
? new Date(userOrder[0]?.createdAt).toLocaleString("en-IN", { ? new Date(userOrder[0]?.createdAt).toLocaleString("en-IN", {
weekday: "short", weekday: "short",
@ -195,7 +252,7 @@ const SinglePrincipalDistributorAllDetails = () => {
: "Loading"} : "Loading"}
</Typography> </Typography>
</Typography> </Typography>
</div> </div>
<div style={{ marginTop: "2rem" }}> <div style={{ marginTop: "2rem" }}>
<h5 style={{ fontWeight: "bold", marginBottom: "1rem" }}> <h5 style={{ fontWeight: "bold", marginBottom: "1rem" }}>
@ -239,9 +296,8 @@ const SinglePrincipalDistributorAllDetails = () => {
? `${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