retail distributor to retailers changed and mobile app upload ui

This commit is contained in:
Sibunnayak 2024-11-04 12:37:48 +05:30
parent 868b8d4d7e
commit 2ae31a4112
13 changed files with 473 additions and 262 deletions

View File

@ -99,7 +99,7 @@ const _nav = [
}, },
{ {
component: CNavItem, component: CNavItem,
name: "Retail Distributor", name: "Retailers",
icon: <CIcon icon={cilUser} customClassName="nav-icon" />, icon: <CIcon icon={cilUser} customClassName="nav-icon" />,
to: "/retail-distributor", to: "/retail-distributor",
group: "RetailDistributor", group: "RetailDistributor",
@ -307,6 +307,13 @@ const _nav = [
to: "/logo", to: "/logo",
group: "Settings", group: "Settings",
}, },
{
component: CNavItem,
name: "Mobile App",
icon: <CIcon icon={cilFeaturedPlaylist} customClassName="nav-icon" />,
to: "/mobile-app",
group: "Settings",
},
// { // {
// component: CNavItem, // component: CNavItem,
// name: "Copyright Message", // name: "Copyright Message",

View File

@ -269,7 +269,7 @@ const routes = [
}, },
{ {
path: "/view/SCretaildistributor/:id", path: "/view/SCretaildistributor/:id",
name: "View Retail Distributor", name: "View Retailer",
element: ViewRetailDistributorSC, element: ViewRetailDistributorSC,
navName: "SalesCoOrdinators", navName: "SalesCoOrdinators",
}, },
@ -312,7 +312,7 @@ const routes = [
}, },
{ {
path: "/view/retaildistributor/:id", path: "/view/retaildistributor/:id",
name: "View Retail Distributor", name: "View Retailer",
element: ViewRetailDistributorTM, element: ViewRetailDistributorTM,
navName: "TerritoryManagers", navName: "TerritoryManagers",
}, },
@ -388,25 +388,25 @@ const routes = [
}, },
{ {
path: "/retaildistributor/view/:id", path: "/retaildistributor/view/:id",
name: "Single Retail Distributor", name: "Single Retailer",
element: SingleRetailDistributor, element: SingleRetailDistributor,
navName: "RetailDistributor", navName: "RetailDistributor",
}, },
{ {
path: "/retaildistributor/add", path: "/retaildistributor/add",
name: "Add Retail Distributor", name: "Add Retailer",
element: AddRetailDistributor, element: AddRetailDistributor,
navName: "RetailDistributor", navName: "RetailDistributor",
}, },
{ {
path: "/add-retail-distributor/multiple", path: "/add-retail-distributor/multiple",
name: "Add Retail Distributor", name: "Add Retailer",
element: AddMultiplerd, element: AddMultiplerd,
navName: "RetailDistributor", navName: "RetailDistributor",
}, },
{ {
path: "/retaildistributor/mapping/:id", path: "/retaildistributor/mapping/:id",
name: "Mapping Retail Distributor with PD SC TM", name: "Mapping Retailer with PD SC TM",
element: MapRD, element: MapRD,
navName: "RetailDistributor", navName: "RetailDistributor",
}, },
@ -499,7 +499,7 @@ const routes = [
}, },
{ {
path: "/view/mappedretaildistributor/:id", path: "/view/mappedretaildistributor/:id",
name: "view retail distributor", name: "view Retailer",
element: ViewRetailDistributorPD, element: ViewRetailDistributorPD,
navName: "PrincipalDistributor", navName: "PrincipalDistributor",
}, },

View File

@ -44,7 +44,7 @@ const ViewRetailDistributorPD = () => {
.catch((error) => console.error("Error fetching sc data:", error)); .catch((error) => console.error("Error fetching sc data:", error));
}, [id, token]); }, [id, token]);
// Fetch Retail Distributors data // Fetch Retailers data
const getPDsretaildistributorData = async () => { const getPDsretaildistributorData = async () => {
setLoading(true); setLoading(true);
axios axios
@ -81,7 +81,7 @@ const ViewRetailDistributorPD = () => {
getPDsretaildistributorData(); getPDsretaildistributorData();
}, [success, itemPerPage, currentPage]); }, [success, itemPerPage, currentPage]);
// Debounced search for Retail Distributors // Debounced search for Retailers
const debouncedSearch = useCallback( const debouncedSearch = useCallback(
debounce(() => { debounce(() => {
setCurrentPage(1); setCurrentPage(1);
@ -93,7 +93,7 @@ const ViewRetailDistributorPD = () => {
const handleSearchChange = useCallback(() => { const handleSearchChange = useCallback(() => {
debouncedSearch(); debouncedSearch();
}, [debouncedSearch]); }, [debouncedSearch]);
// Fetch Retail Distributors data for modal // Fetch Retailers data for modal
const getretaildistributorData = async () => { const getretaildistributorData = async () => {
setLoading(true); setLoading(true);
try { try {
@ -130,7 +130,7 @@ const ViewRetailDistributorPD = () => {
} }
}, [openModal, modalcurrentPage]); }, [openModal, modalcurrentPage]);
// Debounced search for Retail Distributors in modal // Debounced search for Retailers in modal
const debouncedmodalSearch = useCallback( const debouncedmodalSearch = useCallback(
debounce(() => { debounce(() => {
setmodalCurrentPage(1); setmodalCurrentPage(1);
@ -187,7 +187,7 @@ const ViewRetailDistributorPD = () => {
.then((res) => { .then((res) => {
swal({ swal({
title: "Deleted", title: "Deleted",
text: "Retail Distributor Unmapped successfully!", text: "Retailer Unmapped successfully!",
icon: "success", icon: "success",
button: "ok", button: "ok",
}); });
@ -221,7 +221,7 @@ const ViewRetailDistributorPD = () => {
); );
swal({ swal({
title: "Success", title: "Success",
text: "Retail Distributor added successfully!", text: "Retailer added successfully!",
icon: "success", icon: "success",
button: "Ok", button: "Ok",
}); });
@ -274,7 +274,7 @@ const ViewRetailDistributorPD = () => {
}} }}
onClick={handleOpenModal} onClick={handleOpenModal}
> >
Add Retail Distributor Add Retailer
</Button> </Button>
<Button <Button
variant="contained" variant="contained"
@ -302,7 +302,7 @@ const ViewRetailDistributorPD = () => {
maxWidth="md" maxWidth="md"
fullWidth fullWidth
> >
<DialogTitle>Search and Add Retail Distributor</DialogTitle> <DialogTitle>Search and Add Retailer</DialogTitle>
<DialogContent> <DialogContent>
<div <div
style={{ style={{
@ -313,8 +313,8 @@ const ViewRetailDistributorPD = () => {
}} }}
> >
<TextField <TextField
label="Retail Distributor Trade Name" label="Retailer Trade Name"
placeholder="Retail Distributor Trade name" placeholder="Retailer Trade name"
inputRef={rdnameRef} inputRef={rdnameRef}
onChange={handlemodalSearchChange} onChange={handlemodalSearchChange}
disabled={loading} disabled={loading}
@ -368,7 +368,7 @@ const ViewRetailDistributorPD = () => {
) : ( ) : (
<tr> <tr>
<td colSpan="6" className="text-center"> <td colSpan="6" className="text-center">
No Retail Distributor found! No Retailers found!
</td> </td>
</tr> </tr>
)} )}
@ -440,7 +440,7 @@ const ViewRetailDistributorPD = () => {
<label>Trade Name:</label> <label>Trade Name:</label>
<input <input
type="text" type="text"
placeholder="Retail Distributor Trade name" placeholder="Retailer Trade name"
className="form-control" className="form-control"
ref={nameRef} ref={nameRef}
onChange={handleSearchChange} onChange={handleSearchChange}
@ -533,7 +533,7 @@ const ViewRetailDistributorPD = () => {
) : ( ) : (
<tr> <tr>
<td className="text-center" colSpan="6"> <td className="text-center" colSpan="6">
No Retail Distributor found! No Retailer found!
</td> </td>
</tr> </tr>
)} )}

View File

@ -70,7 +70,7 @@ const AddMultiplerd = () => {
setErrors(data.errors); setErrors(data.errors);
swal({ swal({
title: "SpreadSheet Upload Successful", title: "SpreadSheet Upload Successful",
text: "A few Retail Distributor have errors. Please fix them and upload again.", text: "A few Retailers have errors. Please fix them and upload again.",
icon: "warning", icon: "warning",
button: "OK", button: "OK",
}); });
@ -80,7 +80,7 @@ const AddMultiplerd = () => {
) { ) {
swal({ swal({
title: "SpreadSheet Upload Successful", title: "SpreadSheet Upload Successful",
text: "Retail Distributors added successfully.", text: "Retailers added successfully.",
icon: "success", icon: "success",
buttons: "OK", buttons: "OK",
}); });
@ -94,7 +94,7 @@ const AddMultiplerd = () => {
console.error("Upload error:", error); console.error("Upload error:", error);
swal( swal(
"Error", "Error",
`Failed to upload Retail Distributor: ${ `Failed to upload Retailers: ${
error.response?.data?.message || "An unexpected error occurred" error.response?.data?.message || "An unexpected error occurred"
}`, }`,
"error" "error"
@ -114,7 +114,7 @@ const AddMultiplerd = () => {
Back Back
</button> </button>
</div> </div>
<h5 className="mb-6 mt-4">Add Multiple Retail Distributor</h5> <h5 className="mb-6 mt-4">Add Multiple Retailers</h5>
<div className="my-3"> <div className="my-3">
<div className="row"> <div className="row">
<div className="col-lg-9"> <div className="col-lg-9">
@ -141,11 +141,11 @@ const AddMultiplerd = () => {
{errors.length > 0 && ( {errors.length > 0 && (
<div className="my-4"> <div className="my-4">
<h6>Finding errors while adding the Retail Distributor.</h6> <h6>Finding errors while adding the Retailers.</h6>
<table className="table table-bordered"> <table className="table table-bordered">
<thead> <thead>
<tr> <tr>
<th>Retail Distributor Name</th> <th>Retailer Name</th>
<th>Email</th> <th>Email</th>
<th>Phone</th> <th>Phone</th>
<th>PAN</th> <th>PAN</th>
@ -172,11 +172,11 @@ const AddMultiplerd = () => {
)} )}
{updatedDistributors.length > 0 && ( {updatedDistributors.length > 0 && (
<div className="my-4"> <div className="my-4">
<h6>Updated Retail Distributors</h6> <h6>Updated Retailers</h6>
<table className="table table-bordered"> <table className="table table-bordered">
<thead> <thead>
<tr> <tr>
<th>Retail Distributor Name</th> <th>Retailer Name</th>
<th>Email</th> <th>Email</th>
<th>Phone</th> <th>Phone</th>
<th>PAN</th> <th>PAN</th>
@ -203,11 +203,11 @@ const AddMultiplerd = () => {
)} )}
{newlyCreated.length > 0 && ( {newlyCreated.length > 0 && (
<div className="my-4"> <div className="my-4">
<h6>Newly Created Retail Distributors:</h6> <h6>Newly Created Retailers:</h6>
<table className="table table-bordered"> <table className="table table-bordered">
<thead> <thead>
<tr> <tr>
<th>Retail Distributor Name</th> <th>Retailer Name</th>
<th>Email</th> <th>Email</th>
<th>Phone</th> <th>Phone</th>
<th>PAN</th> <th>PAN</th>

View File

@ -241,7 +241,7 @@ const SingleDistributorOrder = () => {
mb: 3, mb: 3,
}} }}
> >
<Typography variant="h4">{distributortype === "principaldistributor" ? "Principal Distributor Details":"Retail Distributor Details"}</Typography> <Typography variant="h4">{distributortype === "principaldistributor" ? "Principal Distributor Details":"Retailers Details"}</Typography>
<IconButton sx={{ color: "red" }} onClick={handleCancel}> <IconButton sx={{ color: "red" }} onClick={handleCancel}>
Cancel <CancelIcon /> Cancel <CancelIcon />
</IconButton> </IconButton>

View File

@ -67,7 +67,7 @@ const MapRD = () => {
.then((res) => { .then((res) => {
swal({ swal({
title: "Deleted", title: "Deleted",
text: "Retail Distributor Unmapped successfully!", text: "Retailer Unmapped successfully!",
icon: "success", icon: "success",
button: "Ok", button: "Ok",
}); });

View File

@ -77,7 +77,7 @@ const RetailDistributor = () => {
<div className="col-12"> <div className="col-12">
<div className="page-title-box d-flex align-items-center justify-content-between"> <div className="page-title-box d-flex align-items-center justify-content-between">
<div style={{ fontSize: "22px" }} className="fw-bold"> <div style={{ fontSize: "22px" }} className="fw-bold">
Retail Distributors Retailers
</div> </div>
<div className="page-title-right"> <div className="page-title-right">
<Button <Button
@ -88,7 +88,7 @@ const RetailDistributor = () => {
Navigate("/retaildistributor/add"); Navigate("/retaildistributor/add");
}} }}
> >
Add Retail Distributor Add Retailer
</Button> </Button>
<Button <Button
variant="contained" variant="contained"
@ -300,7 +300,7 @@ const RetailDistributor = () => {
) : ( ) : (
<tr> <tr>
<td className="text-center" colSpan="9"> <td className="text-center" colSpan="9">
No Retail Distributor found! No Retailer found!
</td> </td>
</tr> </tr>
)} )}

View File

@ -485,7 +485,7 @@ const SingleRetailDistributor = () => {
</Grid> </Grid>
</Grid> </Grid>
</Paper> </Paper>
{/* Address of retail distributor */} {/* Address of Retailer */}
<Paper sx={{ p: 2, mb: 3 }}> <Paper sx={{ p: 2, mb: 3 }}>
<h5 style={{ fontWeight: "bold", marginBottom: "1rem" }}> <h5 style={{ fontWeight: "bold", marginBottom: "1rem" }}>
&bull; Addresses{" "} &bull; Addresses{" "}

View File

@ -151,7 +151,7 @@ const AddRetailDistributor = () => {
}); });
if (response.data.success) { if (response.data.success) {
toast.success("Retail Distributor created successfully!"); toast.success("Retailers created successfully!");
navigate("/retail-distributor"); navigate("/retail-distributor");
} }
} catch (error) { } catch (error) {
@ -181,7 +181,7 @@ const AddRetailDistributor = () => {
Cancel Cancel
</Button> </Button>
<Typography variant="h5" sx={{ mb: 3 }}> <Typography variant="h5" sx={{ mb: 3 }}>
Add Retail Distributor Add Retailer
</Typography> </Typography>
<form onSubmit={handleFormSubmit}> <form onSubmit={handleFormSubmit}>
<Typography variant="h5" sx={{ mb: 2 }}> <Typography variant="h5" sx={{ mb: 2 }}>

View File

@ -44,7 +44,7 @@ const ViewRetailDistributorSC = () => {
.catch((error) => console.error("Error fetching sc data:", error)); .catch((error) => console.error("Error fetching sc data:", error));
}, [id, token]); }, [id, token]);
// Fetch Retail Distributors data // Fetch Retailers data
const getSCsretaildistributorData = async () => { const getSCsretaildistributorData = async () => {
setLoading(true); setLoading(true);
axios axios
@ -81,7 +81,7 @@ const ViewRetailDistributorSC = () => {
getSCsretaildistributorData(); getSCsretaildistributorData();
}, [success, itemPerPage, currentPage]); }, [success, itemPerPage, currentPage]);
// Debounced search for Retail Distributors // Debounced search for Retailers
const debouncedSearch = useCallback( const debouncedSearch = useCallback(
debounce(() => { debounce(() => {
setCurrentPage(1); setCurrentPage(1);
@ -93,7 +93,7 @@ const ViewRetailDistributorSC = () => {
const handleSearchChange = useCallback(() => { const handleSearchChange = useCallback(() => {
debouncedSearch(); debouncedSearch();
}, [debouncedSearch]); }, [debouncedSearch]);
// Fetch Retail Distributors data for modal // Fetch Retailers data for modal
const getretaildistributorData = async () => { const getretaildistributorData = async () => {
setLoading(true); setLoading(true);
try { try {
@ -130,7 +130,7 @@ const ViewRetailDistributorSC = () => {
} }
}, [openModal, modalcurrentPage]); }, [openModal, modalcurrentPage]);
// Debounced search for Retail Distributors in modal // Debounced search for Retailers in modal
const debouncedmodalSearch = useCallback( const debouncedmodalSearch = useCallback(
debounce(() => { debounce(() => {
setmodalCurrentPage(1); setmodalCurrentPage(1);
@ -187,7 +187,7 @@ const ViewRetailDistributorSC = () => {
.then((res) => { .then((res) => {
swal({ swal({
title: "Deleted", title: "Deleted",
text: "Retail Distributor Unmapped successfully!", text: "Retailer Unmapped successfully!",
icon: "success", icon: "success",
button: "ok", button: "ok",
}); });
@ -221,7 +221,7 @@ const ViewRetailDistributorSC = () => {
); );
swal({ swal({
title: "Success", title: "Success",
text: "Retail Distributor added successfully!", text: "Retailer added successfully!",
icon: "success", icon: "success",
button: "Ok", button: "Ok",
}); });
@ -274,7 +274,7 @@ const ViewRetailDistributorSC = () => {
}} }}
onClick={handleOpenModal} onClick={handleOpenModal}
> >
Add Retail Distributor Add Retailer
</Button> </Button>
<Button <Button
variant="contained" variant="contained"
@ -302,7 +302,7 @@ const ViewRetailDistributorSC = () => {
maxWidth="md" maxWidth="md"
fullWidth fullWidth
> >
<DialogTitle>Search and Add Retail Distributor</DialogTitle> <DialogTitle>Search and Add Retailer</DialogTitle>
<DialogContent> <DialogContent>
<div <div
style={{ style={{
@ -313,8 +313,8 @@ const ViewRetailDistributorSC = () => {
}} }}
> >
<TextField <TextField
label="Retail Distributor Trade Name" label="Retailer Trade Name"
placeholder="Retail Distributor Trade name" placeholder="Retailer Trade name"
inputRef={rdnameRef} inputRef={rdnameRef}
onChange={handlemodalSearchChange} onChange={handlemodalSearchChange}
disabled={loading} disabled={loading}
@ -368,7 +368,7 @@ const ViewRetailDistributorSC = () => {
) : ( ) : (
<tr> <tr>
<td colSpan="6" className="text-center"> <td colSpan="6" className="text-center">
No Retail Distributor found! No Retailer found!
</td> </td>
</tr> </tr>
)} )}
@ -440,7 +440,7 @@ const ViewRetailDistributorSC = () => {
<label>Trade Name:</label> <label>Trade Name:</label>
<input <input
type="text" type="text"
placeholder="Retail Distributor Trade name" placeholder="Retailer Trade name"
className="form-control" className="form-control"
ref={nameRef} ref={nameRef}
onChange={handleSearchChange} onChange={handleSearchChange}
@ -533,7 +533,7 @@ const ViewRetailDistributorSC = () => {
) : ( ) : (
<tr> <tr>
<td className="text-center" colSpan="6"> <td className="text-center" colSpan="6">
No Retail Distributor found! No Retailer found!
</td> </td>
</tr> </tr>
)} )}

View File

@ -44,7 +44,7 @@ const ViewRetailDistributorTM = () => {
.catch((error) => console.error("Error fetching TM data:", error)); .catch((error) => console.error("Error fetching TM data:", error));
}, [id, token]); }, [id, token]);
// Fetch Retail Distributors data // Fetch Retailers data
const getTMsretaildistributorData = async () => { const getTMsretaildistributorData = async () => {
setLoading(true); setLoading(true);
axios axios
@ -81,7 +81,7 @@ const ViewRetailDistributorTM = () => {
getTMsretaildistributorData(); getTMsretaildistributorData();
}, [success, itemPerPage, currentPage]); }, [success, itemPerPage, currentPage]);
// Debounced search for Retail Distributors // Debounced search for Retailers
const debouncedSearch = useCallback( const debouncedSearch = useCallback(
debounce(() => { debounce(() => {
setCurrentPage(1); setCurrentPage(1);
@ -93,7 +93,7 @@ const ViewRetailDistributorTM = () => {
const handleSearchChange = useCallback(() => { const handleSearchChange = useCallback(() => {
debouncedSearch(); debouncedSearch();
}, [debouncedSearch]); }, [debouncedSearch]);
// Fetch Retail Distributors data for modal // Fetch Retailers data for modal
const getretaildistributorData = async () => { const getretaildistributorData = async () => {
setLoading(true); setLoading(true);
try { try {
@ -130,7 +130,7 @@ const ViewRetailDistributorTM = () => {
} }
}, [openModal, modalcurrentPage]); }, [openModal, modalcurrentPage]);
// Debounced search for Retail Distributors in modal // Debounced search for Retailers in modal
const debouncedmodalSearch = useCallback( const debouncedmodalSearch = useCallback(
debounce(() => { debounce(() => {
setmodalCurrentPage(1); setmodalCurrentPage(1);
@ -187,7 +187,7 @@ const ViewRetailDistributorTM = () => {
.then((res) => { .then((res) => {
swal({ swal({
title: "Deleted", title: "Deleted",
text: "Retail Distributor Unmapped successfully!", text: "Retailer Unmapped successfully!",
icon: "success", icon: "success",
button: "ok", button: "ok",
}); });
@ -221,7 +221,7 @@ const ViewRetailDistributorTM = () => {
); );
swal({ swal({
title: "Success", title: "Success",
text: "Retail Distributor added successfully!", text: "Retailer added successfully!",
icon: "success", icon: "success",
button: "Ok", button: "Ok",
}); });
@ -274,7 +274,7 @@ const ViewRetailDistributorTM = () => {
}} }}
onClick={handleOpenModal} onClick={handleOpenModal}
> >
Add Retail Distributor Add Retailer
</Button> </Button>
<Button <Button
variant="contained" variant="contained"
@ -302,7 +302,7 @@ const ViewRetailDistributorTM = () => {
maxWidth="md" maxWidth="md"
fullWidth fullWidth
> >
<DialogTitle>Search and Add Retail Distributor</DialogTitle> <DialogTitle>Search and Add Retailer</DialogTitle>
<DialogContent> <DialogContent>
<div <div
style={{ style={{
@ -313,8 +313,8 @@ const ViewRetailDistributorTM = () => {
}} }}
> >
<TextField <TextField
label="Retail Distributor Trade Name" label="Retailer Trade Name"
placeholder="Retail Distributor Trade name" placeholder="Retailer Trade name"
inputRef={rdnameRef} inputRef={rdnameRef}
onChange={handlemodalSearchChange} onChange={handlemodalSearchChange}
disabled={loading} disabled={loading}
@ -368,7 +368,7 @@ const ViewRetailDistributorTM = () => {
) : ( ) : (
<tr> <tr>
<td colSpan="6" className="text-center"> <td colSpan="6" className="text-center">
No Retail Distributor found! No Retailers found!
</td> </td>
</tr> </tr>
)} )}
@ -440,7 +440,7 @@ const ViewRetailDistributorTM = () => {
<label>Trade Name:</label> <label>Trade Name:</label>
<input <input
type="text" type="text"
placeholder="Retail Distributor Trade name" placeholder="Retailer Trade name"
className="form-control" className="form-control"
ref={nameRef} ref={nameRef}
onChange={handleSearchChange} onChange={handleSearchChange}
@ -533,7 +533,7 @@ const ViewRetailDistributorTM = () => {
) : ( ) : (
<tr> <tr>
<td className="text-center" colSpan="6"> <td className="text-center" colSpan="6">
No Retail Distributor found! No Retailer found!
</td> </td>
</tr> </tr>
)} )}

View File

@ -1,21 +1,303 @@
// import React, { useEffect, useState } from "react";
// import swal from "sweetalert";
// import ClipLoader from "react-spinners/ClipLoader";
// import { Link } from "react-router-dom";
// import axios from "axios";
// import { isAutheticated } from "src/auth";
// function MobileApp() {
// const [loading, setLoading] = useState(false);
// const [PDApp, setPDApp] = useState("");
// const [RDApp, setRDApp] = useState("");
// const [SCApp, setSCApp] = useState("");
// const [TMApp, setTMApp] = useState("");
// const [display, setDisplay] = useState(true);
// const token = isAutheticated();
// // urlcreated images
// const [PDAppUrl, setPDAppUrl] = useState("");
// const [RDAppUrl, setRDAppUrl] = useState("");
// const [SCAppUrl, setSCAppUrl] = useState("");
// const [TMAppUrl, setTMAppUrl] = useState("");
// useEffect(() => {
// async function getConfiguration() {
// const configDetails = await axios.get(`/api/config`, {
// headers: {
// Authorization: `Bearer ${token}`,
// },
// });
// // console.log(configDetails.data.result[0]?.mobileapp[0]);
// const data = configDetails.data.result[0]?.mobileapp[0];
// setPDApp(data?.PDApp);
// setRDApp(data?.RDApp);
// setSCApp(data?.SCApp);
// setTMApp(data?.TMApp);
// }
// getConfiguration();
// }, []);
// async function handelSubmit() {
// setLoading(true);
// const formdata = new FormData();
// formdata.append("PDApp", PDApp);
// formdata.append("RDApp", RDApp);
// formdata.append("SCApp", SCApp);
// formdata.append("TMApp", TMApp);
// await axios
// .post(`/api/config/mobile-app`, formdata, {
// headers: {
// Authorization: `Bearer ${token}`,
// "Content-Type": "multipart/formdata",
// "Access-Control-Allow-Origin": "*",
// },
// })
// .then((res) => {
// setLoading(false);
// swal("Success!", res.data.message, res.data.status);
// })
// .catch((error) => {
// setLoading(false);
// });
// }
// return (
// <div>
// <div className="main-content">
// <div className="page-content">
// <div className="container-fluid">
// <div className="row">
// <div className="col-lg-12">
// <div className="card">
// <div className="card-body">
// <div className="row">
// <div className="col-md-12 col-lg-6 col-xl-6">
// <h1 className="text-left head-small">Mobile App</h1>
// <form>
// <div className="row">
// <div className="col-lg-12">
// <div className="form-group">
// <>
// <label
// htmlFor="basicpill-phoneno-input"
// className="label-100 mt-3"
// style={{ fontWeight: "bold" }}
// >
// PD Mobile Application <br />
// </label>
// <div>
// <input
// type="file"
// name="Logo htmlFor Website Header(148 x 48 px)"
// onChange={(e) => {
// setPDApp(e.target.files[0]);
// if (
// e.target.files &&
// e.target.files[0]
// ) {
// setPDAppUrl({
// image: URL.createObjectURL(
// e.target.files[0]
// ),
// });
// console.log(setPDAppUrl);
// }
// }}
// className="form-control input-field mb-3 col-md-6 d-inline-block"
// id="basicpill-phoneno-input"
// />
// {display ? (
// <img
// className="ms-1"
// style={{ width: "100px" }}
// src={
// PDAppUrl.image
// ? PDAppUrl.image
// : PDApp
// }
// alt=""
// />
// ) : (
// ""
// )}
// </div>
// <label
// htmlFor="basicpill-phoneno-input"
// className="label-100 mt-3"
// style={{ fontWeight: "bold" }}
// >
// TM Mobile Application
// <br />
// </label>
// <br />
// <input
// type="file"
// name="Logo htmlFor Website Footer(148 x 48 px)"
// onChange={(e) => {
// setRDApp(e.target.files[0]);
// if (e.target.files && e.target.files[0]) {
// setRDAppUrl({
// image: URL.createObjectURL(
// e.target.files[0]
// ),
// });
// }
// }}
// className="form-control input-field mt-1 col-md-6 d-inline-block"
// id="basicpill-phoneno-input"
// />{" "}
// {display ? (
// <img
// style={{ width: "100px" }}
// src={
// RDAppUrl.image
// ? RDAppUrl.image
// : RDApp
// }
// alt=""
// />
// ) : (
// ""
// )}
// <label
// htmlFor="basicpill-phoneno-input"
// className="label-100 mt-2 row ms-1"
// style={{ fontWeight: "bold" }}
// >
// SC Mobile Application
// <br />
// </label>
// <input
// type="file"
// name="Logo htmlFor Admin Header(148 x 48 px)"
// onChange={(e) => {
// setSCApp(e.target.files[0]);
// if (e.target.files && e.target.files[0]) {
// setSCAppUrl({
// image: URL.createObjectURL(
// e.target.files[0]
// ),
// });
// }
// }}
// className="form-control input-field col-md-6 d-inline-block"
// id="basicpill-phoneno-input"
// />{" "}
// {display ? (
// <img
// style={{ width: "100px" }}
// src={
// SCAppUrl.image
// ? SCAppUrl.image
// : SCApp
// }
// alt=""
// />
// ) : (
// ""
// )}
// <label
// htmlFor="basicpill-phoneno-input"
// className="label-100 mt-2 row ms-1"
// style={{ fontWeight: "bold" }}
// >
// RD Mobile Application
// <br />
// </label>
// <input
// type="file"
// name="Logo htmlFor Admin Header(148 x 48 px)"
// onChange={(e) => {
// setRDApp(e.target.files[0]);
// if (e.target.files && e.target.files[0]) {
// setRDAppUrl({
// image: URL.createObjectURL(
// e.target.files[0]
// ),
// });
// }
// }}
// className="form-control input-field col-md-6 d-inline-block"
// id="basicpill-phoneno-input"
// />{" "}
// {display ? (
// <img
// style={{ width: "100px" }}
// src={
// RDAppUrl.image
// ? RDAppUrl.image
// : RDApp
// }
// alt=""
// />
// ) : (
// ""
// )}
// </>
// </div>
// </div>
// </div>
// <div className="row">
// <div className="col-lg-12">
// <div className="form-group text-left">
// <button
// type="button"
// disabled={
// SCApp === "" ||
// RDApp === "" ||
// PDApp === "" ||
// TMApp === ""
// }
// onClick={handelSubmit}
// className="btn btn-success btn-login waves-effect waves-light mr-3 pt-2 pb-2 pr-4 pl-4"
// >
// <ClipLoader loading={loading} size={18} />
// {!loading && "Save"}
// </button>
// </div>
// </div>
// </div>
// </form>
// </div>
// </div>
// {/* <!-- end table-responsive --> */}
// </div>
// </div>
// </div>
// </div>
// </div>
// {/* <!-- container-fluid --> */}
// </div>
// {/* <!-- End Page-content --> */}
// </div>
// </div>
// );
// }
// export default MobileApp;
import React, { useEffect, useState } from "react"; import React, { useEffect, useState } from "react";
import swal from "sweetalert"; import swal from "sweetalert";
import ClipLoader from "react-spinners/ClipLoader"; import ClipLoader from "react-spinners/ClipLoader";
import { Link } from "react-router-dom";
import axios from "axios"; import axios from "axios";
import { isAutheticated } from "src/auth"; import { isAutheticated } from "src/auth";
function MobileApp() { function MobileApp() {
const [loading, setLoading] = useState(false); const [loading, setLoading] = useState(false);
const [PDApp, setPDApp] = useState(""); const [PDApp, setPDApp] = useState(null);
const [RDApp, setRDApp] = useState(""); const [RDApp, setRDApp] = useState(null);
const [SCApp, setSCApp] = useState(""); const [SCApp, setSCApp] = useState(null);
const [TMApp, setTMApp] = useState(""); const [TMApp, setTMApp] = useState(null);
const [display, setDisplay] = useState(true);
const token = isAutheticated(); const token = isAutheticated();
// urlcreated images // URLs for the uploaded APKs
const [PDAppUrl, setPDAppUrl] = useState(""); const [PDAppUrl, setPDAppUrl] = useState("");
const [RDAppUrl, setRDAppUrl] = useState(""); const [RDAppUrl, setRDAppUrl] = useState("");
const [SCAppUrl, setSCAppUrl] = useState(""); const [SCAppUrl, setSCAppUrl] = useState("");
@ -23,17 +305,20 @@ function MobileApp() {
useEffect(() => { useEffect(() => {
async function getConfiguration() { async function getConfiguration() {
try {
const configDetails = await axios.get(`/api/config`, { const configDetails = await axios.get(`/api/config`, {
headers: { headers: {
Authorization: `Bearer ${token}`, Authorization: `Bearer ${token}`,
}, },
}); });
// console.log(configDetails.data.result[0]?.logo[0]); const data = configDetails.data.result[0]?.mobileapp[0];
const data = configDetails.data.result[0]?.logo[0]; setPDAppUrl(data?.PDAppUrl || "");
setPDApp(data?.PDApp); setRDAppUrl(data?.RDAppUrl || "");
setRDApp(data?.RDApp); setSCAppUrl(data?.SCAppUrl || "");
setSCApp(data?.SCApp); setTMAppUrl(data?.TMAppUrl || "");
setTMApp(data?.TMApp); } catch (error) {
console.error("Failed to fetch configuration", error);
}
} }
getConfiguration(); getConfiguration();
}, []); }, []);
@ -41,27 +326,33 @@ function MobileApp() {
async function handelSubmit() { async function handelSubmit() {
setLoading(true); setLoading(true);
const formdata = new FormData(); const formData = new FormData();
formdata.append("PDApp", PDApp); if (PDApp) formData.append("PDApp", PDApp);
formdata.append("RDApp", RDApp); if (RDApp) formData.append("RDApp", RDApp);
formdata.append("SCApp", SCApp); if (SCApp) formData.append("SCApp", SCApp);
formdata.append("TMApp", TMApp); if (TMApp) formData.append("TMApp", TMApp);
await axios try {
.post(`/api/config/logo`, formdata, { const response = await axios.post(`/api/config/mobile-app`, formData, {
headers: { headers: {
Authorization: `Bearer ${token}`, Authorization: `Bearer ${token}`,
"Content-Type": "multipart/formdata", "Content-Type": "multipart/form-data",
"Access-Control-Allow-Origin": "*",
}, },
})
.then((res) => {
setLoading(false);
swal("Success!", res.data.message, res.data.status);
})
.catch((error) => {
setLoading(false);
}); });
setLoading(false);
swal("Success!", response.data.message, "success");
// Update the APK URLs from response
setPDAppUrl(response.data.PDAppUrl);
setRDAppUrl(response.data.RDAppUrl);
setSCAppUrl(response.data.SCAppUrl);
setTMAppUrl(response.data.TMAppUrl);
} catch (error) {
setLoading(false);
console.error("Failed to upload APKs", error);
swal("Error", "Failed to upload APKs", "error");
}
} }
return ( return (
@ -73,175 +364,88 @@ function MobileApp() {
<div className="col-lg-12"> <div className="col-lg-12">
<div className="card"> <div className="card">
<div className="card-body"> <div className="card-body">
<div className="row">
<div className="col-md-12 col-lg-6 col-xl-6">
<h1 className="text-left head-small">Mobile App</h1> <h1 className="text-left head-small">Mobile App</h1>
<form> <form>
<div className="row"> <div className="row">
<div className="col-lg-12"> <div className="col-lg-6">
<div className="form-group"> <div className="form-group">
<> <label className="label-100 mt-3" style={{ fontWeight: "bold" }}>
<label PD Mobile Application
htmlFor="basicpill-phoneno-input"
className="label-100 mt-3"
style={{ fontWeight: "bold" }}
>
Header Logo for user Website(250 x 100
pixels) <br />
</label>
<div>
<input
type="file"
name="Logo htmlFor Website Header(148 x 48 px)"
onChange={(e) => {
setPDApp(e.target.files[0]);
if (
e.target.files &&
e.target.files[0]
) {
setPDAppUrl({
image: URL.createObjectURL(
e.target.files[0]
),
});
console.log(setPDAppUrl);
}
}}
className="form-control input-field mb-3 col-md-6 d-inline-block"
id="basicpill-phoneno-input"
/>
{display ? (
<img
className="ms-1"
style={{ width: "100px" }}
src={
PDAppUrl.image
? PDAppUrl.image
: PDApp
}
alt=""
/>
) : (
""
)}
</div>
<label
htmlFor="basicpill-phoneno-input"
className="label-100 mt-3"
style={{ fontWeight: "bold" }}
>
{/* Logo htmlFor Website Footer(148 x 48 px) */}
Footer logo for user Website(250 x 100
pixels) <br />
</label>
<br />
<input
type="file"
name="Logo htmlFor Website Footer(148 x 48 px)"
onChange={(e) => {
setRDApp(e.target.files[0]);
if (e.target.files && e.target.files[0]) {
setRDAppUrl({
image: URL.createObjectURL(
e.target.files[0]
),
});
}
}}
className="form-control input-field mt-1 col-md-6 d-inline-block"
id="basicpill-phoneno-input"
/>{" "}
{display ? (
<img
style={{ width: "100px" }}
src={
RDAppUrl.image
? RDAppUrl.image
: RDApp
}
alt=""
/>
) : (
""
)}
<label
htmlFor="basicpill-phoneno-input"
className="label-100 mt-2 row ms-1"
style={{ fontWeight: "bold" }}
>
{/* Logo htmlFor Admin Header(148 x 48 px) */}
Logo for admin website(250 x 100 pixels){" "}
<br />
</label> </label>
<input <input
type="file" type="file"
name="Logo htmlFor Admin Header(148 x 48 px)" onChange={(e) => setPDApp(e.target.files[0])}
onChange={(e) => { className="form-control input-field mb-3"
setSCApp(e.target.files[0]);
if (e.target.files && e.target.files[0]) {
setSCAppUrl({
image: URL.createObjectURL(
e.target.files[0]
),
});
}
}}
className="form-control input-field col-md-6 d-inline-block"
id="basicpill-phoneno-input"
/>{" "}
{display ? (
<img
style={{ width: "100px" }}
src={
SCAppUrl.image
? SCAppUrl.image
: SCApp
}
alt=""
/> />
) : ( {PDAppUrl && (
"" <a href={PDAppUrl} download className="btn btn-link">
Download PD App
</a>
)}
</div>
<div className="form-group">
<label className="label-100 mt-3" style={{ fontWeight: "bold" }}>
RD Mobile Application
</label>
<input
type="file"
onChange={(e) => setRDApp(e.target.files[0])}
className="form-control input-field mb-3"
/>
{RDAppUrl && (
<a href={RDAppUrl} download className="btn btn-link">
Download RD App
</a>
)}
</div>
<div className="form-group">
<label className="label-100 mt-3" style={{ fontWeight: "bold" }}>
SC Mobile Application
</label>
<input
type="file"
onChange={(e) => setSCApp(e.target.files[0])}
className="form-control input-field mb-3"
/>
{SCAppUrl && (
<a href={SCAppUrl} download className="btn btn-link">
Download SC App
</a>
)}
</div>
<div className="form-group">
<label className="label-100 mt-3" style={{ fontWeight: "bold" }}>
TM Mobile Application
</label>
<input
type="file"
onChange={(e) => setTMApp(e.target.files[0])}
className="form-control input-field mb-3"
/>
{TMAppUrl && (
<a href={TMAppUrl} download className="btn btn-link">
Download TM App
</a>
)} )}
</>
</div> </div>
</div> </div>
</div> </div>
<div className="row">
<div className="col-lg-12">
<div className="form-group text-left">
<button <button
type="button" type="button"
disabled={
SCApp === "" ||
RDApp === "" ||
PDApp === ""
}
onClick={handelSubmit} onClick={handelSubmit}
className="btn btn-success btn-login waves-effect waves-light mr-3 pt-2 pb-2 pr-4 pl-4" className="btn btn-success mt-3"
disabled={loading}
> >
<ClipLoader loading={loading} size={18} /> {loading ? <ClipLoader size={18} /> : "Save"}
{!loading && "Save"}
</button> </button>
</div>
</div>
</div>
</form> </form>
</div> </div>
</div> </div>
{/* <!-- end table-responsive --> */}
</div> </div>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
{/* <!-- container-fluid --> */}
</div>
{/* <!-- End Page-content --> */}
</div>
</div> </div>
); );
} }

View File

@ -147,14 +147,14 @@ const WidgetsDropdown = ({
/> />
</CCol> </CCol>
{/* </CRow> */} {/* </CRow> */}
{/* <h4>Retail Distributor</h4> */} {/* <h4>Retailers</h4> */}
{/* <CRow> */} {/* <CRow> */}
<CCol sm={6} lg={3}> <CCol sm={6} lg={3}>
<CWidgetStatsA <CWidgetStatsA
className="mb-4" className="mb-4"
color="primary" color="primary"
value={<>{retaildistributor}</>} value={<>{retaildistributor}</>}
title="Total Reatil Distributor" title="Total Reatailers"
/> />
</CCol> </CCol>
{/* </CRow> */} {/* </CRow> */}
@ -252,7 +252,7 @@ const WidgetsDropdown = ({
className="mb-4" className="mb-4"
color="primary" color="primary"
value={<>{product}</>} value={<>{product}</>}
title="Total products" title="Total SKUs"
/> />
</CCol> </CCol>
<CCol sm={6} lg={3}> <CCol sm={6} lg={3}>