|
|
@@ -14,6 +14,10 @@ import { MAINTAIN_STAFF, MAINTAIN_USER } from "@/middleware"; |
|
|
|
import { TeamResult } from "@/app/api/team"; |
|
|
|
import { Grade } from "@/app/api/grades"; |
|
|
|
import { PositionResult } from "@/app/api/positions"; |
|
|
|
import { Button, Stack } from "@mui/material"; |
|
|
|
import FileDownloadIcon from '@mui/icons-material/FileDownload'; |
|
|
|
import { fetchStaffCurrentInfo } from "@/app/api/reports/actions"; |
|
|
|
import { downloadFile } from "@/app/utils/commonUtil"; |
|
|
|
|
|
|
|
interface Props { |
|
|
|
staff: StaffResult[]; |
|
|
@@ -102,6 +106,16 @@ const StaffSearch: React.FC<Props> = ({ staff, teams, grades, positions, abiliti |
|
|
|
}, t); |
|
|
|
}, []); |
|
|
|
|
|
|
|
const handleExport = useCallback(async (ids: number[]) => { |
|
|
|
console.log(ids) |
|
|
|
const response = await fetchStaffCurrentInfo( |
|
|
|
{staffIds: ids} |
|
|
|
) |
|
|
|
if (response) { |
|
|
|
downloadFile(new Uint8Array(response.blobValue), response.filename!!) |
|
|
|
} |
|
|
|
},[filteredStaff]) |
|
|
|
|
|
|
|
useEffect(() => { |
|
|
|
setFilteredStaff(staff) |
|
|
|
}, [staff]); |
|
|
@@ -147,6 +161,7 @@ const StaffSearch: React.FC<Props> = ({ staff, teams, grades, positions, abiliti |
|
|
|
|
|
|
|
return ( |
|
|
|
<> |
|
|
|
… |
|
|
|
<SearchBox |
|
|
|
criteria={searchCriteria} |
|
|
|
onSearch={(query) => { |
|
|
@@ -165,6 +180,21 @@ const StaffSearch: React.FC<Props> = ({ staff, teams, grades, positions, abiliti |
|
|
|
}} |
|
|
|
/> |
|
|
|
<SearchResults<StaffResult> items={filteredStaff} columns={columns} /> |
|
|
|
|
|
|
|
<Stack |
|
|
|
direction="row" |
|
|
|
justifyContent="flex-end" |
|
|
|
flexWrap="wrap" |
|
|
|
rowGap={2} |
|
|
|
> |
|
|
|
<Button |
|
|
|
variant="contained" |
|
|
|
startIcon={<FileDownloadIcon />} |
|
|
|
onClick={() => handleExport(filteredStaff.map(staff => staff.id))} |
|
|
|
> |
|
|
|
{t("Export")} |
|
|
|
</Button> |
|
|
|
</Stack> |
|
|
|
</> |
|
|
|
); |
|
|
|
}; |
|
|
|