Compare commits

..

686 Commits

Author SHA1 Message Date
randy-ar 77a7b6ccf8 fix(FE): change options value debt supplier 2026-01-13 11:23:17 +07:00
randy-ar 0ac14fe342 fix(FE): fixing floating action button project flock and change page size 2026-01-13 11:11:10 +07:00
randy-ar 00eed01cea Merge branch 'development' of https://gitlab.com/mbugroup/lti-web-client into dev/randy 2026-01-13 10:47:32 +07:00
randy-ar 6702dd7dc6 fix(FE): fixing response data debt supplier 2026-01-13 10:46:52 +07:00
Rivaldi A N S a526772e02 Merge branch 'fix/marketing-report' into 'development'
[FIX/FE] Daily Marketing Report

See merge request mbugroup/lti-web-client!163
2026-01-13 03:38:56 +00:00
ValdiANS b486d25a8b chore: access sales.name 2026-01-13 10:34:54 +07:00
Rivaldi A N S b73b452621 Merge branch 'fix/marketing-report' into 'development'
[FIX/FE] Daily Marketing Report

See merge request mbugroup/lti-web-client!162
2026-01-13 03:27:14 +00:00
ValdiANS 4f4787e088 chore: create DailyMarketingReportResponse 2026-01-13 10:22:19 +07:00
ValdiANS f32024d19a chore: use DailyMarketingReportResponse 2026-01-13 10:21:31 +07:00
ValdiANS 3b666a924f chore: add total hpp price per kg footer 2026-01-13 10:21:22 +07:00
ValdiANS 021df11600 chore: add total props in DailyMarketingReportPDFProps and adjust data type 2026-01-13 10:20:23 +07:00
ValdiANS d306fad40c chore: use DailyMarketingReportResponse type 2026-01-13 10:19:22 +07:00
Rivaldi A N S ebc12638ff Merge branch 'fix/adjustment-closing-tab-and-finance-report' into 'development'
[FIX/FE] Adjustment Finance Report (Kontrol Pembayaran Customer)

See merge request mbugroup/lti-web-client!161
2026-01-13 02:30:22 +00:00
rstubryan 437dd75934 feat(FE): Add 5MB file size validation for document uploads 2026-01-13 08:42:07 +07:00
rstubryan e1c0701629 refactor(FE): Adapt customer payment report types and exports 2026-01-12 21:39:22 +07:00
rstubryan 96a5eb1be5 Merge branch 'development' of gitlab.com:mbugroup/lti-web-client into dev/restu 2026-01-12 17:45:30 +07:00
rstubryan 7add41ea5a refactor(FE): Map approval 6 to green and export FinanceApi 2026-01-12 17:45:15 +07:00
Rivaldi A N S 548dfd19e5 Merge branch 'feat/FE/daily-checklist' into 'development'
[FEAT/FE] Daily Checklist

See merge request mbugroup/lti-web-client!160
2026-01-12 10:42:20 +00:00
ValdiANS f0a6dd4a5a Merge branch 'development' into feat/FE/daily-checklist 2026-01-12 17:37:20 +07:00
Rivaldi A N S 7159114733 Merge branch 'fix/submit-form' into 'development'
[FIX/FE] Create Custom Hooks for Formik Error List

See merge request mbugroup/lti-web-client!159
2026-01-12 10:35:24 +00:00
Rivaldi A N S e300a60b5a Merge branch 'dev/randy' into 'fix/submit-form'
[FIX/FE] Create Custom Hooks for Formik Error List

See merge request mbugroup/lti-web-client!158
2026-01-12 10:34:36 +00:00
ValdiANS 4cbd83a6fa feat: add document_urls property in DetailDailyChecklist type 2026-01-12 17:32:34 +07:00
ValdiANS b39202111e feat: create Document type 2026-01-12 17:32:07 +07:00
ValdiANS a891608d13 feat: add uploadImage and exportDailyChecklistReportToExcel method 2026-01-12 17:31:55 +07:00
ValdiANS aff05c6b1a feat: add export to excel 2026-01-12 17:31:35 +07:00
ValdiANS 70eac011f3 chore: remove export button 2026-01-12 17:31:07 +07:00
ValdiANS 10e843aebf chore: refresh phase after modifying activity 2026-01-12 17:31:00 +07:00
ValdiANS a24f51dad3 feat: show existing document 2026-01-12 17:30:44 +07:00
ValdiANS 9245285fe2 feat: add upload document in daily checklist 2026-01-12 17:30:30 +07:00
randy-ar eb1337292b Merge branch 'development' of https://gitlab.com/mbugroup/lti-web-client into dev/randy 2026-01-12 17:19:53 +07:00
randy-ar aa114c164b fix(FE): create hooks for formik error list and integrate alert error list for finance and master data modules 2026-01-12 17:19:16 +07:00
randy-ar 0f9849c0ac fix(FE): fixing sapronak calculation get kandangId state 2026-01-12 15:38:07 +07:00
randy-ar 36b167dafb fix(FE): add production standard in detail project flock 2026-01-12 15:13:02 +07:00
ValdiANS 1002c6c437 feat: create Daily Checklist Configuration type 2026-01-12 14:42:41 +07:00
ValdiANS 25352659f3 feat: create Daily Checklist Configuration Api Service 2026-01-12 14:42:33 +07:00
ValdiANS dfac7f84ff feat: create MasterConfigurationContent component 2026-01-12 14:42:14 +07:00
ValdiANS c099314bdb feat: add route permission for daily checklist master configuration 2026-01-12 14:42:02 +07:00
ValdiANS 404019f181 feat: add Konfigurasi menu 2026-01-12 14:41:46 +07:00
ValdiANS 8afd8c6382 feat: create master daily checklist configuration page 2026-01-12 14:41:34 +07:00
Rivaldi A N S ef4ad07547 Merge branch 'fix/adjustment-submission-form-biaya' into 'development'
[FIX/FE] Submission Form Biaya Handling

See merge request mbugroup/lti-web-client!157
2026-01-12 07:41:15 +00:00
rstubryan 31aa8e7652 Merge branch 'development' of gitlab.com:mbugroup/lti-web-client into fix/adjustment-submission-form-biaya 2026-01-12 14:33:42 +07:00
Rivaldi A N S 994967e940 Merge branch 'dev/randy' into 'development'
[FEAT/FE] Report Sapronak Calculation per Kandang

See merge request mbugroup/lti-web-client!156
2026-01-12 07:30:47 +00:00
rstubryan 90eef08f9b refactor(FE): Enable sales tab and fetch sales data 2026-01-12 14:30:34 +07:00
rstubryan def2167803 Merge branch 'development' of gitlab.com:mbugroup/lti-web-client into fix/adjustment-submission-form-biaya 2026-01-12 14:13:09 +07:00
rstubryan bf834cf79b refactor(FE): Allow null for select fields and track id fields 2026-01-12 14:12:12 +07:00
randy-ar 470add1563 fix(FE): fix report debt supplier filters date type 2026-01-12 14:11:45 +07:00
randy-ar 114658f198 Merge branch 'development' of https://gitlab.com/mbugroup/lti-web-client into dev/randy 2026-01-12 14:01:35 +07:00
randy-ar d01bfe33a8 fix(FE): fix pagination report debt supplier 2026-01-12 14:01:03 +07:00
Rivaldi A N S 47ba16b20a Merge branch 'fix/finance-and-recording-adjustment' into 'development'
[FIX/FE] Adjust Biaya and Recording

See merge request mbugroup/lti-web-client!155
2026-01-12 06:46:30 +00:00
randy-ar d6c6211937 feat(FE): report sapronak calculation per kandang 2026-01-12 13:44:03 +07:00
ValdiANS 536b1c5b01 chore: uninstall supabase 2026-01-12 13:05:16 +07:00
ValdiANS f84fcb78b8 chore: delete supabase related code 2026-01-12 13:04:46 +07:00
ValdiANS aec5c89979 feat: create Daily Checklist Report type 2026-01-12 12:56:42 +07:00
ValdiANS f46a0610f5 feat: integrate Daily Checklist Report to API 2026-01-12 12:55:31 +07:00
randy-ar d879acc001 feat(FE): workaround general information closing kandang 2026-01-12 12:44:28 +07:00
rstubryan 8516929056 refactor(FE): Rename hand_* to hen_* and egg_mesh to egg_mass 2026-01-12 11:56:52 +07:00
rstubryan 595f2b5e9b refactor(FE): Require approval step 5 for realization 2026-01-12 11:32:17 +07:00
rstubryan 6a4e8776bd refactor(FE): Update approval steps and PDF nominal logic 2026-01-12 11:19:01 +07:00
rstubryan ec16c6c47e refactor(FE): Add Unit VP approval and rename Manager 2026-01-12 11:11:11 +07:00
rstubryan 2b2dd0a026 feat(FE): Add 5MB file size check and show form errors 2026-01-12 10:56:02 +07:00
ValdiANS a8c12d0c92 feat(FE): create type for daily checklist dashboard 2026-01-12 10:47:00 +07:00
ValdiANS 334bd08e60 feat: integrate Daily Checklist Dashboard to API integration 2026-01-12 10:46:19 +07:00
Rivaldi A N S ddd9a3d2da Merge branch 'feat/finance-debt-supplier-report' into 'development'
[FEAT/FE] Debt Supplier Report

See merge request mbugroup/lti-web-client!154
2026-01-12 02:55:53 +00:00
Rivaldi A N S 2b1d5290f3 Merge branch 'dev/randy' into 'feat/finance-debt-supplier-report'
[FEAT/FE] Debt Supplier Report

See merge request mbugroup/lti-web-client!153
2026-01-12 02:55:10 +00:00
randy-ar 935588b30e feat(FE): API integration debt supplier report 2026-01-11 21:07:01 +07:00
randy-ar 677025b4a2 feat(FE): API integration debt supplier report 2026-01-11 21:02:58 +07:00
randy-ar 0da9f9d651 feat(FE): API integration dashboard 2026-01-11 19:15:22 +07:00
randy-ar c752cad057 Merge branch 'development' of https://gitlab.com/mbugroup/lti-web-client into dev/randy 2026-01-11 00:16:49 +07:00
randy-ar cdfb59a70b feat(FE): adding report debt supplier report with temporary data types and dummy data 2026-01-11 00:16:12 +07:00
Rivaldi A N S 91fcbffab6 Merge branch 'feat/dashboard' into 'development'
[FEAT/FE] Slicing UI Dashboard and Integrate With Dummy Data

See merge request mbugroup/lti-web-client!152
2026-01-10 07:34:57 +00:00
Rivaldi A N S 33e3b86b82 Merge branch 'dev/randy' into 'feat/dashboard'
[FEAT/FE] Slicing UI Dashboard and Integrate With Dummy Data

See merge request mbugroup/lti-web-client!151
2026-01-10 07:33:05 +00:00
randy-ar a012707bae chore(FE): pull development 2026-01-10 08:11:45 +07:00
randy-ar 00bc644ea9 Merge branch 'development' of https://gitlab.com/mbugroup/lti-web-client into dev/randy 2026-01-10 08:10:18 +07:00
randy-ar 126346dc52 feat(FE): slicing ui dashboard, API integration with dummy data and form validation 2026-01-10 08:09:29 +07:00
randy-ar 777b06c690 feat(FE): slicing UI dashboard and define data types 2026-01-09 16:48:38 +07:00
Rivaldi A N S 1f96100390 Merge branch 'dev/restu' into 'development'
[FEAT/FE] Add Customer Payment Control Report Page

See merge request mbugroup/lti-web-client!150
2026-01-09 09:30:35 +00:00
rstubryan 7e5898a253 Merge branch 'development' of gitlab.com:mbugroup/lti-web-client into dev/restu 2026-01-09 15:37:49 +07:00
Rivaldi A N S 86651d3f3f Merge branch 'feat/FE/daily-checklist' into 'development'
[FEAT/FE] Daily Checklist

See merge request mbugroup/lti-web-client!149
2026-01-09 08:35:03 +00:00
ValdiANS ebd3e14f0e Merge branch 'development' into feat/FE/daily-checklist 2026-01-09 15:32:27 +07:00
ValdiANS e9a1f4298f chore: add activity_count 2026-01-09 15:30:58 +07:00
ValdiANS cc8f258c41 feat: create Daily Checklist type 2026-01-09 15:30:45 +07:00
ValdiANS f60a07bc5b feat: create Daily Checklist API Service 2026-01-09 15:30:37 +07:00
ValdiANS 6dc93b1065 chore: add activity_count 2026-01-09 15:28:29 +07:00
ValdiANS 76c68d0d79 chore: make select scrollable 2026-01-09 15:23:56 +07:00
rstubryan f1ed22ff22 refactor(FE): Format numbers and currencies in payment XLSX 2026-01-09 15:16:54 +07:00
rstubryan d478ef5e22 refactor(FE): Remove date_type filter and hardcode filter_by 2026-01-09 15:08:21 +07:00
rstubryan 6643fe5a60 refactor(FE): Move filters into modal and refactor filter state 2026-01-09 14:58:41 +07:00
rstubryan 7a6b003cb9 feat(FE): Add Customer Payment report with export features 2026-01-09 14:42:23 +07:00
rstubryan e6cee4a93a feat(FE): Add finance report API and customer payment types 2026-01-09 14:41:21 +07:00
rstubryan c61ef5471b feat(FE): Add finance report route and menu link 2026-01-09 14:40:27 +07:00
ValdiANS c9c618e3f8 feat: integrate DetailDailyChecklistContent component to API 2026-01-09 14:13:14 +07:00
ValdiANS ceb7cb6b2d feat: integrate ListDailyChecklistContent component to API 2026-01-09 14:12:36 +07:00
ValdiANS f765895988 feat: integrate DailyChecklistContent component to API 2026-01-09 14:12:12 +07:00
ValdiANS b1715172db chore: update react and react-dom to safe version 2026-01-09 14:10:31 +07:00
Rivaldi A N S d84b2583d8 Merge branch 'dev/restu' into 'development'
[FEAT/FE] Refactor Closing (Keuangan) & Takeout Closing (Penjualan)

See merge request mbugroup/lti-web-client!148
2026-01-09 06:24:06 +00:00
rstubryan f38cebc0d9 refactor(FE): Limit Location select options to 100 2026-01-09 13:02:20 +07:00
rstubryan 7951754722 refactor(FE): Generate HPP table from static rows with defaults 2026-01-09 12:46:19 +07:00
rstubryan 4fc689898f refactor(FE): Use optional chaining for summary_hpp fields 2026-01-09 12:33:21 +07:00
rstubryan 69d7f65b76 refactor(FE): Disable sales tab and related data fetching 2026-01-09 12:31:53 +07:00
Rivaldi A N S b626c2805f Merge branch 'dev/restu' into 'development'
[FEAT/FE] Add Uniformity Chart Data (Ideal and Outside Range)

See merge request mbugroup/lti-web-client!147
2026-01-09 03:51:22 +00:00
rstubryan 97c16ce596 refactor(FE): Initialize and use current gauge week index 2026-01-09 10:46:05 +07:00
rstubryan 88e3ec7bbc refactor(FE): Reduce default query limit to 100 2026-01-09 09:48:54 +07:00
rstubryan 3ce30115f8 refactor(FE): Add validation and error messages to filter modal 2026-01-09 09:30:51 +07:00
rstubryan 4fdfe63dc9 refactor(FE): Remove document_path from movement payload 2026-01-09 09:24:46 +07:00
rstubryan badb1e141a refactor(FE): Deduplicate delivery documents by filename 2026-01-09 08:29:21 +07:00
rstubryan c894f26d18 refactor(FE): Handle ideal/outside ranges in uniformity tooltip 2026-01-08 13:52:23 +07:00
rstubryan 3b9599d169 refactor(FE): Set peer flag in package-lock.json 2026-01-08 13:51:28 +07:00
rstubryan 9a9a9c0cb5 Merge branch 'development' of gitlab.com:mbugroup/lti-web-client into dev/restu 2026-01-08 13:18:22 +07:00
Rivaldi A N S b69126ed84 Merge branch 'feat/FE/daily-checklist' into 'development'
[FEAT/FE] Daily Checklist

See merge request mbugroup/lti-web-client!146
2026-01-08 06:18:03 +00:00
rstubryan 91b0bf7c27 Merge branch 'development' of gitlab.com:mbugroup/lti-web-client into dev/restu 2026-01-08 13:15:31 +07:00
Rivaldi A N S 1b2a45f9ac Merge branch 'feat/FE/refactor-submission-form' into 'development'
[FEAT/FE] Refactor Submission Form (Alert Error and Submit Button) & Adjust Uniformity Page

See merge request mbugroup/lti-web-client!145
2026-01-08 06:13:10 +00:00
rstubryan cb62416552 refactor(FE): Increase file upload limit to 5 MB 2026-01-08 12:40:35 +07:00
rstubryan d2781b0a89 refactor(FE): Validate Uniformity form and show error list 2026-01-08 12:38:07 +07:00
rstubryan 325f3f1bd8 refactor(FE): Display form error list in purchase forms 2026-01-08 12:35:16 +07:00
rstubryan 346c731c42 refactor(FE): Display Formik validation errors in alert list 2026-01-08 12:31:25 +07:00
rstubryan 61766d3255 refactor(FE): Show validation error list before submit 2026-01-08 12:27:26 +07:00
rstubryan 0898892f15 feat(FE): Show unique form errors and improve product form 2026-01-08 11:11:58 +07:00
rstubryan 3dd4a9cebc refactor(FE): Reset submission flag when clearing uniformity filters 2026-01-08 10:51:47 +07:00
rstubryan 549e15499c feat(FE): Add CV field and section bottom margin 2026-01-08 10:42:07 +07:00
rstubryan a4a07f2ce9 refactor(FE): Remove on-demand weight fetch and show empty state 2026-01-08 10:39:21 +07:00
rstubryan 6930696692 refactor(FE): Lazy-load uniformity details and show spinner 2026-01-08 10:37:17 +07:00
rstubryan 7df9559f35 refactor(FE): Move sampling and result tables to UniformityDetail 2026-01-08 10:29:08 +07:00
rstubryan eeeb0a404c Merge branch 'development' of gitlab.com:mbugroup/lti-web-client into feat/FE/refactor-submission-form 2026-01-08 10:23:50 +07:00
rstubryan b3c4a438ad refactor(FE): Use chart_data for Uniformity and add week nav 2026-01-08 10:17:31 +07:00
ValdiANS a9e6f7155e Merge branch 'development' into feat/FE/daily-checklist 2026-01-08 10:04:32 +07:00
ValdiANS 3d94474d7c chore: add supabase client 2026-01-08 09:56:29 +07:00
ValdiANS 4872a53a25 chore: adjust styling for search input 2026-01-08 09:56:05 +07:00
rstubryan 662dec38bc refactor(FE): Add with_chart param to date filter 2026-01-08 09:51:10 +07:00
Rivaldi A N S 9f0cefe91c Merge branch 'dev/randy' into 'development'
[FEAT/FE] Adding helper function for alert list error formik

See merge request mbugroup/lti-web-client!144
2026-01-08 02:50:32 +00:00
rstubryan 3cb6bfcf52 feat(FE): Add chart data types to Uniformity API types 2026-01-08 09:47:33 +07:00
ValdiANS 7d4869fbdc feat: create type for Phase 2026-01-08 09:41:50 +07:00
ValdiANS 4ae36ee3f0 feat: create type for Phase Activity 2026-01-08 09:41:44 +07:00
ValdiANS 21acb09f0c feat: create type for Master Employee 2026-01-08 09:41:24 +07:00
ValdiANS f17bc1493b feat: create Phase API Service 2026-01-08 09:41:01 +07:00
ValdiANS 6943cd3903 feat: create Phase Activity API Service 2026-01-08 09:40:53 +07:00
ValdiANS 14b63dd0f1 feat: create Employee API Service 2026-01-08 09:40:40 +07:00
ValdiANS db4d9ad38c feat: integrate MasterEmployeeContent component to API 2026-01-08 09:40:02 +07:00
ValdiANS 06dd9a3609 feat: integrate MasterAktivitasContent component to API 2026-01-08 09:39:50 +07:00
ValdiANS 5ba58c92d4 feat: add daily checklist route permissions 2026-01-08 09:39:21 +07:00
ValdiANS d44de5a363 feat: add daily checklist menu 2026-01-08 09:39:02 +07:00
ValdiANS b70ae164e1 feat: format pathname 2026-01-08 09:38:42 +07:00
ValdiANS f89236bb5e feat: create Daily Checklist Report page 2026-01-08 09:38:32 +07:00
ValdiANS 4759a82034 feat: create Master Data Employee page 2026-01-08 09:38:22 +07:00
ValdiANS 866bd90b3d feat: create Master Activity page 2026-01-08 09:38:09 +07:00
ValdiANS b0dfc7f31c feat: create Detail Daily Checklist page 2026-01-08 09:37:57 +07:00
ValdiANS 561a9fe186 feat: add layout file for detail of daily checklist list page 2026-01-08 09:37:35 +07:00
rstubryan dbdfd2c50b refactor(FE): Remove location, project_flock and kandang fields 2026-01-08 09:37:05 +07:00
ValdiANS afc102e618 feat: create Daily Checklist List page 2026-01-08 09:36:54 +07:00
ValdiANS 7736fce5bb feat: create Daily Checklist Dashboard page 2026-01-08 09:36:43 +07:00
ValdiANS 04dcf110a3 feat: create Daily Checklist page 2026-01-08 09:35:58 +07:00
ValdiANS 53bca6170f feat: add SonnerToaster 2026-01-08 09:35:46 +07:00
ValdiANS 20e27dccc1 chore: import figma-make theme styling 2026-01-08 09:34:52 +07:00
rstubryan 965dc01e86 feat(FE): Add location, project flock, and kandang fields 2026-01-08 09:27:51 +07:00
randy-ar 64a0a9c8a8 Merge branch 'development' of https://gitlab.com/mbugroup/lti-web-client into dev/randy 2026-01-08 09:25:20 +07:00
randy-ar 0ed30e184b feat(FE): implement alert error list in marketing module 2026-01-08 09:19:55 +07:00
randy-ar 13205ca80a feat(FE): adding alert errors message for project flock and fixing bug approval status in chickin 2026-01-08 08:59:27 +07:00
rstubryan 0d6e229ee5 refactor(FE): Allow null for document_path in schema 2026-01-07 18:11:12 +07:00
rstubryan 319afa3faf refactor(FE): Require positive IDs in movement form schema 2026-01-07 18:01:26 +07:00
rstubryan 6da6cf699f refactor(FE): Require warehouse IDs to be at least 1 2026-01-07 17:50:44 +07:00
rstubryan ca830f8e3d Merge branch 'development' of gitlab.com:mbugroup/lti-web-client into feat/FE/refactor-submission-form 2026-01-07 17:42:35 +07:00
rstubryan 22be41058f refactor(FE): Normalize Tailwind classnames in MovementForm 2026-01-07 17:35:55 +07:00
rstubryan c4debcecce refactor(FE): Add default empty product and delivery rows 2026-01-07 16:18:02 +07:00
rstubryan 6fdff6706d refactor(FE): Clear file input on form reset 2026-01-07 15:54:16 +07:00
rstubryan d5b4111ae4 refactor(FE): Remove travel_document_path field and handling 2026-01-07 15:46:58 +07:00
Rivaldi A N S 2df86e7be8 Merge branch 'fix/chickins-approval' into 'development'
[FIX/FE] Fix chickins approval

See merge request mbugroup/lti-web-client!143
2026-01-07 08:27:40 +00:00
Rivaldi A N S 6efe44ba55 Merge branch 'dev/randy' into 'fix/chickins-approval'
[FIX/FE] Fix chickins approval

See merge request mbugroup/lti-web-client!142
2026-01-07 08:24:59 +00:00
randy-ar c766f53753 fix(FE): fix chickins approvals status 2026-01-07 15:16:40 +07:00
rstubryan 38dfeec892 refactor(FE): Move movement error to top and remove isValid check 2026-01-07 15:11:36 +07:00
rstubryan cf8ed9ccad refactor(FE): Use expedition vendor id fallback in mapping 2026-01-07 15:06:43 +07:00
rstubryan 90c61cbdf6 refactor(FE): Only disable submit button during submission 2026-01-07 15:01:57 +07:00
rstubryan bfcdb9883d refactor(FE): Move purchase order error alert below heading 2026-01-07 14:53:24 +07:00
rstubryan b0a1b837d0 refactor(FE): Move error alert to top of purchase forms 2026-01-07 14:45:38 +07:00
rstubryan 09ae619829 refactor(FE): Stop blocking Submit on form validity 2026-01-07 14:41:54 +07:00
rstubryan 59f4528841 refactor(FE): Stop disabling Submit when form is invalid 2026-01-07 14:39:43 +07:00
rstubryan d049f6c34f refactor(FE): Tighten product form validation and layout 2026-01-07 14:21:37 +07:00
rstubryan 8b7ed9e46b refactor(FE): Move error alert above form 2026-01-07 14:09:47 +07:00
rstubryan e6172be81e refactor(FE): Allow submit when invalid and move error alert 2026-01-07 14:08:04 +07:00
rstubryan 324b9b14ef refactor(FE): Move form error above fields 2026-01-07 14:07:02 +07:00
rstubryan a10c20394d Merge branch 'development' of gitlab.com:mbugroup/lti-web-client into feat/FE/refactor-submission-form 2026-01-07 14:01:45 +07:00
rstubryan ff2d53a0b7 Merge branch 'development' of gitlab.com:mbugroup/lti-web-client into dev/restu 2026-01-07 14:01:30 +07:00
Rivaldi A N S 42d8896ab7 Merge branch 'fix/FE/route-permission' into 'development'
[FIX/FE] Format pathname for route permission

See merge request mbugroup/lti-web-client!141
2026-01-07 06:57:59 +00:00
ValdiANS 50d499005d fix: format pathname 2026-01-07 13:57:00 +07:00
Rivaldi A N S b421bc48d0 Merge branch 'fix/FE/US-340/marketing-report' into 'development'
[FIX/FE] Adjust marketing report endpoint

See merge request mbugroup/lti-web-client!140
2026-01-07 06:03:34 +00:00
ValdiANS f7986149e8 fix: adjust marketing report endpoint 2026-01-07 13:01:32 +07:00
rstubryan 309a9ecc86 refactor(FE): Increase upload file size limit to 5 MB 2026-01-07 11:38:28 +07:00
ValdiANS d30979f5cd feat: add figma-make style 2026-01-07 11:21:28 +07:00
Rivaldi A N S 43cd3abe02 Merge branch 'dev/randy' into 'development'
[FIX/FE] Adding current stock information in SO and DO marketing

See merge request mbugroup/lti-web-client!139
2026-01-07 04:19:55 +00:00
ValdiANS 770f363c60 feat: add figma make components 2026-01-07 10:59:12 +07:00
ValdiANS 88c6c863e7 feat: install dependencies for components from figma make 2026-01-07 10:58:09 +07:00
randy-ar ba84e718cb Merge branch 'development' of https://gitlab.com/mbugroup/lti-web-client into dev/randy 2026-01-07 10:52:12 +07:00
Rivaldi A N S fed2bf7878 Merge branch 'dev/restu' into 'development'
[HOTFIX/FE][US#281-391] Adjustment Uniformity, Purchase and Expense

See merge request mbugroup/lti-web-client!138
2026-01-07 02:15:53 +00:00
rstubryan 6f90bd604a feat(FE): Enforce 2MB file limit and improve FileInput 2026-01-06 20:38:51 +07:00
rstubryan fa199e4879 refactor(FE): Support add/edit type and use ProductPrice for add 2026-01-06 20:25:09 +07:00
rstubryan 46c06ea548 refactor(FE): Support add/edit type and use ProductPrice for add 2026-01-06 20:24:29 +07:00
rstubryan fd868eaa0c refactor(FE): Add ProductPrice and SellingPrice fields to types 2026-01-06 20:12:47 +07:00
rstubryan 8dfccf25d8 refactor(FE): Truncate delivery document name in MovementForm 2026-01-06 19:32:13 +07:00
randy-ar 5d8dfca3b5 fix(FE): shows delivery number when status marketing is delivery in marketing detail page 2026-01-06 16:06:26 +07:00
randy-ar aee0ad8a20 feat(FE): adding stok information in form repeater SO and DO 2026-01-06 14:42:52 +07:00
rstubryan 2fa086bb32 refactor(FE): Prefer latest_approval action and add file_name 2026-01-06 14:01:01 +07:00
randy-ar 0af612703a fix(FE): remove pullet table, change doc table to conditional data base on project flock category 2026-01-06 13:46:18 +07:00
rstubryan f22c4e4798 refactor(FE): Adjust expense status badge colors 2026-01-06 13:32:59 +07:00
randy-ar 841aadc107 fix(FE): fixing issue reject modal show up when creating project flock 2026-01-06 13:29:05 +07:00
rstubryan f31a80340b refactor(FE): Check delete API response before showing toast 2026-01-06 11:04:54 +07:00
rstubryan 727fd2ad43 Merge branch 'development' of gitlab.com:mbugroup/lti-web-client into dev/restu 2026-01-06 10:46:24 +07:00
rstubryan a4275f4b66 refactor(FE): Support UniformityDetail in confirmation preview 2026-01-06 10:46:05 +07:00
Rivaldi A N S 9ac5e0ee76 Merge branch 'dev/restu' into 'development'
[HOTFIX/FE][US#439-281-352-391] Fix Issue Based on UAT Revision and Taiga

See merge request mbugroup/lti-web-client!137
2026-01-06 03:30:14 +00:00
rstubryan 24499d110a refactor(FE): Refactor Uniformity charts to use API data 2026-01-06 08:36:23 +07:00
rstubryan c24aebe02d refactor(FE): Highlight ideal ranges in Uniformity charts 2026-01-05 15:29:52 +07:00
rstubryan fd32b55ad9 refactor(FE): Provide defaults for missing info_umum fields 2026-01-05 15:13:00 +07:00
rstubryan d2b19cbd7b refactor(FE): Force form remount on initialValues change 2026-01-05 15:07:09 +07:00
rstubryan 2c29cffa45 refactor(FE): Remove overflow-visible class from table wrapper 2026-01-05 14:50:10 +07:00
rstubryan 476cf2fa29 Merge branch 'development' of gitlab.com:mbugroup/lti-web-client into dev/restu 2026-01-05 13:47:41 +07:00
Rivaldi A N S 1797498df2 Merge branch 'dev/randy' into 'development'
[FIX/FE][US#304] Adjust Permission for Finance and Marketing

See merge request mbugroup/lti-web-client!135
2026-01-05 06:47:30 +00:00
randy-ar f7d1beffcf Merge branch 'development' of https://gitlab.com/mbugroup/lti-web-client into dev/randy 2026-01-05 13:46:45 +07:00
rstubryan ac6e7c6d36 Merge branch 'development' of gitlab.com:mbugroup/lti-web-client into dev/restu 2026-01-05 13:46:33 +07:00
rstubryan d7ef86e24b refactor(FE): Add default page/limit to location and flock queries 2026-01-05 13:46:21 +07:00
Rivaldi A N S 3dff72b0f0 Merge branch 'feat/FE/US-335/production-data-report' into 'development'
[FEAT/FE][US#335] Production Data Report

See merge request mbugroup/lti-web-client!136
2026-01-05 06:46:17 +00:00
ValdiANS eea76e77a8 chore: update displayed data 2026-01-05 13:42:20 +07:00
randy-ar 11f9a685a8 fix(FE): permission for balance injection in finance detail page 2026-01-05 13:42:01 +07:00
ValdiANS c863ebc2af chore: update ClosingProductionData type 2026-01-05 13:41:16 +07:00
randy-ar e8aea0a27e fix(FE): resolve merge conflict 2026-01-05 13:13:37 +07:00
randy-ar 79cf777b11 fix(FE): merge with branch development 2026-01-05 13:11:03 +07:00
randy-ar 203782c258 fix(FE): adjust permission finance 2026-01-05 13:05:10 +07:00
Rivaldi A N S 0a0a1a23f9 Merge branch 'feat/FE/US-81/production-result-report' into 'development'
[FEAT/FE][US#81] Production Result Report

See merge request mbugroup/lti-web-client!134
2026-01-05 04:34:21 +00:00
ValdiANS f9f4c5b67c Merge branch 'development' into feat/FE/US-81/production-result-report 2026-01-05 11:30:28 +07:00
ValdiANS 98107373e8 Merge branch 'development' into feat/FE/US-81/production-result-report 2026-01-05 11:30:04 +07:00
ValdiANS 9838cf347b feat(FE-443,444): create exportProductionResultToExcel method 2026-01-05 11:27:38 +07:00
ValdiANS f183ee5c7a chore: update permission name 2026-01-05 11:23:47 +07:00
ValdiANS 2ab2cd6d99 chore: adjust header column styling 2026-01-05 11:19:59 +07:00
ValdiANS 1571d79685 chore: disabled export button if filter is not selected yet 2026-01-05 11:18:19 +07:00
ValdiANS 5e3648b385 chore: update permission name from lti.finance.transaction to lti.finance.transactions 2026-01-05 11:11:34 +07:00
rstubryan 62b05bf9c0 refactor(FE): Add week navigation to UniformityGaugeChart 2026-01-05 09:11:54 +07:00
rstubryan 7579cd5533 refactor(FE): Remove Kandang prop and center Uniformity gauge 2026-01-05 08:56:09 +07:00
rstubryan 174e5ed1a3 Merge branch 'development' of gitlab.com:mbugroup/lti-web-client into dev/restu 2026-01-05 08:36:15 +07:00
kris c6e9e98ce1 Update .gitlab-ci.yml file 2026-01-03 12:42:09 +00:00
randy-ar 9562ce7b40 fix(FE): remove bypass permission in marketing detail and form page 2026-01-02 15:11:06 +07:00
rstubryan 57fa67c05a refactor(FE): Support MovementDocument in movement form 2026-01-02 14:22:57 +07:00
Rivaldi A N S eadb08879d Merge branch 'fix/FE/redirect-to-sso' into 'development'
[FIX/FE] Redirect to SSO

See merge request mbugroup/lti-web-client!133
2026-01-02 07:10:30 +00:00
Rivaldi A N S 50b8b77f22 Merge branch 'dev/randy' into 'development'
[FIX/FE][US#284] Fix sapronak calculation data types

See merge request mbugroup/lti-web-client!132
2026-01-02 06:55:56 +00:00
ValdiANS 045913d05f chore: lint 2026-01-02 13:28:46 +07:00
ValdiANS b53c8b99a0 chore: refresh user session when user first enter the web 2026-01-02 12:40:07 +07:00
randy-ar f23d369e02 fix(FE): integrate search filter marketing 2026-01-02 10:15:50 +07:00
randy-ar d6b8b10183 fix(FE): remove bypass permission and integrate table filter 2026-01-02 10:04:56 +07:00
rstubryan 1c77deeee7 refactor(FE): Move Movement FormData into API service 2026-01-02 10:00:14 +07:00
rstubryan 6a3d2c0dcd refactor(FE): Drop refresh prop and simplify UniformityTable 2026-01-02 09:07:30 +07:00
rstubryan b1f4b4dc4b refactor(FE): Refresh uniformities on successful mutation 2026-01-02 09:03:42 +07:00
rstubryan a518895096 refactor(FE): Conditionally render sampling and result sections 2026-01-02 08:47:08 +07:00
randy-ar 046fb74cab fix(FE-284): adjust data types for sapronak calculation 2025-12-31 15:18:17 +07:00
kris 00f09364b1 Update .gitlab-ci.yml file 2025-12-31 07:44:43 +00:00
kris 02c5cddc94 Update .gitlab-ci.yml file 2025-12-31 07:32:33 +00:00
kris 9f079c1e52 Update .gitlab-ci.yml file 2025-12-31 07:26:27 +00:00
rstubryan c32074d72c Merge branch 'development' of gitlab.com:mbugroup/lti-web-client into dev/restu 2025-12-31 14:12:56 +07:00
kris 7d46e3dc2e Update .gitlab-ci.yml file 2025-12-31 06:57:40 +00:00
rstubryan e7b53efa4b Merge branch 'development' of gitlab.com:mbugroup/lti-web-client into dev/restu 2025-12-31 13:57:28 +07:00
Rivaldi A N S aebb9a0b28 Merge branch 'hotfix-finance-and-production' into 'development'
[HOTFIX/FE][US][TASK] Hotfix bypass permission di marketing

See merge request mbugroup/lti-web-client!131
2025-12-31 06:42:53 +00:00
randy-ar 4ec62c936e hotfix(FE): bypass permission marketing 2025-12-31 13:32:11 +07:00
randy-ar f7ae1f835f Merge branch 'development' of https://gitlab.com/mbugroup/lti-web-client into hotfix-finance-and-production 2025-12-31 13:29:09 +07:00
randy-ar 3769309ce3 hotfix(FE): bypass permission marketinh 2025-12-31 13:28:27 +07:00
randy-ar 15b3151c5f fix(FE): fix perhitungan sapronak 2025-12-31 13:18:22 +07:00
Rivaldi A N S b0707db551 Merge branch 'hotfix/master-data' into 'development'
[HOTFIX/FE] Master Data Warehouse

See merge request mbugroup/lti-web-client!130
2025-12-31 06:12:22 +00:00
randy-ar 1a8d794a66 fix(FE): fix finance party select 2025-12-31 13:10:58 +07:00
ValdiANS 1b7e8a342f fix: fix onInputChange of kandang select input 2025-12-31 13:10:58 +07:00
rstubryan f08fae4f77 refactor(FE): Enable reinitialize and map expedition vendor 2025-12-31 13:00:48 +07:00
randy-ar 6cd09a413d fix(FE): fix delete reseponse project flock 2025-12-31 12:25:08 +07:00
Rivaldi A N S 84eb34a9dd Merge branch 'dev/restu' into 'development'
[HOTFIX/FE] Fix Issue Purchase Expedition Vendor Name

See merge request mbugroup/lti-web-client!129
2025-12-31 05:16:54 +00:00
rstubryan 37317ed95c fix(FE): Make expedition_vendor optional and nullable 2025-12-31 11:58:45 +07:00
rstubryan 201c9249cc fix(FE): Make expedition_vendor optional and nullable 2025-12-31 11:58:14 +07:00
rstubryan 46dfacae23 refactor(FE-Fix): Use optional chaining for expedition vendor name 2025-12-31 11:53:40 +07:00
Rivaldi A N S d856b35e24 Merge branch 'feat/FE/US-281/TASK-316-317-slicing-ui-and-integrate-api-daily-recording-growing-uniformity-page' into 'development'
[FEAT/FE][US#281/TASK-316-317] Uniformity Page and Adjustment Purchase Accept Issue

See merge request mbugroup/lti-web-client!128
2025-12-31 04:29:45 +00:00
rstubryan 28c94e3e1d refactor(FE): Show expedition vendor name in order detail 2025-12-31 11:21:35 +07:00
rstubryan a1e8f582ba refactor(FE-316,317,438): Move Uniformity feature under production
namespace
2025-12-31 11:17:26 +07:00
rstubryan f3f552bd16 Merge branch 'development' of gitlab.com:mbugroup/lti-web-client into feat/FE/US-281/TASK-316-317-slicing-ui-and-integrate-api-daily-recording-growing-uniformity-page 2025-12-31 11:02:37 +07:00
rstubryan 5af00faa32 feat(FE): Add travel document upload to purchase form 2025-12-31 11:02:06 +07:00
Rivaldi A N S f0dcb6b8ca Merge branch 'feat/FE/refresh-user-session' into 'development'
[FEAT/FE] Refresh user session

See merge request mbugroup/lti-web-client!127
2025-12-31 03:47:29 +00:00
rstubryan e32b9ddcb2 feat(FE-316): Display created uniformity in confirmation preview 2025-12-31 10:37:21 +07:00
ValdiANS 57ef4109f7 feat: refresh user session 2025-12-31 10:34:07 +07:00
rstubryan ef3611e7fc refactor(FE-316): Rename document_name to file_name and add standard 2025-12-31 10:20:59 +07:00
rstubryan 0090961ec0 refactor(FE-316): Support localized uniformity statuses and fields 2025-12-31 10:17:39 +07:00
rstubryan 640cf26970 Merge branch 'development' of gitlab.com:mbugroup/lti-web-client into feat/FE/US-281/TASK-316-317-slicing-ui-and-integrate-api-daily-recording-growing-uniformity-page 2025-12-31 10:03:37 +07:00
Rivaldi A N S d1d0692e2e Merge branch 'feat/FE/US-281-439/TASK-440-441-recording-page-and-form-adjustment' into 'development'
[FEAT/FE][US#281-439/TASK-440-441] Recording Page and Form Adjustment

See merge request mbugroup/lti-web-client!125
2025-12-31 03:01:09 +00:00
rstubryan 6b13794ee5 Merge branch 'development' of gitlab.com:mbugroup/lti-web-client into feat/FE/US-281-439/TASK-440-441-recording-page-and-form-adjustment 2025-12-31 09:44:10 +07:00
rstubryan 8e88355894 refactor(FE-441): Refactor RecordingForm layout and labels 2025-12-31 09:43:05 +07:00
Rivaldi A N S 1b98e5d4d8 Merge branch 'feat/FE/US-81/production-result-report' into 'development'
[FEAT/FE][US#81] Production Result Report

See merge request mbugroup/lti-web-client!126
2025-12-31 02:42:23 +00:00
rstubryan d8daf09844 refactorF(FE-441): Display formatted fcr_std in RecordingForm 2025-12-31 09:20:49 +07:00
ValdiANS 0bb9aee139 chore: set dummy permission 2025-12-31 09:09:55 +07:00
Rivaldi A N S 306b8d3bf3 Merge branch 'hotfix/dashboard-permission' into 'development'
[HOTFIX/FE][US#390] Hotfix temporary permission for dashboard and finance

See merge request mbugroup/lti-web-client!124
2025-12-31 02:06:42 +00:00
rstubryan 2bf764a05c refactor(FE-441): Display '-' for empty/zero numeric fields 2025-12-31 09:02:15 +07:00
rstubryan 6c3285f624 refactor(FE-441): Make recording metrics grid responsive 2025-12-31 08:54:15 +07:00
rstubryan afb79b0589 feat(FE-441): Format and display intake, hand house, and totals 2025-12-31 08:50:51 +07:00
rstubryan 4f571f1c16 feat(FE-441): Show laying metrics and extend ProductionMetrics 2025-12-31 08:40:56 +07:00
rstubryan 81ca60a09b Merge branch 'development' of gitlab.com:mbugroup/lti-web-client into feat/FE/US-281-439/TASK-440-441-recording-page-and-form-adjustment 2025-12-31 08:22:40 +07:00
randy-ar 23453eb8f5 hotfix(FE): change temporary permission for dashboard, finance and master data standard 2025-12-30 23:52:13 +07:00
Rivaldi A N S 3dc32da834 Merge branch 'feat/FE/US-81/production-result-report' into 'development'
[FEAT/FE][US#81/TASK-442] Production Result Report

See merge request mbugroup/lti-web-client!123
2025-12-30 16:02:58 +00:00
ValdiANS f089492830 chore: adjust closing data type 2025-12-30 22:49:39 +07:00
rstubryan 3412994d15 Merge branch 'development' of gitlab.com:mbugroup/lti-web-client into feat/FE/US-281/TASK-316-317-slicing-ui-and-integrate-api-daily-recording-growing-uniformity-page 2025-12-30 22:43:23 +07:00
ValdiANS 6eaa92dfd4 Merge branch 'development' into feat/FE/US-81/production-result-report 2025-12-30 22:30:56 +07:00
rstubryan 8d668429e1 Merge branch 'development' of gitlab.com:mbugroup/lti-web-client into feat/FE/US-281-439/TASK-440-441-recording-page-and-form-adjustment 2025-12-30 22:29:28 +07:00
rstubryan 8d1a3b665e refactor(FE-440): Use styled HTML tables for FCR and mortality 2025-12-30 22:29:15 +07:00
ValdiANS 7b99bae197 feat(FE-443): create ProductionResult type 2025-12-30 22:27:59 +07:00
ValdiANS dad169d854 feat(FE-443): create ProductionResultReportApiService 2025-12-30 22:27:33 +07:00
ValdiANS f985c041e4 chore: create getAll method in BaseApiService 2025-12-30 22:26:43 +07:00
ValdiANS 5326eff293 feat(FE-442): add laporan hasil produksi route permission 2025-12-30 22:26:29 +07:00
ValdiANS d66bd8c606 feat(FE-442): add Laporan Hasil Produksi menu 2025-12-30 22:25:53 +07:00
ValdiANS ea5ad20684 feat(FE-442): create ProductionResultProjectFlockKandangTable component 2025-12-30 22:25:27 +07:00
ValdiANS 23ee8828f0 feat(FE-442): create ProductionResultContent component 2025-12-30 22:24:22 +07:00
ValdiANS 0dd2edfe01 feat(FE-442): create Production Result Report page 2025-12-30 22:22:23 +07:00
Rivaldi A N S 6edc278bdf Merge branch 'feat/FE/US-391/TASK-435-436-expense-adjustment' into 'development'
[FEAT/FE][US#391/TASK-435-436] Expense Adjustment

See merge request mbugroup/lti-web-client!122
2025-12-30 15:21:09 +00:00
Rivaldi A N S f81c49becb Merge branch 'dev/randy' into 'development'
[FIX/FE][US#337-390] Fix issue in finance and adding dummy dashboard

See merge request mbugroup/lti-web-client!121
2025-12-30 15:20:45 +00:00
rstubryan 03a9451fc8 feat(FE-441): Add FCR and mortality tables to detail view 2025-12-30 22:18:51 +07:00
rstubryan cc0b051a0a refactor(FE-440): Remove body_weights handling from recording forms 2025-12-30 21:55:37 +07:00
rstubryan 865438e3fb refactor(FE-436): Check kandang_id before showing kandang name 2025-12-30 21:26:40 +07:00
rstubryan d39b71e759 refactor(FE-436): Use fallback when kandang name missing 2025-12-30 21:21:35 +07:00
rstubryan 5e6b03ef08 refactor(FE-435,436): Use location name as fallback for expense titles 2025-12-30 21:17:37 +07:00
rstubryan c291ba3246 refactor(FE-435,436): Use S3 public base URL for document links 2025-12-30 20:52:12 +07:00
randy-ar ab2e7db9d0 fix(FE): error null in marketing 2025-12-30 20:32:23 +07:00
rstubryan 13c1a82142 refactor(FE-435,436): Select Nominal Biaya by approval step 2025-12-30 20:19:05 +07:00
rstubryan 6185fafb57 refactor(FE-435): Multiply qty by price when summing expenses 2025-12-30 19:56:31 +07:00
randy-ar 2ab7c10d5d feat(FE): adding column standard fcr in master data standar production 2025-12-30 19:53:50 +07:00
randy-ar bc6ebcfeda fix(FE): add optional chaining for sapronak calculation in closing odule 2025-12-30 19:34:32 +07:00
randy-ar 10fb9fc990 feat(FE-390): slicing UI and API integration for production dashboard 2025-12-30 19:30:52 +07:00
randy-ar 28639516d5 feat(FE-390): slicing UI and API integration for production dashboard 2025-12-30 19:29:42 +07:00
rstubryan 2bf0f2874e refactor(FE-435): Allow realizations without kandang 2025-12-30 19:28:38 +07:00
rstubryan a81a61135f refactor(FE-435,436): Exclude null kandang_id from expense payload 2025-12-30 19:03:26 +07:00
rstubryan d2e88c2061 refactor(FE-435,436): Allow optional kandang and location expenses 2025-12-30 18:53:46 +07:00
rstubryan 8f4f3d93b8 refactor(FE-435,436): Add location_id to expense form and payload 2025-12-30 18:38:59 +07:00
rstubryan 7daca04cc1 refactor(FE-435): Add required asterisks to table headers 2025-12-30 17:54:03 +07:00
rstubryan 2c5168badf Merge branch 'development' of gitlab.com:mbugroup/lti-web-client into dev/restu 2025-12-30 17:31:28 +07:00
rstubryan 73f4b486c0 refactor(FE-438): Increase vertical margin in table skeleton 2025-12-30 16:46:43 +07:00
rstubryan ed7ee1a268 refactor(FE-316): Refine Filter Modal layout and styles 2025-12-30 16:42:19 +07:00
rstubryan 4e7b91a7b4 refactor(FE-316): Add commented local API URL to UniformityApi 2025-12-30 16:07:35 +07:00
rstubryan 7c0581728e feat(FE-316): Use population instead of available_quantity 2025-12-30 14:41:06 +07:00
rstubryan 52cb440cb3 refactor(FE-316): Rename documents to document in uniformity 2025-12-30 13:35:24 +07:00
rstubryan 7c64870fed refactor(FE-316): Add submission state to apply filters 2025-12-30 11:46:43 +07:00
rstubryan 7290f242f4 feat(FE-438): Add Excel and PDF export for Uniformity table 2025-12-30 11:37:08 +07:00
rstubryan 9be09ae281 refactor(FE-438): Make filter modal and controls responsive 2025-12-30 10:55:43 +07:00
rstubryan 32088b916f refactor(FE-438): Refine Filter modal UI and controls 2025-12-30 10:39:37 +07:00
rstubryan f51236fcfc refactor(FE-316): Use single-select filters, add PF-Kandang lookup 2025-12-30 10:23:01 +07:00
rstubryan c385c42c8f feat(FE-316): Support multi-select filters in UniformityTable 2025-12-30 10:17:46 +07:00
rstubryan 02dc624036 feat(FE-316): Add filter modal and query params for Uniformity 2025-12-30 10:11:51 +07:00
rstubryan 4e5f9c710c refactor(FE-316): Replace bulk delete with single-item delete 2025-12-30 09:50:09 +07:00
randy-ar 2712821f4e fix(FE-337): fix finance input and transaction type 2025-12-30 09:25:54 +07:00
rstubryan d6849a48d2 refactor(FE-316): Rename file to documents in uniformity feature 2025-12-30 09:21:38 +07:00
rstubryan 2e44371c6c feat(FE-316): Add withpopulation query param to kandang lookup 2025-12-30 09:05:50 +07:00
rstubryan 98ae56a1aa feat(FE-438): Load uniformity details on demand 2025-12-29 22:22:09 +07:00
rstubryan 7fcab4d295 feat(FE-316): Add tooltip and remove control to file upload 2025-12-29 21:24:13 +07:00
rstubryan 550bcc426b refactor(FE-316): Rename fileName to file_name in uniformity forms 2025-12-29 21:04:25 +07:00
rstubryan 844ac01b70 refactor(FE-316): Clamp subtitle text and update export filename 2025-12-29 20:58:12 +07:00
rstubryan 9ef232bac5 refactor(FE-316): Polish Uniformity template and upload UI 2025-12-29 20:50:53 +07:00
rstubryan 34ec650a01 refactor(FE-316): Clarify instructions in uniformity template 2025-12-29 20:42:38 +07:00
rstubryan 1d27781c02 feat(FE-316): Add instruction sheet and format data sheet 2025-12-29 19:43:32 +07:00
rstubryan e81c0a3baf feat(FE-316): Add uniformity Excel template generator 2025-12-29 19:34:17 +07:00
rstubryan be0bdcd299 feat(FE-316): Show required data count in upload area 2025-12-29 17:52:26 +07:00
randy-ar 7e73c99074 Merge branch 'development' of https://gitlab.com/mbugroup/lti-web-client into dev/randy 2025-12-29 16:35:11 +07:00
randy-ar 0f86ba0f2d fix(FE): adjust options in master data product 2025-12-29 15:52:43 +07:00
randy-ar 10a37fde75 fix(FE): fix delete and update button row in master data production standards 2025-12-29 15:01:42 +07:00
rstubryan 6ad1a3349b refactor(FE-316): Extract Uniformity confirmation preview component 2025-12-29 14:53:29 +07:00
rstubryan 3bb5d5e5a5 refactor(FE-316): Change upload file hint to .xlsx 2025-12-29 14:44:38 +07:00
rstubryan 3279fb30ce refactor(FE-316): Update template label to XLSX 2025-12-29 14:43:54 +07:00
rstubryan 34eae71b44 refactor(FE-316): Guard unsubscribe call with optional chaining 2025-12-29 14:43:11 +07:00
rstubryan 4f168b51c7 refactor(FE-316): Centralize uniformity types and add typings 2025-12-29 14:32:17 +07:00
rstubryan ded1cc1f62 refactor(FE-316): Extract uniformity slice and add types 2025-12-29 14:24:23 +07:00
rstubryan 39f2fc48a8 refactor(FE): Remove unnecessary comments in useEffect 2025-12-29 14:16:28 +07:00
rstubryan a72b22da6e Merge branch 'development' of gitlab.com:mbugroup/lti-web-client into feat/FE/US-281/TASK-316-317-slicing-ui-and-integrate-api-daily-recording-growing-uniformity-page 2025-12-29 14:15:29 +07:00
rstubryan dc4e569453 refactor(FE-438): Remove unused view handler and simplify catch 2025-12-29 14:03:14 +07:00
rstubryan 17a6cee1e3 refactor(FE-438): Fix Uniformity component sample data and imports 2025-12-29 14:01:37 +07:00
rstubryan 5e32724d40 refactor(FE-438): Show approve/reject only when step is CREATED 2025-12-29 13:51:32 +07:00
randy-ar cd3a5ad441 feat(FE): adding production standard select options for project flock 2025-12-29 13:50:23 +07:00
rstubryan 11bd8b27b5 refactor(FE-438): Remove CV field from Uniformity preview 2025-12-29 13:46:27 +07:00
rstubryan 9a1a6a7e41 refactor(FE-316): Add cursor to buttons and enlarge close icon 2025-12-29 13:43:28 +07:00
rstubryan d02f919b76 refactor(FE-438): Rename uniformityDetails prop to uniformity_details 2025-12-29 13:37:18 +07:00
rstubryan 4529ee50e3 refactor(FE-316, 438): Move uniformity types into shared types file 2025-12-29 13:30:16 +07:00
randy-ar cd42bd6bc0 fix(FE): change hatchery to optional in master data supplier 2025-12-29 13:26:39 +07:00
rstubryan 4ed1e4f8b5 refactor(FE-438): Fix Uniformity gauge skeleton sizing 2025-12-29 13:22:18 +07:00
randy-ar ea7f8a68f4 fix(FE): change select option warehouse marketing to correct data warehouses 2025-12-29 13:19:16 +07:00
rstubryan 11a63f76b7 refactor(FE-438): Use shared DetailOptionType for result tables 2025-12-29 13:18:44 +07:00
rstubryan cd41d5daab refactor(FE-438): Extract uniformity status and weight helpers 2025-12-29 13:16:39 +07:00
rstubryan 9f2fcbf154 refactor(FE-438): Add uniformity details preview drawer 2025-12-29 12:08:30 +07:00
rstubryan 70d9b4d8ed feat(FE-438): Add approval badge to uniformity detail 2025-12-29 09:23:25 +07:00
rstubryan 39f70bd71b refactor(FE-438): Remove unused code from UniformityDetail 2025-12-28 21:25:45 +07:00
rstubryan 817f8a7010 refactor(FE-438): Update UniformityDetail header 2025-12-28 21:22:11 +07:00
rstubryan 2276df2790 feat(FE-438): Handle approve/reject via URL and add buttons 2025-12-28 21:19:38 +07:00
rstubryan 8ec76af012 feat(FE-438): Add Uniformity detail view and navigation 2025-12-28 20:58:59 +07:00
rstubryan 9f0dc8c644 refactor(FE-438): Localize modal buttons and stub uniformity details 2025-12-28 18:48:00 +07:00
rstubryan 2d0c8dbd3f refactor(FE-438): Refactor ConfirmationModal icon and update usages 2025-12-28 17:46:27 +07:00
rstubryan 8224dbf8ec refactor(FE-438): Rework confirmation modals and add bulk approve 2025-12-28 17:08:47 +07:00
rstubryan 6e4462e217 feat(FE-438): Add approve/reject flows to UniformityTable 2025-12-28 16:58:29 +07:00
rstubryan b1ccad081d refactor(FE-438): Add icon position/size and subtitle to modal 2025-12-28 16:44:01 +07:00
rstubryan c0a818af7e feat(FE-438): Add bulk approve/reject/delete and FAB 2025-12-28 14:32:14 +07:00
Rivaldi A N S e0371b0884 Merge branch 'feat/FE/US-388/master-data-uniformity-standard' into 'development'
[FEAT/FE][US#388] Master Data Standar Produksi

See merge request mbugroup/lti-web-client!118
2025-12-28 07:15:27 +00:00
rstubryan 8a6f78ef84 feat(FE-316): Show details table in success confirmation modal 2025-12-28 14:06:30 +07:00
rstubryan b2c09bb7c7 refactor(FE-316): Reset uniformity state on drawer close 2025-12-28 13:56:32 +07:00
rstubryan c550922974 refactor(FE-316): Use real data and formatting in uniformity results 2025-12-28 13:52:59 +07:00
Rivaldi A N S 432d837aaf Merge branch 'dev/randy' into 'feat/FE/US-388/master-data-uniformity-standard'
[FEAT/FE][US#388] Master Data Standar Produksi

See merge request mbugroup/lti-web-client!116
2025-12-28 05:23:38 +00:00
rstubryan b24fb54856 refactor(FE-316): Update uniformity payload/fields and file handling 2025-12-28 11:50:14 +07:00
rstubryan f37eea687a feat(FE-316): Show success modal after creating uniformity 2025-12-28 10:17:29 +07:00
randy-ar 77b05c6440 chore(FE): delete dummy data 2025-12-28 04:39:40 +07:00
randy-ar 731bec5a94 feat(FE-337): slicing ui form finance and API integration 2025-12-28 04:28:02 +07:00
randy-ar 6ea25aa3b1 feat(FE-331): implement permission guard in project flock, chickin and closing kandang 2025-12-28 01:00:20 +07:00
randy-ar d4f4505405 feat(FE-331): implement permission guard in project flock, chickin and closing kandang 2025-12-28 00:56:39 +07:00
randy-ar bd653851e2 feat(FE-331): implement permission guard in master data productions standards 2025-12-28 00:23:50 +07:00
rstubryan c8f47c741a feat(FE-316): Add status badges and result summary tables 2025-12-27 23:15:19 +07:00
rstubryan 78486be3ea refactor(FE-316): Remove RequirePermission and update header buttons 2025-12-27 22:45:44 +07:00
rstubryan fe04bf5692 refactor(FE-316): Hide back icon and divider in uniformity forms 2025-12-27 22:39:03 +07:00
rstubryan 3c29b8bc77 refactor(FE-316): Show selected file name in preview subtitle 2025-12-27 22:32:12 +07:00
rstubryan 45d65024db refactor(FE-316): Extract uniformity state into separate store 2025-12-27 21:51:13 +07:00
rstubryan fd2077c68b refactor(FE-316): Add fileName to Uniformity form data 2025-12-27 21:36:34 +07:00
rstubryan 819b709f7e feat(FE-316): Add Uniformity result drawer and flow 2025-12-27 21:25:06 +07:00
rstubryan 549a710a8d feat(FE-316): Save and preview uniformity verification 2025-12-27 21:00:07 +07:00
rstubryan ec8ae7561d feat(FE-316): Add verifyUniformity and split payload types 2025-12-27 19:09:03 +07:00
rstubryan 5f68c05acc refactor(FE-316,438): Wrap Uniformity actions with permission checks 2025-12-27 18:05:25 +07:00
randy-ar b9b349aa7a fix(FE): resolve git pull merge development 2025-12-27 16:49:16 +07:00
rstubryan 0a447f93c1 Merge branch 'development' of gitlab.com:mbugroup/lti-web-client into feat/FE/US-281/TASK-316-317-slicing-ui-and-integrate-api-daily-recording-growing-uniformity-page 2025-12-27 16:48:00 +07:00
Rivaldi A N S 6ec6323bbc Merge branch 'feat/FE/US-304/permission-guard' into 'development'
[FEAT/FE][US#304] Permission Guard

See merge request mbugroup/lti-web-client!115
2025-12-27 09:41:13 +00:00
randy-ar c44e63bd2b fix(FE): fix page responsive in project flock dan marketing modules 2025-12-27 16:36:07 +07:00
ValdiANS 500c30c2bc feat(FE-331): implement permission guard in transfer to laying 2025-12-27 16:05:50 +07:00
ValdiANS 507c4005af feat(FE-331): implement permission guard in recording 2025-12-27 14:34:59 +07:00
randy-ar d49bca1d40 feat(FE): api integration production standards 2025-12-27 13:46:19 +07:00
rstubryan e4d75dad68 refactor(FE-316): Rename CreateUniformityPayload to
VerifyUniformityPayload
2025-12-27 09:17:09 +07:00
rstubryan 4f22024c82 refactor(FE-316): Rename ExpandedDrawerForm to UniformityPreviewForm 2025-12-27 09:12:31 +07:00
rstubryan 751c27b73e feat(FE-316): Add delete button to ExpandedDrawerForm header 2025-12-27 09:05:12 +07:00
rstubryan 0d77aa4a5f feat(FE-438): Display date and week in Uniformity table 2025-12-27 08:57:01 +07:00
rstubryan 6fde6b180a feat(FE-316): Add isNextStep flag for expanded drawer flow 2025-12-27 08:37:05 +07:00
randy-ar 663c1dea14 feat(FE): add master data production standard, slicing form and index table 2025-12-27 03:23:03 +07:00
rstubryan 4aab54981e refactor(FE-316): Use single file field and remove unused IDs 2025-12-26 23:05:25 +07:00
rstubryan 04c987b86b refactor(FE-316): Remove toggleExpandedDrawer from drawer slice 2025-12-26 22:57:28 +07:00
rstubryan 800739bd4f refactor(FE-316): Add expanded drawer content and dynamic width 2025-12-26 22:50:41 +07:00
rstubryan e0ee846106 refactor(FE-438): Center text in UniformityForm placeholder 2025-12-26 22:39:36 +07:00
rstubryan 84b49d2ac6 refactor(FE-438): Normalize ID handling and simplify callbacks 2025-12-26 22:35:42 +07:00
rstubryan ec95ddbddd refactor(FE-438): Add min validators and file error handling 2025-12-26 22:05:36 +07:00
rstubryan 6d2057842d refactor(FE-438): Remove sm: prefix from drawer-end class 2025-12-26 21:52:10 +07:00
rstubryan 1843a47d59 refactor(FE-438): Replace FileInput with custom file upload UI 2025-12-26 21:50:59 +07:00
ValdiANS 9e0d3e2bbf feat(FE-331): implement permission guard in project flock 2025-12-26 21:08:00 +07:00
rstubryan e6a38c3f65 refactor(FE-438): Scope Drawer classes to sm breakpoint 2025-12-26 20:29:18 +07:00
rstubryan f58cb43801 refacotr(FE-438): Unsubscribe validate subscription and close drawer 2025-12-26 19:17:12 +07:00
rstubryan 517e8c758c refactor(FE-438): Add Project Flock selection and lookup 2025-12-26 17:12:40 +07:00
rstubryan 97c5917401 refactor(FE-438): Unsubscribe immediately after validation 2025-12-26 16:21:42 +07:00
ValdiANS 4be719b9d8 feat(FE-331): implement permission guard in purchase 2025-12-26 16:21:22 +07:00
rstubryan 31a9828661 refactor(FE-316): Use useSelect for location options 2025-12-26 16:15:33 +07:00
rstubryan 580c357667 feat(FE-316): Add Uniformity form with validation and upload 2025-12-26 16:08:04 +07:00
ValdiANS 1152cd2bef chore(FE-331): update report permission 2025-12-26 15:46:06 +07:00
rstubryan f1227c9dcb feat(FE-438): Add UniformityTable skeleton for empty state 2025-12-26 10:58:27 +07:00
rstubryan 5f3c3be1f3 refactor(FE-438): Use skeleton class in UniformityBarChartSkeleton 2025-12-26 10:55:24 +07:00
rstubryan ae00f49e64 feat(FE-438): Add gauge skeleton and use in UniformityChart 2025-12-26 10:36:29 +07:00
rstubryan d9322cc17d refactor(FE-438): Make left legend skeleton DRY and widen gaps 2025-12-26 10:13:17 +07:00
rstubryan f5f154883b feat(FE-438): Add UniformityBarChartSkeleton and use it 2025-12-26 09:49:18 +07:00
rstubryan 8c21883aa9 refactor(FE-316): Move UniformityStat to chart folder 2025-12-26 08:38:54 +07:00
randy-ar 4ddd1dc8e3 feat(FE-337): slicing ui form add finance 2025-12-24 18:45:33 +07:00
rstubryan 879702d31d refactor(FE-316): Add expandable secondary drawer panel 2025-12-24 17:53:14 +07:00
randy-ar 8c95dc8327 feat(FE-350): add filtering table 2025-12-24 16:44:53 +07:00
rstubryan f0eb3fcf52 refactor(FE-316): Remove overflow-visible class from table wrapper 2025-12-24 16:38:50 +07:00
ValdiANS df6c1ae49d feat(FE-331): implement permission guard in marketing 2025-12-24 15:43:45 +07:00
ValdiANS 42a56a08d7 chore(FE-331): update /marketing/detail/ permission name 2025-12-24 15:31:50 +07:00
rstubryan 871f0403ad feat(FE-316): Disable tooltip cursor in uniformity bar chart 2025-12-24 11:46:13 +07:00
rstubryan b57a0fcc90 feat(FE-316): Add gradient fill and refine bar chart axes 2025-12-24 11:44:29 +07:00
rstubryan 6ef9c1338f Merge branch 'feat/FE/US-281/TASK-316-317-slicing-ui-and-integrate-api-daily-recording-growing-uniformity-page' of gitlab.com:mbugroup/lti-web-client into feat/FE/US-281/TASK-316-317-slicing-ui-and-integrate-api-daily-recording-growing-uniformity-page 2025-12-24 11:24:24 +07:00
rstubryan ea4dd29bbf feat(FE-316): Add axis labels and responsive sizing to bar chart 2025-12-24 11:23:37 +07:00
rstubryan d591c89cac feat(FE-316): Add axis labels and responsive sizing to bar chart 2025-12-24 11:22:47 +07:00
rstubryan 22d24af41c feat(FE-316): Add info icon to Card titles 2025-12-24 11:11:35 +07:00
ValdiANS 6ed7dcfa6d feat(FE-331): implement permission guard in expense 2025-12-24 11:08:37 +07:00
ValdiANS dda29e10d1 chore: change "Biaya Operasional" menu text to "Biaya" 2025-12-24 11:07:40 +07:00
rstubryan 20d124504b refactor(FE-316): Use CSS background classes for status badges 2025-12-24 10:57:02 +07:00
rstubryan b9c1989cae refactor(FE-316): Refactor Uniformity table and status helpers 2025-12-24 10:51:12 +07:00
rstubryan 5fae7752f2 feat(FE): Add status indicator to Badge and use theme types 2025-12-24 10:32:39 +07:00
ValdiANS 9d9b9d93db feat(FE-331): implement permission guard in closing 2025-12-24 09:41:48 +07:00
ValdiANS f41899dbc9 feat(FE-331): add /report route to ROUTE_PERMISSIONS 2025-12-24 09:24:16 +07:00
rstubryan 9e5d878e82 feat(FE-316,317): Add accessorKey and id for UniformityTable columns 2025-12-23 22:15:33 +07:00
rstubryan 035f187bac refactor(FE-316,317): Extract Uniformity table columns to constant 2025-12-23 22:12:24 +07:00
rstubryan cb78ec4990 feat(FE-316,317): Enhance UniformityTable with selection and actions 2025-12-23 21:58:28 +07:00
rstubryan 3a2fac013e feat(FE-317): Add uniformity field to Uniformity type 2025-12-23 21:57:44 +07:00
rstubryan 3b2e11fd41 feat(FE-317): Add Uniformity API service and types 2025-12-23 21:21:25 +07:00
rstubryan 414d617341 refactor(FE-316): Adjust UniformityChart responsive grid 2025-12-23 20:10:28 +07:00
rstubryan 0774200aa5 refactor(FE-316): Extract Uniformity charts into components 2025-12-23 18:52:05 +07:00
rstubryan 5dd64b9907 feat(FE-316): Add Gauge and Detail Card to Uniformity Chart 2025-12-23 18:33:47 +07:00
rstubryan 8fc5d42bb8 refactor(FE-316): Fix header markup and comment out UniformityStat 2025-12-23 17:52:29 +07:00
randy-ar 36ff6d04ee feat(FE-337): init slicing UI and define data types 2025-12-23 17:38:16 +07:00
rstubryan f23a0144b0 refactor(FE-316): Replace tooltip with custom uniformity design 2025-12-23 16:40:37 +07:00
ValdiANS de63b6721a feat(FE-331): implement permission guard in inventory 2025-12-23 16:40:32 +07:00
ValdiANS a200dac23c chore(FE-331): fix inventory route path 2025-12-23 16:39:08 +07:00
rstubryan 09dd907f88 feat(FE-316): Add Uniformity page and form component 2025-12-23 16:11:02 +07:00
rstubryan 33b8d0a8b0 feat(FE-316): Add Uniformity page and layout components 2025-12-23 16:10:12 +07:00
rstubryan 398282b3bf feat(FE-316): Add Uniformity page components 2025-12-23 16:09:29 +07:00
rstubryan 035482accc feat(FE-317): Add Uniformity menu item to main drawer 2025-12-23 16:03:36 +07:00
ValdiANS fcfd2fb576 Merge branch 'feat/FE/US-304/permission-guard' into feat/FE/US-304/permission-guard-master-data 2025-12-23 15:55:50 +07:00
ValdiANS 2c28d0a831 Merge branch 'feat/FE/US-304/permission-guard' into feat/FE/US-304/permission-guard-master-data 2025-12-23 15:53:05 +07:00
rstubryan 907afbb062 chore(FE): Add Recharts deps and run tsc in pre-commit 2025-12-23 15:51:26 +07:00
ValdiANS addfaff692 feat(FE-331): implement permission guard in master data 2025-12-23 12:10:07 +07:00
ValdiANS ecdbb764d5 feat(FE-331): only show menu if user has the permission 2025-12-23 12:09:49 +07:00
ValdiANS a3be3de338 feat(FE-331): return PermissionNotFound component if user is not permitted 2025-12-23 12:09:06 +07:00
ValdiANS 9e895af62a chore: refresh user data every 13 minutes 2025-12-23 12:08:39 +07:00
ValdiANS 1f9992c1c8 feat(FE-331): add permissions to MAIN_DRAWER_LINKS 2025-12-23 12:08:16 +07:00
ValdiANS 574fb3b371 feat(FE-331): create ROUTE_PERMISSION constant 2025-12-23 12:07:55 +07:00
ValdiANS 4643a39c3e feat(FE-331): create RequirePermission helper component 2025-12-23 12:07:38 +07:00
ValdiANS 88b8767ca4 chore: lint 2025-12-23 12:07:24 +07:00
ValdiANS de19cc5de2 feat(FE-331): create PermissionNotFound component 2025-12-23 12:07:14 +07:00
rstubryan b9dad3094c Merge branch 'development' of gitlab.com:mbugroup/lti-web-client into dev/restu 2025-12-23 11:08:36 +07:00
Adnan Zahir a4b9b3fd2f Merge branch 'feat/FE/US-334/expedition-hpp-report' into 'development'
[FEAT/FE][US#334] Slicing and Integrate API Expedition HPP Report Table

See merge request mbugroup/lti-web-client!111
2025-12-23 10:57:59 +07:00
Adnan Zahir b91a199d13 Merge branch 'feat/FE/US-339/purchase-report' into 'development'
[FEAT/FE][US#339] Slicing and Integrate API Purchase Report Page

See merge request mbugroup/lti-web-client!109
2025-12-23 10:57:46 +07:00
rstubryan ff427d13cc Merge branch 'feat/FE/US-334/expedition-hpp-report' of gitlab.com:mbugroup/lti-web-client into dev/restu 2025-12-23 10:55:03 +07:00
rstubryan 8295943b82 Merge branch 'feat/FE/US-339/purchase-report' of gitlab.com:mbugroup/lti-web-client into dev/restu 2025-12-23 10:53:44 +07:00
rstubryan a3169d582d Merge branch 'development' of gitlab.com:mbugroup/lti-web-client into dev/restu 2025-12-23 10:52:24 +07:00
rstubryan bf16d259bd Merge branch 'development' of gitlab.com:mbugroup/lti-web-client into feat/FE/US-334/expedition-hpp-report 2025-12-23 10:43:56 +07:00
rstubryan 5ae299a4b5 Merge branch 'development' of gitlab.com:mbugroup/lti-web-client into feat/FE/US-339/purchase-report 2025-12-23 10:31:32 +07:00
Adnan Zahir c840f881bb Merge branch 'feat/FE/US-352/daily-kandang-hpp-report' into 'development'
[FEAT/FE][US#352] HPP Harian Per Kandang Report

See merge request mbugroup/lti-web-client!114
2025-12-23 10:20:10 +07:00
Adnan Zahir 6f16cf6deb Merge branch 'feat/FE/US-338/expense-report' into 'development'
[FEAT/FE][US#338] Expense Report

See merge request mbugroup/lti-web-client!110
2025-12-23 10:19:43 +07:00
Adnan Zahir 5b4bc136f2 Merge branch 'feat/FE/US-336/finance-report' into 'development'
[FEAT/FE][US#336] Reporting Closing Finance

See merge request mbugroup/lti-web-client!108
2025-12-23 10:19:02 +07:00
rstubryan dd6c6263e7 Merge branch 'development' of gitlab.com:mbugroup/lti-web-client into dev/restu 2025-12-23 09:32:08 +07:00
rstubryan 346d655406 refactor(FE): Upgrade xlsx and add HPP per kandang tab 2025-12-23 09:25:26 +07:00
rstubryan 5ff132070c Merge branch 'development' of gitlab.com:mbugroup/lti-web-client into feat/FE/US-352/daily-kandang-hpp-report 2025-12-23 09:24:17 +07:00
randy-ar 398a09bf3b Merge branch 'development' into 'feat/FE/US-336/finance-report'
# Conflicts:
#   src/config/constant.ts
2025-12-23 02:22:41 +00:00
randy-ar 4e1315a027 Merge branch 'development' into 'feat/FE/US-338/expense-report'
# Conflicts:
#   src/components/pages/closing/ClosingDetail.tsx
2025-12-23 02:21:47 +00:00
Adnan Zahir dcf2acc799 Merge branch 'feat/FE/US-333/overhead-report' into 'development'
[FEAT/FE][US#333] Reporting Closing Overhead

See merge request mbugroup/lti-web-client!107
2025-12-22 17:45:56 +07:00
randy-ar 67a3ce2906 fix(FE): resolve conflict with branch development 2025-12-22 16:53:06 +07:00
randy-ar 1d28e80b66 fix(FE): resolve conflict with branch development 2025-12-22 16:45:18 +07:00
randy-ar 9dae6f1e95 fix(FE): resolve merge conflict with branch development 2025-12-22 16:34:49 +07:00
rstubryan 5d03b68576 Merge branch 'development' of gitlab.com:mbugroup/lti-web-client into dev/restu 2025-12-22 15:48:43 +07:00
Adnan Zahir 4bc9926356 Merge branch 'feat/FE/US-335/production-data-report' into 'development'
[FEAT/FE][US#335] Production Data Report

See merge request mbugroup/lti-web-client!106
2025-12-22 15:38:54 +07:00
ValdiANS ea32056ca8 feat(FE-347): adjust getProductionData method 2025-12-22 15:29:39 +07:00
ValdiANS ddfdfe4d91 Merge branch 'development' into feat/FE/US-335/production-data-report 2025-12-22 15:28:01 +07:00
ValdiANS 7ea16d6a8a Merge branch 'development' into feat/FE/US-335/production-data-report 2025-12-22 15:23:15 +07:00
ValdiANS 206d6c0b4e Merge branch 'development' into feat/FE/US-335/production-data-report 2025-12-22 15:15:04 +07:00
Adnan Zahir 382721059a Merge branch 'feat/FE/US-340/marketing-report' into 'development'
[FEAT/FE][US#340] Marketing Report

See merge request mbugroup/lti-web-client!103
2025-12-22 14:47:12 +07:00
Rivaldi A N S 6a71828167 Merge branch 'feat/FE/US-352/TASK-355-356-357-slicing-and-integrate-kandang-hpp-daily-report-page' into 'feat/FE/US-352/daily-kandang-hpp-report'
[FEAT/FE][US#352/TASK-355-356-357] Slicing and Integrate API Hpp Harian Per Kandang Report

See merge request mbugroup/lti-web-client!113
2025-12-20 03:53:12 +00:00
rstubryan a5e79570c5 refactor(FE-356): Clarify 'Sisa Kg' label to specify Ayam 2025-12-20 10:30:11 +07:00
rstubryan 804aa700d3 feat(FE-356): Display egg production and HPP in PDF export 2025-12-20 10:26:18 +07:00
rstubryan 982a5d0d11 feat(FE-356): Display egg production and HPP in PDF export 2025-12-20 10:25:40 +07:00
rstubryan 478e9eb541 refactor(FE-356): Use summaryTotal and memoize per-weight summary 2025-12-20 10:18:50 +07:00
rstubryan 9e0631a415 feat(FE-355,357): Use summary totals and show egg metrics 2025-12-20 10:13:48 +07:00
rstubryan 18ca7d8a59 refactor(FE-357): Reference summary.total in footers 2025-12-20 09:50:19 +07:00
rstubryan eb8a1567c6 refactor(FE-355): Render weight-range summaries as table rows 2025-12-20 09:47:50 +07:00
rstubryan a0e63ea2d4 refactor(FE-355): Use flexRender and prepend default row in table 2025-12-20 09:37:42 +07:00
rstubryan 1ac35691ff refactor(FE-355): Move td classes into tr with [&_td] utilities 2025-12-20 09:32:35 +07:00
Rivaldi A N S f9aa254c18 Merge branch 'dev/randy' into 'feat/FE/US-338/expense-report'
[FIX/FE][US#338] Fixing Export PDF Using jspdf Library

See merge request mbugroup/lti-web-client!112
2025-12-20 02:17:37 +00:00
rstubryan c8effe4473 feat(FE-355,357): Render per-weight-range summary rows 2025-12-20 09:17:31 +07:00
rstubryan c230c8000b refactor(FE-355,356,257): Use API summary per_weight_range for HPP
reports
2025-12-20 08:52:34 +07:00
randy-ar a7267370a0 fix(FE): fix export report expense & fix report closing table view & fix project flock form set disable inofrmasi umum on edit 2025-12-19 17:20:02 +07:00
rstubryan daddebc0a6 refactor(FE-357): Refactor HppPerKandang types and add BaseMetadata 2025-12-19 16:30:06 +07:00
rstubryan 856d1f5c0c feat(FE): Filter supplier options by SAPRONAK category 2025-12-19 14:05:50 +07:00
rstubryan da5a577fde refactor(FE-357): Add key to summary table row 2025-12-19 13:46:02 +07:00
rstubryan c36d1ee153 feat(FE-355): Add custom row renderer to HppPerKandangTab 2025-12-19 13:40:41 +07:00
rstubryan 7259de8b14 feat(FE): Add renderCustomRow prop to Table 2025-12-19 12:56:25 +07:00
Rivaldi A N S 9e576cf444 Merge branch 'feat/FE/US-334/TASK-344-345-slicing-and-integrate-expedition-hpp-report-table' into 'feat/FE/US-334/expedition-hpp-report'
[FEAT/FE][US#334/TASK-344-345] Slicing and Integrate API Expedition HPP Report Table

See merge request mbugroup/lti-web-client!105
2025-12-19 03:33:05 +00:00
rstubryan d7b828cb47 chore(FE): Add xlsx@0.20.3 from SheetJS CDN 2025-12-19 10:24:16 +07:00
Rivaldi A N S f757e5f6ba Merge branch 'dev/randy' into 'feat/FE/US-338/expense-report'
[FEAT/FE][US#338] Expense Report

See merge request mbugroup/lti-web-client!104
2025-12-19 03:17:50 +00:00
rstubryan 7f694c7298 chore(FE): Bump Next.js to 15.5.9 2025-12-19 10:17:08 +07:00
Rivaldi A N S 5326fc918a Merge branch 'feat/FE/US-339/TASK-361-362-363-slicing-purchase-and-integrate-purchase-report-page' into 'feat/FE/US-339/purchase-report'
[FEAT/FE][US#339/TASK-361-362-363-367] Slicing and Integrate API Purchase Report Page

See merge request mbugroup/lti-web-client!101
2025-12-19 03:06:04 +00:00
Rivaldi A N S 6658312427 Merge branch 'dev/randy' into 'feat/FE/US-336/finance-report'
[FEAT/FE][US#336] Reporting Closing Finance

See merge request mbugroup/lti-web-client!100
2025-12-19 02:51:28 +00:00
Rivaldi A N S de73c626b1 Merge branch 'dev/randy' into 'feat/FE/US-333/overhead-report'
[FEAT/FE][US#333] Reporting Closing Overhead

See merge request mbugroup/lti-web-client!99
2025-12-19 02:47:10 +00:00
ValdiANS faaa10b74b chore(FE-347): update ClosingProductionData type 2025-12-19 09:39:56 +07:00
ValdiANS d66eaf08c0 chore(FE-347): set return type for getProductionData method 2025-12-19 09:39:43 +07:00
ValdiANS a6a6ff9f72 feat: create dummyClosingProductionData 2025-12-19 09:38:57 +07:00
ValdiANS 5a21a3b44c chore(FE-347): adjust UI based on updated ClosingProductionData type 2025-12-19 09:38:39 +07:00
rstubryan 00e0126e42 refactor(FE-357): Use string weights and parse floats for filters 2025-12-18 20:35:47 +07:00
rstubryan 2f23755510 Merge branch 'development' of gitlab.com:mbugroup/lti-web-client into feat/FE/US-352/TASK-355-356-357-slicing-and-integrate-kandang-hpp-daily-report-page 2025-12-18 20:27:08 +07:00
rstubryan 996e132660 Merge branch 'development' of gitlab.com:mbugroup/lti-web-client into feat/FE/US-339/TASK-361-362-363-slicing-purchase-and-integrate-purchase-report-page 2025-12-18 20:18:02 +07:00
rstubryan e3eda4f5e4 Merge branch 'development' of gitlab.com:mbugroup/lti-web-client into feat/FE/US-334/TASK-344-345-slicing-and-integrate-expedition-hpp-report-table 2025-12-18 20:15:19 +07:00
ValdiANS 7cc616ff41 Merge branch 'development' into feat/FE/US-335/production-data-report 2025-12-18 19:29:27 +07:00
randy-ar 0b75d68494 Merge branch 'development' of https://gitlab.com/mbugroup/lti-web-client into dev/randy 2025-12-18 19:01:48 +07:00
randy-ar 83224e046b fix(FE): fix submenu stock product name 2025-12-18 19:00:30 +07:00
ValdiANS 096a8d394e Merge branch 'development' into feat/FE/US-335/production-data-report 2025-12-18 18:50:22 +07:00
randy-ar 11bf6ad760 feat(FE): adding xlsx package 2025-12-18 18:14:56 +07:00
randy-ar c8a834f84a feat(FE): adding export xlsx for report expense, change report data fetching, adding progress bar 2025-12-18 18:13:27 +07:00
kris ead5ba759d Update .gitlab-ci.yml file 2025-12-18 10:00:38 +00:00
rstubryan 8ceca2cc59 refactor(FE-345): Rename CostOfRevenueExpedition to HppExpedition 2025-12-18 16:38:39 +07:00
rstubryan 8dc23f83cd refactor(FE-335): Rename expedition HPP types and update usages 2025-12-18 16:26:09 +07:00
Rivaldi A N S 57f53b0a04 Merge branch 'feat/FE/US-340/TASK-364-365-368-marketing-report' into 'feat/FE/US-340/marketing-report'
[FEAT/FE][US#340/TASK#364-365-368] Marketing Report

See merge request mbugroup/lti-web-client!102
2025-12-18 09:25:46 +00:00
rstubryan 447b8067f7 refactor(FE-345): Rename hpp-ekspedisi endpoint to expedition-hpp 2025-12-18 15:55:20 +07:00
rstubryan 4a8f2b1e1d feat(FE-345): Add HPP expedition types and API method 2025-12-18 15:49:01 +07:00
rstubryan 36389bae2a refactor(FE-364): Refactor purchases export to use supplier reports 2025-12-18 15:11:34 +07:00
rstubryan d001b05c4e refactor(FE-361,363,364): Use per-supplier report arrays for export 2025-12-18 14:58:54 +07:00
rstubryan 20494657c6 refactor(FE-363): Extract row and summary types for logistic report 2025-12-18 14:35:10 +07:00
rstubryan 2d8e479b6c refactor(FE-363): Switch LogisticApi service to reports endpoint 2025-12-18 14:16:00 +07:00
rstubryan fef7f0e29b refactor(FE-363): Use relative endpoint for logistic reports 2025-12-18 13:59:11 +07:00
rstubryan 81d242bd1d refactor(FE-361,363): Add sort order selector to PurchasesPerSupplierTab 2025-12-18 13:57:58 +07:00
rstubryan 1be596921a refactor(FE-363): Fetch export data on demand via callback 2025-12-18 13:50:38 +07:00
rstubryan 8fb1ccbdce refactor(FE-364): Add hyphen before timestamp in export filenames 2025-12-18 13:40:26 +07:00
rstubryan 85fddcb19a refactor(FE-364): Timestamp purchases-per-supplier export filenames 2025-12-18 13:39:05 +07:00
rstubryan 915e68f755 refactor(FE-363): Send joined filter params to logistic report API 2025-12-18 13:35:40 +07:00
rstubryan 87adbf8547 refactor(FE-363): Accept array filters in logistic purchase report 2025-12-18 13:31:08 +07:00
rstubryan e8492f87ba refactor(FE-364): Enable multi-select filters for purchases report 2025-12-18 13:28:00 +07:00
rstubryan ceae338c73 refactor(FE-356): Include period in export filenames 2025-12-18 13:10:21 +07:00
rstubryan fa7824224c refactor(FE-356): Use timestamped filename for HPP export 2025-12-18 13:05:01 +07:00
rstubryan 6b30457ec2 feat(FE-356): Include filter details in export header 2025-12-18 13:02:16 +07:00
rstubryan 843fa6ee7a refactor(FE-357): Make area/location/kandang filters multi-select 2025-12-18 12:56:05 +07:00
randy-ar a935ffd9f5 fix(FE): fixing floating button & revert require auth component 2025-12-18 11:33:18 +07:00
rstubryan 1de98db4ba refactor(FE-361): Hide unused logistic tabs and adjust card 2025-12-18 11:31:05 +07:00
rstubryan f844c9ff2c refactor(FE-357): Use relative URL for marketing sale reports 2025-12-18 11:19:23 +07:00
rstubryan 83fc92d48b refactor(FE-356): Refactor weight-range grouping and format currency 2025-12-18 11:12:30 +07:00
rstubryan 4edd4f1285 feat(FE-356): Add egg production and HPP fields to PDF export 2025-12-18 09:57:21 +07:00
rstubryan cc3765abcd refactor(FE-356): Add egg production and pricing columns 2025-12-18 09:50:11 +07:00
rstubryan 3497a6346c refactor(FE-357): Deduplicate totals and supplier aggregation 2025-12-18 09:47:52 +07:00
rstubryan 69b4ca455e refactor(FE-355): Guard HPP total calculation for empty data 2025-12-18 09:33:13 +07:00
rstubryan 320bc52244 refactor(FE-355,357): Show HPP and average DOC totals in table footer 2025-12-18 09:24:49 +07:00
rstubryan 40f2d0ba93 refactor(FE-355): Reorder egg_value_rp column in HppPerKandangTab 2025-12-18 09:12:28 +07:00
rstubryan 481a643b3c refactor(FE-355): Use summary fallbacks for report footers 2025-12-18 09:11:21 +07:00
rstubryan 9b2d98f7ce feat(FE-355,357): Add egg columns to HPP table and disable sale tabs 2025-12-18 08:59:07 +07:00
rstubryan 6155929e14 refactor(FE-357): Use hppPerKandangExport instead of fetchAllExportData 2025-12-17 14:54:28 +07:00
rstubryan 7c9f68d3a3 feat(FE-363): Add Excel export loading and combine export state 2025-12-17 14:44:36 +07:00
randy-ar 918e85e0cc fix(FE): resolve merge conflict with branch development 2025-12-17 14:26:03 +07:00
randy-ar bb80e9e9c6 fix(FE): remove dummy data and integrate live API for closing finance and fixing closing UI when given data is null 2025-12-17 14:22:15 +07:00
rstubryan 80fd75dfc1 refactor(FE-357): Rename API response and export fetch vars 2025-12-17 14:14:27 +07:00
rstubryan e1b562c175 refactor(FE-357): Refactor export data fetching and handlers 2025-12-17 14:05:29 +07:00
rstubryan 9365320b03 feat(FE-357): Add loading state for export 2025-12-17 13:45:00 +07:00
rstubryan e515438312 refactor(FE-355): Use NumberInput and SelectInput for filters 2025-12-17 13:33:51 +07:00
rstubryan 530ef4982d refactor(FE-355,357): Use summary fields for egg HPP and total value 2025-12-17 13:04:26 +07:00
rstubryan a8c3b1a66f feat(FE-356): Include HPP and supplier aggregates in export 2025-12-17 11:56:42 +07:00
rstubryan 62d4d7b7db refactor(FE): Fix Dropdown import path 2025-12-17 11:49:41 +07:00
rstubryan 57df2e9aed Merge branch 'dev/restu' of gitlab.com:mbugroup/lti-web-client into feat/FE/US-352/TASK-355-356-357-slicing-and-integrate-kandang-hpp-daily-report-page 2025-12-17 11:48:24 +07:00
rstubryan 9ea86fe5c3 Merge branch 'dev/restu' of gitlab.com:mbugroup/lti-web-client into feat/FE/US-339/TASK-361-362-363-slicing-purchase-and-integrate-purchase-report-page 2025-12-17 11:47:57 +07:00
rstubryan ecf1677c27 Merge branch 'dev/restu' of gitlab.com:mbugroup/lti-web-client into feat/FE/US-334/TASK-344-345-slicing-and-integrate-expedition-hpp-report-table 2025-12-17 11:47:36 +07:00
rstubryan c1e075b1ff refactor(FE): refactor Dropdown component API and Navbar usage 2025-12-17 11:47:12 +07:00
rstubryan c70cfbd450 feat(FE-355,356,357): Add PDF export for HPP per kandang report 2025-12-17 11:42:45 +07:00
rstubryan 4cc41c0167 feat(FE-355,357): Use API summary for weighted averages 2025-12-17 11:11:44 +07:00
rstubryan 730b7903a7 feat(FE-355): Remove pagination from HppPerKandangTab 2025-12-17 11:01:01 +07:00
rstubryan 78efd587be feat(FE-355,357): Add aggregated footers for HPP per kandang table 2025-12-17 10:54:02 +07:00
rstubryan 3d91c12874 feat(FE-355,356,357): Implement HPP Per Kandang report tab 2025-12-17 10:38:56 +07:00
rstubryan 12e6d60745 feat(FE-357): Rename HppPerkandang types and update API path 2025-12-17 10:37:05 +07:00
rstubryan 01313f0b09 refactor(FE-363): Move logistic API to report/logistic-stock 2025-12-17 10:05:32 +07:00
rstubryan 9f521a6a08 refactor(FE-363): Rename logistic stock report API method 2025-12-17 10:00:35 +07:00
rstubryan 43afc5781c feat(FE-355): Add sale report tabs and marketing layout 2025-12-17 09:50:55 +07:00
rstubryan 0f7f4e891c feat(FE-357): Add marketing sales report API and types 2025-12-17 09:50:36 +07:00
randy-ar b02b458034 feat(FE): Closing Finance and adjust reports expense filter request 2025-12-16 17:52:59 +07:00
rstubryan 304084ea2c Merge branch 'development' of gitlab.com:mbugroup/lti-web-client into feat/FE/US-334/TASK-344-345-slicing-and-integrate-expedition-hpp-report-table 2025-12-16 16:21:39 +07:00
rstubryan 204a1098a3 Merge branch 'development' of gitlab.com:mbugroup/lti-web-client into feat/FE/US-339/TASK-361-362-363-slicing-purchase-and-integrate-purchase-report-page 2025-12-16 16:20:35 +07:00
rstubryan c04cd29ac7 refactor(FE-363): Use snake_case for totals in purchases tab 2025-12-16 15:19:47 +07:00
rstubryan d17c11e2f2 feat(FE-364): Implement Excel export for purchases per supplier 2025-12-16 14:48:17 +07:00
rstubryan c9544e1bd0 refactor(FE-361): Format quantity with formatNumber 2025-12-16 14:21:58 +07:00
rstubryan 1560908101 Merge branch 'development' of gitlab.com:mbugroup/lti-web-client into feat/FE/US-334/TASK-344-345-slicing-and-integrate-expedition-hpp-report-table 2025-12-16 14:08:45 +07:00
rstubryan 874bc27e4c Merge branch 'development' of gitlab.com:mbugroup/lti-web-client into feat/FE/US-339/TASK-361-362-363-slicing-purchase-and-integrate-purchase-report-page 2025-12-16 13:57:40 +07:00
rstubryan aea39a878a Merge branch 'development' of gitlab.com:mbugroup/lti-web-client into feat/FE/US-339/TASK-361-362-363-slicing-purchase-and-integrate-purchase-report-page 2025-12-16 13:57:09 +07:00
rstubryan 84e562e22c refactor(FE-364): Refine PDF table cell styles and header alignment 2025-12-16 13:56:48 +07:00
rstubryan 5c8bc4fc6e feat(FE-364): Center align badge in PDF export styles 2025-12-16 13:52:55 +07:00
rstubryan 9ba3fa1b6c refactor(FE-364): refactor PDF table styles and remove total styles 2025-12-16 13:34:36 +07:00
rstubryan 6f18c58042 refactor(FE-364): refactor PDF table styles and remove total styles 2025-12-16 13:33:57 +07:00
rstubryan 0d8e642b4e refactor(FE-364): update PDF export layout and parameter badges 2025-12-16 13:26:16 +07:00
rstubryan 615d4d5ffe feat(FE-364): Add PDF export for purchases per supplier 2025-12-16 12:00:56 +07:00
rstubryan 2a00da0298 refactor(FE-361): Make filter layout responsive 2025-12-16 11:12:30 +07:00
rstubryan 68437b3b7e feat(FE-361,363): Add product category filter and API params 2025-12-16 10:26:31 +07:00
rstubryan 31b2a5a548 refactor(FE-361,363): Adapt PurchasesPerSupplier to new report shape 2025-12-16 10:01:13 +07:00
rstubryan 4d997256ad refactor(FE-363): Update logistic report API endpoint and types 2025-12-16 10:00:39 +07:00
rstubryan 7ea9e10ad2 chore(FE): Add xlsx dependency from SheetJS CDN 2025-12-15 16:34:00 +07:00
rstubryan 245da2595c fix(FE-vulnerability): Bump Next.js to 15.5.9 2025-12-15 16:29:27 +07:00
rstubryan 45f1e923b7 feat(FE-361,363): Add export dropdown to PurchasesPerSupplier tab 2025-12-15 15:10:22 +07:00
rstubryan 3c3c2345c7 feat(FE-361): Update action buttons in PurchasesPerSupplierTab 2025-12-15 14:14:34 +07:00
rstubryan 3f78cfdb63 refactor(FE): refactor Dropdown component API and Navbar usage 2025-12-15 14:04:16 +07:00
rstubryan 69eaae6d43 feat(FE=361,363): Add Submit button to PurchasesPerSupplierTab 2025-12-15 11:41:12 +07:00
rstubryan 5c9332537c feat(FE-363): Add pagination to purchases per supplier report 2025-12-15 11:08:05 +07:00
rstubryan 63c2a240d2 refactor(FE-363): Use SWR key+fetcher with params for logistic report 2025-12-13 12:03:56 +07:00
rstubryan fd2e1f8b96 refactor(FE-363): Replace LogisticService with LogisticApi instance 2025-12-13 11:51:41 +07:00
rstubryan fdb3e0481a refactor(FE-363): Rename response variable to purchasePerSupplier 2025-12-13 11:46:00 +07:00
rstubryan 9bc632c286 feat(FE-361): Add Reset button to clear report filters 2025-12-13 11:34:37 +07:00
rstubryan 81f98c5f06 feat(FE-361): Add pagination control to supplier purchases table 2025-12-13 11:21:04 +07:00
rstubryan 0983f154d2 refactor(FE-363): Rename SupplierWithItems type for clarity 2025-12-13 10:57:56 +07:00
rstubryan bd4c51cb04 refactor(FE-361,363): Refactor purchases-per-supplier report to use API 2025-12-13 10:55:15 +07:00
randy-ar 9c09395677 feat(FE-338): Slicing UI Halaman Reporting BOP & API integration & refactor debounce input: adding useEffect for sync value 2025-12-11 18:23:55 +07:00
rstubryan 67b5187d39 feat(FE-363): Add Logistic API service and update types 2025-12-11 15:47:21 +07:00
rstubryan 5de5dcffc0 fix(FE): Area import path in logistic-stock types 2025-12-11 15:28:26 +07:00
rstubryan 51ff739926 Merge branch 'dev/hotfix/restu' of gitlab.com:mbugroup/lti-web-client into feat/FE/US-339/TASK-361-362-363-slicing-purchase-and-integrate-purchase-report-page 2025-12-11 15:23:15 +07:00
rstubryan 238edfeca2 Merge branch 'development' of gitlab.com:mbugroup/lti-web-client into feat/FE/US-339/TASK-361-362-363-slicing-purchase-and-integrate-purchase-report-page 2025-12-11 15:22:21 +07:00
rstubryan bd8d121113 feat(FE-344,345): Integrate HPP Ekspedisi into Closing detail 2025-12-11 15:04:37 +07:00
rstubryan 38b91a57f0 refactor(FE-345): Remove unused fields from BaseClosingSales 2025-12-11 14:43:54 +07:00
randy-ar d0abc0e9ff fix(FE): adjust inventory adjustment and inventory product table 2025-12-11 14:35:27 +07:00
rstubryan 4262e8e286 refactor(FE-344): Add Cost of Revenue Expedition table 2025-12-11 14:27:29 +07:00
randy-ar 48c163c1cd fix(FE): remove pengajuan from project flock kandang approval lines 2025-12-11 14:00:46 +07:00
rstubryan 3c03494bd3 Merge branch 'development' of gitlab.com:mbugroup/lti-web-client into feat/FE/US-334/TASK-344-345-slicing-and-integrate-expedition-hpp-report-table 2025-12-11 14:00:19 +07:00
randy-ar 4ea56f2e18 fix(FE): fixing closing button project flock 2025-12-11 01:20:48 +07:00
rstubryan 312580a7fc Merge branch 'development' of gitlab.com:mbugroup/lti-web-client into feat/FE/US-339/TASK-361-362-363-slicing-purchase-and-integrate-purchase-report-page 2025-12-10 15:37:16 +07:00
rstubryan 9c7033b53a feat(FE-361): Migrate main drawer links to SidebarMenuItem 2025-12-10 14:17:12 +07:00
rstubryan 07bfe0a20b Merge branch 'development' of gitlab.com:mbugroup/lti-web-client into feat/FE/US-339/TASK-361-362-363-slicing-purchase-and-integrate-purchase-report-page 2025-12-10 14:12:25 +07:00
rstubryan e23b698fc7 feat(FE-363): Add TypeScript definitions for logistic stock report 2025-12-10 11:18:54 +07:00
rstubryan e3f90a49d0 feat(FE-361): Extract LogisticStockTabs component 2025-12-10 09:22:09 +07:00
rstubryan a1679ba5ff feat(FE-363): Add data type and date range filters 2025-12-09 21:49:26 +07:00
rstubryan 8a7149c123 feat(FE-361): Add logistic stock tabs and tweak styles 2025-12-09 20:19:00 +07:00
rstubryan f87854ed07 refactor(FE-361): Remove wrapper top margin and clear table margin 2025-12-09 18:51:36 +07:00
rstubryan 1ef7130661 refactor(FE-344): Export TABLE_DEFAULT_STYLING and refine classes 2025-12-09 18:45:38 +07:00
rstubryan 066c356d4f refactor(FE-339): Export TABLE_DEFAULT_STYLING and refine table classes 2025-12-09 18:44:35 +07:00
rstubryan 8f5dd1851a refactor(FE-361): Refactor table and pagination components 2025-12-09 18:04:33 +07:00
rstubryan 6a926f881d feat(FE-334): Use column footers and fix closing loading check 2025-12-09 17:51:11 +07:00
rstubryan 68dd5b1121 refactor(FE-344): Add table cell side borders in sales report 2025-12-09 17:49:50 +07:00
rstubryan 5a3c7d71b0 refactor(FE-345): HPP ekspedisi API path to use /closings 2025-12-09 17:48:03 +07:00
rstubryan 5ad61d483a refactor(FE-344): update pagination UI and table footer handling 2025-12-09 16:47:59 +07:00
rstubryan b039ec832b feat(FE-361): Add logistic-stock report page and table footer 2025-12-09 15:49:59 +07:00
rstubryan d7384752a0 feat(FE-361): Add Laporan report menu with logistic submenu 2025-12-09 14:11:15 +07:00
rstubryan dfecef2e0c feat(FE-344,345): Fetch and render HPP Ekspedisi report 2025-12-09 13:28:47 +07:00
rstubryan 80fd8bb7ba feat(FE-344,345): Add CosExpeditionReportTable component 2025-12-09 13:28:14 +07:00
rstubryan 44b9f94cec feat(FE-345): Add getHppEkspedisi to ClosingApiService 2025-12-09 13:27:15 +07:00
rstubryan e3b3f5ccdc feat(FE-345): Add Cost of Services expedition types and export
ClosingSales
2025-12-09 13:26:19 +07:00
333 changed files with 43556 additions and 7368 deletions
+47 -27
View File
@@ -2,6 +2,17 @@ stages:
- build
- deploy
# ==========================================================
# ✅ Global defaults
# ==========================================================
default:
tags:
- server-development-biznet
interruptible: true
# ==========================================================
# 🏗️ Build Template
# ==========================================================
.build_template: &build_template
stage: build
image: node:20-alpine
@@ -39,6 +50,9 @@ stages:
- out/
expire_in: 1 week
# ==========================================================
# 🚀 Deploy Template
# ==========================================================
.deploy_template: &deploy_template
stage: deploy
image:
@@ -73,8 +87,8 @@ stages:
if [ "$CI_COMMIT_BRANCH" = "development" ]; then
ENVIRONMENT_NAME="WEB-LTI-DEV"
elif [ "$CI_COMMIT_BRANCH" = "master" ]; then
ENVIRONMENT_NAME="WEB-LTI-PROD"
elif [ "$CI_COMMIT_BRANCH" = "staging" ]; then
ENVIRONMENT_NAME="WEB-LTI-STAGING"
else
ENVIRONMENT_NAME="UNKNOWN"
fi
@@ -82,11 +96,11 @@ stages:
if [ "$STATUS" = "success" ]; then
COLOR=3066993
TITLE="✅ Deployment ${ENVIRONMENT_NAME} Succeeded"
DESC="Deployment job on branch \`${CI_COMMIT_REF_NAME}\` completed successfully."
DESC="Deployment job on branch \${CI_COMMIT_REF_NAME}\ completed successfully."
else
COLOR=15158332
TITLE="❌ Deployment ${ENVIRONMENT_NAME} Failed"
DESC="Deployment job on branch \`${CI_COMMIT_REF_NAME}\` encountered issues."
DESC="Deployment job on branch \${CI_COMMIT_REF_NAME}\ encountered issues."
fi
jq -n \
@@ -114,7 +128,9 @@ stages:
curl -sS -H "Content-Type: application/json" -d @payload.json "$DISCORD_WEBHOOK_URL"
# ====== DEVELOPMENT (Branch development) ======
# ==========================================================
# ==== DEVELOPMENT (Branch development) ======
# ==========================================================
build:dev:
<<: *build_template
rules:
@@ -122,8 +138,6 @@ build:dev:
environment:
name: development
variables:
# NEXT_PUBLIC_API_BASE_URL: 'https://dev-api-lti.mbugroup.id'
# NEXT_PUBLIC_SSO_LOGIN_URL: 'https://dev-api-sso.mbugroup.id'
NEXT_PUBLIC_LTI_URL: 'https://dev-lti-erp.mbugroup.id'
NEXT_PUBLIC_SSO_LOGIN_URL: 'https://dev-auth-erp.mbugroup.id'
NEXT_PUBLIC_API_BASE_URL: 'https://dev-api-lti.mbugroup.id/api'
@@ -141,25 +155,31 @@ deploy:dev:
environment:
name: development
url: https://dev-lti-erp.mbugroup.id
# ====== PRODUCTION ======
# build:production:
# <<: *build_template
# rules:
# # pilih salah satu: pakai branch master ATAU pakai tags rilis
# - if: '$CI_COMMIT_BRANCH == "master"'
# # - if: '$CI_COMMIT_TAG' # kalau mau rilis via tag, uncomment ini dan hapus baris di atas
# environment:
# name: production
# deploy:production:
# <<: *deploy_template
# needs: ["build:production"]
# rules:
# - if: '$CI_COMMIT_BRANCH == "master"'
# # - if: '$CI_COMMIT_TAG' # selaras dengan rule di build:production
# variables:
# S3_BUCKET: "lti-erp.mbugroup.id"
# CLOUDFRONT_DISTRIBUTION_ID: "ddfd"
# environment:
# name: production
# ==========================================================
# ====== STAGING (Branch staging) ======
# ==========================================================
build:staging:
<<: *build_template
rules:
- if: '$CI_COMMIT_BRANCH == "staging"'
environment:
name: staging
variables:
NEXT_PUBLIC_LTI_URL: 'https://stg-lti-erp.mbugroup.id'
NEXT_PUBLIC_SSO_LOGIN_URL: 'https://stg-auth-erp.mbugroup.id'
NEXT_PUBLIC_API_BASE_URL: 'https://stg-api-lti.mbugroup.id/api'
NEXT_PUBLIC_CLIENT_ID: 'Lumbung-Telur-Indonesia'
deploy:staging:
<<: *deploy_template
needs: ['build:staging']
rules:
- if: '$CI_COMMIT_BRANCH == "staging"'
variables:
S3_BUCKET: 'stg-lti-erp.mbugroup.id'
AWS_REGION: 'ap-southeast-3'
CLOUDFRONT_DISTRIBUTION_ID: 'E2V6PPO1AUIU7H'
environment:
name: staging
url: https://stg-lti-erp.mbugroup.id
+1 -1
View File
@@ -1,3 +1,3 @@
npm run format
npm run lint
npm run build
npx tsc --noEmit
+3431 -103
View File
File diff suppressed because it is too large Load Diff
+18 -4
View File
@@ -15,21 +15,35 @@
"@tanstack/match-sorter-utils": "^8.19.4",
"@tanstack/react-table": "^8.21.3",
"axios": "^1.12.2",
"class-variance-authority": "^0.7.1",
"clsx": "^2.1.1",
"cmdk": "^1.1.1",
"embla-carousel-react": "^8.6.0",
"formik": "^2.4.6",
"input-otp": "^1.4.2",
"jspdf": "^3.0.4",
"jspdf-autotable": "^5.0.2",
"lucide-react": "^0.562.0",
"moment": "^2.30.1",
"next": "^15.5.9",
"react": "19.1.0",
"next": "15.5.9",
"next-themes": "^0.4.6",
"radix-ui": "^1.4.3",
"react": "^19.1.2",
"react-day-picker": "^9.11.1",
"react-dom": "19.1.0",
"react-dom": "^19.1.2",
"react-dropzone": "^14.3.8",
"react-hook-form": "^7.70.0",
"react-hot-toast": "^2.6.0",
"react-number-format": "^5.4.4",
"react-resizable-panels": "2.1.7",
"react-select": "^5.10.2",
"recharts": "^3.6.0",
"sonner": "^2.0.7",
"swr": "^2.3.6",
"tailwind-merge": "^3.3.1",
"use-debounce": "^10.0.6",
"xlsx": "^0.18.5",
"vaul": "^1.1.2",
"xlsx": "https://cdn.sheetjs.com/xlsx-0.20.3/xlsx-0.20.3.tgz",
"yup": "^1.7.0",
"zustand": "^5.0.8"
},
+37 -1
View File
@@ -7,23 +7,43 @@ import ClosingDetail from '@/components/pages/closing/ClosingDetail';
import { ClosingApi } from '@/services/api/closing';
import { isResponseError, isResponseSuccess } from '@/lib/api-helper';
import { FlockApi } from '@/services/api/master-data';
import { ProjectFlockApi } from '@/services/api/production/project-flock';
import { ProjectFlockKandangApi } from '@/services/api/production';
const ClosingDetailPage = () => {
const router = useRouter();
const searchParams = useSearchParams();
const closingId = searchParams.get('closingId');
const kandangId = searchParams.get('kandangId'); // project flock kandang ID
const { data: closing, isLoading: isLoadingClosing } = useSWR(
closingId,
(id: number) => ClosingApi.getGeneralInfo(id)
);
// WORKAROUND - get flock data from closing ID
const { data: projectData, isLoading: isLoadingProject } = useSWR(
`flock-${closingId}`,
() => ProjectFlockApi.getSingle(Number(closingId))
);
// WORKAROUND - get kandang data from closing ID
const { data: kandangData, isLoading: isLoadingKandang } = useSWR(
kandangId ? `kandang-${closingId}-${kandangId}` : null,
() => ProjectFlockKandangApi.getSingle(Number(kandangId))
);
const { data: salesData, isLoading: isLoadingSales } = useSWR(
closingId ? `sales-${closingId}` : null,
() => ClosingApi.getPenjualan(Number(closingId))
);
const { data: hppEkspedisiData, isLoading: isLoadingHppEkspedisi } = useSWR(
closingId ? `hpp-ekspedisi-${closingId}` : null,
() => ClosingApi.getHppEkspedisi(Number(closingId))
);
if (!closingId) {
router.back();
@@ -39,7 +59,12 @@ const ClosingDetailPage = () => {
return;
}
const isLoading = isLoadingClosing || isLoadingSales;
const isLoading =
isLoadingClosing ||
isLoadingSales ||
isLoadingHppEkspedisi ||
isLoadingProject ||
isLoadingKandang;
return (
<div className='w-full p-4 flex flex-row justify-center'>
@@ -50,6 +75,17 @@ const ClosingDetailPage = () => {
id={Number(closingId)}
initialValue={closing.data}
salesData={isResponseSuccess(salesData) ? salesData.data : undefined}
hppExpeditionData={
isResponseSuccess(hppEkspedisiData)
? hppEkspedisiData.data
: undefined
}
projectData={
isResponseSuccess(projectData) ? projectData.data : undefined
}
kandangData={
isResponseSuccess(kandangData) ? kandangData.data : undefined
}
/>
)}
</div>
@@ -0,0 +1,11 @@
import { DailyChecklistContent } from '@/figma-make/components/pages/daily-checklist/DailyChecklistContent';
const DailyChecklistPage = () => {
return (
<section className='w-full'>
<DailyChecklistContent />
</section>
);
};
export default DailyChecklistPage;
@@ -0,0 +1,11 @@
import { Dashboard as DashboardDailyChecklist } from '@/figma-make/components/pages/dashboard/Dashboard';
const DailyChecklistDashboardPage = () => {
return (
<section className='w-full'>
<DashboardDailyChecklist />
</section>
);
};
export default DailyChecklistDashboardPage;
@@ -0,0 +1,11 @@
import { DetailDailyChecklistContent } from '@/figma-make/components/pages/list-daily-checklist/detail/DetailDailyChecklistContent';
const ListDailyChecklistDetailPage = () => {
return (
<section className='w-full'>
<DetailDailyChecklistContent />
</section>
);
};
export default ListDailyChecklistDetailPage;
@@ -0,0 +1,11 @@
import { ListDailyChecklistContent } from '@/figma-make/components/pages/list-daily-checklist/ListDailyChecklistContent';
const ListDailyChecklistPage = () => {
return (
<section className='w-full'>
<ListDailyChecklistContent />
</section>
);
};
export default ListDailyChecklistPage;
@@ -0,0 +1,11 @@
import { MasterAktivitasContent } from '@/figma-make/components/pages/master-data/activity/MasterAktivitasContent';
const MasterAktivitasPage = () => {
return (
<section className='w-full'>
<MasterAktivitasContent />
</section>
);
};
export default MasterAktivitasPage;
@@ -0,0 +1,11 @@
import { MasterConfigurationContent } from '@/figma-make/components/pages/master-data/configuration/MasterConfigurationContent';
const MasterConfigurationPage = () => {
return (
<section className='w-full'>
<MasterConfigurationContent />
</section>
);
};
export default MasterConfigurationPage;
@@ -0,0 +1,11 @@
import { MasterEmployeeContent } from '@/figma-make/components/pages/master-data/employee/MasterEmployeeContent';
const MasterEmployeePage = () => {
return (
<section className='w-full'>
<MasterEmployeeContent />
</section>
);
};
export default MasterEmployeePage;
+11
View File
@@ -0,0 +1,11 @@
import { DailyChecklistReportsContent } from '@/figma-make/components/pages/reports/DailyChecklistReportsContent';
const DailyChecklistReportsPage = () => {
return (
<section className='w-full'>
<DailyChecklistReportsContent />
</section>
);
};
export default DailyChecklistReportsPage;
+3 -5
View File
@@ -1,9 +1,7 @@
import DashboardProduction from '@/components/pages/dashboard/DashboardProduction';
const Dashboard = () => {
return (
<section className='w-full p-4'>
<h1 className='text-3xl font-bold text-primary'>Dashboard</h1>
</section>
);
return <DashboardProduction />;
};
export default Dashboard;
+1 -1
View File
@@ -37,7 +37,7 @@ const ExpenseRealization = () => {
const isExpenseCanBeRealized =
isResponseSuccess(expense) &&
expense.data.latest_approval.action !== 'REJECTED' &&
expense.data.latest_approval.step_number === 3;
expense.data.latest_approval.step_number === 4;
if (isResponseSuccess(expense) && !isExpenseCanBeRealized) {
if (typeof window !== 'undefined') {
+5
View File
@@ -0,0 +1,5 @@
const FinanceAdjust = () => {
return <div>Finance Adjust</div>;
};
export default FinanceAdjust;
@@ -0,0 +1,7 @@
import FormFinanceAddInitialBalance from '@/components/pages/finance/add/initial-balance/FormFinanceAddInitialBalance';
const FinanceAddInitialBalancePage = () => {
return <FormFinanceAddInitialBalance type='add' />;
};
export default FinanceAddInitialBalancePage;
+7
View File
@@ -0,0 +1,7 @@
import FormFinanceInjection from '@/components/pages/finance/add/injection/FormFinanceInjection';
const FinanceAddInjectionPage = () => {
return <FormFinanceInjection type='add' />;
};
export default FinanceAddInjectionPage;
+7
View File
@@ -0,0 +1,7 @@
import FormFinanceAdd from '@/components/pages/finance/add/FormFinanceAdd';
const FinanceAddPage = () => {
return <FormFinanceAdd />;
};
export default FinanceAddPage;
@@ -0,0 +1,51 @@
'use client';
import { useRouter, useSearchParams } from 'next/navigation';
import useSWR from 'swr';
import { FinanceApi } from '@/services/api/finance';
import { isResponseError, isResponseSuccess } from '@/lib/api-helper';
import FormFinanceAddInitialBalance from '@/components/pages/finance/add/initial-balance/FormFinanceAddInitialBalance';
const EditFinanceInitialBalancePage = () => {
const router = useRouter();
const searchParams = useSearchParams();
const financeId = searchParams.get('financeId');
const { data: finance, isLoading: isLoadingFinance } = useSWR(
financeId,
(id: number) => FinanceApi.getSingle(id)
);
if (!financeId) {
router.back();
return (
<div className='w-full flex flex-row justify-center items-center p-4'>
<span className='loading loading-spinner loading-xl' />
</div>
);
}
if (!isLoadingFinance && (!finance || isResponseError(finance))) {
router.replace('/404');
return;
}
return (
<div className='w-full p-4 flex flex-row justify-center'>
{isLoadingFinance && (
<span className='loading loading-spinner loading-xl' />
)}
{!isLoadingFinance && (
<FormFinanceAddInitialBalance
type='edit'
initialValues={isResponseSuccess(finance) ? finance.data : undefined}
/>
)}
</div>
);
};
export default EditFinanceInitialBalancePage;
@@ -0,0 +1,51 @@
'use client';
import { useRouter, useSearchParams } from 'next/navigation';
import useSWR from 'swr';
import { FinanceApi } from '@/services/api/finance';
import { isResponseError, isResponseSuccess } from '@/lib/api-helper';
import FormFinanceInjection from '@/components/pages/finance/add/injection/FormFinanceInjection';
const EditFinanceInjectionPage = () => {
const router = useRouter();
const searchParams = useSearchParams();
const financeId = searchParams.get('financeId');
const { data: finance, isLoading: isLoadingFinance } = useSWR(
financeId,
(id: number) => FinanceApi.getSingle(id)
);
if (!financeId) {
router.back();
return (
<div className='w-full flex flex-row justify-center items-center p-4'>
<span className='loading loading-spinner loading-xl' />
</div>
);
}
if (!isLoadingFinance && (!finance || isResponseError(finance))) {
router.replace('/404');
return;
}
return (
<div className='w-full p-4 flex flex-row justify-center'>
{isLoadingFinance && (
<span className='loading loading-spinner loading-xl' />
)}
{!isLoadingFinance && (
<FormFinanceInjection
type='edit'
initialValues={isResponseSuccess(finance) ? finance.data : undefined}
/>
)}
</div>
);
};
export default EditFinanceInjectionPage;
+52
View File
@@ -0,0 +1,52 @@
'use client';
import { useRouter, useSearchParams } from 'next/navigation';
import useSWR from 'swr';
import { FinanceApi } from '@/services/api/finance';
import { isResponseError, isResponseSuccess } from '@/lib/api-helper';
import FormFinanceAdd from '@/components/pages/finance/add/FormFinanceAdd';
import FormFinanceAddInitialBalance from '@/components/pages/finance/add/initial-balance/FormFinanceAddInitialBalance';
const EditFinanceTransactionPage = () => {
const router = useRouter();
const searchParams = useSearchParams();
const financeId = searchParams.get('financeId');
const { data: finance, isLoading: isLoadingFinance } = useSWR(
financeId,
(id: number) => FinanceApi.getSingle(id)
);
if (!financeId) {
router.back();
return (
<div className='w-full flex flex-row justify-center items-center p-4'>
<span className='loading loading-spinner loading-xl' />
</div>
);
}
if (!isLoadingFinance && (!finance || isResponseError(finance))) {
router.replace('/404');
return;
}
return (
<div className='w-full p-4 flex flex-row justify-center'>
{isLoadingFinance && (
<span className='loading loading-spinner loading-xl' />
)}
{!isLoadingFinance && (
<FormFinanceAdd
type='edit'
initialValues={isResponseSuccess(finance) ? finance.data : undefined}
/>
)}
</div>
);
};
export default EditFinanceTransactionPage;
+11
View File
@@ -0,0 +1,11 @@
import SuspenseHelper from '@/components/helper/SuspenseHelper';
const Layout = ({
children,
}: Readonly<{
children: React.ReactNode;
}>) => {
return <SuspenseHelper>{children}</SuspenseHelper>;
};
export default Layout;
+41
View File
@@ -0,0 +1,41 @@
'use client';
import FinanceDetail from '@/components/pages/finance/FinanceDetail';
import useSWR from 'swr';
import { useRouter, useSearchParams } from 'next/navigation';
import { FinanceApi } from '@/services/api/finance';
import { isResponseError, isResponseSuccess } from '@/lib/api-helper';
const FinanceDetailPage = () => {
const router = useRouter();
const financeId = useSearchParams().get('financeId');
const { data: finance } = useSWR(financeId, () =>
FinanceApi.getSingle(Number(financeId))
);
if (!financeId) {
router.back();
return (
<div className='w-full flex flex-row justify-center items-center p-4'>
<span className='loading loading-spinner loading-xl' />
</div>
);
}
console.log(finance);
// if (!finance || isResponseError(finance)) {
// router.replace('/404');
// return;
// }
return (
<>
{isResponseSuccess(finance) && <FinanceDetail finance={finance.data} />}
</>
);
};
export default FinanceDetailPage;
+14
View File
@@ -0,0 +1,14 @@
'use client';
import FinanceTable from '@/components/pages/finance/FinanceTable';
const Finance = () => {
return (
<section className='size-full p-6'>
<div className='flex flex-row gap-4'></div>
<FinanceTable />
</section>
);
};
export default Finance;
+1
View File
@@ -1,6 +1,7 @@
@import 'tailwindcss';
@plugin "daisyui";
@import '../styles/daisyui.css';
@import '../figma-make/styles/theme.css';
@plugin "daisyui/theme" {
name: 'lti';
+2
View File
@@ -3,6 +3,7 @@ import { Inter } from 'next/font/google';
import '@/app/globals.css';
import { Toaster } from 'react-hot-toast';
import { Toaster as SonnerToaster } from '@/figma-make/components/base/sonner';
import MainDrawer from '@/components/MainDrawer';
import RequireAuth from '@/components/helper/RequireAuth';
@@ -35,6 +36,7 @@ export default function RootLayout({
</RequireAuth>
<Toaster />
<SonnerToaster position='top-right' />
</body>
</html>
);
@@ -0,0 +1,13 @@
'use client';
import ProductionStandardForm from '@/components/pages/master-data/production-standard/form/ProductionStandardForm';
const AddProductionStandardPage = () => {
return (
<>
<ProductionStandardForm formType='add' />
</>
);
};
export default AddProductionStandardPage;
@@ -0,0 +1,56 @@
'use client';
import ProductionStandardForm from '@/components/pages/master-data/production-standard/form/ProductionStandardForm';
import { isResponseError, isResponseSuccess } from '@/lib/api-helper';
import { ProductionStandardApi } from '@/services/api/master-data';
import { useRouter, useSearchParams } from 'next/navigation';
import useSWR from 'swr';
const EditProductionStandardPage = () => {
const router = useRouter();
const searchParams = useSearchParams();
// Get Query Params
const productionStandardId = searchParams.get('productionStandardId');
// Fetch Data
const { data: productionStandard, isLoading: isLoadingProductionStandard } =
useSWR(productionStandardId, (id: number) =>
ProductionStandardApi.getSingle(id)
);
if (!productionStandardId) {
router.back();
return (
<div className='w-full flex flex-row justify-center items-center p-4'>
<span className='loading loading-spinner loading-xl' />
</div>
);
}
if (
!isLoadingProductionStandard &&
(!productionStandard || isResponseError(productionStandard))
) {
router.replace('/404');
return;
}
return (
<>
{isLoadingProductionStandard && (
<span className='loading loading-spinner loading-xl' />
)}
{!isLoadingProductionStandard &&
isResponseSuccess(productionStandard) && (
<ProductionStandardForm
formType='edit'
initialValue={productionStandard.data}
/>
)}
</>
);
};
export default EditProductionStandardPage;
@@ -0,0 +1,11 @@
import SuspenseHelper from '@/components/helper/SuspenseHelper';
const Layout = ({
children,
}: Readonly<{
children: React.ReactNode;
}>) => {
return <SuspenseHelper>{children}</SuspenseHelper>;
};
export default Layout;
@@ -0,0 +1,56 @@
'use client';
import ProductionStandardForm from '@/components/pages/master-data/production-standard/form/ProductionStandardForm';
import { isResponseError, isResponseSuccess } from '@/lib/api-helper';
import { ProductionStandardApi } from '@/services/api/master-data';
import { useRouter, useSearchParams } from 'next/navigation';
import useSWR from 'swr';
const DetailProductionStandardPage = () => {
const router = useRouter();
const searchParams = useSearchParams();
// Get Query Params
const productionStandardId = searchParams.get('productionStandardId');
// Fetch Data
const { data: productionStandard, isLoading: isLoadingProductionStandard } =
useSWR(productionStandardId, (id: number) =>
ProductionStandardApi.getSingle(id)
);
if (!productionStandardId) {
router.back();
return (
<div className='w-full flex flex-row justify-center items-center p-4'>
<span className='loading loading-spinner loading-xl' />
</div>
);
}
if (
!isLoadingProductionStandard &&
(!productionStandard || isResponseError(productionStandard))
) {
router.replace('/404');
return;
}
return (
<>
{isLoadingProductionStandard && (
<span className='loading loading-spinner loading-xl' />
)}
{!isLoadingProductionStandard &&
isResponseSuccess(productionStandard) && (
<ProductionStandardForm
formType='detail'
initialValue={productionStandard.data}
/>
)}
</>
);
};
export default DetailProductionStandardPage;
@@ -0,0 +1,11 @@
import ProductionStandardTable from '@/components/pages/master-data/production-standard/ProductionStandardTable';
const ProductionStandardPage = () => {
return (
<div className='w-full'>
<ProductionStandardTable />
</div>
);
};
export default ProductionStandardPage;
@@ -1,20 +0,0 @@
'use client';
import { FormHeader } from '@/components/helper/form/FormHeader';
import ProjectFlockChickinDetail from '@/components/pages/production/project-flock/chickin/ProjectFlockChickinDetail';
import { useSearchParams } from 'next/navigation';
const AddChickin = () => {
const searchParams = useSearchParams();
const projectFlockId = searchParams.get('projectFlockId');
return (
<>
<section className='w-full'>
<ProjectFlockChickinDetail projectFlockId={Number(projectFlockId)} />
</section>
</>
);
};
export default AddChickin;
@@ -1,10 +0,0 @@
import ChickinTable from '@/components/pages/production/chickin/ChickinTable';
const Chickin = () => {
return (
<section className='w-full'>
<ChickinTable />
</section>
);
};
export default Chickin;
@@ -0,0 +1,7 @@
import UniformityForm from '@/components/pages/production/uniformity/form/UniformityForm';
const AddUniformity = () => {
return <UniformityForm formType='add' />;
};
export default AddUniformity;
@@ -0,0 +1,49 @@
'use client';
import UniformityDetail from '@/components/pages/production/uniformity/detail/UniformityDetail';
import { isResponseError, isResponseSuccess } from '@/lib/api-helper';
import { UniformityApi } from '@/services/api/uniformity';
import { useRouter, useSearchParams } from 'next/navigation';
import useSWR from 'swr';
const UniformityDetailPage = () => {
const router = useRouter();
const searchParams = useSearchParams();
const uniformityId = searchParams.get('uniformityId');
const { data: uniformity, isLoading: isLoadingUniformity } = useSWR(
uniformityId,
(id: string) => UniformityApi.getUniformityDetail(parseInt(id))
);
if (!uniformityId) {
router.back();
return (
<div className='w-full flex flex-row justify-center items-center p-4'>
<span className='loading loading-spinner loading-xl' />
</div>
);
}
if (!isLoadingUniformity && (!uniformity || isResponseError(uniformity))) {
router.replace('/404');
return;
}
return (
<div className='w-full h-full flex flex-col justify-center'>
{isLoadingUniformity && (
<div className='w-full flex flex-row justify-center items-center p-4 min-h-screen'>
<span className='loading loading-spinner loading-xl' />
</div>
)}
{isResponseSuccess(uniformity) && (
<UniformityDetail initialValues={uniformity.data} />
)}
</div>
);
};
export default UniformityDetailPage;
+10
View File
@@ -0,0 +1,10 @@
import { ReactNode } from 'react';
import UniformityPageWrapper from '@/components/pages/production/uniformity/UniformityPageWrapper';
export default function UniformityLayout({
children,
}: {
children: ReactNode;
}) {
return <UniformityPageWrapper>{children}</UniformityPageWrapper>;
}
+7
View File
@@ -0,0 +1,7 @@
import UniformityTable from '@/components/pages/production/uniformity/UniformityTable';
const Uniformity = () => {
return <UniformityTable />;
};
export default Uniformity;
+11
View File
@@ -0,0 +1,11 @@
import SuspenseHelper from '@/components/helper/SuspenseHelper';
const Layout = ({
children,
}: Readonly<{
children: React.ReactNode;
}>) => {
return <SuspenseHelper>{children}</SuspenseHelper>;
};
export default Layout;
+5
View File
@@ -0,0 +1,5 @@
const ReportExpenseDetail = () => {
return <div>ReportExpenseDetail</div>;
};
export default ReportExpenseDetail;
+13
View File
@@ -0,0 +1,13 @@
'use client';
import ReportExpenseTable from '@/components/pages/report/expense/ReportExpenseTable';
const ReportExpense = () => {
return (
<div className='w-full p-4'>
<ReportExpenseTable />
</div>
);
};
export default ReportExpense;
+7
View File
@@ -0,0 +1,7 @@
import FinanceTabs from '@/components/pages/report/finance/FinanceTabs';
const Finance = () => {
return <FinanceTabs />;
};
export default Finance;
+11
View File
@@ -0,0 +1,11 @@
import SuspenseHelper from '@/components/helper/SuspenseHelper';
const Layout = ({
children,
}: Readonly<{
children: React.ReactNode;
}>) => {
return <SuspenseHelper>{children}</SuspenseHelper>;
};
export default Layout;
+7
View File
@@ -0,0 +1,7 @@
import LogisticStockTabs from '@/components/pages/report/logistic-stock/LogisticStockTabs';
const LogisticStock = () => {
return <LogisticStockTabs />;
};
export default LogisticStock;
+11
View File
@@ -0,0 +1,11 @@
import SuspenseHelper from '@/components/helper/SuspenseHelper';
const Layout = ({
children,
}: Readonly<{
children: React.ReactNode;
}>) => {
return <SuspenseHelper>{children}</SuspenseHelper>;
};
export default Layout;
+11
View File
@@ -0,0 +1,11 @@
import ProductionResultContent from '@/components/pages/report/production-result/ProductionResultContent';
const ProductionResultReportPage = () => {
return (
<section className='w-full max-w-7xl pb-16'>
<ProductionResultContent />
</section>
);
};
export default ProductionResultReportPage;
+34 -14
View File
@@ -3,29 +3,25 @@
import { HTMLAttributes, ReactNode } from 'react';
import { cn } from '@/lib/helper';
import type { Color, Variant, Size } from '@/types/theme';
export interface BadgeProps
extends Omit<HTMLAttributes<HTMLSpanElement>, 'className'> {
children?: ReactNode;
className?: {
badge?: string;
status?: string;
};
variant?: 'default' | 'outline' | 'ghost' | 'soft' | 'dash';
color?:
| 'neutral'
| 'primary'
| 'secondary'
| 'accent'
| 'info'
| 'success'
| 'warning'
| 'error';
size?: 'xs' | 'sm' | 'md' | 'lg' | 'xl';
statusIndicator?: boolean;
variant?: Variant;
color?: Color;
size?: Size;
}
const Badge = ({
children,
className,
statusIndicator = false,
variant = 'default',
color,
size = 'md',
@@ -34,7 +30,7 @@ const Badge = ({
const getBadgeClasses = () => {
const baseClasses = 'badge';
const variantClasses = {
const variantClasses: Record<Variant, string> = {
default: '',
outline: 'badge-outline',
ghost: 'badge-ghost',
@@ -42,7 +38,7 @@ const Badge = ({
dash: 'badge-dash',
};
const colorClasses = {
const colorClasses: Record<Color, string> = {
neutral: 'badge-neutral',
primary: 'badge-primary',
secondary: 'badge-secondary',
@@ -51,9 +47,10 @@ const Badge = ({
success: 'badge-success',
warning: 'badge-warning',
error: 'badge-error',
none: '',
};
const sizeClasses = {
const sizeClasses: Record<Size, string> = {
xs: 'badge-xs',
sm: 'badge-sm',
md: 'badge-md',
@@ -70,8 +67,31 @@ const Badge = ({
);
};
const getStatusClasses = () => {
if (!statusIndicator) return '';
const statusIndicatorClasses: Record<Color, string> = {
neutral: 'bg-neutral',
primary: 'bg-primary',
secondary: 'bg-secondary',
accent: 'bg-accent',
info: 'bg-info',
success: 'bg-success',
warning: 'bg-warning',
error: 'bg-error',
none: '',
};
return cn(
'w-2.5 h-2.5 rounded-full',
color && statusIndicatorClasses[color],
className?.status
);
};
return (
<span className={getBadgeClasses()} {...props}>
{statusIndicator && <span className={getStatusClasses()} />}
{children}
</span>
);
+44 -8
View File
@@ -15,6 +15,8 @@ interface DrawerProps {
className?: DrawerClassName;
onBackdropClick?: () => void;
closeOnBackdropClick?: boolean;
expandedContent?: ReactNode;
expandedWidth?: string;
}
type DrawerClassName = {
@@ -36,6 +38,8 @@ const Drawer = ({
className,
onBackdropClick,
closeOnBackdropClick = true,
expandedContent,
expandedWidth = 'w-[400px]',
}: DrawerProps) => {
const getDrawerClassNames = (): DrawerClassName => {
const baseClassNames = {
@@ -46,12 +50,21 @@ const Drawer = ({
drawerSidebarContent: 'min-h-full bg-base-100',
};
const getSidebarWidth = () => {
if (variant === 'sidebar') {
return expandedContent
? 'w-full lg:min-w-[600px] lg:max-w-[600px]'
: 'w-full max-w-[300px] lg:w-[300px]';
}
return 'w-full sm:min-w-120 sm:w-fit';
};
if (variant === 'sidebar') {
return {
...baseClassNames,
drawerSidebarContent: cn(
baseClassNames.drawerSidebarContent,
'w-full max-w-[300px] lg:w-[300px]'
getSidebarWidth()
),
};
} else if (variant === 'right') {
@@ -60,11 +73,11 @@ const Drawer = ({
drawer: cn(baseClassNames.drawer, 'drawer-end'),
drawerSide: cn(
baseClassNames.drawerSide,
'border-l border-solid border-gray-200 drawer-side w-screen top-0 right-0 fixed z-21'
'border-l border-solid border-gray-200 sm:drawer-side w-screen top-0 right-0 fixed z-21'
),
drawerSidebarContent: cn(
baseClassNames.drawerSidebarContent,
'w-full min-w-120 sm:w-fit'
getSidebarWidth()
),
};
} else if (variant === 'left') {
@@ -76,7 +89,7 @@ const Drawer = ({
),
drawerSidebarContent: cn(
baseClassNames.drawerSidebarContent,
'w-full min-w-120 sm:w-fit'
getSidebarWidth()
),
};
}
@@ -138,14 +151,37 @@ const Drawer = ({
onClick={closeDrawer}
/>
{/* Sidebar Content */}
{/* Sidebar Content - Full height container */}
<div
className={cn(
varianClassName?.drawerSidebarContent,
className?.drawerContent
'flex h-screen bg-base-100 overflow-hidden',
variant === 'right' && 'flex-row'
)}
>
{sidebarContent}
{/* Primary Sidebar Content */}
<div
className={cn(
varianClassName?.drawerSidebarContent,
className?.drawerContent,
'overflow-y-auto'
)}
>
{sidebarContent}
</div>
{/* Expanded Drawer (Right side, side-by-side) */}
{expandedContent && (
<div
className={cn(
'border-l border-gray-200 bg-white flex flex-col h-full',
expandedWidth
)}
>
<div className='overflow-y-auto flex-1 h-full'>
{expandedContent}
</div>
</div>
)}
</div>
</div>
</div>
+114
View File
@@ -0,0 +1,114 @@
import React, { ReactNode, useState, useRef } from 'react';
import { cn } from '@/lib/helper';
export interface DropdownProps {
trigger: ReactNode;
children: ReactNode;
className?: {
wrapper?: string;
trigger?: string;
content?: string;
};
align?: 'start' | 'center' | 'end';
direction?: 'top' | 'bottom' | 'left' | 'right';
hover?: boolean;
defaultOpen?: boolean;
open?: boolean;
close?: boolean;
controlled?: boolean;
}
const Dropdown = ({
trigger,
children,
className,
align,
direction,
hover,
defaultOpen = false,
open,
close,
controlled = false,
}: DropdownProps) => {
const [isOpen, setIsOpen] = useState(defaultOpen);
const dropdownRef = useRef<HTMLDivElement>(null);
const toggleDropdown = () => {
if (!controlled) {
const newState = !isOpen;
setIsOpen(newState);
}
};
const getWrapperClasses = () => {
const openState = controlled ? open : isOpen;
return cn(
'dropdown',
{
'dropdown-start': align === 'start',
'dropdown-center': align === 'center',
'dropdown-end': align === 'end',
'dropdown-top': direction === 'top',
'dropdown-bottom': direction === 'bottom',
'dropdown-left': direction === 'left',
'dropdown-right': direction === 'right',
'dropdown-hover': hover,
'dropdown-open': openState && !close,
'dropdown-close': close,
},
className?.wrapper
);
};
const getTriggerClasses = () => {
return cn(className?.trigger);
};
const getContentClasses = () => {
return cn(
'dropdown-content z-[9999] shadow-sm bg-base-100 rounded-box',
className?.content
);
};
if (controlled) {
return (
<div className={getWrapperClasses()}>
{trigger}
{open && !close && (
<div tabIndex={-1} className={getContentClasses()}>
{children}
</div>
)}
</div>
);
}
return (
<div ref={dropdownRef} className={getWrapperClasses()}>
<div
tabIndex={0}
role='button'
className={getTriggerClasses()}
onClick={toggleDropdown}
onKeyDown={(e) => {
if (e.key === 'Enter' || e.key === ' ') {
e.preventDefault();
toggleDropdown();
}
}}
>
{trigger}
</div>
{!close && (
<div tabIndex={-1} className={getContentClasses()}>
{children}
</div>
)}
</div>
);
};
export default Dropdown;
+56 -26
View File
@@ -5,6 +5,8 @@ import Tooltip from '@/components/Tooltip';
import { cn } from '@/lib/helper';
import { Icon } from '@iconify/react';
import { useAuth } from '@/services/hooks/useAuth';
type FloatingActionsButtonProps = {
actions: {
action: 'DETAIL' | 'EDIT' | 'DELETE';
@@ -13,6 +15,7 @@ type FloatingActionsButtonProps = {
onClick?: () => void;
hidden?: boolean;
disabled?: boolean;
permissions?: string | string[];
}[];
approvals: {
action: 'APPROVED' | 'REJECTED';
@@ -20,6 +23,7 @@ type FloatingActionsButtonProps = {
label?: string;
onClick?: () => void;
disabled?: boolean;
permissions?: string | string[];
}[];
selectedRowIds: number[];
onClose: () => void;
@@ -31,9 +35,12 @@ const FloatingActionsButton = ({
selectedRowIds,
onClose,
}: FloatingActionsButtonProps) => {
const { permissionCheck } = useAuth();
// Jika tidak ada baris yang dipilih, jangan tampilkan FAB
const positionStyles =
selectedRowIds.length > 0 ? 'bottom-[10%]' : 'bottom-[-100%]';
selectedRowIds.length > 0
? 'bottom-[5%] opacity-100'
: 'bottom-[-5%] opacity-0';
// Helper untuk menentukan gaya warna tombol approval
const getApprovalColor = (action: 'APPROVED' | 'REJECTED') => {
@@ -53,7 +60,7 @@ const FloatingActionsButton = ({
// Container utama FAB
<div
className={cn(
`absolute ${positionStyles} inset-x-1/2 -translate-x-1/2 z-50`,
`fixed ${positionStyles} inset-x-1/2 -translate-x-1/2 z-50`,
'mx-auto w-full max-w-sm sm:mx-0 bg-base-300 p-4 rounded-xl shadow-md transition-all duration-300 transform',
'bg-slate-950 backdrop-blur-md'
)}
@@ -69,7 +76,18 @@ const FloatingActionsButton = ({
<div className='flex gap-4 items-center'>
{/* Render Aksi dari props.actions */}
{actions
.filter((action) => !action.hidden)
.filter((action) => {
if (action.hidden) return false;
if (action.permissions) {
if (typeof action.permissions === 'string') {
return permissionCheck(action.permissions);
}
return action.permissions.some((permission) =>
permissionCheck(permission)
);
}
return true;
})
.map((action, index) => {
return (
<Button
@@ -109,29 +127,41 @@ const FloatingActionsButton = ({
{/* === BARIS BAWAH: Approval Buttons (Approve/Reject) === */}
<div className={`grid grid-cols-${approvals.length} gap-3`}>
{approvals.map((approval, index) => (
<Button
key={index}
onClick={approval.onClick}
className={cn(
'btn btn-lg w-full',
'bg-white/20 border-white/30',
'text-white/50 font-semibold flex items-center gap-2 rounded-lg transition-all duration-200',
approval.disabled
? 'cursor-not-allowed'
: 'hover:text-white/100 hover:bg-white/40 hover:border-white/50'
)}
disabled={approval.disabled}
>
<Icon
icon={approval.icon}
width={20}
height={20}
className={`text-${getApprovalColor(approval.action)}`}
/>
{approval.label || approval.action}
</Button>
))}
{approvals
.filter((approval) => {
if (approval.permissions) {
if (typeof approval.permissions === 'string') {
return permissionCheck(approval.permissions);
}
return approval.permissions.some((permission) =>
permissionCheck(permission)
);
}
return true;
})
.map((approval, index) => (
<Button
key={index}
onClick={approval.onClick}
className={cn(
'btn btn-lg w-full',
'bg-white/20 border-white/30',
'text-white/50 font-semibold flex items-center gap-2 rounded-lg transition-all duration-200',
approval.disabled
? 'cursor-not-allowed'
: 'hover:text-white/100 hover:bg-white/40 hover:border-white/50'
)}
disabled={approval.disabled}
>
<Icon
icon={approval.icon}
width={20}
height={20}
className={`text-${getApprovalColor(approval.action)}`}
/>
{approval.label || approval.action}
</Button>
))}
</div>
</div>
</div>
+14
View File
@@ -9,10 +9,13 @@ import Drawer from '@/components/Drawer';
import Navbar from '@/components/Navbar';
import Button from '@/components/Button';
import SidebarMenu from '@/components/molecules/SidebarMenu';
import PermissionNotFound from '@/components/helper/PermissionNotFound';
import { useUiStore } from '@/stores/ui/ui.store';
import { MAIN_DRAWER_LINKS } from '@/config/constant';
import { isPathActive } from '@/lib/helper';
import { ROUTE_PERMISSIONS } from '@/config/route-permission';
import { useAuth } from '@/services/hooks/useAuth';
const MainDrawerContent = () => {
const pathname = usePathname();
@@ -62,6 +65,13 @@ const MainDrawer = ({
}>) => {
const { mainDrawerOpen, setMainDrawerOpen } = useUiStore();
const pathname = usePathname();
const { permissionCheck } = useAuth();
const formattedPathname = pathname.endsWith('/') ? pathname : `${pathname}/`;
const isPermitted = ROUTE_PERMISSIONS[formattedPathname]?.some((permission) =>
permissionCheck(permission)
);
const getPageTitle = useCallback(() => {
let title = '';
@@ -101,6 +111,10 @@ const MainDrawer = ({
setMainDrawerOpen(!mainDrawerOpen);
};
if (!isPermitted) {
return <PermissionNotFound />;
}
return (
<Drawer
open={mainDrawerOpen}
+1 -1
View File
@@ -7,7 +7,7 @@ import { Icon } from '@iconify/react';
import Menu from '@/components/menu/Menu';
import MenuItem from '@/components/menu/MenuItem';
import Button from '@/components/Button';
import Dropdown from '@/components/dropdown/Dropdown';
import Dropdown from '@/components/Dropdown';
import { useAuth } from '@/services/hooks/useAuth';
import { AuthApi } from '@/services/api/auth';
+35 -17
View File
@@ -60,6 +60,12 @@ export interface TableProps<TData extends object> {
renderFooter?: boolean;
withCheckbox?: boolean;
rowOptions?: number[];
/**
* Custom row renderer. Should return a complete <tr> element or null.
* This gives full control over the row structure including colspan.
* Return null to render the default row.
*/
renderCustomRow?: (row: Row<TData>) => ReactNode | null;
}
const DUMMY_SKELETON_DATA = [{}, {}, {}, {}, {}];
@@ -112,6 +118,7 @@ const Table = <TData extends object>({
renderFooter = false,
withCheckbox = false,
rowOptions = [10, 20, 50, 100],
renderCustomRow,
}: TableProps<TData>) => {
const isServerSideTable =
totalItems !== undefined &&
@@ -305,24 +312,35 @@ const Table = <TData extends object>({
</thead>
<tbody className={tableClassNames.tableBodyClassName}>
{table.getRowModel().rows.map((row) => (
<tr key={row.id} className={tableClassNames.bodyRowClassName}>
{row.getVisibleCells().map((cell) => (
<td
key={cell.id}
className={cn(
{ 'first:w-9 first:pr-0': withCheckbox },
tableClassNames.bodyColumnClassName
)}
>
{!isLoading &&
flexRender(cell.column.columnDef.cell, cell.getContext())}
{table.getRowModel().rows.map((row) => {
const customRowContent = renderCustomRow?.(row);
{isLoading && <div className='skeleton w-full h-4' />}
</td>
))}
</tr>
))}
if (customRowContent) {
return renderCustomRow?.(row);
}
return (
<tr key={row.id} className={tableClassNames.bodyRowClassName}>
{row.getVisibleCells().map((cell) => (
<td
key={cell.id}
className={cn(
{ 'first:w-9 first:pr-0': withCheckbox },
tableClassNames.bodyColumnClassName
)}
>
{!isLoading &&
flexRender(
cell.column.columnDef.cell,
cell.getContext()
)}
{isLoading && <div className='skeleton w-full h-4' />}
</td>
))}
</tr>
);
})}
</tbody>
<tfoot className={cn(tableClassNames.tableFooterClassName)}>
{renderFooter && (
@@ -0,0 +1,12 @@
const PermissionNotFound = () => {
return (
<div className='w-full h-screen flex flex-col justify-center items-center gap-4'>
<h2 className='text-2xl font-bold text-error'>Permission Not Found</h2>
<p className='text-gray-600 text-center'>
You do not have permission to access this page.
</p>
</div>
);
};
export default PermissionNotFound;
+24 -7
View File
@@ -5,6 +5,7 @@ import useSWR from 'swr';
import { useAuth } from '@/services/hooks/useAuth';
import { httpClientFetcher, SWRHttpKey } from '@/services/http/client';
import { AuthApi } from '@/services/api/auth';
import { isResponseError, isResponseSuccess } from '@/lib/api-helper';
import { BaseApiResponse, GetMeResponse } from '@/types/api/api-general';
import { AxiosError } from 'axios';
@@ -28,8 +29,8 @@ const RequireAuth = ({ children }: RequireAuthProps) => {
>('/sso/userinfo', httpClientFetcher, {
shouldRetryOnError: false,
// refresh every 13 minutes
refreshInterval: 13 * 60 * 1000,
// refresh every 12 minutes
refreshInterval: 12 * 60 * 1000,
});
useEffect(() => {
@@ -55,6 +56,25 @@ const RequireAuth = ({ children }: RequireAuthProps) => {
setIsLoadingUser(isLoadingUserResponse);
}, [isLoadingUserResponse]);
useEffect(() => {
const interval = setInterval(
async () => {
await AuthApi.refresh();
},
12 * 60 * 1000
);
return () => clearInterval(interval);
}, []);
useEffect(() => {
const refreshUserSession = async () => {
await AuthApi.refresh();
};
refreshUserSession();
}, []);
if (
(isLoadingUserResponse && !userResponse && !userErrorResponse) ||
(!userResponse && !userErrorResponse)
@@ -66,7 +86,7 @@ const RequireAuth = ({ children }: RequireAuthProps) => {
);
}
if (userErrorResponse) {
if (!isLoadingUserResponse && userErrorResponse) {
return (
<div className='w-full h-screen flex flex-col justify-center items-center gap-4'>
<h2 className='text-2xl font-bold text-error'>Authentication Failed</h2>
@@ -74,10 +94,7 @@ const RequireAuth = ({ children }: RequireAuthProps) => {
Please try refreshing the page or contact support if the problem
persists.
</p>
<button
className='btn btn-primary'
onClick={() => window.location.reload()}
>
<button className='btn btn-primary' onClick={() => redirectToSSO()}>
Retry
</button>
</div>
@@ -0,0 +1,28 @@
'use client';
import { useAuth } from '@/services/hooks/useAuth';
interface RequirePermissionProps {
children: React.ReactNode;
permissions: string | string[];
}
const RequirePermission = ({
children,
permissions,
}: RequirePermissionProps) => {
const { permissionCheck } = useAuth();
const isPermitted =
typeof permissions === 'string'
? permissionCheck(permissions)
: permissions.some((permission) => permissionCheck(permission));
if (!isPermitted) {
return null;
}
return <>{children}</>;
};
export default RequirePermission;
+49
View File
@@ -0,0 +1,49 @@
import Alert from '@/components/Alert';
import Button from '@/components/Button';
import { Icon } from '@iconify/react';
import { useState } from 'react';
/**
* Alert Unique Error List
* @param formErrorList - Array of error messages
* @param onClose - Function to close the alert
*/
const AlertErrorList = ({
formErrorList,
onClose,
}: {
formErrorList: string[];
onClose: () => void;
}) => {
if (formErrorList.length === 0) return null;
return (
<Alert color='error' className='w-full flex flex-col gap-2 px-4 m-4'>
<div className='flex justify-between items-center gap-2 w-full'>
<div className='flex items-center gap-2'>
<Icon icon='material-symbols:error-outline' width={24} height={24} />
<span className='font-semibold'>
Terdapat {formErrorList.length} error pada form:
</span>
</div>
<Button
onClick={onClose}
variant='link'
className='ml-auto p-0 w-fit text-white'
color='none'
>
<Icon icon='material-symbols:close' width={24} height={24} />
</Button>
</div>
<ul className='list-disc list-inside pl-8 space-y-1 w-full'>
{formErrorList.map((error, index) => (
<li key={index} className='text-sm'>
{error}
</li>
))}
</ul>
</Alert>
);
};
export default AlertErrorList;
@@ -24,6 +24,11 @@ const DebouncedTextInput = (props: DebouncedTextInputProps) => {
setInternalChangeEvent(e);
};
// Sync internal value with external value prop changes (e.g., from reset)
useEffect(() => {
setInternalValue(props.value);
}, [props.value]);
useEffect(() => {
if (debouncedChangeEvent) {
onChange?.(debouncedChangeEvent);
+8
View File
@@ -33,6 +33,7 @@ const FileInput = ({
isError,
errorMessage,
disabled = false,
required = false,
onChange,
onBlur,
readOnly = false,
@@ -56,6 +57,13 @@ const FileInput = ({
)}
>
{label}
{required && (
<>
<span className='tooltip tooltip-error' data-tip='required'>
<span className='text-error'> *</span>
</span>
</>
)}
</label>
)}
+106 -39
View File
@@ -8,10 +8,13 @@ import Button, { ButtonProps } from '@/components/Button';
import { cn } from '@/lib/helper';
export type IconPosition = 'left' | 'center' | 'right';
export interface ConfirmationModalProps {
ref: RefObject<HTMLDialogElement | null>;
type?: 'info' | 'success' | 'error';
text?: string;
subtitleText?: string;
closeOnBackdrop?: boolean;
primaryButton?: ButtonProps & {
text?: string;
@@ -24,17 +27,84 @@ export interface ConfirmationModalProps {
modalBox?: string;
};
children?: React.ReactNode;
iconSize?: number;
iconPosition?: IconPosition;
}
const iconConfig = {
info: {
icon: 'material-symbols:info-outline-rounded',
iconClassName: 'text-info-content',
bgClassName: 'bg-info',
outerRingClassName: 'bg-info/20',
borderClassName: 'border-info',
},
success: {
icon: 'heroicons:check',
iconClassName: 'text-white',
bgClassName: 'bg-[#00D390]',
outerRingClassName: 'bg-[#00D3901F]',
borderClassName: 'border-[#CCF7EB]',
},
error: {
icon: 'solar:danger-triangle-linear',
iconClassName: 'text-error-content',
bgClassName: 'bg-[#f03338]',
outerRingClassName: 'bg-[#f3cdcd]',
borderClassName: 'border-[#fff0ef]',
},
} as const;
const ConfirmationModalIcon = ({
type,
size = 24,
}: {
type: 'info' | 'success' | 'error';
size?: number;
}) => {
const config = iconConfig[type];
return (
<div className='flex items-center justify-center p-2'>
<div
className={cn(
'rounded-full border-4 p-1',
config.outerRingClassName,
config.borderClassName
)}
>
<div className={cn('rounded-full p-1', config.outerRingClassName)}>
<div
className={cn(
'rounded-full p-3 flex items-center justify-center',
config.bgClassName
)}
>
<Icon
icon={config.icon}
width={size}
height={size}
className={config.iconClassName}
/>
</div>
</div>
</div>
</div>
);
};
const ConfirmationModal = ({
ref,
type = 'info',
text,
subtitleText,
closeOnBackdrop,
primaryButton,
secondaryButton,
className,
children,
iconSize = 32,
iconPosition = 'center',
}: ConfirmationModalProps) => {
const [isPrimaryButtonLoading, setIsPrimaryButtonLoading] = useState(false);
@@ -55,47 +125,44 @@ const ConfirmationModal = ({
return (
<Modal ref={ref} closeOnBackdrop={closeOnBackdrop} className={className}>
<div className='w-full flex flex-col gap-4'>
<div
className={cn(
'w-fit p-4 mx-auto flex flex-row justify-center items-center rounded-full',
{
'bg-error': type === 'error',
'bg-info': type === 'info',
'bg-success': type === 'success',
}
)}
>
{type === 'info' && (
<Icon
icon='material-symbols:info-outline-rounded'
width={64}
height={64}
className='text-info-content'
/>
)}
{iconPosition === 'center' ? (
<>
<div className='w-fit mx-auto'>
<ConfirmationModalIcon type={type} size={iconSize} />
</div>
{type === 'success' && (
<Icon
icon='qlementine-icons:success-12'
width={64}
height={64}
className='text-success-content'
/>
)}
<p className='text-center font-medium'>
{text ?? 'Apakah anda yakin ingin melakukan hal ini?'}
</p>
{type === 'error' && (
<Icon
icon='solar:danger-triangle-linear'
width={64}
height={64}
className='text-error-content'
/>
)}
</div>
{subtitleText && (
<p className='text-center text-sm text-gray-400'>
{subtitleText}
</p>
)}
</>
) : (
<div
className={cn('flex flex-row items-center gap-4', {
'flex-row': iconPosition === 'left',
'flex-row-reverse': iconPosition === 'right',
})}
>
<div className='w-fit'>
<ConfirmationModalIcon type={type} size={iconSize} />
</div>
<p className='text-center font-medium'>
{text ?? 'Apakah anda yakin ingin melakukan hal ini?'}
</p>
<div className='flex flex-col gap-1'>
<p className='font-medium'>
{text ?? 'Apakah anda yakin ingin melakukan hal ini?'}
</p>
{subtitleText && (
<p className='text-sm text-gray-400'>{subtitleText}</p>
)}
</div>
</div>
)}
{children && <div className='w-full'>{children}</div>}
@@ -103,7 +170,7 @@ const ConfirmationModal = ({
{secondaryButton && secondaryButton.text && (
<Button
{...secondaryButton}
variant='ghost'
variant='outline'
color={secondaryButton?.color}
isLoading={secondaryButton?.isLoading}
disabled={
+20 -7
View File
@@ -2,6 +2,7 @@ import Link from 'next/link';
import Menu from '@/components/menu/Menu';
import { Icon } from '@iconify/react';
import { cn, isPathActive } from '@/lib/helper';
import { useAuth } from '@/services/hooks/useAuth';
export interface SidebarMenuItem {
type?: 'item' | 'title';
@@ -9,6 +10,7 @@ export interface SidebarMenuItem {
link: string;
icon?: string;
submenu?: SidebarMenuItem[];
permission?: string[];
}
interface SidebarMenuItemProps {
@@ -22,8 +24,17 @@ interface SidebarMenuProps {
}
const SidebarMenuItem = ({ item, activeLink }: SidebarMenuItemProps) => {
const { permissionCheck } = useAuth();
const isItemActive = isPathActive(activeLink, item.link);
const isUserPermitted = item.permission
? item.permission?.some((permissionName) => permissionCheck(permissionName))
: true;
if (!isUserPermitted) {
return null;
}
const menuItemWithoutSubmenu = (
<li>
<Link
@@ -78,13 +89,15 @@ const SidebarMenuItem = ({ item, activeLink }: SidebarMenuItemProps) => {
const SidebarMenu = ({ menu, activeLink }: SidebarMenuProps) => {
return (
<Menu>
{menu.map((menuItem, menuIdx) => (
<SidebarMenuItem
key={menuIdx}
item={menuItem}
activeLink={activeLink}
/>
))}
{menu.map((menuItem, menuIdx) => {
return (
<SidebarMenuItem
key={menuIdx}
item={menuItem}
activeLink={activeLink}
/>
);
})}
</Menu>
);
};
+1 -1
View File
@@ -309,7 +309,7 @@ const useApprovalSteps = ({
moduleId: string;
params?: {
page?: number;
limit: number;
limit: number | string;
search?: string;
group_step_number?: boolean;
};
+36 -7
View File
@@ -12,21 +12,32 @@ import ClosingProductionDataTabContent from '@/components/pages/closing/ClosingP
import {
ClosingGeneralInformation,
BaseClosingSales,
ClosingHppExpedition,
} from '@/types/api/closing';
import ClosingSapronakCalculationTabContent from '@/components/pages/closing/ClosingSapronakCalculationTabContent';
import ClosingOverheadTabContent from '@/components/pages/closing/ClosingOverheadTabContent';
import SalesReportTable from './sale/SalesReportTable';
import ClosingFinanceTabContent from '@/components/pages/closing/ClosingFinanceTabContent';
import SalesReportTable from '@/components/pages/closing/sale/SalesReportTable';
import HppExpeditionReportTable from './hpp-ekspedisi/HppExpeditionReportTable';
import ClosingKandangList from '@/components/pages/closing/ClosingKandangList';
import { ProjectFlock } from '@/types/api/production/project-flock';
import { ProjectFlockKandang } from '@/types/api/production/project-flock-kandang';
interface ClosingDetailProps {
id: number;
initialValue?: ClosingGeneralInformation;
salesData?: BaseClosingSales;
hppExpeditionData?: ClosingHppExpedition;
projectData?: ProjectFlock;
kandangData?: ProjectFlockKandang;
}
const ClosingDetail: React.FC<ClosingDetailProps> = ({
id,
initialValue,
salesData,
hppExpeditionData,
projectData,
kandangData,
}) => {
const [activeTab, setActiveTab] = useState<string>('sapronak');
@@ -40,7 +51,12 @@ const ClosingDetail: React.FC<ClosingDetailProps> = ({
{
id: 'perhitunganSapronak',
label: 'Perhitungan Sapronak',
content: <ClosingSapronakCalculationTabContent projectFlockId={id} />,
content: (
<ClosingSapronakCalculationTabContent
closingGeneralInformation={initialValue}
projectFlockId={id}
/>
),
},
{
id: 'penjualan',
@@ -55,7 +71,7 @@ const ClosingDetail: React.FC<ClosingDetailProps> = ({
{
id: 'hppEkspedisi',
label: 'HPP Ekspedisi',
content: 'HPP Ekspedisi',
content: <HppExpeditionReportTable initialValues={hppExpeditionData} />,
},
{
id: 'dataProduksi',
@@ -65,7 +81,7 @@ const ClosingDetail: React.FC<ClosingDetailProps> = ({
{
id: 'keuangan',
label: 'Keuangan',
content: 'Keuangan',
content: <ClosingFinanceTabContent projectFlockId={id} />,
},
];
@@ -77,7 +93,9 @@ const ClosingDetail: React.FC<ClosingDetailProps> = ({
<section className='w-full max-w-7xl pb-16'>
<header className='flex flex-col gap-4'>
<Button
href='/closing'
href={
!kandangData ? '/closing' : `/closing/detail/?closingId=${id}`
}
variant='link'
className='w-fit p-0 text-primary'
>
@@ -88,7 +106,18 @@ const ClosingDetail: React.FC<ClosingDetailProps> = ({
<h1 className='text-2xl font-bold text-center'>Detail Closing</h1>
</header>
<ClosingGeneralInformationTable initialValue={initialValue} />
<ClosingGeneralInformationTable
initialValue={initialValue}
projectData={projectData}
kandangData={kandangData}
/>
{!kandangData && (
<ClosingKandangList
initialValue={initialValue}
projectData={projectData}
/>
)}
<Tabs
activeTabId={activeTab}
@@ -0,0 +1,17 @@
import ClosingFinanceTable from '@/components/pages/closing/ClosingFinanceTable';
const ClosingFinanceTabContent = ({
projectFlockId,
}: {
projectFlockId: number;
}) => {
return (
<div className='flex flex-col gap-4'>
{projectFlockId && (
<ClosingFinanceTable projectFlockId={projectFlockId} />
)}
</div>
);
};
export default ClosingFinanceTabContent;
@@ -0,0 +1,595 @@
import Card from '@/components/Card';
import Table, { TABLE_DEFAULT_STYLING } from '@/components/Table';
import { isResponseSuccess } from '@/lib/api-helper';
import { formatCurrency, formatTitleCase } from '@/lib/helper';
import { ClosingApi } from '@/services/api/closing';
import {
DataSummarySubTotal,
HppPurchaseData,
ProfitLossDataAmount,
} from '@/types/api/closing';
import useSWR from 'swr';
type HppTableRow =
| (HppPurchaseData & {
group_name: string;
group_index: number;
isGroupHeader?: boolean;
})
| {
group_name: string;
group_index: number;
isGroupHeader: true;
type?: never;
budgeting?: never;
realization?: never;
}
| {
type: string;
group_name: string;
group_index: number;
isGroupHeader: false;
budgeting?: { rp_per_bird: number; rp_per_kg: number; amount: number };
realization?: { rp_per_bird: number; rp_per_kg: number; amount: number };
};
type ProfitLossTableRow =
| (DataSummarySubTotal & {
type: string;
group_name: string;
group_index: number;
isGroupHeader?: boolean;
})
| {
group_name: string;
group_index: number;
isGroupHeader: true;
type?: never;
rp_per_bird?: never;
rp_per_kg?: never;
amount?: never;
};
const ClosingFinanceTable = ({
projectFlockId,
}: {
projectFlockId: number;
}) => {
const { data: finance, isLoading } = useSWR(
`/closing/finance/${projectFlockId}`,
() => ClosingApi.getFinance(projectFlockId)
);
const staticHppRows: Array<{
group_name: string;
type: string;
group_index: number;
}> = [
{
group_name: 'HPP dan Pengeluaran',
type: 'Pembelian PAKAN',
group_index: 0,
},
{
group_name: 'HPP dan Pengeluaran',
type: 'Pembelian STARTER',
group_index: 0,
},
{
group_name: 'HPP dan Pengeluaran',
type: 'Pembelian DOC',
group_index: 0,
},
{
group_name: 'HPP dan Pengeluaran',
type: 'Pembelian PULLET',
group_index: 0,
},
{
group_name: 'HPP dan Pengeluaran',
type: 'Pembelian LAYER',
group_index: 0,
},
{
group_name: 'HPP dan Bahan Baku',
type: 'Pengeluaran Overhead',
group_index: 1,
},
{
group_name: 'HPP dan Bahan Baku',
type: 'Beban Ekspedisi',
group_index: 1,
},
];
const hppTableData: HppTableRow[] = [
{
group_name: 'HPP dan Pengeluaran',
group_index: 0,
isGroupHeader: true as const,
},
...staticHppRows
.filter((row) => row.group_index === 0)
.map((staticRow) => {
const apiData = isResponseSuccess(finance)
? finance.data.hpp_purchases.hpp
.find((g) => g.group_name === staticRow.group_name)
?.data.find((d) => d.type === staticRow.type)
: null;
return {
group_name: staticRow.group_name,
group_index: staticRow.group_index,
type: staticRow.type,
budgeting: apiData?.budgeting || {
rp_per_bird: 0,
rp_per_kg: 0,
amount: 0,
},
realization: apiData?.realization || {
rp_per_bird: 0,
rp_per_kg: 0,
amount: 0,
},
isGroupHeader: false as const,
};
}),
{
group_name: 'HPP dan Bahan Baku',
group_index: 1,
isGroupHeader: true as const,
},
...staticHppRows
.filter((row) => row.group_index === 1)
.map((staticRow) => {
const apiData = isResponseSuccess(finance)
? finance.data.hpp_purchases.hpp
.find((g) => g.group_name === staticRow.group_name)
?.data.find((d) => d.type === staticRow.type)
: null;
return {
group_name: staticRow.group_name,
group_index: staticRow.group_index,
type: staticRow.type,
budgeting: apiData?.budgeting || {
rp_per_bird: 0,
rp_per_kg: 0,
amount: 0,
},
realization: apiData?.realization || {
rp_per_bird: 0,
rp_per_kg: 0,
amount: 0,
},
isGroupHeader: false as const,
};
}),
{
group_name: 'HPP',
group_index: 2,
isGroupHeader: true as const,
},
];
const profitLossTableData: ProfitLossTableRow[] = isResponseSuccess(finance)
? [
// Pembelian group
...finance.data.profit_loss.data.pembelian.map((item) => ({
label: 'Pembelian',
group_name: 'Pembelian',
group_index: 1,
type: item.type,
rp_per_bird: item.rp_per_bird,
rp_per_kg: item.rp_per_kg,
amount: item.amount,
isGroupHeader: false as const,
})),
{
label: finance.data.profit_loss.data.summary.gross_profit.label,
group_name: 'Penjualan',
group_index: 0,
isGroupHeader: true as const,
type: finance.data.profit_loss.data.summary.gross_profit.label,
rp_per_bird:
finance.data.profit_loss.data.summary.gross_profit.rp_per_bird,
rp_per_kg:
finance.data.profit_loss.data.summary.gross_profit.rp_per_kg,
amount: finance.data.profit_loss.data.summary.gross_profit.amount,
},
// Penjualan group
...finance.data.profit_loss.data.penjualan.map((item) => ({
label: 'Penjualan',
group_name: 'Penjualan',
group_index: 0,
type: item.type,
rp_per_bird: item.rp_per_bird,
rp_per_kg: item.rp_per_kg,
amount: item.amount,
isGroupHeader: false as const,
})),
{
label: finance.data.profit_loss.data.summary.sub_total.label,
group_name: 'Pembelian',
group_index: 1,
isGroupHeader: true as const,
type: finance.data.profit_loss.data.summary.sub_total.label,
rp_per_bird:
finance.data.profit_loss.data.summary.sub_total.rp_per_bird,
rp_per_kg: finance.data.profit_loss.data.summary.sub_total.rp_per_kg,
amount: finance.data.profit_loss.data.summary.sub_total.amount,
},
]
: [];
return (
<div className='flex flex-col gap-4'>
<>
<Card
variant='bordered'
className={{
wrapper: 'w-full',
}}
>
<div className='grid grid-cols-2 gap-6'>
<div className='flex flex-col gap-1'>
<div>
{isResponseSuccess(finance)
? formatTitleCase(
finance.data.profit_loss.data.summary.gross_profit
.label || '-'
)
: 'Laba Rugi Brutto'}
</div>
<div className='text-lg font-bold'>
{isResponseSuccess(finance)
? formatCurrency(
finance.data.profit_loss.data.summary.gross_profit.amount
)
: '-'}
</div>
</div>
<div className='flex flex-col gap-1'>
<div>
{isResponseSuccess(finance)
? formatTitleCase(
finance.data.profit_loss.data.summary.net_profit.label ||
'-'
)
: 'Laba Rugi Netto'}
</div>
<div className='text-lg font-bold'>
{isResponseSuccess(finance)
? formatCurrency(
finance.data.profit_loss.data.summary.net_profit.amount
)
: '-'}
</div>
</div>
</div>
</Card>
<Card
title={
isResponseSuccess(finance)
? finance.data.hpp_purchases.title
: 'HPP Purchases'
}
variant='bordered'
collapsible
className={{
wrapper: 'w-full',
}}
>
<div className='mt-6 p-0 mb-0'>
<Table<HppTableRow>
data={hppTableData}
columns={[
{
header: 'No.',
enableSorting: false,
accessorFn: (item, index) => {
if (item.isGroupHeader) return '-';
const dataRowsBefore = hppTableData
.slice(0, index)
.filter((row) => !row.isGroupHeader).length;
return dataRowsBefore + 1;
},
footer: (props) => {
return 'HPP';
},
},
{
header: 'Type',
enableSorting: false,
accessorFn: (item) => formatTitleCase(item.type || '-'),
},
{
header: 'Budgeting',
enableSorting: false,
columns: [
{
header: 'Rp/Ekor',
id: 'budgeting_rp_per_bird',
enableSorting: false,
accessorFn: (item) =>
formatCurrency(item.budgeting?.rp_per_bird || 0),
footer: (props) => {
return props.column.id === 'budgeting_rp_per_bird' &&
isResponseSuccess(finance)
? formatCurrency(
finance.data.hpp_purchases.summary_hpp?.budgeting
?.rp_per_bird || 0
)
: '-';
},
},
{
header: 'Rp/Kg',
id: 'budgeting_rp_per_kg',
enableSorting: false,
accessorFn: (item) =>
formatCurrency(item.budgeting?.rp_per_kg || 0),
footer: (props) => {
return props.column.id === 'budgeting_rp_per_kg' &&
isResponseSuccess(finance)
? formatCurrency(
finance.data.hpp_purchases.summary_hpp?.budgeting
?.rp_per_kg || 0
)
: '-';
},
},
{
header: 'Jumlah (Rp)',
id: 'budgeting_amount',
enableSorting: false,
accessorFn: (item) =>
formatCurrency(item.budgeting?.amount || 0),
footer: (props) => {
return props.column.id === 'budgeting_amount' &&
isResponseSuccess(finance)
? formatCurrency(
finance.data.hpp_purchases.summary_hpp?.budgeting
?.amount || 0
)
: '-';
},
},
],
},
{
header: 'Realization',
enableSorting: false,
columns: [
{
header: 'Rp/Ekor',
id: 'realization_rp_per_bird',
enableSorting: false,
accessorFn: (item) =>
formatCurrency(item.realization?.rp_per_bird || 0),
footer: (props) => {
return props.column.id === 'realization_rp_per_bird' &&
isResponseSuccess(finance)
? formatCurrency(
finance.data.hpp_purchases.summary_hpp
?.realization?.rp_per_bird || 0
)
: '-';
},
},
{
header: 'Rp/Kg',
id: 'realization_rp_per_kg',
enableSorting: false,
accessorFn: (item) =>
formatCurrency(item.realization?.rp_per_kg || 0),
footer: (props) => {
return props.column.id === 'realization_rp_per_kg' &&
isResponseSuccess(finance)
? formatCurrency(
finance.data.hpp_purchases.summary_hpp
?.realization?.rp_per_kg || 0
)
: '-';
},
},
{
header: 'Jumlah (Rp)',
id: 'realization_amount',
enableSorting: false,
accessorFn: (item) =>
formatCurrency(item.realization?.amount || 0),
footer: (props) => {
return props.column.id === 'realization_amount' &&
isResponseSuccess(finance)
? formatCurrency(
finance.data.hpp_purchases.summary_hpp
?.realization?.amount || 0
)
: '-';
},
},
],
},
]}
renderCustomRow={(row) => {
const rowData = row.original;
if (rowData.isGroupHeader) {
return (
<tr
key={row.id}
className={TABLE_DEFAULT_STYLING.bodyRowClassName}
>
<td
className={TABLE_DEFAULT_STYLING.bodyColumnClassName}
></td>
<td
colSpan={7}
className={TABLE_DEFAULT_STYLING.bodyColumnClassName}
>
<div className='font-bold'>
{formatTitleCase(rowData.group_name ?? '-')}
</div>
</td>
</tr>
);
}
return null;
}}
renderFooter={isResponseSuccess(finance)}
/>
</div>
</Card>
<Card
title={
isResponseSuccess(finance)
? finance.data.profit_loss.title
: 'Profit/Loss'
}
variant='bordered'
collapsible
className={{
wrapper: 'w-full',
}}
>
<div className='mt-6 p-0 mb-0'>
<Table<ProfitLossTableRow>
data={profitLossTableData}
columns={[
{
header: 'Jenis',
enableSorting: false,
accessorFn: (item) => item.type,
cell: (item) => (
<div className=''>
{formatTitleCase(item.row.original.type || '-')}
</div>
),
footer: (item) => (
<div className='font-bold uppercase'>
{isResponseSuccess(finance)
? formatTitleCase(
finance.data.profit_loss.data.summary.net_profit
.label || '-'
)
: '-'}
</div>
),
},
{
header: 'Rp/Ekor',
enableSorting: false,
accessorFn: (item) => formatCurrency(item.rp_per_bird || 0),
footer: (item) => (
<div className='font-bold'>
{isResponseSuccess(finance)
? formatCurrency(
finance.data.profit_loss.data.summary.net_profit
.rp_per_bird || 0
)
: formatCurrency(0)}
</div>
),
},
{
header: 'Rp/Kg',
enableSorting: false,
accessorFn: (item) => formatCurrency(item.rp_per_kg || 0),
footer: (item) => (
<div className='font-bold'>
{isResponseSuccess(finance)
? formatCurrency(
finance.data.profit_loss.data.summary.net_profit
.rp_per_kg || 0
)
: formatCurrency(0)}
</div>
),
},
{
header: 'Jumlah (Rp)',
enableSorting: false,
accessorFn: (item) => formatCurrency(item.amount || 0),
footer: (item) => (
<div className='font-bold'>
{isResponseSuccess(finance)
? formatCurrency(
finance.data.profit_loss.data.summary.net_profit
.amount || 0
)
: formatCurrency(0)}
</div>
),
},
]}
renderCustomRow={(row) => {
const rowData = row.original;
if (rowData.isGroupHeader) {
if (rowData.amount) {
return (
<tr
key={row.id}
className={TABLE_DEFAULT_STYLING.footerRowClassName}
>
<td
className={TABLE_DEFAULT_STYLING.bodyColumnClassName}
>
<div className='font-bold ps-6 uppercase'>
{formatTitleCase(rowData.label ?? '-')}
</div>
</td>
<td
className={TABLE_DEFAULT_STYLING.bodyColumnClassName}
>
<div className='font-bold'>
{formatCurrency(rowData.rp_per_bird ?? 0)}
</div>
</td>
<td
className={TABLE_DEFAULT_STYLING.bodyColumnClassName}
>
<div className='font-bold'>
{formatCurrency(rowData.rp_per_kg ?? 0)}
</div>
</td>
<td
className={TABLE_DEFAULT_STYLING.bodyColumnClassName}
>
<div className='font-bold'>
{formatCurrency(rowData.amount ?? 0)}
</div>
</td>
</tr>
);
}
return (
<tr
key={row.id}
className={TABLE_DEFAULT_STYLING.bodyRowClassName}
>
<td
colSpan={4}
className={TABLE_DEFAULT_STYLING.bodyColumnClassName}
>
<div className='font-bold'>
{formatTitleCase(rowData.group_name ?? '-')}
</div>
</td>
</tr>
);
}
return null;
}}
className={{
paginationClassName: 'hidden',
}}
renderFooter={isResponseSuccess(finance)}
/>
</div>
</Card>
</>
</div>
);
};
export default ClosingFinanceTable;
@@ -1,12 +1,29 @@
import { ClosingGeneralInformation } from '@/types/api/closing';
import { ProjectFlock } from '@/types/api/production/project-flock';
import { ProjectFlockKandang } from '@/types/api/production/project-flock-kandang';
import { useMemo } from 'react';
interface ClosingGeneralInformationProps {
initialValue?: ClosingGeneralInformation;
projectData?: ProjectFlock;
kandangData?: ProjectFlockKandang;
}
const ClosingGeneralInformationTable = ({
initialValue,
projectData,
kandangData,
}: ClosingGeneralInformationProps) => {
const chickinPopulation = useMemo(() => {
if (kandangData) {
return kandangData?.chickins?.reduce(
(acc, chickin) => acc + chickin.usage_qty,
0
);
}
return 0;
}, [kandangData]);
return (
<div className='w-full my-4 @container'>
<div className='flex flex-col @sm:flex-row gap-4'>
@@ -17,7 +34,9 @@ const ClosingGeneralInformationTable = ({
<tr>
<td>Lokasi</td>
<td>:</td>
<td>{initialValue?.location_name}</td>
<td>
{initialValue?.location_name ?? projectData?.location?.name}
</td>
</tr>
<tr>
<td>Periode</td>
@@ -25,14 +44,22 @@ const ClosingGeneralInformationTable = ({
<td>{initialValue?.period}</td>
</tr>
<tr>
<td>Kategori</td>
<td>Project Flock</td>
<td>:</td>
<td>{initialValue?.project_category}</td>
<td>
{initialValue?.project_flock?.name ??
projectData?.flock_name}
</td>
</tr>
<tr>
<td>Populasi</td>
<td>:</td>
<td>{initialValue?.population} Ekor</td>
<td>
{!kandangData
? (initialValue?.population ?? 0)
: (chickinPopulation ?? 0)}{' '}
Ekor
</td>
</tr>
<tr>
<td>Jenis Project</td>
@@ -40,9 +67,13 @@ const ClosingGeneralInformationTable = ({
<td>{initialValue?.project_type}</td>
</tr>
<tr className='table-row @sm:hidden'>
<td>Kandang Aktif</td>
<td>Kandang {!kandangData && 'Aktif'}</td>
<td>:</td>
<td>{initialValue?.active_house_count} Kandang</td>
<td>
{!kandangData
? `${initialValue?.active_house_count} Kandang`
: kandangData?.kandang?.name}
</td>
</tr>
<tr className='table-row @sm:hidden'>
<td>Status Pembayaran Penjualan</td>
@@ -69,9 +100,13 @@ const ClosingGeneralInformationTable = ({
<table className='table table-zebra table-sm'>
<tbody>
<tr>
<td>Kandang Aktif</td>
<td>Kandang {!kandangData && 'Aktif'}</td>
<td>:</td>
<td>{initialValue?.active_house_count} Kandang</td>
<td>
{!kandangData
? `${initialValue?.active_house_count} Kandang`
: kandangData?.kandang?.name}
</td>
</tr>
<tr>
<td>Status Pembayaran Penjualan</td>
@@ -0,0 +1,37 @@
import Button from '@/components/Button';
import { ClosingGeneralInformation } from '@/types/api/closing';
import { ProjectFlock } from '@/types/api/production/project-flock';
const ClosingKandangList = ({
initialValue,
projectData,
}: {
initialValue?: ClosingGeneralInformation;
projectData?: ProjectFlock;
}) => {
return (
<div className='w-full my-4 @container'>
<div className='flex flex-col @sm:flex-row gap-4'>
<div className='w-full'>
<div className='overflow-x-auto'>
<h1 className='font-bold my-4'>Kandang</h1>
<div className='flex flex-wrap gap-2 mb-4'>
{projectData?.kandangs?.map((kandang) => (
<Button
key={kandang.id}
variant='outline'
href={`/closing/detail/?closingId=${initialValue?.flock_id}&kandangId=${kandang.project_flock_kandang_id}`}
className='min-w-32'
>
{kandang.name}
</Button>
))}
</div>
</div>
</div>
</div>
</div>
);
};
export default ClosingKandangList;
@@ -33,7 +33,7 @@ const ClosingProductionDataTabContent = ({
);
}
const { purchase, sales, performance, variance } = productionData.data;
const { purchase, sales, performance } = productionData.data;
// Helper for consistent row styling
const DataRow = ({
@@ -58,39 +58,6 @@ const ClosingProductionDataTabContent = ({
</div>
);
// Helper for rows with two values (e.g., Deplesi: Ekor & %)
const DoubleDataRow = ({
label,
value1,
unit1,
value2,
unit2,
value1ClassName = 'font-bold text-gray-800',
value2ClassName = 'font-bold text-blue-500',
}: {
label: string;
value1: string | number;
unit1: string;
value2: string | number;
unit2: string;
value1ClassName?: string;
value2ClassName?: string;
}) => (
<div className='flex justify-between items-center py-1'>
<span className='text-gray-500 text-sm font-medium w-1/2'>{label}</span>
<div className='flex gap-2 w-1/2 justify-end items-center'>
<div className='flex gap-2 items-center min-w-[5rem] justify-end'>
<span className={value1ClassName}>{value1}</span>
<span className='text-gray-500 w-8 text-right'>{unit1}</span>
</div>
<div className='flex gap-2 items-center min-w-[4rem] justify-end ml-2'>
<span className={value2ClassName}>{value2}</span>
<span className='text-gray-500 w-4 text-right'>{unit2}</span>
</div>
</div>
</div>
);
return (
<div className='w-full rounded-xl p-8 shadow-sm'>
<h2 className='text-lg font-bold mb-8 text-gray-800'>Data Produksi</h2>
@@ -121,17 +88,12 @@ const ClosingProductionDataTabContent = ({
/>
<DataRow
label='Pakan Masuk'
value={formatNumber(purchase.feed_in_kg)}
value={formatNumber(purchase.feed_in)}
unit='Kg'
/>
<DataRow
label='Pakan Terpakai'
value={formatNumber(purchase.feed_used_kg)}
unit='Kg'
/>
<DataRow
label='Pakan Terpakai per Ekor'
value={formatNumber(purchase.feed_used_per_head_kg)}
value={formatNumber(purchase.feed_used)}
unit='Kg'
/>
</div>
@@ -142,27 +104,59 @@ const ClosingProductionDataTabContent = ({
<h3 className='font-bold text-gray-700 mb-4 text-base'>
Penjualan
</h3>
<div className='space-y-1'>
<DataRow
label='Penjualan (Kg)'
value={formatNumber(sales.sales_kg)}
unit='Kg'
/>
<DataRow
label='Penjualan (Ekor)'
value={formatNumber(sales.sales_head)}
unit='Ekor'
/>
<DataRow
label='Bobot Rata-Rata'
value={formatNumber(sales.average_weight_kg)}
unit='Kg/Ekor'
/>
<DataRow
label='Harga Jual Rata-Rata'
value={formatNumber(sales.average_price_per_kg)}
unit='Rupiah'
/>
<div className='space-y-4'>
{/* Chicken Sales */}
<div className='space-y-1'>
<DataRow
label='Penjualan (Ekor)'
value={formatNumber(sales.chicken.sales_population)}
unit='Ekor'
/>
<DataRow
label='Penjualan (Kg)'
value={formatNumber(sales.chicken.sales_weight)}
unit='Kg'
/>
<DataRow
label='Bobot Rata-Rata'
value={formatNumber(sales.chicken.avg_weight)}
unit='Kg/Ekor'
/>
<DataRow
label='Harga Jual Rata-Rata'
value={formatNumber(sales.chicken.avg_selling_price)}
unit='Rupiah'
/>
</div>
{/* Egg Sales (if available) */}
{sales.egg && (
<>
<div className='h-px bg-gray-100 my-2' />
<div className='space-y-1'>
<DataRow
label='Telur (Butir)'
value={formatNumber(sales.egg.egg_pieces)}
unit='Butir'
/>
<DataRow
label='Telur (Kg)'
value={formatNumber(sales.egg.egg_mass)}
unit='Kg'
/>
<DataRow
label='Berat Telur Rata-Rata'
value={formatNumber(sales.egg.avg_egg_weight)}
unit='Kg'
/>
<DataRow
label='Harga Jual Telur Rata-Rata'
value={formatNumber(sales.egg.avg_selling_price)}
unit='Rupiah'
/>
</div>
</>
)}
</div>
</section>
</div>
@@ -178,33 +172,49 @@ const ClosingProductionDataTabContent = ({
Performance
</h3>
<div className='space-y-1'>
<DoubleDataRow
<DataRow
label='Deplesi'
value1={formatNumber(performance.depletion_head)}
unit1='Ekor'
value2={formatNumber(performance.depletion_percentage)}
unit2='%'
value={formatNumber(performance.depletion)}
unit='Ekor'
/>
<DataRow
label='Umur'
value={formatNumber(performance.age_days)}
value={formatNumber(performance.age_day)}
unit='Hari'
// Aligning 'Hari' with the first unit column of double row
unitClassName='text-gray-500 w-8 text-right mr-[4.5rem]'
/>
<DataRow
label='Mortalitas Std'
value={formatNumber(performance.mortality_std)}
unitClassName='hidden' // No unit shown in screenshot
value={formatNumber(performance.mor_std)}
unitClassName='hidden'
/>
<DataRow
label='Mortalitas Act'
value={formatNumber(performance.mortality_act)}
value={formatNumber(performance.mor_act)}
unitClassName='hidden'
/>
<DataRow
label='DEFF Mortalitas'
value={formatNumber(performance.deff_mortality)}
value={formatNumber(performance.mor_diff)}
unitClassName='hidden'
/>
<DataRow
label='AWG Std'
value={formatNumber(performance.awg_std)}
unit='Gr/Hari'
/>
<DataRow
label='AWG Act'
value={formatNumber(performance.awg_act)}
unit='Gr/Hari'
/>
<DataRow
label='Feed Intake Std'
value={formatNumber(performance.feed_intake_std)}
unitClassName='hidden'
/>
<DataRow
label='Feed Intake Act'
value={formatNumber(performance.feed_intake)}
unitClassName='hidden'
/>
<DataRow
@@ -219,44 +229,70 @@ const ClosingProductionDataTabContent = ({
/>
<DataRow
label='DEFF FCR'
value={formatNumber(performance.deff_fcr)}
value={formatNumber(performance.fcr_diff)}
unitClassName='hidden'
/>
<DataRow
label='ADG'
value={formatNumber(performance.adg)}
unit='Gr/Hari'
/>
<DataRow
label='IP'
value={formatNumber(performance.ip)}
unitClassName='hidden'
/>
</div>
</section>
{/* Variance Section (Pushed to bottom) */}
<section className='mt-auto pt-4'>
<h3 className='font-bold text-gray-700 mb-4 text-base'>Selisih</h3>
<div className='space-y-1'>
<DataRow
label='Selisih Ayam'
value={formatNumber(variance.variance_head)}
unit='Ekor'
valueClassName='font-bold text-red-500'
/>
<DataRow
label='% Selisih Ayam'
value={formatNumber(variance.variance_head_percentage)}
unit='%'
valueClassName='font-bold text-red-500'
/>
<DataRow
label='Selisih Pakan'
value={formatNumber(variance.variance_feed_kg)}
unit='Kg'
valueClassName='font-bold text-red-500'
/>
{/* Laying Specific Fields */}
{performance.hen_day_act !== undefined && (
<>
<DataRow
label='Hen Day Std'
value={formatNumber(performance.hen_day_std!)}
unit='%'
/>
<DataRow
label='Hen Day Act'
value={formatNumber(performance.hen_day_act)}
unit='%'
/>
</>
)}
{performance.egg_mass !== undefined && (
<>
<DataRow
label='Egg Mass Std'
value={formatNumber(performance.egg_mass_std!)}
unit='Kg'
/>
<DataRow
label='Egg Mass Act'
value={formatNumber(performance.egg_mass)}
unit='Kg'
/>
</>
)}
{performance.egg_weight !== undefined && (
<>
<DataRow
label='Egg Weight Std'
value={formatNumber(performance.egg_weight_std!)}
unit='Gr'
/>
<DataRow
label='Egg Weight Act'
value={formatNumber(performance.egg_weight)}
unit='Gr'
/>
</>
)}
{performance.hen_housed_act !== undefined && (
<>
<DataRow
label='Hen Housed Std'
value={formatNumber(performance.hen_housed_std!)}
unit='%'
/>
<DataRow
label='Hen Housed Act'
value={formatNumber(performance.hen_housed_act)}
unit='%'
/>
</>
)}
</div>
</section>
</div>
@@ -1,21 +1,25 @@
'use client';
import ClosingIncomingSapronaksTable from '@/components/pages/closing/ClosingIncomingSapronaksTable';
import ClosingOutgoingSapronaksTable from '@/components/pages/closing/ClosingOutgoingSapronaksTable';
import ClosingSapronakCalculationTable from '@/components/pages/closing/ClosingSapronakCalculationTable';
import { ClosingGeneralInformation } from '@/types/api/closing';
interface ClosingSapronakCalculationTabContentProps {
projectFlockId?: number;
closingGeneralInformation?: ClosingGeneralInformation;
}
const ClosingSapronakCalculationTabContent = ({
projectFlockId,
closingGeneralInformation,
}: ClosingSapronakCalculationTabContentProps) => {
return (
<div className='flex flex-col gap-4'>
{projectFlockId && (
<>
<ClosingSapronakCalculationTable projectFlockId={projectFlockId} />
<ClosingSapronakCalculationTable
closingGeneralInformation={closingGeneralInformation}
projectFlockId={projectFlockId}
/>
</>
)}
</div>
@@ -3,7 +3,7 @@
import Card from '@/components/Card';
import Table from '@/components/Table';
import { cn, formatCurrency, formatNumber } from '@/lib/helper';
import { formatCurrency, formatDate, formatNumber } from '@/lib/helper';
import {
RowSapronakCalculation,
TotalSapronakCalculation,
@@ -13,19 +13,24 @@ import { useMemo } from 'react';
import useSWR from 'swr';
import { ClosingApi } from '@/services/api/closing';
import { isResponseSuccess } from '@/lib/api-helper';
import { ClosingGeneralInformation } from '@/types/api/closing';
import { useSearchParams } from 'next/navigation';
interface ClosingSapronakCalculationTableProps {
type?: 'detail';
projectFlockId: number;
closingGeneralInformation?: ClosingGeneralInformation;
}
const ClosingSapronakCalculationTable = ({
type,
projectFlockId,
closingGeneralInformation,
}: ClosingSapronakCalculationTableProps) => {
const searchParams = useSearchParams();
const kandangId = searchParams.get('kandangId');
const { data: sapronakCalculation, isLoading } = useSWR(
`/closing/sapronak-calculation/${projectFlockId}`,
() => ClosingApi.getPerhitunganSapronak(projectFlockId),
`/closing/sapronak-calculation/${projectFlockId}${kandangId ? `/${kandangId}` : ''}`,
() => ClosingApi.getPerhitunganSapronak(projectFlockId, Number(kandangId)),
{
keepPreviousData: true,
}
@@ -37,101 +42,121 @@ const ClosingSapronakCalculationTable = ({
): ColumnDef<RowSapronakCalculation>[] => [
{
header: 'Tanggal',
accessorKey: 'tanggal',
cell: (props) => (props.getValue() as string) || '-',
accessorKey: 'date',
cell: (props) =>
props.row.original.date
? formatDate(props.row.original.date, 'DD MMM YYYY')
: '-',
footer: 'Total',
},
{
header: 'No. Referensi',
accessorKey: 'no_referensi',
cell: (props) => (props.getValue() as string) || '-',
accessorKey: 'reference_number',
cell: (props) => (props.row.original.reference_number as string) || '-',
footer: '',
},
{
header: 'QTY Masuk',
accessorKey: 'qty_masuk',
cell: (props) => formatNumber(props.getValue() as number),
accessorKey: 'qty_in',
cell: (props) =>
props.row.original.qty_in
? formatNumber(props.row.original.qty_in as number)
: '0',
footer: total
? () => (
<div className='font-semibold text-gray-900'>
{formatNumber(total.qty_masuk)}
{total?.qty_in ? formatNumber(total?.qty_in) : '0'}
</div>
)
: '',
},
{
header: 'QTY Keluar',
accessorKey: 'qty_keluar',
cell: (props) => formatNumber(props.getValue() as number),
accessorKey: 'qty_out',
cell: (props) =>
props.row.original.qty_out
? formatNumber(props.row.original.qty_out as number)
: '0',
footer: total
? () => (
<div className='font-semibold text-gray-900'>
{formatNumber(total.qty_keluar)}
{total?.qty_out ? formatNumber(total?.qty_out) : '0'}
</div>
)
: '',
},
{
header: 'QTY Pakai',
accessorKey: 'qty_pakai',
cell: (props) => formatNumber(props.getValue() as number),
accessorKey: 'qty_used',
cell: (props) =>
props.row.original.qty_used
? formatNumber(props.row.original.qty_used as number)
: '0',
footer: total
? () => (
<div className='font-semibold text-gray-900'>
{formatNumber(total.qty_pakai)}
{total?.qty_used ? formatNumber(total?.qty_used) : '0'}
</div>
)
: '',
},
{
header: 'Uraian',
accessorKey: 'uraian',
cell: (props) => (props.getValue() as string) || '-',
accessorKey: 'description',
cell: (props) => (props.row.original.description as string) || '-',
footer: '',
},
{
header: 'Kategori Produk',
accessorKey: 'kategori_produk',
cell: (props) => (props.getValue() as string) || '-',
accessorKey: 'product_category',
cell: (props) => (props.row.original.product_category as string) || '-',
footer: '',
},
{
header: 'Harga Beli/Qty (Rp)',
accessorKey: 'harga_beli_per_qty',
cell: (props) => formatCurrency(props.getValue() as number),
accessorKey: 'unit_price',
cell: (props) =>
props.row.original.unit_price
? formatCurrency(props.row.original.unit_price as number)
: '-',
footer: total
? () => (
<div className='font-semibold text-gray-900'>
{formatCurrency(total.harga_beli_per_qty)}
{total?.avg_unit_price
? formatCurrency(total?.avg_unit_price)
: '-'}
</div>
)
: '',
},
{
header: 'Total Harga (Rp)',
accessorKey: 'total_harga',
cell: (props) => formatCurrency(props.getValue() as number),
accessorKey: 'total_amount',
cell: (props) =>
props.row.original.total_amount
? formatCurrency(props.row.original.total_amount as number)
: '-',
footer: total
? () => (
<div className='font-semibold text-gray-900'>
{formatCurrency(total.total_harga)}
{total?.total_amount ? formatCurrency(total?.total_amount) : '-'}
</div>
)
: '',
},
{
header: 'Keterangan',
accessorKey: 'keterangan',
cell: (props) => (props.getValue() as string) || '-',
accessorKey: 'notes',
cell: (props) => (props.row.original.notes as string) || '-',
footer: '',
},
];
// Memoize columns untuk setiap kategori
const docBroilerColumns = useMemo(
const docColumns = useMemo(
() =>
isResponseSuccess(sapronakCalculation)
? createColumns(sapronakCalculation.data?.doc_broiler.total)
? createColumns(sapronakCalculation.data?.doc?.total)
: createColumns(),
[sapronakCalculation]
);
@@ -139,7 +164,7 @@ const ClosingSapronakCalculationTable = ({
const ovkColumns = useMemo(
() =>
isResponseSuccess(sapronakCalculation)
? createColumns(sapronakCalculation.data?.ovk.total)
? createColumns(sapronakCalculation.data?.ovk?.total)
: createColumns(),
[sapronakCalculation]
);
@@ -147,73 +172,95 @@ const ClosingSapronakCalculationTable = ({
const pakanColumns = useMemo(
() =>
isResponseSuccess(sapronakCalculation)
? createColumns(sapronakCalculation.data?.pakan.total)
? createColumns(sapronakCalculation.data?.pakan?.total)
: createColumns(),
[sapronakCalculation]
);
return (
<div className='flex flex-col gap-4'>
{isResponseSuccess(sapronakCalculation) && (
<>
<Card
title='DOC Broiler'
collapsible
defaultCollapsed={false}
className={{
wrapper: 'w-full',
body: 'p-4 shadow',
}}
>
<Table<RowSapronakCalculation>
data={sapronakCalculation.data?.doc_broiler.rows ?? []}
columns={docBroilerColumns}
className={{
containerClassName: 'my-4',
}}
renderFooter
/>
</Card>
{/* Table DOC jika kategori Project Flock Growing */}
<Card
title={
closingGeneralInformation?.project_type == 'GROWING'
? 'DOC'
: 'Pullet'
}
collapsible
defaultCollapsed={false}
className={{
wrapper: 'w-full',
body: 'p-4 shadow',
}}
>
<Table<RowSapronakCalculation>
data={
isResponseSuccess(sapronakCalculation)
? (sapronakCalculation.data?.doc?.rows ?? [])
: []
}
columns={docColumns}
className={{
containerClassName: 'my-4',
}}
renderFooter={
isResponseSuccess(sapronakCalculation) &&
sapronakCalculation.data?.doc?.rows.length > 0
}
/>
</Card>
<Card
title='OVK'
variant='bordered'
collapsible
defaultCollapsed={true}
className={{
wrapper: 'w-full',
}}
>
<Table<RowSapronakCalculation>
data={sapronakCalculation.data?.ovk.rows ?? []}
columns={ovkColumns}
className={{
containerClassName: 'my-4',
}}
renderFooter
/>
</Card>
<Card
title='OVK'
variant='bordered'
collapsible
defaultCollapsed={true}
className={{
wrapper: 'w-full',
}}
>
<Table<RowSapronakCalculation>
data={
isResponseSuccess(sapronakCalculation)
? (sapronakCalculation.data?.ovk?.rows ?? [])
: []
}
columns={ovkColumns}
className={{
containerClassName: 'my-4',
}}
renderFooter={
isResponseSuccess(sapronakCalculation) &&
sapronakCalculation.data?.ovk?.rows.length > 0
}
/>
</Card>
<Card
title='Pakan'
variant='bordered'
collapsible
defaultCollapsed={true}
className={{
wrapper: 'w-full',
}}
>
<Table<RowSapronakCalculation>
data={sapronakCalculation.data?.pakan.rows ?? []}
columns={pakanColumns}
className={{
containerClassName: 'my-4',
}}
renderFooter
/>
</Card>
</>
)}
<Card
title='Pakan'
variant='bordered'
collapsible
defaultCollapsed={true}
className={{
wrapper: 'w-full',
}}
>
<Table<RowSapronakCalculation>
data={
isResponseSuccess(sapronakCalculation)
? (sapronakCalculation.data?.pakan?.rows ?? [])
: []
}
columns={pakanColumns}
className={{
containerClassName: 'my-4',
}}
renderFooter={
isResponseSuccess(sapronakCalculation) &&
sapronakCalculation.data?.pakan?.rows.length > 0
}
/>
</Card>
</div>
);
};
+13 -32
View File
@@ -15,6 +15,8 @@ import SelectInput, {
import RowDropdownOptions from '@/components/table/RowDropdownOptions';
import RowCollapseOptions from '@/components/table/RowCollapseOptions';
import RowOptionsMenuWrapper from '@/components/table/RowOptionsMenuWrapper';
import RequirePermission from '@/components/helper/RequirePermission';
import { cn, formatCurrency, formatDate } from '@/lib/helper';
import { isResponseSuccess } from '@/lib/api-helper';
import { useTableFilter } from '@/services/hooks/useTableFilter';
@@ -43,17 +45,18 @@ const RowOptionsMenu = ({
}) => {
return (
<RowOptionsMenuWrapper type={type}>
{/* TODO: apply RBAC */}
<div className='w-full max-h-40 overflow-auto flex flex-col gap-1'>
<Button
href={`/closing/detail/?closingId=${props.row.original.id}`}
variant='ghost'
color='primary'
className='justify-start text-sm'
>
<Icon icon='mdi:eye-outline' width={16} height={16} />
Detail
</Button>
<RequirePermission permissions='lti.closing.detail'>
<Button
href={`/closing/detail/?closingId=${props.row.original.id}`}
variant='ghost'
color='primary'
className='justify-start text-sm'
>
<Icon icon='mdi:eye-outline' width={16} height={16} />
Detail
</Button>
</RequirePermission>
</div>
</RowOptionsMenuWrapper>
);
@@ -123,28 +126,6 @@ const ClosingsTable = () => {
accessorKey: 'shed_label',
header: 'Jumlah Kandang',
},
{
accessorKey: 'sales_paid_amount',
header: 'Jumlah Sudah Bayar',
cell: (props) => (
<span className='text-success'>
{formatCurrency(props.row.original.sales_paid_amount)}
</span>
),
},
{
accessorKey: 'sales_remaining_amount',
header: 'Jumlah Sisa Bayar',
cell: (props) => (
<span className='text-error'>
{formatCurrency(props.row.original.sales_remaining_amount)}
</span>
),
},
{
accessorKey: 'sales_payment_status',
header: 'Status Pembayaran',
},
{
accessorKey: 'project_status',
header: 'Status',
@@ -0,0 +1,110 @@
'use client';
import React, { useMemo } from 'react';
import { ColumnDef } from '@tanstack/react-table';
import Table from '@/components/Table';
import Card from '@/components/Card';
import { formatCurrency } from '@/lib/helper';
import { BaseHppExpedition, BaseExpeditionCost } from '@/types/api/closing';
interface HppExpeditionReportTableProps {
type?: 'detail';
initialValues?: BaseHppExpedition;
}
const HppExpeditionReportTable = ({
type = 'detail',
initialValues,
}: HppExpeditionReportTableProps) => {
const costOfRevenueExpeditionData: BaseExpeditionCost[] = useMemo(() => {
return initialValues?.expedition_costs || [];
}, [initialValues]);
const totals = useMemo(() => {
const totalHpp = initialValues?.total_hpp_amount || 0;
return {
totalHpp,
};
}, [initialValues]);
const costOfRevenueExpeditionColumns: ColumnDef<BaseExpeditionCost>[] =
useMemo(
() => [
{
id: 'id',
accessorKey: 'id',
header: 'No',
cell: (props) => {
return <div>{props.row.index + 1}</div>;
},
footer: () => (
<div className='font-semibold text-gray-900'>
Total HPP Ekspedisi
</div>
),
},
{
id: 'expedition_vendor_name',
accessorKey: 'expedition_vendor_name',
header: 'Nama Ekspedisi',
cell: (props) => props.getValue() || '-',
},
{
id: 'hpp_amount',
accessorKey: 'hpp_amount',
header: 'HPP Ekspedisi',
cell: (props) => {
const value = props.getValue() as number;
return <div className='text-right'>{formatCurrency(value)}</div>;
},
footer: () => (
<div className='text-right font-semibold text-gray-900'>
{formatCurrency(totals.totalHpp)}
</div>
),
},
],
[totals]
);
return (
<>
<section className='w-full'>
<div className='p-4'>
<h2 className='text-xl font-semibold mb-4'>HPP Ekspedisi</h2>
<Card
className={{
wrapper: 'w-full bg-base-100',
body: 'p-0',
}}
>
<Table
data={costOfRevenueExpeditionData}
columns={costOfRevenueExpeditionColumns}
renderFooter={costOfRevenueExpeditionData.length > 0}
className={{
tableWrapperClassName: 'overflow-x-auto',
tableClassName: 'w-full table-auto text-sm',
headerRowClassName: 'border-b border-b-gray-200',
headerColumnClassName:
'px-4 py-3 text-xs font-semibold text-gray-500 last:flex last:flex-row last:justify-end whitespace-nowrap',
bodyRowClassName:
'hover:bg-gray-50 transition-colors border-b border-l border-r border-b-gray-200 border-l-gray-200 border-r-gray-200',
bodyColumnClassName:
'px-4 py-3 text-xs text-gray-900 whitespace-nowrap',
tableFooterClassName:
'bg-gray-100 font-semibold border border-gray-200',
footerRowClassName: 'border-t-2 border-gray-300',
footerColumnClassName:
'px-4 py-3 text-xs text-gray-900 whitespace-nowrap',
}}
/>
</Card>
</div>
</section>
</>
);
};
export default HppExpeditionReportTable;
@@ -215,31 +215,31 @@ const SalesReportTable = ({
return kandang?.name || '-';
},
},
{
id: 'payment_status',
accessorKey: 'payment_status',
header: 'Status Pembayaran',
cell: (props) => {
const status = props.getValue() as string;
const getStatusColor = (status: string) => {
if (!status) return 'neutral';
switch (status.toLowerCase()) {
case 'paid':
return 'success';
case 'tempo':
return 'warning';
default:
return 'neutral';
}
};
// {
// id: 'payment_status',
// accessorKey: 'payment_status',
// header: 'Status Pembayaran',
// cell: (props) => {
// const status = props.getValue() as string;
// const getStatusColor = (status: string) => {
// if (!status) return 'neutral';
// switch (status.toLowerCase()) {
// case 'paid':
// return 'success';
// case 'tempo':
// return 'warning';
// default:
// return 'neutral';
// }
// };
return (
<Badge variant='soft' size='sm' color={getStatusColor(status)}>
{status || '-'}
</Badge>
);
},
},
// return (
// <Badge variant='soft' size='sm' color={getStatusColor(status)}>
// {status || '-'}
// </Badge>
// );
// },
// },
],
[]
);
@@ -0,0 +1,491 @@
'use client';
import Button from '@/components/Button';
import { Icon } from '@iconify/react';
import Modal, { useModal } from '@/components/Modal';
import DateInput from '@/components/input/DateInput';
import SelectInput, {
OptionType,
useSelect,
} from '@/components/input/SelectInput';
import { useState } from 'react';
import useSWR from 'swr';
import { DashboardApi } from '@/services/api/dashboard';
import { useFormik } from 'formik';
import { ProjectFlockApi } from '@/services/api/production';
import { KandangApi, LocationApi } from '@/services/api/master-data';
import {
DashboardFilterType,
getDashboardFilterSchema,
} from '@/components/pages/dashboard/filter/DashboardProductionFilter.schema';
import DashboardLineChart from '@/components/pages/dashboard/chart/DashboardLineChart';
import DashboardLineChartSkeleton from '@/components/pages/dashboard/skeleton/DashboardLineChartSkeleton';
import { RadioGroup, RadioGroupItem } from '@/components/input/RadioInput';
import {
DashboardFilter,
DashboardMeta,
} from '@/types/api/dashboard/dashboard';
import DashboardStats from '@/components/pages/dashboard/chart/DashboardStats';
import { isResponseSuccess } from '@/lib/api-helper';
import AlertErrorList from '@/components/helper/form/FormErrors';
import { useFormikErrorList } from '@/services/hooks/useFormikErrorList';
// Helper function to normalize values to array
const normalizeToArray = (
value: OptionType | OptionType[] | null | undefined
): number[] => {
if (!value) return [];
if (Array.isArray(value)) {
return value.map((v) => Number(v.value));
}
return [Number(value.value)];
};
const DashboardProduction = () => {
const filterModal = useModal();
const [analysisMode, setAnalysisMode] = useState<'OVERVIEW' | 'COMPARISON'>(
'OVERVIEW'
);
const [endpointUrl, setEndpointUrl] = useState('/dashboards');
const [selectedLocationIds, setSelectedLocationIds] = useState<number[]>([]);
// ===== FETCH DATA =====
const {
data: dashboardProductionResponse,
isLoading: isLoadingDashboardProductionData,
mutate: refreshDashboardProductionData,
} = useSWR(endpointUrl, () =>
DashboardApi.getDashboardProductionFetcher(endpointUrl)
);
const dashboardProductionData = isResponseSuccess(dashboardProductionResponse)
? dashboardProductionResponse.data
: undefined;
// ===== SELECT =====
const { options: flockOptions, isLoadingOptions: isLoadingFlockOptions } =
useSelect(ProjectFlockApi.basePath, 'id', 'flock_name', '', {
limit: 'limit',
location_id: selectedLocationIds ? selectedLocationIds.toString() : '',
});
const {
options: locationOptions,
isLoadingOptions: isLoadingLocationOptions,
} = useSelect(LocationApi.basePath, 'id', 'name', '', {
limit: 'limit',
});
const { options: kandangOptions, isLoadingOptions: isLoadingKandangOptions } =
useSelect(KandangApi.basePath, 'id', 'name', '', {
limit: 'limit',
location_id: selectedLocationIds ? selectedLocationIds.toString() : '',
});
const comparisonTypeOptions = [
{ value: 'FARM', label: 'Farm' },
{ value: 'FLOCK', label: 'Flock' },
{ value: 'KANDANG', label: 'Kandang' },
];
// ===== FORMIK =====
const formik = useFormik({
initialValues: {
startDate: '',
endDate: '',
flock: [] as OptionType[],
location: [] as OptionType[],
kandang: [] as OptionType[],
analysisMode: analysisMode,
comparisonType: '',
lokasiIds: [],
flockIds: [],
kandangIds: [],
} as DashboardFilterType,
validationSchema: getDashboardFilterSchema(analysisMode),
onSubmit: (values) => {
console.log(values);
handleApplyFilter({
start_date: values.startDate || '',
end_date: values.endDate || '',
analysis_mode: values.analysisMode as 'OVERVIEW' | 'COMPARISON',
location_ids: normalizeToArray(values.location),
flock_ids: normalizeToArray(values.flock),
kandang_ids: normalizeToArray(values.kandang),
comparison_type: values.comparisonType,
});
},
});
const handleResetFilter = () => {
formik.resetForm();
setAnalysisMode('OVERVIEW');
setEndpointUrl('/dashboards');
};
const handleApplyFilter = (values: DashboardFilter) => {
console.log(values);
// Build query params object, only include non-empty values
const params: Record<string, string> = {};
if (values.start_date) params.start_date = values.start_date;
if (values.end_date) params.end_date = values.end_date;
if (values.analysis_mode) params.analysis_mode = values.analysis_mode;
if (values.location_ids.length > 0)
params.location_ids = values.location_ids.toString();
if (values.flock_ids.length > 0)
params.flock_ids = values.flock_ids.toString();
if (values.kandang_ids.length > 0)
params.kandang_ids = values.kandang_ids.toString();
if (values.comparison_type) params.comparison_type = values.comparison_type;
setEndpointUrl(`/dashboards?${new URLSearchParams(params).toString()}`);
console.log(endpointUrl);
filterModal.closeModal();
refreshDashboardProductionData();
formik.resetForm();
};
// ===== Formik Error List =====
const { formErrorList, close, handleFormSubmit } = useFormikErrorList(formik);
if (isLoadingDashboardProductionData) {
return (
<div className='w-full min-h-screen flex items-center justify-center'>
<span className='loading loading-spinner loading-xl'></span>
</div>
);
}
return (
<>
<section className='w-full p-4 space-y-6'>
<div className='flex flex-col sm:flex-row items-center justify-between gap-4'>
<div></div>
<div className='flex flex-row justify-end gap-2'>
<Button
variant='outline'
className={`min-w-28 rounded-lg ${
isResponseSuccess(dashboardProductionResponse) &&
(dashboardProductionResponse.meta as unknown as DashboardMeta)
.filters
? 'bg-gradient-to-r from-blue-50 to-blue-100 border-blue-500 text-blue-600 hover:from-blue-100 hover:to-blue-200'
: ''
}`}
onClick={() => filterModal.openModal()}
>
<Icon
icon='heroicons:funnel'
width={20}
height={20}
className={
isResponseSuccess(dashboardProductionResponse) &&
(dashboardProductionResponse.meta as unknown as DashboardMeta)
.filters
? 'text-blue-600'
: ''
}
/>
Filter
{isResponseSuccess(dashboardProductionResponse) &&
dashboardProductionResponse.meta &&
(dashboardProductionResponse.meta as unknown as DashboardMeta)
.filters && (
<span className='w-6 h-6 text-white bg-red-500 rounded-lg flex items-center justify-center text-xs'>
{(() => {
const meta =
dashboardProductionResponse.meta as unknown as DashboardMeta;
if (!meta.filters) return 0;
const count =
(meta.filters.location_ids.length > 1
? meta.filters.location_ids.length
: 0) +
(meta.filters.flock_ids.length > 1
? meta.filters.flock_ids.length
: 0) +
(meta.filters.kandang_ids.length > 1
? meta.filters.kandang_ids.length
: 0);
return meta.filters.analysis_mode === 'OVERVIEW'
? 1
: count;
})()}
</span>
)}
</Button>
<Button
variant='outline'
color='neutral'
className='min-w-28 rounded-lg'
>
<Icon icon='heroicons:arrow-down-tray' width={20} height={20} />
Export
<Icon icon='heroicons:chevron-down' width={20} height={20} />
</Button>
</div>
</div>
{/* Dashboard Stats */}
<DashboardStats data={dashboardProductionData?.statistics_data ?? []} />
{/* Use DashboardLineChart component or skeleton */}
{isLoadingDashboardProductionData ? (
<DashboardLineChartSkeleton />
) : dashboardProductionData &&
dashboardProductionData.charts &&
Object.keys(dashboardProductionData.charts).length > 0 ? (
<DashboardLineChart
analysisMode={
isResponseSuccess(dashboardProductionResponse)
? dashboardProductionResponse.meta
? (
dashboardProductionResponse.meta as unknown as DashboardMeta
).filters?.analysis_mode
: analysisMode
: analysisMode
}
data={dashboardProductionData}
/>
) : (
<DashboardLineChartSkeleton
meta={
isResponseSuccess(dashboardProductionResponse)
? (dashboardProductionResponse.meta as unknown as DashboardMeta)
: undefined
}
/>
)}
</section>
<Modal
ref={filterModal.ref}
className={{
modal: 'p-0',
modalBox: 'p-0 rounded-xl',
}}
>
<div className='space-y-6'>
{/* Modal Header */}
<div className='flex items-center justify-between gap-2 py-3 border-b border-gray-300'>
<div className='flex items-center gap-2 ms-4'>
<Icon icon='heroicons:funnel' width={20} height={20} />
<h3 className='font-semibold'>Filter Data</h3>
</div>
<Button
variant='link'
onClick={() => filterModal.closeModal()}
className='text-gray-500 hover:text-gray-700 me-4 '
>
<Icon icon='heroicons:x-mark' width={20} height={20} />
</Button>
</div>
<form
className='space-y-4'
onSubmit={handleFormSubmit}
onReset={handleResetFilter}
>
{/* Rentang Waktu */}
<div className='px-4'>
<label className='flex items-center gap-2 mb-3'>Tanggal</label>
<div className='flex items-center gap-2'>
<DateInput
name='startDate'
placeholder='Tanggal Mulai'
value={formik.values.startDate}
errorMessage={formik.errors.startDate}
onChange={formik.handleChange}
className={{
inputWrapper: 'rounded-lg',
}}
isError={
Boolean(formik.errors.startDate) &&
Boolean(formik.touched.startDate)
}
/>
<span className='hidden md:block text-center'></span>
<DateInput
name='endDate'
placeholder='Tanggal Akhir'
value={formik.values.endDate}
errorMessage={formik.errors.endDate}
onChange={formik.handleChange}
className={{
inputWrapper: 'rounded-lg',
}}
isError={
Boolean(formik.errors.endDate) &&
Boolean(formik.touched.endDate)
}
/>
</div>
</div>
{/* Analysis Mode */}
<div className='px-4'>
<label className='block mb-3'>Analysis Mode</label>
<RadioGroup
name='analysisMode'
value={formik.values.analysisMode}
onChange={(e) => {
formik.handleChange(e);
setAnalysisMode(e.target.value as 'OVERVIEW' | 'COMPARISON');
// Reset all dependent fields when analysis mode changes
formik.setFieldValue('location', []);
formik.setFieldValue('flock', []);
formik.setFieldValue('kandang', []);
formik.setFieldValue('comparisonType', '');
setSelectedLocationIds([]);
}}
color='primary'
className={{
wrapper: 'w-full my-6 font-semibold text-neutral-500',
}}
>
<RadioGroupItem
color='primary'
value='OVERVIEW'
label='Performance Overview'
/>
<RadioGroupItem
color='primary'
value='COMPARISON'
label='Performance Comparison'
/>
</RadioGroup>
</div>
{formik.values.analysisMode === 'COMPARISON' && (
<div className='px-4'>
<SelectInput
label='Compared By'
value={comparisonTypeOptions.find(
(option) => option.value === formik.values.comparisonType
)}
onChange={(selected) =>
formik.setFieldValue(
'comparisonType',
selected ? (selected as OptionType).value : ''
)
}
errorMessage={formik.errors.comparisonType as string}
options={comparisonTypeOptions}
isLoading={isLoadingLocationOptions}
isError={
Boolean(formik.errors.comparisonType) &&
Boolean(formik.touched.comparisonType)
}
/>
</div>
)}
{/* Location */}
<div className='px-4'>
<SelectInput
label='Farm'
value={formik.values.location}
onChange={(selected) => {
formik.setFieldValue('location', selected);
// Update selectedLocationIds for kandang filter
setSelectedLocationIds(normalizeToArray(selected));
// Reset dependent fields when location changes
formik.setFieldValue('flock', []);
formik.setFieldValue('kandang', []);
}}
errorMessage={formik.errors.location as string}
options={locationOptions}
isLoading={isLoadingLocationOptions}
isMulti={
comparisonTypeOptions.find(
(option) => option.value === formik.values.comparisonType
)?.value === 'FARM'
}
isError={
Boolean(formik.errors.location) &&
Boolean(formik.touched.location)
}
/>
</div>
{/* Flock */}
{!(
formik.values.analysisMode === 'COMPARISON' &&
!(
formik.values.comparisonType === 'FLOCK' ||
formik.values.comparisonType === 'KANDANG'
)
) && (
<div className='px-4'>
<SelectInput
label='Flock'
value={formik.values.flock}
onChange={(selected) =>
formik.setFieldValue('flock', selected)
}
errorMessage={formik.errors.flock as string}
options={flockOptions}
isLoading={isLoadingFlockOptions}
isMulti={
comparisonTypeOptions.find(
(option) => option.value === formik.values.comparisonType
)?.value === 'FLOCK'
}
isError={
Boolean(formik.errors.flock) &&
Boolean(formik.touched.flock)
}
/>
</div>
)}
{/* Kandang */}
{!(
formik.values.analysisMode === 'COMPARISON' &&
!(formik.values.comparisonType === 'KANDANG')
) && (
<div className='px-4'>
<SelectInput
label='Kandang'
value={formik.values.kandang}
onChange={(selected) =>
formik.setFieldValue('kandang', selected)
}
errorMessage={formik.errors.kandang as string}
options={kandangOptions}
isLoading={isLoadingKandangOptions}
isMulti={
comparisonTypeOptions.find(
(option) => option.value === formik.values.comparisonType
)?.value === 'KANDANG'
}
isError={
Boolean(formik.errors.kandang) &&
Boolean(formik.touched.kandang)
}
/>
</div>
)}
<AlertErrorList formErrorList={formErrorList} onClose={close} />
{/* Action Buttons */}
<div className='flex justify-between gap-4 py-4 mt-8 border-t border-gray-300 bg-gray-100'>
<Button
type='reset'
variant='soft'
className='ms-4 min-w-36 rounded-lg'
onClick={handleResetFilter}
>
Reset Filter
</Button>
<Button type='submit' className='me-4 min-w-36 rounded-lg'>
Terapkan Filter
</Button>
</div>
</form>
</div>
</Modal>
</>
);
};
export default DashboardProduction;
@@ -0,0 +1,545 @@
import Button from '@/components/Button';
import Card from '@/components/Card';
import Dropdown from '@/components/Dropdown';
import Menu from '@/components/menu/Menu';
import MenuItem from '@/components/menu/MenuItem';
import {
Dashboard,
DashboardOverviewCharts,
DashboardComparisonCharts,
DashboardChartsSeries,
DashboardChartsDataset,
} from '@/types/api/dashboard/dashboard';
import { Icon } from '@iconify/react';
import { useState, useEffect } from 'react';
import {
CartesianGrid,
Line,
LineChart,
ResponsiveContainer,
Tooltip,
XAxis,
YAxis,
} from 'recharts';
type DashboardLineChartProps = {
analysisMode: 'OVERVIEW' | 'COMPARISON';
data: Dashboard;
};
// Type guard to check if charts is DashboardOverviewCharts
function isOverviewCharts(
charts: DashboardOverviewCharts | DashboardComparisonCharts
): charts is DashboardOverviewCharts {
return 'deplesi' in charts;
}
// Type guard to check if charts is DashboardComparisonCharts
function isComparisonCharts(
charts: DashboardOverviewCharts | DashboardComparisonCharts
): charts is DashboardComparisonCharts {
return 'location' in charts || 'flock' in charts || 'kandang' in charts;
}
const lineColors: Record<string, string> = {
body_weight: '#10B981',
std_body_weight: '#10B981',
act_laying: '#1062B9',
std_laying: '#1062B9',
act_egg_weight: '#10B981',
std_egg_weight: '#10B981',
act_feed_intake: '#F52419',
std_feed_intake: '#F52419',
act_uniformity: '#F59E0B',
std_uniformity: '#F59E0B',
act_fcr: '#10B981',
std_fcr: '#10B981',
act_fcr_cum: '#F52419',
std_fcr_cum: '#10B981',
normal: '#10B981',
abnormal: '#F52419',
act_deplesi: '#10B981',
std_deplesi: '#10B981',
};
const defaultLineColors: string[] = [
'#10B981',
'#1062B9',
'#F52419',
'#F59E0B',
'#7F56D9',
];
// Helper function to get line color
const getLineColor = (
seriesId: string | number,
index: number,
mode: 'OVERVIEW' | 'COMPARISON'
): string => {
// For COMPARISON mode, use default colors with cycling
if (mode === 'COMPARISON') {
return defaultLineColors[index % defaultLineColors.length];
}
// For OVERVIEW mode, use predefined colors or fallback to default
const predefinedColor = lineColors[seriesId];
if (predefinedColor) {
return predefinedColor;
}
// Fallback to default colors with cycling
return defaultLineColors[index % defaultLineColors.length];
};
const DashboardLineChart = ({
analysisMode,
data,
}: DashboardLineChartProps) => {
const [chartData, setChartData] =
useState<keyof DashboardOverviewCharts>('body_weight');
const [open, setOpen] = useState(false);
// Track which series are visible (by series id)
const [visibleSeries, setVisibleSeries] = useState<Set<string | number>>(
new Set()
);
// Mapping for chart type labels
const chartTypeLabels: Record<keyof DashboardOverviewCharts, string> = {
body_weight: 'Body Weight',
performance: 'Performance',
fcr: 'FCR',
quality_control: 'Quality Control',
deplesi: 'Deplesi',
};
// Initialize all series as visible when chartData changes
useEffect(() => {
let seriesData: DashboardChartsSeries[] = [];
if (analysisMode === 'OVERVIEW' && isOverviewCharts(data.charts)) {
seriesData = data.charts[chartData]?.series || [];
} else if (
analysisMode === 'COMPARISON' &&
isComparisonCharts(data.charts)
) {
const comparisonChart =
data.charts.location || data.charts.flock || data.charts.kandang;
seriesData = comparisonChart?.series || [];
}
// Set all series as visible by default
const allSeriesIds = new Set(seriesData.map((s) => s.id));
setVisibleSeries(allSeriesIds);
}, [chartData, analysisMode, data.charts]);
return (
<Card
className={{
wrapper: 'w-full rounded-lg',
}}
variant='bordered'
>
<div className='flex flex-col sm:flex-row justify-between items-start sm:items-center gap-4 mb-6'>
<div className='text-lg font-semibold'>
Performance{' '}
<Icon
icon='heroicons:information-circle'
width={20}
height={20}
className='inline text-neutral-500'
/>
</div>
{analysisMode == 'OVERVIEW' && (
<Dropdown
align='end'
direction='bottom'
trigger={
<Button
variant='outline'
color='none'
className='text-neutral-500 hover:text-neutral-700 rounded-lg px-4 py-2 border-neutral-300'
onClick={() => setOpen(!open)}
>
{chartTypeLabels[chartData]}{' '}
<div className='divider divider-horizontal p-0 m-0 before:bg-neutral-300 after:bg-neutral-300'></div>
<Icon icon='heroicons:chevron-down' width={20} height={20} />
</Button>
}
className={{
content: 'w-52 mt-3',
}}
controlled={open}
>
<Menu>
<MenuItem
title='Body weight'
onClick={() => {
setChartData('body_weight');
setOpen(!open);
}}
/>
<MenuItem
title='Performance'
onClick={() => {
setChartData('performance');
setOpen(!open);
}}
/>
<MenuItem
title='FCR'
onClick={() => {
setChartData('fcr');
setOpen(!open);
}}
/>
<MenuItem
title='Quality Control'
onClick={() => {
setChartData('quality_control');
setOpen(!open);
}}
/>
<MenuItem
title='Deplesi'
onClick={() => {
setChartData('deplesi');
setOpen(!open);
}}
/>
</Menu>
</Dropdown>
)}
</div>
{/* Legend - Dynamic based on series data */}
<div className='flex flex-wrap gap-3 mb-6'>
{(() => {
// Get series data based on current mode and chartData
let seriesData: DashboardChartsSeries[] = [];
if (analysisMode === 'OVERVIEW' && isOverviewCharts(data.charts)) {
seriesData = data.charts[chartData]?.series || [];
} else if (
analysisMode === 'COMPARISON' &&
isComparisonCharts(data.charts)
) {
const comparisonChart =
data.charts.location || data.charts.flock || data.charts.kandang;
seriesData = comparisonChart?.series || [];
}
return seriesData.map((series, index) => {
const isVisible = visibleSeries.has(series.id);
const isStandard = series.id
.toString()
.toLowerCase()
.includes('std');
return (
<button
key={series.id}
onClick={() => {
const newVisible = new Set(visibleSeries);
if (isVisible) {
newVisible.delete(series.id);
} else {
newVisible.add(series.id);
}
setVisibleSeries(newVisible);
}}
className={`flex items-center gap-2 px-3 py-2 rounded-lg border transition-colors ${
isVisible
? 'border-neutral-400 bg-neutral-50'
: 'border-neutral-300 hover:bg-neutral-50'
}`}
>
<div
className={`w-6 h-0.5 ${
isStandard ? 'border-t-2 border-dashed' : ''
} ${!isVisible ? 'opacity-30' : ''}`}
style={{
backgroundColor: isStandard
? 'transparent'
: getLineColor(series.id, index, analysisMode),
borderColor: isStandard
? getLineColor(series.id, index, analysisMode)
: 'transparent',
}}
></div>
<span
className={`text-sm ${isVisible ? 'text-neutral-900 font-medium' : 'text-neutral-700'}`}
>
{series.label}
</span>
<Icon
icon='heroicons:information-circle'
width={16}
height={16}
className='text-neutral-400'
/>
</button>
);
});
})()}
</div>
{/* Chart */}
<ResponsiveContainer width='100%' height={350}>
<LineChart
data={(() => {
// Transform data based on analysisMode
if (analysisMode === 'OVERVIEW') {
// For OVERVIEW mode, use the selected chart data
if (isOverviewCharts(data.charts)) {
const selectedChartData = data.charts[chartData];
if (!selectedChartData || !selectedChartData.dataset) return [];
return selectedChartData.dataset;
}
return [];
} else {
// For COMPARISON mode, use the first available comparison chart
if (isComparisonCharts(data.charts)) {
const chartData =
data.charts.location ||
data.charts.flock ||
data.charts.kandang;
if (!chartData || !chartData.dataset) return [];
return chartData.dataset;
}
return [];
}
})()}
margin={{
top: 5,
right: 10,
left: 0,
bottom: 5,
}}
>
<CartesianGrid strokeDasharray='3 3' stroke='#e5e7eb' />
<XAxis
dataKey='week'
tick={{ fontSize: 11, fill: '#9ca3af' }}
tickLine={false}
axisLine={{ stroke: '#e5e7eb' }}
label={{
value: 'Weeks',
position: 'insideBottom',
offset: -5,
style: { fontSize: 12, fill: '#9ca3af' },
}}
/>
<YAxis
tick={{ fontSize: 11, fill: '#9ca3af' }}
tickLine={false}
axisLine={{ stroke: '#e5e7eb' }}
domain={(() => {
// Calculate dynamic domain based on visible data
let seriesData: DashboardChartsSeries[] = [];
let dataset: DashboardChartsDataset[] = [];
if (
analysisMode === 'OVERVIEW' &&
isOverviewCharts(data.charts)
) {
seriesData = data.charts[chartData]?.series || [];
dataset = data.charts[chartData]?.dataset || [];
} else if (
analysisMode === 'COMPARISON' &&
isComparisonCharts(data.charts)
) {
const comparisonChart =
data.charts.location ||
data.charts.flock ||
data.charts.kandang;
seriesData = comparisonChart?.series || [];
dataset = comparisonChart?.dataset || [];
}
// Get all values from visible series
const visibleSeriesIds = Array.from(visibleSeries);
const allValues: number[] = [];
dataset.forEach((item: DashboardChartsDataset) => {
visibleSeriesIds.forEach((seriesId) => {
const value = item[seriesId];
if (typeof value === 'number') {
allValues.push(value);
}
});
});
if (allValues.length === 0) return [0, 100];
const minValue = Math.min(...allValues);
const maxValue = Math.max(...allValues);
// Add padding (10% on each side)
const padding = (maxValue - minValue) * 0.1;
const domainMin = Math.floor(Math.max(0, minValue - padding));
const domainMax = Math.ceil(maxValue + padding);
return [domainMin, domainMax];
})()}
ticks={(() => {
// Calculate dynamic ticks based on domain
let seriesData: DashboardChartsSeries[] = [];
let dataset: DashboardChartsDataset[] = [];
if (
analysisMode === 'OVERVIEW' &&
isOverviewCharts(data.charts)
) {
seriesData = data.charts[chartData]?.series || [];
dataset = data.charts[chartData]?.dataset || [];
} else if (
analysisMode === 'COMPARISON' &&
isComparisonCharts(data.charts)
) {
const comparisonChart =
data.charts.location ||
data.charts.flock ||
data.charts.kandang;
seriesData = comparisonChart?.series || [];
dataset = comparisonChart?.dataset || [];
}
const visibleSeriesIds = Array.from(visibleSeries);
const allValues: number[] = [];
dataset.forEach((item: DashboardChartsDataset) => {
visibleSeriesIds.forEach((seriesId) => {
const value = item[seriesId];
if (typeof value === 'number') {
allValues.push(value);
}
});
});
if (allValues.length === 0) return [0, 25, 50, 75, 100];
const minValue = Math.min(...allValues);
const maxValue = Math.max(...allValues);
const padding = (maxValue - minValue) * 0.1;
const domainMin = Math.floor(Math.max(0, minValue - padding));
const domainMax = Math.ceil(maxValue + padding);
// Generate 5 evenly spaced ticks
const range = domainMax - domainMin;
const step = range / 4;
return [
domainMin,
Math.round(domainMin + step),
Math.round(domainMin + step * 2),
Math.round(domainMin + step * 3),
domainMax,
];
})()}
/>
<Tooltip
contentStyle={{
backgroundColor: '#1f2937',
border: 'none',
borderRadius: '8px',
padding: '8px 12px',
color: 'white',
}}
labelStyle={{ color: 'white', marginBottom: '4px' }}
itemStyle={{ color: 'white', fontSize: '12px' }}
labelFormatter={(value) => `Week ${value}`}
formatter={(
value: number | undefined,
name: string | undefined
) => {
if (value === undefined || name === undefined) return ['', ''];
// Get series data to find the unit
let seriesData: DashboardChartsSeries[] = [];
if (
analysisMode === 'OVERVIEW' &&
isOverviewCharts(data.charts)
) {
seriesData = data.charts[chartData]?.series || [];
} else if (
analysisMode === 'COMPARISON' &&
isComparisonCharts(data.charts)
) {
const comparisonChart =
data.charts.location ||
data.charts.flock ||
data.charts.kandang;
seriesData = comparisonChart?.series || [];
}
// Find the series that matches this line's name
const series = seriesData.find((s) => s.label === name);
const unit = series?.unit || '';
return [`${value} ${unit}`, name];
}}
/>
{/* Dynamic Line rendering based on visible series */}
{(() => {
let seriesData: DashboardChartsSeries[] = [];
if (analysisMode === 'OVERVIEW' && isOverviewCharts(data.charts)) {
seriesData = data.charts[chartData]?.series || [];
} else if (
analysisMode === 'COMPARISON' &&
isComparisonCharts(data.charts)
) {
const comparisonChart =
data.charts.location ||
data.charts.flock ||
data.charts.kandang;
seriesData = comparisonChart?.series || [];
}
return seriesData
.filter((series) => visibleSeries.has(series.id))
.map((series, index) => {
const isStandard = series.id
.toString()
.toLowerCase()
.includes('std');
// Use series.id directly as dataKey to match dataset fields
const dataKey = series.id.toString();
return (
<Line
key={series.id}
type='monotone'
dataKey={dataKey}
name={series.label}
stroke={getLineColor(series.id, index, analysisMode)}
opacity={isStandard ? 0.5 : 1}
strokeWidth={2}
strokeDasharray={isStandard ? '5 5' : undefined}
dot={
isStandard
? false
: {
r: 3,
fill: '#fff',
stroke: getLineColor(
series.id,
index,
analysisMode
),
strokeWidth: 2,
}
}
activeDot={isStandard ? undefined : { r: 5 }}
/>
);
});
})()}
</LineChart>
</ResponsiveContainer>
</Card>
);
};
export default DashboardLineChart;
@@ -0,0 +1,166 @@
import Alert from '@/components/Alert';
import Card from '@/components/Card';
import { formatNumber } from '@/lib/helper';
import { DashboardStatisticsData } from '@/types/api/dashboard/dashboard';
import { Icon } from '@iconify/react';
interface DashboardStatsProps {
data: DashboardStatisticsData[];
}
// Konfigurasi untuk setiap kartu
const CARD_CONFIG = [
{
key: 'HPP Global',
icon: 'heroicons:banknotes',
alertColor: 'warning' as const,
suffix: ' /Kg',
prefix: 'RP ',
},
{
key: 'Avg. Selling Price',
icon: 'heroicons:document-currency-dollar',
alertColor: 'success' as const,
suffix: ' /Kg',
prefix: '',
},
{
key: 'FCR',
icon: 'heroicons:clipboard-document-list',
alertColor: 'info' as const,
suffix: '',
prefix: '',
},
{
key: 'Mortality',
icon: 'heroicons:exclamation-triangle',
alertColor: 'error' as const,
suffix: ' %',
prefix: '',
},
];
const DashboardStats = ({ data }: DashboardStatsProps) => {
// Helper to get trend icon and color
const getTrendDisplay = (percent: number) => {
const isPositive = percent >= 0;
return {
icon: isPositive
? 'heroicons:arrow-trending-up'
: 'heroicons:arrow-trending-down',
color: isPositive ? 'text-success' : 'text-error',
value: Math.abs(percent),
};
};
// Helper to format value
const formatValue = (value: number, prefix: string, suffix: string) => {
return (
<>
{prefix}
{formatNumber(value)}
{suffix && (
<span className='text-sm font-normal text-neutral-500'>{suffix}</span>
)}
</>
);
};
return (
<div className='grid sm:grid-cols-2 xl:grid-cols-4 gap-6'>
{CARD_CONFIG.map((config) => {
// Find matching data from API
const cardData = data.find((item) => item.label === config.key);
if (!cardData) {
// Show placeholder card for missing data (FCR & Mortality)
return (
<Card
key={config.key}
className={{
wrapper: 'w-full rounded-lg',
body: 'p-0',
}}
variant='bordered'
footer={
<div className='flex flex-row justify-between px-4 pb-4'>
<div className='text-neutral-400 font-semibold text-sm'>
From last month
</div>
<div className='text-neutral-400 font-semibold text-sm'>
Filter Required
</div>
</div>
}
>
<div className='flex flex-row items-center gap-4 px-4 pt-4'>
<Alert variant='soft' className='rounded-lg p-3 bg-neutral-100'>
<Icon
icon={config.icon}
width={32}
height={32}
className='text-neutral-400'
/>
</Alert>
<div>
<h3 className='text-neutral-400 font-semibold text-sm'>
{config.key}
</h3>
<p className='text-2xl font-semibold text-neutral-400'>
********
</p>
</div>
</div>
</Card>
);
}
const trend = getTrendDisplay(cardData.percent_last_month);
return (
<Card
key={config.key}
className={{
wrapper: 'w-full rounded-lg',
body: 'p-0',
}}
variant='bordered'
footer={
<div className='flex flex-row justify-between px-4 pb-4'>
<div className='text-neutral-500 font-semibold text-sm'>
From last month
</div>
<div
className={`${trend.color} font-semibold flex flex-row items-center gap-1 text-sm`}
>
<Icon icon={trend.icon} width={16} height={16} />
{trend.value}%
</div>
</div>
}
>
<div className='flex flex-row items-center gap-4 px-4 pt-4'>
<Alert
variant='soft'
color={config.alertColor}
className='rounded-lg p-3'
>
<Icon icon={config.icon} width={32} height={32} />
</Alert>
<div>
<h3 className='text-neutral-500 font-semibold text-sm'>
{cardData.label}
</h3>
<p className='text-2xl font-semibold'>
{formatValue(cardData.value, config.prefix, config.suffix)}
</p>
</div>
</div>
</Card>
);
})}
</div>
);
};
export default DashboardStats;
@@ -0,0 +1,117 @@
import { OptionType } from '@/components/input/SelectInput';
import * as yup from 'yup';
export type DashboardFilterType = {
startDate: string;
endDate: string;
analysisMode: string;
comparisonType: string | undefined;
location: OptionType | OptionType[];
lokasiIds: number[] | undefined;
flock: OptionType | OptionType[] | undefined;
flockIds: number[] | undefined;
kandang: OptionType | OptionType[] | undefined;
kandangIds: number[] | undefined;
};
// Schema untuk mode OVERVIEW - semua field required
export const DashboardFilterOverviewSchema: yup.ObjectSchema<DashboardFilterType> =
yup.object({
startDate: yup.string().required('Start date is required'),
endDate: yup.string().required('End date is required'),
analysisMode: yup.string().required('Analysis mode is required'),
comparisonType: yup.string().when('analysisMode', {
is: 'COMPARISON',
then: (schema) => schema.required('Compared by is required'),
otherwise: (schema) => schema.optional(),
}),
lokasiIds: yup.array().optional(),
flockIds: yup.array().optional(),
kandangIds: yup.array().optional(),
location: yup
.mixed<OptionType | OptionType[]>()
.required('Farm is required')
.test('is-not-empty', 'Farm is required', (value) => {
if (Array.isArray(value)) {
return value.length > 0;
}
return !!value;
}),
flock: yup
.mixed<OptionType | OptionType[]>()
.required('Flock is required')
.test('is-not-empty', 'Flock is required', (value) => {
if (Array.isArray(value)) {
return value.length > 0;
}
return !!value;
}),
kandang: yup
.mixed<OptionType | OptionType[]>()
.required('Kandang is required')
.test('is-not-empty', 'Kandang is required', (value) => {
if (Array.isArray(value)) {
return value.length > 0;
}
return !!value;
}),
});
// Schema untuk mode COMPARISON - conditional validation
export const DashboardFilterComparisonSchema: yup.ObjectSchema<DashboardFilterType> =
yup.object({
startDate: yup.string().required('Start date is required'),
endDate: yup.string().required('End date is required'),
analysisMode: yup.string().required('Analysis mode is required'),
comparisonType: yup.string().when('analysisMode', {
is: 'COMPARISON',
then: (schema) => schema.required('Compared by is required'),
otherwise: (schema) => schema.optional(),
}),
lokasiIds: yup.array().optional(),
flockIds: yup.array().optional(),
kandangIds: yup.array().optional(),
location: yup
.mixed<OptionType | OptionType[]>()
.required('Farm is required')
.test('is-not-empty', 'Farm is required', (value) => {
if (Array.isArray(value)) {
return value.length > 0;
}
return !!value;
}),
flock: yup.mixed<OptionType | OptionType[]>().when('comparisonType', {
is: (value: string) => value === 'FLOCK' || value === 'KANDANG',
then: (schema) =>
schema.test('is-required', 'Flock is required', (value) => {
if (Array.isArray(value)) {
return value.length > 0;
}
return !!value;
}),
otherwise: (schema) => schema.optional(),
}),
kandang: yup.mixed<OptionType | OptionType[]>().when('comparisonType', {
is: 'KANDANG',
then: (schema) =>
schema.test('is-required', 'Kandang is required', (value) => {
if (Array.isArray(value)) {
return value.length > 0;
}
return !!value;
}),
otherwise: (schema) => schema.optional(),
}),
});
// Helper function untuk mendapatkan schema yang sesuai berdasarkan analysis mode
export const getDashboardFilterSchema = (analysisMode?: string) => {
return analysisMode === 'OVERVIEW'
? DashboardFilterOverviewSchema
: DashboardFilterComparisonSchema;
};
// Default schema
export const DashboardFilterSchema = DashboardFilterComparisonSchema;
export type DashboardFilterValues = yup.InferType<typeof DashboardFilterSchema>;
@@ -0,0 +1,100 @@
import { Icon } from '@iconify/react';
import { DashboardMeta } from '@/types/api/dashboard/dashboard';
const DashboardLineChartSkeleton = ({ meta }: { meta?: DashboardMeta }) => {
return (
<div className='w-full bg-white rounded-lg shadow-sm border border-gray-200 p-6 relative'>
{/* Header with title skeleton */}
<div className='text-lg font-semibold'>
Performance{' '}
<Icon
icon='heroicons:information-circle'
width={20}
height={20}
className='inline text-neutral-500'
/>
</div>
{/* Chart area with axes skeleton */}
<div className='relative mt-6'>
{/* Main chart container */}
<div className='flex gap-4'>
{/* Y-axis skeleton (left side) */}
<div className='flex flex-col justify-between py-4 space-y-4'>
{[1, 2, 3, 4, 5, 6].map((item) => (
<div
key={item}
className='h-4 w-12 bg-gray-100 rounded animate-pulse'
></div>
))}
</div>
{/* Chart content area */}
<div className='flex-1 relative'>
{/* Empty state centered in chart area */}
<div className='absolute inset-0 flex flex-col items-center justify-center pb-12'>
{!meta?.filters && (
<>
{/* Filter icon */}
<div className='w-12 h-12 bg-blue-500 rounded-xl flex items-center justify-center mb-4'>
<Icon
icon='heroicons:funnel'
className='text-white'
width={24}
height={24}
/>
</div>
{/* Empty state text */}
<h3 className='text-gray-900 font-semibold text-base mb-2'>
No Filters Selected
</h3>
<p className='text-gray-500 text-sm text-center max-w-xs'>
Please choose filters to narrow down your results and make
your search easier.
</p>
</>
)}
{meta?.filters && (
<>
{/* Filter icon */}
<div className='w-12 h-12 bg-blue-500 rounded-xl flex items-center justify-center mb-4'>
<Icon
icon='heroicons:chart-bar'
className='text-white'
width={24}
height={24}
/>
</div>
{/* Empty state text */}
<h3 className='text-gray-900 font-semibold text-base mb-2'>
Data Not Yet Available
</h3>
<p className='text-gray-500 text-sm text-center max-w-xs'>
Please change your filters to get the data.
</p>
</>
)}
</div>
{/* Placeholder for chart height */}
<div className='h-64'></div>
{/* X-axis skeleton (bottom) */}
<div className='flex justify-between pt-4 border-t border-gray-100'>
{[1, 2, 3, 4, 5, 6, 7, 8, 9, 10].map((item) => (
<div
key={item}
className='h-4 w-8 bg-gray-100 rounded animate-pulse'
></div>
))}
</div>
</div>
</div>
</div>
</div>
);
};
export default DashboardLineChartSkeleton;
@@ -28,7 +28,7 @@ const ExpenseDetail: React.FC<ExpenseDetailProps> = ({ initialValues }) => {
if (
initialValues?.latest_approval &&
initialValues?.latest_approval.step_number >= 4 &&
initialValues?.latest_approval.step_number >= 5 &&
initialValues.latest_approval.action !== 'REJECTED'
) {
validTabs.push({
@@ -4,6 +4,7 @@ import toast from 'react-hot-toast';
import Link from 'next/link';
import { Icon } from '@iconify/react';
import Button from '@/components/Button';
import RequirePermission from '@/components/helper/RequirePermission';
import Card from '@/components/Card';
import DropFileInput from '@/components/input/DropFileInput';
@@ -15,7 +16,7 @@ import {
} from '@/components/pages/expense/form/ExpenseRequestForm.schema';
import { ExpenseApi } from '@/services/api/expense';
import { isResponseSuccess } from '@/lib/api-helper';
import { ACCEPTED_FILE_TYPE } from '@/config/constant';
import { ACCEPTED_FILE_TYPE, S3_PUBLIC_BASE_URL } from '@/config/constant';
interface ExpenseRealizationContentProps {
initialValues?: Expense;
@@ -47,6 +48,13 @@ const ExpenseRealizationContent = ({
const realizationDocumentsChangeHandler = (val: File[]) => {
formik.setFieldTouched('documents', true);
const invalidFiles = val.filter((file) => file.size > 5 * 1024 * 1024);
if (invalidFiles.length > 0) {
toast.error('Ukuran dokumen maksimal 5 MB!');
return;
}
formik.setFieldValue('documents', val);
};
@@ -62,16 +70,17 @@ const ExpenseRealizationContent = ({
<div>
<div className='w-full max-w-5xl mx-auto flex flex-col sm:flex-row justify-end gap-2'>
<div className='w-full sm:w-fit sm:ml-2 flex flex-row gap-2 items-center'>
{/* TODO: apply RBAC */}
<Button
type='button'
color='warning'
href={`/expense/realization/edit/?expenseId=${initialValues?.id}`}
className='px-4 grow sm:grow-0'
>
<Icon icon='mdi:pencil-outline' width={24} height={24} />
Edit Realisasi
</Button>
<RequirePermission permissions='lti.expense.update.realization'>
<Button
type='button'
color='warning'
href={`/expense/realization/edit/?expenseId=${initialValues?.id}`}
className='px-4 grow sm:grow-0'
>
<Icon icon='mdi:pencil-outline' width={24} height={24} />
Edit Realisasi
</Button>
</RequirePermission>
</div>
</div>
@@ -101,59 +110,69 @@ const ExpenseRealizationContent = ({
initialValues?.realization_docs.length > 0 && (
<ul className='list-disc'>
{initialValues?.realization_docs.map(
(realizationDocument, realizationDocumentIdx) => (
<li key={realizationDocumentIdx}>
<Link
href={realizationDocument.path}
target='_blank'
rel='noopener noreferrer'
className='text-blue-500 underline'
>
{realizationDocument.path}{' '}
<Icon
icon='cuida:open-in-new-tab-outline'
width={12}
height={12}
className='inline'
/>
</Link>
</li>
)
(realizationDocument, realizationDocumentIdx) => {
const path = realizationDocument.path.startsWith(
'/'
)
? realizationDocument.path.slice(1)
: realizationDocument.path;
const documentUrl = `${S3_PUBLIC_BASE_URL}/${path}`;
return (
<li key={realizationDocumentIdx}>
<Link
href={documentUrl}
target='_blank'
rel='noopener noreferrer'
className='text-blue-500 underline'
>
{realizationDocument.path}{' '}
<Icon
icon='cuida:open-in-new-tab-outline'
width={12}
height={12}
className='inline'
/>
</Link>
</li>
);
}
)}
</ul>
)}
</div>
<div className='flex flex-col gap-2'>
<DropFileInput
name='documents'
values={formik.values.documents}
onChange={realizationDocumentsChangeHandler}
onDelete={realizationDocumentsDeleteHandler}
accept={{
...ACCEPTED_FILE_TYPE.PDF,
...ACCEPTED_FILE_TYPE.IMAGE,
}}
maxFiles={10}
className={{
wrapper: 'mt-2',
inputWrapper: 'flex items-center',
}}
/>
<RequirePermission permissions='lti.expense.document.realization'>
<div className='flex flex-col gap-2'>
<DropFileInput
name='documents'
values={formik.values.documents}
onChange={realizationDocumentsChangeHandler}
onDelete={realizationDocumentsDeleteHandler}
accept={{
...ACCEPTED_FILE_TYPE.PDF,
...ACCEPTED_FILE_TYPE.IMAGE,
}}
maxFiles={10}
className={{
wrapper: 'mt-2',
inputWrapper: 'flex items-center',
}}
/>
{formik.values.documents &&
formik.values.documents.length > 0 && (
<Button
onClick={formik.submitForm}
disabled={formik.isSubmitting}
isLoading={formik.isSubmitting}
className='w-fit self-end'
>
<Icon icon='ic:round-plus' width={24} height={24} />
Tambah
</Button>
)}
</div>
{formik.values.documents &&
formik.values.documents.length > 0 && (
<Button
onClick={formik.submitForm}
disabled={formik.isSubmitting}
isLoading={formik.isSubmitting}
className='w-fit self-end'
>
<Icon icon='ic:round-plus' width={24} height={24} />
Tambah
</Button>
)}
</div>
</RequirePermission>
</td>
</tr>
</tbody>
@@ -207,7 +226,7 @@ const ExpenseRealizationContent = ({
let expenseGrandTotal = 0;
kandangExpense.pengajuans?.forEach(
(item) => (expenseGrandTotal += item.price)
(item) => (expenseGrandTotal += item.qty * item.price)
);
return (
@@ -269,7 +288,7 @@ const ExpenseRealizationContent = ({
let expenseGrandTotal = 0;
kandangExpense.realisasi?.forEach(
(item) => (expenseGrandTotal += item.price)
(item) => (expenseGrandTotal += item.qty * item.price)
);
return (
@@ -19,6 +19,7 @@ import { useModal } from '@/components/Modal';
import ConfirmationModal from '@/components/modal/ConfirmationModal';
import ConfirmationModalWithNotes from '@/components/modal/ConfirmationModalWithNotes';
import ExpensePDFPreviewButton from '@/components/pages/expense//pdf/ExpensePDFButton';
import RequirePermission from '@/components/helper/RequirePermission';
import { Expense } from '@/types/api/expense';
import { formatCurrency, formatDate } from '@/lib/helper';
@@ -26,7 +27,7 @@ import {
UploadRequestDocumentsFormSchema,
UploadRequestDocumentsFormValues,
} from '@/components/pages/expense/form/ExpenseRequestForm.schema';
import { ACCEPTED_FILE_TYPE } from '@/config/constant';
import { ACCEPTED_FILE_TYPE, S3_PUBLIC_BASE_URL } from '@/config/constant';
import { ExpenseApi } from '@/services/api/expense';
import { isResponseSuccess } from '@/lib/api-helper';
import { EXPENSE_REQUEST_APPROVAL_LINE } from '@/config/approval-line';
@@ -58,34 +59,40 @@ const ExpenseRequestContent = ({
const isLatestApprovalRejectedOrDone =
isLatestApprovalRejected ||
initialValues?.latest_approval.step_number === 5;
initialValues?.latest_approval.step_number === 6;
const isCurrentApprovalOnManager =
const isCurrentApprovalOnHeadArea =
!isLatestApprovalRejected &&
initialValues?.latest_approval.step_number === 1;
const isCurrentApprovalOnFinance =
const isCurrentApprovalOnUnitVicePresident =
!isLatestApprovalRejected &&
initialValues?.latest_approval.step_number === 2;
const isCurrentApprovalOnFinance =
!isLatestApprovalRejected &&
initialValues?.latest_approval.step_number === 3;
const isCurrentApprovalOnRealization =
!isLatestApprovalRejected &&
initialValues?.latest_approval.step_number === 4;
initialValues?.latest_approval.step_number === 5;
const showEditButton =
initialValues?.latest_approval.step_number !== 5 &&
initialValues?.latest_approval.step_number !== 6 &&
(initialValues?.latest_approval.step_number === 1 ||
initialValues?.latest_approval.step_number === 2 ||
initialValues?.latest_approval.step_number === 3);
initialValues?.latest_approval.step_number === 3 ||
initialValues?.latest_approval.step_number === 4);
const showRejectButton =
!isLatestApprovalRejected &&
(initialValues?.latest_approval.step_number === 1 ||
initialValues?.latest_approval.step_number === 2);
initialValues?.latest_approval.step_number === 2 ||
initialValues?.latest_approval.step_number === 3);
const isExpenseCanBeRealized =
!isLatestApprovalRejected &&
initialValues?.latest_approval.step_number === 3;
initialValues?.latest_approval.step_number === 4;
// Modal hooks
const deleteModal = useModal();
@@ -139,17 +146,17 @@ const ExpenseRequestContent = ({
const confirmationModalDeleteClickHandler = async () => {
setIsDeleteLoading(true);
try {
await ExpenseApi.delete(initialValues?.id as number);
const deleteResponse = await ExpenseApi.delete(initialValues?.id as number);
if (isResponseSuccess(deleteResponse)) {
toast.success('Berhasil menghapus data biaya operasional!');
router.push('/expense');
} catch (error) {
} else {
toast.error('Gagal menghapus data biaya operasional!');
} finally {
deleteModal.closeModal();
setIsDeleteLoading(false);
}
deleteModal.closeModal();
setIsDeleteLoading(false);
};
const confirmationModalCompleteClickHandler = async () => {
@@ -173,8 +180,15 @@ const ExpenseRequestContent = ({
let approveResponse: BaseApiResponse<Expense> | undefined = undefined;
if (isCurrentApprovalOnManager) {
approveResponse = await ExpenseApi.approveManager(
if (isCurrentApprovalOnHeadArea) {
approveResponse = await ExpenseApi.approveHeadArea(
initialValues.id,
notes
);
}
if (isCurrentApprovalOnUnitVicePresident) {
approveResponse = await ExpenseApi.approveUnitVicePresident(
initialValues.id,
notes
);
@@ -206,8 +220,15 @@ const ExpenseRequestContent = ({
let rejectResponse: BaseApiResponse<Expense> | undefined = undefined;
if (isCurrentApprovalOnManager) {
rejectResponse = await ExpenseApi.rejectManager(initialValues.id, notes);
if (isCurrentApprovalOnHeadArea) {
rejectResponse = await ExpenseApi.rejectHeadArea(initialValues.id, notes);
}
if (isCurrentApprovalOnUnitVicePresident) {
rejectResponse = await ExpenseApi.rejectUnitVicePresident(
initialValues.id,
notes
);
}
if (isCurrentApprovalOnFinance) {
@@ -230,6 +251,13 @@ const ExpenseRequestContent = ({
const requestDocumentsChangeHandler = (val: File[]) => {
formik.setFieldTouched('documents', true);
const invalidFiles = val.filter((file) => file.size > 5 * 1024 * 1024);
if (invalidFiles.length > 0) {
toast.error('Ukuran dokumen maksimal 5 MB!');
return;
}
formik.setFieldValue('documents', val);
};
@@ -254,101 +282,135 @@ const ExpenseRequestContent = ({
{/* TODO: apply RBAC */}
<div className='w-full max-w-5xl mx-auto flex flex-col sm:flex-row justify-end gap-2'>
{isCurrentApprovalOnManager && (
<Button
variant='outline'
color='info'
onClick={approveClickHandler}
className='w-full sm:w-fit'
>
<Icon icon='lucide-lab:farm' width={24} height={24} />
Approve Manager
</Button>
{isCurrentApprovalOnHeadArea && (
<RequirePermission permissions='lti.expense.approve.head_area'>
<Button
variant='outline'
color='info'
onClick={approveClickHandler}
className='w-full sm:w-fit'
>
<Icon icon='lucide-lab:farm' width={24} height={24} />
Approve Head Area
</Button>
</RequirePermission>
)}
{isCurrentApprovalOnUnitVicePresident && (
<RequirePermission permissions='lti.expense.approve.unit_vice_president'>
<Button
variant='outline'
color='success'
onClick={approveClickHandler}
className='w-full sm:w-fit'
>
<Icon icon='tdesign:money' width={24} height={24} />
Approve Unit Vice President
</Button>
</RequirePermission>
)}
{isCurrentApprovalOnFinance && (
<Button
variant='outline'
color='success'
onClick={approveClickHandler}
className='w-full sm:w-fit'
>
<Icon icon='tdesign:money' width={24} height={24} />
Approve Finance
</Button>
<RequirePermission permissions='lti.expense.approve.finance'>
<Button
variant='outline'
color='success'
onClick={approveClickHandler}
className='w-full sm:w-fit'
>
<Icon icon='tdesign:money' width={24} height={24} />
Approve Finance
</Button>
</RequirePermission>
)}
{isCurrentApprovalOnRealization && (
<Button
variant='outline'
color='success'
onClick={completeExpenseClickHandler}
className='w-full sm:w-fit'
>
<Icon
icon='material-symbols:done-all-rounded'
width={24}
height={24}
/>
Selesai
</Button>
<RequirePermission permissions='lti.expense.complete.expense'>
<Button
variant='outline'
color='success'
onClick={completeExpenseClickHandler}
className='w-full sm:w-fit'
>
<Icon
icon='material-symbols:done-all-rounded'
width={24}
height={24}
/>
Selesai
</Button>
</RequirePermission>
)}
{showRejectButton && (
<Button
variant='outline'
color='error'
onClick={rejectClickHandler}
className='w-full:w-fit'
<RequirePermission
permissions={[
'lti.expense.approve.head_area',
'lti.expense.approve.unit_vice_president',
'lti.expense.approve.finance',
]}
>
<Icon icon='material-symbols:close' width={24} height={24} />
Reject
</Button>
<Button
variant='outline'
color='error'
onClick={rejectClickHandler}
className='w-full:w-fit'
>
<Icon icon='material-symbols:close' width={24} height={24} />
Reject
</Button>
</RequirePermission>
)}
{isExpenseCanBeRealized && (
<Button
variant='outline'
color='info'
href={`/expense/realization/?expenseId=${initialValues?.id}`}
className='w-full sm:w-fit'
>
<Icon
icon='material-symbols:money-bag-rounded'
width={24}
height={24}
/>
Realisasi
</Button>
<RequirePermission permissions='lti.expense.create.realization'>
<Button
variant='outline'
color='info'
href={`/expense/realization/?expenseId=${initialValues?.id}`}
className='w-full sm:w-fit'
>
<Icon
icon='material-symbols:money-bag-rounded'
width={24}
height={24}
/>
Realisasi
</Button>
</RequirePermission>
)}
<div className='w-full sm:w-fit sm:ml-2 flex flex-row gap-2 items-center'>
{showEditButton && (
<Button
type='button'
color='warning'
href={`/expense/detail/edit/?expenseId=${initialValues?.id}`}
className='px-4 grow sm:grow-0'
>
<Icon icon='mdi:pencil-outline' width={24} height={24} />
Edit
</Button>
<RequirePermission permissions='lti.expense.update'>
<Button
type='button'
color='warning'
href={`/expense/detail/edit/?expenseId=${initialValues?.id}`}
className='px-4 grow sm:grow-0'
>
<Icon icon='mdi:pencil-outline' width={24} height={24} />
Edit
</Button>
</RequirePermission>
)}
<Button
type='button'
color='error'
onClick={deleteExpenseClickHandler}
className='px-4 grow sm:grow-0'
>
<Icon
icon='material-symbols:delete-outline-rounded'
width={24}
height={24}
className='justify-start text-sm'
/>
Delete
</Button>
<RequirePermission permissions='lti.expense.delete'>
<Button
type='button'
color='error'
onClick={deleteExpenseClickHandler}
className='px-4 grow sm:grow-0'
>
<Icon
icon='material-symbols:delete-outline-rounded'
width={24}
height={24}
className='justify-start text-sm'
/>
Delete
</Button>
</RequirePermission>
</div>
</div>
@@ -388,9 +450,13 @@ const ExpenseRequestContent = ({
<th>Kandang</th>
<th>:</th>
<td>
{initialValues?.kandangs
.map((item) => item.name)
.join(', ')}
{initialValues?.kandangs &&
initialValues?.kandangs.some((k) => k.name)
? initialValues?.kandangs
.filter((item) => item.name)
.map((item) => item.name)
.join(', ')
: '-'}
</td>
</tr>
<tr>
@@ -428,7 +494,14 @@ const ExpenseRequestContent = ({
<tr>
<th>Nominal Biaya</th>
<th>:</th>
<td>{formatCurrency(initialValues?.grand_total ?? 0)}</td>
<td>
{formatCurrency(
initialValues?.latest_approval.step_number === 5 ||
initialValues?.latest_approval.step_number === 6
? (initialValues?.total_realisasi ?? 0)
: (initialValues?.total_pengajuan ?? 0)
)}
</td>
</tr>
<tr>
<th>Status Pencairan</th>
@@ -462,59 +535,73 @@ const ExpenseRequestContent = ({
initialValues?.documents.length > 0 && (
<ul className='list-disc'>
{initialValues?.documents.map(
(requestDocument, requestDocumentIdx) => (
<li key={requestDocumentIdx}>
<Link
href={requestDocument.path}
target='_blank'
rel='noopener noreferrer'
className='text-blue-500 underline'
>
{requestDocument.path}{' '}
<Icon
icon='cuida:open-in-new-tab-outline'
width={12}
height={12}
className='inline'
/>
</Link>
</li>
)
(requestDocument, requestDocumentIdx) => {
const path = requestDocument.path.startsWith(
'/'
)
? requestDocument.path.slice(1)
: requestDocument.path;
const documentUrl = `${S3_PUBLIC_BASE_URL}/${path}`;
return (
<li key={requestDocumentIdx}>
<Link
href={documentUrl}
target='_blank'
rel='noopener noreferrer'
className='text-blue-500 underline'
>
{requestDocument.path}{' '}
<Icon
icon='cuida:open-in-new-tab-outline'
width={12}
height={12}
className='inline'
/>
</Link>
</li>
);
}
)}
</ul>
)}
</div>
<div className='flex flex-col gap-2'>
<DropFileInput
name='documents'
values={formik.values.documents}
onChange={requestDocumentsChangeHandler}
onDelete={requestDocumentsDeleteHandler}
accept={{
...ACCEPTED_FILE_TYPE.PDF,
...ACCEPTED_FILE_TYPE.IMAGE,
}}
maxFiles={10}
className={{
wrapper: 'mt-2',
inputWrapper: 'flex items-center',
}}
/>
<RequirePermission permissions='lti.expense.document'>
<div className='flex flex-col gap-2'>
<DropFileInput
name='documents'
values={formik.values.documents}
onChange={requestDocumentsChangeHandler}
onDelete={requestDocumentsDeleteHandler}
accept={{
...ACCEPTED_FILE_TYPE.PDF,
...ACCEPTED_FILE_TYPE.IMAGE,
}}
maxFiles={10}
className={{
wrapper: 'mt-2',
inputWrapper: 'flex items-center',
}}
/>
{formik.values.documents &&
formik.values.documents.length > 0 && (
<Button
onClick={formik.submitForm}
disabled={formik.isSubmitting}
isLoading={formik.isSubmitting}
className='w-fit self-end'
>
<Icon icon='ic:round-plus' width={24} height={24} />
Tambah
</Button>
)}
</div>
{formik.values.documents &&
formik.values.documents.length > 0 && (
<Button
onClick={formik.submitForm}
disabled={formik.isSubmitting}
isLoading={formik.isSubmitting}
className='w-fit self-end'
>
<Icon
icon='ic:round-plus'
width={24}
height={24}
/>
Tambah
</Button>
)}
</div>
</RequirePermission>
</td>
</tr>
</tbody>
@@ -532,7 +619,7 @@ const ExpenseRequestContent = ({
let expenseGrandTotal = 0;
kandangExpense.pengajuans?.forEach(
(item) => (expenseGrandTotal += item.price)
(item) => (expenseGrandTotal += item.qty * item.price)
);
return (
@@ -547,7 +634,9 @@ const ExpenseRequestContent = ({
colSpan={5}
className='font-bold text-center text-base-content text-lg'
>
Biaya {kandangExpense.name}
{kandangExpense.kandang_id && kandangExpense.name
? `Biaya ${kandangExpense.name}`
: `Biaya ${initialValues?.location.name || 'Umum'}`}
</th>
</tr>
<tr>
@@ -21,7 +21,7 @@ const ExpenseStatusBadge = ({ approval }: ExpenseStatusBadgeProps) => {
switch (latestApprovalStepNumber) {
case 1:
expenseStatusPillBadgeColor = 'yellow';
expenseStatusPillBadgeColor = 'gray';
break;
case 2:
@@ -33,12 +33,16 @@ const ExpenseStatusBadge = ({ approval }: ExpenseStatusBadgeProps) => {
break;
case 4:
expenseStatusPillBadgeColor = 'red';
expenseStatusPillBadgeColor = 'yellow';
break;
case 5:
expenseStatusPillBadgeColor = 'green';
break;
case 6:
expenseStatusPillBadgeColor = 'green';
break;
}
if (isLatestApprovalRejected) {
+183 -104
View File
@@ -28,6 +28,7 @@ import ExpenseStatusBadge from '@/components/pages/expense/ExpenseStatusBadge';
import CheckboxInput from '@/components/input/CheckboxInput';
import ConfirmationModalWithNotes from '@/components/modal/ConfirmationModalWithNotes';
import DateInput from '@/components/input/DateInput';
import RequirePermission from '@/components/helper/RequirePermission';
import { Expense } from '@/types/api/expense';
import { ExpenseApi } from '@/services/api/expense';
@@ -54,71 +55,84 @@ const RowOptionsMenu = ({
deleteClickHandler: () => void;
}) => {
const showEditButton =
props.row.original.latest_approval.step_number !== 5 &&
props.row.original.latest_approval.step_number !== 6 &&
(props.row.original.latest_approval.step_number === 1 ||
props.row.original.latest_approval.step_number === 2 ||
props.row.original.latest_approval.step_number === 3);
props.row.original.latest_approval.step_number === 3 ||
props.row.original.latest_approval.step_number === 4);
// TODO: apply RBAC
const showRealizationButton =
props.row.original.latest_approval.action !== 'REJECTED' &&
props.row.original.latest_approval.step_number === 3;
props.row.original.latest_approval.step_number === 4;
return (
<RowOptionsMenuWrapper type={type}>
<div className='w-full max-h-40 overflow-auto flex flex-col gap-1'>
<Button
href={`/expense/detail/?expenseId=${props.row.original.id}`}
variant='ghost'
color='primary'
className='justify-start text-sm'
>
<Icon icon='mdi:eye-outline' width={16} height={16} />
Detail
</Button>
{showEditButton && (
<RequirePermission permissions='lti.expense.detail'>
<Button
href={`/expense/detail/edit/?expenseId=${props.row.original.id}`}
href={`/expense/detail/?expenseId=${props.row.original.id}`}
variant='ghost'
color='warning'
color='primary'
className='justify-start text-sm'
>
<Icon icon='material-symbols:edit-outline' width={16} height={16} />
Edit
<Icon icon='mdi:eye-outline' width={16} height={16} />
Detail
</Button>
</RequirePermission>
{showEditButton && (
<RequirePermission permissions='lti.expense.update'>
<Button
href={`/expense/detail/edit/?expenseId=${props.row.original.id}`}
variant='ghost'
color='warning'
className='justify-start text-sm'
>
<Icon
icon='material-symbols:edit-outline'
width={16}
height={16}
/>
Edit
</Button>
</RequirePermission>
)}
{showRealizationButton && (
<Button
href={`/expense/realization/?expenseId=${props.row.original.id}`}
variant='ghost'
color='info'
className='justify-start text-sm text-info focus-visible:text-info-content hover:text-info-content'
>
<Icon
icon='material-symbols:money-bag-rounded'
width={16}
height={16}
/>
Realisasi
</Button>
<RequirePermission permissions='lti.expense.create.realization'>
<Button
href={`/expense/realization/?expenseId=${props.row.original.id}`}
variant='ghost'
color='info'
className='justify-start text-sm text-info focus-visible:text-info-content hover:text-info-content'
>
<Icon
icon='material-symbols:money-bag-rounded'
width={16}
height={16}
/>
Realisasi
</Button>
</RequirePermission>
)}
<Button
onClick={deleteClickHandler}
variant='ghost'
color='error'
className='justify-start text-sm text-error focus-visible:text-error-content hover:text-error-content'
>
<Icon
icon='material-symbols:delete-outline-rounded'
width={16}
height={16}
className='justify-start text-sm'
/>
Delete
</Button>
<RequirePermission permissions='lti.expense.delete'>
<Button
onClick={deleteClickHandler}
variant='ghost'
color='error'
className='justify-start text-sm text-error focus-visible:text-error-content hover:text-error-content'
>
<Icon
icon='material-symbols:delete-outline-rounded'
width={16}
height={16}
className='justify-start text-sm'
/>
Delete
</Button>
</RequirePermission>
</div>
</RowOptionsMenuWrapper>
);
@@ -180,7 +194,7 @@ const ExpensesTable = () => {
parseInt(item)
);
const isAllSelectedRowLatestApprovalOnManager = useMemo(() => {
const isAllSelectedRowLatestApprovalOnHeadArea = useMemo(() => {
return selectedRowIds.every((rowId) => {
if (!isResponseSuccess(expenses)) return false;
@@ -189,11 +203,28 @@ const ExpensesTable = () => {
const isLatestApprovalRejected =
expenseItem?.latest_approval.action === 'REJECTED';
const isCurrentApprovalOnManager =
const isCurrentApprovalOnHeadArea =
!isLatestApprovalRejected &&
expenseItem?.latest_approval.step_number === 1;
return isCurrentApprovalOnManager;
return isCurrentApprovalOnHeadArea;
});
}, [expenses, selectedRowIds]);
const isAllSelectedRowLatestApprovalOnUnitVicePresident = useMemo(() => {
return selectedRowIds.every((rowId) => {
if (!isResponseSuccess(expenses)) return false;
const expenseItem = expenses.data.find((item) => item.id === rowId);
const isLatestApprovalRejected =
expenseItem?.latest_approval.action === 'REJECTED';
const isCurrentApprovalOnUnitVicePresident =
!isLatestApprovalRejected &&
expenseItem?.latest_approval.step_number === 2;
return isCurrentApprovalOnUnitVicePresident;
});
}, [expenses, selectedRowIds]);
@@ -208,7 +239,7 @@ const ExpensesTable = () => {
const isCurrentApprovalOnFinance =
!isLatestApprovalRejected &&
expenseItem?.latest_approval.step_number === 2;
expenseItem?.latest_approval.step_number === 3;
return isCurrentApprovalOnFinance;
});
@@ -225,7 +256,7 @@ const ExpensesTable = () => {
const isCurrentApprovalOnRealization =
!isLatestApprovalRejected &&
expenseItem?.latest_approval.step_number === 4;
expenseItem?.latest_approval.step_number === 5;
return isCurrentApprovalOnRealization;
});
@@ -384,7 +415,7 @@ const ExpensesTable = () => {
) => {
return (
row.original.latest_approval.action !== 'REJECTED' &&
row.original.latest_approval.step_number !== 5
row.original.latest_approval.step_number !== 6
);
};
@@ -407,11 +438,19 @@ const ExpensesTable = () => {
const confirmationModalDeleteClickHandler = async () => {
setIsDeleteLoading(true);
await ExpenseApi.delete(selectedExpense?.id as number);
refreshExpenses();
const deleteResponse = await ExpenseApi.delete(
selectedExpense?.id as number
);
if (isResponseSuccess(deleteResponse)) {
refreshExpenses();
deleteModal.closeModal();
toast.success('Berhasil menghapus biaya operasional!');
} else {
deleteModal.closeModal();
toast.error('Gagal menghapus biaya operasional!');
}
deleteModal.closeModal();
toast.success('Berhasil menghapus biaya operasional!');
setIsDeleteLoading(false);
};
@@ -420,8 +459,13 @@ const ExpensesTable = () => {
let bulkApproveResponse: BaseApiResponse<Expense> | undefined = undefined;
if (isAllSelectedRowLatestApprovalOnManager) {
bulkApproveResponse = await ExpenseApi.bulkApproveManager(
if (isAllSelectedRowLatestApprovalOnHeadArea) {
bulkApproveResponse = await ExpenseApi.bulkApproveHeadArea(
selectedRowIds,
notes
);
} else if (isAllSelectedRowLatestApprovalOnUnitVicePresident) {
bulkApproveResponse = await ExpenseApi.bulkApproveUnitVicePresident(
selectedRowIds,
notes
);
@@ -457,8 +501,13 @@ const ExpensesTable = () => {
let bulkRejectResponse: BaseApiResponse<Expense> | undefined = undefined;
if (isAllSelectedRowLatestApprovalOnManager) {
bulkRejectResponse = await ExpenseApi.bulkRejectManager(
if (isAllSelectedRowLatestApprovalOnHeadArea) {
bulkRejectResponse = await ExpenseApi.bulkRejectHeadArea(
selectedRowIds,
notes
);
} else if (isAllSelectedRowLatestApprovalOnUnitVicePresident) {
bulkRejectResponse = await ExpenseApi.bulkRejectUnitVicePresident(
selectedRowIds,
notes
);
@@ -559,57 +608,87 @@ const ExpensesTable = () => {
<div className='flex flex-col gap-2 mb-4'>
<div className='w-full flex flex-col sm:flex-row justify-between items-end sm:items-center gap-4'>
<div className='w-full sm:w-fit flex flex-col sm:flex-row self-start gap-2'>
<Button
href='/expense/add'
variant='outline'
color='primary'
className='w-full sm:w-fit'
>
<Icon icon='ic:round-plus' width={24} height={24} />
Tambah
</Button>
<RequirePermission permissions='lti.expense.create'>
<Button
href='/expense/add'
variant='outline'
color='primary'
className='w-full sm:w-fit'
>
<Icon icon='ic:round-plus' width={24} height={24} />
Tambah
</Button>
</RequirePermission>
{selectedRowIds.length > 0 && (
<>
<Button
variant='outline'
color='info'
onClick={bulkApproveClickHandler}
disabled={!isAllSelectedRowLatestApprovalOnManager}
className='w-full sm:w-fit'
>
<Icon icon='lucide-lab:farm' width={24} height={24} />
Approve Manager
</Button>
<RequirePermission permissions='lti.expense.approve.head_area'>
<Button
variant='outline'
color='info'
onClick={bulkApproveClickHandler}
disabled={!isAllSelectedRowLatestApprovalOnHeadArea}
className='w-full sm:w-fit'
>
<Icon icon='lucide-lab:farm' width={24} height={24} />
Approve Head Area
</Button>
</RequirePermission>
<Button
variant='outline'
color='success'
onClick={bulkApproveClickHandler}
disabled={!isAllSelectedRowLatestApprovalOnFinance}
className='w-full sm:w-fit'
>
<Icon icon='tdesign:money' width={24} height={24} />
Approve Finance
</Button>
<RequirePermission permissions='lti.expense.approve.unit_vice_president'>
<Button
variant='outline'
color='success'
onClick={bulkApproveClickHandler}
disabled={
!isAllSelectedRowLatestApprovalOnUnitVicePresident
}
className='w-full sm:w-fit'
>
<Icon icon='tdesign:money' width={24} height={24} />
Approve Unit Vice President
</Button>
</RequirePermission>
<Button
variant='outline'
color='error'
onClick={bulkRejectClickHandler}
disabled={
!isAllSelectedRowLatestApprovalOnManager &&
!isAllSelectedRowLatestApprovalOnFinance
}
className='w-full sm:w-fit'
<RequirePermission permissions='lti.expense.approve.finance'>
<Button
variant='outline'
color='success'
onClick={bulkApproveClickHandler}
disabled={!isAllSelectedRowLatestApprovalOnFinance}
className='w-full sm:w-fit'
>
<Icon icon='tdesign:money' width={24} height={24} />
Approve Finance
</Button>
</RequirePermission>
<RequirePermission
permissions={[
'lti.expense.approve.head_area',
'lti.expense.approve.unit_vice_president',
'lti.expense.approve.finance',
]}
>
<Icon
icon='material-symbols:close'
width={24}
height={24}
/>
Reject
</Button>
<Button
variant='outline'
color='error'
onClick={bulkRejectClickHandler}
disabled={
!isAllSelectedRowLatestApprovalOnHeadArea &&
!isAllSelectedRowLatestApprovalOnUnitVicePresident &&
!isAllSelectedRowLatestApprovalOnFinance
}
className='w-full sm:w-fit'
>
<Icon
icon='material-symbols:close'
width={24}
height={24}
/>
Reject
</Button>
</RequirePermission>
</>
)}
</div>
@@ -9,7 +9,7 @@ interface RealizationStatusBadgeProps {
const RealizationStatusBadge = ({ approval }: RealizationStatusBadgeProps) => {
const isLatestApprovalRejected = approval?.action === 'REJECTED';
const isExpenseRealized = approval?.step_number && approval.step_number >= 4;
const isExpenseRealized = approval?.step_number && approval.step_number >= 5;
const realizationStatus = isExpenseRealized
? 'Sudah Realisasi'
@@ -20,10 +20,10 @@ interface ExpenseKandangsTableProps {
locationId?: number;
type: 'add' | 'edit' | 'detail';
selectedKandangs: {
id: number;
name: string;
id?: number;
name?: string;
}[];
onChange: (kandangs: { id: number; name: string }[]) => void;
onChange: (kandangs: { id?: number; name?: string }[]) => void;
className?: {
wrapper?: string;
};
@@ -67,7 +67,11 @@ const ExpenseKandangsTable = ({
);
const [sorting, setSorting] = useState<SortingState>([]);
const [rowSelection, setRowSelection] = useState<Record<string, boolean>>(
convertRowSelectionArrToObj(selectedKandangs.map((item) => item.id))
convertRowSelectionArrToObj(
selectedKandangs
.map((item) => item.id)
.filter((id): id is number => id !== undefined)
)
);
const kandangsColumns: ColumnDef<Kandang>[] = [
@@ -1,6 +1,7 @@
import * as Yup from 'yup';
import { Expense } from '@/types/api/expense';
import { formatDate } from '@/lib/helper';
import { S3_PUBLIC_BASE_URL } from '@/config/constant';
type ExpenseRealizationFormSchemaType = {
category?: {
@@ -12,7 +13,7 @@ type ExpenseRealizationFormSchemaType = {
label: string;
};
realization_date?: string;
kandangs?: { id: number; name: string }[];
kandangs?: { id?: number; name?: string }[];
supplier?: {
value: number;
label: string;
@@ -20,7 +21,7 @@ type ExpenseRealizationFormSchemaType = {
existing_documents?: { name: string; url: string }[];
documents?: File[];
realizations: {
kandang_id: number;
kandang_id?: number;
cost_items: {
nonstock?: {
value: number;
@@ -49,12 +50,11 @@ export const ExpenseRealizationFormSchema: Yup.ObjectSchema<ExpenseRealizationFo
kandangs: Yup.array()
.of(
Yup.object({
id: Yup.number().required('Kandang wajib dipilih!'),
name: Yup.string().required('Kandang wajib dipilih!'),
id: Yup.number().optional(),
name: Yup.string().optional(),
})
)
.min(1, 'Kandang wajib dipilih!')
.required('Kandang wajib dipilih!'),
.optional(),
supplier: Yup.object({
value: Yup.number().min(1).required(),
@@ -73,7 +73,7 @@ export const ExpenseRealizationFormSchema: Yup.ObjectSchema<ExpenseRealizationFo
realizations: Yup.array()
.of(
Yup.object({
kandang_id: Yup.number().min(1, 'Wajib memilih kandang!').required(),
kandang_id: Yup.number().min(1, 'Wajib memilih kandang!').optional(),
cost_items: Yup.array()
.of(
Yup.object({
@@ -86,12 +86,12 @@ export const ExpenseRealizationFormSchema: Yup.ObjectSchema<ExpenseRealizationFo
notes: Yup.string(),
})
)
.min(1, 'Kandang harus memiliki setidaknya 1 biaya!')
.required('Biaya kandang wajib diisi!'),
.min(1, 'Harus memiliki setidaknya 1 biaya!')
.required('Biaya wajib diisi!'),
})
)
.min(1, 'Biaya kandang wajib diisi!')
.required('Biaya kandang wajib diisi!'),
.min(1, 'Biaya wajib diisi!')
.required('Biaya wajib diisi!'),
});
export const UpdateExpenseRealizationFormSchema = ExpenseRealizationFormSchema;
@@ -139,10 +139,13 @@ export const getExpenseRealizationFormInitialValues = (
label: initialValues.supplier.name,
}
: undefined,
existing_documents: initialValues?.realization_docs?.map((doc) => ({
name: doc.path,
url: doc.path,
})),
existing_documents: initialValues?.realization_docs?.map((doc) => {
const path = doc.path.startsWith('/') ? doc.path.slice(1) : doc.path;
return {
name: doc.path,
url: `${S3_PUBLIC_BASE_URL}/${path}`,
};
}),
documents: [],
realizations: initialValues?.kandangs
? initialValues.kandangs.map((kandangExpense) => {
@@ -16,6 +16,7 @@ import DateInput from '@/components/input/DateInput';
import DropFileInput from '@/components/input/DropFileInput';
import ExpenseKandangsTable from '@/components/pages/expense/form/ExpenseKandangsTable';
import ExpenseRealizationKandangDetailExpense from '@/components/pages/expense/form/ExpenseRealizationKandangDetailExpense';
import RequirePermission from '@/components/helper/RequirePermission';
import {
CreateExpenseRealizationPayload,
@@ -149,25 +150,10 @@ const ExpenseRealizationForm = ({
formik.setFieldValue('location', val);
formik.setFieldValue('kandangs', []);
formik.setFieldValue('realizations', []);
};
const kandangsChangeHandler = (kandangs: { id: number; name: string }[]) => {
formik.setFieldTouched('kandangs', true);
formik.setFieldValue('kandangs', kandangs);
const newRealizations = [...(formik.values.realizations ?? [])];
// add new realizations
kandangs.forEach((kandangItem) => {
const isKandangExistInRealization = newRealizations.find(
(realizationItem) => realizationItem.kandang_id === kandangItem.id
);
if (isKandangExistInRealization) return;
newRealizations.push({
kandang_id: kandangItem.id,
// Auto-create realization item for location (without kandang)
formik.setFieldValue('realizations', [
{
cost_items: [
{
nonstock: undefined,
@@ -176,25 +162,57 @@ const ExpenseRealizationForm = ({
notes: '',
},
],
},
]);
};
const kandangsChangeHandler = (
kandangs: { id?: number; name?: string }[]
) => {
formik.setFieldTouched('kandangs', true);
formik.setFieldValue('kandangs', kandangs);
// If no kandangs selected, create realization item for location
if (kandangs.length === 0) {
formik.setFieldValue('realizations', [
{
cost_items: [
{
nonstock: undefined,
quantity: undefined,
price: undefined,
notes: '',
},
],
},
]);
return;
}
// Start with empty array when kandangs are selected
const newRealizations: typeof formik.values.realizations = [];
// add new realizations for each kandang
kandangs.forEach((kandangItem) => {
if (!kandangItem.id) return;
const existingRealization = formik.values.realizations?.find(
(realizationItem) => realizationItem.kandang_id === kandangItem.id
);
newRealizations.push({
kandang_id: kandangItem.id,
cost_items: existingRealization?.cost_items || [
{
nonstock: undefined,
quantity: undefined,
price: undefined,
notes: '',
},
],
});
});
// prune realizations
const kandangIds = new Set(kandangs.map((kandang) => kandang.id));
const deletedRealizationsIdx: number[] = [];
newRealizations.forEach((realization, idx) => {
const isRealizationValid = kandangIds.has(realization.kandang_id);
if (!isRealizationValid) {
deletedRealizationsIdx.push(idx);
}
});
deletedRealizationsIdx.forEach((deletedRealizationIdx) => {
newRealizations.splice(deletedRealizationIdx, 1);
});
formik.setFieldValue('realizations', newRealizations);
};
@@ -205,6 +223,13 @@ const ExpenseRealizationForm = ({
const realizationDocumentsChangeHandler = (val: File[]) => {
formik.setFieldTouched('documents', true);
const invalidFiles = val.filter((file) => file.size > 5 * 1024 * 1024);
if (invalidFiles.length > 0) {
toast.error('Ukuran dokumen maksimal 5 MB!');
return;
}
formik.setFieldValue('documents', val);
};
@@ -290,21 +315,23 @@ const ExpenseRealizationForm = ({
className={{ wrapper: 'col-span-12' }}
/>
<DropFileInput
label='Dokumen Realisasi'
name='documents'
values={formik.values.documents}
onChange={realizationDocumentsChangeHandler}
onDelete={realizationDocumentsDeleteHandler}
accept={{
...ACCEPTED_FILE_TYPE.PDF,
...ACCEPTED_FILE_TYPE.IMAGE,
}}
className={{
wrapper: 'col-span-12',
inputWrapper: 'h-12 flex items-center',
}}
/>
<RequirePermission permissions='lti.expense.document.realization'>
<DropFileInput
label='Dokumen Realisasi'
name='documents'
values={formik.values.documents}
onChange={realizationDocumentsChangeHandler}
onDelete={realizationDocumentsDeleteHandler}
accept={{
...ACCEPTED_FILE_TYPE.PDF,
...ACCEPTED_FILE_TYPE.IMAGE,
}}
className={{
wrapper: 'col-span-12',
inputWrapper: 'h-12 flex items-center',
}}
/>
</RequirePermission>
{formik.values.existing_documents &&
formik.values.existing_documents.length > 0 && (
@@ -335,7 +362,10 @@ const ExpenseRealizationForm = ({
)}
<ExpenseRealizationKandangDetailExpense
type={type}
formik={formik}
supplierId={formik.values.supplier?.value as number}
location={formik.values.location}
className={{
wrapper: 'col-span-12',
}}
@@ -357,20 +387,22 @@ const ExpenseRealizationForm = ({
{type !== 'add' && (
<div className='flex flex-row justify-start gap-2'>
{type !== 'edit' && (
<Button
type='button'
color='warning'
href={`/expense/detail/edit/?expenseId=${initialValues?.id}`}
className='px-4'
>
<Icon
icon='material-symbols:edit-outline'
width={24}
height={24}
className='justify-start text-sm'
/>
Edit
</Button>
<RequirePermission permissions='lti.expense.update'>
<Button
type='button'
color='warning'
href={`/expense/detail/edit/?expenseId=${initialValues?.id}`}
className='px-4'
>
<Icon
icon='material-symbols:edit-outline'
width={24}
height={24}
className='justify-start text-sm'
/>
Edit
</Button>
</RequirePermission>
)}
</div>
)}
@@ -18,6 +18,11 @@ import { Nonstock } from '@/types/api/master-data/nonstock';
interface ExpenseRealizationKandangDetailExpenseProps {
type?: 'add' | 'edit' | 'detail';
formik: FormikContextType<ExpenseRealizationFormValues>;
supplierId?: number;
location?: {
value: number;
label: string;
};
className?: {
wrapper?: string;
};
@@ -25,12 +30,18 @@ interface ExpenseRealizationKandangDetailExpenseProps {
const ExpenseRealizationKandangDetailExpense: React.FC<
ExpenseRealizationKandangDetailExpenseProps
> = ({ type, formik, className }) => {
> = ({ type, formik, supplierId, location, className }) => {
const {
setInputValue: setNonstockInputValue,
options: nonstockOptions,
isLoadingOptions: isLoadingNonstockOptions,
} = useSelect<Nonstock>(NonstockApi.basePath, 'id', 'name');
} = useSelect<Nonstock>(
NonstockApi.basePath,
'id',
'name',
'search',
supplierId ? { supplier_id: String(supplierId) } : undefined
);
const nonstockChangeHandler = (
kandangExpenseIdx: number,
@@ -82,140 +93,159 @@ const ExpenseRealizationKandangDetailExpense: React.FC<
</div>
<div className='w-full flex flex-col gap-6'>
{formik.values.realizations.length === 0 && (
{!formik.values.supplier?.value && (
<div>
<p className='text-sm text-gray-400 text-center'>
Pilih kandang terlebih dahulu!
Pilih supplier terlebih dahulu!
</p>
</div>
)}
{formik.values.realizations.map((kandangExpense, kandangExpenseIdx) => {
const kandangName = formik.values.kandangs?.find(
(kandang) => kandang.id === kandangExpense.kandang_id
);
{formik.values.realizations.length === 0 &&
formik.values.supplier?.value && (
<div>
<p className='text-sm text-gray-400 text-center'>
Belum ada item biaya. Silakan pilih lokasi terlebih dahulu.
</p>
</div>
)}
return (
kandangName?.name && (
<div
key={`kandangExpense-${kandangExpenseIdx}`}
className='w-full flex flex-col gap-4'
>
<div>
<h5 className='mb-2 text-lg font-bold text-center'>
Biaya {kandangName?.name}
</h5>
{formik.values.realizations.length > 0 &&
formik.values.supplier?.value &&
formik.values.realizations.map(
(kandangExpense, kandangExpenseIdx) => {
const kandangName = kandangExpense.kandang_id
? formik.values.kandangs?.find(
(kandang) => kandang.id === kandangExpense.kandang_id
)
: null;
<div className='overflow-x-auto'>
<table className='table'>
<thead>
<tr>
<th>Nonstock</th>
<th>Total Kuantitas</th>
<th>Harga Satuan</th>
<th>Catatan</th>
</tr>
</thead>
return (
(kandangName?.name || !kandangExpense.kandang_id) && (
<div
key={`kandangExpense-${kandangExpenseIdx}`}
className='w-full flex flex-col gap-4'
>
<div>
<h5 className='mb-2 text-lg font-bold text-center'>
{kandangName?.name
? `Biaya ${kandangName.name}`
: location?.label
? `Biaya ${location.label}`
: 'Biaya Umum'}
</h5>
<tbody>
{kandangExpense.cost_items.map(
(expenseItem, expenseIdx) => (
<tr key={`expense-${expenseIdx}`}>
<td className='p-2'>
<SelectInput
placeholder='Pilih Nonstock'
value={expenseItem.nonstock}
onChange={(val) => {
nonstockChangeHandler(
kandangExpenseIdx,
expenseIdx,
val
);
}}
options={nonstockOptions}
isLoading={isLoadingNonstockOptions}
onInputChange={setNonstockInputValue}
className={{ wrapper: 'min-w-48' }}
isDisabled
/>
</td>
<td className='p-2'>
<NumberInput
required
name={`realizations[${kandangExpenseIdx}].cost_items[${expenseIdx}].quantity`}
placeholder='Masukkan Total Kuantitas'
value={
formik.values.realizations[
kandangExpenseIdx
].cost_items[expenseIdx].quantity ?? ''
}
onChange={formik.handleChange}
onBlur={formik.handleBlur}
isError={isExpenseRepeaterInputError(
'quantity',
kandangExpenseIdx,
expenseIdx
)}
className={{ wrapper: 'min-w-24' }}
/>
</td>
<td className='p-2'>
<NumberInput
name={`realizations[${kandangExpenseIdx}].cost_items[${expenseIdx}].price`}
placeholder='Masukkan Harga Satuan'
value={
formik.values.realizations[
kandangExpenseIdx
].cost_items[expenseIdx].price ?? ''
}
onChange={formik.handleChange}
onBlur={formik.handleBlur}
isError={isExpenseRepeaterInputError(
'price',
kandangExpenseIdx,
expenseIdx
)}
inputPrefix={
<span className='text-gray-600 font-medium'>
Rp
</span>
}
className={{ wrapper: 'min-w-24' }}
/>
</td>
<td className='p-2'>
<TextInput
name={`realizations[${kandangExpenseIdx}].cost_items[${expenseIdx}].notes`}
placeholder='Tuliskan catatan'
value={
formik.values.realizations[
kandangExpenseIdx
].cost_items[expenseIdx].notes ?? ''
}
onChange={formik.handleChange}
onBlur={formik.handleBlur}
isError={isExpenseRepeaterInputError(
'notes',
kandangExpenseIdx,
expenseIdx
)}
className={{ wrapper: 'min-w-24' }}
/>
</td>
<div className='overflow-x-auto'>
<table className='table'>
<thead>
<tr>
<th>Nonstock</th>
<th>Total Kuantitas</th>
<th>Harga Satuan</th>
<th>Catatan</th>
</tr>
)
)}
</tbody>
</table>
</thead>
<tbody>
{kandangExpense.cost_items.map(
(expenseItem, expenseIdx) => (
<tr key={`expense-${expenseIdx}`}>
<td className='p-2'>
<SelectInput
placeholder='Pilih Nonstock'
value={expenseItem.nonstock}
onChange={(val) => {
nonstockChangeHandler(
kandangExpenseIdx,
expenseIdx,
val
);
}}
options={nonstockOptions}
isLoading={isLoadingNonstockOptions}
onInputChange={setNonstockInputValue}
className={{ wrapper: 'min-w-48' }}
isDisabled
/>
</td>
<td className='p-2'>
<NumberInput
required
name={`realizations[${kandangExpenseIdx}].cost_items[${expenseIdx}].quantity`}
placeholder='Masukkan Total Kuantitas'
value={
formik.values.realizations[
kandangExpenseIdx
].cost_items[expenseIdx].quantity ?? ''
}
onChange={formik.handleChange}
onBlur={formik.handleBlur}
isError={isExpenseRepeaterInputError(
'quantity',
kandangExpenseIdx,
expenseIdx
)}
className={{ wrapper: 'min-w-24' }}
/>
</td>
<td className='p-2'>
<NumberInput
name={`realizations[${kandangExpenseIdx}].cost_items[${expenseIdx}].price`}
placeholder='Masukkan Harga Satuan'
value={
formik.values.realizations[
kandangExpenseIdx
].cost_items[expenseIdx].price ?? ''
}
onChange={formik.handleChange}
onBlur={formik.handleBlur}
isError={isExpenseRepeaterInputError(
'price',
kandangExpenseIdx,
expenseIdx
)}
inputPrefix={
<span className='text-gray-600 font-medium'>
Rp
</span>
}
className={{ wrapper: 'min-w-24' }}
/>
</td>
<td className='p-2'>
<TextInput
name={`realizations[${kandangExpenseIdx}].cost_items[${expenseIdx}].notes`}
placeholder='Tuliskan catatan'
value={
formik.values.realizations[
kandangExpenseIdx
].cost_items[expenseIdx].notes ?? ''
}
onChange={formik.handleChange}
onBlur={formik.handleBlur}
isError={isExpenseRepeaterInputError(
'notes',
kandangExpenseIdx,
expenseIdx
)}
className={{ wrapper: 'min-w-24' }}
/>
</td>
</tr>
)
)}
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
)
);
})}
)
);
}
)}
</div>
</Card>
);
@@ -1,32 +1,36 @@
import * as Yup from 'yup';
import { Expense } from '@/types/api/expense';
import { formatDate } from '@/lib/helper';
import { S3_PUBLIC_BASE_URL } from '@/config/constant';
type ExpenseFormSchemaType = {
category?: {
value: 'BOP' | 'NON-BOP';
label: 'BOP' | 'NON-BOP';
};
} | null;
location?: {
value: number;
label: string;
};
} | null;
location_id: number;
transaction_date?: string;
kandangs?: { id: number; name: string }[];
kandangs?: { id?: number; name?: string }[];
supplier?: {
value: number;
label: string;
};
} | null;
supplier_id: number;
existing_documents?: { id: number; name: string; url: string }[];
deleted_documents?: number[];
documents?: File[];
expense_nonstocks: {
kandang_id: number;
kandang_id?: number;
cost_items: {
nonstock?: {
value: number;
label: string;
};
} | null;
nonstock_id?: number;
quantity?: number;
price?: number;
notes?: string;
@@ -39,36 +43,54 @@ export const ExpenseRequestFormSchema: Yup.ObjectSchema<ExpenseFormSchemaType> =
category: Yup.object({
value: Yup.string().oneOf(['BOP', 'NON-BOP']).required(),
label: Yup.string().oneOf(['BOP', 'NON-BOP']).required(),
}).required('Kategori wajib diisi!'),
})
.nullable()
.optional(),
location: Yup.object({
value: Yup.number().min(1).required(),
label: Yup.string().required(),
}).required('Lokasi wajib diisi!'),
})
.nullable()
.optional(),
location_id: Yup.number()
.required('Lokasi wajib diisi!')
.min(1, 'Lokasi wajib diisi!')
.typeError('Lokasi wajib diisi!'),
transaction_date: Yup.string().required('Tanggal transaksi wajib diisi!'),
kandangs: Yup.array()
.of(
Yup.object({
id: Yup.number().required('Kandang wajib dipilih!'),
name: Yup.string().required('Kandang wajib dipilih!'),
id: Yup.number().optional(),
name: Yup.string().optional(),
})
)
.min(1, 'Kandang wajib dipilih!')
.required('Kandang wajib dipilih!'),
.optional(),
supplier: Yup.object({
value: Yup.number().min(1).required(),
label: Yup.string().required(),
}).required('Vendor wajib diisi!'),
})
.nullable()
.optional(),
existing_documents: Yup.array().of(
Yup.object({
id: Yup.number().required(),
name: Yup.string().required(),
url: Yup.string().required(),
})
),
supplier_id: Yup.number()
.required('Vendor wajib diisi!')
.min(1, 'Vendor wajib diisi!')
.typeError('Vendor wajib diisi!'),
existing_documents: Yup.array()
.of(
Yup.object({
id: Yup.number().required(),
name: Yup.string().required(),
url: Yup.string().required(),
})
)
.optional(),
deleted_documents: Yup.array().of(Yup.number().required()).optional(),
@@ -77,16 +99,24 @@ export const ExpenseRequestFormSchema: Yup.ObjectSchema<ExpenseFormSchemaType> =
expense_nonstocks: Yup.array()
.of(
Yup.object({
kandang_id: Yup.number().min(1, 'Wajib memilih kandang!').required(),
kandang_id: Yup.number().min(1, 'Wajib memilih kandang!').optional(),
cost_items: Yup.array()
.of(
Yup.object({
nonstock: Yup.object({
value: Yup.number().min(1).required(),
label: Yup.string().required(),
}).required('Nonstock wajib diisi!'),
quantity: Yup.number().required('Total kuantitas wajib diisi!'),
price: Yup.number().required('Harga satuan wajib diisi!'),
}).nullable(),
nonstock_id: Yup.number()
.required('Nonstock wajib diisi!')
.min(1, 'Nonstock wajib diisi!')
.typeError('Nonstock wajib diisi!'),
quantity: Yup.number()
.required('Total kuantitas wajib diisi!')
.typeError('Total kuantitas wajib diisi!'),
price: Yup.number()
.required('Harga satuan wajib diisi!')
.typeError('Harga satuan wajib diisi!'),
notes: Yup.string(),
})
)
@@ -101,7 +131,16 @@ export const ExpenseRequestFormSchema: Yup.ObjectSchema<ExpenseFormSchemaType> =
export const UpdateExpenseRequestFormSchema = ExpenseRequestFormSchema;
export const UploadRequestDocumentsFormSchema = Yup.object({
documents: Yup.array().of(Yup.mixed<File>().required()).required(),
documents: Yup.array()
.of(
Yup.mixed<File>()
.required()
.test('fileSize', 'Ukuran dokumen maksimal 5 MB', (value) => {
if (!value || !(value instanceof File)) return true;
return value.size <= 5 * 1024 * 1024;
})
)
.required(),
});
export type ExpenseRequestFormValues = Yup.InferType<
@@ -121,13 +160,14 @@ export const getExpenseFormInitialValues = (
value: initialValues.category,
label: initialValues.category,
}
: undefined,
: null,
location: initialValues?.location
? {
value: initialValues.location.id,
label: initialValues.location.name,
}
: undefined,
: null,
location_id: Number(initialValues?.location.id || 0),
transaction_date: initialValues?.transaction_date
? formatDate(initialValues.transaction_date, 'YYYY-MM-DD')
: undefined,
@@ -140,12 +180,16 @@ export const getExpenseFormInitialValues = (
value: initialValues.supplier.id,
label: initialValues.supplier.name,
}
: undefined,
existing_documents: initialValues?.documents?.map((doc) => ({
id: doc.id,
name: doc.path,
url: doc.path,
})),
: null,
supplier_id: initialValues?.supplier?.id ?? 0,
existing_documents: initialValues?.documents?.map((doc) => {
const path = doc.path.startsWith('/') ? doc.path.slice(1) : doc.path;
return {
id: doc.id,
name: doc.path,
url: `${S3_PUBLIC_BASE_URL}/${path}`,
};
}),
deleted_documents: [],
documents: [],
expense_nonstocks: initialValues?.kandangs
@@ -157,12 +201,25 @@ export const getExpenseFormInitialValues = (
value: expenseItem.nonstock.id,
label: expenseItem.nonstock.name,
},
nonstock_id: expenseItem.nonstock.id,
quantity: expenseItem.qty,
price: expenseItem.price,
notes: expenseItem.note,
}))
: [],
}))
: [],
: [
{
cost_items: [
{
nonstock: null,
nonstock_id: 0,
quantity: undefined,
price: undefined,
notes: '',
},
],
},
],
};
};
@@ -18,6 +18,7 @@ import DateInput from '@/components/input/DateInput';
import ExpenseKandangsTable from '@/components/pages/expense/form/ExpenseKandangsTable';
import DropFileInput from '@/components/input/DropFileInput';
import ExpenseRequestKandangDetailExpense from '@/components/pages/expense/form/ExpenseRequestKandangDetailExpense';
import RequirePermission from '@/components/helper/RequirePermission';
import {
ExpenseRequestFormSchema,
@@ -36,6 +37,8 @@ import { cn, sleep } from '@/lib/helper';
import { LocationApi, SupplierApi } from '@/services/api/master-data';
import { ACCEPTED_FILE_TYPE } from '@/config/constant';
import { Supplier } from '@/types/api/master-data/supplier';
import { getUniqueFormikErrors } from '@/lib/formik-helper';
import AlertErrorList from '@/components/helper/form/FormErrors';
interface ExpenseFormProps {
type?: 'add' | 'edit' | 'detail';
@@ -54,6 +57,7 @@ const ExpenseRequestForm = ({
const rejectModal = useModal();
const [expenseFormErrorMessage, setExpenseFormErrorMessage] = useState('');
const [formErrorList, setFormErrorList] = useState<string[]>([]);
const createExpenseHandler = useCallback(
async (payload: CreateExpensePayload) => {
@@ -107,18 +111,24 @@ const ExpenseRequestForm = ({
const expensePayload: CreateExpensePayload = {
category: formik.values.category?.value as 'BOP' | 'NON-BOP',
location_id: values.location_id as number,
transaction_date: values?.transaction_date as string,
supplier_id: values.supplier?.value as number,
documents: values.documents as File[],
expense_nonstocks: values.expense_nonstocks.map((expenseNonstock) => ({
kandang_id: expenseNonstock.kandang_id,
cost_items: expenseNonstock.cost_items.map((costItem) => ({
nonstock_id: costItem.nonstock?.value as number,
quantity: parseFloat(String(costItem.quantity)) as number,
price: parseFloat(String(costItem.price)) as number,
notes: costItem.notes ?? '',
})),
})),
expense_nonstocks: values.expense_nonstocks.map((expenseNonstock) => {
const basePayload = {
cost_items: expenseNonstock.cost_items.map((costItem) => ({
nonstock_id: costItem.nonstock?.value as number,
quantity: parseFloat(String(costItem.quantity)) as number,
price: parseFloat(String(costItem.price)) as number,
notes: costItem.notes ?? '',
})),
};
return expenseNonstock.kandang_id
? { ...basePayload, kandang_id: expenseNonstock.kandang_id }
: basePayload;
}),
};
switch (type) {
@@ -129,19 +139,25 @@ const ExpenseRequestForm = ({
case 'edit':
const expenseUpdatePayload: UpdateExpensePayload = {
category: formik.values.category?.value as 'BOP' | 'NON-BOP',
location_id: values.location_id as number,
transaction_date: values?.transaction_date as string,
supplier_id: values.supplier?.value as number,
documents: values.documents as File[],
expense_nonstocks: values.expense_nonstocks.map(
(expenseNonstock) => ({
kandang_id: expenseNonstock.kandang_id,
cost_items: expenseNonstock.cost_items.map((costItem) => ({
nonstock_id: costItem.nonstock?.value as number,
quantity: parseFloat(String(costItem.quantity)) as number,
price: parseFloat(String(costItem.price)) as number,
notes: costItem.notes ?? '',
})),
})
(expenseNonstock) => {
const basePayload = {
cost_items: expenseNonstock.cost_items.map((costItem) => ({
nonstock_id: costItem.nonstock?.value as number,
quantity: parseFloat(String(costItem.quantity)) as number,
price: parseFloat(String(costItem.price)) as number,
notes: costItem.notes ?? '',
})),
};
return expenseNonstock.kandang_id
? { ...basePayload, kandang_id: expenseNonstock.kandang_id }
: basePayload;
}
),
};
@@ -178,30 +194,67 @@ const ExpenseRequestForm = ({
formik.setFieldTouched('location', true);
formik.setFieldValue('location', val);
const locationId = Array.isArray(val) ? val[0]?.value : val?.value;
formik.setFieldValue('location_id', locationId);
formik.setFieldValue('kandangs', []);
formik.setFieldValue('expense_nonstocks', []);
// Auto-create expense item for location (without kandang)
formik.setFieldValue('expense_nonstocks', [
{
cost_items: [
{
nonstock: null,
nonstock_id: 0,
quantity: undefined,
price: undefined,
notes: '',
},
],
},
]);
};
const kandangsChangeHandler = (kandangs: { id: number; name: string }[]) => {
const kandangsChangeHandler = (
kandangs: { id?: number; name?: string }[]
) => {
formik.setFieldTouched('kandangs', true);
formik.setFieldValue('kandangs', kandangs);
const newExpenseNonstocks = [...(formik.values.expense_nonstocks ?? [])];
// If no kandangs selected, create expense item for location
if (kandangs.length === 0) {
formik.setFieldValue('expense_nonstocks', [
{
cost_items: [
{
nonstock: null,
nonstock_id: 0,
quantity: undefined,
price: undefined,
notes: '',
},
],
},
]);
return;
}
const newExpenseNonstocks: typeof formik.values.expense_nonstocks = [];
// add new expense_nonstocks
kandangs.forEach((kandangItem) => {
const isKandangExistInExpenseNonstocks = newExpenseNonstocks.find(
if (!kandangItem.id) return;
const existingExpenseNonstock = formik.values.expense_nonstocks?.find(
(expenseNonstockItem) =>
expenseNonstockItem.kandang_id === kandangItem.id
);
if (isKandangExistInExpenseNonstocks) return;
newExpenseNonstocks.push({
kandang_id: kandangItem.id,
cost_items: [
cost_items: existingExpenseNonstock?.cost_items || [
{
nonstock: undefined,
nonstock: null,
nonstock_id: 0,
quantity: undefined,
price: undefined,
notes: '',
@@ -210,32 +263,26 @@ const ExpenseRequestForm = ({
});
});
// prune expense_nonstocks
const kandangIds = new Set(kandangs.map((kandang) => kandang.id));
const deletedExpenseNonstocksIdx: number[] = [];
newExpenseNonstocks.forEach((expenseNonstock, idx) => {
const isExpenseNonstockValid = kandangIds.has(expenseNonstock.kandang_id);
if (!isExpenseNonstockValid) {
deletedExpenseNonstocksIdx.push(idx);
}
});
deletedExpenseNonstocksIdx.forEach((deletedExpenseNonstockIdx) => {
newExpenseNonstocks.splice(deletedExpenseNonstockIdx, 1);
});
formik.setFieldValue('expense_nonstocks', newExpenseNonstocks);
};
const supplierChangeHandler = (val: OptionType | OptionType[] | null) => {
formik.setFieldTouched('supplier', true);
formik.setFieldValue('supplier', val);
const supplierId = Array.isArray(val) ? val[0]?.value : val?.value;
formik.setFieldValue('supplier_id', supplierId ?? 0);
};
const requestDocumentsChangeHandler = (val: File[]) => {
formik.setFieldTouched('documents', true);
const invalidFiles = val.filter((file) => file.size > 5 * 1024 * 1024);
if (invalidFiles.length > 0) {
toast.error('Ukuran dokumen maksimal 5 MB!');
return;
}
formik.setFieldValue('documents', val);
};
@@ -291,6 +338,22 @@ const ExpenseRequestForm = ({
router.push('/expense');
};
const handleValidateForm = async () => {
const errors = await formik.validateForm();
if (Object.keys(errors).length > 0) {
const errorMessages = getUniqueFormikErrors(errors);
setFormErrorList(errorMessages);
return;
}
};
const handleFormSubmit = (e: React.FormEvent<HTMLFormElement>) => {
e.preventDefault();
handleValidateForm();
formik.handleSubmit(e);
};
useEffect(() => {
formikSetValues(getExpenseFormInitialValues(initialValues));
}, [formikSetValues, getExpenseFormInitialValues, initialValues]);
@@ -316,10 +379,27 @@ const ExpenseRequestForm = ({
</header>
<form
onSubmit={formik.handleSubmit}
onSubmit={handleFormSubmit}
onReset={formik.handleReset}
className='w-full mt-8 flex flex-col gap-6'
>
{expenseFormErrorMessage && (
<div role='alert' className='alert alert-error'>
<Icon
icon='material-symbols:error-outline'
width={24}
height={24}
/>
<span>{expenseFormErrorMessage}</span>
</div>
)}
{formErrorList.length > 0 && (
<AlertErrorList
formErrorList={formErrorList}
onClose={() => setFormErrorList([])}
/>
)}
<div className='grid grid-cols-12 gap-4'>
<SelectInput
label='Kategori'
@@ -385,21 +465,23 @@ const ExpenseRequestForm = ({
className={{ wrapper: 'col-span-12' }}
/>
<DropFileInput
label='Dokumen Pengajuan'
name='documents'
values={formik.values.documents}
onChange={requestDocumentsChangeHandler}
onDelete={requestDocumentsDeleteHandler}
accept={{
...ACCEPTED_FILE_TYPE.PDF,
...ACCEPTED_FILE_TYPE.IMAGE,
}}
className={{
wrapper: 'col-span-12',
inputWrapper: 'h-12 flex items-center',
}}
/>
<RequirePermission permissions='lti.expense.document'>
<DropFileInput
label='Dokumen Pengajuan'
name='documents'
values={formik.values.documents}
onChange={requestDocumentsChangeHandler}
onDelete={requestDocumentsDeleteHandler}
accept={{
...ACCEPTED_FILE_TYPE.PDF,
...ACCEPTED_FILE_TYPE.IMAGE,
}}
className={{
wrapper: 'col-span-12',
inputWrapper: 'h-12 flex items-center',
}}
/>
</RequirePermission>
{formik.values.existing_documents &&
formik.values.existing_documents.length > 0 && (
@@ -451,7 +533,10 @@ const ExpenseRequestForm = ({
)}
<ExpenseRequestKandangDetailExpense
type={type}
formik={formik}
supplierId={formik.values.supplier?.value as number}
location={formik.values.location}
className={{
wrapper: 'col-span-12',
}}
@@ -461,48 +546,41 @@ const ExpenseRequestForm = ({
<div className='flex flex-row justify-between gap-2 flex-wrap'>
{type !== 'add' && (
<div className='flex flex-row justify-start gap-2'>
<Button
type='button'
color='error'
onClick={deleteExpenseClickHandler}
className='px-4'
>
<Icon
icon='material-symbols:delete-outline-rounded'
width={24}
height={24}
className='justify-start text-sm'
/>
Delete
</Button>
{type !== 'edit' && (
<RequirePermission permissions='lti.expense.delete'>
<Button
type='button'
color='warning'
href={`/expense/detail/edit/?expenseId=${initialValues?.id}`}
color='error'
onClick={deleteExpenseClickHandler}
className='px-4'
>
<Icon
icon='material-symbols:edit-outline'
icon='material-symbols:delete-outline-rounded'
width={24}
height={24}
className='justify-start text-sm'
/>
Edit
Delete
</Button>
)}
</div>
)}
</RequirePermission>
{expenseFormErrorMessage && (
<div role='alert' className='alert alert-error w-full'>
<Icon
icon='material-symbols:error-outline'
width={24}
height={24}
/>
<span>{expenseFormErrorMessage}</span>
{type !== 'edit' && (
<RequirePermission permissions='lti.expense.update'>
<Button
type='button'
color='warning'
href={`/expense/detail/edit/?expenseId=${initialValues?.id}`}
className='px-4'
>
<Icon
icon='material-symbols:edit-outline'
width={24}
height={24}
className='justify-start text-sm'
/>
Edit
</Button>
</RequirePermission>
)}
</div>
)}
@@ -520,7 +598,7 @@ const ExpenseRequestForm = ({
type='submit'
color='primary'
isLoading={formik.isSubmitting}
disabled={!formik.isValid || formik.isSubmitting}
disabled={formik.isSubmitting}
className='px-4'
>
Submit
@@ -21,6 +21,11 @@ import { removeArrayItemAndSync } from '@/lib/utils/formik';
interface ExpenseRequestKandangDetailExpenseProps {
type?: 'add' | 'edit' | 'detail';
formik: FormikContextType<ExpenseRequestFormValues>;
supplierId?: number;
location?: {
value: number;
label: string;
} | null;
className?: {
wrapper?: string;
};
@@ -28,12 +33,18 @@ interface ExpenseRequestKandangDetailExpenseProps {
const ExpenseRequestKandangDetailExpense: React.FC<
ExpenseRequestKandangDetailExpenseProps
> = ({ type, formik, className }) => {
> = ({ type, formik, supplierId, location, className }) => {
const {
setInputValue: setNonstockInputValue,
options: nonstockOptions,
isLoadingOptions: isLoadingNonstockOptions,
} = useSelect<Nonstock>(NonstockApi.basePath, 'id', 'name');
} = useSelect<Nonstock>(
NonstockApi.basePath,
'id',
'name',
'search',
supplierId ? { supplier_id: String(supplierId) } : undefined
);
const nonstockChangeHandler = (
kandangExpenseIdx: number,
@@ -48,13 +59,20 @@ const ExpenseRequestKandangDetailExpense: React.FC<
`expense_nonstocks[${kandangExpenseIdx}].cost_items[${expenseIdx}].nonstock`,
val
);
const nonstockId = Array.isArray(val) ? val[0]?.value : val?.value;
formik.setFieldValue(
`expense_nonstocks[${kandangExpenseIdx}].cost_items[${expenseIdx}].nonstock_id`,
nonstockId ?? 0
);
};
const addExpenseItemHandler = (kandangExpenseIdx: number) => {
const newExpensesValue = [
...formik.values.expense_nonstocks[kandangExpenseIdx].cost_items,
{
nonstock: undefined,
nonstock: null,
nonstock_id: 0,
price: undefined,
quantity: undefined,
notes: '',
@@ -113,41 +131,57 @@ const ExpenseRequestKandangDetailExpense: React.FC<
</div>
<div className='w-full flex flex-col gap-6'>
{(formik.values.expense_nonstocks.length === 0 ||
!formik.values.supplier?.value) && (
{!formik.values.supplier?.value && (
<div>
<p className='text-sm text-gray-400 text-center'>
Pilih kandang terlebih dahulu!
Pilih supplier terlebih dahulu!
</p>
</div>
)}
{formik.values.expense_nonstocks.length === 0 &&
formik.values.supplier?.value && (
<div>
<p className='text-sm text-gray-400 text-center'>
Belum ada item biaya. Silakan pilih lokasi terlebih dahulu.
</p>
</div>
)}
{formik.values.expense_nonstocks.length > 0 &&
formik.values.supplier?.value &&
formik.values.expense_nonstocks.map(
(kandangExpense, kandangExpenseIdx) => {
const kandangName = formik.values.kandangs?.find(
(kandang) => kandang.id === kandangExpense.kandang_id
);
const kandangName = kandangExpense.kandang_id
? formik.values.kandangs?.find(
(kandang) => kandang.id === kandangExpense.kandang_id
)
: null;
return (
kandangName?.name && (
(kandangName?.name || !kandangExpense.kandang_id) && (
<div
key={`kandangExpense-${kandangExpenseIdx}`}
className='w-full flex flex-col gap-4'
>
<div>
<h5 className='mb-2 text-lg font-bold text-center'>
Biaya {kandangName?.name}
Biaya {kandangName?.name || location?.label || 'Umum'}
</h5>
<div className='overflow-x-auto'>
<table className='table'>
<thead>
<tr>
<th>Nonstock</th>
<th>Total Kuantitas</th>
<th>Harga Satuan</th>
<th className='after:content-["*"] after:text-red-500 after:ml-0.5'>
Nonstock
</th>
<th className='after:content-["*"] after:text-red-500 after:ml-0.5'>
Total Kuantitas
</th>
<th className='after:content-["*"] after:text-red-500 after:ml-0.5'>
Harga Satuan
</th>
<th>Catatan</th>
{type !== 'detail' && <th>Aksi</th>}
</tr>
@@ -198,7 +198,7 @@ const ExpensePDF = ({ expense }: ExpensePDFProps) => {
expense?.latest_approval?.action === 'REJECTED';
const isExpenseRealized =
expense?.latest_approval?.step_number &&
expense?.latest_approval.step_number >= 4;
expense?.latest_approval.step_number >= 5;
const realizationStatus = isExpenseRealized
? 'Sudah Realisasi'
@@ -219,7 +219,13 @@ const ExpensePDF = ({ expense }: ExpensePDFProps) => {
{ label: 'Lokasi', value: expense?.location.name },
{
label: 'Kandang',
value: expense?.kandangs.map((item) => item.name).join(', '),
value:
expense?.kandangs && expense?.kandangs.some((k) => k.name)
? expense?.kandangs
.filter((item) => item.name)
.map((item) => item.name)
.join(', ')
: '-',
},
{ label: 'Vendor', value: expense?.supplier.name },
{
@@ -235,7 +241,12 @@ const ExpensePDF = ({ expense }: ExpensePDFProps) => {
{ label: 'Nama Pengaju', value: expense?.created_user.name },
{
label: 'Nominal Biaya',
value: formatCurrency(expense?.grand_total ?? 0),
value: formatCurrency(
expense?.latest_approval.step_number === 5 ||
expense?.latest_approval.step_number === 6
? (expense?.total_realisasi ?? 0)
: (expense?.total_pengajuan ?? 0)
),
},
{
label: 'Nominal Pengajuan',
@@ -326,7 +337,7 @@ const ExpensePDF = ({ expense }: ExpensePDFProps) => {
let expenseRequestTotal = 0;
kandangExpense.pengajuans?.forEach(
(item) => (expenseRequestTotal += item.price)
(item) => (expenseRequestTotal += item.qty * item.price)
);
return (
@@ -335,7 +346,9 @@ const ExpensePDF = ({ expense }: ExpensePDFProps) => {
style={ExpensePDFStyle.kandangExpenseContainer}
>
<Text style={ExpensePDFStyle.kandangExpenseTitle}>
{kandangExpense.name}
{kandangExpense.kandang_id && kandangExpense.name
? `Biaya ${kandangExpense.name}`
: `Biaya ${expense?.location.name || 'Umum'}`}
</Text>
<View style={ExpensePDFStyle.kandangExpenseTable}>
@@ -484,7 +497,7 @@ const ExpensePDF = ({ expense }: ExpensePDFProps) => {
let expenseRealizationTotal = 0;
kandangExpense.realisasi?.forEach(
(item) => (expenseRealizationTotal += item.price)
(item) => (expenseRealizationTotal += item.qty * item.price)
);
return (
@@ -493,7 +506,9 @@ const ExpensePDF = ({ expense }: ExpensePDFProps) => {
style={ExpensePDFStyle.kandangExpenseContainer}
>
<Text style={ExpensePDFStyle.kandangExpenseTitle}>
{kandangExpense.name}
{kandangExpense.kandang_id && kandangExpense.name
? `Biaya ${kandangExpense.name}`
: `Biaya ${expense?.location.name || 'Umum'}`}
</Text>
<View style={ExpensePDFStyle.kandangExpenseTable}>
@@ -0,0 +1,216 @@
import Button from '@/components/Button';
import Card from '@/components/Card';
import { FormHeader } from '@/components/helper/form/FormHeader';
import RequirePermission from '@/components/helper/RequirePermission';
import DebouncedTextInput from '@/components/input/DebouncedTextInput';
import { useModal } from '@/components/Modal';
import ConfirmationModal from '@/components/modal/ConfirmationModal';
import Table from '@/components/Table';
import {
FINANCE_INITIAL_BALANCE_STATUS,
FINANCE_TRANSACTION_STATUS,
FINANCE_INJECTION_STATUS,
} from '@/config/constant';
import { formatCurrency, formatDate, formatTitleCase } from '@/lib/helper';
import { FinanceApi } from '@/services/api/finance';
import { Finance } from '@/types/api/finance/finance';
import { Icon } from '@iconify/react';
import { useRouter } from 'next/navigation';
import { useState } from 'react';
import toast from 'react-hot-toast';
const FinanceDetail = ({ finance }: { finance: Finance }) => {
const router = useRouter();
const deleteModal = useModal();
const [isDeleteLoading, setIsDeleteLoading] = useState(false);
const informasiUmum = [
{
label: 'ID',
value: finance.payment_code,
},
{
label: 'Jenis Transaksi',
value: finance.transaction_type,
},
{
label: 'Pihak',
value: finance.party.id ? finance.party.name : '-',
},
{
label: 'Tanggal',
value: formatDate(finance.payment_date, 'DD MMM yyyy'),
},
{
label: 'Metode Pembayaran',
value: finance.payment_method,
},
{
label: 'Catatan',
value: finance.notes || '-',
},
];
const informasiTransfer = [
{
label: 'No. Referensi',
value: finance.reference_number ?? '-',
},
{
label: 'Nomor Rekening',
value: `${finance.bank.alias} - ${finance.bank.account_number} - ${finance.bank.owner}`,
},
{
label: `Rekening ${formatTitleCase(finance.party.type)}`,
value: finance.party.account_number,
},
{
label: 'Nominal',
value: formatCurrency(finance.expense_amount),
},
{
label: 'Sisa',
value: formatCurrency(finance.income_amount),
},
].filter((item) => {
// Hide party account number row if transaction type is INJECTION
if (
FINANCE_INJECTION_STATUS.includes(finance.transaction_type) &&
item.label === `Rekening ${formatTitleCase(finance.party.type)}`
) {
return false;
}
return true;
});
const confirmationModalDeleteClickHandler = async () => {
setIsDeleteLoading(true);
await FinanceApi.delete(finance.id as number);
router.back();
deleteModal.closeModal();
toast.success('Successfully delete Finance!');
setIsDeleteLoading(false);
};
return (
<div className='flex flex-col gap-6 p-6'>
<FormHeader title='' backUrl='/finance' />
<Card
title='Detail Keuangan'
className={{
wrapper: 'w-full',
}}
variant='bordered'
>
<div className='grid grid-cols-2 gap-4 mb-6'>
<Table
data={informasiUmum}
columns={[
{
header: '',
id: 'label',
accessorKey: 'label',
},
{
header: '',
id: 'value',
accessorKey: 'value',
},
]}
className={{
headerRowClassName: 'hidden',
paginationClassName: 'hidden',
containerClassName: 'mb-0',
}}
/>
<Table
data={informasiTransfer}
columns={[
{
header: '',
id: 'label',
accessorKey: 'label',
},
{
header: '',
id: 'value',
accessorKey: 'value',
},
]}
className={{
headerRowClassName: 'hidden',
paginationClassName: 'hidden',
containerClassName: 'mb-0',
}}
/>
</div>
</Card>
<div className='flex flex-row gap-2 justify-end'>
{FINANCE_TRANSACTION_STATUS.includes(finance.transaction_type) && (
<RequirePermission permissions='lti.finance.payments.update'>
<Button
color='warning'
className='min-w-24'
href={`/finance/detail/edit?financeId=${finance.id}`}
>
<Icon icon='mdi:pencil-outline' />
Edit
</Button>
</RequirePermission>
)}
{FINANCE_INITIAL_BALANCE_STATUS.includes(finance.transaction_type) && (
<RequirePermission permissions='lti.finance.initial_balances.update'>
<Button
color='warning'
className='min-w-24'
href={`/finance/detail/edit/initial-balance?financeId=${finance.id}`}
>
<Icon icon='mdi:pencil-outline' />
Edit
</Button>
</RequirePermission>
)}
{FINANCE_INJECTION_STATUS.includes(finance.transaction_type) && (
<RequirePermission permissions='lti.finance.injections.update'>
<Button
color='warning'
className='min-w-24'
href={`/finance/detail/edit/injection?financeId=${finance.id}`}
>
<Icon icon='mdi:pencil-outline' />
Edit
</Button>
</RequirePermission>
)}
<RequirePermission permissions='lti.finance.transactions.delete'>
<Button
color='error'
className='min-w-24'
onClick={() => deleteModal.openModal()}
>
<Icon icon='mdi:delete-outline' />
Delete
</Button>
</RequirePermission>
</div>
<ConfirmationModal
ref={deleteModal.ref}
type='error'
text={`Apakah anda yakin ingin menghapus data Finance ini (${finance?.payment_code})?`}
secondaryButton={{
text: 'Tidak',
}}
primaryButton={{
text: 'Ya',
color: 'error',
isLoading: isDeleteLoading,
onClick: confirmationModalDeleteClickHandler,
}}
/>
</div>
);
};
export default FinanceDetail;
@@ -0,0 +1,571 @@
import { ChangeEventHandler, useMemo, useState } from 'react';
import { CellContext, Row } from '@tanstack/react-table';
import { useSearchParams } from 'next/navigation';
import useSWR from 'swr';
import Button from '@/components/Button';
import Card from '@/components/Card';
import Dropdown from '@/components/dropdown/Dropdown';
import DateInput from '@/components/input/DateInput';
import DebouncedTextInput from '@/components/input/DebouncedTextInput';
import SelectInput, {
OptionType,
useSelect,
} from '@/components/input/SelectInput';
import Menu from '@/components/menu/Menu';
import MenuItem from '@/components/menu/MenuItem';
import Table from '@/components/Table';
import Tooltip from '@/components/Tooltip';
import { formatCurrency, formatDate, formatTitleCase } from '@/lib/helper';
import { useTableFilter } from '@/services/hooks/useTableFilter';
import { Finance } from '@/types/api/finance/finance';
import {
FINANCE_INITIAL_BALANCE_STATUS,
FINANCE_INJECTION_STATUS,
FINANCE_TRANSACTION_STATUS,
ROWS_OPTIONS,
} from '@/config/constant';
import { FinanceApi } from '@/services/api/finance';
import { isResponseSuccess } from '@/lib/api-helper';
import { BankApi, CustomerApi, SupplierApi } from '@/services/api/master-data';
import { Bank } from '@/types/api/master-data/bank';
import { useModal } from '@/components/Modal';
import ConfirmationModal from '@/components/modal/ConfirmationModal';
import toast from 'react-hot-toast';
import RowOptionsMenuWrapper from '@/components/table/RowOptionsMenuWrapper';
import RequirePermission from '@/components/helper/RequirePermission';
import { Icon } from '@iconify/react';
import RowDropdownOptions from '@/components/table/RowDropdownOptions';
import RowCollapseOptions from '@/components/table/RowCollapseOptions';
const RowOptionsMenu = ({
type = 'dropdown',
props,
deleteClickHandler,
}: {
type: 'dropdown' | 'collapse';
props: CellContext<Finance, unknown>;
deleteClickHandler: () => void;
}) => {
return (
<RowOptionsMenuWrapper type={type}>
<RequirePermission
permissions={[
'lti.finance.transactions.detail',
'lti.finance.initial_balances.detail',
'lti.finance.injections.detail',
'lti.finance.payments.detail',
]}
>
<Button
href={`/finance/detail?financeId=${props.row.original.id}`}
variant='ghost'
color='primary'
className='justify-start text-sm'
>
<Icon icon='mdi:eye-outline' width={16} height={16} />
Detail
</Button>
</RequirePermission>
{FINANCE_TRANSACTION_STATUS.includes(
props.row.original.transaction_type
) && (
<RequirePermission permissions='lti.finance.payments.update'>
<Button
href={`/finance/detail/edit?financeId=${props.row.original.id}`}
variant='ghost'
color='warning'
className='justify-start text-sm'
>
<Icon icon='material-symbols:edit-outline' width={16} height={16} />
Edit
</Button>
</RequirePermission>
)}
{FINANCE_INITIAL_BALANCE_STATUS.includes(
props.row.original.transaction_type
) && (
<RequirePermission permissions='lti.finance.initial_balances.update'>
<Button
href={`/finance/detail/edit/initial-balance?financeId=${props.row.original.id}`}
variant='ghost'
color='warning'
className='justify-start text-sm'
>
<Icon icon='material-symbols:edit-outline' width={16} height={16} />
Edit
</Button>
</RequirePermission>
)}
{FINANCE_INJECTION_STATUS.includes(
props.row.original.transaction_type
) && (
<RequirePermission permissions='lti.finance.injections.update'>
<Button
href={`/finance/detail/edit/injection?financeId=${props.row.original.id}`}
variant='ghost'
color='warning'
className='justify-start text-sm'
>
<Icon icon='material-symbols:edit-outline' width={16} height={16} />
Edit
</Button>
</RequirePermission>
)}
<RequirePermission permissions='lti.finance.transactions.delete'>
<Button
onClick={deleteClickHandler}
variant='ghost'
color='error'
className='text-error hover:text-inherit'
>
<Icon
icon='material-symbols:delete-outline-rounded'
width={16}
height={16}
className='justify-start text-sm'
/>
Delete
</Button>
</RequirePermission>
</RowOptionsMenuWrapper>
);
};
const FinanceTable = () => {
const {
state: tableFilterState,
updateFilter,
setPage,
setPageSize,
toQueryString: getTableFilterQueryString,
} = useTableFilter({
initial: {
search: '',
transactionType: '',
bankId: '',
partyType: '',
sortBy: '',
startDate: '',
endDate: '',
},
paramMap: {
page: 'page',
pageSize: 'limit',
transactionType: 'transaction_type',
bankId: 'bank_id',
partyType: 'party_type',
sortBy: 'sort_date',
startDate: 'start_date',
endDate: 'end_date',
},
});
// ===== State =====
const [searchParams, setSearchParams] = useSearchParams();
const deleteModal = useModal();
const [pendingFilters, setPendingFilters] = useState({
search: '',
transactionType: '',
bankId: '',
partyType: '',
sortBy: '',
startDate: '',
endDate: '',
});
const [selectedTransactionType, setSelectedTransactionType] =
useState<OptionType | null>(null);
const [selectedBank, setSelectedBank] = useState<OptionType | null>(null);
const [selectedPartyType, setSelectedPartyType] = useState<OptionType | null>(
null
);
const [selectedSortBy, setSelectedSortBy] = useState<OptionType | null>(null);
const [selectedFinance, setSelectedFinance] = useState<Finance | null>(null);
const [isDeleteLoading, setIsDeleteLoading] = useState(false);
// ===== Fetch Data =====
const {
data: finances,
isLoading,
mutate: refreshFinances,
} = useSWR(
`${FinanceApi.basePath}/transactions${getTableFilterQueryString()}`,
FinanceApi.getAllFetcher
);
// ===== Options =====
const transactionTypeOptions = useMemo(() => {
return [
{ label: 'Transfer', value: 'TRANSFER' },
{ label: 'Cash', value: 'CASH' },
{ label: 'Card', value: 'CARD' },
{ label: 'Cheque', value: 'CHEQUE' },
{ label: 'Saldo', value: 'SALDO' },
];
}, []);
const partyTypeOptions = useMemo(() => {
return [
{ label: 'Customer', value: 'CUSTOMER' },
{ label: 'Supplier', value: 'SUPPLIER' },
];
}, []);
const sortByOptions = useMemo(() => {
return [
{ label: 'Tanggal Pembayaran', value: 'payment_date' },
{ label: 'Tanggal Dibuat', value: 'created_at' },
];
}, []);
const { options: bankOptions, rawData: bankRawData } = useSelect<Bank>(
BankApi.basePath,
'id',
'alias',
'',
{
limit: 'limit',
}
);
// ===== Handler =====
const searchChangeHandler: ChangeEventHandler<HTMLInputElement> = (e) => {
setPendingFilters((prev) => ({ ...prev, search: e.target.value }));
};
const transactionTypeChangeHandler = (
val: OptionType | OptionType[] | null
) => {
setSelectedTransactionType(val as OptionType);
setPendingFilters((prev) => ({
...prev,
transactionType: val ? ((val as OptionType).value as string) : '',
}));
};
const bankChangeHandler = (val: OptionType | OptionType[] | null) => {
setSelectedBank(val as OptionType);
setPendingFilters((prev) => ({
...prev,
bankId: val ? ((val as OptionType).value as string) : '',
}));
};
const partyTypeChangeHandler = (val: OptionType | OptionType[] | null) => {
setSelectedPartyType(val as OptionType);
setPendingFilters((prev) => ({
...prev,
partyType: val ? ((val as OptionType).value as string) : '',
}));
};
const sortByChangeHandler = (val: OptionType | OptionType[] | null) => {
setSelectedSortBy(val as OptionType);
setPendingFilters((prev) => ({
...prev,
sortBy: val ? ((val as OptionType).value as string) : '',
}));
};
const startDateChangeHandler: ChangeEventHandler<HTMLInputElement> = (e) => {
setPendingFilters((prev) => ({ ...prev, startDate: e.target.value }));
};
const endDateChangeHandler: ChangeEventHandler<HTMLInputElement> = (e) => {
setPendingFilters((prev) => ({ ...prev, endDate: e.target.value }));
};
const pageSizeChangeHandler = (val: OptionType | OptionType[] | null) => {
const newVal = val as OptionType;
setPageSize(newVal.value as number);
};
const submitFilterHandler = () => {
updateFilter('search', pendingFilters.search);
updateFilter('transactionType', pendingFilters.transactionType);
updateFilter('bankId', pendingFilters.bankId);
updateFilter('partyType', pendingFilters.partyType);
updateFilter('sortBy', pendingFilters.sortBy);
updateFilter('startDate', pendingFilters.startDate);
updateFilter('endDate', pendingFilters.endDate);
};
const resetFilterHandler = () => {
setSelectedTransactionType(null);
setSelectedBank(null);
setSelectedPartyType(null);
setSelectedSortBy(null);
const emptyFilters = {
search: '',
transactionType: '',
bankId: '',
partyType: '',
sortBy: '',
startDate: '',
endDate: '',
};
setPendingFilters(emptyFilters);
updateFilter('search', '');
updateFilter('transactionType', '');
updateFilter('bankId', '');
updateFilter('partyType', '');
updateFilter('sortBy', '');
updateFilter('startDate', '');
updateFilter('endDate', '');
};
const confirmationModalDeleteClickHandler = async () => {
setIsDeleteLoading(true);
await FinanceApi.delete(selectedFinance?.id as number);
refreshFinances();
deleteModal.closeModal();
toast.success('Successfully delete Finance!');
setIsDeleteLoading(false);
};
const columns = useMemo(() => {
return [
{
header: 'ID',
accessorKey: 'payment_code',
},
{
header: 'References Number',
accessorKey: 'reference_number',
cell: (props: CellContext<Finance, unknown>) => {
const value = props.row.original.reference_number;
return <span>{value ?? '-'}</span>;
},
},
{
header: 'Jenis Transaksi',
accessorKey: 'transaction_type',
cell: (props: CellContext<Finance, unknown>) => {
const value = props.row.original.transaction_type
.split('_')
.join(' ');
return <span>{formatTitleCase(value)}</span>;
},
},
{
header: 'Pihak',
accessorFn: (finance: Finance) => finance.party.name,
cell: (props: CellContext<Finance, unknown>) => {
if (props.row.original.party.id) {
return <span>{props.row.original.party.name}</span>;
}
return <span>{'-'}</span>;
},
},
{
header: 'Tanggal',
accessorFn: (finance: Finance) =>
formatDate(finance.payment_date, 'DD MMM YYYY'),
},
{
header: 'Metode Pembayaran',
accessorKey: 'payment_method',
cell: (props: CellContext<Finance, unknown>) => {
const value = props.row.original.payment_method.split('_').join(' ');
return <span>{formatTitleCase(value)}</span>;
},
},
{
header: 'Bank',
accessorFn: (finance: Finance) =>
`${finance.bank.alias} - ${finance.bank.account_number} - ${finance.bank.owner}`,
},
{
header: 'Pengeluaran (Rp)',
accessorFn: (finance: Finance) =>
formatCurrency(finance.expense_amount),
},
{
header: 'Pemasukan (Rp)',
accessorFn: (finance: Finance) => formatCurrency(finance.income_amount),
},
{
header: 'Aksi',
cell: (props: CellContext<Finance, unknown>) => {
const currentPageSize =
props.table.getPaginationRowModel().rows.length;
const currentPageRows = props.table.getPaginationRowModel().flatRows;
const currentRowRelativeIndex =
currentPageRows.findIndex((r) => r.id === props.row.id) + 1;
const isLast2Rows = currentRowRelativeIndex > currentPageSize - 2;
const deleteClickHandler = () => {
setSelectedFinance(props.row.original);
deleteModal.openModal();
};
return (
<>
{currentPageSize > 2 && (
<RowDropdownOptions isLast2Rows={isLast2Rows}>
<RowOptionsMenu
type='dropdown'
props={props}
deleteClickHandler={deleteClickHandler}
/>
</RowDropdownOptions>
)}
{currentPageSize <= 2 && (
<RowCollapseOptions>
<RowOptionsMenu
type='collapse'
props={props}
deleteClickHandler={deleteClickHandler}
/>
</RowCollapseOptions>
)}
</>
);
},
},
];
}, []);
return (
<section className='size-full p-6 flex flex-col gap-6'>
<div className='flex justify-end gap-2'>
<RequirePermission permissions='lti.finance.injections.create'>
<Button
color='warning'
className='min-w-24'
href='/finance/add/injection'
>
Injection Saldo Bank
</Button>
</RequirePermission>
<RequirePermission permissions='lti.finance.initial_balances.create'>
<Button
color='info'
className='text-white min-w-24'
href='/finance/add/initial-balance'
>
Saldo Awal
</Button>
</RequirePermission>
<RequirePermission permissions='lti.finance.payments.create'>
<Button color='primary' className='min-w-24' href='/finance/add'>
Tambah
</Button>
</RequirePermission>
</div>
<Card
variant='bordered'
className={{
wrapper: 'w-full',
}}
footer={
<div className='flex justify-end gap-2'>
<Button
color='warning'
className='min-w-24'
onClick={resetFilterHandler}
>
Reset
</Button>
<Button
color='primary'
className='min-w-24'
onClick={submitFilterHandler}
>
Cari
</Button>
</div>
}
>
<div className='grid grid-cols-4 gap-6'>
<SelectInput
options={transactionTypeOptions}
label='Jenis Transaksi'
value={selectedTransactionType}
onChange={transactionTypeChangeHandler}
isClearable
/>
<SelectInput
options={
isResponseSuccess(bankRawData)
? bankOptions.map((bank) => ({
label:
bankRawData.data.find((data) => data.id === bank.value)
?.alias +
' - ' +
bankRawData.data.find((data) => data.id === bank.value)
?.account_number +
' - ' +
bankRawData.data.find((data) => data.id === bank.value)
?.owner,
value: bank.value,
}))
: []
}
label='Bank'
value={selectedBank}
onChange={bankChangeHandler}
isClearable
/>
<SelectInput
options={partyTypeOptions}
label='Pihak'
value={selectedPartyType}
onChange={partyTypeChangeHandler}
isClearable
/>
<DebouncedTextInput
name='search'
label='Cari'
placeholder='Cari'
value={pendingFilters.search}
onChange={searchChangeHandler}
/>
<SelectInput
options={sortByOptions}
label='Urutkan Berdasarkan'
value={selectedSortBy}
onChange={sortByChangeHandler}
isClearable
/>
<DateInput
name='startDate'
label='Periode Tanggal (Mulai)'
value={pendingFilters.startDate}
onChange={startDateChangeHandler}
/>
<DateInput
name='endDate'
label='Periode Tanggal (Akhir)'
value={pendingFilters.endDate}
onChange={endDateChangeHandler}
/>
</div>
</Card>
<Table<Finance>
data={isResponseSuccess(finances) ? finances.data : []}
columns={columns}
pageSize={tableFilterState.pageSize}
page={tableFilterState.page}
onPageChange={setPage}
onPageSizeChange={setPageSize}
totalItems={
isResponseSuccess(finances) ? finances.meta?.total_results : 0
}
isLoading={isLoading}
/>
<ConfirmationModal
ref={deleteModal.ref}
type='error'
text={`Apakah anda yakin ingin menghapus data Finance ini (${selectedFinance?.payment_code})?`}
secondaryButton={{
text: 'Tidak',
}}
primaryButton={{
text: 'Ya',
color: 'error',
isLoading: isDeleteLoading,
onClick: confirmationModalDeleteClickHandler,
}}
/>
</section>
);
};
export default FinanceTable;
@@ -0,0 +1,67 @@
import * as Yup from 'yup';
import { OptionType } from '@/components/input/SelectInput';
/**
* API Payload format:
* {
"party_id": 1,
"party_type": "CUSTOMER",
"payment_date": "2025-11-21",
"payment_method": "Transfer",
"bank_id": 1,
"reference_number": "DO.MBU.123",
"nominal": 25000000,
"notes": "Pembayaran piutang penjualan telur"
}
*/
// Type for form values (includes option objects for SelectInput)
export type FinanceFormValues = {
party_type_option: OptionType | null;
party_id_option: OptionType | null;
party_account_number: string;
payment_date: string;
payment_method_option: OptionType | null;
bank_id_option: OptionType | null;
reference_number: string;
nominal: string;
notes: string;
};
export const FinanceFormSchema = Yup.object().shape({
party_type_option: Yup.mixed()
.nullable()
.test(
'is-valid-option',
'Jenis transaksi wajib diisi',
(value) => value !== null && value !== undefined
),
party_id_option: Yup.mixed()
.nullable()
.test(
'is-valid-option',
'Pihak wajib diisi',
(value) => value !== null && value !== undefined
),
party_account_number: Yup.string().required('Nomor rekening wajib diisi'),
payment_date: Yup.string().required('Tanggal pembayaran wajib diisi'),
payment_method_option: Yup.mixed()
.nullable()
.test(
'is-valid-option',
'Metode pembayaran wajib diisi',
(value) => value !== null && value !== undefined
),
bank_id_option: Yup.mixed()
.nullable()
.test(
'is-valid-option',
'Bank wajib diisi',
(value) => value !== null && value !== undefined
),
reference_number: Yup.string().required('Nomor referensi wajib diisi'),
nominal: Yup.string().required('Nominal wajib diisi'),
notes: Yup.string().required('Catatan wajib diisi'),
});
export const UpdateFinanceFormSchema = FinanceFormSchema;
@@ -0,0 +1,417 @@
'use client';
import Button from '@/components/Button';
import AlertErrorList from '@/components/helper/form/FormErrors';
import { FormHeader } from '@/components/helper/form/FormHeader';
import DateInput from '@/components/input/DateInput';
import NumberInput from '@/components/input/NumberInput';
import SelectInput, {
OptionType,
useSelect,
} from '@/components/input/SelectInput';
import TextArea from '@/components/input/TextArea';
import TextInput from '@/components/input/TextInput';
import {
FinanceFormSchema,
FinanceFormValues,
} from '@/components/pages/finance/add/FormFinanceAdd.schema';
import {
FINANCE_PARTY_TYPE_OPTIONS,
FINANCE_PAYMENT_METHOD_OPTIONS,
} from '@/config/constant';
import { isResponseError, isResponseSuccess } from '@/lib/api-helper';
import { formatDate, formatTitleCase } from '@/lib/helper';
import { useFormikErrorList } from '@/services/hooks/useFormikErrorList';
import { FinanceApi } from '@/services/api/finance';
import { BankApi, CustomerApi, SupplierApi } from '@/services/api/master-data';
import {
CreateFinancePayment,
Finance,
UpdateFinancePayment,
} from '@/types/api/finance/finance';
import { Bank } from '@/types/api/master-data/bank';
import { useFormik } from 'formik';
import { useRouter } from 'next/navigation';
import { useCallback, useMemo } from 'react';
import toast from 'react-hot-toast';
interface FormFinanceAddProps {
type?: 'add' | 'edit';
initialValues?: Finance;
}
interface PartyCommonProps {
id: number;
name: string;
account_number: string;
}
const FormFinanceAdd = ({
type = 'add',
initialValues,
}: FormFinanceAddProps) => {
const router = useRouter();
// ===== Formik =====
const formikInitialValues = useMemo((): FinanceFormValues => {
return {
party_type_option:
FINANCE_PARTY_TYPE_OPTIONS.find(
(option) => option.value === initialValues?.party.type
) || null,
party_id_option: initialValues?.party
? {
label: initialValues?.party.name || '',
value: initialValues?.party.id || 0,
}
: null,
payment_date: initialValues?.payment_date || '',
payment_method_option:
FINANCE_PAYMENT_METHOD_OPTIONS.find(
(option) => option.value === initialValues?.payment_method
) || null,
bank_id_option: initialValues?.bank
? {
label: initialValues.bank.name,
value: initialValues.bank.id,
}
: null,
party_account_number: initialValues?.party.account_number || '',
reference_number: initialValues?.reference_number || '',
nominal: initialValues?.nominal.toString() || '',
notes: initialValues?.notes || '',
};
}, [initialValues]);
const formik = useFormik<FinanceFormValues>({
initialValues: formikInitialValues,
validationSchema: FinanceFormSchema,
validateOnChange: true,
validateOnBlur: true,
onSubmit: async (values) => {
const payload = transformFormValuesToPayload(values);
switch (type) {
case 'add':
await createFinance(payload);
break;
case 'edit':
if (initialValues?.id) {
await updateFinance(initialValues.id, payload);
}
break;
}
},
});
// ===== Formik Error List =====
const { formErrorList, close, handleFormSubmit } = useFormikErrorList(formik);
// ===== Options =====
const {
options: partyOptions,
isLoadingOptions: isLoadingPartyOptions,
rawData: partyRawData,
} = useSelect<PartyCommonProps>(
formik.values.party_type_option?.value === 'CUSTOMER'
? CustomerApi.basePath
: SupplierApi.basePath,
'id',
'name',
'',
{ limit: 'limit' }
);
const {
options: bankOptions,
rawData: bankRawData,
isLoadingOptions: isLoadingBankOptions,
} = useSelect<Bank>(BankApi.basePath, 'id', 'name', '', { limit: 'limit' });
// ===== Helper Functions =====
const transformFormValuesToPayload = (
values: FinanceFormValues
): CreateFinancePayment => {
return {
party_id: Number(values.party_id_option?.value) || 0,
party_type: (values.party_type_option?.value as string) || '',
payment_date: formatDate(values.payment_date, 'YYYY-MM-DD'),
payment_method: (values.payment_method_option?.value as string) || '',
bank_id: Number(values.bank_id_option?.value) || 0,
reference_number: values.reference_number,
nominal: Number(values.nominal.replace(/\D/g, '')) || 0,
notes: values.notes,
};
};
// ===== Handler =====
const createFinance = useCallback(
async (payload: CreateFinancePayment) => {
const response = await FinanceApi.create(payload);
if (isResponseError(response)) {
toast.error(response.message);
return;
}
toast.success('Data berhasil ditambahkan');
router.refresh();
router.push('/finance');
},
[router]
);
const updateFinance = useCallback(
async (financeId: number, payload: UpdateFinancePayment) => {
const response = await FinanceApi.update(financeId, payload);
if (isResponseError(response)) {
toast.error(response.message);
return;
}
toast.success('Data berhasil diperbarui');
router.refresh();
router.push('/finance');
},
[router]
);
return (
<>
<section className='w-full max-w-xl mx-auto'>
<div className='flex flex-col gap-6 p-6'>
<FormHeader
title={`${type === 'add' ? 'Tambah' : 'Ubah'} Data Keuangan`}
backUrl='/finance'
/>
<form className='flex flex-col gap-4' onSubmit={handleFormSubmit}>
<SelectInput
label='Jenis Transaksi'
placeholder='Pilih jenis transaksi'
options={FINANCE_PARTY_TYPE_OPTIONS}
value={formik.values.party_type_option}
onChange={(value) => {
formik.setFieldValue('party_type_option', value);
formik.setFieldValue('party_id_option', null);
formik.setFieldValue('party_account_number', '');
}}
isError={Boolean(
formik.touched.party_type_option &&
formik.errors.party_type_option
)}
errorMessage={
formik.touched.party_type_option &&
formik.errors.party_type_option
? formik.errors.party_type_option
: ''
}
required
isClearable
/>
<SelectInput
label={
formik.values.party_type_option?.value
? formatTitleCase(
formik.values.party_type_option.value as string
)
: 'Pilih Jenis Transaksi Dahulu'
}
placeholder={`Pilih ${formik.values.party_type_option?.value ? formatTitleCase(formik.values.party_type_option.value as string) : 'jenis transaksi dahulu'}`}
options={partyOptions}
value={formik.values.party_id_option}
onChange={(value) => {
formik.setFieldValue('party_id_option', value);
if (isResponseSuccess(partyRawData) && value) {
formik.setFieldValue(
'party_account_number',
partyRawData.data?.find(
(item) => item.id === (value as OptionType)?.value
)?.account_number || ''
);
}
}}
isLoading={isLoadingPartyOptions}
isError={Boolean(
formik.touched.party_id_option && formik.errors.party_id_option
)}
errorMessage={
formik.touched.party_id_option && formik.errors.party_id_option
? formik.errors.party_id_option
: ''
}
required
isClearable
isDisabled={!formik.values.party_type_option?.value}
/>
<DateInput
label='Tanggal'
placeholder='Pilih tanggal'
name='payment_date'
value={formik.values.payment_date}
onChange={formik.handleChange}
onBlur={formik.handleBlur}
isError={Boolean(
formik.touched.payment_date && formik.errors.payment_date
)}
errorMessage={
formik.touched.payment_date && formik.errors.payment_date
? formik.errors.payment_date
: ''
}
required
/>
<SelectInput
label='Metode Pembayaran'
placeholder='Pilih metode pembayaran'
options={FINANCE_PAYMENT_METHOD_OPTIONS}
value={formik.values.payment_method_option}
onChange={(value) => {
formik.setFieldValue('payment_method_option', value);
}}
isError={Boolean(
formik.touched.payment_method_option &&
formik.errors.payment_method_option
)}
errorMessage={
formik.touched.payment_method_option &&
formik.errors.payment_method_option
? formik.errors.payment_method_option
: ''
}
required
isClearable
/>
<SelectInput
label='Bank'
placeholder='Pilih bank'
options={
isResponseSuccess(bankRawData)
? bankOptions.map((option) => ({
label:
bankRawData.data?.find(
(item) => item.id === option.value
)?.alias +
' - ' +
bankRawData.data?.find(
(item) => item.id === option.value
)?.account_number +
' - ' +
bankRawData.data?.find(
(item) => item.id === option.value
)?.owner,
value: option.value,
}))
: []
}
value={formik.values.bank_id_option}
onChange={(value) => {
formik.setFieldValue('bank_id_option', value);
}}
isLoading={isLoadingBankOptions}
isError={Boolean(
formik.touched.bank_id_option && formik.errors.bank_id_option
)}
errorMessage={
formik.touched.bank_id_option && formik.errors.bank_id_option
? formik.errors.bank_id_option
: ''
}
required
isClearable
/>
<TextInput
label={`Nomor Rekening ${formik.values.party_type_option?.value ? formatTitleCase(formik.values.party_type_option.value as string) : 'Pihak'}`}
placeholder={`Masukkan nomor rekening ${formik.values.party_type_option?.value ? formatTitleCase(formik.values.party_type_option.value as string) : 'pihak'}`}
name='party_account_number'
value={formik.values.party_account_number}
onChange={formik.handleChange}
onBlur={formik.handleBlur}
isError={Boolean(
formik.touched.party_account_number &&
formik.errors.party_account_number
)}
errorMessage={
formik.touched.party_account_number &&
formik.errors.party_account_number
? formik.errors.party_account_number
: ''
}
required
readOnly
/>
<TextInput
label='Nomor Referensi'
placeholder='Masukkan nomor referensi'
name='reference_number'
value={formik.values.reference_number}
onChange={formik.handleChange}
onBlur={formik.handleBlur}
isError={Boolean(
formik.touched.reference_number &&
formik.errors.reference_number
)}
errorMessage={
formik.touched.reference_number &&
formik.errors.reference_number
? formik.errors.reference_number
: ''
}
required
/>
<NumberInput
label='Nominal'
placeholder='Masukkan nominal'
name='nominal'
value={formik.values.nominal}
onChange={formik.handleChange}
onBlur={formik.handleBlur}
isError={Boolean(formik.touched.nominal && formik.errors.nominal)}
errorMessage={
formik.touched.nominal && formik.errors.nominal
? formik.errors.nominal
: ''
}
required
/>
<TextArea
label='Catatan'
placeholder='Masukkan catatan'
name='notes'
value={formik.values.notes}
onChange={formik.handleChange}
onBlur={formik.handleBlur}
isError={Boolean(formik.touched.notes && formik.errors.notes)}
errorMessage={
formik.touched.notes && formik.errors.notes
? formik.errors.notes
: ''
}
required
/>
<AlertErrorList formErrorList={formErrorList} onClose={close} />
<div className='flex justify-center gap-4'>
<Button
type='reset'
color='warning'
className='w-min-24'
onClick={() => formik.resetForm()}
disabled={formik.isSubmitting}
>
Reset
</Button>
<Button
type='submit'
className='w-min-24'
disabled={formik.isSubmitting || !formik.isValid}
>
Submit
</Button>
</div>
</form>
</div>
</section>
</>
);
};
export default FormFinanceAdd;
@@ -0,0 +1,49 @@
import * as Yup from 'yup';
import { OptionType } from '@/components/input/SelectInput';
// Type for form values (includes option objects for SelectInput)
export type InitialBalanceFormValues = {
party_type_option: OptionType | null;
party_id_option: OptionType | null;
bank_id_option: OptionType | null;
reference_number: string;
initial_balance_type_option: OptionType | null;
nominal: string;
note: string;
};
export const InitialBalanceFormSchema = Yup.object().shape({
party_type_option: Yup.mixed()
.nullable()
.test(
'is-valid-option',
'Jenis pihak wajib diisi',
(value) => value !== null && value !== undefined
),
party_id_option: Yup.mixed()
.nullable()
.test(
'is-valid-option',
'Pihak wajib diisi',
(value) => value !== null && value !== undefined
),
bank_id_option: Yup.mixed()
.nullable()
.test(
'is-valid-option',
'Bank wajib diisi',
(value) => value !== null && value !== undefined
),
reference_number: Yup.string().required('Nomor referensi wajib diisi'),
initial_balance_type_option: Yup.mixed()
.nullable()
.test(
'is-valid-option',
'Tipe saldo awal wajib diisi',
(value) => value !== null && value !== undefined
),
nominal: Yup.string().required('Nominal wajib diisi'),
note: Yup.string().required('Catatan wajib diisi'),
});
export const UpdateInitialBalanceFormSchema = InitialBalanceFormSchema;
@@ -0,0 +1,383 @@
'use client';
import Button from '@/components/Button';
import AlertErrorList from '@/components/helper/form/FormErrors';
import { FormHeader } from '@/components/helper/form/FormHeader';
import NumberInput from '@/components/input/NumberInput';
import SelectInput, { useSelect } from '@/components/input/SelectInput';
import TextArea from '@/components/input/TextArea';
import TextInput from '@/components/input/TextInput';
import {
InitialBalanceFormSchema,
InitialBalanceFormValues,
} from '@/components/pages/finance/add/initial-balance/FormFinanceAddInitialBalance.schema';
import {
FINANCE_INITIAL_BALANCE_TYPE_OPTIONS,
FINANCE_PARTY_TYPE_OPTIONS,
} from '@/config/constant';
import { useFormikErrorList } from '@/services/hooks/useFormikErrorList';
import { isResponseError, isResponseSuccess } from '@/lib/api-helper';
import { formatTitleCase } from '@/lib/helper';
import { FinanceApi } from '@/services/api/finance';
import { BankApi, CustomerApi, SupplierApi } from '@/services/api/master-data';
import {
CreateInitialBalance,
Finance,
UpdateInitialBalance,
} from '@/types/api/finance/finance';
import { Bank } from '@/types/api/master-data/bank';
import { Icon } from '@iconify/react';
import { useFormik } from 'formik';
import { useRouter } from 'next/navigation';
import { useCallback, useMemo } from 'react';
import toast from 'react-hot-toast';
interface FormFinanceAddInitialBalanceProps {
type?: 'add' | 'edit';
initialValues?: Finance;
}
const FormFinanceAddInitialBalance = ({
type = 'add',
initialValues,
}: FormFinanceAddInitialBalanceProps) => {
const router = useRouter();
// ===== Formik =====
const formikInitialValues = useMemo((): InitialBalanceFormValues => {
// Type assertion to handle potential initial_balance_type field
const extendedInitialValues = initialValues as Finance & {
initial_balance_type?: string;
};
return {
party_type_option:
FINANCE_PARTY_TYPE_OPTIONS.find(
(option) => option.value === initialValues?.party.type
) || null,
party_id_option: initialValues?.party
? {
label: initialValues.party.name,
value: initialValues.party.id,
}
: null,
bank_id_option: initialValues?.bank
? {
label: initialValues.bank.name,
value: initialValues.bank.id,
}
: null,
reference_number: initialValues?.reference_number || '',
initial_balance_type_option:
(initialValues?.nominal ?? 0) < 0
? FINANCE_INITIAL_BALANCE_TYPE_OPTIONS.find(
(option) => option.value === 'NEGATIVE'
) || null
: FINANCE_INITIAL_BALANCE_TYPE_OPTIONS.find(
(option) => option.value === 'POSITIVE'
) || null,
nominal: initialValues?.nominal?.toString() || '',
note: initialValues?.notes || '',
};
}, [initialValues]);
const formik = useFormik<InitialBalanceFormValues>({
initialValues: formikInitialValues,
validationSchema: InitialBalanceFormSchema,
validateOnChange: true,
validateOnBlur: true,
onSubmit: async (values) => {
const payload = transformFormValuesToPayload(values);
switch (type) {
case 'add':
await createInitialBalance(payload);
break;
case 'edit':
if (initialValues?.id) {
await updateInitialBalance(initialValues.id, payload);
}
break;
}
},
});
// ===== Options =====
const { options: partyOptions, isLoadingOptions: isLoadingPartyOptions } =
useSelect(
formik.values.party_type_option?.value === 'CUSTOMER'
? CustomerApi.basePath
: SupplierApi.basePath,
'id',
'name',
'',
{ limit: 'limit' }
);
const {
options: bankOptions,
rawData: bankRawData,
isLoadingOptions: isLoadingBankOptions,
} = useSelect<Bank>(BankApi.basePath, 'id', 'name', '', { limit: 'limit' });
// ===== Helper Functions =====
const transformFormValuesToPayload = (
values: InitialBalanceFormValues
): CreateInitialBalance => {
return {
party_type: (values.party_type_option?.value as string) || '',
party_id: Number(values.party_id_option?.value) || 0,
bank_id: Number(values.bank_id_option?.value) || 0,
reference_number: values.reference_number,
initial_balance_type:
(values.initial_balance_type_option?.value as string) || '',
nominal: Number(values.nominal.replace(/\D/g, '')) || 0,
note: values.note,
};
};
// ===== Handler =====
const createInitialBalance = useCallback(
async (payload: CreateInitialBalance) => {
const response = await FinanceApi.createInitialBalances(payload);
if (isResponseError(response)) {
toast.error(response.message);
return;
}
toast.success('Saldo awal berhasil ditambahkan');
router.refresh();
router.push('/finance');
},
[router]
);
const updateInitialBalance = useCallback(
async (financeId: number, payload: UpdateInitialBalance) => {
const response = await FinanceApi.updateInitialBalances(
financeId,
payload
);
if (isResponseError(response)) {
toast.error(response.message);
return;
}
toast.success('Saldo awal berhasil diperbarui');
router.refresh();
router.push('/finance');
},
[router]
);
// ===== Formik Error List =====
const { formErrorList, close, handleFormSubmit } = useFormikErrorList(formik);
return (
<>
<section className='w-full max-w-xl mx-auto'>
<div className='flex flex-col gap-6 p-6'>
<FormHeader
title={`${type === 'add' ? 'Tambah' : 'Ubah'} Saldo Awal`}
backUrl='/finance'
/>
<form className='flex flex-col gap-4' onSubmit={handleFormSubmit}>
<SelectInput
label='Jenis Pihak'
placeholder='Pilih jenis pihak'
options={FINANCE_PARTY_TYPE_OPTIONS}
value={formik.values.party_type_option}
onChange={(value) => {
formik.setFieldValue('party_type_option', value);
formik.setFieldValue('party_id_option', null);
formik.setFieldValue('party_account_number', '');
}}
isError={Boolean(
formik.touched.party_type_option &&
formik.errors.party_type_option
)}
errorMessage={
formik.touched.party_type_option &&
formik.errors.party_type_option
? formik.errors.party_type_option
: ''
}
required
isClearable
/>
<SelectInput
label={
formik.values.party_type_option?.value
? formatTitleCase(
formik.values.party_type_option.value as string
)
: 'Pilih Jenis Pihak Dahulu'
}
placeholder={`Pilih ${formik.values.party_type_option?.value ? formatTitleCase(formik.values.party_type_option.value as string) : 'jenis pihak dahulu'}`}
options={partyOptions}
value={formik.values.party_id_option}
onChange={(value) => {
formik.setFieldValue('party_id_option', value);
}}
isLoading={isLoadingPartyOptions}
isError={Boolean(
formik.touched.party_id_option && formik.errors.party_id_option
)}
errorMessage={
formik.touched.party_id_option && formik.errors.party_id_option
? formik.errors.party_id_option
: ''
}
required
isClearable
isDisabled={!formik.values.party_type_option?.value}
/>
<SelectInput
label='Bank'
placeholder='Pilih bank'
options={
isResponseSuccess(bankRawData)
? bankOptions.map((option) => ({
label:
bankRawData.data?.find(
(item) => item.id === option.value
)?.alias +
' - ' +
bankRawData.data?.find(
(item) => item.id === option.value
)?.account_number +
' - ' +
bankRawData.data?.find(
(item) => item.id === option.value
)?.owner,
value: option.value,
}))
: []
}
value={formik.values.bank_id_option}
onChange={(value) => {
formik.setFieldValue('bank_id_option', value);
}}
isLoading={isLoadingBankOptions}
isError={Boolean(
formik.touched.bank_id_option && formik.errors.bank_id_option
)}
errorMessage={
formik.touched.bank_id_option && formik.errors.bank_id_option
? formik.errors.bank_id_option
: ''
}
required
isClearable
/>
<TextInput
label='Nomor Referensi'
placeholder='Masukkan nomor referensi'
name='reference_number'
value={formik.values.reference_number}
onChange={formik.handleChange}
onBlur={formik.handleBlur}
isError={Boolean(
formik.touched.reference_number &&
formik.errors.reference_number
)}
errorMessage={
formik.touched.reference_number &&
formik.errors.reference_number
? formik.errors.reference_number
: ''
}
required
/>
<SelectInput
label='Tipe Saldo Awal'
placeholder='Pilih tipe saldo awal'
options={FINANCE_INITIAL_BALANCE_TYPE_OPTIONS}
value={formik.values.initial_balance_type_option}
onChange={(value) => {
formik.setFieldValue('initial_balance_type_option', value);
}}
isError={Boolean(
formik.touched.initial_balance_type_option &&
formik.errors.initial_balance_type_option
)}
errorMessage={
formik.touched.initial_balance_type_option &&
formik.errors.initial_balance_type_option
? formik.errors.initial_balance_type_option
: ''
}
required
isClearable
/>
<NumberInput
label='Nominal'
placeholder='Masukkan nominal'
name='nominal'
value={formik.values.nominal}
onChange={formik.handleChange}
onBlur={formik.handleBlur}
isError={Boolean(formik.touched.nominal && formik.errors.nominal)}
errorMessage={
formik.touched.nominal && formik.errors.nominal
? formik.errors.nominal
: ''
}
allowNegative={false}
startAdornment={
formik.values.initial_balance_type_option?.value ===
'POSITIVE' ? (
<Icon icon='mdi:plus' />
) : formik.values.initial_balance_type_option?.value ===
'NEGATIVE' ? (
<Icon icon='mdi:minus' />
) : (
''
)
}
required
/>
<TextArea
label='Catatan'
placeholder='Masukkan catatan'
name='note'
value={formik.values.note}
onChange={formik.handleChange}
onBlur={formik.handleBlur}
isError={Boolean(formik.touched.note && formik.errors.note)}
errorMessage={
formik.touched.note && formik.errors.note
? formik.errors.note
: ''
}
required
/>
<AlertErrorList formErrorList={formErrorList} onClose={close} />
<div className='flex justify-center gap-4'>
<Button
type='reset'
color='warning'
className='w-min-24'
onClick={() => formik.resetForm()}
disabled={formik.isSubmitting}
>
Reset
</Button>
<Button
type='submit'
className='w-min-24'
disabled={formik.isSubmitting || !formik.isValid}
>
Submit
</Button>
</div>
</form>
</div>
</section>
</>
);
};
export default FormFinanceAddInitialBalance;
@@ -0,0 +1,25 @@
import { OptionType } from '@/components/input/SelectInput';
import * as Yup from 'yup';
// Type for form values (includes option objects for SelectInput)
export type InjectionFormValues = {
bank_id_option: OptionType | null;
adjustment_date: string;
nominal: string;
note: string;
};
export const InjectionFormSchema = Yup.object<InjectionFormValues>({
bank_id_option: Yup.mixed()
.nullable()
.test(
'is-valid-option',
'Bank wajib diisi',
(value) => value !== null && value !== undefined
),
adjustment_date: Yup.string().required('Tanggal penyesuaian wajib diisi'),
nominal: Yup.string().required('Nominal wajib diisi'),
note: Yup.string().required('Catatan wajib diisi'),
});
export const UpdateInjectionFormSchema = InjectionFormSchema;

Some files were not shown because too many files have changed in this diff Show More