(wip) schedle generation;
added confirmations on schedule DELETE!!! better reports page; log every delete over API, more logging;
This commit is contained in:
@ -434,9 +434,8 @@ export default function CalendarPage({ initialEvents, initialShifts }) {
|
||||
setActiveButton(null);
|
||||
}
|
||||
}
|
||||
const deleteShifts = async (buttonId, forDay: Boolean) => {
|
||||
const deleteShifts = async (forDay: Boolean) => {
|
||||
try {
|
||||
setActiveButton(buttonId);
|
||||
await axiosInstance.get(`/api/shiftgenerate?action=delete&date=${common.getISODateOnly(value)}&forDay=${forDay}`);
|
||||
toast.success('Готово!', { autoClose: 1000 });
|
||||
setIsMenuOpen(false);
|
||||
@ -533,7 +532,29 @@ export default function CalendarPage({ initialEvents, initialShifts }) {
|
||||
|
||||
|
||||
const [isMenuOpen, setIsMenuOpen] = useState(false);
|
||||
const [isConfirmModalOpen, setConfirmModalOpen] = useState(false);
|
||||
|
||||
const [confirmModalProps, setConfirmModalProps] = useState({
|
||||
isOpen: false,
|
||||
message: '',
|
||||
onConfirm: () => { }
|
||||
});
|
||||
const openConfirmModal = (message, action, actionName) => {
|
||||
if (actionName) {
|
||||
setActiveButton(actionName);
|
||||
}
|
||||
setConfirmModalProps({
|
||||
isOpen: true,
|
||||
message: message,
|
||||
onConfirm: () => {
|
||||
toast.info('Потвърдено!', { autoClose: 2000 });
|
||||
setConfirmModalProps((prevProps) => ({ ...prevProps, isOpen: false }));
|
||||
action();
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
//const [isConfirmModalDeletOpen, setConfirmModalDeleteOpen] = useState(false);
|
||||
|
||||
async function copyOldAvailabilities(event: MouseEvent<HTMLButtonElement, MouseEvent>): Promise<void> {
|
||||
await axiosInstance.get(`/api/?action=copyOldAvailabilities&date=${common.getISODateOnly(value)}`);
|
||||
}
|
||||
@ -592,10 +613,16 @@ export default function CalendarPage({ initialEvents, initialShifts }) {
|
||||
<button className="button btn m-2 bg-blue-800" onClick={generateDOCX}>
|
||||
{isLoading('generateDOCX') ? (<i className="fas fa-sync-alt fa-spin mr-2"></i>) : (<i className="fa fa-file-export"></i>)}Експорт в Word
|
||||
</button>
|
||||
<button className="button btn m-2 bg-yellow-500 hover:bg-yellow-600 text-white" onClick={() => { setActiveButton("sendEmails"); setConfirmModalOpen(true) }}>
|
||||
<button className="button btn m-2 bg-yellow-500 hover:bg-yellow-600 text-white"
|
||||
onClick={() => openConfirmModal(
|
||||
'Това ще изпрати имейли до всички участници за смените им през избрания месец. Сигурни ли сте?',
|
||||
() => sendMails(),
|
||||
"sendEmails"
|
||||
)}
|
||||
>
|
||||
{isLoading('sendEmails') ? (<i className="fas fa-sync-alt fa-spin mr-2"></i>) : (<i className="fas fa-envelope mr-2"></i>)} изпрати мейли!
|
||||
</button>
|
||||
<ConfirmationModal
|
||||
{/* <ConfirmationModal
|
||||
isOpen={isConfirmModalOpen}
|
||||
onClose={() => setConfirmModalOpen(false)}
|
||||
onConfirm={() => {
|
||||
@ -604,7 +631,14 @@ export default function CalendarPage({ initialEvents, initialShifts }) {
|
||||
sendMails()
|
||||
}}
|
||||
message="Това ще изпрати имейли до всички участници за смените им през избрания месец. Сигурни ли сте?"
|
||||
/> */}
|
||||
<ConfirmationModal
|
||||
isOpen={confirmModalProps.isOpen}
|
||||
onClose={() => setConfirmModalProps((prevProps) => ({ ...prevProps, isOpen: false }))}
|
||||
onConfirm={confirmModalProps.onConfirm}
|
||||
message={confirmModalProps.message}
|
||||
/>
|
||||
|
||||
<button
|
||||
className={`button btn m-2 ${isPublished ? 'hover:bg-gray-500 bg-yellow-500' : 'hover:bg-red-300 bg-blue-400'}`}
|
||||
onClick={togglePublished}>
|
||||
@ -627,7 +661,13 @@ export default function CalendarPage({ initialEvents, initialShifts }) {
|
||||
<button className="block px-4 py-2 text-sm text-gray-700 hover:bg-gray-100" onClick={() => generateShifts("genDay", false, true, true)}>
|
||||
{isLoading('genDay') ? (<i className="fas fa-sync-alt fa-spin mr-2"></i>) : (<i className="fas fa-cogs mr-2"></i>)}
|
||||
Генерирай смени ({value.getDate()}-ти) </button>
|
||||
<button className="block px-4 py-2 text-sm text-red-500 hover:bg-gray-100" onClick={() => { deleteShifts("deleteShiftsDay", true) }}>
|
||||
<button className="block px-4 py-2 text-sm text-red-500 hover:bg-gray-100"
|
||||
onClick={() => openConfirmModal(
|
||||
'Сигурни ли сте че искате да изтриете смените и назначения на този ден?',
|
||||
() => deleteShifts(true),
|
||||
"deleteShiftsDay"
|
||||
)}
|
||||
>
|
||||
{isLoading('deleteShiftsDay') ? (<i className="fas fa-sync-alt fa-spin mr-2"></i>) : (<i className="fas fa-trash-alt mr-2"></i>)}
|
||||
изтрий смените ({value.getDate()}-ти)</button>
|
||||
|
||||
@ -641,11 +681,16 @@ export default function CalendarPage({ initialEvents, initialShifts }) {
|
||||
<button className="block w-full px-4 py-2 text-sm text-gray-700 hover:bg-gray-100 flex items-center" onClick={() => generateShifts("genDay", true, true)}>
|
||||
{isLoading('genDay') ? (<i className="fas fa-sync-alt fa-spin mr-2"></i>) : (<i className="fas fa-cogs mr-2"></i>)}
|
||||
Генерирай смени </button>
|
||||
<button className="block px-4 py-2 text-sm text-red-500 hover:bg-gray-100" onClick={() => { deleteShifts("deleteShifts", false) }}>
|
||||
<button className="block px-4 py-2 text-sm text-red-500 hover:bg-gray-100"
|
||||
onClick={() => openConfirmModal(
|
||||
'Сигурни ли сте че искате да изтриете ВСИЧКИ смени и назначения за месеца?',
|
||||
() => deleteShifts(false),
|
||||
"deleteShifts"
|
||||
)}
|
||||
>
|
||||
{isLoading('deleteShifts') ? (<i className="fas fa-sync-alt fa-spin mr-2"></i>) : (<i className="fas fa-trash-alt mr-2"></i>)}
|
||||
изтрий смените</button>
|
||||
|
||||
|
||||
<hr className="my-1" />
|
||||
|
||||
<button className="block px-4 py-2 text-sm text-gray-700 hover:bg-gray-100" onClick={generateXLS}><i className="fas fa-file-excel mr-2"></i> Генерирай XLSX</button>
|
||||
|
@ -62,7 +62,7 @@ export default function Reports() {
|
||||
const { data } = await axiosInstance.get("/api/data/locations");
|
||||
setLocations(data);
|
||||
console.log(data);
|
||||
axiosInstance.get(`/api/data/reports?include=publisher,location`)
|
||||
axiosInstance.get(`/api/data/reports?include=publisher,location,shift`)
|
||||
.then((res) => {
|
||||
// let reports = res.data;
|
||||
// reports.forEach((report) => {
|
||||
@ -123,8 +123,12 @@ export default function Reports() {
|
||||
{filteredReports.map((report) => (
|
||||
<tr key={report.id}>
|
||||
<td className="border px-2 py-2">{report.publisher.firstName + " " + report.publisher.lastName}</td>
|
||||
<td className="border px-2 py-2">{common.getDateFormated(new Date(report.date))}</td>
|
||||
<td className="border px-2 py-2">{report.location?.name}</td>
|
||||
<td className="border px-2 py-2">{common.getDateFormated(new Date(report.date))}
|
||||
{report.type === ReportType.ServiceReport ? (report.shift ? " от " + common.getTimeFormatted(report.shift?.startTime) + " ч." : "") : common.getTimeFormatted(report.date)}
|
||||
</td>
|
||||
<td className="border px-2 py-2">{report.location?.name}
|
||||
{report.type === ReportType.ServiceReport ? (report.shift ? "" : "за целия ден") : report.comments}
|
||||
</td>
|
||||
<td className="border px-2 py-2">
|
||||
{(report.type === ReportType.ServiceReport)
|
||||
? (
|
||||
@ -145,12 +149,16 @@ export default function Reports() {
|
||||
<span style={{ color: 'blue' }}> - Предложение</span> :
|
||||
""}
|
||||
</div>
|
||||
<div dangerouslySetInnerHTML={{ __html: report.experienceInfo }} />
|
||||
<div style={{ maxHeight: '960px', maxWidth: '960px', overflow: 'auto' }}>
|
||||
<div dangerouslySetInnerHTML={{ __html: report.experienceInfo }} />
|
||||
</div>
|
||||
</>
|
||||
) : (
|
||||
<>
|
||||
<div><strong>Случка</strong></div>
|
||||
<div dangerouslySetInnerHTML={{ __html: report.experienceInfo }} />
|
||||
<div style={{ maxHeight: '960px', maxWidth: '960px', overflow: 'auto' }}>
|
||||
<div dangerouslySetInnerHTML={{ __html: report.experienceInfo }} />
|
||||
</div>
|
||||
</>
|
||||
)
|
||||
|
||||
|
Reference in New Issue
Block a user