|
|
@@ -6,7 +6,7 @@ import { Button, Grid, Stack } from "@mui/material"; |
|
|
|
import React, { ChangeEvent, useCallback } from "react"; |
|
|
|
import { useTranslation } from "react-i18next"; |
|
|
|
import { errorDialogWithContent, submitDialog, successDialog, successDialogWithContent } from "../Swal/CustomAlerts"; |
|
|
|
import { importLeaves, importTimesheets, rearrangeTimesheets } from "@/app/api/timesheets/actions"; |
|
|
|
import { importLeaves, importOSTimesheets, importTimesheets, rearrangeTimesheets } from "@/app/api/timesheets/actions"; |
|
|
|
|
|
|
|
interface Props { |
|
|
|
} |
|
|
@@ -34,6 +34,9 @@ const ExcelFileImport: React.FC<Props> = async ({ }) => { |
|
|
|
case "importTimesheet": |
|
|
|
response = await importTimesheets(formData) |
|
|
|
break; |
|
|
|
case "importOSTimesheet": |
|
|
|
response = await importOSTimesheets(formData) |
|
|
|
break; |
|
|
|
case "importLeave": |
|
|
|
response = await importLeaves(formData) |
|
|
|
break; |
|
|
@@ -67,23 +70,23 @@ const ExcelFileImport: React.FC<Props> = async ({ }) => { |
|
|
|
response = await rearrangeTimesheets() |
|
|
|
break; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (response.includes("Rearrange success")) { |
|
|
|
successDialogWithContent(t("Rearrange Success"), t(`${response}`), t) |
|
|
|
} else { |
|
|
|
errorDialogWithContent(t("Rearrange Fail"), t(`${response}`), t) |
|
|
|
} |
|
|
|
}, t, |
|
|
|
{ |
|
|
|
title: "Do you want to rearrange?", |
|
|
|
confirmButtonText: "Rearrange" |
|
|
|
}) |
|
|
|
{ |
|
|
|
title: "Do you want to rearrange?", |
|
|
|
confirmButtonText: "Rearrange" |
|
|
|
}) |
|
|
|
|
|
|
|
} catch (err) { |
|
|
|
console.log(err) |
|
|
|
return false |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
}, []) |
|
|
|
|
|
|
|
return ( |
|
|
@@ -99,7 +102,7 @@ const ExcelFileImport: React.FC<Props> = async ({ }) => { |
|
|
|
<input |
|
|
|
id='importProject' |
|
|
|
type='file' |
|
|
|
accept='.xlsx, .csv' |
|
|
|
accept='.xlsx' |
|
|
|
hidden |
|
|
|
onChange={(event) => { |
|
|
|
handleExcelFileImportClick(event) |
|
|
@@ -118,7 +121,7 @@ const ExcelFileImport: React.FC<Props> = async ({ }) => { |
|
|
|
<input |
|
|
|
id='importTimesheet' |
|
|
|
type='file' |
|
|
|
accept='.xlsx, .csv' |
|
|
|
accept='.xlsx' |
|
|
|
hidden |
|
|
|
onChange={(event) => { |
|
|
|
handleExcelFileImportClick(event) |
|
|
@@ -127,6 +130,25 @@ const ExcelFileImport: React.FC<Props> = async ({ }) => { |
|
|
|
{t("Import Timesheet")} |
|
|
|
</Button> |
|
|
|
</Grid> |
|
|
|
<Grid container> |
|
|
|
<Button |
|
|
|
variant="contained" |
|
|
|
color="info" |
|
|
|
startIcon={<FileUpload />} |
|
|
|
component="label" |
|
|
|
> |
|
|
|
<input |
|
|
|
id='importOSTimesheet' |
|
|
|
type='file' |
|
|
|
accept='.xlsx' |
|
|
|
hidden |
|
|
|
onChange={(event) => { |
|
|
|
handleExcelFileImportClick(event) |
|
|
|
}} |
|
|
|
/> |
|
|
|
{t("Import OS Timesheet")} |
|
|
|
</Button> |
|
|
|
</Grid> |
|
|
|
<Grid container> |
|
|
|
<Button |
|
|
|
id="rearrangeTimesheet" |
|
|
@@ -149,7 +171,7 @@ const ExcelFileImport: React.FC<Props> = async ({ }) => { |
|
|
|
<input |
|
|
|
id='importLeave' |
|
|
|
type='file' |
|
|
|
accept='.xlsx, .csv' |
|
|
|
accept='.xlsx' |
|
|
|
hidden |
|
|
|
onChange={(event) => { |
|
|
|
handleExcelFileImportClick(event) |
|
|
|