mirror of
https://gitlab.com/mbugroup/lti-web-client.git
synced 2026-05-24 23:35:45 +00:00
refactor(FE-356): Use timestamped filename for HPP export
This commit is contained in:
@@ -14,7 +14,7 @@ import { KandangApi } from '@/services/api/master-data';
|
|||||||
import { SaleReportApi } from '@/services/api/report/marketing-sale';
|
import { SaleReportApi } from '@/services/api/report/marketing-sale';
|
||||||
import Table from '@/components/Table';
|
import Table from '@/components/Table';
|
||||||
import { ColumnDef } from '@tanstack/react-table';
|
import { ColumnDef } from '@tanstack/react-table';
|
||||||
import { formatCurrency, formatNumber } from '@/lib/helper';
|
import { formatCurrency, formatDate, formatNumber } from '@/lib/helper';
|
||||||
import { HppPerKandangReport } from '@/types/api/report/hpp-per-kandang';
|
import { HppPerKandangReport } from '@/types/api/report/hpp-per-kandang';
|
||||||
import { isResponseSuccess } from '@/lib/api-helper';
|
import { isResponseSuccess } from '@/lib/api-helper';
|
||||||
import { useTableFilter } from '@/services/hooks/useTableFilter';
|
import { useTableFilter } from '@/services/hooks/useTableFilter';
|
||||||
@@ -401,40 +401,7 @@ const HppPerKandangTab = () => {
|
|||||||
const workbook = XLSX.utils.book_new();
|
const workbook = XLSX.utils.book_new();
|
||||||
XLSX.utils.book_append_sheet(workbook, worksheet, 'HPP Per Kandang');
|
XLSX.utils.book_append_sheet(workbook, worksheet, 'HPP Per Kandang');
|
||||||
|
|
||||||
const areaName =
|
const filename = `laporan-hpp-harian-kandang-${tableFilterState.period}-${formatDate(new Date(), 'YYYY-MM-DD-HHmm')}.xlsx`;
|
||||||
tableFilterState.area_id.length > 0
|
|
||||||
? tableFilterState.area_id
|
|
||||||
.map(
|
|
||||||
(id) =>
|
|
||||||
areaOptions.find((opt) => opt.value === Number(id))?.label
|
|
||||||
)
|
|
||||||
.filter(Boolean)
|
|
||||||
.join(', ') || 'Semua Area'
|
|
||||||
: 'Semua Area';
|
|
||||||
|
|
||||||
const locationName =
|
|
||||||
tableFilterState.location_id.length > 0
|
|
||||||
? tableFilterState.location_id
|
|
||||||
.map(
|
|
||||||
(id) =>
|
|
||||||
locationOptions.find((opt) => opt.value === Number(id))?.label
|
|
||||||
)
|
|
||||||
.filter(Boolean)
|
|
||||||
.join(', ') || 'Semua Lokasi'
|
|
||||||
: 'Semua Lokasi';
|
|
||||||
|
|
||||||
const kandangName =
|
|
||||||
tableFilterState.kandang_id.length > 0
|
|
||||||
? tableFilterState.kandang_id
|
|
||||||
.map(
|
|
||||||
(id) =>
|
|
||||||
kandangOptions.find((opt) => opt.value === Number(id))?.label
|
|
||||||
)
|
|
||||||
.filter(Boolean)
|
|
||||||
.join(', ') || 'Semua Kandang'
|
|
||||||
: 'Semua Kandang';
|
|
||||||
|
|
||||||
const filename = `Laporan_HPP_Per_Kandang_${areaName}_${locationName}_${kandangName}_${tableFilterState.period}.xlsx`;
|
|
||||||
|
|
||||||
XLSX.writeFile(workbook, filename);
|
XLSX.writeFile(workbook, filename);
|
||||||
toast.success('Excel berhasil dibuat dan diunduh.');
|
toast.success('Excel berhasil dibuat dan diunduh.');
|
||||||
|
|||||||
Reference in New Issue
Block a user