import {
useEffect,
useState,
Fragment
// useReducer
} from 'react';
import BorderColorIcon from '@mui/icons-material/BorderColor';
import {
// Navigate,
// useSearchParams,
useLocation,
useNavigate
} from 'react-router-dom';
import axios from 'axios';
import ArrowBackIcon from '@mui/icons-material/ArrowBack';
import {
// UserOutlined,
EnvironmentOutlined,
EditTwoTone
// DeleteTwoTone
} from '@ant-design/icons';
// import WomanIcon from '@mui/icons-material/Woman';
// import { Link } from 'react-router-dom';
// import SoupKitchenIcon from '@mui/icons-material/SoupKitchen';
import DirectionsCarIcon from '@mui/icons-material/DirectionsCar';
import { KeyboardArrowUp, KeyboardArrowDown } from '@mui/icons-material';
// import { PopupTransition } from 'components/@extended/Transitions';
// import { useDispatch } from 'react-redux';
// import { openSnackbar } from 'store/reducers/snackbar';
// assets
import { DeleteFilled, NotificationOutlined } from '@ant-design/icons';
var utc = require('dayjs/plugin/utc');
// import { groupBy } from "core-js/actual/array/group-by";
// import "lodash.chunk";
// var chunk = require('lodash.chunk');
import {
Grid,
Typography,
Stack,
Button as Button1,
// Box,
FormControl,
Table,
TableHead,
TableRow,
TableCell,
TableContainer,
TableBody,
Chip,
Divider,
CardActions,
IconButton,
Avatar,
Dialog,
DialogTitle,
DialogContent,
Checkbox,
Tooltip,
Button,
Tab,
Tabs,
Skeleton,
// DialogContent,
DialogActions,
TextField,
CircularProgress,
Collapse,
Alert,
AlertTitle,
Link
// Card,
// CardHeader
} from '@mui/material';
import { PopupTransition } from 'components/@extended/Transitions';
// import ControlPointIcon from '@mui/icons-material/ControlPoint';
import CancelOutlinedIcon from '@mui/icons-material/CancelOutlined';
import MainCard from 'components/MainCard';
import Loader from 'components/Loader';
// import AlertCustomerDelete from 'sections/apps/customer/AlertCustomerDelete';
import dayjs from 'dayjs';
dayjs.extend(utc);
// import { Link as RouterLink } from 'react-router-dom';
// import PlayCircleFilled from '@mui/icons-material/PlayCircleFilled';
// import SmileFilled from '@mui/icons-material/Mood';
// import HeartFilled from '@mui/icons-material/Favorite';
import { useTheme } from '@mui/material/styles';
import useMediaQuery from '@mui/material/useMediaQuery';
import { MobileCard, MobileCardList, MobileField, MobileFieldGrid } from 'components/nearle_components/MobileCard';
import {
CloseOutlined,
WarningOutlined,
WarningFilled
// PlusOutlined,
// EyeTwoTone,
// EditTwoTone,
// DeleteTwoTone
} from '@ant-design/icons';
import { enqueueSnackbar } from 'notistack';
const Details = () => {
// const [searchParams] = useSearchParams();
const [orderarr, setOrderarr] = useState([]);
const [loading, setLoading] = useState(true);
const location = useLocation();
const [orderid, setOrderid] = useState('');
const [eventlocation, setEventlocation] = useState('');
const [orderdate, setOrderdate] = useState('');
const [eventname, setEventname] = useState('');
const [open, setOpen] = useState(false);
const [clientname, setClientname] = useState('');
// const [duedate, setDuedate] = useState('');
const [tenantaddress, setTenantaddress] = useState('');
const [dialogopen, setDialogopen] = useState(false);
const [orderstatus, setOrderstatus] = useState('');
const [currentrole] = useState('');
const [taxamount, setTaxamount] = useState('');
const [subtotal, setSubtotal] = useState('');
const [grandtotal, setGrandtotal] = useState('');
const [venuetype, setVenuetype] = useState('');
const [orderaddons, setOrderaddons] = useState([]);
const [otherinstructions, setOtherinstructions] = useState('');
const [cancelleddate, setCancelleddate] = useState('');
const [stafflist, setStafflist] = useState([]);
const [staffarr, setStaffarr] = useState([]);
const [orderheaderid, setOrderheaderid] = useState('');
const [tenantid, setTenantid] = useState('');
const [starttime] = useState('');
const [endtime] = useState('');
// const [orderstatus,setOrderstatus]=useStatus('');
const [pendingtime, setPendingtime] = useState('');
// const [processdate,setProcessdate]=useState('');
const [categoryarr, setcategoryarr] = useState([]);
const [currentshiftobj, setCurrentshiftobj] = useState({
shifts: 0,
assigned: 0,
remaining: 0,
shiftid: 0,
price: 0
});
const [tabstatus, setTabstatus] = useState(0);
const { state } = useLocation();
const [assignedpendingcount, setAssignedpendingcount] = useState('');
// const [, forceUpdate] = useReducer(x => x + 1, 0);
// const dispatch = useDispatch();
const navigate = useNavigate();
const [expandopen, setExpandopen] = useState(['', '']);
const [startdate, setStartdate] = useState('');
const [invoiceeligible, setInvoiceeligible] = useState(false);
useEffect(() => {
console.log('categoryarr');
console.log(orderarr, eventlocation, venuetype, starttime, endtime);
// forceUpdate();
}, [categoryarr]);
// const navigate = useNavigate();
useEffect(() => {
if (state) {
setOrderheaderid(state.orderheaderid);
setTenantid(state.tenantid);
}
console.log(state);
// fetchroleslist(1)
console.log(Date.now());
}, []);
useEffect(() => {
if (state) {
setOrderheaderid(state.orderheaderid);
setTenantid(state.tenantid);
}
console.log(state);
// fetchroleslist(1)
console.log(Date.now());
}, [state.orderheaderid, state.tenantid]);
const theme = useTheme();
const isMobile = useMediaQuery(theme.breakpoints.down('md'));
// const fetchorderdetails = async () => {
// setLoading(true);
// await axios
// .get(`${process.env.REACT_APP_URL}/orders/orderbyid/?orderheaderid=${orderheaderid}`)
// .then((res) => {
// console.log(res);
// setLoading(false);
// })
// .catch((err) => {
// console.log(err);
// setLoading(false);
// });
// };
const fetchorderaddons = async () => {
setLoading(true);
await axios
.get(`${process.env.REACT_APP_URL2}/orders/getordersbystatus?tenantid=${tenantid}`)
.then((res) => {
console.log(res);
let result = res.data.Details.find((res1) => res1.orderheaderid == orderheaderid);
// orderheaderid
console.log('result');
console.log(result);
setOrderaddons(result.orderaddons);
setVenuetype(result.venuetype);
setOtherinstructions(result.remarks);
setStartdate(result.startdate);
setClientname(result.tenantname);
setEventlocation('');
setTenantaddress(result.tenantaddress);
setEventname(result.eventname);
setOrderdate(dayjs(result.orderdate).format('MM/DD/YYYY') || '');
setOrderid(result.orderid);
setOrderstatus(result.orderstatus);
setTaxamount(result.taxamount);
setSubtotal(result.orderamount);
setGrandtotal(result.ordervalue);
setCancelleddate(dayjs(result.cancelled).format('MM/DD/YYYY') || '');
// if (result.orderstatus === 'pending') {
setPendingtime(result.pending);
// }
setLoading(false);
})
.catch((err) => {
console.log(err);
setLoading(false);
});
};
const fetchorderattires = async () => {
setLoading(true);
await axios
.get(`${process.env.REACT_APP_URL2}/orders/getorderdetails?orderheaderid=${orderheaderid}`)
.then((res) => {
console.log('res');
console.log(res);
setOrderarr(res.data.Details || []);
// let result = res.data.Details.find((res1) => res1.orderheaderid == searchParams.get('id'))
// orderheaderid
// console.log(result)
// setOrderaddons(result.orderaddons);
// setVenuetype(result.venuetype)
// setOtherinstructions(result.remarks)
// console.log("res");
// let result = _.chain(res.data.Details)
// .groupBy("shiftid")
// .map((value, key) => ({shiftid:key, locationaddress: value[0].locationaddress, roles: value }))
// .value()
// setcategoryarr(result);
console.log('categoryarr');
setcategoryarr(res.data.Details);
console.log(res.data.Details);
setLoading(false);
})
.catch((err) => {
console.log(err);
setLoading(false);
});
};
const fetchstafflist = async (odid) => {
setLoading(true);
try {
// await axios.get(`${process.env.REACT_APP_URL}/orders/orderanalytics?orderdate=${chosendate}`)
await axios
.get(`${process.env.REACT_APP_URL2}/orders/getassignedinfo?orderdetailid=${odid}`)
.then((res) => {
console.log(res);
if (res.data.status) {
setStafflist(res.data.Details);
}
setLoading(false);
})
.catch((err) => {
console.log(err);
setLoading(false);
});
} catch (err) {
console.log(err);
setLoading(false);
}
};
const cancelorder = async () => {
await axios
.put(`${process.env.REACT_APP_URL2}/orders/cancel`, {
// "Orderheaderid": parseInt(orderheaderid),
// "Tenantid": parseInt(tenantid),
// "Orderstatus": "cancelled",
// "Currentdatetime": dayjs().format('YYYY-MM-DD HH:mm:ss'),
// "Cod": false,
// "Remarks": "",
orderheaderid: parseInt(orderheaderid),
// "orderdetailid":78,
// "shiftid":788,
orderstatus: 'cancelled',
cancelled: dayjs().format('YYYY-MM-DD HH:mm:ss'),
unserviceable: invoiceeligible ? 0 : 1
})
.then((res) => {
console.log(res);
if (res.data.status) {
if (orderheaderid && tenantid) {
// fetchorderdetails();
fetchorderaddons();
fetchorderattires();
}
}
})
.catch((err) => {
console.log(err);
});
};
const unassign = async (val) => {
let obj = {
orderheaderid: orderheaderid,
orderprocessid: val.orderprocessid,
orderdetailid: val.orderdetailid,
orderstatus: 'pending',
pending: dayjs().format('YYYY-MM-DD HH:mm:ss'),
// processing:0,
// cancelled:0,
// completed:0,
// accepted:0,
status: 1
};
console.log(obj);
await axios
.put(`${process.env.REACT_APP_URL2}/orders/updateprocessstatus`, obj)
.then((res) => {
console.log(res);
if (res.data.message === 'Successful') {
// if (orderheaderid && tenantid) {
enqueueSnackbar('Role unassigned successfully', {
variant: 'success',
anchorOrigin: { vertical: 'top', horizontal: 'right' },
autoHideDuration: 2000
});
if (currentshiftobj.assigned > currentshiftobj.shifts) {
sendunassignnotification(val);
}
fetchorderaddons();
fetchorderattires();
setOpen(false);
fetchassignedcount();
dialogclose();
setTimeout(() => {
fetchassignedcount();
}, 2000);
}
})
.catch((err) => {
console.log(err);
});
};
const sendunassignnotification = (val) => {
console.log(val);
let data2;
let tokenarr = [val.userfcmtoken];
let arr1 = [
{
notificationid: 0,
notificationdate: dayjs().format('YYYY-MM-DD HH:mm:ss'),
Title: 'Staff Un-Asigned',
message: `${val.firstname} has been Un-assigned to the order ${orderid}`,
configid: 2,
tenantid: tenantid,
orderheaderid: orderheaderid,
orderprocessid: val.orderprocessid,
shiftid: val.shiftid,
userid: val.userid,
orderid: orderid,
success: 0,
orderstatus: 'assigned',
processing: dayjs().format('YYYY-MM-DD HH:mm:ss'),
notifytype: 2,
notifyreason: 'Staff Un-Assigned'
// "sound": "ring",
// "click_action": "FLUTTER_NOTIFICATION_CLICK",
// "firstname": val.firstname
}
];
data2 = {
Title: 'Staff Un-Asigned',
message: `A Staff has been Un-assigned to the order ${orderid}`,
tenantid: tenantid,
orderheaderid: orderheaderid,
orderid: orderid,
configid: 2
// "click_action": "FLUTTER_NOTIFICATION_CLICK"
};
let fcmmodel = {
priority: 'high',
registration_ids: tokenarr,
data: data2,
notification: {
body: `An order has been Un-assigned ${orderid}`,
title: 'Legendary',
sound: 'ring',
content_available: true,
click_action: 'FLUTTER_NOTIFICATION_CLICK'
}
};
let grpnotifyobj = {
notifications: arr1,
fcmmodel: fcmmodel
};
console.log('grpnotifyobj unassign');
console.log(grpnotifyobj);
sendgroupnotification(grpnotifyobj);
};
useEffect(() => {
console.log(orderheaderid);
if (orderheaderid && tenantid) {
// fetchorderdetails();
fetchorderaddons();
fetchorderattires();
fetchassignedcount();
// fetchuserdetails();
console.log(location.state || '');
// setOrderid(location.state.orderid || '');
// setEventlocation(location.state.eventlocation || '');
// setEventlocation(address || []);
// setOrderdate(dayjs(location.state.orderdate.substring(0, 10)).format('MM/DD/YYYY') || '');
// setDuedate(dayjs(location.state.orderdate.substring(0, 10)).format('MM/DD/YYYY') || '')
// setEventname(location.state.eventname || '');
// setClientname(location.state.tenantname || '')
} else {
setLoading(false);
}
// fetchorderdetails();
console.log(orderheaderid, tenantid);
}, [orderheaderid, tenantid, assignedpendingcount]);
const handleClose = () => {
setOpen(false);
};
const dialogclose = () => {
setDialogopen(false);
setStaffarr([]);
setExpandopen(['', '']);
};
useEffect(() => {
console.log(currentshiftobj);
});
const assignok = async () => {
let arr = [];
let arr1 = [];
staffarr.map((val) => {
arr.push({
orderprocessid: 0,
// "processdate": `${dayjs(new Date()).format('YYYY-MM-DD')} ${dayjs(new Date()).format('HH:mm:ss')}`, //current date
processdate: dayjs().format('YYYY-MM-DD HH:mm:ss'), //current date
tenantid: tenantid,
orderheaderid: orderheaderid,
orderdetailid: val.orderdetailid, ////
productid: val.productid, /////
userid: val.userid,
orderstatus: 'pending',
pending: `${dayjs(pendingtime).format('YYYY-MM-DD')} ${dayjs(pendingtime).format('HH:mm:ss')}`, // if pending
starttime: `${dayjs(starttime).format('YYYY-MM-DD')} ${dayjs(starttime).format('HH:mm:ss')}`,
endtime: `${dayjs(endtime).format('YYYY-MM-DD')} ${dayjs(endtime).format('HH:mm:ss')}`,
appuserid: parseInt(localStorage.getItem('appuserid')), //loginuserid
shiftid: val.shiftid,
userrate: val.userrate,
productrate: val.productrate
});
staffarr.map((val) => {
arr1.push({
notificationid: 0,
notificationdate: dayjs().format('YYYY-MM-DD HH:mm:ss'),
Title: 'Staff Asigned',
message: `A Staff has been assigned to the order ${orderid}`,
configid: 2,
tenantid: tenantid,
orderheaderid: orderheaderid,
orderprocessid: 0,
shiftid: val.shiftid,
userid: val.userid,
orderid: orderid,
sound: 'ring',
click_action: 'FLUTTER_NOTIFICATION_CLICK',
firstname: val.firstname
});
});
});
console.log('arr');
console.log(arr);
await axios
.post(`${process.env.REACT_APP_URL2}/orders/createorderprocess`, arr)
.then((res) => {
console.log(res);
if (res.data.message === 'Successfully created') {
// if (orderheaderid && tenantid) {
// fetchorderdetails();
// fetchorderaddons();
// fetchorderattires();
// }
enqueueSnackbar('Roles assigned successfully', {
variant: 'success',
anchorOrigin: { vertical: 'top', horizontal: 'right' },
autoHideDuration: 2000
});
// fetchroleslist(productid, '', '', orderheaderid, arr1[0].shiftid);
// console.log(productid, '', '', orderheaderid, arr1[0].shiftid);
// arr1.map((val2) => {
// notificationpush(val2,val2.Title);
// })
setDialogopen(false);
fetchorderattires();
fetchassignedcount();
}
})
.catch((err) => {
console.log(err);
});
console.log(arr);
};
const notificationpush = async (val) => {
let fcmtoken = val.userfcmtoken;
let obj1 = {
notificationid: 0,
notificationdate: dayjs().format('YYYY-MM-DD HH:mm:ss'),
Title: 'Staff Asigned',
message: `A Staff has been assigned to the order ${orderid}`,
configid: 2,
tenantid: tenantid,
orderheaderid: orderheaderid,
orderprocessid: val.orderprocessid,
shiftid: val.shiftid,
userid: val.userid,
orderid: orderid,
sound: 'ring',
click_action: 'FLUTTER_NOTIFICATION_CLICK'
// "firstname": val.firstname
};
console.log(obj1, fcmtoken);
await axios
.post(
`${process.env.REACT_APP_URL2}/utils/notification/send`,
{
priority: 'high',
registration_ids: [fcmtoken],
data: obj1,
notification: {
body: `A Staff has been assigned to ${orderid}`,
title: 'Legendary',
sound: 'ring',
content_available: true
}
},
{
headers: {
Authorization: `Bearer ${process.env.REACT_APP_STAFF_TOKEN}`
}
}
)
.then((res) => {
console.log(res);
// if(res.data.status){
enqueueSnackbar('Notification sent successfully', {
variant: 'success',
anchorOrigin: { vertical: 'top', horizontal: 'right' },
autoHideDuration: 2000
});
// }
})
.catch((err) => {
console.log(err);
});
};
const sendgroupnotification = async (obj1) => {
console.log(obj1);
await axios
.post(`${process.env.REACT_APP_URL2}/utils/notification/sendall`, obj1, {
headers: {
Authorization: `Bearer ${process.env.REACT_APP_STAFF_TOKEN}`
}
})
.then((res) => {
console.log(res);
if (res.data.status) {
// updateorderstatus();
enqueueSnackbar('Notification sent successfully', {
variant: 'success',
anchorOrigin: { vertical: 'top', horizontal: 'right' },
autoHideDuration: 2000
});
fetchorderaddons();
}
})
.catch((err) => {
console.log(err);
});
};
// const updateorderstatus = async () => {
// await axios.put(`${process.env.REACT_APP_URL2}/orders/updateorderstatus`,{
// "orderheaderid":orderheaderid,
// "tenantid":tenantid,
// "orderstatus":"processing",
// "pending":"",
// "processing":dayjs().format('YYYY-MM-DD HH:mm:ss'),
// "completed":""
// })
// .then((res) => {
// console.log(res)
// fetchorderdetails();
// fetchorderaddons();
// fetchorderattires();
// })
// .catch((err) => {
// console.log(err)
// fetchorderdetails();
// fetchorderaddons();
// fetchorderattires();
// })
// }
const fetchassignedcount = async () => {
// console.log(obj1)
await axios
.get(`${process.env.REACT_APP_URL2}/orders/getorderstatuscount?orderheaderid=${orderheaderid}`)
.then((res) => {
if (res.data.status) {
// let arr1=[];
console.log(res);
setAssignedpendingcount(res.data.pendingcount);
fetchorderaddons();
// res.data.details.map((val) => {
// let val2={
// "notificationid": 0,
// "notificationdate": dayjs().format('YYYY-MM-DD HH:mm:ss'),
// "Title": "Staff Asigned",
// "message": `A Staff has been assigned to the order ${orderid}`,
// "configid": 2,
// "tenantid": tenantid,
// "orderheaderid": orderheaderid,
// "orderprocessid": val.orderprocessid,
// "shiftid": val.shiftid,
// "userid": val.userid,
// "orderid": orderid,
// "sound": "ring",
// "click_action": "FLUTTER_NOTIFICATION_CLICK",
// // "firstname": val.firstname
// };
// notificationpush(val2,val.userfcmtoken);
// })
} else {
setAssignedpendingcount(res.data.pendingcount);
fetchorderaddons();
}
})
.catch((err) => {
console.log(err);
});
};
function AlertCustomerDelete({
// title,
open,
handleClose
}) {
const [deletepassword, setDeletepassword] = useState('');
return (
);
}
return (
<>
{loading && }
{/*
*/}
{/* */}
{/*
Details
*/}
history.back()}
// onClick={()=>}
>
{/* Test me */}
Details
{/* */}
: orderid}
variant="combined"
color="warning"
size="small"
/>
{/* Date */}
{/* {orderdate} */}
: orderdate}
variant="combined"
color="primary"
size="small"
/>
{orderstatus === 'pending' && }
{orderstatus === 'cancelled' && }
{orderstatus === 'completed' && }
{orderstatus === 'processing' && }
{orderstatus === 'assigned' && }
{orderstatus === 'confirmed' && }
{orderstatus === 'active' && }
{orderstatus === 'closed' && }
{orderstatus === 'modified' && }
{/* {dayjs(startdate).$d.toString()} */}
{/* {startdate} */}
{/* {dayjs().$d.toString()} */}
{(orderstatus === 'pending' || orderstatus === 'assigned' || orderstatus === 'confirmed' || orderstatus === 'modified') && (
// && (dayjs(startdate).$d > dayjs().$d)
}
onClick={(e) => {
e.stopPropagation();
// if (dayjs(startdate).$d > dayjs().$d) {
if (dayjs(dayjs().format('MM-DD-YYYY')).isBefore(dayjs(dayjs(startdate).format('MM-DD-YYYY')))) {
navigate(`/editorder`, {
state: {
orderheaderid: orderheaderid,
tenantid: tenantid
}
});
} else {
enqueueSnackbar(
'Order cannot be edited.\n Order date is not valid at this time',
{
variant: 'error',
anchorOrigin: { vertical: 'top', horizontal: 'right' },
autoHideDuration: 4000,
style: { whiteSpace: 'pre-line' }
}
);
}
}}
>
Edit Order
)}
{/* {(((orderstatus === 'pending')
|| (orderstatus === 'modified'))
&& assignedpendingcount === 0) &&
<>
}
onClick={() => {
fetchassignedstaffs();
}}
>
Notify Staff
>
} */}
{orderstatus !== 'cancelled' && orderstatus !== '' && orderstatus !== 'completed' && orderstatus !== 'closed' && (
<>
{
console.log(dayjs(startdate).diff(dayjs(), 'm') / 60);
if (dayjs(startdate).diff(dayjs(), 'm') / 60 > 24) {
setInvoiceeligible(false);
setOpen(true);
} else {
setInvoiceeligible(true);
setOpen(true);
}
}}
sx={{ borderRadius: '40px', mt: { xs: 2, sm: 0 }, width: { xs: '100%', sm: 'auto' } }}
startIcon={}
>
Cancel Order
>
)}
{orderstatus === 'cancelled' && (
<>
>
)}
{/* {(orderstatus === 'completed') &&
} */}
{/* Dialog window */}
{/* {(dayjs().isBefore(dayjs(startdate)))?'true':'false'}
*/}
{/* */}
{/* */}
{/* */}
{/*
BEO
*/}
{/* */}
{/*
Due Date
{duedate}
*/}
{/*
*/}
{/* */}
{/* */}
Client
{clientname === '' ? : clientname}
{/* {eventlocation.map((val, i) => {
return {val}
})
}
{eventlocation}
fafdf
dafaf
afdafafd */}
{tenantaddress === '' ? : tenantaddress}
Event
{eventname === '' ? : eventname}
{/*
{(eventlocation === '') ? : eventlocation}
: venuetype} color="primary" variant="light" size="small" sx={{ width: 'max-content' }} />
*/}
{categoryarr.map((val5, j) => {
return (
Shift {j + 1}
{''}
{val5.locationaddress}
{val5.shiftstatus === 1 && }
{val5.ordercontacts.map((val11) => {
return (
<>
{val11.contactname.charAt(0).toUpperCase()}
>
);
})}
{isMobile ? (
{val5.orderdetails.length === 0 && (
)}
{val5.orderdetails.map((row, i) => (
#{i + 1}
{row.productname}
{
setStafflist([]);
setExpandopen(expandopen[0] === j && expandopen[1] === i ? ['', ''] : [j, i]);
fetchstafflist(row.orderdetailid);
}}
>
{expandopen[0] === j && expandopen[1] === i ? : }
{orderstatus === 'cancelled' && (
)}
{row.status === 1 && (
)}
{row.supplyqty > row.orderqty && (
)}
{dayjs(row.starttime).format('MM/DD/YYYY')}
{dayjs(row.starttime).format('hh:mm A')}
{dayjs(row.endtime).format('MM/DD/YYYY')}
{dayjs(row.endtime).format('hh:mm A')}
{stafflist.length === 0 ? (
loading ? (
) : (
No Staffs has been Assigned
)
) : (
{stafflist.map((val, si) => (
{val.staffname}
{val.orderstatus === 'pending' && }
{val.orderstatus === 'cancelled' && (
)}
{val.orderstatus === 'completed' && (
)}
{val.orderstatus === 'processing' && (
)}
{val.orderstatus === 'assigned' && }
{val.orderstatus === 'confirmed' && (
)}
{val.orderstatus === 'active' && }
{val.orderstatus === 'closed' && }
{dayjs(val.Starttime).format('MM/DD/YYYY')}
{dayjs(val.Starttime).format('hh:mm A')}
{dayjs(val.Endtime).format('MM/DD/YYYY')}
{dayjs(val.Endtime).format('hh:mm A')}
))}
)}
))}
) : (
#
Role
Start Date
End Date
Unpaid break
Count
Assigned
Attire
Price
{/* Tax */}
Amount
Action
{val5.orderdetails.length === 0 && (
<>
{/* */}
{/*
*/}
{/* */}
>
)}
{/* */}
{val5.orderdetails.map((row, i) => (
<>
{i + 1}
{row.productname}
{/* {row.productname}
*/}
{dayjs(row.starttime).format('MM/DD/YYYY')}
{dayjs(row.starttime).format('hh:mm A')}
{' '}
{dayjs(row.endtime).format('MM/DD/YYYY')}
{dayjs(row.endtime).format('hh:mm A')}
{row.unpaidbreak || 0}
{/* < Grid container spacing={1}>
{(row.orderattires || []).map((val) => {
return
})
}
*/}
${row.price}
{/* {row.taxamount} */}
${row.landingamount}
{
setStafflist([]);
setExpandopen(expandopen[0] === j && expandopen[1] === i ? ['', ''] : [j, i]);
// expanddatafetch(row.orderheaderid);
// fetchroleslist(row.productid, '', '', val5.orderheaderid, row.shiftid);
fetchstafflist(row.orderdetailid);
}}
>
{expandopen[0] === j && expandopen[1] === i ? : }
{/* {(orderstatus !== 'cancelled') &&
<>
{
setExpandopen(['', ''])
setCurrentrole(row.productname);
setStarttime(row.starttime);
console.log('row')
console.log(row)
setEndtime(row.endtime);
setProductid(row.productid);
setOrderdetailid(row.orderdetailid);
if ((row.orderqty === row.supplyqty)
|| (row.status == 1)
|| (val5.shiftstatus == 1)
) {
fetchroleslist(row.productid, '', '', val5.orderheaderid, row.shiftid);
} else {
fetchroleslist(row.productid, row.starttime, row.endtime, val5.orderheaderid, row.shiftid);
}
setStaffarr([]);
let obj = currentshiftobj;
obj.shifts = row.orderqty;
obj.shiftid = row.shiftid;
obj.remaining = row.orderqty - row.supplyqty;
obj.assigned = row.supplyqty;
obj.price = row.price;
setCurrentshiftobj(obj);
setDialogopen(true);
}} >
>
} */}
{orderstatus === 'cancelled' && (
<>
>
)}
{row.status === 1 && (
)}
{row.supplyqty > row.orderqty && (
)}
{/* */}
{stafflist.length === 0 ? (
<>
{loading ? (
<>
>
) : (
<>
No Staffs has been Assigned
>
)}
>
) : (
#
Staff
Start Time
End Time
Pay Rate
{/* Category */}
Clockin
Clockout
Hours Worked
{/* Experience */}
{/* Level */}
{/* City */}
Status
{stafflist.map((val, i) => {
return (
res.userid == val.userid)) ? '#f5f5f5' : '', ':hover': {
// backgroundColor: (staffarr.find((res) => res.userid == val.userid)) ? '#f5f5f5 !important' : ''
// }
}
}
>
{i + 1}
{/*
{val.staffname}
*/}
{val.staffname}
{dayjs(val.Starttime).format('MM/DD/YYYY')}
{dayjs(val.Starttime).format('hh:mm A')}
{dayjs(val.Endtime).format('MM/DD/YYYY')}
{dayjs(val.Endtime).format('hh:mm A')}
{val.rolecost}
{/*
{val.cateoryname}
*/}
{/* Clock In: */}
{/* Age */}
{/* Clock In: */}
{/* Age */}
{val.hoursworked}
{/*
{val.tenantname}
{val.orderid}
{dayjs(val.startdate).utc().format('MM/DD/YYYY')}
{val.eventname}
{`${val.locationaddress.slice(0, 15)}...`}
*/}
{val.orderstatus === 'pending' && (
)}
{val.orderstatus === 'cancelled' && (
)}
{val.orderstatus === 'completed' && (
)}
{val.orderstatus === 'processing' && (
)}
{val.orderstatus === 'assigned' && (
)}
{val.orderstatus === 'confirmed' && (
)}
{val.orderstatus === 'active' && (
)}
{val.orderstatus === 'closed' && (
)}
);
})}
)}
>
))}
)}
);
})}
{/* */}
{/* Order Addons
*/}
{(orderaddons || []).map((val) => {
return (
} variant="outlined" color="error" label={val.addon} />
);
})}
{/*
} variant='outlined' color="error" label="Parking Provided" />
} variant='outlined' color="error" label="Meal Provided" />
*/}
{/*
} color="error" label="Like" />
} color="error" label="Like" />
} color="error" label="Like" />
*/}
{/* */}
{/* */}
{/* */}
Sub Total:
${subtotal === '' ? : subtotal}
{/*
Discount:
0
*/}
Tax:
{taxamount === '' ? : taxamount}
Grand Total:
{grandtotal === '' ? : `$${grandtotal}`}
{/* */}
Other Instructions:
{otherinstructions}
{/*
}>Send Notifications
*/}
{/* */}
{/* */}
>
);
};
export default Details;