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

View File

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

View File

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

View File

@ -70,7 +70,7 @@ const AddMultiplerd = () => {
setErrors(data.errors);
swal({
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",
button: "OK",
});
@ -80,7 +80,7 @@ const AddMultiplerd = () => {
) {
swal({
title: "SpreadSheet Upload Successful",
text: "Retail Distributors added successfully.",
text: "Retailers added successfully.",
icon: "success",
buttons: "OK",
});
@ -94,7 +94,7 @@ const AddMultiplerd = () => {
console.error("Upload error:", error);
swal(
"Error",
`Failed to upload Retail Distributor: ${
`Failed to upload Retailers: ${
error.response?.data?.message || "An unexpected error occurred"
}`,
"error"
@ -114,7 +114,7 @@ const AddMultiplerd = () => {
Back
</button>
</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="row">
<div className="col-lg-9">
@ -141,11 +141,11 @@ const AddMultiplerd = () => {
{errors.length > 0 && (
<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">
<thead>
<tr>
<th>Retail Distributor Name</th>
<th>Retailer Name</th>
<th>Email</th>
<th>Phone</th>
<th>PAN</th>
@ -172,11 +172,11 @@ const AddMultiplerd = () => {
)}
{updatedDistributors.length > 0 && (
<div className="my-4">
<h6>Updated Retail Distributors</h6>
<h6>Updated Retailers</h6>
<table className="table table-bordered">
<thead>
<tr>
<th>Retail Distributor Name</th>
<th>Retailer Name</th>
<th>Email</th>
<th>Phone</th>
<th>PAN</th>
@ -203,11 +203,11 @@ const AddMultiplerd = () => {
)}
{newlyCreated.length > 0 && (
<div className="my-4">
<h6>Newly Created Retail Distributors:</h6>
<h6>Newly Created Retailers:</h6>
<table className="table table-bordered">
<thead>
<tr>
<th>Retail Distributor Name</th>
<th>Retailer Name</th>
<th>Email</th>
<th>Phone</th>
<th>PAN</th>

View File

@ -241,7 +241,7 @@ const SingleDistributorOrder = () => {
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}>
Cancel <CancelIcon />
</IconButton>

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -44,7 +44,7 @@ const ViewRetailDistributorTM = () => {
.catch((error) => console.error("Error fetching TM data:", error));
}, [id, token]);
// Fetch Retail Distributors data
// Fetch Retailers data
const getTMsretaildistributorData = async () => {
setLoading(true);
axios
@ -81,7 +81,7 @@ const ViewRetailDistributorTM = () => {
getTMsretaildistributorData();
}, [success, itemPerPage, currentPage]);
// Debounced search for Retail Distributors
// Debounced search for Retailers
const debouncedSearch = useCallback(
debounce(() => {
setCurrentPage(1);
@ -93,7 +93,7 @@ const ViewRetailDistributorTM = () => {
const handleSearchChange = useCallback(() => {
debouncedSearch();
}, [debouncedSearch]);
// Fetch Retail Distributors data for modal
// Fetch Retailers data for modal
const getretaildistributorData = async () => {
setLoading(true);
try {
@ -130,7 +130,7 @@ const ViewRetailDistributorTM = () => {
}
}, [openModal, modalcurrentPage]);
// Debounced search for Retail Distributors in modal
// Debounced search for Retailers in modal
const debouncedmodalSearch = useCallback(
debounce(() => {
setmodalCurrentPage(1);
@ -187,7 +187,7 @@ const ViewRetailDistributorTM = () => {
.then((res) => {
swal({
title: "Deleted",
text: "Retail Distributor Unmapped successfully!",
text: "Retailer Unmapped successfully!",
icon: "success",
button: "ok",
});
@ -221,7 +221,7 @@ const ViewRetailDistributorTM = () => {
);
swal({
title: "Success",
text: "Retail Distributor added successfully!",
text: "Retailer added successfully!",
icon: "success",
button: "Ok",
});
@ -274,7 +274,7 @@ const ViewRetailDistributorTM = () => {
}}
onClick={handleOpenModal}
>
Add Retail Distributor
Add Retailer
</Button>
<Button
variant="contained"
@ -302,7 +302,7 @@ const ViewRetailDistributorTM = () => {
maxWidth="md"
fullWidth
>
<DialogTitle>Search and Add Retail Distributor</DialogTitle>
<DialogTitle>Search and Add Retailer</DialogTitle>
<DialogContent>
<div
style={{
@ -313,8 +313,8 @@ const ViewRetailDistributorTM = () => {
}}
>
<TextField
label="Retail Distributor Trade Name"
placeholder="Retail Distributor Trade name"
label="Retailer Trade Name"
placeholder="Retailer Trade name"
inputRef={rdnameRef}
onChange={handlemodalSearchChange}
disabled={loading}
@ -368,7 +368,7 @@ const ViewRetailDistributorTM = () => {
) : (
<tr>
<td colSpan="6" className="text-center">
No Retail Distributor found!
No Retailers found!
</td>
</tr>
)}
@ -440,7 +440,7 @@ const ViewRetailDistributorTM = () => {
<label>Trade Name:</label>
<input
type="text"
placeholder="Retail Distributor Trade name"
placeholder="Retailer Trade name"
className="form-control"
ref={nameRef}
onChange={handleSearchChange}
@ -533,7 +533,7 @@ const ViewRetailDistributorTM = () => {
) : (
<tr>
<td className="text-center" colSpan="6">
No Retail Distributor found!
No Retailer found!
</td>
</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 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 [PDApp, setPDApp] = useState(null);
const [RDApp, setRDApp] = useState(null);
const [SCApp, setSCApp] = useState(null);
const [TMApp, setTMApp] = useState(null);
const token = isAutheticated();
// urlcreated images
// URLs for the uploaded APKs
const [PDAppUrl, setPDAppUrl] = useState("");
const [RDAppUrl, setRDAppUrl] = useState("");
const [SCAppUrl, setSCAppUrl] = useState("");
@ -23,17 +305,20 @@ function MobileApp() {
useEffect(() => {
async function getConfiguration() {
const configDetails = await axios.get(`/api/config`, {
headers: {
Authorization: `Bearer ${token}`,
},
});
// console.log(configDetails.data.result[0]?.logo[0]);
const data = configDetails.data.result[0]?.logo[0];
setPDApp(data?.PDApp);
setRDApp(data?.RDApp);
setSCApp(data?.SCApp);
setTMApp(data?.TMApp);
try {
const configDetails = await axios.get(`/api/config`, {
headers: {
Authorization: `Bearer ${token}`,
},
});
const data = configDetails.data.result[0]?.mobileapp[0];
setPDAppUrl(data?.PDAppUrl || "");
setRDAppUrl(data?.RDAppUrl || "");
setSCAppUrl(data?.SCAppUrl || "");
setTMAppUrl(data?.TMAppUrl || "");
} catch (error) {
console.error("Failed to fetch configuration", error);
}
}
getConfiguration();
}, []);
@ -41,27 +326,33 @@ function MobileApp() {
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);
const formData = new FormData();
if (PDApp) formData.append("PDApp", PDApp);
if (RDApp) formData.append("RDApp", RDApp);
if (SCApp) formData.append("SCApp", SCApp);
if (TMApp) formData.append("TMApp", TMApp);
await axios
.post(`/api/config/logo`, formdata, {
try {
const response = await axios.post(`/api/config/mobile-app`, formData, {
headers: {
Authorization: `Bearer ${token}`,
"Content-Type": "multipart/formdata",
"Access-Control-Allow-Origin": "*",
"Content-Type": "multipart/form-data",
},
})
.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 (
@ -73,174 +364,87 @@ function MobileApp() {
<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" }}
>
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>
<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=""
/>
) : (
""
)}
</>
</div>
</div>
<h1 className="text-left head-small">Mobile App</h1>
<form>
<div className="row">
<div className="col-lg-6">
<div className="form-group">
<label className="label-100 mt-3" style={{ fontWeight: "bold" }}>
PD Mobile Application
</label>
<input
type="file"
onChange={(e) => setPDApp(e.target.files[0])}
className="form-control input-field mb-3"
/>
{PDAppUrl && (
<a href={PDAppUrl} download className="btn btn-link">
Download PD App
</a>
)}
</div>
<div className="row">
<div className="col-lg-12">
<div className="form-group text-left">
<button
type="button"
disabled={
SCApp === "" ||
RDApp === "" ||
PDApp === ""
}
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 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>
</form>
<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>
{/* <!-- end table-responsive --> */}
<button
type="button"
onClick={handelSubmit}
className="btn btn-success mt-3"
disabled={loading}
>
{loading ? <ClipLoader size={18} /> : "Save"}
</button>
</form>
</div>
</div>
</div>
</div>
</div>
{/* <!-- container-fluid --> */}
</div>
{/* <!-- End Page-content --> */}
</div>
</div>
);

View File

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