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 SendIcon from '@mui/icons-material/Send'; 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 { 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, setCurrentrole] = 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, setStarttime] = useState(''); const [endtime, setEndtime] = useState(''); // const [orderstatus,setOrderstatus]=useStatus(''); const [pendingtime, setPendingtime] = useState(''); // const [processdate,setProcessdate]=useState(''); const [orderdetailid, setOrderdetailid] = useState(''); const [productid, setProductid] = 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 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 fetchroleslist = async (cid, starttime1, endtime1, hid, sid) => { let fromdate = dayjs(starttime1).subtract(59, 'minutes') .format('YYYY-MM-DD HH:mm:ss'); // let todate = dayjs(endtime1).utc().format('YYYY-MM-DD HH:mm:ss'); // let fromdate = dayjs(starttime1).utc().format('YYYY-MM-DD HH:mm:ss'); let todate = dayjs(endtime1) .format('YYYY-MM-DD HH:mm:ss'); let url1; if (starttime1) { url1 = `${process.env.REACT_APP_URL2}/staffs/pools/getstaffs/?categoryid=${cid}&headerid=${hid}&shiftid=${sid}&starttime=${fromdate}&endtime=${todate}`; } else { url1 = `${process.env.REACT_APP_URL2}/staffs/pools/getstaffs/?categoryid=${cid}&headerid=${hid}&shiftid=${sid}` } setLoading(true); setStafflist([]) await axios // .get(`${process.env.REACT_APP_URL2}/staffs/pools/getstaffs/?categoryid=${cid}&headerid=${hid}&starttime=${fromdate}&endtime=${todate}`) .get(url1) .then((res) => { console.log('rolelist'); console.log(res); // console.log(fromdate, todate) // console.log(dayjs(starttime1).format('YYYY-MM-DD HH:mm:ss')) // console.log(dayjs(endtime1).format('HH:mm:ss')) setStafflist(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) 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 fetchassignedstaffs = async () => { // console.log(obj1) await axios.get(`${process.env.REACT_APP_URL2}/orders/getnotificationusers?orderheaderid=${orderheaderid}`) .then((res) => { if (res.data.status) { let arr1 = []; let data2; let tokenarr = [] console.log(res) res.data.details.map((val) => { arr1.push({ "notificationid": 0, "notificationdate": dayjs().format('YYYY-MM-DD HH:mm:ss'), "Title": "Staff Asigned", "message": `${val.staffname} has been 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": 1, "notifyreason": 'Staff Assigned' // "sound": "ring", // "click_action": "FLUTTER_NOTIFICATION_CLICK", // "firstname": val.firstname }); tokenarr.push(val.userfcmtoken); }) data2 = { "Title": "Staff Asigned", "message": `A Staff has been 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 assigned ${orderid}`, "title": "Legendary", "sound": "ring", "content_available": true, "click_action": "FLUTTER_NOTIFICATION_CLICK" } } let grpnotifyobj = { "notifications": arr1, "fcmmodel": fcmmodel } console.log("grpnotifyobj") console.log(grpnotifyobj) sendgroupnotification(grpnotifyobj) // notificationpush(obj2, val.userfcmtoken); // notificationpush(arr1,tokenarr); // enqueueSnackbar('Notifications 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 ( handleClose(false)} maxWidth="xs" > {/* Are you sure you want to cancel this order? */} {(invoiceeligible) && }> Order is within 24Hrs time frame. The order will be invoiced with standard pricing as agreed. {/* This is an warning alert. */} Terms & Condition link } Please type in the order number to confirm. { console.log(e.target.value) setDeletepassword(e.target.value) }} error={deletepassword !== orderid.slice(4)} // error={true} value={deletepassword} /> ); } return ( <> {loading && } Assign Roles {/* */} setTabstatus((e) => (e === 0) ? 1 : 0)} variant="scrollable" scrollButtons="auto" > {/* */} {/* title */} {/* setTabstatus((e) => (e === 0) ? 1 : 0)} variant="scrollable" scrollButtons="auto" > */} {/* */} {/* */} {(stafflist.length === 0) ? <> {(loading) ? <> : No Staffs Available } : # Staff Category {/* Gender */} Price Experience Level City Action {stafflist.map((val, i) => { return res.userid == val.userid)) ? '#f5f5f5' : '', ':hover': { backgroundColor: (staffarr.find((res) => res.userid == val.userid)) ? '#f5f5f5 !important' : '' } }}> {i + 1} {/* {row.tenantname.charAt(0)} */} {val.firstname} {val.contactno} {/* {val.contactno} some demo address */} {val.cateoryname} {/* {row.category} */} {val.rolecost} {/* */} {/* {(row.gender === 1) && } */} {/* {row.gender === 0 && } */} {/* */} {/* */} {/* B+ */} {/* {row.devicetype} */} {val.experience} Years {val.city} {(val.orderdetailid !== orderdetailid) ? <> res.userid == val.userid)) ? true : false} onClick={(e) => { console.log(currentshiftobj) if (currentshiftobj.remaining >= 0) { if (e.target.checked && currentshiftobj.remaining != 0) { let arr = staffarr; arr.push({ userid: val.userid, orderdetailid, productid, shiftid: currentshiftobj.shiftid, userrate: currentshiftobj.price, productrate: val.rolecost, firstname: val.firstname }); setStaffarr([...arr]) let obj = currentshiftobj; // obj.shifts--; // obj.assigned = arr.length; obj.assigned++; obj.remaining = obj.shifts - obj.assigned; setCurrentshiftobj({ ...obj }) } else if (currentshiftobj.assigned != currentshiftobj.shifts || (currentshiftobj.remaining === 0 && (!e.target.checked))) { let arr = staffarr; // let index = arr.indexOf(val.userid) let index = arr.findIndex((val1) => val1.userid === val.userid) arr.splice(index, 1); setStaffarr([...arr]); let obj = currentshiftobj; // obj.shifts++; // obj.assigned = arr.length; obj.assigned--; obj.remaining = obj.shifts - obj.assigned; setCurrentshiftobj({ ...obj }) } // forceUpdate(); console.log(staffarr); } }} /> : <> {/* */} { console.log(val) unassign(val) // sendunassignnotification(val) }}> {/* */} { console.log(val) // unassign(val) notificationpush(val) }}> {/* */} } {(val.orderid) && <> } }) }
}
{(stafflist.length > 0) && <> OK { // dialogclose(); setStaffarr([]); let obj = currentshiftobj; // obj.shifts = row.orderqty; obj.remaining = obj.shifts; obj.assigned = 0; setCurrentshiftobj(obj); }}>clear } { dialogclose() }}>Close {/* */} {/* */}
{/* */} {/* */} {/* 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 } }} 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 < Fragment key={val5.locationaddress}> Shift {j + 1} {''}{val5.locationaddress} {(val5.shiftstatus === 1) && } {val5.ordercontacts.map((val11) => { return <> {val11.contactname.charAt(0).toUpperCase()} }) } # 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} {/* */}
{/* */} {/* */} ); }; export default Details;