shift replcement works
This commit is contained in:
@ -9,6 +9,9 @@ import PublisherSearchBox from '../../../components/publisher/PublisherSearchBox
|
||||
|
||||
import { monthNamesBG, GetTimeFormat, GetDateFormat } from "../../../src/helpers/const"
|
||||
import { useSession, getSession } from 'next-auth/react';
|
||||
import axiosInstance from 'src/axiosSecure';
|
||||
import { toast } from 'react-toastify';
|
||||
import LocalShippingIcon from '@mui/icons-material/LocalShipping';
|
||||
|
||||
export default function MySchedulePage({ assignments }) {
|
||||
|
||||
@ -46,7 +49,8 @@ export default function MySchedulePage({ assignments }) {
|
||||
{assignment.shift.assignments.map((a, index) => {
|
||||
return (
|
||||
<span key={index} className="inline-flex items-center mr-1 px-1 py-0.5 rounded-full text-sm font-medium ">
|
||||
{a.publisher.firstName} {a.publisher.lastName}</span>
|
||||
{a.publisher.firstName} {a.publisher.lastName}{a.isWithTransport && <LocalShippingIcon style={{ paddingLeft: '4px' }} />}
|
||||
</span>
|
||||
)
|
||||
}
|
||||
)}
|
||||
@ -98,6 +102,26 @@ export default function MySchedulePage({ assignments }) {
|
||||
// Add publisher as assignment logic
|
||||
setIsModalOpen(false);
|
||||
console.log("publisher", publisher.firstName, " ", publisher.lastName, " set to shift ", assignment.shift.id);
|
||||
//api.replaceInAssignment()
|
||||
axiosInstance.post('/api/?action=replaceInAssignment', {
|
||||
oldPublisherId: session.user.id,
|
||||
newPublisherId: publisher.id,
|
||||
shiftId: assignment.shift.id,
|
||||
}).then(response => {
|
||||
console.log("response", response);
|
||||
//toast success and confirm the change
|
||||
toast.success("Промяната е записана!", {
|
||||
position: "top-right",
|
||||
autoClose: 5000,
|
||||
hideProgressBar: false,
|
||||
closeOnClick: true,
|
||||
pauseOnHover: true,
|
||||
draggable: true,
|
||||
progress: undefined,
|
||||
});
|
||||
}).catch(error => {
|
||||
console.log("error", error);
|
||||
});
|
||||
//addAssignment(publisher, shift.id);
|
||||
}}
|
||||
showAllAuto={true}
|
||||
|
Reference in New Issue
Block a user