forgot pass sign image footer api content etc

This commit is contained in:
pawan-dot 2024-02-13 11:14:44 +05:30
parent ad6545d897
commit 8d79ce8cb0
23 changed files with 1069 additions and 964 deletions

View File

@ -23,7 +23,7 @@
name="keyword" name="keyword"
content="Bootstrap,Admin,Template,Open,Source,CSS,SCSS,HTML,RWD,Dashboard,React" content="Bootstrap,Admin,Template,Open,Source,CSS,SCSS,HTML,RWD,Dashboard,React"
/> />
<title>Admin Get Sygnal</title> <title>Smellika Admin</title>
<!-- <!--
manifest.json provides metadata used when your web app is added to the manifest.json provides metadata used when your web app is added to the
homescreen on Android. See https://developers.google.com/web/fundamentals/engage-and-retain/web-app-manifest/ homescreen on Android. See https://developers.google.com/web/fundamentals/engage-and-retain/web-app-manifest/

View File

@ -8,6 +8,7 @@ import ForgotPassword from "./views/pages/register/ForgotPassword";
import NewRegister from "./views/pages/register/NewRegister"; import NewRegister from "./views/pages/register/NewRegister";
// import ProtectedRoute from './components/ProtectedRoute'; // import ProtectedRoute from './components/ProtectedRoute';
import { isAutheticated } from "./auth"; import { isAutheticated } from "./auth";
import InternetConnectionPopUp from "./views/InternetConnectionPopUp";
const loading = ( const loading = (
<div className="pt-3 text-center"> <div className="pt-3 text-center">
@ -100,6 +101,7 @@ const App = () => {
</Routes> </Routes>
<Toaster /> <Toaster />
</Suspense> </Suspense>
<InternetConnectionPopUp />
</HashRouter> </HashRouter>
); );
}; };

View File

@ -18,11 +18,12 @@ import {
cilNotes, cilNotes,
cilSpeedometer, cilSpeedometer,
cilSwapHorizontal, cilSwapHorizontal,
cilTablet,
cilTennisBall, cilTennisBall,
cilText, cilText,
cilUser, cilUser,
} from "@coreui/icons"; } from "@coreui/icons";
import { CNavGroup, CNavItem, CNavTitle } from "@coreui/react"; import { CNavGroup, CNavItem, CNavTitle, CTabContent } from "@coreui/react";
const _nav = [ const _nav = [
{ {
@ -37,23 +38,37 @@ const _nav = [
icon: <CIcon icon={cilTennisBall} customClassName="nav-icon" />, icon: <CIcon icon={cilTennisBall} customClassName="nav-icon" />,
to: "/users-address", to: "/users-address",
}, },
// {
// component: CNavItem,
// name: "Design",
// icon: <CIcon icon={cibMaterialDesign} customClassName="nav-icon" />,
// to: "/design",
// },
{ {
component: CNavItem, component: CNavGroup,
name: "Design", name: "Product Management",
icon: <CIcon icon={cibMaterialDesign} customClassName="nav-icon" />,
to: "/design",
},
{
component: CNavItem,
name: "Categories",
icon: <CIcon icon={cilCat} customClassName="nav-icon" />,
to: "/categories",
},
{
component: CNavItem,
name: "Products",
icon: <CIcon icon={cilClipboard} customClassName="nav-icon" />, icon: <CIcon icon={cilClipboard} customClassName="nav-icon" />,
to: "/products", items: [
{
component: CNavItem,
name: "Categories",
icon: <CIcon icon={cilCat} customClassName="nav-icon" />,
to: "/categories",
},
{
component: CNavItem,
name: "Products",
icon: <CIcon icon={cilClipboard} customClassName="nav-icon" />,
to: "/products",
},
{
component: CNavItem,
name: "Gst Rate",
icon: <CIcon icon={cilTablet} customClassName="nav-icon" />,
to: "/tax",
},
],
}, },
{ {
component: CNavGroup, component: CNavGroup,

View File

@ -78,7 +78,7 @@ const AppSidebar = () => {
<img src={AdminlogoUrl} alt="" width="100%" /> <img src={AdminlogoUrl} alt="" width="100%" />
</Link> </Link>
) : { AppName } ? ( ) : { AppName } ? (
<h3>Admin Get Sygnal </h3> <h3>Smellika Admin </h3>
) : ( ) : (
"" ""
)} )}

View File

@ -13,10 +13,7 @@ import { cibGmail } from "@coreui/icons";
import { createRoot } from "react-dom/client"; import { createRoot } from "react-dom/client";
const setupAxios = () => { const setupAxios = () => {
axios.defaults.baseURL = "http://localhost:8000"; axios.defaults.baseURL = "http://localhost:5000";
// axios.defaults.baseURL = "https://printsigns.onrender.com/"; //->latest deployed
// axios.defaults.baseURL = "https://api.thesolarsign.com/"; //->latest deployed
axios.defaults.headers = { axios.defaults.headers = {
"Cache-Control": "no-cache,no-store", "Cache-Control": "no-cache,no-store",

View File

@ -86,6 +86,7 @@ import Content from "./views/Content/content";
import EditPrivacyPolicy from "./views/Content/editPrivacyPolicy"; import EditPrivacyPolicy from "./views/Content/editPrivacyPolicy";
import EditTermsConditions from "./views/Content/editTermsConditions"; import EditTermsConditions from "./views/Content/editTermsConditions";
import EditShippingPolicy from "./views/Content/editShippingPolicy"; import EditShippingPolicy from "./views/Content/editShippingPolicy";
import EditRefundpolicy from "./views/Content/editRefundPolicy";
import UserTable from "./views/UserAddress/userTable"; import UserTable from "./views/UserAddress/userTable";
import EditUserAddress from "./views/UserAddress/editUserAddress"; import EditUserAddress from "./views/UserAddress/editUserAddress";
@ -247,6 +248,11 @@ const routes = [
name: "Content", name: "Content",
element: EditShippingPolicy, element: EditShippingPolicy,
}, },
{
path: "/content/refund-policy",
name: "Content",
element: EditRefundpolicy,
},
// { path: '/complaint/view/:id', name: 'view Complain', element: ViewComplaint }, // { path: '/complaint/view/:id', name: 'view Complain', element: ViewComplaint },
//Complaints //Complaints

View File

@ -311,7 +311,7 @@ const Banners = () => {
</div> </div>
<div className="page-title-right"> <div className="page-title-right">
{/* <Button <Button
variant="contained" variant="contained"
color="primary" color="primary"
style={{ style={{
@ -325,7 +325,7 @@ const Banners = () => {
// }} // }}
> >
Add New Banner Add New Banner
</Button> */} </Button>
<Modal <Modal
open={open} open={open}
onClose={handleClose} onClose={handleClose}
@ -360,7 +360,7 @@ const Banners = () => {
onChange={(e) => onChange={(e) =>
setBannerName( setBannerName(
e.target.value.charAt(0).toUpperCase() + e.target.value.charAt(0).toUpperCase() +
e.target.value.slice(1) e.target.value.slice(1)
) )
} }
/> />
@ -483,7 +483,7 @@ const Banners = () => {
p={2} p={2}
display={"flex"} display={"flex"}
justifyContent={"right"} justifyContent={"right"}
// width={"500px"} // width={"500px"}
> >
{!edit && ( {!edit && (
<button <button
@ -627,7 +627,7 @@ const Banners = () => {
width="40" width="40"
alt="" alt=""
/> />
<h5>{ } </h5> <h5>{} </h5>
</td> </td>
<td> <td>
<h5>{item.bannerName} </h5> <h5>{item.bannerName} </h5>

View File

@ -29,6 +29,11 @@ export default function Content() {
action: "Edit", action: "Edit",
path: "/content/shipping-policy", path: "/content/shipping-policy",
}, },
{
name: "Refund policy",
action: "Edit",
path: "/content/refund-policy",
},
]; ];
return ( return (

View File

@ -0,0 +1,165 @@
import { Typography } from "@material-ui/core";
import { Box, Button, TextField } from "@mui/material";
import React, { useEffect, useState } from "react";
import ReactrichTextEditor from "./reactrichTextEditor";
import ReactQuill from "react-quill";
import "react-quill/dist/quill.snow.css";
import axios from "axios";
import { isAutheticated } from "src/auth";
import { useNavigate, useNavigation } from "react-router-dom";
const TOOLBAR_OPTIONS = [
[{ header: [1, 2, 3, 4, 5, 6, false] }],
[{ font: [] }],
[{ list: "ordered" }, { list: "bullet" }],
["bold", "italic", "underline"],
[{ color: [] }, { background: [] }],
[{ align: [] }],
];
export default function editRefundPolicy() {
const [title, setTitle] = useState("Refund policy");
const [content, setContent] = useState("");
const [added, setAdded] = useState(false);
const [olderContent, setOlderContent] = useState("");
const navigation = useNavigate();
const token = isAutheticated();
const handleContentChange = (content, delta, source, editor) => {
setContent(editor.getHTML());
};
const getTermsAndConditions = async () => {
const response = await axios.get("/api/content/refund-policy", {
headers: {
Authorization: `Bearer ${token}`,
},
});
if (response.status === 200) {
// console.log(response);
setContent(response?.data?.Refundpolicys[0]?.Refundpolicy);
setOlderContent(response?.data?.Refundpolicys[0]?.Refundpolicy);
}
};
const addTermsandConditions = async () => {
const response = await axios.patch(
"/api/content/refund-policy",
{ content },
{
headers: {
Authorization: `Bearer ${token}`,
},
}
);
if (response.status == 201) {
swal({
title: "Congratulations!!",
text: "Refund policy added successfully!",
icon: "success",
button: "OK",
});
}
};
const handleCancelClick = () => {
setContent(olderContent);
};
const updateContent = async () => {
const response = await axios.patch(
"/api/content//refund-policy",
{ content },
{
headers: {
Authorization: `Bearer ${token}`,
},
}
);
if (response.status === 200) {
swal({
title: "Congratulations!!",
text: "Refund policy updated successfully!",
icon: "success",
button: "OK",
});
} else {
swal({
title: "Sorry, please try again",
text: "Something went wrong!",
icon: "error",
button: "Retry",
dangerMode: true,
});
}
};
const handleSaveClick = async () => {
if (olderContent === undefined) {
await addTermsandConditions();
setAdded(true);
} else {
await updateContent();
setAdded(false);
}
// Reload terms and conditions
await getTermsAndConditions();
};
useEffect(() => {
// addTermsandConditions();
getTermsAndConditions();
}, [added]);
return (
<div>
<div style={{ display: "flex" }}>
<Button
variant="contained"
color="primary"
onClick={handleSaveClick}
style={{
fontWeight: "bold",
marginBottom: "1rem",
textTransform: "capitalize",
marginRight: "5px",
}}
>
Save
</Button>
<Button
variant="contained"
color="primary"
onClick={handleCancelClick}
style={{
fontWeight: "bold",
marginBottom: "1rem",
textTransform: "capitalize",
marginRight: "5px",
}}
>
Cancel
</Button>
</div>
<Box style={{ background: "#FFFFFF", color: "black", padding: "1rem" }}>
{/* <TextField
type="text"
value={title}
onChange={(e) => setTitle(e.target.value)}
variant="outlined"
size="small"
fullWidth
/> */}
<Typography
style={{ margin: "0.5rem 0rem", fontWeight: "bold" }}
variant="h6"
>
{" "}
Refund policy:{" "}
</Typography>
<Typography style={{ margin: "0.5rem 0rem" }}>Body</Typography>
<ReactQuill
theme="snow"
value={content}
onChange={handleContentChange}
modules={{ toolbar: TOOLBAR_OPTIONS }}
/>
</Box>
</div>
);
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,42 @@
import React, { useState, useEffect } from "react";
import Swal from "sweetalert2";
const InternetConnectionPopUp = () => {
const [isOnline, setIsOnline] = useState(window.navigator.onLine);
useEffect(() => {
const handleOnlineStatusChange = () => {
setIsOnline(window.navigator.onLine);
// If the internet connection is reestablished, reload the page
if (window.navigator.onLine) {
window.location.reload();
}
};
// Add event listeners to detect online/offline status changes
window.addEventListener("online", handleOnlineStatusChange);
window.addEventListener("offline", handleOnlineStatusChange);
// Cleanup: remove event listeners when the component is unmounted
return () => {
window.removeEventListener("online", handleOnlineStatusChange);
window.removeEventListener("offline", handleOnlineStatusChange);
};
}, []);
return (
<div>
{!isOnline &&
swal({
title: "Warning",
text: "Internet connection is lost. Please check your connection.",
icon: "warning",
button: "Retry",
dangerMode: true,
})}
</div>
);
};
export default InternetConnectionPopUp;

View File

@ -29,9 +29,12 @@ const AddProduct = () => {
const [name, setName] = useState(""); const [name, setName] = useState("");
const [description, setDescription] = useState(""); const [description, setDescription] = useState("");
const [productImages, setProductImages] = useState([]); const [productImages, setProductImages] = useState([]);
const [price, setPrice] = useState(""); const [price, setPrice] = useState(0);
const [categoryName, setCategoryName] = useState(""); const [category, setCategoryName] = useState("");
const [error, setError] = useState(""); const [error, setError] = useState("");
const [selectedTax, setselectedTax] = useState();
const [totalAmt, setTotalAmt] = useState(0);
const [gst_amount, setGst_amount] = useState(0);
const handleFileChange = (e) => { const handleFileChange = (e) => {
const files = e.target.files; const files = e.target.files;
@ -106,102 +109,25 @@ const AddProduct = () => {
getAllTax(); getAllTax();
getCategories(); getCategories();
}, [token]); }, [token]);
const TaxRatechange = async (e) => {
let m = JSON.parse(e.target.value);
if (m?.tax) {
let totalprice = Number(price) + Number((price * m?.tax) / 100);
setGst_amount(Number((price * m?.tax) / 100)?.toFixed(2));
setTotalAmt(totalprice?.toFixed(2));
setselectedTax(m?._id);
}
};
// const handleChange = (e) => {
// if (e.target.id === "image") {
// if (
// e.target.files[0]?.type === "image/jpeg" ||
// e.target.files[0]?.type === "image/png" ||
// e.target.files[0]?.type === "image/jpg"
// ) {
// if (imagesPreview.length > 3) {
// swal({
// title: "Warning",
// text: "maximum Four image Upload ",
// icon: "error",
// button: "Close",
// dangerMode: true,
// });
// return;
// }
// // only for file preview------------------------------------
// const files = Array.from(e.target.files);
// files.forEach((file) => {
// const reader = new FileReader();
// reader.onload = () => {
// if (reader.readyState === 2) {
// setImagesPreview((old) => [...old, reader.result]);
// }
// };
// reader.readAsDataURL(file);
// });
// // -----------------------------------------------------------------------------
// setData((prev) => ({
// ...prev,
// image: [...data.image, ...e.target.files],
// }));
// return;
// } else {
// swal({
// title: "Warning",
// text: "Upload jpg, jpeg, png only.",
// icon: "error",
// button: "Close",
// dangerMode: true,
// });
// setData((prev) => ({
// ...prev,
// imageURL: "",
// image: "",
// }));
// e.target.value = null;
// return;
// }
// }
// setData((prev) => ({ ...prev, [e.target.id]: e.target.value }));
// };
// const TaxRatechange = async (e) => {
// let taxDetails = {
// name: e.target.value.slice(12, 16),
// rate: Number(e.target.value.slice(4, 6)),
// taxId: e.target.value.slice(24),
// };
// let trRate = taxDetails.rate / 100;
// let PriceWithT = Number(data.price);
// PriceWithT += +(PriceWithT * trRate).toFixed();
// //price_Level_2_With_Tax
// let price_Level_2_With_Tax = Number(data.price_Level_2);
// price_Level_2_With_Tax += +(price_Level_2_With_Tax * trRate).toFixed();
// //
// //price_Level_3_With_Tax
// let price_Level_3_With_Tax = Number(data.price_Level_3);
// price_Level_3_With_Tax += +(price_Level_3_With_Tax * trRate).toFixed();
// setData((prev) => ({
// ...prev,
// price_With_Tax: PriceWithT,
// price_Level_2_With_Tax: price_Level_2_With_Tax,
// price_Level_3_With_Tax: price_Level_3_With_Tax,
// taxId: taxDetails.taxId,
// }));
// };
// console.log(data.image.length)
const handleSubmit = () => { const handleSubmit = () => {
if ( if (
name == "" || name === "" ||
description == "" || description === "" ||
productImages.length == 0 || productImages.length == 0 ||
price == "" category === "" ||
selectedTax === "" ||
gst_amount === "" ||
price === ""
) { ) {
swal({ swal({
title: "Warning", title: "Warning",
@ -218,7 +144,11 @@ const AddProduct = () => {
formData.append("description", description); formData.append("description", description);
formData.append("price", price); formData.append("price", price);
formData.append("category", categoryName); formData.append("category", category);
formData.append("total_amount", totalAmt);
formData.append("gst_amount", gst_amount);
formData.append("gst", selectedTax);
productImages.forEach((Singleimage) => { productImages.forEach((Singleimage) => {
// console.log(Singleimage) // console.log(Singleimage)
@ -427,17 +357,6 @@ const AddProduct = () => {
marginBottom: "1rem", marginBottom: "1rem",
}} }}
/> />
{/* <IconButton
onClick={() => handelDelete(image)}
sx={{
position: "absolute",
fontSize: "small",
"&:hover": {
background: "black",
},
background: "black",
}}
> */}
<DeleteSharpIcon <DeleteSharpIcon
onClick={() => handelDelete(image)} onClick={() => handelDelete(image)}
fontSize="small" fontSize="small"
@ -479,7 +398,7 @@ const AddProduct = () => {
<div className="card-body px-5"> <div className="card-body px-5">
<div className="mb-3 me-3"> <div className="mb-3 me-3">
<label htmlFor="title" className="form-label"> <label htmlFor="title" className="form-label">
Price* Price(Rs)*
</label> </label>
<input <input
type="number" type="number"
@ -489,26 +408,26 @@ const AddProduct = () => {
onChange={(e) => setPrice(e.target.value)} onChange={(e) => setPrice(e.target.value)}
/> />
</div> </div>
<div> <div className="">
<label htmlFor="categorySelect">Select a Category:</label> <label htmlFor="categorySelect">Select a Category *:</label>
{/* <select <select
id="category" id="category"
className="form-control"
style={{ width: "100%" }} style={{ width: "100%" }}
value={categoryName} value={category}
onChange={(e) => setCategoryName(e.target.value)} onChange={(e) => setCategoryName(e.target.value)}
> >
<option value={""}>None</option> <option value={""}>None</option>
{categories.map((category, index) => ( {categories.map((category, index) => (
<option key={index} value={category.categoryName}> <option key={index} value={category?._id}>
{category.categoryName} {category.categoryName}
</option> </option>
))} ))}
</select> */} </select>
<FormControl fullWidth> {/* <FormControl fullWidth>
<Select <Select
labelId="demo-simple-select-label" labelId="demo-simple-select-label"
id="demo-simple-select" id="demo-simple-select"
fullWidth
value={categoryName} value={categoryName}
onChange={(e) => setCategoryName(e.target.value)} onChange={(e) => setCategoryName(e.target.value)}
> >
@ -540,35 +459,58 @@ const AddProduct = () => {
</MenuItem> </MenuItem>
))} ))}
</Select> </Select>
</FormControl> </FormControl> */}
</div> </div>
{allTax.length > 0 && ( {allTax.length > 0 && (
<div className=" mb-3"> <div className=" mb-3">
<label htmlFor="title" className="form-label"> <label htmlFor="title" className="form-label">
Tax* Gst*
</label>{" "} </label>{" "}
<select <select
className=" form-control" className="form-control"
name="" name="gst"
id="" id="gst"
onChange={(e) => TaxRatechange(e)} onChange={(e) => TaxRatechange(e)}
> >
<option value="" disabled> <option value="">--Select--</option>
-----
</option>
{allTax.map((t, i) => ( {allTax.map((t, i) => (
<option <option key={i} value={JSON.stringify(t)}>
key={i}
value={`tax:${t.tax},name:${t.name} ,taxId:${t._id}`}
>
{t.tax}% {t.name} {t.tax}% {t.name}
</option> </option>
))} ))}
</select> </select>
</div> </div>
)} )}
<div className="mb-3 me-3">
<label htmlFor="title" className="form-label">
Gst Amount (Rs) *
</label>
<input
disabled
type="number"
name="gst_amount"
className="form-control"
id="gst_amount"
value={gst_amount}
// onChange={(e) => setPrice(e.target.value)}
/>
</div>
<div className="mb-3 me-3">
<label htmlFor="title" className="form-label">
Total Amount(Rs)*
</label>
<input
disabled
type="number"
name="total_amount"
className="form-control"
id="total_amount"
value={totalAmt}
// onChange={(e) => setPrice(e.target.value)}
/>
</div>
</div> </div>
</div> </div>
</div> </div>

View File

@ -31,8 +31,11 @@ const EditProduct = () => {
const [description, setDescription] = useState(""); const [description, setDescription] = useState("");
const [productImages, setProductImages] = useState([]); const [productImages, setProductImages] = useState([]);
const [price, setPrice] = useState(""); const [price, setPrice] = useState("");
const [categoryName, setCategoryName] = useState(""); const [category, setCategoryName] = useState("");
const [error, setError] = useState(""); const [error, setError] = useState("");
const [selectedTax, setselectedTax] = useState();
const [totalAmt, setTotalAmt] = useState(0);
const [gst_amount, setGst_amount] = useState(0);
const [newUpdatedImages, setNewUpdatedImages] = useState([]); const [newUpdatedImages, setNewUpdatedImages] = useState([]);
//get Productdata //get Productdata
@ -45,11 +48,15 @@ const EditProduct = () => {
}, },
}) })
.then((res) => { .then((res) => {
console.log(res?.data?.product?.gst?._id);
setName(res?.data?.product.name); setName(res?.data?.product.name);
setDescription(res.data.product.description); setDescription(res.data.product.description);
setProductImages(res.data.product.image); setProductImages(res.data.product.image);
setPrice(res.data.product.price); setPrice(res.data.product.price);
setCategoryName(res.data.product.category); setCategoryName(res.data.product?.category?._id);
setselectedTax(res.data.product?.gst?.name);
setTotalAmt(res.data.product?.total_amount);
setGst_amount(res.data.product?.gst_amount);
}) })
.catch((err) => { .catch((err) => {
swal({ swal({
@ -102,19 +109,25 @@ const EditProduct = () => {
}; };
getAllTax(); getAllTax();
}, [token]); }, [token]);
const TaxRatechange = async (e) => {
let m = JSON.parse(e.target.value);
if (m?.tax) {
let totalprice = Number(price) + Number((price * m?.tax) / 100);
setGst_amount(Number((price * m?.tax) / 100)?.toFixed(2));
setTotalAmt(totalprice?.toFixed(2));
setselectedTax(m?._id);
}
};
const handleSubmit = () => { const handleSubmit = () => {
if ( if (
name == "" || name === "" ||
description == "" || description === "" ||
price == "" || productImages.length == 0 ||
category === "" ||
selectedTax === "" ||
gst_amount === "" ||
price === "" ||
(productImages.length == 0 && newUpdatedImages.length == 0) (productImages.length == 0 && newUpdatedImages.length == 0)
// data.price_With_Tax === '' ||
// data.price_Level_2 === '' ||
// data.price_Level_2_With_Tax === '' ||
// data.price_Level_3 === '' ||
// data.price_Level_3_With_Tax === '' ||
// data.imageURL.trim() === ''
) { ) {
swal({ swal({
title: "Warning", title: "Warning",
@ -131,7 +144,11 @@ const EditProduct = () => {
formData.append("description", description); formData.append("description", description);
formData.append("price", price); formData.append("price", price);
formData.append("category", categoryName); formData.append("category", category);
formData.append("total_amount", totalAmt);
formData.append("gst_amount", gst_amount);
formData.append("gst", selectedTax);
newUpdatedImages.length > 0 && newUpdatedImages.length > 0 &&
newUpdatedImages.forEach((Singleimage) => { newUpdatedImages.forEach((Singleimage) => {
@ -453,7 +470,7 @@ const EditProduct = () => {
<div className="card-body px-5"> <div className="card-body px-5">
<div className="mb-3 me-3"> <div className="mb-3 me-3">
<label htmlFor="title" className="form-label"> <label htmlFor="title" className="form-label">
Price (optional) Price(Rs)*
</label> </label>
<input <input
type="number" type="number"
@ -464,63 +481,27 @@ const EditProduct = () => {
/> />
</div> </div>
<div> <div>
<label htmlFor="categorySelect">Select a Category:</label> <label htmlFor="categorySelect">Select a Category *:</label>
{/* <select <select
id="category" id="category"
className="form-control"
style={{ width: "100%" }} style={{ width: "100%" }}
value={categoryName} value={category}
onChange={(e) => setCategoryName(e.target.value)} onChange={(e) => setCategoryName(e.target.value)}
> >
<option value={""}>None</option> <option value={""}>None</option>
{categories.map((category, index) => ( {categories.map((category, index) => (
<option key={index} value={category.categoryName}> <option key={index} value={category?._id}>
{category.categoryName} {category.categoryName}
</option> </option>
))} ))}
</select> */} </select>
<FormControl fullWidth>
<Select
labelId="demo-simple-select-label"
id="demo-simple-select"
fullWidth
value={categoryName}
onChange={(e) => setCategoryName(e.target.value)}
>
<MenuItem
style={{
width: "100%",
display: "flex",
justifyContent: "left",
textAlign: "left",
padding: "0.5rem",
}}
value={""}
>
None
</MenuItem>
{categories.map((category, i) => (
<MenuItem
style={{
width: "100%",
display: "flex",
justifyContent: "left",
textAlign: "left",
padding: "0.5rem",
}}
key={i}
value={category.categoryName}
>
{category.categoryName}
</MenuItem>
))}
</Select>
</FormControl>
</div> </div>
{allTax.length > 0 && ( {allTax.length > 0 && (
<div className=" mb-3"> <div className=" mb-3">
<label htmlFor="title" className="form-label"> <label htmlFor="title" className="form-label">
Tax* Gst*
</label>{" "} </label>{" "}
<select <select
className=" form-control" className=" form-control"
@ -528,21 +509,45 @@ const EditProduct = () => {
id="" id=""
onChange={(e) => TaxRatechange(e)} onChange={(e) => TaxRatechange(e)}
> >
<option value="" disabled> <option value="">--Select--</option>
-----
</option>
{allTax.map((t, i) => ( {allTax.map((t, i) => (
<option <option key={i} value={JSON.stringify(t)}>
key={i}
value={`tax:${t.tax},name:${t.name} ,taxId:${t._id}`}
>
{t.tax}% {t.name} {t.tax}% {t.name}
</option> </option>
))} ))}
</select> </select>
</div> </div>
)} )}
<div className="mb-3 me-3">
<label htmlFor="title" className="form-label">
Gst Amount (Rs) *
</label>
<input
disabled
type="number"
name="gst_amount"
className="form-control"
id="gst_amount"
value={gst_amount}
// onChange={(e) => setPrice(e.target.value)}
/>
</div>
<div className="mb-3 me-3">
<label htmlFor="title" className="form-label">
Total Amount(Rs)*
</label>
<input
disabled
type="number"
name="total_amount"
className="form-control"
id="total_amount"
value={totalAmt}
// onChange={(e) => setPrice(e.target.value)}
/>
</div>
</div> </div>
</div> </div>
</div> </div>

View File

@ -44,6 +44,7 @@ const Products = () => {
}, },
}) })
.then((res) => { .then((res) => {
console.log(res.data?.product);
setProductsData(res.data?.product); setProductsData(res.data?.product);
setLoading(false); setLoading(false);
}) })
@ -310,9 +311,9 @@ const Products = () => {
textAlign: "left", textAlign: "left",
padding: "0.5rem", padding: "0.5rem",
}} }}
value={product.category} value={product.category?.categoryName}
> >
{product.category} {product.category?.categoryName}
</MenuItem> </MenuItem>
))} ))}
</Select> </Select>
@ -334,8 +335,8 @@ const Products = () => {
> >
<tr> <tr>
<th className="text-start">Image</th> <th className="text-start">Image</th>
<th className="text-start">Product Name</th> <th className="text-start">Product</th>
<th className="text-start">Category Name</th> <th className="text-start">Category</th>
<th className="text-start">Price</th> <th className="text-start">Price</th>
<th className="text-start">Added On</th> <th className="text-start">Added On</th>
@ -374,11 +375,13 @@ const Products = () => {
</th> </th>
<td className="text-start">{product.name}</td> <td className="text-start">{product.name}</td>
<td className="text-start"> <td className="text-start">
{product.category !== "" {product.category?.categoryName !== ""
? product.category ? product.category?.categoryName
: "Category Not selected "} : "Category Not selected "}
</td> </td>
<th className="text-start">${product.price}</th> <th className="text-start">
{product?.total_amount}
</th>
<td className="text-start"> <td className="text-start">
{new Date(product.createdAt).toLocaleString( {new Date(product.createdAt).toLocaleString(
"en-IN", "en-IN",

View File

@ -85,7 +85,6 @@ function ViewProduct() {
<tr> <tr>
<th>Name</th> <td>{product?.name}</td> <th>Name</th> <td>{product?.name}</td>
</tr> </tr>
{product.image && ( {product.image && (
<tr> <tr>
<th>image</th> <th>image</th>
@ -101,15 +100,39 @@ function ViewProduct() {
</td> </td>
</tr> </tr>
)} )}
<tr>
<th>Category </th>
<td>
{product.category?.categoryName !== ""
? product.category?.categoryName
: "Category not selected "}
</td>
</tr>
<tr> <tr>
<th>Description</th> <th>Description</th>
<td>{product?.description}</td> <td>{product?.description}</td>
</tr> </tr>
<tr> <tr>
<th>Base Price</th> <th>Price</th>
<td>${product?.price}</td> <td>{product?.price}</td>
</tr> </tr>
<tr>
<th>Gst</th>
<td>
{product?.gst?.tax}% {product?.gst?.name}
</td>
</tr>
{product?.gst_amount && (
<tr>
<th>Gst Amount</th>
<td>{product?.gst_amount}</td>
</tr>
)}
<tr>
<th>Total Amount(with Gst)</th>
<td>{product?.total_amount}</td>
</tr>
{/* <tr><th>Product Time</th><td>{product?.time}</td></tr> {/* <tr><th>Product Time</th><td>{product?.time}</td></tr>
<tr><th>Location</th><td>{product?.location}</td></tr> */} <tr><th>Location</th><td>{product?.location}</td></tr> */}
<tr> <tr>
@ -132,15 +155,6 @@ function ViewProduct() {
</span> </span>
</td> </td>
</tr> </tr>
<tr>
<th>Category </th>
<td>
{product.category !== ""
? product.category
: "Category not selected "}
</td>
</tr>
</thead> </thead>
<tbody></tbody> <tbody></tbody>
</table> </table>

View File

@ -139,7 +139,7 @@ function CancelledOrders() {
{order?.user?.name} {order?.user?.name}
</td> </td>
<td className="text-start"> <td className="text-start">
${order?.total_amount} {order?.total_amount}
</td> </td>
<td className="text-start"> <td className="text-start">
{new Date(order?.paidAt).toLocaleString( {new Date(order?.paidAt).toLocaleString(

View File

@ -139,7 +139,7 @@ function DeliveredOrders() {
{order?.user?.name} {order?.user?.name}
</td> </td>
<td className="text-start"> <td className="text-start">
${order?.total_amount} {order?.total_amount}
</td> </td>
<td className="text-start"> <td className="text-start">
{new Date(order?.paidAt).toLocaleString( {new Date(order?.paidAt).toLocaleString(

View File

@ -142,7 +142,7 @@ function DispatchedOrders() {
{order?.user?.name} {order?.user?.name}
</td> </td>
<td className="text-start"> <td className="text-start">
${order?.total_amount} {order?.total_amount}
</td> </td>
<td className="text-start"> <td className="text-start">
{new Date(order?.paidAt).toLocaleString( {new Date(order?.paidAt).toLocaleString(

View File

@ -193,7 +193,7 @@ function NewOrders() {
{order?.user?.name} {order?.user?.name}
</td> </td>
<td className="text-start"> <td className="text-start">
${order?.total_amount} {order?.total_amount}
</td> </td>
<td className="text-start"> <td className="text-start">
{new Date(order?.paidAt).toLocaleString( {new Date(order?.paidAt).toLocaleString(

View File

@ -143,7 +143,7 @@ function ProcessingOrders() {
{order?.user?.name} {order?.user?.name}
</td> </td>
<td className="text-start"> <td className="text-start">
${order?.total_amount} {order?.total_amount}
</td> </td>
<td className="text-start"> <td className="text-start">
{new Date(order?.paidAt).toLocaleString( {new Date(order?.paidAt).toLocaleString(

View File

@ -1,50 +1,52 @@
import React, { useState, useEffect } from 'react' import React, { useState, useEffect } from "react";
import { Link } from 'react-router-dom' 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 ReturnedOrders() { function ReturnedOrders() {
const token = isAutheticated() const token = isAutheticated();
const [loading, setLoading] = useState(true) const [loading, setLoading] = useState(true);
const [success, setSuccess] = useState(true) const [success, setSuccess] = useState(true);
const [returnedOrdersData, setReturnedOrdersData] = useState([]) const [returnedOrdersData, setReturnedOrdersData] = useState([]);
const [currentPage, setCurrentPage] = useState(1) const [currentPage, setCurrentPage] = useState(1);
const [itemPerPage, setItemPerPage] = useState(10) const [itemPerPage, setItemPerPage] = useState(10);
const [showData, setShowData] = useState(returnedOrdersData) const [showData, setShowData] = useState(returnedOrdersData);
const handleShowEntries = (e) => { const handleShowEntries = (e) => {
setCurrentPage(1) setCurrentPage(1);
setItemPerPage(e.target.value) setItemPerPage(e.target.value);
} };
useEffect(() => { useEffect(() => {
function getProcessingOrder() { function getProcessingOrder() {
axios axios
.get(`/api/order/list/returned`, { .get(`/api/order/list/returned`, {
headers: { 'Access-Control-Allow-Origin': '*', Authorization: `Bearer ${token}` }, headers: {
"Access-Control-Allow-Origin": "*",
Authorization: `Bearer ${token}`,
},
}) })
.then((res) => { .then((res) => {
setReturnedOrdersData(res.data.data) setReturnedOrdersData(res.data.data);
setLoading(false) setLoading(false);
}) })
.catch((err) => { .catch((err) => {
console.log(err) console.log(err);
setLoading(false) setLoading(false);
}) });
} }
getProcessingOrder() getProcessingOrder();
}, []) }, []);
useEffect(() => { useEffect(() => {
const loadData = () => { const loadData = () => {
const indexOfLastPost = currentPage * itemPerPage const indexOfLastPost = currentPage * itemPerPage;
const indexOfFirstPost = indexOfLastPost - itemPerPage const indexOfFirstPost = indexOfLastPost - itemPerPage;
setShowData(returnedOrdersData.slice(indexOfFirstPost, indexOfLastPost)) setShowData(returnedOrdersData.slice(indexOfFirstPost, indexOfLastPost));
} };
loadData() loadData();
}, [currentPage, itemPerPage, returnedOrdersData]) }, [currentPage, itemPerPage, returnedOrdersData]);
return ( return (
<div className="main-content"> <div className="main-content">
@ -60,7 +62,7 @@ function ReturnedOrders() {
justify-content-between justify-content-between
" "
> >
<div style={{ fontSize: '22px' }} className="fw-bold"> <div style={{ fontSize: "22px" }} className="fw-bold">
Returned Orders Returned Orders
</div> </div>
</div> </div>
@ -76,7 +78,7 @@ function ReturnedOrders() {
<label className="w-100"> <label className="w-100">
Show Show
<select <select
style={{ width: '10%' }} style={{ width: "10%" }}
name="" name=""
onChange={(e) => handleShowEntries(e)} onChange={(e) => handleShowEntries(e)}
className=" className="
@ -99,9 +101,12 @@ function ReturnedOrders() {
<div className="table-responsive table-shoot mt-3"> <div className="table-responsive table-shoot mt-3">
<table <table
className="table table-centered table-nowrap" className="table table-centered table-nowrap"
style={{ border: '1px solid' }} style={{ border: "1px solid" }}
> >
<thead className="thead-light" style={{ background: '#ecdddd' }}> <thead
className="thead-light"
style={{ background: "#ecdddd" }}
>
<tr> <tr>
<th className="text-start">Order ID</th> <th className="text-start">Order ID</th>
<th className="text-start">Parent Name</th> <th className="text-start">Parent Name</th>
@ -130,17 +135,24 @@ function ReturnedOrders() {
return ( return (
<tr key={i}> <tr key={i}>
<td className="text-start">{order.order_id}</td> <td className="text-start">{order.order_id}</td>
<td className="text-start">{order.parent.name}</td>
<td className="text-start">{order?.total_amount}</td>
<td className="text-start"> <td className="text-start">
{new Date(order?.placed_on).toLocaleString('en-IN', { {order.parent.name}
month: 'short', </td>
day: 'numeric', <td className="text-start">
year: 'numeric', {order?.total_amount}
hour: '2-digit', </td>
minute: 'numeric', <td className="text-start">
hour12: true, {new Date(order?.placed_on).toLocaleString(
})} "en-IN",
{
month: "short",
day: "numeric",
year: "numeric",
hour: "2-digit",
minute: "numeric",
hour12: true,
}
)}
</td> </td>
<td className="text-start"> <td className="text-start">
<span className="badge text-bg-success text-white"> <span className="badge text-bg-success text-white">
@ -148,9 +160,11 @@ function ReturnedOrders() {
</span> </span>
</td> </td>
<td className="text-start"> <td className="text-start">
<Link to={`/orders/${order.status}/${order._id}`}> <Link
to={`/orders/${order.status}/${order._id}`}
>
<button <button
style={{ color: 'white' }} style={{ color: "white" }}
type="button" type="button"
className=" className="
btn btn-primary btn-sm btn btn-primary btn-sm
@ -164,7 +178,7 @@ function ReturnedOrders() {
</Link> </Link>
</td> </td>
</tr> </tr>
) );
}) })
)} )}
</tbody> </tbody>
@ -179,9 +193,12 @@ function ReturnedOrders() {
role="status" role="status"
aria-live="polite" aria-live="polite"
> >
Showing {currentPage * itemPerPage - itemPerPage + 1} to{' '} Showing {currentPage * itemPerPage - itemPerPage + 1} to{" "}
{Math.min(currentPage * itemPerPage, returnedOrdersData.length)} of{' '} {Math.min(
{returnedOrdersData.length} entries currentPage * itemPerPage,
returnedOrdersData.length
)}{" "}
of {returnedOrdersData.length} entries
</div> </div>
</div> </div>
@ -191,13 +208,13 @@ function ReturnedOrders() {
<li <li
className={ className={
currentPage === 1 currentPage === 1
? 'paginate_button page-item previous disabled' ? "paginate_button page-item previous disabled"
: 'paginate_button page-item previous' : "paginate_button page-item previous"
} }
> >
<span <span
className="page-link" className="page-link"
style={{ cursor: 'pointer' }} style={{ cursor: "pointer" }}
onClick={() => setCurrentPage((prev) => prev - 1)} onClick={() => setCurrentPage((prev) => prev - 1)}
> >
Previous Previous
@ -208,8 +225,10 @@ function ReturnedOrders() {
<li className="paginate_button page-item"> <li className="paginate_button page-item">
<span <span
className="page-link" className="page-link"
style={{ cursor: 'pointer' }} style={{ cursor: "pointer" }}
onClick={(e) => setCurrentPage((prev) => prev - 1)} onClick={(e) =>
setCurrentPage((prev) => prev - 1)
}
> >
{currentPage - 1} {currentPage - 1}
</span> </span>
@ -217,7 +236,10 @@ function ReturnedOrders() {
)} )}
<li className="paginate_button page-item active"> <li className="paginate_button page-item active">
<span className="page-link" style={{ cursor: 'pointer' }}> <span
className="page-link"
style={{ cursor: "pointer" }}
>
{currentPage} {currentPage}
</span> </span>
</li> </li>
@ -226,18 +248,18 @@ function ReturnedOrders() {
(currentPage + 1) * itemPerPage - itemPerPage > (currentPage + 1) * itemPerPage - itemPerPage >
returnedOrdersData.length - 1 returnedOrdersData.length - 1
) && ( ) && (
<li className="paginate_button page-item "> <li className="paginate_button page-item ">
<span <span
className="page-link" className="page-link"
style={{ cursor: 'pointer' }} style={{ cursor: "pointer" }}
onClick={() => { onClick={() => {
setCurrentPage((prev) => prev + 1) setCurrentPage((prev) => prev + 1);
}} }}
> >
{currentPage + 1} {currentPage + 1}
</span> </span>
</li> </li>
)} )}
<li <li
className={ className={
@ -245,13 +267,13 @@ function ReturnedOrders() {
(currentPage + 1) * itemPerPage - itemPerPage > (currentPage + 1) * itemPerPage - itemPerPage >
returnedOrdersData.length - 1 returnedOrdersData.length - 1
) )
? 'paginate_button page-item next' ? "paginate_button page-item next"
: 'paginate_button page-item next disabled' : "paginate_button page-item next disabled"
} }
> >
<span <span
className="page-link" className="page-link"
style={{ cursor: 'pointer' }} style={{ cursor: "pointer" }}
onClick={() => setCurrentPage((prev) => prev + 1)} onClick={() => setCurrentPage((prev) => prev + 1)}
> >
Next Next
@ -268,7 +290,7 @@ function ReturnedOrders() {
</div> </div>
</div> </div>
</div> </div>
) );
} }
export default ReturnedOrders export default ReturnedOrders;

View File

@ -449,14 +449,14 @@ function ViewOrders() {
</div> </div>
<p className="m-0 mt-3 ms-3"> <p className="m-0 mt-3 ms-3">
<stong> Total Price:</stong> $ <stong> Total Price:</stong>
{productDetails?.quantity * {productDetails?.quantity *
productDetails?.price} productDetails?.price}
</p> </p>
</div> </div>
<div className="col-sm-6"> <div className="col-sm-6">
<p className="m-0 mt-3"> <p className="m-0 mt-3">
<stong> Price:</stong> $ <stong> Price:</stong>
{productDetails?.price} {productDetails?.price}
</p> </p>
</div> </div>
@ -468,10 +468,10 @@ function ViewOrders() {
) )
)} )}
<div className="m-0 contents-center mt-3 mb-2"> <div className="m-0 contents-center mt-3 mb-2">
<small className="mb-4">Shipping Charge: </small> $ <small className="mb-4">Shipping Charge: </small>
{orderDetails?.shipping_charge} {orderDetails?.shipping_charge}
<br /> <br />
<span className="mt-2"> Total Order Value: </span> $ <span className="mt-2"> Total Order Value: </span>
{orderDetails?.total_amount} {orderDetails?.total_amount}
</div> </div>
</div> </div>

View File

@ -138,9 +138,9 @@ const Login = () => {
<CCard className="p-4"> <CCard className="p-4">
<CCardBody> <CCardBody>
<CForm> <CForm>
<h1>Get Sygnal</h1> <h1>Smellika</h1>
<p className="text-medium-emphasis"> <p className="text-medium-emphasis">
Sign In to Your Get Sygnal Admin Dashboard Account. Sign In to Your Smellika Admin Dashboard Account.
</p> </p>
<CInputGroup className="mb-3"> <CInputGroup className="mb-3">
<CInputGroupText> <CInputGroupText>