order and tax

This commit is contained in:
pawan-dot 2023-02-02 15:09:49 +05:30
parent e671d8fc91
commit b71589fa55
19 changed files with 1760 additions and 109 deletions

View File

@ -40,7 +40,7 @@
"@coreui/react-chartjs": "^2.0.0",
"@coreui/utils": "^1.3.1",
"@material-ui/core": "^4.12.4",
"@reduxjs/toolkit": "^1.8.2",
"@reduxjs/toolkit": "^1.9.2",
"@wojtekmaj/enzyme-adapter-react-17": "^0.6.5",
"axios": "^0.25.0",
"bootstrap": "^5.1.3",
@ -57,9 +57,10 @@
"react-date-picker": "^8.4.0",
"react-datepicker": "^4.8.0",
"react-dom": "^18.0.0",
"react-hot-toast": "^2.4.0",
"react-paginate": "^8.1.3",
"react-qr-code": "^2.0.11",
"react-redux": "^7.2.6",
"react-redux": "^7.2.9",
"react-router-dom": "^6.7.0",
"react-spinners": "^0.11.0",
"react-time-picker": "^4.5.0",

View File

@ -2,6 +2,7 @@ import React, { Component, Suspense } from 'react'
import axios from 'axios';
import { Router, Route, Routes, HashRouter } from 'react-router-dom'
import { useState, useEffect } from 'react';
import { Toaster } from "react-hot-toast";
import './scss/style.scss'
import ForgotPassword from './views/pages/register/ForgotPassword'
import NewRegister from './views/pages/register/NewRegister'
@ -81,7 +82,9 @@ const App = () => {
<Route path="*" name="Home" element={<DefaultLayout />} />
</Routes>
<Toaster />
</Suspense>
</HashRouter>
)

View File

@ -13,6 +13,7 @@ import {
cilDrop,
cilFace,
cilFilterSquare,
cilLoopCircular,
cilMedicalCross,
cilMoney,
cilMugTea,
@ -24,6 +25,7 @@ import {
cilSpeedometer,
cilStar,
cilTablet,
cilTags,
cilTennisBall,
cilUser,
@ -48,7 +50,7 @@ const _nav = [
},
{
component: CNavItem,
name: 'Temples',
name: 'Franchisee',
icon: <CIcon icon={cilTennisBall} customClassName="nav-icon" />,
to: '/temples',
},
@ -112,7 +114,7 @@ const _nav = [
{
component: CNavItem,
name: 'Cities',
icon: <CIcon icon={cilNotes} customClassName="nav-icon" />,
icon: <CIcon icon={cilLoopCircular} customClassName="nav-icon" />,
to: '/cities',
},
{
@ -139,12 +141,12 @@ const _nav = [
// icon: <CIcon icon={cilCommand} customClassName="nav-icon" />,
// to: '/pincode',
// },
// {
// component: CNavItem,
// name: 'Tax Rates',
// icon: <CIcon icon={cilCommand} customClassName="nav-icon" />,
// to: '/tax',
// },
{
component: CNavItem,
name: 'Tax Rates',
icon: <CIcon icon={cilTags} customClassName="nav-icon" />,
to: '/tax',
},
// {
// component: CNavItem,
// name: 'Pages',

View File

@ -30,4 +30,6 @@ const AppContent = () => {
)
}
export default React.memo(AppContent)

View File

@ -7,8 +7,8 @@ import ReactDOM from 'react-dom'
import App from './App'
import * as serviceWorker from './serviceWorker'
import { Provider } from 'react-redux'
import store from './store'
import axios from 'axios'
import { store } from './redux/store';
const setupAxios = () => {
axios.defaults.baseURL = 'https://atpapi.checkapp.one'

View File

@ -0,0 +1,71 @@
import axios from "axios";
// Add to Cart
// export const addItemsToCart = (id, quantity) => async (dispatch, getState) => {
// const { productData } = await axios.get(`/api/v1/product/${id}`);
// dispatch({
// type: ADD_TO_CART,
// payload: {
// product: productData.product._id,
// name: productData.product.name,
// price: productData.product.price,
// image: productData.product.images[0].url,
// stock: productData.product.Stock,
// quantity,
// },
// });
// localStorage.setItem("cartItems", JSON.stringify(getState().cart.cartItems));
// };
export const addItemsToCart = (id) => async (dispatch, getState) => {
console.log(id)
try {
dispatch({
type: "ADD_TO_CART_REQUIST",
});
const productData = await axios.get(`/api/product/getOne/${id}`);
console.log(productData.data.product)
dispatch({
type: "ADD_TO_CART_SUCCESS",
payload: {
product: productData?.data?.product?._id,
name: productData?.data?.product?.name,
price: productData?.data?.product?.base_Price,
image: productData?.data?.product?.image.url,
// stock: productData.product.Stock,
// quantity,
},
});
localStorage.setItem("cartItems", JSON.stringify(getState().cart.cartItems));
} catch (error) {
console.log(error)
dispatch({
type: "ADD_TO_CART_FAILURE",
payload: error.response.data.message,
});
}
};
// REMOVE FROM CART
export const removeItemsFromCart = (id) => async (dispatch, getState) => {
dispatch({
type: REMOVE_CART_ITEM,
payload: id,
});
localStorage.setItem("cartItems", JSON.stringify(getState().cart.cartItems));
};
// SAVE SHIPPING INFO
// export const saveShippingInfo = (productData) => async (dispatch) => {
// dispatch({
// type: SAVE_SHIPPING_INFO,
// payload: productData,
// });
// localStorage.setItem("shippingInfo", JSON.stringify(productData));
// };

View File

@ -0,0 +1,85 @@
import { createReducer } from "@reduxjs/toolkit";
let initialState = localStorage.getItem("cartItems") ? JSON.parse(localStorage.getItem("cartItems")) : ({
cartItems: [],
subTotal: 0,
shipping: 0,
tax: 0,
total: 0,
})
export const cartReducer = createReducer(
initialState,
{
addToCart: (state, action) => {
const item = action.payload;
const isItemExist = state.cartItems.find((i) => i.id === item.id);
if (isItemExist) {
state.cartItems.forEach((i) => {
if (i.id === item.id) i.quantity += 1;
});
} else {
state.cartItems.push(item);
}
},
decrement: (state, action) => {
const item = state.cartItems.find((i) => i.id === action.payload);
if (item.quantity > 1) {
state.cartItems.forEach((i) => {
if (i.id === item.id) i.quantity -= 1;
});
}
},
deleteFromCart: (state, action) => {
state.cartItems = state.cartItems.filter((i) => i.id !== action.payload);
},
calculatePrice: (state) => {
let sum = 0;
state.cartItems.forEach((i) => (sum += i.price * i.quantity));
state.subTotal = sum;
// state.shipping = state.subTotal > 1000 ? 0 : 200;
// state.tax = +(state.subTotal * 0.18).toFixed();
state.total = state.subTotal
// + state.tax + state.shipping;
},
}
);
let initialInfo = localStorage.getItem("shippingInfo") ? JSON.parse(localStorage.getItem("shippingInfo")) : ({
franchisees: [],
})
export const shipingReducer = createReducer(
initialInfo,
{
addShippingInfo: (state, action) => {
const item = action.payload;
const isItemExist = state.franchisees.find((i) => i.id === item.id);
if (isItemExist) {
// state.cartItems.forEach((i) => {
// if (i.id === item.id) i.quantity += 1;
// });
return;
} else {
state.franchisees.push(item);
}
},
deleteFromshippingInfo: (state, action) => {
state.franchisees = state.franchisees.filter((i) => i.id !== action.payload);
},
}
)

28
src/redux/store.js Normal file
View File

@ -0,0 +1,28 @@
import { configureStore } from "@reduxjs/toolkit"
import { cartReducer, shipingReducer } from "./reducers/cartReducer"
// let initialState = {
// cart: {
// cartItems: localStorage.getItem("cartItems")
// ? JSON.parse(localStorage.getItem("cartItems"))
// : [],
// subTotal: 0,
// shipping: 0,
// tax: 0,
// total: 0,
// // shippingInfo: localStorage.getItem("shippingInfo")
// // ? JSON.parse(localStorage.getItem("shippingInfo"))
// // : {},
// },
// };
export const store = configureStore({
reducer: {
cart: cartReducer,
shipingInfo: shipingReducer
},
// initialState
})

View File

@ -39,7 +39,12 @@ import DispatchedOrders from './views/orders/DispatchedOrders.js'
import DeliveredOrders from './views/orders/DeliveredOrders.js'
import CancelledOrders from './views/orders/CancelledOrders.js'
import ReturnedOrders from './views/orders/ReturnedOrders.js'
import ViewOrder from './views/orders/ViewOrder.js'
import ViewOrder from './views/orders/ViewOrder'
import AddOrder from './views/orders/AddOrder'
//Taxes
import Tax from './views/configuration/tax/Tax'
import Addtax from './views/configuration/tax/Addtax'
import Edittax from './views/configuration/tax/Edittax'
const routes = [
{ path: '/', exact: true, name: 'Home' },
@ -54,13 +59,16 @@ const routes = [
{ path: '/product/edit/:id', name: 'Edit products', element: EditProduct },
{ path: '/product/view/:id', name: 'view products', element: ViewProduct },
//Order Management
{ path: '/orders/new', name: 'New Orders', element: NewOrders },
{ path: '/order/add', name: 'add Order', element: AddOrder },
// { path: '/orders/processing', name: 'Processing Orders', element: ProcessingOrders },
// { path: '/orders/dispatched', name: 'Dispatched Orders', element: DispatchedOrders },
// { path: '/orders/delivered', name: 'Delivered Orders', element: DeliveredOrders },
// { path: '/orders/cancelled', name: 'Cancelled Orders', element: CancelledOrders },
// { path: '/orders/returned', name: 'Returned Orders', element: ReturnedOrders },
// { path: '/orders/:status/:id', name: 'View Order', element: ViewOrder },
{ path: '/order/:status/:id', name: 'View Order', element: ViewOrder },
//Temple
@ -87,6 +95,11 @@ const routes = [
{ path: '/socialmedia', name: 'Social Media', element: Socialmedia },
{ path: '/address', name: 'Address', element: Address },
{ path: '/logo', name: 'Logo', element: Logo },
//Taxes
{ path: '/tax', name: 'Tax Rates', element: Tax },
{ path: '/tax/add', name: 'Add Tax', element: Addtax },
{ path: '/tax/edit/:id', name: 'Edit Tax', element: Edittax },
// -------------------------------------------//

View File

@ -1,20 +1,4 @@
import { createStore } from 'redux'
const initialState = {
sidebarShow: true,
}
const changeState = (state = initialState, { type, ...rest }) => {
switch (type) {
case 'set':
return { ...state, ...rest }
default:
return state
}
}
const store = createStore(changeState)
export default store
// import { configureStore } from "@reduxjs/toolkit";
// import { newCategoryReducer, AllcategoryReducer } from "./reducers/categoryReducer.js";
// import { loginReducer } from "./reducers/directoryReducer.js";

View File

@ -128,7 +128,7 @@ const EditProduct = () => {
axios
.put(`/api//product/update/${id}`, formData, {
.put(`/api/product/update/${id}`, formData, {
headers: {
Authorization: `Bearer ${token}`,
'Content-Type': 'multipart/formdata',

View File

@ -22,6 +22,8 @@ const AddTemple = () => {
city: '',
state_name: '',
short_url: '',
contact_Number: '',
contact_Person_Name: ''
// pan: '',
// business_name: '',
// gstin: '',
@ -102,10 +104,11 @@ const AddTemple = () => {
const handleSubmit = () => {
if (
data.name.trim() === '' ||
// data.pan.trim() === '' ||
// data.business_name.trim() === '' ||
// data.gstin.trim() === '' ||
// data.option.trim() === '' ||
data.contact_Number === '' ||
data.contact_Person_Name === '' ||
data.address_line_1.trim() === '' ||
data.address_line_2.trim() === '' ||
data.city === '' ||
@ -133,6 +136,9 @@ const AddTemple = () => {
formData.set('address_line_2', data.address_line_2)
formData.set('city', data.city)
formData.set('state_name', data.state_name)
formData.set('contact_Number', data.contact_Number)
formData.set('contact_Person_Name', data.contact_Person_Name)
formData.set('url', WebsiteURL + data.short_url + '/login')
formData.set('short_url', data.short_url)
formData.append('image', data.image)
@ -180,7 +186,7 @@ const AddTemple = () => {
"
>
<div style={{ fontSize: '22px' }} className="fw-bold">
Add Temple
Add Franchisee
</div>
<div style={{ display: 'flex', gap: '1rem' }}>
<h4 className="mb-0"></h4>
@ -219,12 +225,12 @@ const AddTemple = () => {
</div>
</div>
<div className="row">
<div className="col-6 my-1">
<div className="col-sm-12 col-md-12 col-lg-6 my-1">
<div className="card h-100">
<div className="card-body px-5">
<div className="mb-3">
<label htmlFor="title" className="form-label">
Temple Name*
Franchisee Name*
</label>
<input
type="text"
@ -236,19 +242,7 @@ const AddTemple = () => {
/>
<p className="pt-1 pl-2 text-secondary">Remaining characters : {limiter.nameHas}</p>
</div>
{/* <div className="mb-3">
<label htmlFor="title" className="form-label">
PAN*
</label>
<input
type="text"
className="form-control"
id="pan"
value={data.pan}
maxLength="50"
onChange={(e) => handleChange(e)}
/>
</div> */}
<div className="mb-3">
<label htmlFor="title" className="form-label">
Address Line 1*
@ -275,32 +269,7 @@ const AddTemple = () => {
onChange={(e) => handleChange(e)}
/>
</div>
{/* <div className="mb-3">
<label htmlFor="title" className="form-label">
Business Name*
</label>
<input
type="text"
className="form-control"
id="business_name"
value={data.business_name}
maxLength="50"
onChange={(e) => handleChange(e)}
/>
</div> */}
{/* <div className="mb-3">
<label htmlFor="title" className="form-label">
GSTIN*
</label>
<input
type="text"
className="form-control"
id="gstin"
value={data.gstin}
maxLength="50"
onChange={(e) => handleChange(e)}
/>
</div> */}
<div className="mb-3">
<label htmlFor="pageToLink" className="form-label">
City*
@ -340,9 +309,34 @@ const AddTemple = () => {
</div>
</div>
</div>
<div className="col-6 my-1">
<div className="col-sm-12 col-md-12 col-lg-6 my-1">
<div className="card h-100">
<div className="card-body px-5">
<div className="mb-3">
<label htmlFor="title" className="form-label">
Contact Number*
</label>
<input
type="number"
className="form-control"
id="contact_Number"
value={data.contact_Number}
onChange={(e) => handleChange(e)}
/>
</div>
<div className="mb-3">
<label htmlFor="title" className="form-label">
Contact Person Name*
</label>
<input
type="text"
className="form-control"
id="contact_Person_Name"
value={data.contact_Person_Name}
onChange={(e) => handleChange(e)}
/>
</div>
<div className="mb-3">
<label htmlFor="title" className="form-label">
URL*
@ -361,21 +355,8 @@ const AddTemple = () => {
/>
</div>
</div>
{/* <div className="mb-3">
<label htmlFor="option" className="form-label">
Option*
</label>
<select
className="form-control"
id="option"
value={data.option}
onChange={(e) => handleChange(e)}
>
<option value="">None</option>
<option value="group">Group</option>
<option value="bundle">Bundle</option>
</select>
</div> */}
<div className="mb-3">
<label htmlFor="image" className="form-label">
Temple Banner*

View File

@ -20,13 +20,15 @@ const EditTemple = () => {
name: '',
address_line_1: '',
address_line_2: '',
contact_Person_Name: '',
contact_Number: '',
city: '',
state_name: '',
short_url: '',
pan: '',
business_name: '',
gstin: '',
option: '',
// pan: '',
// business_name: '',
// gstin: '',
// option: '',
})
const [cities, setCities] = useState([])
const [loading, setLoading] = useState(false)
@ -124,6 +126,8 @@ const EditTemple = () => {
data.name.trim() === '' ||
data.address_line_1.trim() === '' ||
data.address_line_2.trim() === '' ||
data.contact_Number === '' ||
data.contact_Person_Name === '' ||
data.city === '' ||
data.short_url === '' ||
data.state_name === ''
@ -148,6 +152,8 @@ const EditTemple = () => {
formData.set('address_line_2', data.address_line_2)
formData.set('city', data.city)
formData.set('state_name', data.state_name)
formData.set('contact_Number', data.contact_Number)
formData.set('contact_Person_Name', data.contact_Person_Name)
formData.set('url', WebsiteURL + data.short_url + '/login')
formData.set('short_url', data.short_url)
formData.append('image', data.image)
@ -195,7 +201,7 @@ const EditTemple = () => {
"
>
<div style={{ fontSize: '22px' }} className="fw-bold">
Edit Temple
Edit Franchisee
</div>
<div style={{ display: 'flex', gap: '1rem' }}>
<h4 className="mb-0"></h4>
@ -240,7 +246,7 @@ const EditTemple = () => {
<div className="card-body px-5">
<div className="mb-3">
<label htmlFor="title" className="form-label">
Temple Name*
Franchisee Name*
</label>
<input
type="text"
@ -359,6 +365,31 @@ const EditTemple = () => {
<div className="col-6 my-1">
<div className="card h-100">
<div className="card-body px-5">
<div className="mb-3">
<label htmlFor="title" className="form-label">
Contact Number*
</label>
<input
type="number"
className="form-control"
id="contact_Number"
value={data.contact_Number}
onChange={(e) => handleChange(e)}
/>
</div>
<div className="mb-3">
<label htmlFor="title" className="form-label">
Contact Person Name*
</label>
<input
type="text"
className="form-control"
id="contact_Person_Name"
value={data.contact_Person_Name}
onChange={(e) => handleChange(e)}
/>
</div>
<div className="mb-3">
<label htmlFor="title" className="form-label">
URL*

View File

@ -96,7 +96,7 @@ const Temples = () => {
"
>
<div style={{ fontSize: '22px' }} className="fw-bold">
Temples
Franchisees
</div>
<div className="page-title-right">
@ -110,7 +110,7 @@ const Temples = () => {
textTransform: 'capitalize',
}}
>
Add Temple
Add Franchisee
</Button>
</Link>
</div>
@ -154,7 +154,7 @@ const Temples = () => {
>
<thead className="thead-info" style={{ background: 'rgb(140, 213, 213)' }}>
<tr>
<th className="text-start">Temple Name</th>
<th className="text-start">Franchisee Name</th>
<th className="text-start">Logo</th>
<th className="text-start">City </th>
<th className="text-start">Created On</th>

View File

@ -0,0 +1,191 @@
import axios from 'axios'
import React, { useState } from 'react'
import { Link, useNavigate } from 'react-router-dom'
import { isAutheticated } from 'src/auth'
import swal from 'sweetalert'
function Addtax() {
const navigate = useNavigate()
const token = isAutheticated()
const [loading, setLoading] = useState(false)
const [data, setData] = useState({
name: '',
tax: '',
hsn_code: '',
})
const [limiter, setLimiter] = useState({
name: 50,
namehas: 50,
tax: 2,
taxhas: 2,
hsn_code: 10,
hsn_codehas: 10,
})
const handleChange = (e) => {
if ((e.target.name === 'tax' || e.target.name === 'hsn_code') && /^\D+$/.test(e.target.value))
return
setData((prev) => ({ ...prev, [e.target.name]: e.target.value }))
setLimiter((prev) => ({
...prev,
[e.target.name + 'has']: prev[e.target.name] - e.target.value.length,
}))
}
async function handleSubmit() {
if ((data.name.trim() === '' || data.tax.trim() === '', data.hsn_code.trim() === '')) {
return swal('Error', 'All fields are required!', 'error')
}
setLoading(true)
await axios
.post(`/api/tax/add_tax`, data, {
headers: {
Authorization: `Bearer ${token}`,
},
})
.then((res) => {
setLoading(false)
swal('Success', 'Tax added successfully', 'success')
navigate('/tax', { replace: true })
})
.catch((err) => {
// console.log(err)
swal('Error', err.response.data.message ? err.response.data.message : 'Something Went Wrong', 'error')
setLoading(false)
})
}
return (
<div className="main-content">
<div className="page-content">
<div className="container-fluid">
<div className="row">
<div className="col-12">
<div
className="
page-title-box
d-flex
align-items-center
justify-content-between
"
>
<h4 className="mb-0">Add New Tax Rate</h4>
</div>
</div>
</div>
<div className="row my-2">
<div className="col-12">
<div className="form-group text-right">
<button
onClick={() => handleSubmit()}
type="button"
disabled={loading}
className="
btn btn-success btn-login
waves-effect waves-light
me-3
"
>
Save
</button>
<Link to="/tax">
<button
type="button"
className="
btn btn-success btn-cancel
waves-effect waves-light
mr-3
"
>
Cancel
</button>
</Link>
</div>
</div>
</div>
<div className="row">
<div className="col-lg-8">
<div className="card">
<div className="card-body">
<div className="row">
<div className="col-md-12">
<form>
<div className="row">
<div className="col-lg-12">
<div className="form-group">
<label htmlFor="basicpill-phoneno-input" className="label-100">
Name*
</label>
<input
value={data.name}
onChange={(e) => handleChange(e)}
type="text"
name="name"
className="form-control input-field"
maxLength={limiter.name}
/>
<label htmlFor="basicpill-phoneno-input" className="label-100">
Remaining Characters: {limiter.namehas}
</label>
</div>
</div>
</div>
<div className="row mt-2">
<div className="col-lg-12">
<div className="form-group">
<label htmlFor="basicpill-phoneno-input" className="label-100">
HSN Code*
</label>
<input
value={data.hsn_code}
onChange={(e) => handleChange(e)}
type="text"
name="hsn_code"
maxLength={limiter.hsn_code}
className="form-control input-field"
/>
<label htmlFor="basicpill-phoneno-input" className="label-100">
Remaining Characters: {limiter.hsn_codehas}
</label>
</div>
</div>
</div>
<div className="row mt-2">
<div className="col-lg-12">
<div className="form-group">
<label htmlFor="basicpill-phoneno-input" className="label-100">
Tax Rate (in %)*
</label>
<input
value={data.tax}
onChange={(e) => handleChange(e)}
type="text"
name="tax"
maxLength={limiter.tax}
className="form-control input-field"
/>
<label htmlFor="basicpill-phoneno-input" className="label-100">
Remaining Characters: {limiter.taxhas}
</label>
</div>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
)
}
export default Addtax

View File

@ -0,0 +1,208 @@
import axios from 'axios'
import React, { useEffect, useState } from 'react'
import { Link, useParams, useNavigate } from 'react-router-dom'
import { isAutheticated } from 'src/auth'
function Edittax() {
const { id } = useParams()
const token = isAutheticated()
const navigate = useNavigate()
const [loading, setLoading] = useState(false)
const [data, setData] = useState({
name: '',
tax: '',
hsn_code: '',
})
const [limiter, setLimiter] = useState({
name: 50,
namehas: 50,
tax: 2,
taxhas: 2,
hsn_code: 10,
hsn_codehas: 10,
})
useEffect(() => {
function getTax() {
setLoading(true)
axios
.get(`/api/tax/view_tax/${id}`, {
headers: {
Authorization: `Bearer ${token}`,
},
})
.then((res) => {
setLoading(false)
setData((prev) => ({
...prev,
name: res.data?.name,
tax: res.data?.tax?.toString(),
hsn_code: res.data?.hsn_code?.toString(),
}))
setLimiter((prev) => ({
...prev,
namehas: prev.name - res.data?.name.length,
taxhas: prev.tax - res.data?.tax?.toString().length,
hsn_codehas: prev.hsn_code - res.data?.hsn_code.toString()?.length,
}))
})
.catch((res) => {
setLoading(false)
navigate('/tax', { replace: true })
})
}
getTax()
}, [])
const handleChange = (e) => {
if ((e.target.name === 'tax' || e.target.name === 'hsn_code') && /^\D+$/.test(e.target.value))
return
setData((prev) => ({ ...prev, [e.target.name]: e.target.value }))
setLimiter((prev) => ({
...prev,
[e.target.name + 'has']: prev[e.target.name] - e.target.value.length,
}))
}
function handleSubmit() {
if ((data.name.trim() === '' || data.tax.trim() === '', data.hsn_code.trim() === '')) {
return swal('Error', 'All fields are required!', 'error')
}
setLoading(true)
axios
.patch(`/api/tax/update_tax/${id}`, data, {
headers: {
Authorization: `Bearer ${token}`,
},
})
.then((res) => {
setLoading(false)
swal('Success', 'Tax updated successfully', 'success')
navigate('/tax', { replace: true })
})
.catch((err) => {
swal('Error', 'Something went wrong!', 'error')
setLoading(false)
})
}
return (
<div className="main-content">
<div className="page-content">
<div className="container-fluid">
<div className="row mb-2">
<div className="col-12">
<div className="form-group text-right">
<button
type="button"
onClick={() => handleSubmit()}
disabled={loading}
className="
btn btn-success btn-login
waves-effect waves-light
me-3
"
>
Save
</button>
<Link to="/tax">
<button
type="button"
className="
btn btn-success btn-cancel
waves-effect waves-light
mr-3
"
>
Cancel
</button>
</Link>
</div>
</div>
</div>
<div className="row">
<div className="col-lg-8">
<div className="card">
<div className="card-body">
<div className="row">
<div className="col-md-12">
<form>
<div className="row">
<div className="col-lg-12">
<div className="form-group">
<label htmlFor="basicpill-phoneno-input" className="label-100">
Name*
</label>
<input
value={data.name}
onChange={(e) => handleChange(e)}
type="text"
name="name"
className="form-control input-field"
maxLength={limiter.name}
/>
<label htmlFor="basicpill-phoneno-input" className="label-100">
Remaining Characters: {limiter.namehas}
</label>
</div>
</div>
</div>
<div className="row mt-2">
<div className="col-lg-12">
<div className="form-group">
<label htmlFor="basicpill-phoneno-input" className="label-100">
HSN Code*
</label>
<input
value={data.hsn_code}
onChange={(e) => handleChange(e)}
type="text"
name="hsn_code"
maxLength={limiter.hsn_code}
className="form-control input-field"
/>
<label htmlFor="basicpill-phoneno-input" className="label-100">
Remaining Characters: {limiter.hsn_codehas}
</label>
</div>
</div>
</div>
<div className="row mt-2">
<div className="col-lg-12">
<div className="form-group">
<label htmlFor="basicpill-phoneno-input" className="label-100">
Tax Rate (in %)*
</label>
<input
value={data.tax}
onChange={(e) => handleChange(e)}
type="text"
name="tax"
maxLength={limiter.tax}
className="form-control input-field"
/>
<label htmlFor="basicpill-phoneno-input" className="label-100">
Remaining Characters: {limiter.taxhas}
</label>
</div>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
)
}
export default Edittax

View File

@ -0,0 +1,217 @@
import axios from 'axios'
import React, { useEffect, useState } from 'react'
import { isAutheticated } from 'src/auth'
import { Link } from 'react-router-dom'
import swal from 'sweetalert'
function Tax() {
const [taxList, settaxList] = useState([])
const [success, setSuccess] = useState(true)
const [loading, setLoading] = useState(true)
const token = isAutheticated()
useEffect(() => {
function getTaxes() {
setLoading(true)
axios
.get(`/api/tax/view_tax`, {
headers: {
Authorization: `Bearer ${token}`,
},
})
.then((res) => {
setLoading(false)
settaxList(res.data)
})
.catch((err) => setLoading(false))
}
getTaxes()
}, [success])
function handleDelete(id) {
axios
.delete(`/api/tax/delete_tax/${id}`, {
headers: {
Authorization: `Bearer ${token}`,
},
})
.then((res) => setSuccess((prev) => !prev))
.catch((err) => swal('Error!', 'Something went wrong!', 'error'))
}
return (
<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 ml-0 mr-0 mb-10">
<div className="col-sm-12 col-md-6"></div>
<div className="col-sm-12 col-md-6 text-end">
<div className="dropdown d-block">
<Link to="/tax/add">
<button
type="button"
className="
btn btn-primary
add-btn
waves-effect waves-light
float-right
"
>
<i className="fa fa-plus mb-2" aria-hidden="true"></i> Add New Tax Rate
</button>
</Link>
</div>
</div>
</div>
<div className="table-responsive table-shoot mt-2">
<table className="table table-centered table-nowrap mb-0">
<thead className="thead" style={{ background: 'rgb(140, 213, 213)' }}>
<tr>
<th>Name</th>
<th>Tax Rate</th>
<th>Action</th>
</tr>
</thead>
<tbody>
{loading && (
<tr>
<td colSpan="6" className="text-center">
Loading...
</td>
</tr>
)}
{taxList.map((tax, index) => {
return (
<tr key={index}>
<td>{tax.name}</td>
<td>{tax.tax}%</td>
<td>
<Link to={`/tax/edit/${tax._id}`}>
<button
type="button"
className="btn btn-primary btn-sm waves-effect waves-light btn-table me-2"
>
Edit
</button>
</Link>
<button
type="button"
className=" btn btn-danger btn-sm
waves-effect waves-light
btn-table
ml-2
"
onClick={() => handleDelete(tax._id)}
id="sa-params"
>
Delete
</button>
</td>
</tr>
)
})}
</tbody>
</table>
</div>
{/* <div className="row mt-20">
<div className="col-sm-12 col-md-6 mb-20">
<div
className="dataTables_info"
id="datatable_info"
role="status"
aria-live="polite"
>
Showing 1 to 10 of 57 entries
</div>
</div>
<div className="col-sm-12 col-md-6">
<div
className="
dataTables_paginate
paging_simple_numbers
float-right
"
>
<ul className="pagination">
<li
className="
paginate_button
page-item
previous
disabled
"
>
<a
href="#"
aria-controls="datatable"
data-dt-idx="0"
tabindex="0"
className="page-link"
>
Previous
</a>
</li>
<li className="paginate_button page-item active">
<a
href="#"
aria-controls="datatable"
data-dt-idx="1"
tabindex="0"
className="page-link"
>
1
</a>
</li>
<li className="paginate_button page-item">
<a
href="#"
aria-controls="datatable"
data-dt-idx="2"
tabindex="0"
className="page-link"
>
2
</a>
</li>
<li className="paginate_button page-item">
<a
href="#"
aria-controls="datatable"
data-dt-idx="3"
tabindex="0"
className="page-link"
>
3
</a>
</li>
<li className="paginate_button page-item next">
<a href="#" tabindex="0" className="page-link">
Next
</a>
</li>
</ul>
</div>
</div>
</div> */}
</div>
</div>
</div>
</div>
</div>
</div>
</div>
)
}
export default Tax

View File

@ -0,0 +1,815 @@
import React, { useState, useEffect, useRef } from 'react'
import axios from 'axios'
import { Link, useNavigate, useParams } from 'react-router-dom'
import QRCode from 'react-qr-code'
import { isAutheticated } from 'src/auth'
import { useDispatch, useSelector } from 'react-redux'
import { addItemsToCart } from 'src/redux/Actions/cartAction'
import toast from 'react-hot-toast'
import { cibBlackberry } from '@coreui/icons'
import Button from '@material-ui/core/Button'
// import PrintOrderDetails from './PrintOrderDetails.js'
function AddOrder() {
const { status, id } = useParams()
const { cartItems, subTotal, tax, shipping, total } = useSelector(
(state) => state.cart
);
// const { cart, shippingInfo } = useSelector(
// (state) => state
// );
const AllStates = useSelector(
(state) => state
);
console.log(AllStates.shipingInfo.franchisees)
const getValue = useRef()
const getFranchiseeID = useRef()
const dispatch = useDispatch();
const navigate = useNavigate()
const printOrderRef = useRef()
const token = isAutheticated()
const [productData, setProductData] = useState([])
const [allFranchisee, setAllFranchisee] = useState([])
const [productDetails, setProductDetails] = useState()
const [loading, setLoading] = useState(true)
const [orderStatus, setOrderStatus] = useState('')
const [data, setData] = useState({
product_Name: '',
address: '',
quantity: '',
contact_Number: '',
total_Price: '',
})
useEffect(() => {
function getProductDetails() {
setLoading(true)
axios
.get(`/api/product/getAll/`, {
headers: { 'Access-Control-Allow-Origin': '*', Authorization: `Bearer ${token}` },
})
.then((res) => {
setLoading(false)
// console.log(res.data.product)
setProductData(res.data.product)
})
.catch((err) => {
setLoading(false)
// getBack()
})
}
function getFranchiseeDetails() {
setLoading(true)
axios
.get(`/api/temple`, {
headers: { 'Access-Control-Allow-Origin': '*', Authorization: `Bearer ${token}` },
})
.then((res) => {
setLoading(false)
// console.log(res.data.product)
setAllFranchisee(res.data.data)
})
.catch((err) => {
setLoading(false)
// getBack()
})
}
getProductDetails()
getFranchiseeDetails()
}, [])
const handleChange = (e) => {
if (e.target.type === 'text') {
setData((prev) => ({ ...prev, [e.target.id]: e.target.value }))
} else {
setOrderStatus(e.target.value)
}
}
const handleQuantityChange = (e) => {
setData((prev) => ({
...prev,
quantity: e.target.value,
total_Price: (productDetails?.base_Price * e.target.value)
}))
}
// ------------------------product handle------------------------------//
const handleGetSingleProduct = async (e) => {
axios
.get(`/api/product/getOne/${getValue.current.value}`, {
headers: { 'Access-Control-Allow-Origin': '*', Authorization: `Bearer ${token}` },
})
.then((res) => {
setLoading(false)
let options = {
name: res?.data?.product?.name,
price: res?.data?.product?.base_Price,
id: res?.data?.product?._id,
quantity: 1,
image: res?.data?.product?.image?.url
}
dispatch({ type: "addToCart", payload: options });
dispatch({ type: "calculatePrice" });
localStorage.setItem("cartItems", JSON.stringify(AllStates.cart));
toast.success("Product Added");
})
.catch((err) => {
setLoading(false)
})
}
const handleRemove = (id) => {
dispatch({
type: "deleteFromCart",
payload: id,
});
dispatch({ type: "calculatePrice" });
localStorage.setItem("cartItems", JSON.stringify(AllStates.cart));
toast.success("Item Removed");
};
//increase qty
const increaseQuantity = (id) => {
dispatch({
type: "addToCart",
payload: { id },
});
dispatch({ type: "calculatePrice" });
localStorage.setItem("cartItems", JSON.stringify(AllStates.cart));
}
const decreaseQuantity = (id) => {
dispatch({
type: "decrement",
payload: id,
});
dispatch({ type: "calculatePrice" });
localStorage.setItem("cartItems", JSON.stringify(AllStates.cart));
};
// ------------------------product handle End------------------------------//
// ------------------------Frenchisee handle------------------------------//
const handleGetSingleFrenchisee = async () => {
axios
.get(`/api/Temple/arrayspopulate/${getFranchiseeID.current.value}`, {
headers: {
'Access-Control-Allow-Origin': '*',
Authorization: `Bearer ${token}`,
},
})
.then((res) => {
setLoading(false)
console.log(res.data.data)
let options = {
id: res?.data?.data?._id,
name: res?.data?.data?.name,
contact_Number: res?.data?.data?.contact_Number,
contact_Person_Name: res?.data?.data?.contact_Person_Name,
address: (res?.data?.data?.address_line_1 + ' ' + res?.data?.data?.address_line_2),
city: res?.data?.data?.city?.city_name,
state: res?.data?.data?.city?.state?.state_name,
banner: res?.data?.data?.banner?.url,
Franchisee_Url: res?.data?.data?.url
}
dispatch({ type: "addShippingInfo", payload: options });
localStorage.setItem("shippingInfo", JSON.stringify(AllStates.shipingInfo));
toast.success("Franchisee Added");
})
.catch((err) => {
setLoading(false)
})
}
const FranchiseeRemove = (id) => {
dispatch({
type: "deleteFromshippingInfo",
payload: id,
});
localStorage.setItem("shippingInfo", JSON.stringify(AllStates.shipingInfo));
toast.success("Franchisee Removed");
};
// ------------------------Frenchisee handle End------------------------------//
console.log(AllStates.shipingInfo.franchisees.length)
console.log(cartItems)
function handleSubmit() {
if (
AllStates.shipingInfo.franchisees.length < 1) {
swal({
title: 'Warning',
text: 'Please select Franchisee ',
icon: 'error',
button: 'Close',
dangerMode: true,
})
return
}
else if (cartItems.length < 1) {
swal({
title: 'Warning',
text: 'Please select atleast one product',
icon: 'error',
button: 'Close',
dangerMode: true,
})
return
} else if (
shipping === '' ||
tax === '' ||
total === ''
) {
swal({
title: 'Warning',
text: 'Fill all mandatory fields',
icon: 'error',
button: 'Close',
dangerMode: true,
})
return
}
setLoading(true)
// const formData = new FormData()
// formData.set('orderItems', cartItems)
// formData.set('shippingInfo', AllStates.shipingInfo.franchisees)
// formData.set('shipping_charge', shipping)
// formData.set('tax_amount', tax)
// formData.set('total_amount', total)
setLoading(true)
axios
.post(
`/api/order/create`,
{
orderItems: cartItems,
shippingInfo: AllStates.shipingInfo.franchisees,
shipping_charge: shipping,
tax_amount: tax,
total_amount: total
},
{
headers: {
'Access-Control-Allow-Origin': '*',
Authorization: `Bearer ${token}`,
},
},
)
.then((res) => {
console.log(res)
swal({
title: 'Created',
text: 'Order Created!',
icon: 'success',
button: 'ok',
})
setLoading(false)
navigate('/orders/new')
})
.catch((err) => {
setLoading(false)
swal({
title: 'Warning',
text: 'Something went wrong!',
icon: 'error',
button: 'Retry',
dangerMode: true,
})
})
}
function getBack() {
navigate(`/orders/${status}`, { replace: true })
}
return (
<>
{' '}
<div className="main-content">
<div className="page-content">
<div className="container-fluid">
<div className="row">
<div className="col-12">
<div
className="
page-title-box
d-flex
align-items-center
justify-content-between
"
>
<div style={{ fontSize: '22px' }} className="fw-bold">
Add Order
</div>
<div className="page-title-right">
<Button
variant="contained"
color="primary"
style={{
fontWeight: 'bold',
marginBottom: '1rem',
textTransform: 'capitalize',
marginRight: '5px',
}}
onClick={() => handleSubmit()}
disabled={loading}
>
{loading ? 'Loading' : 'Order Now'}
</Button>
<Link to="/orders/new">
<Button
variant="contained"
color="secondary"
style={{
fontWeight: 'bold',
marginBottom: '1rem',
textTransform: 'capitalize',
}}
>
Back
</Button>
</Link>
</div>
</div>
</div>
</div>
<div className="row">
<div className="col-lg-7 mt-3">
<div className="card">
<div className="card-body">
<div className="mt-1">
<label className="fw-bold">Select Product:</label>
<div className="d-flex">
<select
className="form-control me-2"
// onChange={handleGetSingleProduct}
// value={productData?._id}
ref={getValue}
>
<option value="" >-----</option>
{productData && productData.map((item, index) =>
<option key={index} value={item?._id}>{item?.name}</option>
)}
</select>
<button className='btn-sm btn-primary' onClick={(e) => handleGetSingleProduct(e)}>Add</button>
</div>
</div>
<div className="mt-2">
<label className="fw-bold">Product :</label>
{
cartItems && cartItems.map((productDetails, i) =>
<div className="my-2">
<div className="row" style={{ fontSize: '14px' }}>
<div className="col-sm-4">
<img
src={productDetails?.image}
alt={productDetails?.name}
style={{
width: '100%',
objectFit: 'contain',
maxHeight: '150px',
}}
/>
</div>
<div className="col-sm-8">
<h6 className="m-0 ms-2">{productDetails?.name}</h6>
<div className="row">
<div className="col-sm-6">
<div
className='d-flex justify-content-center mt-3 me-3 '
style={{
width: "6rem",
}}>
<button className='btn btn-sm btn-primary ' onClick={() => decreaseQuantity(productDetails?.id)} >-</button>
<span className='px-2 mt-1' style={{}}>{productDetails?.quantity}</span>
<button className='btn btn-sm btn-primary' onClick={() => increaseQuantity(productDetails?.id)}>+</button>
</div>
<button className='btn btn-danger btn-sm ms-2 mt-3' onClick={() => handleRemove(productDetails?.id)} >Delete</button>
</div>
<div className="col-sm-6">
<h6 className="m-0 mt-3">
<stong> Price:</stong> {productDetails?.price}
</h6>
{' '}
</div>
</div>
</div>
</div>
<hr />
</div>
)
}
{subTotal && <h5 className="m-0 contents-center mt-3">
<span> Total Order Value:</span> {subTotal}
</h5>}
</div>
</div>
</div>
</div>
<div className="col-lg-5 mt-3">
<div className="card">
<div className="card-body">
<div className="mt-1">
<label className="fw-bold">Franchisee :</label>
<div className="d-flex">
<select
className="form-control me-2"
onChange={handleChange}
value={orderStatus}
ref={getFranchiseeID}
>
<option value="" disabled></option>
{allFranchisee && allFranchisee.map((item, index) =>
<option key={index} value={item?._id}>{item?.name}</option>
)}
</select>
<button className='btn-sm btn-primary' onClick={(e) => handleGetSingleFrenchisee(e)} >Add</button>
</div>
</div>
{
AllStates.shipingInfo.franchisees && AllStates.shipingInfo.franchisees.map((franchiDetails, i) =>
<div className="my-2">
<div className="row" style={{ fontSize: '14px' }}>
<div className="col-sm-4">
<img
src={franchiDetails?.banner}
alt={franchiDetails?.name}
width='100%'
// style={{
// width: '100%',
// objectFit: 'contain',
// maxHeight: '100px',
// }}
/>
</div>
<div className="col-sm-8">
<h6 className="m-0 ms-2">{franchiDetails?.name}</h6>
<parent className="m-0 ms-2 mt-3">
Address. : {franchiDetails?.address}
</parent>
<p className="m-0 ms-2 mt-1">
Contact No. : {franchiDetails?.contact_Number}
</p>
<p className="m-0 ms-2 mt-1">
contact Person Name. : {franchiDetails?.contact_Person_Name}
</p>
<button className='btn btn-danger btn-sm ms-2 mt-2' onClick={() => FranchiseeRemove(franchiDetails?.id)} >Delete</button>
</div>
</div>
<hr />
</div>
)
}
{/* <div className="mt-1">
<label className="fw-bold">Address :</label>
</div>
<div className="mt-1">
<label className="fw-bold">Contact Number :</label>
</div> */}
{/* <div className="mt-3">
<label>
<span className="fw-bold">Order ID: {productData?.order_id}</span>
</label>
</div> */}
{/* <div className="mt-3">
{productData?.order_id && (
<div className="d-flex">
<p className="fw-bold me-3">Order ID QR Code:</p>
<QRCode
value={JSON.stringify({ order_id: productData?.order_id })}
size={256}
style={{ height: '150px', width: '150px' }}
/>
</div>
)}
</div> */}
{/* {productData.status === 'processing' && (
<>
<div className="mt-3">
<label className="fw-bold">Courier Name* :</label>
<input
type="text"
className="form-control"
id="courier_name"
value={data.courier_name}
onChange={handleChange}
/>
</div>
<div className="mt-3">
<label className="fw-bold">Tracking ID* :</label>
<input
type="text"
className="form-control"
id="tracking_id"
value={data.tracking_id}
onChange={handleChange}
/>
</div>
</>
)} */}
{/* <div className="mt-3">
<label>
<span className="fw-bold">Amount Paid : </span>Rs.{productData?.total_amount}
</label>
</div> */}
{/* {productData?.address && (
<>
<div className="mt-1">
<label>
<span className="fw-bold">Address : </span>
{`${productData.address?.full_name}, ${productData.address?.flat_house_no_apartment
}, ${productData.address?.area_street_sector_village}, ${productData.address?.landmark && productData.address?.landmark + ', '
}${productData.address?.address_line &&
productData.address?.address_line + ', '
}${productData.address?.city}, ${productData.address?.state}, ${productData.address?.pincode
}`}
</label>
</div>
<div className="mt-1">
<label>
{' '}
<span className="fw-bold">Contact Number : </span>
{productData.address?.mobile_number}
</label>
</div>
</>
)} */}
{/* {productData?.courier_name && (
<div className="mt-1">
<label>
<span className="fw-bold">Courier Name : </span>
{productData?.courier_name}
</label>
</div>
)}
{productData?.tracking_id && (
<div className="mt-1">
<label>
<span className="fw-bold">Tracking ID : </span>
{productData?.tracking_id}
</label>
</div>
)} */}
{/* <div className="mt-1">
<label>
<span className="fw-bold">Order Placed On : </span>
{new Date(productData?.placed_on).toLocaleString('en-IN', {
month: 'short',
day: 'numeric',
year: 'numeric',
hour: '2-digit',
minute: 'numeric',
hour12: true,
})}
</label>
</div> */}
<div className="mt-1">
<label>
<span className="fw-bold">Razorpay Order ID : </span>
{productData?.razorpay_order_id}
</label>
</div>{' '}
<div className="mt-1">
<label>
<span className="fw-bold">Razorpay Payment ID : </span>
{productData?.razorpay_payment_id}
</label>
</div>
</div>
</div>
<div className="card my-1">
<div className="card-body">
<label className="fw-bold">Status Timeline :</label>
<table
className="table table-info table-sm m-0"
style={{
borderRadius: '8px',
borderCollapse: 'collapse',
overflow: 'hidden',
}}
>
<tbody>
<tr className="text-center">
<th scope="row">Order Placed On</th>
<td> : </td>
<td>
{productData?.status_timeline?.new
? new Date(productData?.status_timeline?.new).toLocaleString('en-IN', {
month: 'short',
day: 'numeric',
year: 'numeric',
hour: '2-digit',
minute: 'numeric',
hour12: true,
})
: new Date(productData?.placed_on).toLocaleString('en-IN', {
month: 'short',
day: 'numeric',
year: 'numeric',
hour: '2-digit',
minute: 'numeric',
hour12: true,
})}
</td>
</tr>
<tr className="text-center">
<th scope="row">Processing Started</th>
<td> : </td>
<td>
{productData?.status_timeline?.processing
? new Date(productData?.status_timeline?.processing).toLocaleString(
'en-IN',
{
month: 'short',
day: 'numeric',
year: 'numeric',
hour: '2-digit',
minute: 'numeric',
hour12: true,
},
)
: '-'}
</td>
</tr>
<tr className="text-center">
<th scope="row">Dispatched On</th>
<td> : </td>
<td>
{productData?.status_timeline?.dispatched
? new Date(productData?.status_timeline?.dispatched).toLocaleString(
'en-IN',
{
month: 'short',
day: 'numeric',
year: 'numeric',
hour: '2-digit',
minute: 'numeric',
hour12: true,
},
)
: '-'}
</td>
</tr>
<tr className="text-center">
<th scope="row">Delivered On</th>
<td> : </td>
<td>
{productData?.status_timeline?.delivered
? new Date(productData?.status_timeline?.delivered).toLocaleString(
'en-IN',
{
month: 'short',
day: 'numeric',
year: 'numeric',
hour: '2-digit',
minute: 'numeric',
hour12: true,
},
)
: '-'}
</td>
</tr>
<tr className="text-center">
<th scope="row">Cancelled On</th>
<td> : </td>
<td>
{productData?.status_timeline?.cancelled
? new Date(productData?.status_timeline?.cancelled).toLocaleString(
'en-IN',
{
month: 'short',
day: 'numeric',
year: 'numeric',
hour: '2-digit',
minute: 'numeric',
hour12: true,
},
)
: '-'}
</td>
</tr>
<tr className="text-center">
<th scope="row">Returned On</th>
<td> : </td>
<td>
{productData?.status_timeline?.returned
? new Date(productData?.status_timeline?.returned).toLocaleString(
'en-IN',
{
month: 'short',
day: 'numeric',
year: 'numeric',
hour: '2-digit',
minute: 'numeric',
hour12: true,
},
)
: '-'}
</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div style={{ display: 'none' }}>
{/* <PrintOrderDetails productData={productData} ref={printOrderRef} /> */}
</div>
</>
)
}
export default AddOrder

View File

@ -3,6 +3,7 @@ import { Link } from 'react-router-dom'
import axios from 'axios'
import { isAutheticated } from 'src/auth'
import Button from '@material-ui/core/Button'
function NewOrders() {
const token = isAutheticated()
@ -22,11 +23,12 @@ function NewOrders() {
useEffect(() => {
function getNewOrder() {
axios
.get(`/api/order/list/new`, {
.get(`/api/order/getAll`, {
headers: { 'Access-Control-Allow-Origin': '*', Authorization: `Bearer ${token}` },
})
.then((res) => {
setNewOrdersData(res.data.data)
setNewOrdersData(res.data.order)
console.log(res.data.order)
setLoading(false)
})
.catch((err) => {
@ -63,6 +65,23 @@ function NewOrders() {
<div style={{ fontSize: '22px' }} className="fw-bold">
New Orders
</div>
<div className="page-title-right">
<Link to="/order/add">
<Button
variant="contained"
color="primary"
style={{
fontWeight: 'bold',
marginBottom: '1rem',
textTransform: 'capitalize',
}}
>
Add Order
</Button>
</Link>
</div>
</div>
</div>
</div>
@ -107,7 +126,7 @@ function NewOrders() {
<th className="text-start">Order ID</th>
<th className="text-start">Franchisee</th>
<th className="text-start">Order value</th>
{/* <th className="text-start">Placed On</th> */}
<th className="text-start">Order At</th>
<th className="text-start">Status</th>
<th className="text-start">Actions</th>
</tr>
@ -130,11 +149,11 @@ function NewOrders() {
showData.map((order, i) => {
return (
<tr key={i}>
<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">{order?.order_id}</td>
<td className="text-start">{order?.user?.name}</td>
<td className="text-start">{order?.total_amount}</td>
<td className="text-start">
{new Date(order?.placed_on).toLocaleString('en-IN', {
{new Date(order?.createdAt).toLocaleString('en-IN', {
month: 'short',
day: 'numeric',
year: 'numeric',
@ -145,11 +164,11 @@ function NewOrders() {
</td>
<td className="text-start">
<span className="badge text-bg-success text-white">
{order?.status}
{order?.orderStatus}
</span>
</td>
<td className="text-start">
<Link to={`/orders/${order.status}/${order._id}`}>
<Link to={`/orders/${order.orderStatus}/${order._id}`}>
<button
style={{ color: 'white' }}
type="button"