Compare commits

..

739 Commits

Author SHA1 Message Date
kris ead5ba759d Update .gitlab-ci.yml file 2025-12-18 10:00:38 +00:00
Adnan Zahir 224f7ddeea Merge branch 'feat/FE/US-284/sapronak-calculation-report' into 'development'
[FEAT/FE][US#284] Add Feature Perhitungan Sapronak Closing Report

See merge request mbugroup/lti-web-client!98
2025-12-16 15:00:47 +07:00
randy-ar f58b03ba0e fix(FE): revert auth component 2025-12-16 14:24:52 +07:00
randy-ar d348cee4e6 fix(FE): resolve merge conflict 2025-12-16 14:17:23 +07:00
Adnan Zahir be238779a4 Merge branch 'dev/hotfix/restu' into 'development'
[HOTFIX/FE] Fixing Recording and Approval Button

See merge request mbugroup/lti-web-client!97
2025-12-16 13:57:24 +07:00
Adnan Zahir 8db7b6d5e9 Merge branch 'feat/FE/US-279/closing-button' into 'development'
[FEAT/FE][US#279] Add Feature Closing Produksi (Project Flock)

See merge request mbugroup/lti-web-client!96
2025-12-16 13:56:20 +07:00
Rivaldi A N S ebe752b27b Merge branch 'feat/FE/US-284/TASK-324-325-slicing-and-integration-sapronak-calculation-closing-report' into 'feat/FE/US-284/sapronak-calculation-report'
[FEAT/FE][US#284/TASK#324-325] Add Feature Perhitungan Sapronak Closing Report

See merge request mbugroup/lti-web-client!71
2025-12-15 07:54:59 +00:00
rstubryan 3dd36b8248 fix(FE): Parse recordingId and hide actions for rejected 2025-12-11 11:05:20 +07:00
rstubryan 12698004e1 fix(FE): Update recording detail links to include production path 2025-12-11 10:47:25 +07:00
rstubryan a0ca8e8f69 Merge branch 'feat/FE/US-279/closing-button' of gitlab.com:mbugroup/lti-web-client into dev/hotfix/restu 2025-12-11 10:46:52 +07:00
rstubryan 69206d4524 fix(FE): Update recording detail links to include production path 2025-12-11 10:46:38 +07:00
rstubryan a73f9a1acd fix(FE): Update recording detail links to include production path 2025-12-11 10:46:21 +07:00
Rivaldi A N S 48649df409 Merge branch 'dev/randy' into 'feat/FE/US-279/closing-button'
[FEAT/FE][US#279/TASK#312-313] Add Feature Closing Produksi (Project Flock)

See merge request mbugroup/lti-web-client!72
2025-12-10 18:06:46 +00:00
randy-ar c53f9352be fix(FE): closing project flock & merge development 2025-12-11 00:32:54 +07:00
Adnan Zahir df632526d2 Merge branch 'dev/hotfix/restu' into 'development'
[HOTFIX/FE] Fixing Credit Term issue on Purchase

See merge request mbugroup/lti-web-client!95
2025-12-11 00:10:33 +07:00
rstubryan 4ec455b3b7 feat(FE): Add credit_term to purchase forms and types 2025-12-10 23:54:59 +07:00
randy-ar 4f4fd3e6b7 fix(FE): pull development 2025-12-10 23:19:43 +07:00
Adnan Zahir 0d7dd0a110 Merge branch 'feat/FE/US-278/purchase-and-expense' into 'development'
[FEAT/FE][US#278] Adjust Purchase Request and Purchase Order (Expense Extended)

See merge request mbugroup/lti-web-client!86
2025-12-10 23:18:50 +07:00
Adnan Zahir 9bf4fd585d Merge branch 'feat/FE/US-282/egg-grading-adjustment' into 'development'
[FEAT/FE][US#282] Adjustment Recording Egg Grading

See merge request mbugroup/lti-web-client!85
2025-12-10 23:18:20 +07:00
kris a77a360410 Merge branch 'fix/redirect-error' into 'development'
[HOTFIX/FE] Fixing redirect issues

See merge request mbugroup/lti-web-client!94
2025-12-10 15:31:00 +00:00
ValdiANS 9628ee88ad chore: add condition for redirecting to SSO 2025-12-10 21:47:58 +07:00
ValdiANS 4356bd8803 fix: remove redirectToSSO 2025-12-10 21:43:05 +07:00
kris cbf1660da5 Merge branch 'fix/redirect-error' into 'development'
[HOTFIX/FE] Fixing redirect issues

See merge request mbugroup/lti-web-client!93
2025-12-10 11:53:47 +00:00
ValdiANS 37f59f9470 fix: remove unnecessary code 2025-12-10 18:50:58 +07:00
kris 6e3b25eb98 Merge branch 'fix/redirect-error' into 'development'
[HOTFIX/FE] Fixing redirect issues

See merge request mbugroup/lti-web-client!92
2025-12-10 11:11:50 +00:00
ValdiANS f939f4b0fb fix: return children only if userResponse success and user is set 2025-12-10 18:10:08 +07:00
ValdiANS 720ff2128f fix: add use-client and export dynamic 2025-12-10 18:09:30 +07:00
ValdiANS 280fffe6a5 fix: add use-client 2025-12-10 18:09:21 +07:00
ValdiANS 6340a5e519 fix: export dynamic 2025-12-10 18:09:10 +07:00
kris d4fc0b4a4f Merge branch 'fix/redirect-error' into 'development'
[HOTFIX/FE] Fixing redirect issues

See merge request mbugroup/lti-web-client!91
2025-12-10 10:32:40 +00:00
ValdiANS 4f595c7cad chore: wrap router.replace in useEffect 2025-12-10 17:31:21 +07:00
ValdiANS 3826b8ea53 feat: set trailingSlash to true 2025-12-10 17:31:06 +07:00
kris 5cc82f1615 Merge branch 'fix/redirect-error' into 'development'
[HOTFIX/FE] Fixing redirect issues

See merge request mbugroup/lti-web-client!90
2025-12-10 10:16:33 +00:00
ValdiANS cfaac14820 chore: return loading text if all condition unmet 2025-12-10 17:15:23 +07:00
kris b39d1f5c2e Merge branch 'fix/redirect-error' into 'development'
[HOTFIX/FE] Fixing redirect issues

See merge request mbugroup/lti-web-client!89
2025-12-10 10:08:42 +00:00
ValdiANS 30ab48e426 fix: redirect to dashboard if pathname is in root path 2025-12-10 17:07:44 +07:00
kris 88c640df18 Merge branch 'fix/redirect-error' into 'development'
[HOTFIX/FE] Fixing redirect issues

See merge request mbugroup/lti-web-client!88
2025-12-10 10:00:08 +00:00
ValdiANS 017b081832 fix: redirect to SSO if user isnt exist and show loading state if still loading user 2025-12-10 16:57:45 +07:00
ValdiANS 83d76f7de4 fix: set isLoadingUser in useAuth hook 2025-12-10 16:57:20 +07:00
randy-ar 9af140e58d fix(FE): fix merge conflict 2025-12-10 16:56:25 +07:00
randy-ar 654aa50cc7 fix(FE): fix merge conflict 2025-12-10 16:53:50 +07:00
randy-ar 814e8db1ba fix(FE): resolve merge conflict development 2025-12-10 16:45:54 +07:00
randy-ar d1883654bc fix(FE): resolve merge conflict development 2025-12-10 16:44:52 +07:00
kris 2c6ad71fd3 Update .gitlab-ci.yml file 2025-12-10 09:42:13 +00:00
randy-ar 6c31d933b0 fix(FE): resolve merge conflict 2025-12-10 16:41:21 +07:00
Mitra Berlian Unggas b806c0f0a1 Merge branch 'fix/redirect-error' into 'development'
[HOTFIX/FE] Fixing redirect issues

See merge request mbugroup/lti-web-client!87
2025-12-10 09:36:29 +00:00
randy-ar a073488c2c fix(FE): fixing closing project flock and fetching data in closing report 2025-12-10 16:32:50 +07:00
Rivaldi A N S 7efb2a4dbb Merge branch 'feat/FE/US-278/TASK-311-adjustment-purchase-and-expense' into 'feat/FE/US-278/purchase-and-expense'
[FEAT/FE][US#278/TASK-311] Adjust Purchase Request and Purchase Order (Expense Extended)

See merge request mbugroup/lti-web-client!83
2025-12-10 09:27:50 +00:00
Rivaldi A N S 01d1ed8f0d Merge branch 'feat/FE/US-282/TASK-318-319-slicing-and-adjustment-egg-grading-form' into 'feat/FE/US-282/egg-grading-adjustment'
[FEAT/FE][US#282/TASK-318-319] Adjustment Recording Egg Grading

See merge request mbugroup/lti-web-client!84
2025-12-10 09:25:32 +00:00
ValdiANS aed58ef10c hotfix: Implement client-side dashboard redirect with loading spinner, improve authentication error handling by clearing user state on 401, and extend SSO redirect loop protection. 2025-12-10 16:23:51 +07:00
rstubryan f105852a07 Merge branch 'development' of gitlab.com:mbugroup/lti-web-client into feat/FE/US-282/TASK-318-319-slicing-and-adjustment-egg-grading-form 2025-12-10 15:52:30 +07:00
rstubryan 21d6fc8579 Merge branch 'development' of gitlab.com:mbugroup/lti-web-client into feat/FE/US-278/TASK-311-adjustment-purchase-and-expense 2025-12-10 15:44:58 +07:00
kris eea1fcb513 Update .gitlab-ci.yml file 2025-12-10 08:43:08 +00:00
rstubryan 7c4d5e68fa Merge branch 'development' of gitlab.com:mbugroup/lti-web-client into feat/FE/US-282/TASK-318-319-slicing-and-adjustment-egg-grading-form 2025-12-10 15:36:36 +07:00
rstubryan b74e43c483 Merge branch 'development' of gitlab.com:mbugroup/lti-web-client into feat/FE/US-278/TASK-311-adjustment-purchase-and-expense 2025-12-10 15:36:12 +07:00
Adnan Zahir dbff1bda3d Merge branch 'dev/hotfix/restu' into 'development'
[HOTFIX/FE] Fixing Penjualan Tabs (Misplacement Issue)

See merge request mbugroup/lti-web-client!81
2025-12-10 15:33:54 +07:00
Adnan Zahir 244c564f06 Merge branch 'fix/redirect-error' into 'development'
[HOTFIX/FE] Fixing redirect issues

See merge request mbugroup/lti-web-client!82
2025-12-10 15:31:31 +07:00
ValdiANS 757e0435ac hotfix: use redirectToSSO function 2025-12-10 15:21:46 +07:00
ValdiANS 46d70e36dd feat: create auth-helper file and redirectToSSO helper function 2025-12-10 15:21:10 +07:00
ValdiANS 0cc9d0e94e hotfix: Centralize SSO redirection logic into a new helper with loop protection, integrate it into the HTTP client and RequireAuth component, and add an authentication failure UI. 2025-12-10 15:18:37 +07:00
rstubryan d7199fad53 hotfix(FE): Pass sales data to ClosingDetail and fix sales API 2025-12-10 15:05:52 +07:00
rstubryan 8c2683c440 Merge branch 'development' of gitlab.com:mbugroup/lti-web-client into dev/restu 2025-12-10 14:34:12 +07:00
rstubryan b9e69b243f Merge branch 'development' of gitlab.com:mbugroup/lti-web-client into feat/FE/US-282/TASK-318-319-slicing-and-adjustment-egg-grading-form 2025-12-10 13:59:04 +07:00
rstubryan 8dec4915a2 Merge branch 'development' of gitlab.com:mbugroup/lti-web-client into feat/FE/US-278/TASK-311-adjustment-purchase-and-expense 2025-12-10 13:57:07 +07:00
rstubryan 7be32326a9 feat(FE-311): Disable approval actions when rejected 2025-12-10 13:56:13 +07:00
randy-ar c416fdbdaa fix(FE): resolve conflit merge development 2025-12-10 13:51:19 +07:00
Adnan Zahir 270e8ff0c6 Merge branch 'dev/hot-fix/randy' into 'development'
[HOTFIX/FE] Fixing Dropdown Button Logout

See merge request mbugroup/lti-web-client!80
2025-12-10 13:44:20 +07:00
Adnan Zahir 64abc5001d Merge branch 'feat/FE/US-285/marketing-closing-report' into 'development'
[FEAT/FE][US#285] Add Feature Marketing Closing Report (Sales/Penjualan)

See merge request mbugroup/lti-web-client!77
2025-12-10 13:38:26 +07:00
randy-ar f48cfca650 fix(FE): revert require auth component 2025-12-10 13:35:42 +07:00
rstubryan a116f7ca66 fix(FE): Remove closing detail page and layout 2025-12-10 13:32:29 +07:00
rstubryan 429f5ffb62 feat(FE-311): Add rejection modals and accept handler 2025-12-10 13:30:40 +07:00
randy-ar eed142a85f hotfix(FE): fixing dropdown logout and floating button max size 2025-12-10 13:25:07 +07:00
rstubryan 48f228de1c Merge branch 'development' of gitlab.com:mbugroup/lti-web-client into feat/FE/US-278/TASK-311-adjustment-purchase-and-expense 2025-12-10 13:08:36 +07:00
rstubryan c92abfc9ab Merge branch 'development' of gitlab.com:mbugroup/lti-web-client into feat/FE/US-285/marketing-closing-report 2025-12-10 11:54:05 +07:00
rstubryan 7e999b2e34 feat(FE): Show sales report on closing detail page 2025-12-10 11:53:47 +07:00
rstubryan e90c7d993c Merge branch ‘development’ of gitlab.com:mbugroup/lti-web-client into
feat/FE/US-285/marketing-closing-report
2025-12-10 11:44:46 +07:00
rstubryan 99fbcaaea3 Merge branch 'development' of gitlab.com:mbugroup/lti-web-client into feat/FE/US-285/marketing-closing-report 2025-12-10 11:40:43 +07:00
Adnan Zahir 865b0b3d8f Merge branch 'fix/FE/US-163-164/api-integration-adjustment-in-expense-request-and-realization' into 'development'
[FIX/FE][US#163-164] API Integration Adjustment in Expense Request and Realization

See merge request mbugroup/lti-web-client!78
2025-12-10 11:32:21 +07:00
Adnan Zahir a4c83f99a7 Merge branch 'feat/FE/US-286/inventory-management-product-stock' into 'development'
[FEAT/FE][US#286] Inventory Product Stock

See merge request mbugroup/lti-web-client!76
2025-12-10 11:25:27 +07:00
Adnan Zahir 294c971fea Merge branch 'feat/FE/US-280/project-flock-budget' into 'development'
[FEAT/FE][US#280] Project Flock Budgets

See merge request mbugroup/lti-web-client!75
2025-12-10 11:14:07 +07:00
randy-ar 8a8128a692 fix(FE): resolve merge conflict checkbox and constant 2025-12-10 10:09:56 +07:00
randy-ar 649dd70ea7 Merge branch 'development' of https://gitlab.com/mbugroup/lti-web-client into dev/randy 2025-12-10 10:03:28 +07:00
Adnan Zahir 44b9210ccc Merge branch 'feat/FE/US-283/sapronak-closing-report' into 'development'
[FEAT/FE][US#283] Sapronak Closing Report

See merge request mbugroup/lti-web-client!74
2025-12-10 09:42:35 +07:00
randy-ar 8c7640eb9c feat(FE-333): adding feature overhead closing report 2025-12-09 18:14:46 +07:00
randy-ar 489815ecaf fix(FE): revert require auth component 2025-12-09 18:04:06 +07:00
randy-ar f9dfe7b27f feat(FE-284): Refactor table component support for nesting header 2025-12-09 17:57:46 +07:00
ValdiANS 33691f45bb chore(FE-323): update outgoing sapronak API endpoint 2025-12-09 11:38:57 +07:00
ValdiANS 2c72c44be4 chore(FE-323): update incoming sapronak API endpoint 2025-12-09 11:38:53 +07:00
ValdiANS 98dfd4564c chore(FE-323): change closing API route path 2025-12-09 11:37:26 +07:00
ValdiANS a795d78c80 Merge branch 'development' into feat/FE/US-283/sapronak-closing-report 2025-12-09 10:58:43 +07:00
ValdiANS 7d8a6ff852 fix: update next.js version 2025-12-09 10:52:49 +07:00
randy-ar 8a0adf847e fix(FE-279): adjust closing project flock kandang 2025-12-09 10:33:38 +07:00
rstubryan 8e80d668fa refactor(FE-311): Remove credit_term from purchase request data and UI 2025-12-09 10:13:48 +07:00
rstubryan a45de4fb13 refactor(FE-311): Remove grand_total and due_date from purchases 2025-12-09 09:58:15 +07:00
rstubryan 6ee5bc3f1b refactor(FE-318,319): Remove egg grading schema and UI logic 2025-12-08 23:37:20 +07:00
rstubryan 012fe800bc refactor(FE-318,319): Remove laying grading checks and simplify approval 2025-12-08 23:35:55 +07:00
rstubryan c3835d5128 refactor(FE-319): Renumber RECORDINGS approval workflow steps 2025-12-08 23:35:12 +07:00
rstubryan 7c4bd81364 feat(FE-319): Remove recording grading feature 2025-12-08 23:34:01 +07:00
rstubryan 545af8267a feat(FE-319): Refactor recording types and simplify payloads 2025-12-08 23:33:34 +07:00
rstubryan 2e6a724b2f refactor(FE-319): Use approval step 2 and remove grading button 2025-12-08 20:13:10 +07:00
rstubryan 305b8e5005 refactor(FE-319): Remove Grading-Telur step from RECORDINGS workflow 2025-12-08 20:12:18 +07:00
rstubryan 5deca5739f refactor(FE-318): Add egg weight column and separate inputs 2025-12-08 20:08:35 +07:00
rstubryan b464432581 chore(FE): Add .claude to .gitignore 2025-12-08 18:49:17 +07:00
rstubryan 512ad5175e refactor(FE-311): Default received_qty and remove transport_total 2025-12-08 18:37:58 +07:00
rstubryan a7d884b5f0 refactor(FE-311): Use latest_approval instead of approval 2025-12-08 18:14:38 +07:00
rstubryan ce75eb25d7 refactor(FE-311): Show previous values only in edit mode 2025-12-08 17:55:22 +07:00
rstubryan c7911f01f2 refactor(FE-311): Remove Total Transport header from approval form 2025-12-08 17:43:44 +07:00
rstubryan 68874a1c14 feat(FE-311): Use latest_approval for purchase approvals 2025-12-08 17:42:23 +07:00
rstubryan 7cc2a31745 Merge branch 'feat/FE/US-280/project-flock-budget' of gitlab.com:mbugroup/lti-web-client into feat/FE/US-278/TASK-311-adjustment-purchase-and-expense 2025-12-08 16:28:09 +07:00
rstubryan f5663b82aa refactor(ci): clean up .gitlab-ci.yml by removing unnecessary whitespace 2025-12-08 14:43:53 +07:00
rstubryan 3a7f1f4812 refactor(FE-311): remove transport_total field and update approval actions 2025-12-08 14:42:39 +07:00
rstubryan 32ffc1f14c chore(prettier): Remove trailing whitespace in .gitlab-ci.yml 2025-12-08 14:08:40 +07:00
rstubryan 58fb9b0c08 chore(CVE): Bump Next to 15.5.7 and ignore .claude 2025-12-08 14:07:25 +07:00
randy-ar 3569955e7f fix(FE): fix warn issue next js 2025-12-08 14:01:13 +07:00
randy-ar 7df743ebf5 fix(FE): adjust sapronak calculation to closing detail page 2025-12-08 10:24:41 +07:00
rstubryan 86a0faaa52 chore(ci): clean up .gitlab-ci.yml by removing unnecessary whitespace 2025-12-08 10:09:21 +07:00
rstubryan df3f342214 chore(CVE): update Next.js version to ^15.5.7 in package.json and package-lock.json 2025-12-08 10:07:00 +07:00
rstubryan c3c1bbbe96 feat(FE-326): Add egg weight field to recording forms 2025-12-08 09:47:22 +07:00
ValdiANS dc0fd7a3ed chore: format code 2025-12-07 15:00:25 +07:00
ValdiANS 5782abb531 refactor: change expense_date to transaction_date 2025-12-07 14:59:51 +07:00
ValdiANS 2d1cabb86b refactor: update CreateExpensePayload, UpdateExpensePayload, and CreateExpenseRealizationPayload types 2025-12-07 14:59:25 +07:00
Rivaldi A N S b362fd1748 Merge branch 'feat/FE/US-285/TASK-326-327-slicing-and-integration-marketing-closing-report' into 'feat/FE/US-285/marketing-closing-report'
[FEAT/FE][US#285/TASK#326-327] Add Feature Marketing Closing Report (Sales/Penjualan)

See merge request mbugroup/lti-web-client!70
2025-12-06 10:25:38 +00:00
Rivaldi A N S 3411aa9b1b Merge branch 'dev/randy' into 'feat/FE/US-286/inventory-management-product-stock'
[FEAT/FE][US#286] Inventory Product Stock

See merge request mbugroup/lti-web-client!69
2025-12-06 10:25:19 +00:00
Rivaldi A N S 1f29e3cb50 Merge branch 'dev/randy' into 'feat/FE/US-280/project-flock-budget'
[FEAT/FE][US#280] Project Flock Budgets

See merge request mbugroup/lti-web-client!68
2025-12-06 10:23:34 +00:00
Rivaldi A N S b671de1336 Merge branch 'feat/FE/US-283/TASK-320-321-322-323-sapronak-closing-report' into 'feat/FE/US-283/sapronak-closing-report'
[FEAT/FE][US#283/TASK#320-321-322-323] Sapronak Closing Report

See merge request mbugroup/lti-web-client!73
2025-12-06 10:18:01 +00:00
ValdiANS 090a3183f7 feat(FE-323): create Closing type 2025-12-06 17:14:09 +07:00
ValdiANS 17865d733d feat(FE-323): create ClosingApiService 2025-12-06 17:13:53 +07:00
ValdiANS 5be67ef01c chore: update formatDate helper function 2025-12-06 17:13:27 +07:00
ValdiANS 7f326bedd4 chore(FE-320): add Closing menu 2025-12-06 17:13:00 +07:00
ValdiANS c350bc0be2 feat(FE-321): create ClosingSapronakTabContent component 2025-12-06 16:54:44 +07:00
ValdiANS 6f7627ac92 feat(FE-321): create ClosingOutgoingSapronaksTable component 2025-12-06 16:54:27 +07:00
ValdiANS 1ae5c1bd64 feat(FE-321): create ClosingIncomingSapronaksTable component 2025-12-06 16:54:15 +07:00
ValdiANS 5bb366026d feat(FE-321): create ClosingGeneralInformationTable component 2025-12-06 16:53:54 +07:00
ValdiANS 9888dc4356 feat(FE-321): create ClosingDetail component 2025-12-06 16:53:39 +07:00
ValdiANS 7615daa22a chore: update Pagination component 2025-12-06 16:53:20 +07:00
ValdiANS 435cc0aedc feat(FE-321): create layout file for closing detail route 2025-12-06 16:53:05 +07:00
ValdiANS d189252551 feat(FE-321): create Closing detail page 2025-12-06 16:52:45 +07:00
ValdiANS d85cf29193 feat(FE-320): create ClosingsTable component 2025-12-06 16:52:12 +07:00
ValdiANS 84ff5e178b feat(FE-320): create Closing list page 2025-12-06 16:51:48 +07:00
ValdiANS 72840e2193 chore: set container size value 2025-12-06 16:46:14 +07:00
ValdiANS ea2ada8224 chore: update daisyui version 2025-12-06 16:44:31 +07:00
randy-ar b97cc39854 fix(FE): revert RequireAuth component and closing logic 2025-12-06 13:10:03 +07:00
randy-ar 195bbbe449 fix(FE): change closing folder name 2025-12-06 12:51:13 +07:00
randy-ar 375b50b646 fix(FE): revert RequireAuth Component 2025-12-06 12:45:07 +07:00
randy-ar a5c71ff8ce feat(FE-284): Slicing and API Integration Perhitungan Sapronak 2025-12-06 12:43:22 +07:00
randy-ar e09074eed0 feat(FE): add sapronak table 2025-12-06 11:55:47 +07:00
randy-ar ffbf886718 fix(FE): adjust chickin and closing after submit 2025-12-06 11:38:28 +07:00
rstubryan b3f7b8a3c5 feat(FE-326): Add totals footer row to sales report table 2025-12-06 10:26:26 +07:00
rstubryan e407410c4a feat(FE-Storyless): Add footer support to Table component 2025-12-06 10:25:40 +07:00
randy-ar 341cb42452 feat(FE): adding temporary perhitungan sapronak 2025-12-06 10:05:10 +07:00
rstubryan 99b9df27a7 refactor(FE-326): Comment _closing for copy-paste function 2025-12-06 09:58:38 +07:00
rstubryan 27c867036f refactor(FE-327): Update import paths for consistency in SalesReportTable 2025-12-06 09:51:40 +07:00
rstubryan c9552dec2d refactor(FE-326): Remove custom header rows and simplify Table 2025-12-06 09:47:38 +07:00
rstubryan aad24c3c58 refactor(FE-327): Rename salesBroilerData to salesData 2025-12-06 09:12:02 +07:00
rstubryan ff1493b520 refactor(FE-326): Remove avgPriceAct/totalAct and use partner totals,
fix badge case
2025-12-06 09:09:41 +07:00
rstubryan 4ff1649991 chore(FE-327): Remove unused state from SalesReportTable 2025-12-06 08:56:14 +07:00
rstubryan 4fe53f364a refactor(FE-326): Remove Tabs wrapper from SalesReportTable 2025-12-06 08:54:12 +07:00
randy-ar 85fdb4f7dd refactor(FE): refactor chickin views and adjust approval logic in project flocks 2025-12-06 00:15:30 +07:00
randy-ar 885e4250fd feat(FE-279): Add functionality closing project flock 2025-12-05 22:55:11 +07:00
rstubryan eaf118845c feat(FE-327): Include Kandang in sales data and display name 2025-12-05 19:15:38 +07:00
rstubryan 30db7ee95d refactor(FE-327): change SalesReportTable to use new API fields 2025-12-05 18:27:45 +07:00
rstubryan 5869e0434b refactor(FE-327): change closing API paths and sales types 2025-12-05 18:26:58 +07:00
rstubryan f205c66509 refactor(FE-327): Rename Ekor label to Kuantitas 2025-12-05 17:49:59 +07:00
rstubryan 46e072bbcf refactor(FE-327): Map Indonesian sales fields and add API sample 2025-12-05 11:15:41 +07:00
rstubryan c31b284cf4 refactor(FE-327): Split BaseClosingSales into BaseSales and wrapper 2025-12-05 11:14:52 +07:00
ValdiANS bac3f30ce3 chore: update Table component 2025-12-04 23:09:08 +07:00
ValdiANS be725d42c3 chore: add Size type 2025-12-04 22:46:26 +07:00
ValdiANS b37c3f87b0 chore: set color for menu foreground and background 2025-12-04 22:46:18 +07:00
ValdiANS ae4c17b391 chore: create isPathActive helper 2025-12-04 22:45:57 +07:00
ValdiANS 48dd6d7218 chore: update MAIN_DRAWER_LINKS structure 2025-12-04 22:45:48 +07:00
ValdiANS cee3d4ba90 chore: create SidebarMenu component 2025-12-04 22:45:29 +07:00
ValdiANS a8d7fdc30d chore: update Menu component 2025-12-04 22:45:20 +07:00
ValdiANS 2bb2da74e6 chore: update CheckboxInput component 2025-12-04 22:45:13 +07:00
ValdiANS fd024fdb8f chore: update Pagination component 2025-12-04 22:44:43 +07:00
ValdiANS 79a89ea193 chore: use SidebarMenu component 2025-12-04 22:44:17 +07:00
ValdiANS 611655e408 chore: update gitlab-ci 2025-12-04 22:42:57 +07:00
ValdiANS 702943c55c chore: update next, daisyui, and eslint-config-next library 2025-12-04 22:36:22 +07:00
rstubryan 075d945a59 refactor(FE-326): Use placeholder for sales type in header 2025-12-04 21:29:45 +07:00
rstubryan 7d9a88cf3b feat(FE-326,327): Add sortable table headers and styling 2025-12-04 20:14:29 +07:00
rstubryan b095208fae refactor(FE-327): Temporarily map Indonesian sales fields to English 2025-12-04 17:41:22 +07:00
randy-ar c69d9dd605 fix(FE): revert require auth component to correct file 2025-12-04 16:39:00 +07:00
randy-ar a1d0c7b331 fix(FE): adjust data types for inventory product stock 2025-12-04 16:35:10 +07:00
randy-ar e0a8514814 fix(FE): adjust data types for project flock and product stock inventory 2025-12-04 16:13:47 +07:00
rstubryan 949761d59d feat(FE-326,327): add footer rendering to SalesReportTable for total sales display 2025-12-04 14:25:27 +07:00
rstubryan 15ced14e20 refactor(FE-Storyless): add footer rendering support to Table component 2025-12-04 14:25:11 +07:00
rstubryan 492efb18e2 chore: update next.js to version 15.5.7 in package.json and package-lock.json 2025-12-04 14:15:58 +07:00
rstubryan 8ea29579ec feat(FE-326,327): add layout and closing detail page with sales report integration 2025-12-04 14:10:57 +07:00
randy-ar dc6b0eaec6 fix(FE): change datatype location in inventory products 2025-12-04 14:10:46 +07:00
rstubryan 1a4a05308f refactor(FE-326,327): enhance SalesReportTable to handle empty sales data and conditionally render summary row 2025-12-04 14:08:44 +07:00
rstubryan ba40bbb1d3 refactor(FE-327): remove dummy sales data and update ClosingApiService to fetch real sales data from API 2025-12-04 14:07:10 +07:00
rstubryan 647b002065 refactor(FE-326): change SalesReportTable to use BaseClosingSales type and support initial values 2025-12-04 11:55:57 +07:00
rstubryan 991a594ee1 refactor(FE-326): Add ClosingApiService and types for closing sales data 2025-12-04 11:51:11 +07:00
randy-ar 3b846bf11c fix(FE): fixing error suspense layout 2025-12-04 02:06:33 +07:00
randy-ar 3e07316678 feat(FE-328-329-330): Adding Feature Inventory Product Stocks 2025-12-04 02:05:34 +07:00
rstubryan 411c2586f5 chore(format): prettier format 2025-12-03 22:32:11 +07:00
rstubryan 3a87b039bf feat(FE-326): Add SalesReportTable component 2025-12-03 22:31:10 +07:00
rstubryan 50559caf52 feat(FE-326): Support custom header rows and cell render hook 2025-12-03 22:28:18 +07:00
rstubryan 8fbe6aa148 chore(FE-Storyless): Add .claude to .gitignore 2025-12-03 22:26:33 +07:00
randy-ar 873a4b308d fix(FE): resolve conflict pull branch development 2025-12-03 21:21:42 +07:00
randy-ar f0ec758d7f feat(FE-314-315): API Integration project budgets and refactoring UI 2025-12-03 21:09:12 +07:00
rstubryan 88878f7613 Merge branch 'development' of gitlab.com:mbugroup/lti-web-client into dev/restu 2025-12-03 10:55:39 +07:00
randy-ar 31f758d680 refactor(FE): refactor UI detail from page into drawer 2025-12-02 16:25:55 +07:00
randy-ar 9eba5ffeca feat(FE): create floation actions button 2025-12-02 12:37:03 +07:00
randy-ar 6b5838b5aa feat(FE): refactor drawer zustand store 2025-12-02 11:01:53 +07:00
randy-ar c76f3a3715 feat(FE): US#278 slicing UI from and client side validation 2025-12-02 04:11:01 +07:00
randy-ar 48435a9cbb fix(FE): change import module to absolute path 2025-12-01 10:22:00 +07:00
randy-ar 2ace95a0db feat(FE): add drawer ui store 2025-12-01 10:13:28 +07:00
kris 58532881f4 Update .gitlab-ci.yml update env 2025-11-28 13:06:03 +00:00
kris 4073f4dfde Update .gitlab-ci.yml update env 2025-11-28 12:47:47 +00:00
kris 94e2d71dba Update .gitlab-ci.yml file 2025-11-28 10:15:49 +00:00
kris 944f479e2d Update .gitlab-ci.yml file 2025-11-28 10:02:17 +00:00
kris 5046d687b5 Update .gitlab-ci.yml file 2025-11-28 09:54:57 +00:00
randy-ar 892bb19dfd refactor(FE): change project flock form, detail and chickin view using drawer 2025-11-28 16:41:01 +07:00
kris 711deda6a8 Update .gitlab-ci.yml file 2025-11-28 09:38:44 +00:00
Adnan Zahir 029be31020 Merge branch 'feat/FE/US-164/expense-realization' into 'development'
[FEAT/FE][US#164] Expense Realization

See merge request mbugroup/lti-web-client!67
2025-11-28 15:40:33 +07:00
Rivaldi A N S ed7563a028 Merge branch 'feat/FE/US-164/TASK-200-204-205-206-207-expense-realization' into 'feat/FE/US-164/expense-realization'
[FEAT/FE][US#164/TASK#200-204-205-206-207] Expense Realization

See merge request mbugroup/lti-web-client!66
2025-11-28 03:41:26 +00:00
ValdiANS f82ca4f959 chore(FE-195): adjust RowOptionsMenu type 2025-11-28 10:32:00 +07:00
ValdiANS 0cc01ae738 feat(FE-196,199): create ExpensePDF component 2025-11-28 10:31:27 +07:00
ValdiANS 1de743a404 feat(FE-196,199): create ExpensePDFButton component 2025-11-28 10:31:08 +07:00
ValdiANS 68c1e76a4a feat(FE-196,199): add Expense PDF Preview button 2025-11-28 10:30:26 +07:00
ValdiANS 2001cdb843 chore(FE-205): adjust content styling 2025-11-28 10:29:36 +07:00
ValdiANS b8590040ff chore: remove unnecessary code 2025-11-28 10:28:33 +07:00
ValdiANS 909aa3357c chore: add MBU logo 2025-11-28 10:24:56 +07:00
rstubryan 7a76719547 refactor(FE-Storyless): remove console, window and err catch 2025-11-27 13:46:53 +07:00
rstubryan 4b6144d0b4 refactor(FE-Storyless): update import paths for schema files to use absolute paths 2025-11-27 13:36:12 +07:00
ValdiANS 507543eff8 chore: remove unnecessary code 2025-11-27 09:38:26 +07:00
ValdiANS 8dc6b3d1db Merge branch 'development' into feat/FE/US-164/TASK-200-204-205-206-207-expense-realization 2025-11-26 13:44:01 +07:00
Adnan Zahir 22ce1b1142 Merge branch 'feat/FE/US-162/purchase-order' into 'development'
[FEAT/FE][US#161|US#162] Add Feature Purchase Request and Purchase Order

See merge request mbugroup/lti-web-client!65
2025-11-26 12:47:50 +07:00
Rivaldi A N S e126ab4a0e Merge branch 'feat/FE/US-161/TASK-208-212-slicing-ui-and-validation-create-purchase-request-form' into 'feat/FE/US-162/purchase-order'
[FEAT/FE][US#161|US#162] Add Feature Purchase Request and Purchase Order

See merge request mbugroup/lti-web-client!61
2025-11-26 03:10:06 +00:00
rstubryan 7685be0c7b Merge branch 'development' of gitlab.com:mbugroup/lti-web-client into feat/FE/US-161/TASK-208-212-slicing-ui-and-validation-create-purchase-request-form 2025-11-26 09:43:52 +07:00
Adnan Zahir 8b72f58467 Merge branch 'fix/FE/US-160/marketing-delivery-order' into 'development'
[FIX/FE][US#160] Fixing Missing Component UI DebounceTextArea

See merge request mbugroup/lti-web-client!64
2025-11-26 09:43:16 +07:00
Rivaldi A N S 87c25a8bc4 Merge branch 'dev/randy' into 'fix/FE/US-160/marketing-delivery-order'
[FIX/FE][US#160/TASK#220] Fixing Missing Component UI DebounceTextArea

See merge request mbugroup/lti-web-client!63
2025-11-26 02:15:14 +00:00
randy-ar 1e4c826a0a fix(FE): fixing error missing component DebounceTextArea 2025-11-26 01:27:00 +07:00
rstubryan 6d3632a385 Merge branch 'development' of gitlab.com:mbugroup/lti-web-client into feat/FE/US-161/TASK-208-212-slicing-ui-and-validation-create-purchase-request-form 2025-11-25 11:30:49 +07:00
Adnan Zahir d75ac635df Merge branch 'feat/FE/US-160/marketing-delivery-order' into 'development'
[FE/FE][US#160] Marketing - Delivery Order

See merge request mbugroup/lti-web-client!62
2025-11-25 11:30:17 +07:00
Rivaldi A N S 352fd701cb Merge branch 'dev/randy' into 'feat/FE/US-160/marketing-delivery-order'
[FE/FE][US#160/TASK#179-181-220-272] Adding Feature Delivery Order

See merge request mbugroup/lti-web-client!60
2025-11-25 04:22:36 +00:00
ValdiANS 2a97f9d504 Merge branch 'development' into feat/FE/US-164/TASK-200-204-205-206-207-expense-realization 2025-11-25 10:55:52 +07:00
ValdiANS b805fb4ae1 chore(FE-196): use useApprovalSteps hook 2025-11-25 10:48:27 +07:00
ValdiANS 642f966985 chore: adjust ApprovalSteps component 2025-11-25 10:47:34 +07:00
ValdiANS c3e4d4c630 chore(FE-199,207): adjust expense type according to the API need 2025-11-25 09:25:40 +07:00
ValdiANS b616f28c95 feat: add interceptor to axiosClient to redirect to login page if the user is logged out 2025-11-25 09:24:46 +07:00
ValdiANS 334202569c chore(FE-199,207): integrate ExpenseApiService to API 2025-11-25 09:24:12 +07:00
ValdiANS 1a1fefc237 chore: create AuthApiService 2025-11-25 09:19:58 +07:00
ValdiANS 47690f82ac chore(FE-199): update Expense Request approval line step name 2025-11-25 09:18:04 +07:00
ValdiANS b868a37485 chore(FE-188,193): adjust ExpenseRequestKandangDetailExpense component 2025-11-25 09:17:02 +07:00
randy-ar 034d185b84 fix(FE): make text area debounce input for lag textarea input issue 2025-11-24 17:18:16 +07:00
ValdiANS e4a6b22357 chore(FE-188,193,199): adjust Expense Request Form and integrate to API 2025-11-24 09:54:28 +07:00
ValdiANS 82eac4a965 chore(FE-198): adjust Expense Request Form validation 2025-11-24 09:47:09 +07:00
ValdiANS 20c3e2d6b4 feat(FE-200,204): create ExpenseRealizationKandangDetailExpense component 2025-11-24 09:44:48 +07:00
ValdiANS f24ae992e6 feat(FE-206): create Expense Realization Form validation 2025-11-24 09:43:58 +07:00
ValdiANS 4f375a4f0b feat(FE-200,204): create Expense Realization Form 2025-11-24 09:43:20 +07:00
ValdiANS 510d10270e feat(FE-195): implement bulk approve/reject in Expense list page 2025-11-24 09:42:14 +07:00
ValdiANS b083b9cb1a feat(FE-196): create Expense Request Detail's content component 2025-11-24 09:38:31 +07:00
ValdiANS 93d14cb98b feat(FE-205): create Expense Realization Detail's content component 2025-11-24 09:38:13 +07:00
ValdiANS b0bd2bd8a5 chore(FE-196,205): refactor ExpenseDetail component 2025-11-24 09:35:30 +07:00
ValdiANS c0bba827a0 chore: remove dummy data 2025-11-24 09:31:27 +07:00
ValdiANS 032e9d45b3 feat: add logout functionality 2025-11-24 09:30:12 +07:00
ValdiANS 4027b25598 chore(FE-204): create Edit Expense Realization page 2025-11-24 09:26:37 +07:00
ValdiANS 70b1ba3f6b chore(FE-200): create Add Expense Realization page 2025-11-24 09:26:20 +07:00
ValdiANS d34c113be3 chore(FE-205): create layout file for expense realization detail page 2025-11-24 09:23:54 +07:00
ValdiANS 6a08854603 chore(FE-204,207): add validation to check if expense can be edited 2025-11-24 09:21:32 +07:00
rstubryan 824eed910a fix(resolve): fix resolve merge 2025-11-24 08:34:50 +07:00
randy-ar d769bfe452 fix(FE-270): adjust endpoint get next period project flock 2025-11-23 13:34:45 +07:00
rstubryan 274322606d refactor(FE-212): enhance quantity and price handling in PurchaseOrderStaffApprovalForm with improved validation and formatting 2025-11-22 13:47:24 +07:00
rstubryan 62c3d2af53 refactor(FE-212): add quantity field handling in PurchaseOrderStaffApprovalForm for improved item updates 2025-11-22 13:36:38 +07:00
rstubryan 01b9595606 refactor(FE-212): replace quantity input with NumberInput for editable rows in PurchaseOrderStaffApprovalForm 2025-11-22 13:32:10 +07:00
rstubryan 09065f59cf refactor(FE-212): enhance approval step logic in PurchaseOrderStaffApprovalForm for better item management 2025-11-22 13:23:23 +07:00
rstubryan ad79f29494 refactor(FE-212): update supplier data fetching logic to handle invalid supplier IDs in PurchaseRequestForm 2025-11-22 13:00:57 +07:00
randy-ar a26665e4ac fix(FE-179): prevent qty input greater than sales order qty 2025-11-22 12:58:55 +07:00
randy-ar eaaed9521b fix(FE-179-220): Adjust form add and edit delivery, add validation to prevent duplicate product 2025-11-22 12:04:46 +07:00
rstubryan 5bb94b5679 refactor(FE-Issue): add validation to prevent selecting the same warehouse for source and destination in MovementForm 2025-11-22 11:33:28 +07:00
rstubryan 3c7f630580 feat(FE-Storyless): add date input for transfer date in MovementForm 2025-11-22 11:17:06 +07:00
rstubryan 6ce5a5b625 refactor(FE-208): filter supplier options by category in MovementForm for improved data relevance 2025-11-22 11:10:49 +07:00
rstubryan c12a58cb6d refactor(FE-208): add validation to ensure destination warehouse is different from source warehouse in MovementForm 2025-11-22 11:07:23 +07:00
rstubryan 34c1da94d8 refactor(FE-Issue): remove unused product and warehouse selection from MovementTable for cleaner UI 2025-11-22 10:47:27 +07:00
rstubryan 5b84a19afa refactor(FE-Issue): add max length validation for product category name in ProductCategoryForm 2025-11-22 10:35:56 +07:00
rstubryan a4a2b76277 fix(resolve): fix resolve MR 2025-11-22 10:25:37 +07:00
rstubryan 23abdbb78f refactor(FE-208): display formatted total and subtotal quantities in PurchaseOrderInvoice for improved clarity 2025-11-22 10:21:36 +07:00
rstubryan 6a39c2fd3f refactor(FE-208): swap accessor keys for total_qty and sub_qty in PurchaseOrderDetail for accurate data representation 2025-11-22 10:17:38 +07:00
rstubryan f9215738aa feat(FE-212): add quantity validation to PurchaseOrderAcceptApprovalForm to prevent submission with exceeded received quantities 2025-11-22 10:16:39 +07:00
rstubryan b12a1ebd36 feat(FE-212): add rawDataApprovals prop to PurchaseOrderStaffApprovalForm for improved approval data handling 2025-11-22 10:11:30 +07:00
rstubryan 0fefe5e035 feat(FE-212): enhance PurchaseOrderStaffApprovalForm to dynamically determine form type and validate product selection for duplicates 2025-11-22 09:47:20 +07:00
rstubryan ef95d1a0e8 refactor(FE-208): improve deletion logic in PurchaseOrderDetail to restrict item deletion to approval step 3 and enhance approval step handling 2025-11-22 00:58:06 +07:00
rstubryan 30ab69ae21 refactor(FE-208,212,213): update PurchaseOrderForm and PurchaseOrderStaffApprovalForm to allow optional product and warehouse fields and control visibility of action buttons based on approval step 2025-11-22 00:52:23 +07:00
rstubryan 5b28067203 feat(FE-208,212,213): enhance PurchaseOrderStaffApprovalForm with product and warehouse selection for new items 2025-11-21 22:46:50 +07:00
rstubryan ffea96edf9 refactor(FE-208): update deletion logic in PurchaseOrderDetail to allow item deletion only at approval step 3 2025-11-21 20:30:06 +07:00
rstubryan 1a74a9d33f feat(FE-208,212,213): integrate dynamic supplier selection in PurchaseOrderAcceptApprovalForm 2025-11-21 20:23:58 +07:00
rstubryan b9990e0253 refactor(FE-208): enhance PurchaseRequestForm to fetch and display supplier-specific products 2025-11-21 18:54:17 +07:00
rstubryan 95a7afdaa6 feat(FE-208): add refetchData prop to PurchaseOrderDetail and related forms for improved data synchronization 2025-11-21 18:18:40 +07:00
randy-ar b198f24b75 Merge branch 'development' of https://gitlab.com/mbugroup/lti-web-client into dev/randy 2025-11-21 13:35:03 +07:00
randy-ar b7c3b9313c fix(FE-169-177): Allow Drafted Marketing to be rejected 2025-11-21 13:33:40 +07:00
rstubryan c74733430b feat(FE-208): implement conditional item deletion in PurchaseOrderDetail and update form handling in PurchaseOrderStaffApprovalForm 2025-11-21 13:26:34 +07:00
rstubryan f6fe2d4eb1 refactor(FE-208): remove 'Jumlah Retur' column from PurchaseOrderDetail for UI simplification 2025-11-21 11:01:33 +07:00
rstubryan d624da97c3 feat(FE-208): replace product name input with select dropdown for better usability 2025-11-21 10:13:38 +07:00
Adnan Zahir fdf680bc38 Merge branch 'feat/FE/US-159/marketing-sales-order' into 'development'
[FE/FE][US#159] Sales Order

See merge request mbugroup/lti-web-client!59
2025-11-21 10:08:11 +07:00
Rivaldi A N S e9d9897e1d Merge branch 'dev/randy' into 'feat/FE/US-159/marketing-sales-order'
[FE/FE][US#159/TASK#166-167-168-169-176-177-271] Adding Feature Sales Order

See merge request mbugroup/lti-web-client!56
2025-11-21 03:04:03 +00:00
randy-ar 70521330e4 fix(FE): resolve merge conflict 2025-11-21 09:45:40 +07:00
rstubryan 63e5962a4e fix(resolve): fix resolve MR 2025-11-21 09:25:16 +07:00
rstubryan 835074f538 refactor(FE-212): group purchase items by warehouse in PurchaseOrderStaffApprovalForm 2025-11-21 09:17:00 +07:00
Adnan Zahir e69e5da2c3 Merge branch 'feat/FE/US-79/egg-grading' into 'development'
[FEAT/FE][US#78|US#79] Add Feature Daily Recording Laying, Grading and Adjusting Recording Growing

See merge request mbugroup/lti-web-client!58
2025-11-21 09:15:02 +07:00
Rivaldi A N S e451a128c5 Merge branch 'feat/FE/US-78/TASK-170-174-slicing-ui-and-validation-create-daily-recording-laying-form' into 'feat/FE/US-79/egg-grading'
[FEAT/FE][US#78|US#79] Add Feature Daily Recording Laying, Grading and Adjusting Recording Growing

See merge request mbugroup/lti-web-client!51
2025-11-21 02:05:18 +00:00
randy-ar 23ab4b15e1 fix(FE-270): delete relations project flock to flock data master 2025-11-21 01:28:57 +07:00
randy-ar d523a01e34 fix(FE-270): adjust flock_name in select input and fixing project flock approval 2025-11-21 00:31:25 +07:00
rstubryan e00b7bc3f2 refactor(FE-212): update default unit of measure in PurchaseOrderAcceptApprovalForm 2025-11-20 23:52:35 +07:00
rstubryan 51f157dfad refactor(FE-208,212): enhance quantity validation and formatting in PurchaseOrderAcceptApprovalForm 2025-11-20 23:50:14 +07:00
rstubryan c1d71ee3c6 refactor(FE-212): add warehouse information to PurchaseOrderAcceptApprovalForm 2025-11-20 23:31:35 +07:00
rstubryan c8b3e52ac0 refactor(FE-212): remove commented-out edit button in PurchaseTable component 2025-11-20 23:28:05 +07:00
rstubryan b2ef545f63 refactor(FE-208,212,213): replace product_id and warehouse_id with purchase_item_id in PurchaseRequestStaffApprovalForm and related schemas 2025-11-20 23:21:12 +07:00
rstubryan a6d187a8b3 refactor(FE-208,212,213): add action field to staff approval request payloads and implement rejection handling in PurchaseOrderDetail 2025-11-20 23:05:12 +07:00
rstubryan 24e2bcf35d refactor(FE-212): update notes field in UpdateStaffApprovalRequestPayload for consistency 2025-11-20 22:54:22 +07:00
rstubryan 417d08e0fc refactor(FE-212,213): unify purchase API service references in Purchase components 2025-11-20 22:39:04 +07:00
rstubryan 6e9d065bc6 refactor(FE-212): change HTTP method to DELETE for item removal in PurchaseRequestForm 2025-11-20 22:16:44 +07:00
randy-ar af939ee225 feat(FE-272): adding DO PDF export 2025-11-20 19:43:50 +07:00
randy-ar 391b355e8d feat(FE-181-179-220-271): adding SO export PDF and adjusting delivery form 2025-11-20 18:15:42 +07:00
rstubryan 4ddc44b59c refactor(FE-208,212): enhance product selection and quantity input handling in PurchaseRequestForm based on supplier selection 2025-11-20 15:38:04 +07:00
rstubryan e0b4805d0a refactor(FE-208,212): reset touched fields and values for purchase items in PurchaseRequestForm 2025-11-20 15:36:12 +07:00
rstubryan 074e6fad05 refactor(FE-208,212): improve credit term handling and validation in PurchaseRequestForm 2025-11-20 15:33:43 +07:00
rstubryan e640bce8ea refactor(FE-208): streamline supplier change handling and reset purchase items in PurchaseRequestForm 2025-11-20 15:25:39 +07:00
rstubryan f1e5692f8f refactor(FE-208,212): initialize items in PurchaseRequestForm with initial values 2025-11-20 14:50:36 +07:00
rstubryan 655e971788 refactor(FE-208): update input wrapper classes for consistency in PurchaseRequestForm 2025-11-20 14:44:41 +07:00
rstubryan 00e18d6d0d refactor(FE-208,212): enhance form validation and streamline change handlers in PurchaseRequestForm 2025-11-20 14:13:57 +07:00
rstubryan 343cc7c4e7 refactor(FE-212): remove unused poDate and supplier fields from table filter in PurchaseTable 2025-11-20 13:34:52 +07:00
rstubryan 4e8b17f55c refactor(FE-208): remove unused supplier state and handlers in PurchaseTable 2025-11-20 13:32:26 +07:00
rstubryan 862e056950 chore(FE-Storyless): prettier format 2025-11-20 13:07:51 +07:00
rstubryan 1310c7401c feat(FE-170,174): enhance number formatting in RecordingForm validation messages 2025-11-20 11:25:36 +07:00
rstubryan d0f2fefe1c feat(FE-170,174): add validation for total chick quantity in RecordingForm 2025-11-20 11:18:48 +07:00
rstubryan 6cb517ac92 fix(FE-174): correct parameter name for next day recording API request 2025-11-20 10:58:32 +07:00
rstubryan c698893f88 feat(FE-170,174,175): implement next day recording functionality in RecordingForm 2025-11-20 10:31:24 +07:00
rstubryan cb236c191b refactor(FE-170,174): adjust layout of action buttons in RecordingForm for better responsiveness 2025-11-20 09:20:39 +07:00
rstubryan ac764c9d3b refactor(FE-170,174): clean up grading redirect in RecordingTable action 2025-11-20 09:08:06 +07:00
randy-ar b33e7a1919 feat(FE-181-179-220): Slicing UI, Client Side Validation and API Integration for Delivery Order 2025-11-20 00:57:07 +07:00
rstubryan 28a5343592 refactor(FE-170): update tableWrapperClassName to allow overflow visibility 2025-11-19 22:41:02 +07:00
rstubryan d3c3d9c9c6 feat(FE-170,174): add notes input to approval and rejection confirmation modals 2025-11-19 20:25:06 +07:00
rstubryan 42253d123b feat(FE-170,174): enhance approval and rejection modals to include notes input 2025-11-19 20:07:26 +07:00
rstubryan 539b329b6f refactor(FE-170,174): refine RecordingTable approval logic and remove unused tooltips 2025-11-19 19:47:55 +07:00
rstubryan 427887a0e0 feat(FE-170,174): update RecordingTable to restrict selection and approval to GROWING category only 2025-11-19 19:34:46 +07:00
rstubryan 7e58e46254 feat(FE-170,174): add loading state and improve validation messages in GradingForm 2025-11-19 19:17:32 +07:00
rstubryan c876824c8f feat(FE-170,174,175): add validation for incomplete grading in GradingForm 2025-11-19 19:05:45 +07:00
rstubryan 9c69369a51 feat(FE-170): remove total_weight from body_weights and update validation logic in RecordingForm 2025-11-19 18:04:15 +07:00
rstubryan 7b28e47c68 refactor(FE-170): streamline RecordingTable component by removing unused imports and state management for area, location, and kandang 2025-11-19 17:23:04 +07:00
rstubryan 432ea1e975 refactor(FE-208,212): update input wrapper classes for improved responsiveness in PurchaseRequestForm 2025-11-19 17:12:18 +07:00
rstubryan 14f216a352 refactor(FE-208,212): rename product_warehouse to warehouse and update related schema and form handling 2025-11-19 16:21:46 +07:00
rstubryan 8bda56e5d3 refactor(FE-208,212): add refreshApprovals and onModalClose props to approval forms 2025-11-19 13:27:36 +07:00
randy-ar 429f2b9109 fix(FE): adding capacity to kandang and change confirmation modal marketing with note 2025-11-19 13:00:21 +07:00
rstubryan 9d6455167f refactor(FE-208,212): enhance approval button layout and add reject option in PurchaseOrderDetail 2025-11-19 11:40:47 +07:00
rstubryan e3274a3353 refactor(FE-208,212): streamline approval button handling in PurchaseOrderDetail 2025-11-19 11:37:32 +07:00
rstubryan 07fd71558e refactor(FE-208,212): remove debug information from PurchaseOrderAcceptApprovalForm 2025-11-19 11:02:50 +07:00
rstubryan d2a69917e7 refactor(FE-208,212): improve rendering of grouped goods receipt items in PurchaseOrderDetail 2025-11-19 10:55:44 +07:00
rstubryan af5dfa9292 refactor(FE-208,212): implement grouping of goods receipt items and enhance table rendering in PurchaseOrderDetail 2025-11-19 10:50:53 +07:00
randy-ar 8662bcb63b fix(FE): resolve merge conflict 2025-11-19 10:30:21 +07:00
randy-ar f68e59e8c7 fix(FE): fixing table flickering when input form value 2025-11-19 10:21:59 +07:00
rstubryan b520b4ee54 refactor(FE-208,212,213): add transport-related fields and update form handling in PurchaseOrder forms 2025-11-19 10:19:05 +07:00
rstubryan 89d9d40713 refactor(FE-208,212): remove warehouse-related fields and logic from PurchaseOrder forms and schema 2025-11-19 09:17:17 +07:00
rstubryan 17378d8408 refactor(FE-208,212): rename getPurchaseItemError to isRepeaterInputError for clarity in validation checks 2025-11-18 23:13:15 +07:00
rstubryan 25544e2e38 refactor(FE-208,212): enhance PurchaseOrderDetail and PurchaseOrderStaffApprovalForm to conditionally render invoice and item receipt based on approval steps 2025-11-18 23:10:49 +07:00
rstubryan 89b54f6f87 refactor(FE-208,212): update PurchaseOrderDetail to conditionally render invoice based on update permissions 2025-11-18 22:51:29 +07:00
rstubryan 3a431352ed refactor(FE-208,212): enhance PurchaseOrderDetail and PurchaseOrderStaffApprovalForm to conditionally allow updates based on approval step 2025-11-18 22:46:46 +07:00
rstubryan f6afb741af refactor(FE-208,212): enhance PurchaseOrderStaffApprovalForm for edit functionality and validation checks 2025-11-18 22:32:39 +07:00
rstubryan f4bb87550c refactor(FE-212): add updateStaffApproval method and enhance PurchaseStaffApprovalItem schema with optional purchase_item_id 2025-11-18 22:28:27 +07:00
rstubryan 3d468d9507 refactor(FE-208,213): simplify PurchaseOrderForm and PurchaseOrderStaffApprovalForm by removing unused product and warehouse fields and enhancing price validation 2025-11-18 22:13:14 +07:00
rstubryan 0c79e86736 refactor(FE-208,212): update PurchaseOrderForm and PurchaseOrderStaffApprovalForm for improved validation and dynamic item handling 2025-11-18 21:00:46 +07:00
rstubryan 1b90d657ff refactor(FE-208,212): update PurchaseOrderForm and PurchaseOrderStaffApprovalForm for improved validation and dynamic item handling 2025-11-18 20:43:57 +07:00
rstubryan 0d025ba34c refactor(FE-208,213): streamline PurchaseOrderAcceptApprovalForm by removing hardcoded warehouse options and utilizing initialValues for dynamic data 2025-11-18 18:31:49 +07:00
rstubryan 8c3cd3bc53 refactor(FE-208,213): enhance PurchaseOrderDetail and PurchaseOrderStaffApprovalForm components with initialValues prop and clean up unused code 2025-11-18 18:22:10 +07:00
rstubryan 75e7b9a6de refactor(FE-208,213): update PurchaseOrderDetail and PurchaseOrderInvoice components for improved warehouse and supplier details 2025-11-18 14:58:49 +07:00
rstubryan 00c432a918 refactor(FE-208,212,213): update approval steps and improve PurchaseOrderDetail component structure 2025-11-18 14:49:30 +07:00
rstubryan f6cf22f885 refactor(FE-208): update PurchaseOrderDetail component to use initialValues prop 2025-11-18 14:36:16 +07:00
rstubryan 3d86c9ce6b refactor(FE-Storyless): add support for 'UPDATED' action in approval status and make page parameter optional 2025-11-18 14:34:26 +07:00
rstubryan d93f0c26b6 refactor(FE-212): update PurchaseOrderDetail component to use initialValues prop instead of data 2025-11-18 14:32:24 +07:00
rstubryan e8dd4f3759 feat(FE-218,212,213): implement PurchaseOrderDetail component and update related types 2025-11-18 14:30:09 +07:00
rstubryan edd59598f9 refactor(FE-208,212): refine PurchaseRequestForm validation and state management 2025-11-18 13:50:54 +07:00
rstubryan 964a4500ab feat(FE-208): update date formatting in PurchaseTable for improved readability 2025-11-18 13:39:42 +07:00
rstubryan 9a650a130d feat(FE-208): enhance PurchaseTable with improved state management and memoization 2025-11-18 13:35:58 +07:00
rstubryan 2f2c1fca07 feat(FE-212): add sales orders link and accepted file types constants 2025-11-18 13:25:21 +07:00
rstubryan 2680d5a24d feat(FE-212): add sales orders link and accepted file types constants 2025-11-18 13:24:34 +07:00
rstubryan 0f9019e7b4 fix(resolve): fix resolve MR 2025-11-18 11:36:41 +07:00
rstubryan 14b7f06369 fix(resolve): fix resolve MR 2025-11-18 11:17:20 +07:00
rstubryan 4dd50622a9 feat(FE-170,174,175): enhance grading button with consumable eggs validation and update rejection notes 2025-11-18 11:11:32 +07:00
rstubryan 6022ff2dae feat(FE-170,174,175): add tooltip for grading button based on consumable eggs validation 2025-11-18 10:48:41 +07:00
rstubryan 9164b985b1 feat(FE-170,174,175): implement approval lines for growing and laying recording categories 2025-11-18 10:37:10 +07:00
rstubryan 38cab1464c refactor(FE-170,174,175): add layout component and enhance API data fetching limits 2025-11-18 09:40:35 +07:00
Adnan Zahir 71b7598f87 Merge branch 'feat/FE/US-163/expense-request' into 'development'
[FEAT/FE][US#163] Expense Request

See merge request mbugroup/lti-web-client!55
2025-11-18 09:25:50 +07:00
Rivaldi A N S 075e5e452f Merge branch 'feat/FE/US-163/TASK-188-193-195-196-198-expense-request' into 'feat/FE/US-163/expense-request'
[FEAT/FE][US#163/TASK#188-193-195-196-198] Expense Request

See merge request mbugroup/lti-web-client!54
2025-11-17 09:15:04 +00:00
ValdiANS 8cd054e6aa Merge branch 'development' into feat/FE/US-163/expense-request 2025-11-17 16:04:35 +07:00
randy-ar a9bdb6c36e feat(FE-177): Integrate API sales order and fixing sales order initial state 2025-11-17 15:59:31 +07:00
ValdiANS 8b02d0df1c chore(FE-199): add reference_number, po_number, and approval property 2025-11-17 14:57:55 +07:00
ValdiANS 470cdb8b02 chore(FE-199): create Expense dummy data 2025-11-17 14:56:25 +07:00
ValdiANS da40e7d7be chore(FE-196): create expense request approval line 2025-11-17 14:55:27 +07:00
rstubryan 9260f1aff6 refactor(FE-212): update qty validation in PurchaseRequestForm schema to enforce numeric input 2025-11-17 14:54:15 +07:00
rstubryan 0087ba384c refactor(FE-212): update qty validation in PurchaseRequestForm schema to enforce numeric input 2025-11-17 14:45:46 +07:00
rstubryan 71a41d3f37 feat(FE-208,212): update purchase request form to use 'qty' instead of 'quantity' and add credit term field 2025-11-17 14:38:09 +07:00
ValdiANS c58dde960c chore(FE-188,193): add IDR prefix 2025-11-17 14:23:35 +07:00
ValdiANS 4e88e76538 feat(FE-193): add existing documents link 2025-11-17 14:10:08 +07:00
ValdiANS e6ac11893a chore(FE-198): create UploadRequestDocumentsFormSchema and UploadRequestDocumentsFormValues 2025-11-17 14:07:14 +07:00
ValdiANS 83f1ba46a7 chore(FE-188,193): adjust ExpenseKandangsTable component 2025-11-17 14:05:24 +07:00
ValdiANS fc76b44279 feat(FE-195,196): create RealizationStatusBadge component 2025-11-17 14:00:16 +07:00
ValdiANS dbe6ced602 feat(FE-195,196): create ExpenseStatusBadge component 2025-11-17 13:58:37 +07:00
ValdiANS f01e764d9c feat(FE-195): add filter and approve/reject functionality 2025-11-17 13:56:26 +07:00
rstubryan 6467af35bc refactor(FE-208): restructure goods receipt table columns in PurchaseOrderDetail 2025-11-17 13:51:32 +07:00
ValdiANS ac227f7780 feat(FE-196): create ExpenseDetail component for expense detail page 2025-11-17 13:48:07 +07:00
rstubryan c8f1ea0e4f feat(FE-208): add index column to goods receipt table in PurchaseOrderDetail 2025-11-17 13:45:28 +07:00
ValdiANS 6067c00219 feat(FE-193): create Expense Edit page 2025-11-17 13:40:40 +07:00
rstubryan 283c2b2a44 feat(FE-208,212): implement bulk delete functionality for purchase order items with confirmation modal 2025-11-17 13:21:43 +07:00
rstubryan 7ec4105454 refactor(FE-208,212): implement delete functionality for purchase order items with confirmation modal 2025-11-17 13:09:47 +07:00
ValdiANS a151abfbe9 feat(FE-196): create Expense Detail page 2025-11-17 11:58:34 +07:00
ValdiANS e14d10c503 chore(FE-193,196): create expense detail layout file 2025-11-17 11:57:44 +07:00
rstubryan d0ba9eadbd refactor(FE-208): add edit functionality and modal for Penerimaan Barang in PurchaseOrderDetail 2025-11-17 11:29:17 +07:00
rstubryan 2190f65cb2 refactor(FE-208): add edit functionality to Item Pembelian section in PurchaseOrderDetail 2025-11-17 11:15:13 +07:00
rstubryan b82ba60a32 refactor(FE-208): enhance PurchaseOrderDetail layout with section header for goods receipt information 2025-11-17 10:21:17 +07:00
rstubryan 30ed70b669 refactor(FE-212): add DeletePurchaseRequestItemPayload and implement PurchaseDeleteItemsService 2025-11-17 10:13:30 +07:00
rstubryan 69a8899cac refactor(FE-212): simplify PurchaseRequestService to a constant API instance 2025-11-17 09:39:16 +07:00
rstubryan 9f41768e54 refactor(FE-208): rename PurchaseRequisitions to PurchaseRequest and update related API references 2025-11-17 09:22:49 +07:00
rstubryan c951f09667 refactor(FE-208): rename PurchaseRequisitions to PurchaseRequest and update related API references 2025-11-17 09:21:18 +07:00
randy-ar d3c4706d87 refactor(FE-177-166-167): separate table repeater component and adjust data types with new API Payload 2025-11-16 23:19:28 +07:00
rstubryan 64605b168e refactor(FE-208): remove period from currency formatting in invoice display 2025-11-15 10:57:30 +07:00
rstubryan e421c7d422 refactor(FE-208): enhance PurchaseOrderInvoice layout with improved cell styling and add inner table header 2025-11-15 10:54:59 +07:00
rstubryan 4bd6ac3cac refactor(FE-208): enhance PurchaseOrderInvoice styles with primary color and adjust address maxWidth 2025-11-15 10:43:46 +07:00
rstubryan e638856ea9 chore(deps): add @react-pdf/renderer dependency for PDF generation functionality 2025-11-15 10:36:30 +07:00
rstubryan c45c8601cb feat(FE-208): add PurchaseOrderInvoice component for PDF generation and update PurchaseOrderDetail to integrate invoice display 2025-11-15 10:36:01 +07:00
rstubryan 57a867f611 refactor(FE-208): update approval buttons in PurchaseOrderDetail to include Manager Approval 2025-11-14 16:08:30 +07:00
rstubryan a5758aece4 refactor(FE-208): remove unnecessary font styling from purchase number display in PurchaseOrderDetail 2025-11-14 16:07:21 +07:00
randy-ar 3fdb10ec7f feat(FE-177): refactor sales order management with new schema and API integration 2025-11-14 15:52:58 +07:00
ValdiANS 1ee0454e6b Merge branch 'development' into feat/FE/US-163/TASK-188-193-198-slicing-expense-request-form 2025-11-14 13:41:47 +07:00
rstubryan 0c4c0ce3ab feat(FE-208,212): add PO document path and update PurchaseOrderDetail to display document link 2025-11-14 13:22:05 +07:00
rstubryan 00e0202be2 feat(FE-208): add confirmation modal for manager approval with notes functionality 2025-11-14 10:52:36 +07:00
rstubryan 3d49947c1e feat(FE-212): add manager approval requisition type and service with nullable notes 2025-11-14 10:52:21 +07:00
rstubryan 1ab72b8637 feat(FE-208): add staff and accept approval modals with action buttons in PurchaseOrderDetail 2025-11-14 10:23:37 +07:00
rstubryan f98a597115 refactor(FE-208): refactor PurchaseOrderDetail to integrate Purchase data and update Goods Receipt structure 2025-11-14 10:11:13 +07:00
rstubryan 1be61ae4ff feat(FE-212): extend PurchaseItem type with additional fields for enhanced purchase details 2025-11-14 09:09:23 +07:00
rstubryan 1b64c1f5d1 feat(FE-208): add goods receipt section with table and dummy data in purchase order detail view 2025-11-14 09:05:58 +07:00
rstubryan 7485919e52 feat(FE-208): implement purchase order detail view with collapsible sections and summary table 2025-11-13 16:43:08 +07:00
rstubryan e5d9612e29 refactor(FE-208): update 'Purchase' title to 'Pembelian' in constants 2025-11-13 15:50:11 +07:00
rstubryan b6ac8026c7 chore: prettier format 2025-11-13 15:43:41 +07:00
rstubryan d9ebde65cb chore: prettier format 2025-11-13 15:35:15 +07:00
Adnan Zahir c6f881c78d Merge branch 'feat/FE/US-75-chick-in-doc' into 'development'
[FEAT/FE][US#75] Refactor Chick In DOC

See merge request mbugroup/lti-web-client!52
2025-11-13 15:19:16 +07:00
Rivaldi A N S 18b036285a Merge branch 'dev/randy' into 'feat/FE/US-75-chick-in-doc'
[FIX/FE][US#17/TASK#238-239-240] Resolve Merge Conflict

See merge request mbugroup/lti-web-client!53
2025-11-13 07:54:40 +00:00
rstubryan 5648b51c2e feat(FE-Storyless): add collapsible functionality and improve image handling 2025-11-13 14:54:37 +07:00
rstubryan c7bad200ae chore: prettier format 2025-11-13 14:30:24 +07:00
rstubryan a2dd781140 chore: prettier format 2025-11-13 14:28:46 +07:00
randy-ar 10976452f5 fix(FE-85): remove debug message in flock edit page 2025-11-13 14:25:44 +07:00
ValdiANS 6ffb6e1560 chore: prettier format 2025-11-13 14:25:03 +07:00
ValdiANS 138c97a695 Merge branch 'development' into feat/FE/US-163/TASK-188-193-198-slicing-expense-request-form 2025-11-13 14:20:28 +07:00
randy-ar 56f57c4a6b fix(FE): resolve merge conflict 2025-11-13 14:12:25 +07:00
rstubryan c2479ad248 chore: prettier format 2025-11-13 14:08:35 +07:00
rstubryan b3f4e42f1a chore: prettier format 2025-11-13 14:01:07 +07:00
rstubryan ac8c39324b fix(resolve): resolve MR 2025-11-13 13:06:18 +07:00
Adnan Zahir 7478c2597f Merge branch 'feat/FE/US-77/transfer-to-laying' into 'development'
[FEAT/FE][US#77] Transfer to Laying - API Integration

See merge request mbugroup/lti-web-client!50
2025-11-13 12:33:30 +07:00
Rivaldi A N S 5975340c3d Merge branch 'dev/randy' into 'feat/FE/US-75-chick-in-doc'
[FEAT/FE][US#75/TASK#238-239-240] Refactor Chick In DOC

See merge request mbugroup/lti-web-client!48
2025-11-13 04:53:00 +00:00
randy-ar e5318fd6b5 refactor(FE-238-86): change useApprovalSteps params, and minimize fetching data 2025-11-13 11:18:11 +07:00
randy-ar def7ee4a0b fix(FE-238): hide approval button when chickin on submission 2025-11-13 10:46:11 +07:00
rstubryan 26811f5e3e Merge branch 'development' of gitlab.com:mbugroup/lti-web-client into feat/FE/US-161/TASK-208-212-slicing-ui-and-validation-create-purchase-request-form 2025-11-13 10:24:37 +07:00
randy-ar 4485ea8181 fix(FE-238): mengubah ui form chick in 2025-11-13 09:54:51 +07:00
rstubryan 57ca050100 Merge branch 'development' of gitlab.com:mbugroup/lti-web-client into feat/FE/US-78/TASK-170-174-slicing-ui-and-validation-create-daily-recording-laying-form 2025-11-13 09:34:52 +07:00
rstubryan b64ab6567b feat(FE-170,175): simplify approval status logic in GradingForm and RecordingForm 2025-11-13 09:23:29 +07:00
rstubryan 478ca186d3 feat(FE-170,175): add approval steps and status display in GradingForm and RecordingForm 2025-11-12 23:41:22 +07:00
rstubryan 47262adaf1 feat(FE-170,174,175): implement approval steps in RecordingForm and remove unused form step status 2025-11-12 23:12:22 +07:00
rstubryan e2249cf73a chore(FE-Storyless): temp fix resolve issue error on flock name 2025-11-12 22:24:06 +07:00
rstubryan 0e7c178736 feat(FE-170): enhance RecordingForm to include kandang_id from lookup and simplify product labels 2025-11-12 22:13:17 +07:00
rstubryan 4a974048a7 feat(FE-208): refactor Purchase Order forms to use table layout for improved readability and maintainability 2025-11-12 21:52:02 +07:00
rstubryan cd8ab8844b feat(FE-208): enhance Purchase Order acceptance form with Card component and improved layout for received date inputs 2025-11-12 20:43:34 +07:00
rstubryan 5d88af1a31 feat(FE-208,212): implement table-based UI for Purchase Order acceptance and staff approval forms 2025-11-12 20:27:06 +07:00
randy-ar fa3ba46810 refactor(FE): menambahkan parameter params useApprovalSteps dan return rawData 2025-11-12 17:03:37 +07:00
rstubryan 4215c6c6ce feat(FE-208): enhance DateInput component with range selection and modal support 2025-11-12 16:54:17 +07:00
randy-ar 6670f1e31b refactor(FE-238-239-240): implement approval workflow chickin & project flock, membuat custom hook useApprovals, dan handling error format approvals 2025-11-12 15:25:14 +07:00
randy-ar b2f4317c08 refactor(FE-238-239-240): implement approval workflow chickin & project flock, membuat custom hook useApprovals, dan handling error format approvals 2025-11-12 15:24:44 +07:00
Rivaldi A N S b9fb3c8311 Merge branch 'feat/FE/US-77/TASK-149-transfer-to-laying-api-integration' into 'feat/FE/US-77/transfer-to-laying'
[FEAT/FE][US#77/TASK#149] API Integration

See merge request mbugroup/lti-web-client!49
2025-11-12 06:48:25 +00:00
ValdiANS 305ad67cb4 chore: run format before commit 2025-11-12 13:39:48 +07:00
ValdiANS e3ecf5dc50 feat(FE-149): adjust BaseTransferToLaying and CreateTransferToLayingPayload structure based on the API 2025-11-12 13:38:12 +07:00
ValdiANS bc8ba1df9c feat(FE-149): add flock_name and kandangs.project_flock_kandang_id field 2025-11-12 13:37:05 +07:00
ValdiANS e7d2c3bc13 feat: add capacity to kandang 2025-11-12 13:36:33 +07:00
ValdiANS b7a055888b chore: remove unnecessary code 2025-11-12 13:36:22 +07:00
ValdiANS 8d09aec66a feat(FE-149): integrate TransferToLayingService to API 2025-11-12 13:36:12 +07:00
ValdiANS 776b809931 chore: change project flock API endpoint 2025-11-12 13:35:24 +07:00
ValdiANS c6fb707a9f chore(FE-149): add TRANSFER_TO_LAYING_APPROVAL_LINE constant 2025-11-12 13:34:49 +07:00
ValdiANS 569a8b495b feat(FE-149): integrate TransferToLayingForm to API 2025-11-12 13:34:25 +07:00
ValdiANS 1ff1e53e02 feat(FE-149): create getTransferToLayingFormInitialValues and getFilledTransferToLayingFormInitialValues helper function 2025-11-12 13:32:23 +07:00
ValdiANS 8e3282bb7d feat(FE-149): integrate TransferToLayingsTable to API 2025-11-12 13:31:35 +07:00
ValdiANS 3c0bd647a8 chore: add capacity dummy data 2025-11-12 13:30:35 +07:00
ValdiANS 557e20cffe chore: set approval status to idle if previous status is rejected 2025-11-12 13:25:58 +07:00
ValdiANS 5124c1b66a chore: create ConfirmationModalWithNotes component 2025-11-12 13:24:51 +07:00
ValdiANS c9092f36e3 chore: add children prop 2025-11-12 13:23:20 +07:00
ValdiANS 73ab5703db chore: update DateInput component 2025-11-12 13:19:00 +07:00
ValdiANS 2959295bfa chore: add enableRowSelection prop 2025-11-12 13:18:26 +07:00
ValdiANS 03b16248e5 chore: update Modal component 2025-11-12 13:15:47 +07:00
rstubryan f264474293 refactor(FE-208): update modal width classes in PurchaseTable for improved responsiveness 2025-11-12 13:14:27 +07:00
ValdiANS 963377199f feat(FE-149): integrate transfer to laying edit page to API 2025-11-12 13:11:30 +07:00
ValdiANS 4bbf6fd7f8 feat(FE-149): integrate transfer to laying detail page to API 2025-11-12 13:10:18 +07:00
ValdiANS 4422b7391a chore(FE-149): install react-day-picker 2025-11-12 13:04:09 +07:00
rstubryan c770651a01 refactor(FE-212): simplify validation for supplier, area, location, and warehouse fields in PurchaseRequisitionsForm 2025-11-12 12:58:08 +07:00
rstubryan 603f95a9b2 refactor(FE-208,212): update terminology in PurchaseOrder forms for consistency and clarity 2025-11-12 11:54:00 +07:00
rstubryan f26e54e8f2 refactor(FE-208,212): update width classes for form fields in PurchaseOrder forms for better responsiveness 2025-11-12 11:16:46 +07:00
rstubryan bc53b9073c feat(FE-208,212): simplify PurchaseOrder forms by removing unused fields and updating user names 2025-11-12 10:51:57 +07:00
rstubryan 45f12cad4f feat(FE-Storyless): update modal functionality to use show() method and clean up code 2025-11-12 09:33:32 +07:00
randy-ar 5dccaf40cb refactor(FE-88): memisahkan file api project flock & penyesuaian tipe data dan paylod dengan BE 2025-11-12 09:04:23 +07:00
rstubryan fde9c449a6 feat(FE-Storyless): update UI form UI repo 2025-11-12 08:57:06 +07:00
rstubryan ecb497430a feat(FE-208,212): enhance PurchaseOrder forms with onCancel functionality and UI improvements 2025-11-11 15:05:05 +07:00
rstubryan 8c17367fb6 feat(FE-208,212): add PurchaseOrderAcceptApprovalForm and validation schema for acceptance of purchase requisitions 2025-11-11 14:06:53 +07:00
rstubryan 21ac73527d feat(FE-212): refactor purchase requisitions services and update item schema for approval process 2025-11-11 13:23:48 +07:00
kris f00e772018 Update .gitlab-ci.yml file 2025-11-11 06:07:24 +00:00
rstubryan f7b2e3c6f2 feat(FE-208,212): add PurchaseRequisitionsStaffApprovalForm and schema for staff approval process 2025-11-11 11:26:46 +07:00
rstubryan 5fc01a9afa feat(FE-208): use CheckboxInput component for item selection in PurchaseRequisitionsForm 2025-11-11 11:26:22 +07:00
rstubryan 3ed3e2e21a feat(FE-208): add PurchaseOrderDetail component for displaying approval steps 2025-11-10 17:09:28 +07:00
rstubryan 7d1992d075 feat(FE-212): add staff approval service and payload types for purchase requisitions 2025-11-10 17:09:04 +07:00
randy-ar f63d3d3870 refactor(FE): Refactor project flock api & implement approval component in project flock details 2025-11-10 17:05:24 +07:00
rstubryan 63dac00f17 feat(FE-212): add PURCHASE_ORDER_APPROVAL_LINE for purchase order approval steps 2025-11-10 14:33:20 +07:00
rstubryan efcc14f3ab refactor(FE-212): rename PurchaseApi to PurchaseRequisitionsApi and update related references in forms and tables 2025-11-10 14:33:01 +07:00
rstubryan 5e64d37c61 Merge branch 'development' of gitlab.com:mbugroup/lti-web-client into feat/FE/US-161/TASK-208-212-slicing-ui-and-validation-create-purchase-request-form 2025-11-10 13:12:02 +07:00
rstubryan c7022ee200 Merge branch 'development' of gitlab.com:mbugroup/lti-web-client into feat/FE/US-78/TASK-170-174-slicing-ui-and-validation-create-daily-recording-laying-form 2025-11-10 08:37:23 +07:00
rstubryan 3ac0672f7e feat(FE-170,175): update RecordingForm to include selectedKandang in product URL generation and options filtering 2025-11-10 08:36:55 +07:00
randy-ar 9f4f140018 refactor(FE-239-238): Refactor UI & API Integration For Form Chickin & Chickin Details 2025-11-10 06:07:02 +07:00
randy-ar e0c347c3d5 refactor(FE-87-106): refactor api integration untuk project flock dan project flock kandang 2025-11-10 04:08:08 +07:00
rstubryan 8db9d1a52c refactor(FE-212): update product warehouse fetching logic and options mapping in PurchaseRequisitionsForm 2025-11-08 10:53:29 +07:00
rstubryan 10dca5c692 refactor(FE-208): rename PurchaseRequestForm to PurchaseRequisitionsForm and update related components 2025-11-08 09:53:21 +07:00
rstubryan 53751d566c refactor(FE-212): rename PurchaseRequestForm schema to PurchaseRequisitionsForm and update related types 2025-11-08 09:52:48 +07:00
rstubryan 12a1e61b68 refactor(FE-212): update purchase types and payloads for requisition handling 2025-11-08 09:52:34 +07:00
rstubryan 4f88f26b71 feat(FE-170,175): update approval logic in RecordingTable to include additional conditions for egg grading status 2025-11-07 14:56:28 +07:00
rstubryan 80fcabde7e feat(FE-170,175): extend GradingForm to support additional grading data and improve form initialization 2025-11-07 14:56:03 +07:00
rstubryan 2e35462300 feat(FE-170): change Cancel button to Reset in RecordingForm for improved form handling 2025-11-07 08:51:54 +07:00
rstubryan f8f613ec9d refactor(FE-170,175): update approval logic in RecordingForm to consider grading data for LAYING category 2025-11-06 23:45:02 +07:00
rstubryan a1bf38023c feat(FE-170,175): enhance approval logic and tooltips for LAYING category recordings in RecordingTable 2025-11-06 23:40:13 +07:00
rstubryan f032f71136 feat(FE-170,175): implement payload creation for growing and laying recordings in RecordingForm 2025-11-06 23:27:46 +07:00
rstubryan 2e5530cf91 refactor(FE-170): simplify confirmation modal text in RecordingTable 2025-11-06 23:15:50 +07:00
rstubryan c45217e98e feat(FE-170,175): add grading data handling in RecordingForm and update types 2025-11-06 22:40:04 +07:00
rstubryan 62c16bb9d1 feat(FE-170,175): enhance RecordingTable with grading completion checks and approval logic 2025-11-06 22:28:31 +07:00
rstubryan c012668340 feat(FE-175): update grading logic in GradingForm to utilize konsumsiBaikEggId 2025-11-06 21:38:52 +07:00
ValdiANS 512e016b5e chore(FE-199): adjust Expense type 2025-11-06 21:11:18 +07:00
ValdiANS 57ffd50558 feat(FE-195): set expense table column header and cell 2025-11-06 21:10:50 +07:00
rstubryan 5245d44a79 feat(FE-170,175): add module_id prop to approval history modal in RecordingTable 2025-11-06 19:13:11 +07:00
rstubryan b39e8325f8 feat(FE-170): simplify action buttons in RecordingForm for detail view 2025-11-06 17:47:34 +07:00
rstubryan b24c9d8336 feat(FE-170): add approval logic to RecordingForm for detail view actions 2025-11-06 17:17:49 +07:00
rstubryan d8b076d105 feat(FE-170,175): enhance RecordingForm and RecordingTable with approval logic and UI improvements 2025-11-06 17:12:30 +07:00
randy-ar fcc2fced06 feat(FE-166-167-168): slicing ui create, edit dan detail sales order 2025-11-06 16:57:17 +07:00
rstubryan ffa11fa20a feat(FE-170): add grading button for laying category in RecordingTable 2025-11-06 15:46:21 +07:00
ValdiANS e4b61cfe05 chore(FE-199): create Expense API service with dummy data 2025-11-06 15:30:22 +07:00
ValdiANS c59a88bbcb chore(FE-188,193): create formik helper function utils and create removeArrayItemAndSync formik helper function 2025-11-06 15:29:42 +07:00
ValdiANS a8b1f6f8c2 chore(FE-188,193): create convertRowSelectionArrToObj and convertRowSelectionObjToArr helper function 2025-11-06 15:29:15 +07:00
ValdiANS 6e582c4e7c chore(FE-188,193): create ACCEPTED_FILE_TYPES constant 2025-11-06 15:29:00 +07:00
ValdiANS f011f5b7f9 feat(FE-188,193): create ExpenseRequestKandangDetailExpense component 2025-11-06 15:28:42 +07:00
ValdiANS 1d4a16cd0b feat(FE-198): add kandangs, existing_documents, kandangExpenses to ExpenseFormSchemaType and create helper function to get form initial values 2025-11-06 15:28:12 +07:00
ValdiANS 2a71734583 feat(FE-188,193): add Vendor, Request Documents, and Kandang Detail Expense input 2025-11-06 15:26:54 +07:00
ValdiANS e9eee6eb3e feat(FE-188,193): create ExpenseKandangsTable component 2025-11-06 15:22:03 +07:00
rstubryan 069ab98da1 refactor(FE-170): refactor RecordingForm navigation and action buttons for improved user experience 2025-11-06 15:19:01 +07:00
rstubryan 90dd26064d feat(FE-170,175): enhance GradingForm with additional recording details and improve UI for grading information 2025-11-06 15:12:04 +07:00
rstubryan de9ec716f5 feat(FE-170,175): add toast notification for grading exceeding available eggs and enhance UI for grading information 2025-11-06 14:53:21 +07:00
rstubryan 501222a4ee feat(FE-170,175): enhance GradingForm with total egg consumption display and validation for grading limits 2025-11-06 14:42:17 +07:00
rstubryan 62c595bdf6 feat(FE-170,175): enhance product fetching in RecordingForm with additional filters and limits 2025-11-06 14:26:45 +07:00
rstubryan 06eec88d56 feat(FE-170,175): implement form steps and navigation for LAYING category in RecordingForm 2025-11-06 14:13:16 +07:00
randy-ar 158971d904 feat(FE-166-169): Slicing UI Penjualan Form dan Client side validation 2025-11-06 13:45:52 +07:00
rstubryan 6d8d608cc9 refactor(FE-170): add support for 'UPDATED' action in RecordingTable with corresponding status text 2025-11-06 13:27:18 +07:00
rstubryan c9edc407b4 refactor(FE-174,175): update approve method to allow custom notes in RecordingForm 2025-11-06 13:08:26 +07:00
rstubryan c774480a5a refactor(FE-170): enhance RecordingForm with approve and reject buttons for detail view 2025-11-06 13:05:48 +07:00
rstubryan fa42f9b941 refactor(FE-170): clean up imports and enhance state management in RecordingForm 2025-11-06 10:58:14 +07:00
rstubryan 3d3569bbc0 feat(FE-170,175): integrate ProjectFlockKandang API and enhance RecordingForm with detailed project flock and kandang options 2025-11-06 10:33:45 +07:00
rstubryan a524dec16d refactor(FE-174): add ProjectFlockKandang API and enhance type definitions 2025-11-06 09:53:32 +07:00
rstubryan 4e40aba544 refactor(FE-170): refine product name checks in RecordingForm by removing specific keywords 2025-11-06 09:21:01 +07:00
rstubryan 6c164313de refactor(FE-Storyless): correct endpoint URL for project flocks in RecordingService 2025-11-06 09:18:52 +07:00
rstubryan be98655c75 feat(FE-170): improve product name checks in RecordingForm for better matching 2025-11-05 16:43:18 +07:00
rstubryan 333212a1de feat(FE-170,174,175): enhance RecordingForm with product warehouse integration and improve data handling 2025-11-05 15:39:19 +07:00
rstubryan a33a4167c1 refactor(FE-170,175): update approval notes handling in RecordingTable for better clarity 2025-11-05 14:00:48 +07:00
rstubryan 2cf8bcf746 feat(FE-170): refactor approval history button and badge components in RecordingTable 2025-11-05 14:00:02 +07:00
rstubryan b1457a5feb feat(FE-170,174,175): add approval history modal and integrate approval API in RecordingTable 2025-11-05 13:41:55 +07:00
rstubryan fac9d5fa42 feat(FE-170,174): update validation messages and labels for egg product fields in RecordingForm 2025-11-05 13:13:46 +07:00
rstubryan 4454eac8af feat(FE-170,175): implement multi-select approval and rejection for recordings in RecordingTable 2025-11-05 10:01:07 +07:00
rstubryan fa36c10c01 feat(FE-170,175): add approval and rejection functionality with confirmation modals in RecordingTable 2025-11-05 09:46:38 +07:00
rstubryan 02cc4a759d feat(FE-Storyless): add approval workflows for project flocks and recordings 2025-11-05 08:43:10 +07:00
rstubryan 04a1f5e014 feat(FE-170,174): add total_weight field and update calculations in body_weights for RecordingForm 2025-11-04 16:23:29 +07:00
rstubryan b7ab537b95 feat(FE-170): add selection checkboxes and enhance project details in RecordingTable 2025-11-04 16:07:02 +07:00
rstubryan b0665b2541 refactor(FE-174): rename name to flock_name in BaseProjectFlock type for clarity 2025-11-04 16:06:39 +07:00
rstubryan 77e3fe12c3 refactor(FE-170): update API endpoint and rename label for project flock in RecordingForm 2025-11-04 16:06:04 +07:00
ValdiANS 6a070e39da chore(FE-188): updateDropFileInput component 2025-11-04 15:54:13 +07:00
ValdiANS 3b69286a8e chore(FE-188): add DropFileInput component 2025-11-04 15:47:01 +07:00
ValdiANS 0de2e87221 fix(FE-188): required symbol space 2025-11-04 15:46:49 +07:00
ValdiANS 9daa6aaf8c chore(FE-188): update Modal component 2025-11-04 15:46:30 +07:00
ValdiANS a12ae51f3a fix(FE-188): rename to ExpenseRequestForm 2025-11-04 15:46:08 +07:00
ValdiANS 17c316c4af fix(FE-188): required symbol space 2025-11-04 15:45:36 +07:00
ValdiANS c438a8f6aa chore: install react-dropzone 2025-11-04 15:39:55 +07:00
rstubryan 966ad7545c refactor(FE-174): rename project_flock_kandangs_id to project_flock_kandang_id for consistency in RecordingForm 2025-11-04 15:20:33 +07:00
rstubryan 0a17249fb9 refactor(FE-174): rename project_flock_kandangs_id to project_flock_kandang_id for consistency in RecordingForm schema 2025-11-04 14:54:07 +07:00
rstubryan b19be7dd4b refactor(FE-174): update recording types to include approval and egg grading fields for enhanced data handling 2025-11-04 14:53:07 +07:00
rstubryan 8c29358594 refactor(FE-208): remove required attribute from Area and Lokasi SelectInputs in PurchaseRequestForm 2025-11-04 14:36:07 +07:00
randy-ar d8637923bd refactor(FE-106-91-339-238): Slicing UI Chickin DOC Refactored 2025-11-04 13:24:10 +07:00
rstubryan 9d86e21657 refactor(FE-208): remove checkbox selection from PurchaseTable component 2025-11-04 13:20:44 +07:00
rstubryan ef193b9f03 feat(FE-208,212): enhance PurchaseRequestForm with dummy data and update type definitions for purchase items 2025-11-04 13:17:43 +07:00
rstubryan 4828af71b8 feat(FE-208): create PurchaseEdit page with dummy data and integrate PurchaseRequestForm 2025-11-04 11:31:32 +07:00
rstubryan 3312a47f38 feat(FE-208): create PurchaseDetail page with dummy data and integrate PurchaseRequestForm 2025-11-04 11:22:52 +07:00
rstubryan c790180e86 feat(FE-208): add Layout component to wrap children with SuspenseHelper 2025-11-04 10:51:54 +07:00
rstubryan ef339e128d feat(FE-208,212): add Purchase and PurchaseTable components for managing purchase requests 2025-11-04 10:51:12 +07:00
rstubryan 7c9c7eac10 refactor(FE-208,212): update import path for PurchaseRequestForm to reflect new directory structure 2025-11-04 10:49:45 +07:00
rstubryan 986830aa47 refactor(FE-208,212): rename PurchaseRequestForm files and update import paths for consistency 2025-11-04 10:49:19 +07:00
rstubryan 1e44fec15f feat(FE-208,212): implement PurchaseService for fetching purchase request data with dummy response 2025-11-04 10:48:57 +07:00
rstubryan 39dbf57d7f refactor(FE-208,212): streamline PurchaseRequestForm structure, enhance state management, and improve field handling for purchase items 2025-11-04 09:20:39 +07:00
rstubryan 289c8d5672 refactor(FE-208,212): enhance PurchaseRequestForm with product data fetching, update price and UOM fields based on selected products 2025-11-04 08:56:57 +07:00
ValdiANS afa0c6c83f chore: rename ExpenseForm to ExpenseRequestForm 2025-11-03 16:16:12 +07:00
ValdiANS 1afa6f7fad chore: rename ExpenseForm.schema.ts to ExpenseRequestForm.schema.ts 2025-11-03 16:15:19 +07:00
rstubryan ee24ceaff1 refactor(FE-208,212): update PurchaseRequestForm to reset location fields on area change, improve handling of location value and dependencies 2025-11-03 15:45:42 +07:00
rstubryan ecdd8ae49c refactor(FE-208,212): update PurchaseRequestForm schema and validation, improve credit term handling and reset logic for supplier changes 2025-11-03 15:19:19 +07:00
rstubryan e1d070b3af refactor(FE-208,212): update PurchaseRequestForm schema and validation, enhance credit term handling and improve error messages for required fields 2025-11-03 15:02:00 +07:00
rstubryan 4149c51a7b refactor(FE-208,212): update PurchaseRequestForm validation for area and location fields, enhance error handling and conditional checks 2025-11-03 14:29:24 +07:00
rstubryan ae5a57277b refactor(FE-208,212): enhance PurchaseRequestForm with location and warehouse handling, update validation and reset logic for dependent fields 2025-11-03 14:06:32 +07:00
rstubryan 7b19cd4a21 refactor(FE-208,212): enhance PurchaseRequestForm with area and location fields, update validation and data handling for new inputs 2025-11-03 13:01:17 +07:00
rstubryan 408250d7ed refactor(FE-208): enhance PurchaseRequestForm layout and actions, replace header with custom component and improve button handling 2025-11-03 11:39:37 +07:00
rstubryan ae91e17ac0 refactor(FE-207,212): update PurchaseRequestForm schema and validation, enforce required fields and improve data handling for purchase items 2025-11-03 11:29:43 +07:00
rstubryan b4a9c86c2a refactor(FE-212): update PurchaseRequestForm schema and validation, streamline warehouse handling and add sub quantity field 2025-11-03 11:04:07 +07:00
rstubryan 1d79e8de1d refactor(FE-Storyless): streamline RecordingForm component by native card and optimizing layout for better usability 2025-11-03 10:45:36 +07:00
rstubryan e4ab86c3eb refactor(FE-170): streamline RecordingForm component by native card and optimizing layout for better usability 2025-11-03 10:44:37 +07:00
rstubryan d8599a850a refactor(FE-170): streamline RecordingTable component by removing unused state and optimizing layout for better usability 2025-11-03 10:40:13 +07:00
ValdiANS ae560c2451 chore: run prettier formatting before every commit 2025-11-03 10:31:44 +07:00
rstubryan bcb4d4492d refactor(FE-170): replace FormHeader with custom header in GradingForm and RecordingForm for improved layout and navigation 2025-11-03 10:30:33 +07:00
ValdiANS 176e1e7cb8 chore: install react-day-picker 2025-11-03 10:29:23 +07:00
ValdiANS f6d4ef4697 chore: update DateInput component 2025-11-03 10:27:51 +07:00
rstubryan e9e8ad771e refactor(FE-174): enhance GradingForm and RecordingForm with improved error handling and modal integration for delete actions 2025-11-03 10:22:35 +07:00
randy-ar 219cbedbcd refactor(FE-238-106): change dateinput and create chickin page and pull development 2025-11-03 10:12:15 +07:00
rstubryan d53f7fc72f fix(resolve): fix resolve merge 2025-11-03 10:12:12 +07:00
randy-ar 3eb2930640 refactor(FE-238-106): change dateinput and create chickin page 2025-11-03 10:09:12 +07:00
rstubryan 4e4117b5b0 fix(resolve): fix resolve merge 2025-11-03 10:02:26 +07:00
rstubryan 2ba23654ce refactor(FE-Storyless): simplify RowOptionsMenu by using RowOptionsMenuWrapper and enhance button layout 2025-11-03 09:44:50 +07:00
rstubryan ac11559754 chore(FE-Storyless): remove inputmask package and its type definitions from dependencies 2025-11-03 09:35:52 +07:00
rstubryan fa1552e276 fix(resolve): fix resolve merge 2025-11-03 09:35:09 +07:00
rstubryan 9a4d961dee refactor(FE-174): implement create, update, and delete grading methods in RecordingApi and update handlers 2025-11-03 09:28:20 +07:00
ValdiANS 33c0d5513c Merge branch 'development' into feat/FE/US-163/expense-request 2025-11-03 09:26:03 +07:00
rstubryan c26e174885 refactor(FE-174): enhance RecordingApi by adding approve and reject methods for better approval handling 2025-11-03 09:00:49 +07:00
rstubryan b976600099 refactor(FE-170,174): update GradingForm to include recording_egg_id in grading data enhance validation schema 2025-11-02 23:22:37 +07:00
rstubryan aac7215be7 refactor(FE-170,174): update schema and validation for stocks and depletions; rename usage_qty to qty for consistency 2025-11-02 23:14:07 +07:00
rstubryan e116311dc2 refactor(FE-170,174): restructure schema and validation for body weights, stocks, and depletions; improve handling of input values 2025-11-02 23:04:54 +07:00
rstubryan 4afeded080 Merge branch 'dev/restu' of gitlab.com:mbugroup/lti-web-client into feat/FE/US-78/TASK-170-174-slicing-ui-and-validation-create-daily-recording-laying-form 2025-11-02 21:53:56 +07:00
rstubryan 83757b5208 fix(resolve): fix resolve merge 2025-11-02 21:53:41 +07:00
rstubryan f335bc23eb refactor(FE-Storyless): simplify MovementForm by integrating useSelect for warehouse and supplier inputs, enhance data fetching logic 2025-11-02 21:42:03 +07:00
rstubryan d793824520 refactor(FE-Storyless): enhance MovementForm schema and validation, improve handling of product quantities and delivery costs 2025-11-02 21:33:38 +07:00
rstubryan 901b61a172 refactor(FE-Storyless): enhance ProductCategoryForm schema and validation, improve UI text and layout 2025-11-02 21:21:57 +07:00
rstubryan 39dd583e77 refactor(FE-Storyless): enhance ProductForm schema and handling, add required fields and improve validation 2025-11-02 21:15:41 +07:00
rstubryan fc3b090da5 refactor(FE-Storyless): replace TextInput with NumberInput for price and tax fields, enhance form handling 2025-11-02 20:59:37 +07:00
rstubryan 16db7af070 chore(FE-Storyless): remove inputmask and related type definitions 2025-11-02 20:14:22 +07:00
rstubryan f70433d901 refactor(FE-Storyless): remove UpdateMovementPayload type and related schema, streamline MovementForm handling 2025-11-01 10:43:43 +07:00
rstubryan 393f8a6d1b Merge remote-tracking branch 'origin/dev/restu' into dev/restu
# Conflicts:
#	src/components/pages/inventory/movement/MovementTable.tsx
2025-11-01 09:46:46 +07:00
rstubryan e73d3e0823 refactor(FE-Storyless): add product and warehouse filters with select inputs 2025-11-01 09:46:31 +07:00
rstubryan ee4a470fd2 refactor(FE-Storyless): add product and warehouse filters with select inputs 2025-11-01 09:46:06 +07:00
rstubryan 40171720fb Merge branch 'development' of gitlab.com:mbugroup/lti-web-client into dev/restu 2025-11-01 08:36:04 +07:00
rstubryan 09cb5f10aa refactor(FE-Storyless): replace FormHeader and FormActions with custom header and action buttons for improved UI 2025-11-01 08:35:46 +07:00
rstubryan 1228b45045 feat(FE-170,174): clean up RecordingForm and RecordingTable components for improved readability and maintainability 2025-10-31 17:27:10 +07:00
rstubryan 19afb80597 feat(FE-170,174): refactor GradingForm to use grading form handlers and remove approval logic 2025-10-31 17:26:56 +07:00
rstubryan 9495742cb7 feat(FE-174): add grading form handlers for creating, updating, and deleting grading records 2025-10-31 17:26:24 +07:00
rstubryan 01db13ed6c feat(FE-170,174): add GradingForm component for managing grading records 2025-10-31 15:15:48 +07:00
rstubryan 4a1f775c85 feat(FE-170): update daily recording form to redirect to grading form after successful submission 2025-10-31 15:15:32 +07:00
randy-ar 495e11c6fe fix(FE-41): Menambahkan kolom kapasitas di tabel kandang 2025-10-31 14:57:15 +07:00
ValdiANS 15893c18c9 feat(FE-199): create Expense API types 2025-10-31 14:33:28 +07:00
ValdiANS 026e60704b feat(FE-199): create Expense API service 2025-10-31 14:33:19 +07:00
ValdiANS 21b155e64b feat(FE-195): add Expense menu 2025-10-31 14:30:36 +07:00
ValdiANS 1a1bf8754e feat(FE-188): create Expense Form schema 2025-10-31 14:30:00 +07:00
ValdiANS a51c7c44ec feat(FE-188): create ExpenseForm component 2025-10-31 14:29:31 +07:00
ValdiANS 4d1241d712 feat(FE-195): create ExpenseTable component 2025-10-31 14:29:11 +07:00
ValdiANS 80747bb441 chore(FE-195): adjust ConfirmationModal primaryButton and secondaryButton props 2025-10-31 14:28:51 +07:00
ValdiANS 00f64b1897 chore: add string as the valueKey and labelKey type 2025-10-31 14:28:04 +07:00
ValdiANS 01bfe1cc3b chore: export ButtonProps interface 2025-10-31 14:27:13 +07:00
ValdiANS a0cf6c0f56 feat(FE-188): create Add Expense page 2025-10-31 14:26:52 +07:00
ValdiANS c72befb5b4 feat(FE-195): create Expense page 2025-10-31 14:25:01 +07:00
rstubryan 3a52d800e0 feat(FE-174): add grading functionality to daily recording form with validation 2025-10-31 14:01:51 +07:00
randy-ar b6991652ac feat(FE-169): Slicing UI Index Pengajuan Sales & Define Data Type for Marketing 2025-10-31 13:57:30 +07:00
rstubryan c486d6cf81 feat(FE-170): implement form steps and navigation for daily recording form 2025-10-31 13:52:54 +07:00
rstubryan e7ed3d6ab2 feat(FE-174): add FormStepStatus type to enhance daily recording form state management 2025-10-31 13:52:36 +07:00
rstubryan 2d30514d64 refactor(FE-170,174): simplify daily recording form by removing unused flock period logic 2025-10-31 13:08:55 +07:00
rstubryan 59b0eeea2b feat(FE-170): add egg handling and validation to daily recording form 2025-10-31 00:02:04 +07:00
rstubryan 0e77597a70 refactor(FE-174): add grading and egg handling to daily recording form 2025-10-31 00:01:46 +07:00
rstubryan b7de8b40d8 feat(FE-170,174): implement project flock kandang selection and validation in daily recording form 2025-10-30 21:41:14 +07:00
rstubryan 87295252aa refactor(FE-174): remove unused pending_qty field from stocks in recording type definition 2025-10-30 21:41:01 +07:00
randy-ar 7ab96fac8b Merge branch 'development' of https://gitlab.com/mbugroup/lti-web-client into dev/randy 2025-10-30 21:24:20 +07:00
randy-ar 99194eaf80 refactor(FE-92-87): mengganti select input dengan reuseable component 2025-10-30 21:23:37 +07:00
rstubryan 50196493e3 feat(FE-170,174): add depletion products handling and update select input options in daily recording form 2025-10-30 20:21:37 +07:00
rstubryan 75348620d7 feat(FE-170,174): enhance daily recording form with weight validation and dynamic average weight calculation 2025-10-30 19:09:21 +07:00
rstubryan 4cb045de6c refactor(US-170,174): update recording types and validation schema for daily recording form 2025-10-30 18:10:37 +07:00
rstubryan ae0cca778e chore(FE-Storyless): remove inputmask and its type definitions for cleanup 2025-10-30 18:10:04 +07:00
rstubryan 74503f12d6 fix(FE-Storyless): update SelectInput value handling to use undefined instead of null for better compatibility 2025-10-30 14:01:13 +07:00
rstubryan a5f8eb60c6 fix(FE-Storyless): update SelectInput value handling to use undefined instead of null for better compatibility 2025-10-30 13:32:32 +07:00
rstubryan c83ebd73be refactor(FE-Storyless): remove unnecessary padding from badge styles for improved layout 2025-10-30 13:08:36 +07:00
rstubryan be68353b38 feat(FE-114): add unique keys to SelectInput components in RecordingForm for improved rendering 2025-10-30 12:50:56 +07:00
rstubryan 2307035717 feat(FE-Storyless): add custom control component to SelectInput for adornment support 2025-10-30 12:00:22 +07:00
rstubryan a8fee20133 refactor(FE-208,212): enhance PurchaseRequestForm with product and product warehouse fields 2025-10-30 10:39:23 +07:00
rstubryan b0e8a460fd refactor(FE-208,212): update PurchaseRequestForm schema and component to handle warehouse IDs 2025-10-30 09:29:38 +07:00
rstubryan b2c38cd06f feat(FE-208): create PurchaseRequestForm component and add AddPurchaseRequest page 2025-10-29 21:12:42 +07:00
rstubryan 7ba7b884a4 feat(FE-212): rename purchasing files and update validation schemas for purchase requests 2025-10-29 21:12:24 +07:00
rstubryan 3daf1a518e feat(FE-208): add 'Purchase' link to navigation constants 2025-10-29 21:11:40 +07:00
rstubryan c6fcb17b4d feat(FE-212): add validation schemas for purchase request and update forms 2025-10-29 20:31:31 +07:00
rstubryan 8b09a8d315 feat(FE-212): implement PurchaseApi service for purchase requests 2025-10-29 17:26:26 +07:00
rstubryan 215580215e feat(FE-212): add types for purchase creation and updates 2025-10-29 17:26:06 +07:00
rstubryan c832c4adeb fix(resolve): resolve merge issue 2025-10-29 15:56:57 +07:00
rstubryan eda3f0f1be chore(FE-Storyless): update Prettier to version 3.6.2 and remove .prettierrc from .gitignore 2025-10-29 15:52:34 +07:00
rstubryan c7b04c5bc6 feat(FE-137): integrate flock periods data fetching in RecordingForm for accurate recording validation 2025-10-28 10:58:37 +07:00
rstubryan c37950a230 refactor(FE-137): optimize recordedProjectFlockIds calculation to filter today's recordings 2025-10-28 10:44:08 +07:00
rstubryan 7da95b80b0 refactor(FE-Storyless): conditionally handle onChange prop in SelectInput for better flexibility 2025-10-28 08:58:01 +07:00
rstubryan c74ed18a16 refactor(FE-137): enable clearable option for select inputs in RecordingForm 2025-10-27 14:15:48 +07:00
rstubryan 15e6372c30 feat(FE-137): add product flag badges to RecordingForm for enhanced visibility 2025-10-27 13:03:37 +07:00
rstubryan 6dd3593f70 feat(FE-137): integrate Badge component to display project flock period in RecordingForm 2025-10-27 12:57:00 +07:00
rstubryan 5d376f8783 refactor(FE-137): remove unnecessary padding from SelectInput for improved layout 2025-10-27 12:56:38 +07:00
rstubryan 304d14a6fe refactor(FE-137): remove 'Periode' column from RecordingTable for cleaner display 2025-10-27 11:57:46 +07:00
rstubryan 0b0ecd3bc4 refactor(FE-137): replace stock availability text with Badge component in MovementForm 2025-10-27 11:25:15 +07:00
rstubryan 58369b8ffa refactor(FE-137): simplify stock display in MovementForm and RecordingForm, enhance input handling in SelectInput 2025-10-27 11:05:06 +07:00
rstubryan 943c0e05b9 refactor(FE-137): conditionally render location SelectInput in RecordingForm based on type 2025-10-27 06:50:48 +07:00
rstubryan 9143248e1d refactor(FE-137): remove redundant status column from RecordingTable 2025-10-27 06:28:51 +07:00
rstubryan 4b9d0d2064 refactor(FE-137): enhance RecordingForm validation to prevent duplicate project flock entries 2025-10-27 06:18:27 +07:00
rstubryan c8f596ad2a refactor(FE-137): update RecordingForm to improve project flock handling and label formatting 2025-10-27 05:54:14 +07:00
rstubryan 135fc2d5d3 feat(FE-114): update MovementForm and RecordingForm to use inputPrefix and inputSuffix for improved input handling 2025-10-25 14:24:51 +07:00
rstubryan 189c152745 feat(FE-114): add inputPrefix and inputSuffix props for enhanced input customization 2025-10-25 14:24:23 +07:00
rstubryan a0556ea1f4 refactor(FE-114): add currency prefix and unit suffix to delivery cost and body weight inputs 2025-10-25 13:53:53 +07:00
rstubryan 81ce36e326 refactor(FE-137): remove ID column from RecordingTable for cleaner presentation 2025-10-25 13:41:18 +07:00
rstubryan d7ce8c667a refactor(FE-114): simplify input handling in MovementForm and RecordingForm by removing unnecessary value normalization 2025-10-25 11:26:38 +07:00
rstubryan 6290199074 feat(FE-Storyless): integrate NumberInput and PatternInput components with react-number-format for enhanced input handling 2025-10-25 10:49:07 +07:00
rstubryan 896a0c6de2 refactor(FE-64): integrate product and supplier selection with API data fetching in MovementForm 2025-10-24 21:10:03 +07:00
rstubryan 9c5dc0dbb5 refactor(FE-137): integrate approve and reject functionality in RecordingForm with loading states and modal confirmations 2025-10-24 20:44:15 +07:00
rstubryan 81003eac63 feat(FE-137): enhance stock product selection in RecordingForm with initial values support 2025-10-24 20:37:11 +07:00
rstubryan e322e0d078 feat(FE-137): update RECORDING_FLAG_OPTIONS values for consistency in constant.ts 2025-10-24 20:29:33 +07:00
rstubryan 17e6eef0c5 feat(FE-137): add approve and reject functionality in RecordingForm with confirmation modals 2025-10-24 18:02:41 +07:00
rstubryan 6114d706ad feat(FE-137): disable input field in RecordingForm when type is 'detail' 2025-10-24 14:13:21 +07:00
rstubryan d14fa2ed2b feat(FE-137): integrate advanced filtering options in RecordingTable with dropdowns for area, location, and kandang 2025-10-24 13:53:20 +07:00
rstubryan 537fc617ff feat(FE-137): implement bulk approval and rejection functionality in RecordingTable with user feedback 2025-10-24 13:40:27 +07:00
rstubryan 7a6a35568f feat(FE-137): enhance RecordingTable to support recording deletion with user feedback and refresh functionality 2025-10-24 13:32:46 +07:00
rstubryan d2c485fdf0 feat(FE-114,137): implement stock validation in RecordingForm to manage usage limits and enhance user feedback 2025-10-24 12:45:07 +07:00
rstubryan 0c49978033 feat(FE-114,137): enhance RecordingForm to handle stock usage and depletion total changes with improved input handling 2025-10-24 12:26:33 +07:00
rstubryan 00de4782e7 feat(FE-137): simplify RecordingTable by removing unused columns and enhancing data clarity 2025-10-24 12:14:47 +07:00
rstubryan c546bd6b3c feat(FE-137): refactor RecordingTable to remove unused types and streamline data fetching 2025-10-24 11:37:25 +07:00
rstubryan 258324f092 feat(US-137): update RecordingTable to enhance data display and add new columns for project details 2025-10-24 11:36:14 +07:00
rstubryan 12a69b7c6c feat(FE-137): integrate SWR for fetching recordings and update table to display API data 2025-10-24 11:35:11 +07:00
rstubryan b148a09e84 feat(US-137): update API endpoints and default values in RecordingForm for production environment 2025-10-24 11:27:32 +07:00
rstubryan adc995dbe7 feat(US-114): enhance auto-calculation logic in RecordingForm to handle manual edits 2025-10-24 11:00:14 +07:00
rstubryan 9cbc703a63 feat(FE-114): integrate row selection functionality in RecordingTable and Table components 2025-10-24 10:18:56 +07:00
rstubryan 41e6848d75 refactor(FE-114): remove optional product_warehouse_id validation from RecordingForm schema 2025-10-24 10:08:38 +07:00
rstubryan ca5b236565 refactor(FE-114): enforce required usage amount in RecordingForm validation 2025-10-24 10:00:35 +07:00
rstubryan 714072aea1 fix(merge): resolve merge conflict 2025-10-24 09:57:38 +07:00
rstubryan a9f0696b38 refactor(FE-114): auto-populate notes with product name and enhance tooltip visibility in RecordingForm 2025-10-24 09:50:12 +07:00
rstubryan c30fcd81b2 refactor(FE-114): simplify CreateRecordingPayload structure and update validation in RecordingForm 2025-10-24 08:53:41 +07:00
rstubryan 7f5ae94706 feat(FE-114): integrate product stock fetching and selection in RecordingForm 2025-10-23 22:59:41 +07:00
rstubryan 6060ec0f7e feat(FE-114): prevent auto-calculation override during manual average weight editing in RecordingForm 2025-10-23 22:02:12 +07:00
rstubryan ef249fee12 feat(FE-114): add average weight calculation and input handling in RecordingForm 2025-10-23 21:54:06 +07:00
rstubryan 71df86c8df feat(FE-114): integrate location and project flock selection in RecordingForm 2025-10-23 21:34:40 +07:00
rstubryan d61c0ab844 feat(FE-114): integrate date time handling in RecordingForm for on-time status 2025-10-23 20:59:20 +07:00
rstubryan b653cc1dab refactor(FE-114): replace button elements with Button component for consistency and improved styling 2025-10-23 20:44:59 +07:00
rstubryan 392e211181 refactor(FE-Storyless): replace img with Image component for optimized loading 2025-10-23 19:54:17 +07:00
rstubryan cebe738beb refactor(FE-114): enhance type safety and improve checkbox input handling 2025-10-23 19:52:38 +07:00
rstubryan 6e5875a7b7 refactor(FE-Storyless): add flock_id, area_id, fcr_id, location_id, and kandang_ids to project-flock type definition 2025-10-23 19:52:21 +07:00
rstubryan db8cb56984 fix(merge): resolve conflict on merge 2025-10-23 18:24:02 +07:00
rstubryan 22f1a32e1b feat(FE-137): integrate API for daily recording with enhanced data structure and validation 2025-10-23 11:59:22 +07:00
218 changed files with 34978 additions and 7461 deletions
+3 -3
View File
@@ -40,8 +40,8 @@ yarn-error.log*
*.tsbuildinfo
next-env.d.ts
# prettier
.prettierrc
# idea
.idea
# claude
.claude
+63 -21
View File
@@ -2,7 +2,6 @@ stages:
- build
- deploy
# ====== TEMPLATE: BUILD STATIC NEXT.JS ======
.build_template: &build_template
stage: build
image: node:20-alpine
@@ -11,15 +10,31 @@ stages:
paths:
- node_modules/
variables:
NPM_CONFIG_PRODUCTION: "false"
NODE_ENV: ""
NPM_CONFIG_PRODUCTION: 'false'
NODE_ENV: ''
script:
- echo "Installing dependencies..."
- npm ci --no-audit --no-fund
- echo "Build env used:"
- echo "NEXT_PUBLIC_LTI_URL=$NEXT_PUBLIC_LTI_URL"
- echo "NEXT_PUBLIC_SSO_LOGIN_URL=$NEXT_PUBLIC_SSO_LOGIN_URL"
- echo "NEXT_PUBLIC_API_BASE_URL=$NEXT_PUBLIC_API_BASE_URL"
- echo "Building Next.js static export..."
- npx next build
- |
mkdir -p out
cat <<EOF > out/build-info.json
{
"commit": "$CI_COMMIT_SHORT_SHA",
"pipeline": "$CI_PIPELINE_ID",
"built_at": "$(date -u +"%Y-%m-%dT%H:%M:%SZ")",
"NEXT_PUBLIC_LTI_URL": "$NEXT_PUBLIC_LTI_URL",
"NEXT_PUBLIC_SSO_LOGIN_URL": "$NEXT_PUBLIC_SSO_LOGIN_URL",
"NEXT_PUBLIC_API_BASE_URL": "$NEXT_PUBLIC_API_BASE_URL"
}
EOF
artifacts:
name: "out-$CI_COMMIT_SHORT_SHA"
name: 'out-$CI_COMMIT_SHORT_SHA'
paths:
- out/
expire_in: 1 week
@@ -28,7 +43,7 @@ stages:
stage: deploy
image:
name: amazon/aws-cli:latest
entrypoint: ["/bin/sh", "-c"]
entrypoint: ['/bin/sh', '-c']
script:
- set -e
- aws --version
@@ -56,11 +71,10 @@ stages:
- |
RUN_URL="${CI_PROJECT_URL}/-/pipelines/${CI_PIPELINE_ID}"
# Tentukan nama environment
if [ "$CI_COMMIT_BRANCH" = "devops-s3" ]; then
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
@@ -100,30 +114,59 @@ stages:
curl -sS -H "Content-Type: application/json" -d @payload.json "$DISCORD_WEBHOOK_URL"
# ====== DEVELOPMENT (Branch devops-s3) ======
# ====== DEVELOPMENT (Branch development) ======
build:dev:
<<: *build_template
rules:
- if: '$CI_COMMIT_BRANCH == "devops-s3"'
- if: '$CI_COMMIT_BRANCH == "development"'
environment:
name: devops-s3
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'
NEXT_PUBLIC_CLIENT_ID: 'Lumbung-Telur-Indonesia'
deploy:dev:
<<: *deploy_template
needs: ["build:dev"]
needs: ['build:dev']
rules:
- if: '$CI_COMMIT_BRANCH == "devops-s3"'
- if: '$CI_COMMIT_BRANCH == "development"'
variables:
S3_BUCKET: "dev-lti-erp.mbugroup.id"
AWS_REGION: "ap-southeast-3"
CLOUDFRONT_DISTRIBUTION_ID: "E1Z8XTA8XF1GIV"
S3_BUCKET: 'dev-lti-erp.mbugroup.id'
AWS_REGION: 'ap-southeast-3'
CLOUDFRONT_DISTRIBUTION_ID: 'E1Z8XTA8XF1GIV'
environment:
name: devops-s3
name: development
url: https://dev-lti-erp.mbugroup.id
# ====== 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
# ====== PRODUCTION ======
# build:production:
# <<: *build_template
@@ -145,5 +188,4 @@ deploy:dev:
# CLOUDFRONT_DISTRIBUTION_ID: "ddfd"
# environment:
# name: production
# url: https://royalgoldcapital.com
+2 -1
View File
@@ -1,2 +1,3 @@
npm run format
npm run lint
npm run build
npm run build
+6 -6
View File
@@ -1,4 +1,4 @@
version: "3.9"
version: '3.9'
services:
dev-web-lti:
@@ -7,7 +7,7 @@ services:
context: .
dockerfile: Dockerfile
ports:
- "3002:3000"
- '3002:3000'
env_file:
- .env
environment:
@@ -19,13 +19,13 @@ services:
deploy:
resources:
limits:
cpus: "3.0"
cpus: '3.0'
memory: 3G
reservations:
cpus: "1.0"
cpus: '1.0'
memory: 512M
extra_hosts:
- "host.docker.internal:host-gateway"
- 'host.docker.internal:host-gateway'
# Optional: aktifkan healthcheck jika punya endpoint
# healthcheck:
# test: ["CMD-SHELL", "curl -fsS http://localhost:3000/api/healthz || exit 1"]
@@ -36,4 +36,4 @@ services:
networks:
dev-lti-network:
external: true
external: true
+1
View File
@@ -3,6 +3,7 @@ import type { NextConfig } from 'next';
const nextConfig: NextConfig = {
output: 'export',
images: { unoptimized: true },
trailingSlash: true,
};
export default nextConfig;
+654 -71
View File
File diff suppressed because it is too large Load Diff
+6 -5
View File
@@ -11,16 +11,18 @@
"format": "prettier --write ."
},
"dependencies": {
"@react-pdf/renderer": "^4.3.1",
"@tanstack/match-sorter-utils": "^8.19.4",
"@tanstack/react-table": "^8.21.3",
"axios": "^1.12.2",
"clsx": "^2.1.1",
"formik": "^2.4.6",
"inputmask": "^5.0.9",
"moment": "^2.30.1",
"next": "15.5.3",
"next": "15.5.7",
"react": "19.1.0",
"react-day-picker": "^9.11.1",
"react-dom": "19.1.0",
"react-dropzone": "^14.3.8",
"react-hot-toast": "^2.6.0",
"react-number-format": "^5.4.4",
"react-select": "^5.10.2",
@@ -34,13 +36,12 @@
"@eslint/eslintrc": "^3",
"@iconify/react": "^6.0.2",
"@tailwindcss/postcss": "^4",
"@types/inputmask": "^5.0.7",
"@types/node": "^20",
"@types/react": "^19",
"@types/react-dom": "^19",
"daisyui": "^5.1.12",
"daisyui": "^5.5.8",
"eslint": "^9",
"eslint-config-next": "15.5.3",
"eslint-config-next": "^15.5.7",
"husky": "^9.1.7",
"prettier": "^3.6.2",
"tailwindcss": "^4",
Binary file not shown.

After

Width:  |  Height:  |  Size: 28 KiB

+59
View File
@@ -0,0 +1,59 @@
'use client';
import { useRouter, useSearchParams } from 'next/navigation';
import useSWR from 'swr';
import ClosingDetail from '@/components/pages/closing/ClosingDetail';
import { ClosingApi } from '@/services/api/closing';
import { isResponseError, isResponseSuccess } from '@/lib/api-helper';
const ClosingDetailPage = () => {
const router = useRouter();
const searchParams = useSearchParams();
const closingId = searchParams.get('closingId');
const { data: closing, isLoading: isLoadingClosing } = useSWR(
closingId,
(id: number) => ClosingApi.getGeneralInfo(id)
);
const { data: salesData, isLoading: isLoadingSales } = useSWR(
closingId ? `sales-${closingId}` : null,
() => ClosingApi.getPenjualan(Number(closingId))
);
if (!closingId) {
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 (!isLoadingClosing && (!closing || isResponseError(closing))) {
router.replace('/404');
return;
}
const isLoading = isLoadingClosing || isLoadingSales;
return (
<div className='w-full p-4 flex flex-row justify-center'>
{isLoading && <span className='loading loading-spinner loading-xl' />}
{!isLoading && isResponseSuccess(closing) && (
<ClosingDetail
id={Number(closingId)}
initialValue={closing.data}
salesData={isResponseSuccess(salesData) ? salesData.data : undefined}
/>
)}
</div>
);
};
export default ClosingDetailPage;
+11
View File
@@ -0,0 +1,11 @@
import ClosingsTable from '@/components/pages/closing/ClosingsTable';
const Closing = () => {
return (
<section className='w-full p-4'>
<ClosingsTable />
</section>
);
};
export default Closing;
+11
View File
@@ -0,0 +1,11 @@
import ExpenseRequestForm from '@/components/pages/expense/form/ExpenseRequestForm';
const AddExpense = () => {
return (
<div className='w-full p-4 flex flex-row justify-center'>
<ExpenseRequestForm />
</div>
);
};
export default AddExpense;
+63
View File
@@ -0,0 +1,63 @@
'use client';
import { useRouter, useSearchParams } from 'next/navigation';
import useSWR from 'swr';
import ExpenseRequestForm from '@/components/pages/expense/form/ExpenseRequestForm';
import { ExpenseApi } from '@/services/api/expense';
import { isResponseError, isResponseSuccess } from '@/lib/api-helper';
const ExpenseEditPage = () => {
const router = useRouter();
const searchParams = useSearchParams();
const expenseId = searchParams.get('expenseId');
const { data: expense, isLoading: isLoadingExpense } = useSWR(
expenseId,
(id: number) => ExpenseApi.getSingle(id)
);
if (!expenseId) {
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 (!isLoadingExpense && (!expense || isResponseError(expense))) {
router.replace('/404');
return;
}
const isExpenseCanBeEdited =
!isLoadingExpense &&
isResponseSuccess(expense) &&
expense.data.latest_approval.step_number !== 5 &&
(expense.data.latest_approval.step_number === 1 ||
expense.data.latest_approval.step_number === 2 ||
expense.data.latest_approval.step_number === 3);
if (!isLoadingExpense && !isExpenseCanBeEdited) {
router.back();
return;
}
return (
<div className='w-full p-4 flex flex-row justify-center'>
{isLoadingExpense && (
<span className='loading loading-spinner loading-xl' />
)}
{!isLoadingExpense && isResponseSuccess(expense) && (
<ExpenseRequestForm type='edit' initialValues={expense.data} />
)}
</div>
);
};
export default ExpenseEditPage;
+50
View File
@@ -0,0 +1,50 @@
'use client';
import { useRouter, useSearchParams } from 'next/navigation';
import useSWR from 'swr';
import ExpenseDetail from '@/components/pages/expense/ExpenseDetail';
import { ExpenseApi } from '@/services/api/expense';
import { isResponseError, isResponseSuccess } from '@/lib/api-helper';
const ExpenseDetailPage = () => {
const router = useRouter();
const searchParams = useSearchParams();
const expenseId = searchParams.get('expenseId');
const { data: expense, isLoading: isLoadingExpense } = useSWR(
expenseId,
(id: number) => ExpenseApi.getSingle(id)
);
if (!expenseId) {
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 (!isLoadingExpense && (!expense || isResponseError(expense))) {
router.replace('/404');
return;
}
return (
<div className='w-full p-4 flex flex-row justify-center'>
{isLoadingExpense && (
<span className='loading loading-spinner loading-xl' />
)}
{!isLoadingExpense && isResponseSuccess(expense) && (
<ExpenseDetail initialValues={expense.data} />
)}
</div>
);
};
export default ExpenseDetailPage;
+11
View File
@@ -0,0 +1,11 @@
import ExpensesTable from '@/components/pages/expense/ExpensesTable';
const Expense = () => {
return (
<section className='w-full p-4'>
<ExpensesTable />
</section>
);
};
export default Expense;
+62
View File
@@ -0,0 +1,62 @@
'use client';
import { useRouter, useSearchParams } from 'next/navigation';
import useSWR from 'swr';
import ExpenseRealizationForm from '@/components/pages/expense/form/ExpenseRealizationForm';
import { ExpenseApi } from '@/services/api/expense';
import { isResponseError, isResponseSuccess } from '@/lib/api-helper';
const ExpenseRealizationEditPage = () => {
const router = useRouter();
const searchParams = useSearchParams();
const expenseId = searchParams.get('expenseId');
const { data: expense, isLoading: isLoadingExpense } = useSWR(
expenseId,
(id: number) => ExpenseApi.getSingle(id)
);
if (!expenseId) {
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 (!isLoadingExpense && (!expense || isResponseError(expense))) {
router.replace('/404');
return;
}
const isExpenseRealizationCanBeEdited =
!isLoadingExpense &&
isResponseSuccess(expense) &&
expense.data.latest_approval.action !== 'REJECTED' &&
(expense.data.latest_approval.step_number === 4 ||
expense.data.latest_approval.step_number === 5);
if (!isLoadingExpense && !isExpenseRealizationCanBeEdited) {
router.back();
return;
}
return (
<div className='w-full p-4 flex flex-row justify-center'>
{isLoadingExpense && (
<span className='loading loading-spinner loading-xl' />
)}
{!isLoadingExpense && isResponseSuccess(expense) && (
<ExpenseRealizationForm type='edit' initialValues={expense.data} />
)}
</div>
);
};
export default ExpenseRealizationEditPage;
+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;
+67
View File
@@ -0,0 +1,67 @@
'use client';
import { useRouter, useSearchParams } from 'next/navigation';
import useSWR from 'swr';
import ExpenseRealizationForm from '@/components/pages/expense/form/ExpenseRealizationForm';
import { ExpenseApi } from '@/services/api/expense';
import { isResponseError, isResponseSuccess } from '@/lib/api-helper';
const ExpenseRealization = () => {
const router = useRouter();
const searchParams = useSearchParams();
const expenseId = searchParams.get('expenseId');
const { data: expense, isLoading: isLoadingExpense } = useSWR(
expenseId,
(id: number) => ExpenseApi.getSingle(id)
);
if (!expenseId) {
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 (!isLoadingExpense && (!expense || isResponseError(expense))) {
router.replace('/404');
return;
}
const isExpenseCanBeRealized =
isResponseSuccess(expense) &&
expense.data.latest_approval.action !== 'REJECTED' &&
expense.data.latest_approval.step_number === 3;
if (isResponseSuccess(expense) && !isExpenseCanBeRealized) {
if (typeof window !== 'undefined') {
router.back();
}
return (
<div className='w-full flex flex-row justify-center items-center p-4'>
<span className='loading loading-spinner loading-xl' />
</div>
);
}
return (
<div className='w-full p-4 flex flex-row justify-center'>
{isLoadingExpense && (
<span className='loading loading-spinner loading-xl' />
)}
{!isLoadingExpense && isResponseSuccess(expense) && (
<ExpenseRealizationForm initialValues={expense.data} />
)}
</div>
);
};
export default ExpenseRealization;
+44 -20
View File
@@ -7,26 +7,39 @@
default: false;
prefersdark: false;
color-scheme: 'light';
--color-base-100: oklch(98% 0.001 106.423);
--color-base-200: oklch(97% 0.001 106.424);
--color-base-300: oklch(92% 0.003 48.717);
--color-base-content: oklch(22.389% 0.031 278.072);
--color-primary: oklch(60% 0.126 221.723);
--color-primary-content: oklch(100% 0 0);
--color-secondary: oklch(52% 0.105 223.128);
--color-secondary-content: oklch(100% 0 0);
--color-accent: oklch(45% 0.085 224.283);
--color-accent-content: oklch(100% 0 0);
--color-neutral: oklch(39% 0.07 227.392);
--color-neutral-content: oklch(100% 0 0);
--color-info: oklch(58% 0.158 241.966);
--color-info-content: oklch(100% 0 0);
--color-success: oklch(62% 0.194 149.214);
--color-success-content: oklch(100% 0 0);
--color-warning: oklch(85% 0.199 91.936);
--color-warning-content: oklch(0% 0 0);
--color-error: oklch(57% 0.245 27.325);
--color-error-content: oklch(100% 0 0);
/* Primary Colors */
--color-primary: oklch(39.4% 0.177 301.9);
--color-primary-content: oklch(87.5% 0.038 274.5);
/* Secondary Colors */
--color-secondary: oklch(60.1% 0.258 335.7);
--color-secondary-content: oklch(99.4% 0.007 337.8);
/* Accent Colors */
--color-accent: oklch(76.2% 0.155 170.8);
--color-accent-content: oklch(7.2% 0.007 167.6);
/* Neutral Colors */
--color-neutral: oklch(22.4% 0.032 258.8);
--color-neutral-content: oklch(87.7% 0.016 257);
/* Base Colors */
--color-base-100: oklch(100% 0 0); /* #ffffff */
--color-base-200: oklch(97.2% 0 0); /* #f2f2f2 */
--color-base-300: oklch(93.1% 0.002 249.7); /* #e5e6e6 */
--color-base-content: oklch(18.6% 0.024 257.7); /* #1f2937 */
/* Status/Utility Colors */
--color-info: oklch(67.4% 0.176 238.9);
--color-info-content: oklch(0% 0 0); /* #000000 */
--color-success: oklch(62.3% 0.147 149);
--color-success-content: oklch(100% 0 0); /* #ffffff */
--color-warning: oklch(82.2% 0.165 91.9);
--color-warning-content: oklch(0% 0 0); /* #000000 */
--color-error: oklch(61.8% 0.203 27.8);
--color-error-content: oklch(100% 0 0); /* #fffffff */
--radius-selector: 0rem;
--radius-field: 0.25rem;
--radius-box: 0.25rem;
@@ -43,8 +56,19 @@
@theme {
--font-inter: var(--font-inter);
--container-sm: 40rem;
--container-md: 48rem;
--container-lg: 64rem;
--container-xl: 80rem;
--container-2xl: 96rem;
}
html {
scrollbar-gutter: initial;
}
.react-select__menu-portal {
position: relative;
z-index: 99999 !important;
}
@@ -12,8 +12,6 @@ const DetailInventoryAdjustment = () => {
// Ambil data dari router state
useEffect(() => {
console.log('Router State');
console.log(window.history.state);
const state = window.history.state?.usr as
| { inventoryAdjustment?: InventoryAdjustment }
| undefined;
@@ -26,9 +24,6 @@ const DetailInventoryAdjustment = () => {
const finalData = inventoryAdjustment;
console.log('Final Data');
console.log(finalData);
if (!finalData) {
return (
<div className='w-full flex flex-row justify-center items-center p-4'>
@@ -0,0 +1,11 @@
import SuspenseHelper from '@/components/helper/SuspenseHelper';
const Layout = ({
children,
}: Readonly<{
children: React.ReactNode;
}>) => {
return <SuspenseHelper>{children}</SuspenseHelper>;
};
export default Layout;
+50
View File
@@ -0,0 +1,50 @@
'use client';
import InventoryProductDetail from '@/components/pages/inventory/product/detail/InventoryProductDetail';
import { isResponseError, isResponseSuccess } from '@/lib/api-helper';
import { InventoryProductApi } from '@/services/api/inventory';
import { useRouter, useSearchParams } from 'next/navigation';
import useSWR from 'swr';
const InventoryProductDetailPage = () => {
const router = useRouter();
const searchParams = useSearchParams();
const inventoryProductId = searchParams.get('inventoryProductId');
const { data: inventoryProduct, isLoading: isLoadingInventoryProduct } =
useSWR(inventoryProductId, (id: number) =>
InventoryProductApi.getSingle(id)
);
if (!inventoryProductId) {
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 (
!isLoadingInventoryProduct &&
(!inventoryProduct || isResponseError(inventoryProduct))
) {
router.replace('/404');
return;
}
return (
<div className='size-full'>
{isLoadingInventoryProduct && (
<span className='loading loading-spinner loading-xl' />
)}
{!isLoadingInventoryProduct && isResponseSuccess(inventoryProduct) && (
<InventoryProductDetail inventoryProduct={inventoryProduct.data} />
)}
</div>
);
};
export default InventoryProductDetailPage;
+11
View File
@@ -0,0 +1,11 @@
import InventoryProductTable from '@/components/pages/inventory/product/InventoryProductTable';
const InventoryProductPage = () => {
return (
<div className='size-full'>
<InventoryProductTable />
</div>
);
};
export default InventoryProductPage;
@@ -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,54 @@
'use client';
import MarketingForm from '@/components/pages/marketing/form/MarketingForm';
import { isResponseError, isResponseSuccess } from '@/lib/api-helper';
import { MarketingApi } from '@/services/api/marketing/marketing';
import { useRouter, useSearchParams } from 'next/navigation';
import toast from 'react-hot-toast';
import useSWR from 'swr';
const EditMarketingDelivery = () => {
const router = useRouter();
const searchParams = useSearchParams();
const soId = searchParams.get('marketingId');
const {
data: marketing,
isLoading: isLoading,
mutate: refreshMarketing,
} = useSWR(`get-so-${soId}`, () =>
MarketingApi.getSingle(soId ? parseInt(soId) : 0)
);
if (!soId) {
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 (!isLoading && (!marketing || isResponseError(marketing))) {
router.replace('/404');
return;
}
return (
<div className='w-full p-4'>
{isLoading && <span className='loading loading-spinner loading-xl' />}
{!isLoading && isResponseSuccess(marketing) && (
<MarketingForm
formType='add_deliver'
initialValues={marketing.data}
afterSubmit={() => {
refreshMarketing();
}}
/>
)}
</div>
);
};
export default EditMarketingDelivery;
@@ -0,0 +1,11 @@
import MarketingForm from '@/components/pages/marketing/form/MarketingForm';
const AddSalesOrder = () => {
return (
<div className='size-full p-4'>
<MarketingForm formType='add' />
</div>
);
};
export default AddSalesOrder;
@@ -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,62 @@
'use client';
import MarketingForm from '@/components/pages/marketing/form/MarketingForm';
import { isResponseError, isResponseSuccess } from '@/lib/api-helper';
import { MarketingApi } from '@/services/api/marketing/marketing';
import { useRouter, useSearchParams } from 'next/navigation';
import toast from 'react-hot-toast';
import useSWR from 'swr';
const EditMarketingDelivery = () => {
const router = useRouter();
const searchParams = useSearchParams();
const soId = searchParams.get('marketingId');
const {
data: marketing,
isLoading: isLoading,
mutate: refreshMarketing,
} = useSWR(`get-so-${soId}`, () =>
MarketingApi.getSingle(soId ? parseInt(soId) : 0)
);
if (!soId) {
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 (!isLoading && (!marketing || isResponseError(marketing))) {
router.replace('/404');
return;
}
if (
isResponseSuccess(marketing) &&
marketing.data.latest_approval.step_number != 3
) {
toast.error('Data Marketing perlu dilakukan approval terlebih dahulu!');
router.back();
}
return (
<div className='w-full p-4'>
{isLoading && <span className='loading loading-spinner loading-xl' />}
{!isLoading && isResponseSuccess(marketing) && (
<MarketingForm
formType='edit_deliver'
initialValues={marketing.data}
afterSubmit={() => {
refreshMarketing();
}}
/>
)}
</div>
);
};
export default EditMarketingDelivery;
+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;
+49
View File
@@ -0,0 +1,49 @@
'use client';
import MarketingDetail from '@/components/pages/marketing/detail/MarketingDetail';
import { isResponseError, isResponseSuccess } from '@/lib/api-helper';
import { MarketingApi } from '@/services/api/marketing/marketing';
import { useRouter, useSearchParams } from 'next/navigation';
import useSWR from 'swr';
const DetailMarketing = () => {
const router = useRouter();
const searchParams = useSearchParams();
const soId = searchParams.get('marketingId');
const {
data: marketing,
isLoading: isLoading,
mutate: refreshMarketing,
} = useSWR(soId, (id: number) => MarketingApi.getSingle(id));
if (!soId) {
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 (!isLoading && (!marketing || isResponseError(marketing))) {
router.replace('/404');
return;
}
return (
<div className='w-full p-4'>
{isLoading && <span className='loading loading-spinner loading-xl' />}
{!isLoading && isResponseSuccess(marketing) && (
<MarketingDetail
initialValues={marketing.data}
refresh={refreshMarketing}
/>
)}
</div>
);
};
export default DetailMarketing;
@@ -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,52 @@
'use client';
import MarketingForm from '@/components/pages/marketing/form/MarketingForm';
import { isResponseError, isResponseSuccess } from '@/lib/api-helper';
import { MarketingApi } from '@/services/api/marketing/marketing';
import { useRouter, useSearchParams } from 'next/navigation';
import useSWR from 'swr';
const EditSalesOrder = () => {
const router = useRouter();
const searchParams = useSearchParams();
const soId = searchParams.get('marketingId');
const {
data: marketing,
isLoading: isLoading,
mutate: refreshMarketing,
} = useSWR(`get-so-${soId}`, () =>
MarketingApi.getSingle(soId ? parseInt(soId) : 0)
);
if (!soId) {
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 (!isLoading && (!marketing || isResponseError(marketing))) {
router.replace('/404');
return;
}
return (
<div className='w-full p-4'>
{isLoading && <span className='loading loading-spinner loading-xl' />}
{!isLoading && isResponseSuccess(marketing) && (
<MarketingForm
formType='edit'
initialValues={marketing.data}
afterSubmit={() => {
refreshMarketing();
}}
/>
)}
</div>
);
};
export default EditSalesOrder;
+11
View File
@@ -0,0 +1,11 @@
import MarketingTable from '@/components/pages/marketing/MarketingTable';
const Marketing = () => {
return (
<div className='w-full p-4'>
<MarketingTable />
</div>
);
};
export default Marketing;
+25 -7
View File
@@ -1,11 +1,29 @@
import { redirect } from 'next/navigation';
'use client';
import { useEffect } from 'react';
import { usePathname, useRouter } from 'next/navigation';
import { useAuth } from '@/services/hooks/useAuth';
import { redirectToSSO } from '@/lib/auth-helper';
export default function Home() {
redirect('/dashboard');
const { user, isLoadingUser } = useAuth();
return (
<main className='w-full h-full min-h-screen flex flex-row justify-center items-center'>
<h1>LTI ERP</h1>
</main>
);
const router = useRouter();
const pathname = usePathname();
useEffect(() => {
if (pathname === '/') {
router.replace('/dashboard');
}
}, [pathname]);
if (isLoadingUser) {
return (
<main className='w-full h-full min-h-screen flex flex-row justify-center items-center'>
<span className='loading loading-spinner loading-lg'></span>
</main>
);
}
return <>Loading...</>;
}
-270
View File
@@ -1,270 +0,0 @@
'use client';
import Button from '@/components/Button';
import SelectInput, { OptionType } from '@/components/input/SelectInput';
import Modal, { useModal } from '@/components/Modal';
import ConfirmationModal from '@/components/modal/ConfirmationModal';
import ChickinForm from '@/components/pages/production/chickin/form/ChickinForm';
import Table from '@/components/Table';
import { isResponseError, isResponseSuccess } from '@/lib/api-helper';
import { cn } from '@/lib/helper';
import { ProjectFlockApi } from '@/services/api/production';
import { useTableFilter } from '@/services/hooks/useTableFilter';
import { BaseApiResponse } from '@/types/api/api-general';
import { Kandang } from '@/types/api/master-data/kandang';
import { ProjectFlockKandang } from '@/types/api/production/project-flock-kandang';
import { Icon } from '@iconify/react';
import { useRouter, useSearchParams } from 'next/navigation';
import { useState } from 'react';
import useSWR from 'swr';
const AddChickin = () => {
const router = useRouter();
const searchParams = useSearchParams();
const projectFlockId = searchParams.get('projectFlockId');
// Tables Props
const { state: tableFilterState } = useTableFilter({
initial: { search: '' },
paramMap: { page: 'page', pageSize: 'limit' },
});
// States
const [selectedKandang, setSelectedKandang] = useState<Kandang | undefined>(
undefined
);
const [projectFlockKandang, setProjectFlockKandang] =
useState<BaseApiResponse<ProjectFlockKandang>>();
const [isLoadingProjectFlockKandang, setIsLoadingProjectFlockKandang] =
useState(false);
const [searchProjectFlock, setSearchProjectFlock] = useState('');
// Fetch Data
const { data: projectFlock, isLoading: isLoadingProjectFlock } = useSWR(
projectFlockId,
(id: number) => ProjectFlockApi.getSingle(id)
);
const { data: listProjectFlock, isLoading: isLoadingListProjectFlock } =
useSWR(
`${ProjectFlockApi.basePath}?${new URLSearchParams({
search: searchProjectFlock,
}).toString()}`,
ProjectFlockApi.getAllFetcher
);
const getProjectFlockKandangUrl = `/kandangs/lookup`;
// Mapping Options
const options = isResponseSuccess(listProjectFlock)
? listProjectFlock?.data.map((projectFlock) => {
return {
value: projectFlock.id,
label: `${projectFlock?.flock?.name} - ${projectFlock?.category} - Periode ${projectFlock.period}`,
};
})
: [];
const chickinModal = useModal();
const alertModal = useModal();
if (!projectFlockId) {
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 (
!isLoadingProjectFlock &&
(!projectFlock || isResponseError(projectFlock))
) {
router.replace('/404');
return;
}
// Handle Function
const handleChickinClick = async (kandang: Kandang) => {
setIsLoadingProjectFlockKandang(true);
setSelectedKandang(kandang);
const ProjectFlockKandangRes = await ProjectFlockApi.customRequest<
BaseApiResponse<ProjectFlockKandang>,
'GET'
>(getProjectFlockKandangUrl, {
method: 'GET',
params: {
project_flock_id: projectFlockId ?? 0,
kandang_id: kandang.id,
},
});
if (isResponseSuccess(ProjectFlockKandangRes)) {
setProjectFlockKandang(ProjectFlockKandangRes);
setIsLoadingProjectFlockKandang(false);
if (
ProjectFlockKandangRes.data.available_quantity &&
ProjectFlockKandangRes.data.available_quantity > 0
) {
chickinModal.openModal();
} else {
alertModal.openModal();
}
}
};
const handleAfterSubmit = () => {
chickinModal.closeModal();
router.push('/production/chickin');
};
return (
<>
{isResponseSuccess(projectFlock) && (
<>
<section className='w-full p-4'>
<header className='flex flex-col gap-4'>
<Button
href='/production/project-flock'
variant='link'
className='w-fit p-0 text-primary'
>
<Icon icon='uil:arrow-left' width={24} height={24} />
Kembali
</Button>
<div className='flex flex-col gap-4 w-full my-4'>
<div className='max-w-full sm:max-w-1/2 md:max-w-3/5 lg:max-w-2/5'>
<SelectInput
required
isSearchable
label='Project Flock'
options={options}
isLoading={isLoadingListProjectFlock}
value={{
label: `${projectFlock.data?.flock?.name} - ${projectFlock.data?.category} - Periode ${projectFlock.data?.period}`,
value: projectFlock.data?.id,
}}
onChange={(val) =>
router.push(
`/production/chickin/add?projectFlockId=${
(val as OptionType | null)?.value
}`
)
}
onInputChange={(val) => {
setSearchProjectFlock(val);
}}
/>
</div>
</div>
</header>
<Table<Kandang>
data={projectFlock.data?.kandangs}
columns={[
{
header: '#',
cell: (props) =>
tableFilterState.pageSize * (tableFilterState.page - 1) +
props.row.index +
1,
},
{
accessorKey: 'name',
header: 'Nama Kandang',
},
{
header: 'Aksi',
cell: (props) => {
return (
<>
<Button
color='success'
variant='outline'
onClick={() => {
handleChickinClick(props.row.original);
}}
disabled={isLoadingProjectFlockKandang}
>
<Icon
icon='mdi:home-import-outline'
width={24}
height={24}
/>
Chickin
</Button>
</>
);
},
},
]}
page={undefined}
className={{
containerClassName: cn({
'mb-20':
isResponseSuccess(projectFlock) &&
projectFlock.data?.kandangs?.length === 0,
}),
tableWrapperClassName: 'overflow-x-auto min-h-full!',
tableClassName: 'font-inter w-full table-auto min-h-full!',
headerRowClassName: 'border-b border-b-gray-200',
headerColumnClassName:
'px-6 py-3 text-xs font-semibold text-gray-500 last:flex last:flex-row last:justify-end',
bodyRowClassName: 'border-b border-b-gray-200',
bodyColumnClassName:
'px-6 py-3 last:flex last:flex-row last:justify-end',
paginationClassName: 'hidden',
}}
/>
</section>
<Modal ref={chickinModal.ref}>
<div className='flex flex-row justify-between items-center'>
<h1 className='text-xl font-semibold text-center mb-6'>
Chickin Kandang - {selectedKandang?.name}
</h1>
<Button
color='error'
variant='link'
onClick={chickinModal.closeModal}
>
<Icon
className='text-black'
icon='uil:times'
width={24}
height={24}
/>
</Button>
</div>
{isResponseSuccess(projectFlockKandang) &&
!isLoadingProjectFlockKandang && (
<ChickinForm
initialValues={{
project_flock_kandang: projectFlockKandang.data,
created_user: projectFlock.data?.created_user,
created_at: projectFlock.data?.created_at,
updated_at: projectFlock.data?.updated_at,
approval: projectFlock.data?.approval,
}}
afterSubmit={handleAfterSubmit}
/>
)}
</Modal>
<ConfirmationModal
ref={alertModal.ref}
type='info'
text={`Persediaan Day Old Chick pada kandang (${selectedKandang?.name}) belum ada, mohon isi terlebih dahulu di bagian Persediaan!`}
secondaryButton={undefined}
primaryButton={{
text: 'Ya',
color: 'info',
onClick: () => {
alertModal.closeModal();
},
}}
/>
</>
)}
</>
);
};
export default AddChickin;
-351
View File
@@ -1,351 +0,0 @@
'use client';
import Button from '@/components/Button';
import Card from '@/components/Card';
import Modal, { useModal } from '@/components/Modal';
import ConfirmationModal from '@/components/modal/ConfirmationModal';
import ChickinForm from '@/components/pages/production/chickin/form/ChickinForm';
import { isResponseError, isResponseSuccess } from '@/lib/api-helper';
import { ChickinApi } from '@/services/api/production';
import { BaseApiResponse } from '@/types/api/api-general';
import {
Chickin,
ChickinApprovalPayload,
} from '@/types/api/production/chickin';
import { Icon } from '@iconify/react';
import { useRouter, useSearchParams } from 'next/navigation';
import { useState } from 'react';
import toast from 'react-hot-toast';
import useSWR from 'swr';
/**
* TODO: Refactor code - pindahin detail ke reuseable component
* setelah implement approval and reject
*/
const DetailChickin = () => {
const router = useRouter();
const searchParams = useSearchParams();
const chickinId = searchParams.get('chickinId');
const [isApproveLoading, setIsApproveLoading] = useState(false);
const [isDeleteLoading, setIsDeleteLoading] = useState(false);
const confirmModal = useModal();
const deleteModal = useModal();
const chickinModal = useModal();
const {
data: chickin,
isLoading,
mutate: refreshChickin,
} = useSWR(chickinId, (id: number) => ChickinApi.getSingle(id));
const [isApprovedDisabled, setIsApprovedDisabled] = useState(
// chickin.data?.approval.step_number == 1 ? false : true
true
);
const [isRejectedDisabled, setIsRejectedDisabled] =
useState(!isApprovedDisabled);
const [approvalAction, setApprovalAction] = useState<'APPROVED' | 'REJECTED'>(
!isApprovedDisabled ? 'APPROVED' : 'REJECTED'
);
if (!chickinId) {
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 (!isLoading && (!chickin || isResponseError(chickin))) {
router.replace('/404');
return;
}
if (!isResponseSuccess(chickin)) {
return (
<div className='w-full flex flex-row justify-center items-center p-4'>
<span className='loading loading-spinner loading-xl' />
</div>
);
}
const confirmationModalClickHandler = async ({
action = 'APPROVED',
}: {
action: 'APPROVED' | 'REJECTED';
}) => {
if (chickin?.data.id === undefined) return;
setIsApproveLoading(true);
const approveChickinRes = await ChickinApi.customRequest<
BaseApiResponse<Chickin>,
ChickinApprovalPayload
>(`/approvals`, {
method: 'POST',
payload: {
action: action,
approvable_ids: [chickin.data.id],
},
});
if (isResponseSuccess(approveChickinRes)) {
if (refreshChickin) {
await refreshChickin();
}
toast.success(approveChickinRes.message as string);
}
if (isResponseError(approveChickinRes)) {
toast.error(approveChickinRes?.message as string);
}
confirmModal.closeModal();
setIsApproveLoading(false);
};
const confirmationModalDeleteClickHandler = async () => {
setIsDeleteLoading(true);
const deleteProjectFlockRes = await ChickinApi.delete(
chickin.data?.id as number
);
if (isResponseSuccess(deleteProjectFlockRes)) {
toast.success(deleteProjectFlockRes?.message as string);
router.push('/production/chickin');
}
if (isResponseError(deleteProjectFlockRes)) {
toast.error(deleteProjectFlockRes?.message as string);
}
deleteModal.closeModal();
setIsDeleteLoading(false);
};
return (
<>
<div className='w-full p-4 flex flex-col justify-center gap-4'>
{isLoading && <span className='loading loading-spinner loading-xl' />}
{!isLoading && isResponseSuccess(chickin) && (
<>
{/* <div className='w-full flex flex-col sm:flex-row gap-2'>
<Button
variant='outline'
color='success'
onClick={(() => {
if (chickin?.data.id) {
setApprovalAction('APPROVED');
confirmModal.openModal();
}
})}
disabled={!chickin?.data.id || isApprovedDisabled}
className='w-full sm:w-fit'
>
<Icon icon='material-symbols:check' width={24} height={24} />
Approve
</Button>
<Button
variant='outline'
color='error'
onClick={() => {
if (chickin?.data.id) {
setApprovalAction('REJECTED');
confirmModal.openModal();
}
}}
disabled={!chickin?.data.id || isRejectedDisabled}
className='w-full sm:w-fit'
>
<Icon icon='mdi:times' width={24} height={24} />
Reject
</Button>
</div> */}
<Card
title='Informasi Umum'
variant='bordered'
className={{
wrapper: 'w-full',
}}
>
<div className='grid grid-cols-2 gap-4 mt-4'>
<div className='flex flex-col gap-2'>
<div className='font-semibold text-sm'>Flock</div>
<div className='text-sm'>
{
chickin.data.project_flock_kandang?.project_flock.flock
.name
}
</div>
</div>
<div className='flex flex-col gap-2'>
<div className='font-semibold text-sm'>Area</div>
<div className='text-sm'>
{
chickin.data.project_flock_kandang?.project_flock.area
.name
}
</div>
</div>
<div className='flex flex-col gap-2'>
<div className='font-semibold text-sm'>Kategori</div>
<div className='text-sm'>
{chickin.data.project_flock_kandang?.project_flock.category}
</div>
</div>
<div className='flex flex-col gap-2'>
<div className='font-semibold text-sm'>Lokasi</div>
<div className='text-sm'>
{
chickin.data.project_flock_kandang?.project_flock.location
.name
}
</div>
</div>
<div className='flex flex-col gap-2'>
<div className='font-semibold text-sm'>Periode</div>
<div className='text-sm'>
{chickin.data.project_flock_kandang?.project_flock.period}
</div>
</div>
<div className='flex flex-col gap-2'>
<div className='font-semibold text-sm'>Kandang</div>
<div className='text-sm'>
{chickin.data.project_flock_kandang?.kandang.name}
</div>
</div>
</div>
</Card>
<Card
title='Detail Chickin'
variant='bordered'
className={{
wrapper: 'w-full',
}}
>
<div className='grid grid-cols-2 gap-4 mt-4'>
<div className='flex flex-col gap-2'>
<div className='font-semibold text-sm'>Flock Kandang</div>
<div className='text-sm'>
{
chickin.data.project_flock_kandang?.project_flock.flock
.name
}{' '}
- {chickin.data.project_flock_kandang?.kandang.name}
</div>
</div>
<div className='flex flex-col gap-2'>
<div className='font-semibold text-sm'>Tanggal Chickin</div>
<div className='text-sm'>
{chickin.data.chick_in_date
? new Date(chickin.data.chick_in_date).toLocaleDateString(
'id-ID'
)
: '-'}
</div>
</div>
<div className='flex flex-col gap-2'>
<div className='font-semibold text-sm'>Jumlah (Ekor)</div>
<div className='text-sm'>
{chickin.data.quantity?.toLocaleString('id-ID')}
</div>
</div>
<div className='flex flex-col gap-2'>
<div className='font-semibold text-sm'>Catatan</div>
<div className='text-sm'>{chickin.data.note}</div>
</div>
</div>
</Card>
<div className='w-full flex flex-col sm:flex-row gap-2'>
<Button
color='error'
onClick={() => {
deleteModal.openModal();
}}
>
<Icon icon='mdi:times' width={24} height={24} />
Delete
</Button>
<Button
color='warning'
onClick={() => {
chickinModal.openModal();
}}
>
<Icon icon='mdi:pencil-outline' width={24} height={24} />
Edit
</Button>
</div>
</>
)}
</div>
<ConfirmationModal
ref={deleteModal.ref}
type='error'
text={`Apakah anda yakin ingin menghapus data Project Flock ini (${chickin?.data.project_flock_kandang?.project_flock.flock.name} - ${chickin?.data.project_flock_kandang?.kandang.name})?`}
secondaryButton={{
text: 'Tidak',
}}
primaryButton={{
text: 'Ya',
color: 'error',
isLoading: isDeleteLoading,
onClick: confirmationModalDeleteClickHandler,
}}
/>
<Modal ref={chickinModal.ref}>
<div className='flex flex-row justify-between items-center'>
<h1 className='text-xl font-semibold text-center mb-6'>
Chickin Kandang -{' '}
{chickin?.data?.project_flock_kandang &&
chickin?.data?.project_flock_kandang.kandang?.name}
</h1>
<Button
color='error'
variant='link'
onClick={chickinModal.closeModal}
>
<Icon
className='text-black'
icon='uil:times'
width={24}
height={24}
/>
</Button>
</div>
<ChickinForm
initialValues={chickin?.data}
formType='edit'
afterSubmit={() => {
refreshChickin();
chickinModal.closeModal();
}}
/>
</Modal>
<ConfirmationModal
ref={confirmModal.ref}
type={approvalAction == 'APPROVED' ? 'success' : 'error'}
text={`Apakah anda yakin ingin ${
approvalAction == 'APPROVED' ? 'approve' : 'reject'
} chickin berikut? (${
chickin?.data.project_flock_kandang?.project_flock.flock.name
} - ${chickin?.data.project_flock_kandang?.kandang.name})?`}
secondaryButton={{
text: 'Tidak',
}}
primaryButton={{
text: 'Ya',
color: approvalAction == 'APPROVED' ? 'success' : 'error',
isLoading: isApproveLoading,
onClick: () => {
confirmationModalClickHandler({
action: approvalAction,
});
},
}}
/>
</>
);
};
export default DetailChickin;
@@ -1,10 +1,18 @@
'use client';
import ProjectFlockForm from '@/components/pages/production/project-flock/form/ProjectFlockForm';
import React, { useImperativeHandle } from 'react';
import toast from 'react-hot-toast';
const AddProjectFlock = () => {
// useImperativeHandle(ref, () => ({
// validate() {
// toast.success('Validating');
// return false;
// },
// }));
return (
<section className='w-full p-4 flex flex-row justify-center'>
<section className='w-full flex flex-row justify-center'>
<ProjectFlockForm formType='add' />
</section>
);
@@ -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,60 @@
'use client';
import ChickinForm from '@/components/pages/production/chickin/form/ChickinForm';
import { isResponseSuccess } from '@/lib/api-helper';
import { ProjectFlockKandangApi } from '@/services/api/production';
import { useRouter, useSearchParams } from 'next/navigation';
import useSWR from 'swr';
export default function AddChickinKandang() {
const searchParams = useSearchParams();
const projectFlockKandangId = searchParams.get('projectFlockKandangId');
const projectFlockId = searchParams.get('projectFlockId');
const router = useRouter();
const {
data: projectFlockKandang,
isLoading: isLoading,
mutate: refreshProjectFlockKandang,
} = useSWR(
`get-single-project-flock-kandang/${projectFlockKandangId}`,
async () =>
ProjectFlockKandangApi.getSingle(
parseInt(projectFlockKandangId as string)
)
);
if (!projectFlockKandangId) {
router.push(`/production/chickin/add?projectFlockId=${projectFlockId}`);
return (
<div className='w-full flex flex-row justify-center items-center p-4'>
<span className='loading loading-spinner loading-xl' />
</div>
);
}
if (!isLoading && !projectFlockKandang) {
router.replace('/404');
return;
}
const handleAfterSubmit = () => {
refreshProjectFlockKandang();
};
return (
<>
<section className='size-full'>
{isLoading && <span className='loading loading-spinner loading-xl' />}
{!isLoading &&
isResponseSuccess(projectFlockKandang) &&
projectFlockId && (
<ChickinForm
initialValues={projectFlockKandang.data}
afterSubmit={handleAfterSubmit}
/>
)}
</section>
</>
);
}
@@ -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,20 @@
'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;
@@ -2,7 +2,7 @@ import ChickinTable from '@/components/pages/production/chickin/ChickinTable';
const Chickin = () => {
return (
<section className='w-full p-4'>
<section className='w-full'>
<ChickinTable />
</section>
);
@@ -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,63 @@
'use client';
import ProjectFlockClosingForm from '@/components/pages/production/project-flock/closing/ProjectFlockClosingForm';
import { isResponseError, isResponseSuccess } from '@/lib/api-helper';
import { ProjectFlockKandangApi } from '@/services/api/production';
import { ProjectFlockApi } from '@/services/api/production/project-flock';
import { useRouter, useSearchParams } from 'next/navigation';
import useSWR from 'swr';
const ProjectFlockClosingPage = () => {
const router = useRouter();
const searchParams = useSearchParams();
const projectFlockId = searchParams.get('projectFlockId');
const projectFlockKandangId = searchParams.get('projectFlockKandangId');
const { data: projectFlockKandang, isLoading: isLoadingProjectFlockKandang } =
useSWR(`get-flock-kandang-id/${projectFlockKandangId}`, () =>
ProjectFlockKandangApi.getSingle(parseInt(projectFlockKandangId ?? ''))
);
const { data: projectFlock, isLoading: isLoadingProjectFlock } = useSWR(
`get-flock-id/${projectFlockId}`,
() => ProjectFlockApi.getSingle(parseInt(projectFlockId ?? ''))
);
if (!projectFlockId || !projectFlockKandangId) {
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 (
!isLoadingProjectFlock &&
(!projectFlock || isResponseError(projectFlock)) &&
!isLoadingProjectFlockKandang &&
(!projectFlockKandang || isResponseError(projectFlockKandang))
) {
router.replace('/404');
return;
}
return (
<div className='w-full h-full flex flex-col justify-center'>
{isLoadingProjectFlock ||
(isLoadingProjectFlockKandang && (
<span className='loading loading-spinner loading-xl' />
))}
{isResponseSuccess(projectFlock) &&
isResponseSuccess(projectFlockKandang) && (
<ProjectFlockClosingForm
projectFlock={projectFlock.data}
projectFlockKandang={projectFlockKandang.data}
/>
)}
</div>
);
};
export default ProjectFlockClosingPage;
@@ -2,7 +2,7 @@
import ProjectFlockForm from '@/components/pages/production/project-flock/form/ProjectFlockForm';
import { isResponseError, isResponseSuccess } from '@/lib/api-helper';
import { ProjectFlockApi } from '@/services/api/production';
import { ProjectFlockApi } from '@/services/api/production/project-flock';
import { useRouter, useSearchParams } from 'next/navigation';
import useSWR from 'swr';
@@ -12,10 +12,11 @@ const ProjectFlockEdit = () => {
const projectFlockId = searchParams.get('projectFlockId');
const { data: projectFlock, isLoading: isLoadingCostumer } = useSWR(
projectFlockId,
(id: number) => ProjectFlockApi.getSingle(id)
);
const {
data: projectFlock,
isLoading: isLoadingProjectFlock,
mutate: refreshProjectFlocks,
} = useSWR(projectFlockId, (id: number) => ProjectFlockApi.getSingle(id));
if (!projectFlockId) {
router.back();
@@ -27,17 +28,20 @@ const ProjectFlockEdit = () => {
);
}
if (!isLoadingCostumer && (!projectFlock || isResponseError(projectFlock))) {
if (
!isLoadingProjectFlock &&
(!projectFlock || isResponseError(projectFlock))
) {
router.replace('/404');
return;
}
return (
<div className='w-full p-4 flex flex-row justify-center'>
{isLoadingCostumer && (
<div className='w-full flex flex-col justify-center'>
{isLoadingProjectFlock && (
<span className='loading loading-spinner loading-xl' />
)}
{!isLoadingCostumer && isResponseSuccess(projectFlock) && (
{!isLoadingProjectFlock && isResponseSuccess(projectFlock) && (
<ProjectFlockForm formType='edit' initialValues={projectFlock.data} />
)}
</div>
@@ -1,12 +1,13 @@
'use client';
import ProjectFlockDetail from '@/components/pages/production/project-flock/detail/ProjectFlockDetail';
import ProjectFlockForm from '@/components/pages/production/project-flock/form/ProjectFlockForm';
import { isResponseError, isResponseSuccess } from '@/lib/api-helper';
import { ProjectFlockApi } from '@/services/api/production';
import { ProjectFlockApi } from '@/services/api/production/project-flock';
import { useRouter, useSearchParams } from 'next/navigation';
import useSWR from 'swr';
const ProjectFlockDetail = () => {
const ProjectFlockDetailPage = () => {
const router = useRouter();
const searchParams = useSearchParams();
@@ -37,19 +38,17 @@ const ProjectFlockDetail = () => {
}
return (
<div className='w-full p-4 flex flex-row justify-center'>
<div className='w-full h-full flex flex-col justify-center'>
{isLoadingProjectFlock && (
<span className='loading loading-spinner loading-xl' />
)}
{!isLoadingProjectFlock && isResponseSuccess(projectFlock) && (
<ProjectFlockForm
formType='detail'
initialValues={projectFlock.data}
refreshProjectFlocks={refreshProjectFlock}
/>
{isResponseSuccess(projectFlock) && (
<ProjectFlockDetail projectFlock={projectFlock.data} />
)}
</div>
);
};
export default ProjectFlockDetail;
export default ProjectFlockDetailPage;
ProjectFlockDetail;
ProjectFlockDetail;
@@ -0,0 +1,60 @@
'use client';
import { usePathname, useRouter } from 'next/navigation';
import Drawer from '@/components/Drawer';
import React, { ReactNode } from 'react';
import ProjectFlockTable from '@/components/pages/production/project-flock/ProjectFlockTable';
import { useUiStore } from '@/stores/ui/ui.store';
export default function ProjectFlockLayout({
children,
}: {
children: ReactNode;
}) {
const pathname = usePathname();
const router = useRouter();
const toggleValidate = useUiStore((s) => s.toggleValidate);
const isAdd = pathname.includes('/add');
const isEdit = pathname.includes('/detail/edit');
const isDetail = pathname.includes('/detail');
const isChickin = pathname.includes('/chickin/add/kandang');
const isClosing = pathname.includes('/closing');
const isOpen = isAdd || isEdit || isDetail || isChickin || isClosing;
const handleBackdropClick = () => {
const unsub = useUiStore.getState().subscribeIsValid((isValid) => {
if (isValid) {
unsub(); // berhenti listen
router.push('/production/project-flock');
}
});
toggleValidate();
};
return (
<>
{/* List page always rendered */}
<div className='min-h-sceen w-full relative'>
<ProjectFlockTable
refresh={() => !isOpen && router.push('/production/project-flock')}
/>
</div>
{/* Render Drawer only on /add */}
<Drawer
open={isOpen}
setOpen={(v) => {
if (!v) router.push('/production/project-flock');
}}
closeOnBackdropClick={isDetail ? true : false}
onBackdropClick={handleBackdropClick}
variant='right'
zIndex='99999'
sidebarContent={isOpen && <div className=''>{children}</div>}
/>
</>
);
}
+1 -1
View File
@@ -2,7 +2,7 @@ import ProjectFlockTable from '@/components/pages/production/project-flock/Proje
const ProjectFlock = () => {
return (
<section className='w-full p-4'>
<section className='size-full p-4'>
<ProjectFlockTable />
</section>
);
@@ -0,0 +1,11 @@
import SuspenseHelper from '@/components/helper/SuspenseHelper';
const Layout = ({
children,
}: Readonly<{
children: React.ReactNode;
}>) => {
return <SuspenseHelper>{children}</SuspenseHelper>;
};
export default Layout;
@@ -14,7 +14,7 @@ const RecordingEdit = () => {
const { data: recording, isLoading: isLoadingRecording } = useSWR(
recordingId,
(id: number) => RecordingApi.getSingle(id) // Gunakan RecordingApi
(id: string) => RecordingApi.getSingle(parseInt(id))
);
if (!recordingId) {
+1 -1
View File
@@ -14,7 +14,7 @@ const RecordingDetail = () => {
const { data: recording, isLoading: isLoadingRecording } = useSWR(
recordingId,
(id: number) => RecordingApi.getSingle(id)
(id: string) => RecordingApi.getSingle(parseInt(id))
);
if (!recordingId) {
@@ -8,91 +8,6 @@ import TransferToLayingForm from '@/components/pages/production/transfer-to-layi
import { TransferToLayingApi } from '@/services/api/production/transfer-to-laying';
import { isResponseError, isResponseSuccess } from '@/lib/api-helper';
import { TransferToLaying } from '@/types/api/production/transfer-to-laying';
// TODO: delete dummy data
const DUMMY_TRANSFER_TO_LAYING_EDIT: TransferToLaying = {
id: 1,
transfer_date: '2025-10-14',
flock_source: {
id: 1,
name: 'Flock asal test',
},
flock_destination: {
id: 2,
name: 'Flock tujuan destination',
},
quantity: 10,
kandangs: [
{
kandang: {
id: 1,
name: 'Kandang test',
status: 'ACTIVE',
location: {
id: 1,
name: 'test location',
address: 'test address 1',
area: { id: 1, name: 'test area 1' },
},
pic: {
id: 1,
id_user: 2,
email: 'test@gmail.com',
name: 'test',
},
created_user: {
id: 1,
id_user: 2,
email: 'test@gmail.com',
name: 'test',
},
created_at: '14-10-2025',
updated_at: '14-10-2025',
},
quantity: 8,
},
{
kandang: {
id: 1,
name: 'Kandang test 2',
status: 'ACTIVE',
location: {
id: 1,
name: 'test location',
address: 'test address 1',
area: { id: 1, name: 'test area 1' },
},
pic: {
id: 1,
id_user: 2,
email: 'test@gmail.com',
name: 'test',
},
created_user: {
id: 1,
id_user: 2,
email: 'test@gmail.com',
name: 'test',
},
created_at: '14-10-2025',
updated_at: '14-10-2025',
},
quantity: 2,
},
],
reason: 'Test alasan',
created_user: {
id: 1,
id_user: 2,
email: 'test@gmail.com',
name: 'test',
},
created_at: '14-10-2025',
updated_at: '14-10-2025',
};
const TransferToLayingEdit = () => {
const router = useRouter();
const searchParams = useSearchParams();
@@ -114,33 +29,33 @@ const TransferToLayingEdit = () => {
);
}
// TODO: remove dummy data and integrate with real API
if (
!isLoadingTransferToLaying &&
(!transferToLaying ||
(isResponseError(transferToLaying) && !DUMMY_TRANSFER_TO_LAYING_EDIT))
(!transferToLaying || isResponseError(transferToLaying))
) {
router.replace('/404');
return;
}
if (
isResponseSuccess(transferToLaying) &&
transferToLaying.data.approval.step_number === 2
) {
router.replace('/production/transfer-to-laying');
return;
}
return (
<div className='w-full p-4 flex flex-row justify-center'>
{isLoadingTransferToLaying && (
<span className='loading loading-spinner loading-xl' />
)}
{/* {!isLoadingTransferToLaying && isResponseSuccess(transferToLaying) && (
{!isLoadingTransferToLaying && isResponseSuccess(transferToLaying) && (
<TransferToLayingForm
type='detail'
type='edit'
initialValues={transferToLaying.data}
/>
)} */}
{/* TODO: remove this dummy data and integrate to real API */}
<TransferToLayingForm
type='edit'
initialValues={DUMMY_TRANSFER_TO_LAYING_EDIT}
/>
)}
</div>
);
};
@@ -8,91 +8,6 @@ import TransferToLayingForm from '@/components/pages/production/transfer-to-layi
import { TransferToLayingApi } from '@/services/api/production/transfer-to-laying';
import { isResponseError, isResponseSuccess } from '@/lib/api-helper';
import { TransferToLaying } from '@/types/api/production/transfer-to-laying';
// TODO: delete dummy data
const DUMMY_TRANSFER_TO_LAYING_DETAIL: TransferToLaying = {
id: 1,
transfer_date: '2025-10-14',
flock_source: {
id: 1,
name: 'Flock asal test',
},
flock_destination: {
id: 2,
name: 'Flock tujuan destination',
},
quantity: 10,
kandangs: [
{
kandang: {
id: 1,
name: 'Kandang test',
status: 'ACTIVE',
location: {
id: 1,
name: 'test location',
address: 'test address 1',
area: { id: 1, name: 'test area 1' },
},
pic: {
id: 1,
id_user: 2,
email: 'test@gmail.com',
name: 'test',
},
created_user: {
id: 1,
id_user: 2,
email: 'test@gmail.com',
name: 'test',
},
created_at: '14-10-2025',
updated_at: '14-10-2025',
},
quantity: 8,
},
{
kandang: {
id: 1,
name: 'Kandang test 2',
status: 'ACTIVE',
location: {
id: 1,
name: 'test location',
address: 'test address 1',
area: { id: 1, name: 'test area 1' },
},
pic: {
id: 1,
id_user: 2,
email: 'test@gmail.com',
name: 'test',
},
created_user: {
id: 1,
id_user: 2,
email: 'test@gmail.com',
name: 'test',
},
created_at: '14-10-2025',
updated_at: '14-10-2025',
},
quantity: 2,
},
],
reason: 'Test alasan',
created_user: {
id: 1,
id_user: 2,
email: 'test@gmail.com',
name: 'test',
},
created_at: '14-10-2025',
updated_at: '14-10-2025',
};
const TransferToLayingDetail = () => {
const router = useRouter();
const searchParams = useSearchParams();
@@ -114,11 +29,9 @@ const TransferToLayingDetail = () => {
);
}
// TODO: remove dummy data and integrate with real API
if (
!isLoadingTransferToLaying &&
(!transferToLaying ||
(isResponseError(transferToLaying) && !DUMMY_TRANSFER_TO_LAYING_DETAIL))
(!transferToLaying || isResponseError(transferToLaying))
) {
router.replace('/404');
return;
@@ -129,18 +42,13 @@ const TransferToLayingDetail = () => {
{isLoadingTransferToLaying && (
<span className='loading loading-spinner loading-xl' />
)}
{/* {!isLoadingTransferToLaying && isResponseSuccess(transferToLaying) && (
{!isLoadingTransferToLaying && isResponseSuccess(transferToLaying) && (
<TransferToLayingForm
type='detail'
initialValues={transferToLaying.data}
/>
)} */}
{/* TODO: remove this dummy data and integrate to real API */}
<TransferToLayingForm
type='detail'
initialValues={DUMMY_TRANSFER_TO_LAYING_DETAIL}
/>
)}
</div>
);
};
+11
View File
@@ -0,0 +1,11 @@
import PurchaseRequestForm from '@/components/pages/purchase/form/request/PurchaseRequestForm';
const AddPurchaseRequest = () => {
return (
<div className='w-full p-4 flex flex-row justify-center'>
<PurchaseRequestForm />
</div>
);
};
export default AddPurchaseRequest;
+47
View File
@@ -0,0 +1,47 @@
'use client';
import { useRouter, useSearchParams } from 'next/navigation';
import useSWR from 'swr';
import PurchaseRequestForm from '@/components/pages/purchase/form/request/PurchaseRequestForm';
import { PurchaseApi } from '@/services/api/purchase';
import { isResponseSuccess, isResponseError } from '@/lib/api-helper';
const PurchaseEdit = () => {
const router = useRouter();
const searchParams = useSearchParams();
const purchaseId = searchParams.get('purchaseId');
const { data: purchase, isLoading: isLoadingPurchase } = useSWR(
purchaseId,
(id: number) => PurchaseApi.getSingle(id)
);
if (!purchaseId) {
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 (!isLoadingPurchase && (!purchase || isResponseError(purchase))) {
router.replace('/404');
return;
}
return (
<div className='w-full p-4 flex flex-row justify-center'>
{isLoadingPurchase && (
<span className='loading loading-spinner loading-xl' />
)}
{!isLoadingPurchase && isResponseSuccess(purchase) && (
<PurchaseRequestForm type='edit' initialValues={purchase.data} />
)}
</div>
);
};
export default PurchaseEdit;
+54
View File
@@ -0,0 +1,54 @@
'use client';
import { useRouter, useSearchParams } from 'next/navigation';
import useSWR from 'swr';
import PurchaseOrderDetail from '@/components/pages/purchase/order/PurchaseOrderDetail';
import { PurchaseApi } from '@/services/api/purchase';
import { isResponseSuccess, isResponseError } from '@/lib/api-helper';
const PurchaseDetail = () => {
const router = useRouter();
const searchParams = useSearchParams();
const purchaseId = searchParams.get('purchaseId');
const {
data: purchase,
isLoading: isLoadingPurchase,
mutate: mutatePurchase,
} = useSWR(purchaseId, (id: number) => PurchaseApi.getSingle(id));
if (!purchaseId) {
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 (!isLoadingPurchase && (!purchase || isResponseError(purchase))) {
router.replace('/404');
return;
}
return (
<div className='w-full p-4'>
{isLoadingPurchase && (
<div className='w-full flex flex-row justify-center items-center'>
<span className='loading loading-spinner loading-xl' />
</div>
)}
{!isLoadingPurchase && isResponseSuccess(purchase) && (
<PurchaseOrderDetail
type='detail'
initialValues={purchase.data}
refetchData={mutatePurchase}
/>
)}
</div>
);
};
export default PurchaseDetail;
+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 PurchaseTable from '@/components/pages/purchase/PurchaseTable';
const Purchase = () => {
return (
<section className='w-full p-4'>
<PurchaseTable />
</section>
);
};
export default Purchase;
+1 -1
View File
@@ -3,7 +3,7 @@ import Link from 'next/link';
import { cn } from '@/lib/helper';
import { Color } from '@/types/theme';
interface ButtonProps extends react.ComponentProps<'button'> {
export interface ButtonProps extends react.ComponentProps<'button'> {
variant?: 'soft' | 'outline' | 'dash' | 'ghost' | 'link' | 'active';
color?: Color;
href?: string;
+128 -33
View File
@@ -1,8 +1,11 @@
'use client';
import { HTMLAttributes, ReactNode } from 'react';
import { HTMLAttributes, ReactNode, useState } from 'react';
import { cn } from '@/lib/helper';
import Image from 'next/image';
import Collapse from '@/components/Collapse';
import { Icon } from '@iconify/react';
export interface CardProps
extends Omit<HTMLAttributes<HTMLDivElement>, 'className'> {
@@ -10,8 +13,13 @@ export interface CardProps
subtitle?: string;
image?: string;
imageAlt?: string;
imageWidth?: number;
imageHeight?: number;
actions?: ReactNode;
footer?: ReactNode;
collapsible?: boolean;
defaultCollapsed?: boolean;
onCollapsedChange?: (collapsed: boolean) => void;
className?: {
wrapper?: string;
image?: string;
@@ -20,6 +28,7 @@ export interface CardProps
subtitle?: string;
actions?: string;
footer?: string;
collapsible?: string;
};
variant?: 'default' | 'compact' | 'bordered' | 'shadow' | 'image-full';
size?: 'sm' | 'md' | 'lg';
@@ -30,14 +39,27 @@ const Card = ({
subtitle,
image,
imageAlt,
imageWidth,
imageHeight,
actions,
footer,
collapsible,
defaultCollapsed = false,
onCollapsedChange,
className,
variant = 'default',
size = 'md',
children,
...props
}: CardProps) => {
const [isCollapsed, setIsCollapsed] = useState(defaultCollapsed);
const handleCollapsedChange = (open: boolean) => {
const collapsed = !open;
setIsCollapsed(collapsed);
onCollapsedChange?.(collapsed);
};
const getCardClasses = () => {
const baseClasses = 'card bg-base-100';
@@ -63,11 +85,31 @@ const Card = ({
);
};
const getImageDimensions = () => {
if (variant === 'image-full') {
return {
width: imageWidth || 128,
height: imageHeight || 128,
};
}
const cardWidths = {
sm: 256, // w-64
md: 384, // w-96
lg: 448, // w-[28rem]
};
return {
width: imageWidth || cardWidths[size],
height: imageHeight || 192,
};
};
const getImageClasses = () => {
if (variant === 'image-full') {
return cn('w-32 h-32 object-cover', className?.image);
return cn('object-cover', className?.image);
}
return cn('h-48 object-cover', className?.image);
return cn('w-full object-cover', className?.image);
};
const getBodyClasses = () => {
@@ -102,45 +144,98 @@ const Card = ({
return cn('border-t border-base-300 mt-4 pt-4', className?.footer);
};
const renderCardContent = () => {
const hasContent = children || actions || footer;
const titleContent = (
<div className='group flex items-center !justify-between w-full'>
<div className='flex-1'>
{title && <h2 className={getTitleClasses()}>{title}</h2>}
{subtitle && <p className={getSubtitleClasses()}>{subtitle}</p>}
</div>
{collapsible && (
<button
onClick={() => handleCollapsedChange(!isCollapsed)}
className='btn btn-ghost btn-sm btn-circle'
aria-label={isCollapsed ? 'Expand content' : 'Collapse content'}
>
<Icon
icon={
isCollapsed
? 'material-symbols:expand-more'
: 'material-symbols:expand-less'
}
width={20}
/>
</button>
)}
</div>
);
const cardContent = (
<div className='space-y-4'>
{children}
{actions && <div className={getActionsClasses()}>{actions}</div>}
{footer && <div className={getFooterClasses()}>{footer}</div>}
</div>
);
return (
<>
{image && (
<figure>
<Image
src={image}
alt={imageAlt || title || 'Card image'}
width={getImageDimensions().width}
height={getImageDimensions().height}
className={getImageClasses()}
/>
</figure>
)}
<div className={getBodyClasses()}>
{collapsible && hasContent ? (
<Collapse
variant='default'
bordered={false}
open={!isCollapsed}
onOpenChange={handleCollapsedChange}
title={titleContent}
titleClassName='w-full cursor-pointer'
contentClassName='p-0'
fullWidth={true}
>
{cardContent}
</Collapse>
) : (
<>
{(title || subtitle) && (
<div className='mb-4'>
{title && <h2 className={getTitleClasses()}>{title}</h2>}
{subtitle && (
<p className={getSubtitleClasses()}>{subtitle}</p>
)}
</div>
)}
{hasContent && cardContent}
</>
)}
</div>
</>
);
};
if (variant === 'image-full' && image) {
return (
<div className={getCardClasses()} {...props}>
<figure>
<img
src={image}
alt={imageAlt || title || 'Card image'}
className={getImageClasses()}
/>
</figure>
<div className={getBodyClasses()}>
{title && <h2 className={getTitleClasses()}>{title}</h2>}
{subtitle && <p className={getSubtitleClasses()}>{subtitle}</p>}
{children}
{actions && <div className={getActionsClasses()}>{actions}</div>}
</div>
{footer && <div className={getFooterClasses()}>{footer}</div>}
{renderCardContent()}
</div>
);
}
return (
<div className={getCardClasses()} {...props}>
{image && (
<figure>
<img
src={image}
alt={imageAlt || title || 'Card image'}
className={getImageClasses()}
/>
</figure>
)}
<div className={getBodyClasses()}>
{title && <h2 className={getTitleClasses()}>{title}</h2>}
{subtitle && <p className={getSubtitleClasses()}>{subtitle}</p>}
{children}
{actions && <div className={getActionsClasses()}>{actions}</div>}
</div>
{footer && <div className={getFooterClasses()}>{footer}</div>}
{renderCardContent()}
</div>
);
};
+6 -2
View File
@@ -26,6 +26,9 @@ export type CollapseProps = {
disabled?: boolean;
/** Allow only one open at a time by switching to radio input */
asRadio?: boolean;
/** Force full width instead of auto-fit when collapsed
* (Khusus justify-between dan justify-end) */
fullWidth?: boolean;
/** Extra classnames */
className?: string;
titleClassName?: string;
@@ -44,6 +47,7 @@ export const Collapse = ({
bordered,
disabled,
asRadio = false,
fullWidth,
className,
titleClassName,
contentClassName,
@@ -68,9 +72,9 @@ export const Collapse = ({
'collapse',
variant === 'arrow' && 'collapse-arrow',
variant === 'plus' && 'collapse-plus',
bordered && 'border base-content/20 border-opacity-20 rounded',
bordered && 'border base-content/20 border-opacity-20 rounded-box',
disabled && 'opacity-60 pointer-events-none',
!open && 'w-fit',
!fullWidth && !open && 'w-fit',
className
);
+103 -8
View File
@@ -10,28 +10,102 @@ interface DrawerProps {
open: boolean;
setOpen: (newOpenState: boolean) => void;
openOnLarge?: boolean;
variant?: 'sidebar' | 'left' | 'right';
zIndex?: string;
className?: DrawerClassName;
onBackdropClick?: () => void;
closeOnBackdropClick?: boolean;
}
type DrawerClassName = {
drawer?: string;
drawerContent?: string;
drawerSide?: string;
drawerOverlay?: string;
drawerSidebarContent?: string;
};
const Drawer = ({
children,
sidebarContent,
open,
setOpen,
openOnLarge,
variant = 'sidebar',
zIndex = '20',
className,
onBackdropClick,
closeOnBackdropClick = true,
}: DrawerProps) => {
const getDrawerClassNames = (): DrawerClassName => {
const baseClassNames = {
drawer: 'drawer',
drawerContent: 'drawer-content',
drawerSide: 'drawer-side',
drawerOverlay: 'drawer-overlay',
drawerSidebarContent: 'min-h-full bg-base-100',
};
if (variant === 'sidebar') {
return {
...baseClassNames,
drawerSidebarContent: cn(
baseClassNames.drawerSidebarContent,
'w-full max-w-[300px] lg:w-[300px]'
),
};
} else if (variant === 'right') {
return {
...baseClassNames,
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'
),
drawerSidebarContent: cn(
baseClassNames.drawerSidebarContent,
'w-full min-w-120 sm:w-fit'
),
};
} else if (variant === 'left') {
return {
...baseClassNames,
drawerSide: cn(
baseClassNames.drawerSide,
'border-l border-solid border-gray-200 drawer-side w-screen top-0 right-0 fixed z-21'
),
drawerSidebarContent: cn(
baseClassNames.drawerSidebarContent,
'w-full min-w-120 sm:w-fit'
),
};
}
return baseClassNames; // Fallback for default or unknown variant
};
const varianClassName = getDrawerClassNames();
const toggleDrawer = () => {
setOpen(!open);
};
const closeDrawer = () => {
setOpen(false);
if (closeOnBackdropClick) {
setOpen(false);
}
onBackdropClick && onBackdropClick();
};
return (
<div
className={cn('drawer', {
'lg:drawer-open': openOnLarge,
})}
className={cn(
'drawer',
{
'lg:drawer-open': openOnLarge,
},
varianClassName?.drawer,
className?.drawer
)}
>
<input
type='checkbox'
@@ -40,16 +114,37 @@ const Drawer = ({
className='drawer-toggle'
/>
<div className='drawer-content'>{children}</div>
{/* Drawer Content */}
<div
className={cn(varianClassName?.drawerContent, className?.drawerContent)}
>
{children}
</div>
<div className='drawer-side border-r border-solid border-gray-200 z-20'>
{/* Drawer Side */}
<div
className={cn(
varianClassName?.drawerSide,
className?.drawerSide,
zIndex
)}
>
<label
aria-label='close sidebar'
className='drawer-overlay'
className={cn(
varianClassName?.drawerOverlay,
className?.drawerOverlay
)}
onClick={closeDrawer}
/>
<div className='min-h-full w-full max-w-[300px] lg:w-[300px] bg-base-100'>
{/* Sidebar Content */}
<div
className={cn(
varianClassName?.drawerSidebarContent,
className?.drawerContent
)}
>
{sidebarContent}
</div>
</div>
+141
View File
@@ -0,0 +1,141 @@
'use client';
import Button from '@/components/Button';
import Tooltip from '@/components/Tooltip';
import { cn } from '@/lib/helper';
import { Icon } from '@iconify/react';
type FloatingActionsButtonProps = {
actions: {
action: 'DETAIL' | 'EDIT' | 'DELETE';
icon: string;
label?: string;
onClick?: () => void;
hidden?: boolean;
disabled?: boolean;
}[];
approvals: {
action: 'APPROVED' | 'REJECTED';
icon: string;
label?: string;
onClick?: () => void;
disabled?: boolean;
}[];
selectedRowIds: number[];
onClose: () => void;
};
const FloatingActionsButton = ({
actions,
approvals,
selectedRowIds,
onClose,
}: FloatingActionsButtonProps) => {
// Jika tidak ada baris yang dipilih, jangan tampilkan FAB
const positionStyles =
selectedRowIds.length > 0 ? 'bottom-[10%]' : 'bottom-[-100%]';
// Helper untuk menentukan gaya warna tombol approval
const getApprovalColor = (action: 'APPROVED' | 'REJECTED') => {
if (action === 'APPROVED') return 'success';
if (action === 'REJECTED') return 'error';
return 'primary';
};
const getActionColor = (action: 'DETAIL' | 'EDIT' | 'DELETE') => {
if (action === 'DETAIL') return 'white';
if (action === 'EDIT') return 'warning';
if (action === 'DELETE') return 'error';
return 'primary';
};
return (
// Container utama FAB
<div
className={cn(
`absolute ${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'
)}
>
<div className='flex flex-col gap-3'>
{/* === BARIS ATAS: Status Seleksi dan Actions (Termasuk Close) === */}
<div className='flex justify-between items-center text-white'>
<h4 className='text-base font-semibold'>
{selectedRowIds.length} Selected
</h4>
<div className='flex flex-row gap-1 items-stretch'>
<div className='flex gap-4 items-center'>
{/* Render Aksi dari props.actions */}
{actions
.filter((action) => !action.hidden)
.map((action, index) => {
return (
<Button
key={index}
onClick={action.onClick}
className='text-white hover:text-gray-400 tooltip tooltip-bottom p-0'
variant='link'
disabled={action.disabled}
>
<Tooltip content={action.label || action.action}>
<Icon
icon={action.icon}
width={20}
height={20}
className={`text-${getActionColor(action.action)} font-thin`}
/>
</Tooltip>
</Button>
);
})}
<div className='border-[0.5px] border-white/30 h-full'></div>
{/* Tombol Close */}
<Button
onClick={onClose}
className='text-white hover:text-gray-400 p-0'
variant='link'
>
<Tooltip content='Close'>
<Icon icon='mdi:close' width={20} height={20} />
</Tooltip>
</Button>
</div>
</div>
</div>
{/* === 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>
))}
</div>
</div>
</div>
);
};
export default FloatingActionsButton;
+7 -147
View File
@@ -1,161 +1,21 @@
'use client';
import { useCallback, useState } from 'react';
import { useCallback } from 'react';
import { usePathname } from 'next/navigation';
import Image from 'next/image';
import { Icon } from '@iconify/react';
import Drawer from '@/components/Drawer';
import Menu from '@/components/menu/Menu';
import MenuItem from '@/components/menu/MenuItem';
import Navbar from '@/components/Navbar';
import Collapse from '@/components/Collapse';
import Button from '@/components/Button';
import SidebarMenu from '@/components/molecules/SidebarMenu';
import { useUiStore } from '@/stores/ui/ui.store';
import { MAIN_DRAWER_LINKS } from '@/config/constant';
import { cn } from '@/lib/helper';
type CollapseMenuProps = {
title: string;
link: string;
icon: string;
submenu?: CollapseMenuProps[];
depth?: number;
};
const isPathActive = (pathname: string, link?: string) => {
if (!link) return false;
const splittedPathname = pathname.split('/');
const splittedLink = link.split('/');
const isActiveLinkValid = splittedLink.every((linkChunk, idx) => {
return linkChunk === splittedPathname[idx];
});
return pathname.startsWith(link) && isActiveLinkValid;
};
const CollapseMenu = ({
title,
link,
icon,
submenu,
depth = 0,
}: CollapseMenuProps) => {
const pathname = usePathname();
const isActive = isPathActive(pathname, link);
const [open, setOpen] = useState(isActive);
const menuCollapseTitle = (
<div
className={cn(
'w-full px-3 py-2 rounded-md text-base font-semibold transition-colors flex flex-row justify-between items-center gap-2 hover:bg-primary/10 opacity-40',
{
'bg-primary/10 opacity-100': open || isActive,
}
)}
>
<div className='flex flex-row items-center gap-2'>
<Icon icon={icon} width={20} height={20} />
<span>{title}</span>
</div>
<Icon
icon='cuida:caret-up-outline'
width={20}
height={20}
className={cn('transition-transform', {
'rotate-90': !open,
'rotate-180': open,
})}
/>
</div>
);
return (
<Collapse
open={open}
title={menuCollapseTitle}
onOpenChange={setOpen}
className='w-full'
titleClassName='w-full p-0!'
>
<Menu>
<div
className='w-full py-0.5 flex flex-col gap-0.5'
style={{
paddingLeft: `${0.5 * (depth + 1)}rem`,
}}
>
{submenu?.map((item, idx) => {
const hasSubmenu = item.submenu && item.submenu.length > 0;
if (!hasSubmenu) {
return (
<MenuItem
key={idx}
title={item.title}
href={item.link}
icon={item.icon}
active={isPathActive(pathname, item.link)}
/>
);
}
return (
<CollapseMenu
key={idx}
title={item.title}
link={item.link}
icon={item.icon}
submenu={item.submenu}
depth={depth + 1}
/>
);
})}
</div>
</Menu>
</Collapse>
);
};
const MainDrawerMenu = () => {
const pathname = usePathname();
return (
<Menu>
{MAIN_DRAWER_LINKS.map((item, idx) => {
const hasSubmenu = item.submenu && item.submenu.length > 0;
if (!hasSubmenu) {
return (
<MenuItem
key={idx}
title={item.title}
href={item.link}
icon={item.icon}
active={pathname.startsWith(item.link)}
/>
);
}
return (
<CollapseMenu
key={idx}
title={item.title}
link={item.link}
icon={item.icon}
submenu={item.submenu}
/>
);
})}
</Menu>
);
};
import { isPathActive } from '@/lib/helper';
const MainDrawerContent = () => {
const pathname = usePathname();
const { setMainDrawerOpen } = useUiStore();
const closeMainDrawerHandler = () => {
@@ -191,7 +51,7 @@ const MainDrawerContent = () => {
</div>
</div>
<MainDrawerMenu />
<SidebarMenu menu={MAIN_DRAWER_LINKS} activeLink={pathname} />
</div>
);
};
@@ -216,9 +76,9 @@ const MainDrawer = ({
const hasSubmenu = menu?.submenu && menu?.submenu.length > 0;
if (!title) {
title += menu?.title;
title += menu?.text;
} else {
title += ' - ' + menu?.title;
title += ' - ' + menu?.text;
}
if (!hasSubmenu || !menu.submenu) return;
+43 -25
View File
@@ -1,38 +1,52 @@
'use client';
import { ReactNode, RefObject, useCallback, useRef, useState } from 'react';
import {
ReactNode,
RefObject,
useCallback,
useEffect,
useRef,
useState,
} from 'react';
import { cn } from '@/lib/helper';
export const useModal = () => {
export const useModal = (isNestingModal = false) => {
const ref = useRef<HTMLDialogElement>(null);
const [open, setOpen] = useState(false);
const openModal = useCallback(() => {
if (!ref.current) return;
if (isNestingModal) {
ref.current.showModal();
} else {
ref.current.show();
}
setOpen(true);
ref.current?.showModal();
}, []);
}, [isNestingModal]);
const closeModal = useCallback(() => {
if (!ref.current) return;
ref.current.close();
setOpen(false);
ref.current?.close();
}, []);
const toggle = useCallback(() => {
if (open) {
closeModal();
} else {
openModal();
}
open ? closeModal() : openModal();
}, [open, closeModal, openModal]);
if (ref.current) {
ref.current.addEventListener('close', () => {
closeModal();
});
}
useEffect(() => {
const dialog = ref.current;
if (!dialog) return;
return { ref, open, setOpen, openModal, closeModal, toggle } as const;
const handleClose = () => setOpen(false);
dialog.addEventListener('close', handleClose);
return () => {
dialog.removeEventListener('close', handleClose);
};
}, []);
return { ref, open, openModal, closeModal, toggle } as const;
};
interface ModalProps {
@@ -46,15 +60,19 @@ interface ModalProps {
}
const Modal = ({ ref, children, closeOnBackdrop, className }: ModalProps) => {
return (
<dialog ref={ref} className={cn('modal', className?.modal)}>
<div className={cn('modal-box', className?.modalBox)}>{children}</div>
const handleBackdropClick = (e: React.MouseEvent<HTMLDialogElement>) => {
if (closeOnBackdrop && e.target === ref.current) {
ref.current?.close();
}
};
{closeOnBackdrop && (
<form method='dialog' className='modal-backdrop'>
<button>close</button>
</form>
)}
return (
<dialog
ref={ref}
className={cn('modal', className?.modal)}
onClick={handleBackdropClick}
>
<div className={cn('modal-box', className?.modalBox)}>{children}</div>
</dialog>
);
};
+36 -14
View File
@@ -1,9 +1,17 @@
'use client';
import toast from 'react-hot-toast';
import { useRouter } from 'next/navigation';
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 { useAuth } from '@/services/hooks/useAuth';
import { AuthApi } from '@/services/api/auth';
import { isResponseError } from '@/lib/api-helper';
interface NavbarProps {
title: string;
@@ -11,6 +19,21 @@ interface NavbarProps {
}
const Navbar = ({ title, toggleSidebar }: NavbarProps) => {
const { setUser } = useAuth();
const router = useRouter();
const logoutClickHandler = async () => {
const logoutRes = await AuthApi.logout();
if (isResponseError(logoutRes)) {
toast.error('Gagal logout! Coba lagi!');
return;
}
setUser(undefined);
router.replace(process.env.NEXT_PUBLIC_SSO_LOGIN_URL as string);
};
return (
<div className='navbar px-4 bg-base-100 shadow-sm'>
<div className='flex-1'>
@@ -30,22 +53,21 @@ const Navbar = ({ title, toggleSidebar }: NavbarProps) => {
</div>
<div className='flex gap-2'>
<div className='dropdown dropdown-end'>
<div
tabIndex={0}
role='button'
className='btn btn-ghost btn-circle avatar'
>
<div className='w-10 rounded-full border grid place-items-center'>
<Icon icon='uil:user' width={40} height={40} />
<Dropdown
position='bottom-end'
trigger={
<div className='btn btn-ghost btn-circle avatar'>
<div className='w-10 rounded-full border flex justify-center items-center'>
<Icon icon='uil:user' width={40} height={40} />
</div>
</div>
</div>
<Menu className='dropdown-content w-52 mt-3 p-2 bg-base-100 shadow rounded-box menu-sm'>
<MenuItem title='Settings' href='#' />
<MenuItem title='Logout' href='#' />
}
contentClassName='w-52 mt-3'
>
<Menu className='p-2 bg-base-100 shadow rounded-box menu-sm'>
<MenuItem title='Logout' onClick={logoutClickHandler} />
</Menu>
</div>
</Dropdown>
</div>
</div>
);
+302 -212
View File
@@ -1,7 +1,9 @@
'use client';
import { ReactNode } from 'react';
import { ChangeEventHandler, ReactNode } from 'react';
import { Icon } from '@iconify/react';
import Button from '@/components/Button';
import { cn } from '@/lib/helper';
@@ -17,16 +19,18 @@ const PaginationButton = ({
disabled?: boolean;
onClick?: () => void;
}) => (
<button
className={cn(
'join-item btn btn-ghost p-2.5 rounded-lg text-sm font-medium text-gray-500 aspect-square',
'disabled:text-gray-700 disabled:pointer-events-auto! disabled:cursor-not-allowed! disabled:bg-gray-50 disabled:active:translate-y-0'
)}
<Button
variant='ghost'
color='none'
disabled={disabled}
onClick={onClick}
className={cn(
'join-item w-10 h-10 grid place-items-center p-2.5 rounded-lg! text-sm font-semibold text-base-content/50 aspect-square',
'disabled:text-primary disabled:pointer-events-auto! disabled:cursor-not-allowed! disabled:bg-primary/10 disabled:active:translate-y-0'
)}
>
{content}
</button>
</Button>
);
const EtcPaginationButton = ({
@@ -48,7 +52,7 @@ const EtcPaginationButton = ({
tabIndex={0}
role='button'
className={cn(
'join-item btn btn-ghost p-2.5 rounded-lg text-sm font-medium text-gray-500 aspect-square'
'join-item btn btn-ghost p-2.5 rounded-lg! text-sm font-medium text-gray-500 aspect-square'
)}
>
...
@@ -57,7 +61,7 @@ const EtcPaginationButton = ({
<div className='dropdown-content'>
<ul
tabIndex={0}
className='menu bg-base-100 rounded-lg z-1 w-fit min-w-max max-h-64 p-1 shadow-sm mb-2 overflow-y-auto flex-nowrap'
className='menu bg-base-100 rounded-lg! z-1 w-fit min-w-max max-h-64 p-1 shadow-sm mb-2 overflow-y-auto flex-nowrap'
>
{pages.map((pageNumber) => (
<li key={pageNumber}>
@@ -76,7 +80,7 @@ const EtcPaginationButton = ({
<button
disabled
className={cn(
'join-item btn btn-ghost p-2.5 rounded-lg text-sm font-medium text-gray-500 aspect-square'
'join-item btn btn-ghost p-2.5 rounded-lg! text-sm font-medium text-gray-500 aspect-square'
)}
>
...
@@ -90,16 +94,20 @@ const Pagination = ({
currentPage = 1,
totalItems = 0,
itemsPerPage = 10,
rowOptions = [10, 20, 50, 100],
onPageChange,
onPrevPage = () => {},
onNextPage = () => {},
onRowChange,
}: {
currentPage: number;
totalItems: number;
itemsPerPage: number;
rowOptions?: number[];
onPageChange: (pageNumber: number) => void;
onPrevPage: () => void;
onNextPage: () => void;
onRowChange?: (row: number) => void;
}) => {
const totalPages =
Math.ceil(totalItems / itemsPerPage) === 0
@@ -107,30 +115,139 @@ const Pagination = ({
: Math.ceil(totalItems / itemsPerPage);
const pageChangeHandler = (pageNumber: number) => onPageChange(pageNumber);
const firstPageClickHandler = () => onPageChange(1);
const lastPageClickHandler = () => onPageChange(totalPages);
const rowChangeHandler: ChangeEventHandler<HTMLSelectElement> = (e) => {
onRowChange?.(Number(e.target.value));
};
const DisplayedRowCountSelect = () => (
<div className='flex flex-row items-center gap-4'>
<span className='text-sm font-medium text-base-content/50'>Showing</span>
<select
defaultValue={itemsPerPage}
onChange={rowChangeHandler}
className='select select-xs w-fit pl-3 pr-7 text-base-content/50'
>
{rowOptions.map((rowOption, rowOptionIdx) => (
<option
key={rowOptionIdx}
value={rowOption}
className='text-base-content active:text-neutral-content'
>
{rowOption} Per page
</option>
))}
</select>
</div>
);
const GoToFirstPageButton = () => (
<Button
disabled={currentPage === 1}
onClick={firstPageClickHandler}
variant='ghost'
color='none'
className={cn(
'join-item w-10 h-10 grid place-items-center p-2.5 rounded-lg! text-sm font-semibold text-base-content/50 aspect-square',
'disabled:bg-[initial]! disabled:text-base-content disabled:pointer-events-auto! disabled:cursor-not-allowed disabled:active:translate-y-0'
)}
>
<Icon
icon='heroicons:chevron-double-left'
width={20}
height={20}
className='text-gray-400 group-disabled:text-gray-300'
/>
</Button>
);
const PrevPageButton = () => (
<Button
disabled={currentPage === 1}
onClick={onPrevPage}
variant='ghost'
color='none'
className={cn(
'join-item w-10 h-10 grid place-items-center p-2.5 rounded-lg! text-sm font-semibold text-base-content/50 aspect-square',
'disabled:bg-[initial]! disabled:text-base-content disabled:pointer-events-auto! disabled:cursor-not-allowed disabled:active:translate-y-0'
)}
>
<Icon
icon='heroicons:chevron-left'
width={20}
height={20}
className='text-gray-400 group-disabled:text-gray-300'
/>
</Button>
);
const GoToLastPageButton = () => (
<Button
variant='ghost'
color='none'
disabled={currentPage === totalPages}
onClick={lastPageClickHandler}
className={cn(
'join-item w-10 h-10 grid place-items-center p-2.5 rounded-lg! text-sm font-semibold text-base-content/50 aspect-square',
'disabled:bg-[initial]! disabled:text-base-content disabled:pointer-events-auto! disabled:cursor-not-allowed disabled:active:translate-y-0'
)}
>
<Icon
icon='heroicons:chevron-double-right'
width={20}
height={20}
className='text-gray-400 group-disabled:text-gray-300'
/>
</Button>
);
const NextPageButton = () => (
<Button
variant='ghost'
color='none'
disabled={currentPage === totalPages}
onClick={onNextPage}
className={cn(
'join-item w-10 h-10 grid place-items-center p-2.5 rounded-lg! text-sm font-semibold text-base-content/50 aspect-square',
'disabled:bg-[initial]! disabled:text-base-content disabled:pointer-events-auto! disabled:cursor-not-allowed disabled:active:translate-y-0'
)}
>
<Icon
icon='heroicons:chevron-right'
width={20}
height={20}
className='text-gray-400 group-disabled:text-gray-300'
/>
</Button>
);
const PageInfo = () => (
<span className='text-nowrap text-sm font-medium text-base-content/50'>
Page {currentPage} of {totalPages}
</span>
);
return (
<div>
<div className='join w-full justify-between items-center gap-3'>
<button
disabled={currentPage === 1}
onClick={onPrevPage}
className={cn(
'join-item btn btn-outline group px-3 py-2 text-sm font-semibold rounded-lg border border-gray-300 shadow-xs hidden sm:flex justify-center items-center gap-1.5',
'disabled:bg-[initial]! disabled:text-gray-400 disabled:pointer-events-auto! disabled:cursor-not-allowed disabled:active:translate-y-0'
)}
>
<Icon
icon='uil:arrow-left'
width={20}
height={20}
className='text-gray-400 group-disabled:text-gray-300'
/>{' '}
Previous
</button>
<div className='@container'>
<div className='flex flex-row justify-center items-center'>
<div className='hidden @md:block'>
<DisplayedRowCountSelect />
</div>
{totalPages <= 7 && (
<div className='join-item join gap-0.5'>
{range(1, totalPages).map((pageNumber) => (
<div className='join w-full justify-end @md:justify-center items-center gap-0.5'>
<div className='hidden @md:block'>
<GoToFirstPageButton />
</div>
<div className='hidden @md:block'>
<PrevPageButton />
</div>
{totalPages <= 7 &&
range(1, totalPages).map((pageNumber) => (
<PaginationButton
key={pageNumber}
content={pageNumber}
@@ -138,195 +255,168 @@ const Pagination = ({
onClick={() => pageChangeHandler(pageNumber)}
/>
))}
</div>
)}
{totalPages > 7 && (
<div className='join-item join gap-0.5'>
<PaginationButton
content={1}
disabled={currentPage === 1}
onClick={() => pageChangeHandler(1)}
/>
{totalPages >= 2 &&
(currentPage <= 3 || currentPage >= totalPages - 2) && (
<PaginationButton
content={2}
disabled={currentPage === 2}
onClick={() => pageChangeHandler(2)}
/>
)}
{totalPages >= 2 &&
currentPage > 3 &&
currentPage < totalPages - 2 && (
<EtcPaginationButton
startPage={2}
endPage={currentPage - 2}
onPageItemClick={pageChangeHandler}
/>
)}
{totalPages >= 3 &&
(currentPage <= 4 || currentPage >= totalPages - 2) &&
currentPage !== totalPages - 2 && (
<PaginationButton
content={3}
disabled={currentPage === 3}
onClick={() => pageChangeHandler(3)}
/>
)}
{totalPages >= 7 &&
(currentPage <= 2 || currentPage >= totalPages - 2) && (
<EtcPaginationButton
startPage={
currentPage <= 2
? currentPage + 2
: currentPage === totalPages - 2
? 3
: currentPage >= totalPages - 1
? 4
: 1
}
endPage={
currentPage <= 2 || currentPage >= totalPages - 1
? totalPages - 3
: currentPage === totalPages - 2
? totalPages - 4
: 2
}
onPageItemClick={pageChangeHandler}
/>
)}
{totalPages >= 3 &&
currentPage > 4 &&
currentPage < totalPages - 1 && (
<PaginationButton
content={currentPage - 1}
onClick={() => pageChangeHandler(currentPage - 1)}
/>
)}
{totalPages >= 7 &&
currentPage > 3 &&
currentPage < totalPages - 2 && (
<PaginationButton content={currentPage} disabled />
)}
{totalPages >= 5 &&
currentPage > 2 &&
currentPage < totalPages - 2 && (
<PaginationButton
content={currentPage + 1}
onClick={() => pageChangeHandler(currentPage + 1)}
/>
)}
{totalPages >= 5 &&
(currentPage <= 2 || currentPage >= totalPages - 2) && (
<PaginationButton
content={totalPages - 2}
disabled={currentPage === totalPages - 2}
onClick={() => pageChangeHandler(totalPages - 2)}
/>
)}
{totalPages >= 6 &&
currentPage > 2 &&
currentPage < totalPages - 3 && (
<EtcPaginationButton
startPage={
currentPage <= 3
? currentPage + 2
: currentPage >= 4
? currentPage + 2
: 1
}
endPage={
currentPage <= 3
? totalPages - 2
: currentPage >= 4
? totalPages - 1
: 0
}
onPageItemClick={pageChangeHandler}
/>
)}
{totalPages >= 6 &&
(currentPage <= 3 || currentPage >= totalPages - 3) && (
<PaginationButton
content={totalPages - 1}
disabled={currentPage === totalPages - 1}
onClick={() => pageChangeHandler(totalPages - 1)}
/>
)}
{totalPages >= 7 && (
{totalPages > 7 && (
<>
<PaginationButton
content={totalPages}
disabled={currentPage === totalPages}
onClick={() => pageChangeHandler(totalPages)}
content={1}
disabled={currentPage === 1}
onClick={() => pageChangeHandler(1)}
/>
)}
</div>
)}
<button
disabled={currentPage === totalPages}
onClick={onNextPage}
className={cn(
'join-item btn btn-outline group px-3 py-2 text-sm font-semibold rounded-lg border border-gray-300 shadow-xs hidden sm:flex justify-center items-center gap-1.5',
'disabled:bg-[initial]! disabled:text-gray-400 disabled:pointer-events-auto! disabled:cursor-not-allowed disabled:active:translate-y-0'
{totalPages >= 2 &&
(currentPage <= 3 || currentPage >= totalPages - 2) && (
<PaginationButton
content={2}
disabled={currentPage === 2}
onClick={() => pageChangeHandler(2)}
/>
)}
{totalPages >= 2 &&
currentPage > 3 &&
currentPage < totalPages - 2 && (
<EtcPaginationButton
startPage={2}
endPage={currentPage - 2}
onPageItemClick={pageChangeHandler}
/>
)}
{totalPages >= 3 &&
(currentPage <= 4 || currentPage >= totalPages - 2) &&
currentPage !== totalPages - 2 && (
<PaginationButton
content={3}
disabled={currentPage === 3}
onClick={() => pageChangeHandler(3)}
/>
)}
{totalPages >= 7 &&
(currentPage <= 2 || currentPage >= totalPages - 2) && (
<EtcPaginationButton
startPage={
currentPage <= 2
? currentPage + 2
: currentPage === totalPages - 2
? 3
: currentPage >= totalPages - 1
? 4
: 1
}
endPage={
currentPage <= 2 || currentPage >= totalPages - 1
? totalPages - 3
: currentPage === totalPages - 2
? totalPages - 4
: 2
}
onPageItemClick={pageChangeHandler}
/>
)}
{totalPages >= 3 &&
currentPage > 4 &&
currentPage < totalPages - 1 && (
<PaginationButton
content={currentPage - 1}
onClick={() => pageChangeHandler(currentPage - 1)}
/>
)}
{totalPages >= 7 &&
currentPage > 3 &&
currentPage < totalPages - 2 && (
<PaginationButton content={currentPage} disabled />
)}
{totalPages >= 5 &&
currentPage > 2 &&
currentPage < totalPages - 2 && (
<PaginationButton
content={currentPage + 1}
onClick={() => pageChangeHandler(currentPage + 1)}
/>
)}
{totalPages >= 5 &&
(currentPage <= 2 || currentPage >= totalPages - 2) && (
<PaginationButton
content={totalPages - 2}
disabled={currentPage === totalPages - 2}
onClick={() => pageChangeHandler(totalPages - 2)}
/>
)}
{totalPages >= 6 &&
currentPage > 2 &&
currentPage < totalPages - 3 && (
<EtcPaginationButton
startPage={
currentPage <= 3
? currentPage + 2
: currentPage >= 4
? currentPage + 2
: 1
}
endPage={
currentPage <= 3
? totalPages - 2
: currentPage >= 4
? totalPages - 1
: 0
}
onPageItemClick={pageChangeHandler}
/>
)}
{totalPages >= 6 &&
(currentPage <= 3 || currentPage >= totalPages - 3) && (
<PaginationButton
content={totalPages - 1}
disabled={currentPage === totalPages - 1}
onClick={() => pageChangeHandler(totalPages - 1)}
/>
)}
{totalPages >= 7 && (
<PaginationButton
content={totalPages}
disabled={currentPage === totalPages}
onClick={() => pageChangeHandler(totalPages)}
/>
)}
</>
)}
>
Next{' '}
<Icon
icon='uil:arrow-right'
width={20}
height={20}
className='text-gray-400 group-disabled:text-gray-300'
/>
</button>
<div className='hidden @md:block'>
<NextPageButton />
</div>
<div className='hidden @md:block'>
<GoToLastPageButton />
</div>
</div>
<div className='hidden @md:block'>
<PageInfo />
</div>
</div>
<div className='flex gap-2 mt-2 sm:hidden'>
<button
disabled={currentPage === 1}
onClick={onPrevPage}
className={cn(
'join-item btn btn-outline group px-3 py-2 text-sm font-semibold rounded-lg border border-gray-300 shadow-xs flex justify-center items-center gap-1.5',
'disabled:bg-[initial]! disabled:text-gray-400 disabled:pointer-events-auto! disabled:cursor-not-allowed disabled:active:translate-y-0'
)}
>
<Icon
icon='uil:arrow-left'
width={20}
height={20}
className='text-gray-400 group-disabled:text-gray-300'
/>{' '}
Previous
</button>
<div className='flex @md:hidden flex-col justify-center items-end gap-2'>
<div className='flex flex-row items-center gap-0.5'>
<GoToFirstPageButton />
<PrevPageButton />
<NextPageButton />
<GoToLastPageButton />
</div>
<button
disabled={currentPage === totalPages}
onClick={onNextPage}
className={cn(
'join-item btn btn-outline group px-3 py-2 text-sm font-semibold rounded-lg border border-gray-300 shadow-xs flex justify-center items-center gap-1.5',
'disabled:bg-[initial]! disabled:text-gray-400 disabled:pointer-events-auto! disabled:cursor-not-allowed disabled:active:translate-y-0'
)}
>
Next{' '}
<Icon
icon='uil:arrow-right'
width={20}
height={20}
className='text-gray-400 group-disabled:text-gray-300'
/>
</button>
<div className='flex flex-row items-center gap-4'>
<DisplayedRowCountSelect />
<PageInfo />
</div>
</div>
</div>
);
+159 -66
View File
@@ -13,6 +13,8 @@ import {
FilterFn,
SortingState,
OnChangeFn,
Row,
HeaderContext,
} from '@tanstack/react-table';
import { rankItem } from '@tanstack/match-sorter-utils';
import { Icon } from '@iconify/react';
@@ -30,6 +32,9 @@ interface TableClassNames {
tableBodyClassName?: string;
bodyRowClassName?: string;
bodyColumnClassName?: string;
tableFooterClassName?: string;
footerRowClassName?: string;
footerColumnClassName?: string;
paginationClassName?: string;
}
@@ -37,6 +42,7 @@ export interface TableProps<TData extends object> {
data: TData[];
columns: ColumnDef<TData, unknown>[];
pageSize?: number;
onPageSizeChange?: (pageSize: number) => void;
totalItems?: number;
page?: number;
onPageChange?: (page: number) => void;
@@ -50,6 +56,10 @@ export interface TableProps<TData extends object> {
manualSorting?: boolean;
rowSelection?: Record<string, boolean>;
setRowSelection?: OnChangeFn<Record<string, boolean>>;
enableRowSelection?: boolean | ((row: Row<TData>) => boolean);
renderFooter?: boolean;
withCheckbox?: boolean;
rowOptions?: number[];
}
const DUMMY_SKELETON_DATA = [{}, {}, {}, {}, {}];
@@ -62,40 +72,57 @@ const emptyContentDefaultValue = (
</div>
);
export const TABLE_DEFAULT_STYLING = {
containerClassName: 'w-full mb-20',
tableWrapperClassName:
'overflow-x-auto border border-solid border-base-content/10 rounded-lg',
tableClassName: 'font-inter w-full table-auto text-sm font-medium',
tableHeaderClassName: '',
headerRowClassName: '',
headerColumnClassName:
'px-4 py-3 border-base-content/10 text-base-content/50',
tableBodyClassName: '',
bodyRowClassName: 'border-t border-base-content/10',
bodyColumnClassName: 'px-4 py-3 text-base-content',
paginationClassName: '',
tableFooterClassName: 'font-semibold border-base-content/10',
footerRowClassName: 'bg-base-200 border-t-2 border-base-content/10',
footerColumnClassName: 'p-4 text-base-content whitespace-nowrap',
};
const Table = <TData extends object>({
data = [],
columns = [],
pageSize = 10,
onPageSizeChange,
totalItems,
page,
onPageChange,
isLoading = false,
fuzzySearchValue,
onFuzzySearchValueChange,
className = {
containerClassName: '',
tableWrapperClassName: '',
tableClassName: '',
tableHeaderClassName: '',
headerRowClassName: '',
headerColumnClassName: '',
tableBodyClassName: '',
bodyRowClassName: '',
bodyColumnClassName: '',
paginationClassName: '',
},
className = TABLE_DEFAULT_STYLING,
emptyContent = emptyContentDefaultValue,
sorting,
setSorting,
manualSorting = false,
rowSelection,
setRowSelection,
enableRowSelection,
renderFooter = false,
withCheckbox = false,
rowOptions = [10, 20, 50, 100],
}: TableProps<TData>) => {
const isServerSideTable =
totalItems !== undefined &&
page !== undefined &&
onPageChange !== undefined;
const tableClassNames = {
...TABLE_DEFAULT_STYLING,
...className,
};
const [pagination, setPagination] = useState({
pageIndex: 0,
pageSize: pageSize,
@@ -150,6 +177,10 @@ const Table = <TData extends object>({
tableOptions.getRowId = (row) => (row as { id: string }).id;
}
if (enableRowSelection !== undefined) {
tableOptions.enableRowSelection = enableRowSelection;
}
const table = useReactTable(tableOptions);
const { setPageSize } = table;
@@ -184,68 +215,106 @@ const Table = <TData extends object>({
}, [pageSize, setPageSize]);
return (
<div className={className.containerClassName}>
<div className={className.tableWrapperClassName}>
<table className={className.tableClassName}>
<thead className={className.tableHeaderClassName}>
<div className={tableClassNames.containerClassName}>
<div className={tableClassNames.tableWrapperClassName}>
<table className={tableClassNames.tableClassName}>
<thead className={tableClassNames.tableHeaderClassName}>
{table.getHeaderGroups().map((headerGroup) => (
<tr key={headerGroup.id} className={className.headerRowClassName}>
{headerGroup.headers.map((header) => (
<th
key={header.id}
colSpan={header.colSpan}
onClick={header.column.getToggleSortingHandler()}
className={cn(
header.column.getCanSort()
? 'cursor-pointer select-none'
: '',
className.headerColumnClassName
)}
>
<div className='flex items-center gap-1'>
{flexRender(
header.column.columnDef.header,
header.getContext()
<tr
key={headerGroup.id}
className={tableClassNames.headerRowClassName}
>
{headerGroup.headers.map((header) => {
const columnRelativeDepth =
header.depth - header.column.depth;
if (
!header.isPlaceholder &&
columnRelativeDepth > 1 &&
header.id === header.column.id
) {
return null;
}
let rowSpan = 1;
if (header.isPlaceholder) {
const leafs = header.getLeafHeaders();
rowSpan = leafs[leafs.length - 1].depth - header.depth;
}
return (
<th
key={header.id}
colSpan={header.colSpan}
rowSpan={rowSpan}
onClick={header.column.getToggleSortingHandler()}
className={cn(
header.column.getCanSort()
? 'cursor-pointer select-none'
: '',
{
'first:w-9 first:pr-0': withCheckbox,
},
{
'border-b': header.colSpan > 1,
},
tableClassNames.headerColumnClassName
)}
>
<div
className={cn('flex items-center gap-1 min-h-full', {
'justify-center': header.colSpan > 1,
})}
>
{flexRender(
header.column.columnDef.header,
header.getContext()
)}
{header.column.getCanSort() && (
<div className='flex items-center'>
<Icon
icon='lucide:arrow-up'
width={12}
height={12}
className={cn(
'transition-all ease-in-out duration-200',
header.column.getIsSorted() === 'asc'
? 'text-black'
: 'text-black/30'
)}
/>
<Icon
icon='lucide:arrow-down'
width={12}
height={12}
className={cn(
'transition-all ease-in-out duration-200',
header.column.getIsSorted() === 'desc'
? 'text-black'
: 'text-black/30'
)}
/>
</div>
)}
</div>
</th>
))}
{header.column.getCanSort() && (
<div className='w-4 h-4 relative flex flex-col items-center'>
<Icon
icon='heroicons:chevron-up-16-solid'
width={18}
height={18}
className={cn(
'absolute -top-1',
'transition-all ease-in-out duration-200',
header.column.getIsSorted() === 'asc'
? 'text-black'
: 'text-black/30'
)}
/>
<Icon
icon='heroicons:chevron-down-16-solid'
width={18}
height={18}
className={cn(
'absolute -bottom-1.5',
'transition-all ease-in-out duration-200',
header.column.getIsSorted() === 'desc'
? 'text-black'
: 'text-black/30'
)}
/>
</div>
)}
</div>
</th>
);
})}
</tr>
))}
</thead>
<tbody className={className.tableBodyClassName}>
<tbody className={tableClassNames.tableBodyClassName}>
{table.getRowModel().rows.map((row) => (
<tr key={row.id} className={className.bodyRowClassName}>
<tr key={row.id} className={tableClassNames.bodyRowClassName}>
{row.getVisibleCells().map((cell) => (
<td key={cell.id} className={className.bodyColumnClassName}>
<td
key={cell.id}
className={cn(
{ 'first:w-9 first:pr-0': withCheckbox },
tableClassNames.bodyColumnClassName
)}
>
{!isLoading &&
flexRender(cell.column.columnDef.cell, cell.getContext())}
@@ -255,6 +324,28 @@ const Table = <TData extends object>({
</tr>
))}
</tbody>
<tfoot className={cn(tableClassNames.tableFooterClassName)}>
{renderFooter && (
<tr className={cn(tableClassNames.footerRowClassName)}>
{table.getAllLeafColumns().map((column) => (
<td
key={column.id}
className={cn(
{ 'first:w-9 first:pr-0': withCheckbox },
tableClassNames.footerColumnClassName
)}
>
{column.columnDef.footer &&
flexRender(column.columnDef.footer, {
column,
header: column.columnDef,
table,
} as HeaderContext<TData, unknown>)}
</td>
))}
</tr>
)}
</tfoot>
</table>
</div>
@@ -263,7 +354,7 @@ const Table = <TData extends object>({
emptyContent}
{data.length > 0 && table.getRowModel().rows.length > 0 && !isLoading && (
<div className={cn('mt-5', className.paginationClassName)}>
<div className={cn('mt-5', tableClassNames.paginationClassName)}>
<Pagination
totalItems={isServerSideTable ? totalItems : table.getRowCount()}
itemsPerPage={table.getState().pagination.pageSize}
@@ -275,6 +366,8 @@ const Table = <TData extends object>({
onPrevPage={prevPageClickHandler}
onNextPage={nextPageClickHandler}
onPageChange={pageChangeHandler}
rowOptions={rowOptions}
onRowChange={onPageSizeChange}
/>
</div>
)}
+129
View File
@@ -0,0 +1,129 @@
import { HTMLAttributes, ReactNode, useEffect, useState } from 'react';
import { cn } from '@/lib/helper';
export interface TabItem {
id: string;
label: ReactNode;
content?: ReactNode;
disabled?: boolean;
}
export interface TabsProps
extends Omit<HTMLAttributes<HTMLDivElement>, 'className'> {
tabs: TabItem[];
variant?: 'bordered' | 'lifted' | 'boxed';
size?: 'xs' | 'sm' | 'md' | 'lg' | 'xl';
placement?: 'top' | 'bottom';
/** Tab yang aktif secara default (uncontrolled mode) */
defaultActiveId?: string;
/** Tab yang aktif (controlled mode, dikontrol parent) */
activeTabId?: string;
className?:
| string
| {
wrapper?: string;
tab?: string;
content?: string;
};
onTabChange?: (tabId: string) => void;
}
const Tabs = ({
tabs,
variant,
size = 'md',
placement = 'top',
defaultActiveId,
activeTabId: controlledActiveId,
className,
onTabChange,
...props
}: TabsProps) => {
// State internal hanya dipakai kalau `activeTabId` (controlled) tidak diset
const [uncontrolledActiveId, setUncontrolledActiveId] = useState(
defaultActiveId || tabs[0]?.id || ''
);
const isControlled = controlledActiveId !== undefined;
const activeTabId = isControlled ? controlledActiveId : uncontrolledActiveId;
const handleTabChange = (tabId: string) => {
if (tabId === activeTabId) return;
if (!isControlled) setUncontrolledActiveId(tabId);
onTabChange?.(tabId);
};
const { wrapper: wrapperClassName, tab: tabClassName } =
typeof className === 'object'
? className
: { wrapper: className, tab: undefined };
const getTabsClasses = () => {
const variantClasses: Record<string, string> = {
bordered: 'tabs-bordered',
lifted: 'tabs-lift',
boxed: 'tabs-box',
};
const sizeClasses: Record<string, string> = {
xs: 'tabs-xs',
sm: 'tabs-sm',
md: '',
lg: 'tabs-lg',
xl: 'tabs-xl',
};
const placementClasses: Record<string, string> = {
top: '',
bottom: 'tabs-bottom',
};
return cn(
'tabs',
variant && variantClasses[variant],
sizeClasses[size],
placementClasses[placement],
wrapperClassName
);
};
const getTabClasses = (isActive: boolean, isDisabled?: boolean) =>
cn(
'tab',
{
'tab-active': isActive,
'tab-disabled': isDisabled,
},
tabClassName
);
const activeContent = tabs.find((tab) => tab.id === activeTabId)?.content;
return (
<div
{...props}
className={cn(
'w-full',
typeof className === 'string' ? className : undefined
)}
>
<div role='tablist' className={getTabsClasses()}>
{tabs.map(({ id, label, disabled }) => (
<button
key={id}
role='tab'
className={getTabClasses(id === activeTabId, disabled)}
onClick={() => !disabled && handleTabChange(id)}
disabled={disabled}
>
{label}
</button>
))}
</div>
{activeContent && <div className='mt-4'>{activeContent}</div>}
</div>
);
};
export default Tabs;
+116
View File
@@ -0,0 +1,116 @@
'use client';
import { ReactNode, useRef, useEffect, useState } from 'react';
import { cn } from '@/lib/helper';
interface DropdownProps {
trigger: ReactNode;
children: ReactNode;
position?:
| 'top'
| 'bottom'
| 'left'
| 'right'
| 'top-start'
| 'top-end'
| 'bottom-start'
| 'bottom-end'
| 'left-start'
| 'left-end'
| 'right-start'
| 'right-end';
align?: 'start' | 'center' | 'end';
hover?: boolean;
className?: string;
contentClassName?: string;
}
const Dropdown = ({
trigger,
children,
position = 'bottom',
align = 'start',
hover = false,
className,
contentClassName,
}: DropdownProps) => {
const [isOpen, setIsOpen] = useState(false);
const dropdownRef = useRef<HTMLDivElement>(null);
// Handle click outside to close dropdown
useEffect(() => {
const handleClickOutside = (event: MouseEvent) => {
if (
dropdownRef.current &&
!dropdownRef.current.contains(event.target as Node)
) {
setIsOpen(false);
}
};
if (isOpen) {
document.addEventListener('mousedown', handleClickOutside);
}
return () => {
document.removeEventListener('mousedown', handleClickOutside);
};
}, [isOpen]);
// Build position classes
const getPositionClasses = () => {
const classes: string[] = [];
// Handle combined positions like 'top-start'
if (position.includes('-')) {
const [pos, al] = position.split('-');
classes.push(`dropdown-${pos}`);
classes.push(`dropdown-${al}`);
} else {
classes.push(`dropdown-${position}`);
if (align !== 'start') {
classes.push(`dropdown-${align}`);
}
}
return classes.join(' ');
};
const handleToggle = (e: React.MouseEvent) => {
e.preventDefault();
e.stopPropagation();
// alert('clicked');
setIsOpen(!isOpen);
};
return (
<div
ref={dropdownRef}
className={cn(
'dropdown',
getPositionClasses(),
hover && 'dropdown-hover',
isOpen && 'dropdown-open',
className
)}
>
{/* Trigger Button */}
<div onClick={handleToggle} className='cursor-pointer'>
{trigger}
</div>
{/* Dropdown Content - Only render when open */}
{isOpen && (
<div
tabIndex={-1}
className={cn('dropdown-content z-[10]', contentClassName)}
onClick={() => setIsOpen(false)} // Close on item click
>
{children}
</div>
)}
</div>
);
};
export default Dropdown;
+64 -174
View File
@@ -1,197 +1,87 @@
'use client';
import { ReactNode, useEffect } from 'react';
import { useRouter } from 'next/navigation';
import useSWRImmutable from 'swr/immutable';
import useSWR from 'swr';
import { useAuth } from '@/services/hooks/useAuth';
import { httpClientFetcher, SWRHttpKey } from '@/services/http/client';
import { isResponseSuccess } from '@/lib/api-helper';
import { GetMeResponse } from '@/types/api/api-general';
// TODO: delete this later, DONT HARDCODE USER DATA
const DUMMY_USER = {
id: 1,
email: 'admin@mbugroup.id',
npk: '0001',
name: 'Super Admin',
image: null,
created_at: '2025-09-30T03:24:20.899229Z',
updated_at: '2025-09-30T03:24:20.899229Z',
roles: [
{
id: 1,
key: 'mbu.super_admin',
name: 'MBU Administrator',
client: {
id: 1,
name: 'PT Mitra Berlian Unggas',
alias: 'MBU',
},
permissions: [
{
id: 1,
name: 'mbu:purchase:read',
action: 'read',
client: {
id: 1,
name: 'PT Mitra Berlian Unggas',
alias: 'MBU',
},
},
{
id: 2,
name: 'mbu:purchase:create',
action: 'create',
client: {
id: 1,
name: 'PT Mitra Berlian Unggas',
alias: 'MBU',
},
},
{
id: 3,
name: 'mbu:purchase:approve',
action: 'approve',
client: {
id: 1,
name: 'PT Mitra Berlian Unggas',
alias: 'MBU',
},
},
],
},
{
id: 2,
key: 'lti.super_admin',
name: 'LTI Administrator',
client: {
id: 2,
name: 'PT Lumbung Telur Indonesia',
alias: 'LTI',
},
permissions: [
{
id: 4,
name: 'lti:purchase:read',
action: 'read',
client: {
id: 2,
name: 'PT Lumbung Telur Indonesia',
alias: 'LTI',
},
},
{
id: 5,
name: 'lti:purchase:create',
action: 'create',
client: {
id: 2,
name: 'PT Lumbung Telur Indonesia',
alias: 'LTI',
},
},
{
id: 6,
name: 'lti:purchase:approve',
action: 'approve',
client: {
id: 2,
name: 'PT Lumbung Telur Indonesia',
alias: 'LTI',
},
},
],
},
{
id: 3,
key: 'manbu.super_admin',
name: 'MANBU Administrator',
client: {
id: 3,
name: 'PT Mandiri Berlian Unggas',
alias: 'MANBU',
},
permissions: [
{
id: 7,
name: 'manbu:purchase:read',
action: 'read',
client: {
id: 3,
name: 'PT Mandiri Berlian Unggas',
alias: 'MANBU',
},
},
{
id: 8,
name: 'manbu:purchase:create',
action: 'create',
client: {
id: 3,
name: 'PT Mandiri Berlian Unggas',
alias: 'MANBU',
},
},
{
id: 9,
name: 'manbu:purchase:approve',
action: 'approve',
client: {
id: 3,
name: 'PT Mandiri Berlian Unggas',
alias: 'MANBU',
},
},
],
},
],
};
import { isResponseError, isResponseSuccess } from '@/lib/api-helper';
import { BaseApiResponse, GetMeResponse } from '@/types/api/api-general';
import { AxiosError } from 'axios';
import { redirectToSSO } from '@/lib/auth-helper';
interface RequireAuthProps {
children?: ReactNode;
}
const RequireAuth = ({ children }: RequireAuthProps) => {
const router = useRouter();
const { setUser, setIsLoadingUser } = useAuth();
const { user, setUser, setIsLoadingUser } = useAuth();
const { data: userResponse, isLoading: isLoadingUserResponse } =
useSWRImmutable<GetMeResponse & { ok?: boolean }, unknown, SWRHttpKey>(
'/auth/sso/userinfo',
httpClientFetcher,
{
shouldRetryOnError: false,
revalidateOnFocus: false,
revalidateOnReconnect: false,
refreshInterval: 0,
}
);
useEffect(() => {
setIsLoadingUser(isLoadingUserResponse);
}, [isLoadingUserResponse, setIsLoadingUser]);
const {
data: userResponse,
isLoading: isLoadingUserResponse,
error: userErrorResponse,
} = useSWR<
GetMeResponse & { ok?: boolean },
AxiosError<BaseApiResponse>,
SWRHttpKey
>('/sso/userinfo', httpClientFetcher, {
shouldRetryOnError: false,
});
useEffect(() => {
if (isResponseSuccess(userResponse)) {
setUser(userResponse.data);
} else {
// router.replace(process.env.NEXT_PUBLIC_SSO_LOGIN_URL as string);
// TODO: remove this later, DONT HARDCODE USER DATA
setUser(DUMMY_USER);
}
}, [userResponse, setIsLoadingUser, setUser]);
}, [userResponse, setUser]);
// TODO: uncomment this later
// if (isLoadingUserResponse && !userResponse) {
// return (
// <div className='w-full flex flex-row justify-center items-center p-4'>
// <span className='loading loading-spinner loading-xl' />
// </div>
// );
// }
// Explicitly handle 401 redirect from the component level
useEffect(() => {
if (
isResponseError(userResponse) &&
userErrorResponse?.response?.status === 401
) {
// Clear cache to prevent stale data from rendering children
// mutate('/sso/userinfo', undefined, { revalidate: false }); // Optional: if using global mutate
setUser(undefined);
redirectToSSO();
}
}, [userErrorResponse, setUser, userResponse]);
return <>{children}</>;
useEffect(() => {
setIsLoadingUser(isLoadingUserResponse);
}, [isLoadingUserResponse]);
if (
(isLoadingUserResponse && !userResponse && !userErrorResponse) ||
(!userResponse && !userErrorResponse)
) {
return (
<div className='w-full flex flex-row justify-center items-center p-4'>
<span className='loading loading-spinner loading-xl' />
</div>
);
}
if (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>
<p className='text-gray-600'>
Please try refreshing the page or contact support if the problem
persists.
</p>
<button
className='btn btn-primary'
onClick={() => window.location.reload()}
>
Retry
</button>
</div>
);
}
return <>{isResponseSuccess(userResponse) && user && children}</>;
};
export default RequireAuth;
@@ -0,0 +1,104 @@
'use client';
import { Icon } from '@iconify/react';
import Link from 'next/link';
import { ReactNode } from 'react';
import { cn } from '@/lib/helper';
export interface DrawerHeaderProps {
// Left side props
leftIcon?: string;
leftIconSize?: number;
leftIconHref?: string;
leftIconOnClick?: () => void;
leftIconClassName?: string;
// Subtitle/label props
subtitle?: string | ReactNode;
subtitleClassName?: string;
// Right side actions (children)
children?: ReactNode;
// Container props
className?: string;
showDivider?: boolean;
}
const DrawerHeader = ({
leftIcon = 'mdi:close',
leftIconSize = 24,
leftIconHref,
leftIconOnClick,
leftIconClassName,
subtitle,
subtitleClassName,
children,
className,
showDivider = true,
}: DrawerHeaderProps) => {
const renderLeftIcon = () => {
const iconElement = (
<Icon
icon={leftIcon}
width={leftIconSize}
height={leftIconSize}
className={cn('cursor-pointer', leftIconClassName)}
/>
);
if (leftIconHref) {
return (
<Link href={leftIconHref} className='hover:text-gray-400'>
{iconElement}
</Link>
);
}
if (leftIconOnClick) {
return (
<button
onClick={leftIconOnClick}
className='hover:text-gray-400 bg-transparent border-none p-0'
>
{iconElement}
</button>
);
}
return iconElement;
};
return (
<div
className={cn(
'flex flex-row justify-between items-center px-4 pt-4',
className
)}
>
{/* Left Side */}
<div className='flex flex-row h-full gap-2 items-center'>
{renderLeftIcon()}
{showDivider && subtitle && (
<div className='divider divider-horizontal p-0 m-0'></div>
)}
{subtitle && (
<div className={cn('text-sm text-neutral', subtitleClassName)}>
{subtitle}
</div>
)}
</div>
{/* Right Side Actions */}
{children && (
<div className='flex flex-row gap-3 justify-end items-center'>
{children}
</div>
)}
</div>
);
};
export default DrawerHeader;
+67 -15
View File
@@ -9,6 +9,11 @@ interface FormActionsProps<T> {
editUrl?: string;
onDelete?: () => void;
disableSubmit?: boolean;
onApprove?: () => void;
onReject?: () => void;
isApproveLoading?: boolean;
isRejectLoading?: boolean;
showApproveReject?: boolean;
}
export const FormActions = <T,>({
@@ -17,25 +22,32 @@ export const FormActions = <T,>({
editUrl,
onDelete,
disableSubmit = false,
onApprove,
onReject,
isApproveLoading = false,
isRejectLoading = false,
showApproveReject = false,
}: FormActionsProps<T>) => {
return (
<div className='flex flex-row justify-between gap-2 flex-wrap'>
{type !== 'add' && onDelete && (
{type !== 'add' && (
<div className='flex flex-row justify-start gap-2'>
<Button
type='button'
color='error'
onClick={onDelete}
className='px-4'
>
<Icon
icon='material-symbols:delete-outline-rounded'
width={24}
height={24}
className='justify-start text-sm'
/>
Delete
</Button>
{onDelete && (
<Button
type='button'
color='error'
onClick={onDelete}
className='px-4'
>
<Icon
icon='material-symbols:delete-outline-rounded'
width={24}
height={24}
className='justify-start text-sm'
/>
Delete
</Button>
)}
{type !== 'edit' && editUrl && (
<Button
type='button'
@@ -52,6 +64,46 @@ export const FormActions = <T,>({
Edit
</Button>
)}
{type === 'detail' &&
showApproveReject &&
(onApprove || onReject) && (
<>
{onApprove && (
<Button
type='button'
color='success'
onClick={onApprove}
className='px-4'
isLoading={isApproveLoading}
>
<Icon
icon='material-symbols:check-circle-outline'
width={24}
height={24}
className='justify-start text-sm'
/>
Approve
</Button>
)}
{onReject && (
<Button
type='button'
color='error'
onClick={onReject}
className='px-4'
isLoading={isRejectLoading}
>
<Icon
icon='material-symbols:cancel-outline'
width={24}
height={24}
className='justify-start text-sm'
/>
Reject
</Button>
)}
</>
)}
</div>
)}
{type !== 'detail' && (
+17 -4
View File
@@ -2,15 +2,27 @@ import Button from '@/components/Button';
import { Icon } from '@iconify/react';
interface FormHeaderProps {
type: 'add' | 'edit' | 'detail';
type?: 'add' | 'edit' | 'detail';
title: string;
backUrl: string;
backUrl?: string;
onBackClick?: () => void;
}
export const FormHeader = ({ type, title, backUrl }: FormHeaderProps) => {
export const FormHeader = ({
type,
title,
backUrl,
onBackClick,
}: FormHeaderProps) => {
return (
<header className='flex flex-col gap-4'>
<Button href={backUrl} variant='link' className='w-fit p-0 text-primary'>
<Button
type='button'
href={!onBackClick ? backUrl : undefined}
onClick={onBackClick}
variant='link'
className='w-fit p-0 text-primary'
>
<Icon icon='uil:arrow-left' width={24} height={24} />
Kembali
</Button>
@@ -18,6 +30,7 @@ export const FormHeader = ({ type, title, backUrl }: FormHeaderProps) => {
{type === 'add' && `Tambah ${title}`}
{type === 'edit' && `Edit ${title}`}
{type === 'detail' && `Detail ${title}`}
{!type && title}
</h1>
</header>
);
+13 -2
View File
@@ -2,8 +2,9 @@
import { HTMLProps, useEffect, useRef } from 'react';
import { cn } from '@/lib/helper';
import { Size } from '@/types/theme';
interface CheckboxInputProps extends HTMLProps<HTMLInputElement> {
interface CheckboxInputProps extends Omit<HTMLProps<HTMLInputElement>, 'size'> {
name: string;
label?: string;
indeterminate?: boolean;
@@ -16,6 +17,7 @@ interface CheckboxInputProps extends HTMLProps<HTMLInputElement> {
isError?: boolean;
isValid?: boolean;
errorMessage?: string;
size?: Size;
}
const CheckboxInput = ({
@@ -27,10 +29,19 @@ const CheckboxInput = ({
isValid,
isError,
errorMessage,
size = 'sm',
...rest
}: CheckboxInputProps) => {
const ref = useRef<HTMLInputElement>(null!);
const checkboxBaseClassName = cn('checkbox cursor-pointer rounded-md', {
'checkbox-xs': size === 'xs',
'checkbox-sm': size === 'sm',
'checkbox-md': size === 'md',
'checkbox-lg': size === 'lg',
'checkbox-xl': size === 'xl',
});
useEffect(() => {
if (typeof indeterminate === 'boolean') {
ref.current.indeterminate = !rest.checked && indeterminate;
@@ -53,7 +64,7 @@ const CheckboxInput = ({
id={name}
name={name}
className={cn(
'checkbox cursor-pointer',
checkboxBaseClassName,
{
'border-error': isError,
'border-success': isValid,
+246 -40
View File
@@ -1,14 +1,23 @@
'use client';
import { ChangeEventHandler, FocusEventHandler, ReactNode } from 'react';
import { cn } from '@/lib/helper';
import {
ChangeEventHandler,
FocusEventHandler,
useEffect,
useState,
} from 'react';
import { cn, formatDate } from '@/lib/helper';
import { DateRange, DayPicker, Matcher } from 'react-day-picker';
import 'react-day-picker/dist/style.css';
import { Icon } from '@iconify/react';
import Modal, { useModal } from '@/components/Modal';
import Button from '@/components/Button';
export interface DateInputProps {
label?: string;
bottomLabel?: string;
name: string;
value?: string;
value?: string | { from?: string; to?: string };
placeholder?: string;
min?: string;
max?: string;
@@ -24,9 +33,9 @@ export interface DateInputProps {
readOnly?: boolean;
required?: boolean;
isLoading?: boolean;
isRange?: boolean;
isNestedModal?: boolean; // New prop to indicate if used inside another modal
errorMessage?: string;
startAdornment?: ReactNode;
endAdornment?: ReactNode;
onChange?: ChangeEventHandler<HTMLInputElement>;
onBlur?: FocusEventHandler<HTMLInputElement>;
}
@@ -36,22 +45,148 @@ const DateInput = ({
bottomLabel,
name,
value,
placeholder,
placeholder = 'dd/mm/yyyy',
min,
max,
className,
isError,
isValid,
errorMessage,
startAdornment,
endAdornment,
isError: externalError,
isValid: externalValid,
errorMessage: externalErrorMessage,
disabled = false,
required = false,
onChange,
onBlur,
readOnly = false,
isLoading = false,
isRange = false,
isNestedModal = false,
}: DateInputProps) => {
const [internalError, setInternalError] = useState<string | null>(null);
const [selected, setSelected] = useState<Date | undefined>();
const [selectedRange, setSelectedRange] = useState<{
from?: Date;
to?: Date;
}>({});
const [displayValue, setDisplayValue] = useState<string>('');
const minDate = min
? new Date(min.split('/').reverse().join('-'))
: undefined;
const maxDate = max
? new Date(max.split('/').reverse().join('-'))
: undefined;
const calendarModal = useModal(isNestedModal);
// --- Sync value props ---
useEffect(() => {
if (!value) {
setDisplayValue('');
return;
}
if (isRange && typeof value === 'object') {
const from = value.from ? new Date(value.from) : undefined;
const to = value.to ? new Date(value.to) : undefined;
setSelectedRange({ from, to });
setDisplayValue(
`${from ? formatDate(from, 'DD/MM/YYYY') : ''} ${
to ? '- ' + formatDate(to, 'DD/MM/YYYY') : ''
}`
);
} else if (typeof value === 'string') {
const iso = value.includes('/')
? value.split('/').reverse().join('-')
: value;
const date = new Date(iso);
setSelected(date);
setDisplayValue(formatDate(iso, 'DD/MM/YYYY'));
}
}, [value, isRange]);
const handleClick = (e: React.MouseEvent<HTMLInputElement>) => {
e.preventDefault();
if (!disabled && !readOnly) calendarModal.openModal();
};
const handleBlur: FocusEventHandler<HTMLInputElement> = (e) => {
onBlur?.(e);
};
const handleSelectSingle = (selectedDate?: Date) => {
if (!selectedDate) return;
if (minDate && selectedDate < minDate) {
setInternalError(`Tanggal tidak boleh sebelum ${min}`);
return;
}
if (maxDate && selectedDate > maxDate) {
setInternalError(`Tanggal tidak boleh setelah ${max}`);
return;
}
setInternalError(null);
setSelected(selectedDate);
const formattedDisplay = formatDate(selectedDate, 'DD/MM/YYYY');
const formattedISO = formatDate(selectedDate, 'YYYY-MM-DD');
setDisplayValue(formattedDisplay);
const syntheticEvent = {
target: { name, value: formattedISO },
} as unknown as React.ChangeEvent<HTMLInputElement>;
onChange?.(syntheticEvent);
calendarModal.closeModal();
};
const handleSelectRange = (range?: { from?: Date; to?: Date }) => {
if (!range) return;
setSelectedRange(range);
const fromStr = range.from ? formatDate(range.from, 'DD/MM/YYYY') : '';
const toStr = range.to ? formatDate(range.to, 'DD/MM/YYYY') : '';
setDisplayValue(`${fromStr}${toStr ? ' - ' + toStr : ''}`);
// Jika kedua tanggal sudah terpilih
if (range.from && range.to) {
if (minDate && range.from < minDate) {
setInternalError(`Tanggal mulai tidak boleh sebelum ${min}`);
return;
}
if (maxDate && range.to > maxDate) {
setInternalError(`Tanggal akhir tidak boleh setelah ${max}`);
return;
}
setInternalError(null);
const syntheticEvent = {
target: {
name,
value: {
from: formatDate(range.from, 'YYYY-MM-DD'),
to: formatDate(range.to, 'YYYY-MM-DD'),
},
},
} as unknown as React.ChangeEvent<HTMLInputElement>;
onChange?.(syntheticEvent);
}
};
const handleResetDate = () => {
setSelected(undefined);
setSelectedRange({});
setDisplayValue('');
const syntheticEvent = {
target: { name, value: isRange ? { from: '', to: '' } : '' },
} as unknown as React.ChangeEvent<HTMLInputElement>;
onChange?.(syntheticEvent);
calendarModal.closeModal();
};
const handleSaveDate = () => {
if (internalError) return;
calendarModal.closeModal();
};
const finalIsError = externalError || !!internalError;
const finalErrorMessage = internalError || externalErrorMessage;
return (
<div
className={cn(
@@ -64,65 +199,136 @@ const DateInput = ({
htmlFor={name}
className={cn(
'w-full text-sm font-normal leading-5',
{
'text-error': isError,
},
{ 'text-error': finalIsError },
className?.label
)}
>
{label}
{required && (
<>
<span className='text-error' title='required'>
{' '}
<span className='tooltip tooltip-error' data-tip='required'>
<span className='text-error'>*</span>
</span>
</>
*
</span>
)}
</label>
)}
<div
className={cn(
'input h-12 px-4 py-2 text-base font-normal leading-6 w-full rounded outline-none! transition-all duration-200 flex items-center',
'input h-12 bg-inherit px-4 py-2 text-base font-normal leading-6 w-full rounded transition-all duration-200 flex items-center border',
{
'border-error': isError,
'border-success!': isValid,
'border-error': finalIsError,
'border-success': externalValid && !finalIsError,
},
className?.inputWrapper
)}
>
{startAdornment && startAdornment}
<input
type='date'
type='text'
id={name}
name={name}
placeholder={placeholder}
value={value}
onChange={onChange}
onBlur={onBlur}
min={min}
max={max}
placeholder={isRange ? 'dd/mm/yyyy - dd/mm/yyyy' : placeholder}
value={displayValue}
onBlur={handleBlur}
onClick={handleClick}
disabled={disabled}
className={cn('grow bg-transparent cursor-pointer', className?.input)}
readOnly={readOnly}
readOnly // ✅ tidak bisa diketik manual
className={cn(
'grow bg-transparent cursor-pointer focus:outline-none',
className?.input
)}
/>
{(isLoading || endAdornment) && (
{isLoading && (
<div className='flex flex-row gap-2'>
{isLoading && <span className='loading loading-spinner' />}
{endAdornment && endAdornment}
<span className='loading loading-spinner' />
</div>
)}
<Icon
icon='uil:calendar'
width={24}
height={24}
className='cursor-pointer text-dark'
onClick={(e) =>
handleClick(e as unknown as React.MouseEvent<HTMLInputElement>)
}
/>
</div>
{!isError && bottomLabel && (
{!finalIsError && bottomLabel && (
<p className='w-full text-sm opacity-60'>{bottomLabel}</p>
)}
{isError && errorMessage && (
<p className='w-full text-sm text-error'>{errorMessage}</p>
{finalIsError && finalErrorMessage && (
<p className='w-full text-sm text-error'>{finalErrorMessage}</p>
)}
<Modal
ref={calendarModal.ref}
className={{
modal: 'rounded',
modalBox: `!max-w-max min-h-${isRange ? '124' : '110'} flex flex-col`,
}}
closeOnBackdrop
>
{isRange ? (
<DayPicker
required={required}
mode='range'
captionLayout='dropdown-years'
navLayout='around'
reverseYears
defaultMonth={selectedRange.from ?? new Date()}
startMonth={minDate ?? new Date(1999, 1)}
endMonth={maxDate ?? new Date(new Date().getFullYear() + 5, 11)}
selected={selectedRange as DateRange}
onSelect={handleSelectRange}
footer={<div className='text-center mt-3'>{displayValue}</div>}
disabled={
[
minDate ? { before: minDate } : undefined,
maxDate ? { after: maxDate } : undefined,
].filter(Boolean) as Matcher[]
}
/>
) : (
<DayPicker
required={required}
mode='single'
captionLayout='dropdown-years'
navLayout='around'
reverseYears
defaultMonth={selected ?? new Date()}
startMonth={minDate ?? new Date(1999, 1)}
endMonth={maxDate ?? new Date(new Date().getFullYear() + 5, 11)}
selected={selected}
onSelect={handleSelectSingle}
disabled={
[
minDate ? { before: minDate } : undefined,
maxDate ? { after: maxDate } : undefined,
].filter(Boolean) as Matcher[]
}
/>
)}
<div className='mt-auto flex flex-col gap-2'>
{isRange && (
<small className='text-secondary'>
Tekan dua kali untuk memilih tanggal awal
</small>
)}
<div className='flex h-full justify-end items-end gap-2'>
<Button type='button' color='warning' onClick={handleResetDate}>
Reset
</Button>
{isRange && (
<Button type='button' onClick={handleSaveDate}>
Simpan
</Button>
)}
</div>
</div>
</Modal>
</div>
);
};
@@ -0,0 +1,44 @@
'use client';
import { ChangeEvent, ChangeEventHandler, useEffect, useState } from 'react';
import { useDebounce } from 'use-debounce';
import TextArea, { TextAreaProps } from '@/components/input/TextArea';
interface DebouncedTextAreaProps extends TextAreaProps {
delay?: number;
}
const DebouncedTextArea = (props: DebouncedTextAreaProps) => {
const { delay, onChange } = props;
const [internalChangeEvent, setInternalChangeEvent] =
useState<ChangeEvent<HTMLTextAreaElement>>();
const [internalValue, setInternalValue] = useState(props.value);
const [debouncedChangeEvent] = useDebounce(internalChangeEvent, delay ?? 300);
const [debouncedValue] = useDebounce(internalValue, delay ?? 300);
const internalChangeHandler: ChangeEventHandler<HTMLTextAreaElement> = (
e
) => {
setInternalValue(e.target.value);
setInternalChangeEvent(e);
};
useEffect(() => {
if (debouncedChangeEvent) {
onChange?.(debouncedChangeEvent);
}
}, [debouncedValue]);
return (
<TextArea
{...props}
value={internalValue}
onChange={internalChangeHandler}
/>
);
};
export default DebouncedTextArea;
+194
View File
@@ -0,0 +1,194 @@
import { useEffect } from 'react';
import { useDropzone, type Accept } from 'react-dropzone';
import { Icon } from '@iconify/react';
import Button from '@/components/Button';
import { cn } from '@/lib/helper';
interface DropFileInputProps {
name: string;
label?: string;
bottomLabel?: string;
caption?: string;
values?: File[];
accept?: Accept;
required?: boolean;
maxFiles?: number; // defaults to 1
maxSize?: number; // defaults to 2097152 (2 MB)
isError?: boolean;
errorMessage?: string;
disabled?: boolean;
onChange?: (files: File[]) => void;
onDelete?: (index: number) => void;
className?: {
wrapper?: string;
inputContainer?: string;
label?: string;
inputWrapper?: string;
caption?: string;
bottomLabel?: string;
errorMessage?: string;
fileItemContainer?: string;
};
}
const DropFileInput: React.FC<DropFileInputProps> = ({
name,
label,
bottomLabel,
caption = 'Seret atau Pilih Dokumen',
values,
accept,
required,
maxFiles = Infinity,
maxSize,
isError,
errorMessage,
disabled,
onChange,
onDelete,
className,
}) => {
const isDisabled =
Boolean(values && maxFiles && values.length >= maxFiles) || disabled;
const {
acceptedFiles,
getRootProps,
getInputProps,
isFocused,
isDragAccept,
isDragReject,
} = useDropzone({
maxSize,
maxFiles,
accept: accept,
disabled: isDisabled,
});
useEffect(() => {
if (values && maxFiles && values.length <= maxFiles) {
onChange?.([...values, ...acceptedFiles]);
}
}, [acceptedFiles]);
return (
<div className={cn('w-full', className?.wrapper)}>
<div
className={cn(
'w-full flex flex-col gap-2 text-start',
className?.inputContainer
)}
>
{label && (
<label
htmlFor={name}
className={cn(
'w-full text-sm font-normal leading-5',
className?.label
)}
>
{label}
{required && (
<>
{' '}
<span className='tooltip tooltip-error' data-tip='required'>
<span className='text-error'>*</span>
</span>
</>
)}
</label>
)}
<div
{...getRootProps({
'aria-disabled': isDisabled,
className: cn(
'dropzone w-full px-4 py-2 border border-dashed border-gray-300 rounded cursor-pointer transition-all',
'hover:border-primary hover:bg-primary/10',
{
'border-success bg-success/10': isDragAccept,
'border-error bg-error/10': isDragReject || isError,
'border-primary bg-primary/10': isFocused,
'bg-gray-200/20 cursor-not-allowed': isDisabled,
},
className?.inputWrapper
),
})}
>
<input
{...getInputProps({
id: name,
name,
disabled: isDisabled,
'aria-disabled': isDisabled,
})}
/>
{caption && (
<p className={cn('text-gray-500 text-sm', className?.caption)}>
{caption}
</p>
)}
</div>
{!isError && bottomLabel && (
<p
className={cn('w-full text-sm opacity-60', className?.bottomLabel)}
>
{bottomLabel}
</p>
)}
{isError && (
<p
className={cn('w-full text-sm text-error', className?.errorMessage)}
>
{errorMessage}
</p>
)}
</div>
{values && values.length > 0 && (
<div
className={cn(
'w-full mt-1.5 flex flex-col gap-1.5',
className?.fileItemContainer
)}
>
{values.map((file, idx) => (
<div
key={idx}
className={cn('w-full flex flex-row items-center gap-2')}
>
<div className='p-2 rounded-full bg-primary/10'>
<Icon
icon='basil:file-solid'
width={24}
height={24}
className='text-blue-500'
/>
</div>
<div className='w-full text-sm'>
<p>{file.name}</p>
</div>
<Button
variant='ghost'
color='error'
onClick={() => {
onDelete?.(idx);
}}
className='rounded-full text-error focus-visible:text-error-content hover:text-error-content'
>
<Icon icon='fluent:delete-12-regular' width={24} height={24} />
</Button>
</div>
))}
</div>
)}
</div>
);
};
export default DropFileInput;
+2 -2
View File
@@ -49,8 +49,8 @@ const NumberInput = ({
onValueChange={valueChangeHandler}
decimalScale={decimalScale}
allowNegative={allowNegative}
startAdornment={inputPrefix}
endAdornment={inputSuffix}
inputPrefix={inputPrefix}
inputSuffix={inputSuffix}
{...restProps}
/>
);
+90
View File
@@ -0,0 +1,90 @@
'use client';
import { ChangeEvent } from 'react';
import {
PatternFormat,
NumberFormatBase,
NumberFormatBaseProps,
OnValueChange,
} from 'react-number-format';
import TextInput, { TextInputProps } from '@/components/input/TextInput';
interface PatternInputProps extends Omit<TextInputProps, 'type'> {
/**
* Format pattern, contoh: "##/##/####", "(###) ###-####", "####-####-####"
*/
format: string;
/** Mask karakter kosong, misal "_" */
mask?: string;
/** Menampilkan mask walau value kosong */
allowEmptyFormatting?: boolean;
/** Placeholder karakter format, default: "#" */
patternChar?: string;
/** Jika true, izinkan huruf (A-Z) selain angka */
inputVehicleNumber?: boolean;
type?: 'text' | 'password' | 'tel';
}
/**
* PatternInput tetap backward-compatible dengan Storybook
* tapi bisa menerima huruf jika `allowCharacters={true}`
*/
const PatternInput = ({
type = 'text',
format,
mask = '_',
allowEmptyFormatting = false,
patternChar = '#',
inputVehicleNumber = false,
onChange,
...restProps
}: PatternInputProps) => {
const handleValueChange: OnValueChange = (values, { event }) => {
const newEvent = event as ChangeEvent<HTMLInputElement> | undefined;
if (newEvent) {
newEvent.target.value = values.value.toUpperCase();
onChange?.(newEvent);
}
};
if (inputVehicleNumber) {
return (
<NumberFormatBase
{...restProps}
type={type}
customInput={TextInput}
format={(value) => {
const clean = value.replace(/[^a-z0-9]/gi, '').toUpperCase();
const match = clean.match(/^([A-Z]{0,2})(\d{0,4})([A-Z]{0,3})$/);
if (!match) return clean;
const [, prefix, number, suffix] = match;
return [prefix, number, suffix].filter(Boolean).join(' ');
}}
removeFormatting={(val) => val.replace(/\s+/g, '')}
isValidInputCharacter={(char) => /^[a-z0-9]$/i.test(char)}
getCaretBoundary={(val) =>
Array(val.length + 1)
.fill(true)
.map(Boolean)
}
onValueChange={handleValueChange}
/>
);
}
return (
<PatternFormat
{...restProps}
type={type}
format={format}
mask={mask}
allowEmptyFormatting={allowEmptyFormatting}
patternChar={patternChar}
customInput={TextInput}
onValueChange={handleValueChange}
/>
);
};
export default PatternInput;
+174 -75
View File
@@ -1,6 +1,11 @@
'use client';
import { ChangeEventHandler, ReactNode } from 'react';
import {
ChangeEventHandler,
ReactNode,
createContext,
useContext,
} from 'react';
import { cn } from '@/lib/helper';
export interface RadioOption {
@@ -8,37 +13,74 @@ export interface RadioOption {
value: string;
}
export interface RadioInputProps {
label?: string;
bottomLabel?: string;
// DaisyUI Radio Colors
export type RadioColor =
| 'neutral'
| 'primary'
| 'secondary'
| 'accent'
| 'success'
| 'warning'
| 'info'
| 'error';
// DaisyUI Radio Sizes
export type RadioSize = 'xs' | 'sm' | 'md' | 'lg' | 'xl';
// Context untuk RadioGroup
interface RadioGroupContextValue {
name: string;
value?: string;
options: RadioOption[];
variant?: string;
className?: {
wrapper?: string;
label?: string;
radioWrapper?: string;
radio?: string;
};
isError?: boolean;
isValid?: boolean;
errorMessage?: string;
required?: boolean;
color?: RadioColor;
size?: RadioSize;
disabled?: boolean;
startAdornment?: ReactNode;
endAdornment?: ReactNode;
onChange?: ChangeEventHandler<HTMLInputElement>;
onBlur?: (e: React.FocusEvent<HTMLInputElement>) => void;
}
const RadioInput = ({
const RadioGroupContext = createContext<RadioGroupContextValue | undefined>(
undefined
);
const useRadioGroup = () => {
const context = useContext(RadioGroupContext);
if (!context) {
throw new Error('RadioGroupItem must be used within RadioGroup');
}
return context;
};
// RadioGroup Component
export interface RadioGroupProps {
label?: string;
bottomLabel?: string;
name: string;
value?: string;
options?: RadioOption[];
color?: RadioColor;
size?: RadioSize;
className?: {
wrapper?: string;
label?: string;
radioWrapper?: string;
};
isError?: boolean;
errorMessage?: string;
required?: boolean;
disabled?: boolean;
onChange?: ChangeEventHandler<HTMLInputElement>;
onBlur?: (e: React.FocusEvent<HTMLInputElement>) => void;
children?: ReactNode;
}
export const RadioGroup = ({
label,
bottomLabel,
name,
value,
options,
variant = 'radio-primary',
color = 'primary',
size = 'md',
className,
isError,
errorMessage,
@@ -46,68 +88,125 @@ const RadioInput = ({
disabled = false,
onChange,
onBlur,
}: RadioInputProps) => {
return (
<div className={cn('w-full flex flex-col gap-2', className?.wrapper)}>
{/* Label atas */}
{label && (
<label
className={cn(
'w-full text-sm font-normal leading-5',
{ 'text-error': isError },
className?.label
)}
>
{label}
{required && (
<span className='text-error ml-1' title='required'>
*
</span>
)}
</label>
)}
children,
}: RadioGroupProps) => {
const contextValue: RadioGroupContextValue = {
name,
value,
color,
size,
disabled,
onChange,
onBlur,
};
{/* Daftar opsi radio */}
<div
className={cn(
'flex flex-row flex-wrap gap-4 items-center',
className?.radioWrapper
)}
>
{options.map((option) => (
return (
<RadioGroupContext.Provider value={contextValue}>
<div className={cn('w-full flex flex-col gap-2', className?.wrapper)}>
{/* Label atas */}
{label && (
<label
key={option.value}
className={cn(
'flex flex-row items-center gap-2 cursor-pointer',
disabled && 'opacity-60 cursor-not-allowed'
'w-full text-sm font-normal leading-5',
{ 'text-error': isError },
className?.label
)}
>
<input
type='radio'
name={name}
value={option.value}
checked={value === option.value}
onChange={onChange}
onBlur={onBlur}
disabled={disabled}
className={cn('radio', variant, className?.radio)}
/>
<span className='text-sm'>{option.label}</span>
{label}
{required && (
<span className='text-error ml-1' title='required'>
*
</span>
)}
</label>
))}
)}
{/* Daftar opsi radio */}
<div
className={cn(
'flex flex-row flex-wrap gap-4 items-center',
className?.radioWrapper
)}
>
{/* Jika options diberikan, render otomatis */}
{options &&
options.map((option) => (
<RadioGroupItem
key={option.value}
value={option.value}
label={option.label}
/>
))}
{/* Atau gunakan children untuk custom rendering */}
{children}
</div>
{/* Label bawah */}
{!isError && bottomLabel && (
<p className='text-sm opacity-60'>{bottomLabel}</p>
)}
{/* Pesan error */}
{isError && errorMessage && (
<p className='text-sm text-error'>{errorMessage}</p>
)}
</div>
{/* Label bawah */}
{!isError && bottomLabel && (
<p className='text-sm opacity-60'>{bottomLabel}</p>
)}
{/* Pesan error */}
{isError && errorMessage && (
<p className='text-sm text-error'>{errorMessage}</p>
)}
</div>
</RadioGroupContext.Provider>
);
};
export default RadioInput;
// RadioGroupItem Component
export interface RadioGroupItemProps {
value: string;
label?: string;
className?: string;
disabled?: boolean;
color?: RadioColor;
size?: RadioSize;
}
export const RadioGroupItem = ({
value,
label,
className,
disabled: itemDisabled,
color: itemColor,
size: itemSize,
}: RadioGroupItemProps) => {
const {
name,
value: groupValue,
color: groupColor,
size: groupSize,
disabled: groupDisabled,
onChange,
onBlur,
} = useRadioGroup();
const isDisabled = itemDisabled ?? groupDisabled;
const radioColor = itemColor ?? groupColor;
const radioSize = itemSize ?? groupSize;
return (
<label
className={cn(
'flex flex-row items-center gap-2 cursor-pointer',
isDisabled && 'opacity-60 cursor-not-allowed',
className
)}
>
<input
type='radio'
name={name}
value={value}
checked={groupValue === value}
onChange={onChange}
onBlur={onBlur}
disabled={isDisabled}
className={cn('radio', `radio-${radioColor}`, `radio-${radioSize}`)}
/>
{label && <span className='text-sm'>{label}</span>}
</label>
);
};
+77 -25
View File
@@ -1,22 +1,23 @@
'use client';
import { ComponentType, ReactNode, useEffect, useMemo, useState } from 'react';
import useSWR from 'swr';
import Select, {
OptionProps,
GroupBase,
InputActionMeta,
MultiValue,
SingleValue,
components as ReactSelectComponents,
ControlProps,
} from 'react-select';
import CreatableSelect from 'react-select/creatable';
import makeAnimated from 'react-select/animated';
import { useDebounce } from 'use-debounce';
import { cn, getByPath } from '@/lib/helper';
import useSWR from 'swr';
import { httpClientFetcher } from '@/services/http/client';
import { isResponseSuccess } from '@/lib/api-helper';
import { BaseApiResponse } from '@/types/api/api-general';
import { isResponseSuccess } from '@/lib/api-helper';
export interface OptionType {
value: string | number;
@@ -53,6 +54,8 @@ interface SelectInputBaseProps<T = OptionType> {
openMenu?: boolean;
delay?: number;
onInputChange?: (search: string) => void;
startAdornment?: ReactNode;
menuPortalTarget?: HTMLElement | null;
}
interface SelectInputProps<T = OptionType> extends SelectInputBaseProps<T> {
@@ -63,6 +66,33 @@ interface SelectInputProps<T = OptionType> extends SelectInputBaseProps<T> {
const animatedComponents = makeAnimated();
const CustomControl = <
Option,
IsMulti extends boolean,
Group extends GroupBase<Option>,
>(
props: ControlProps<Option, IsMulti, Group>
) => {
const { children } = props;
const customProps = props.selectProps as unknown as {
shouldShowAdornment?: boolean;
startAdornment?: ReactNode;
};
const shouldShowAdornment = customProps.shouldShowAdornment ?? false;
const startAdornment = customProps.startAdornment;
return (
<ReactSelectComponents.Control {...props}>
<div className='flex-1 px-4! py-1.5 gap-1 flex items-center'>
{shouldShowAdornment && startAdornment}
{children}
</div>
</ReactSelectComponents.Control>
);
};
const SelectInput = <T extends OptionType>(props: SelectInputProps<T>) => {
const {
label,
@@ -87,15 +117,25 @@ const SelectInput = <T extends OptionType>(props: SelectInputProps<T>) => {
delay = 300,
createables = false,
onInputChange,
startAdornment,
menuPortalTarget,
} = props;
const [internalInputValue, setInternalInputValue] = useState('');
const [debouncedInputValue] = useDebounce(internalInputValue, delay);
const shouldShowAdornment = startAdornment && !internalInputValue;
const components = useMemo(() => {
const base = isAnimated ? animatedComponents : {};
return { ...base, IndicatorSeparator: () => null };
}, [isAnimated]);
const customComponents = { ...base, IndicatorSeparator: () => null };
if (startAdornment) {
customComponents.Control = CustomControl;
}
return customComponents;
}, [isAnimated, startAdornment]);
const internalInputChangeHandler = (val: string, meta: InputActionMeta) => {
if (meta.action === 'input-change') setInternalInputValue(val);
@@ -139,9 +179,12 @@ const SelectInput = <T extends OptionType>(props: SelectInputProps<T>) => {
>
{label}
{required && (
<span className='tooltip tooltip-error' data-tip='required'>
<span className='text-error'> *</span>
</span>
<>
{' '}
<span className='tooltip tooltip-error' data-tip='required'>
<span className='text-error'>*</span>
</span>
</>
)}
</span>
)}
@@ -149,11 +192,12 @@ const SelectInput = <T extends OptionType>(props: SelectInputProps<T>) => {
<SelectComponent<T, boolean, GroupBase<T>>
instanceId='select'
value={value ?? (isMulti ? [] : null)}
onChange={handleChange}
onChange={onChange ? handleChange : undefined}
options={options}
menuIsOpen={openMenu}
inputValue={internalInputValue}
onInputChange={internalInputChangeHandler}
onMenuClose={() => setInternalInputValue('')}
isMulti={isMulti}
isDisabled={isDisabled}
isLoading={isLoading}
@@ -163,17 +207,19 @@ const SelectInput = <T extends OptionType>(props: SelectInputProps<T>) => {
placeholder={placeholder}
className={cn('w-full', className?.select)}
classNames={{
control: ({ isFocused, isDisabled }) =>
cn(
'w-full min-h-12! rounded border bg-white transition-shadow cursor-pointer!',
{
'border-red-500! ring-2 ring-red-200': isError,
'border-indigo-500 ring-2 ring-indigo-200': isFocused,
'border-gray-300': !isError && !isFocused,
'bg-gray-100 text-gray-400 cursor-not-allowed': isDisabled,
}
),
valueContainer: () => cn('flex-1 px-4! py-2! gap-1'),
...(!startAdornment && {
control: ({ isFocused, isDisabled }) =>
cn(
'w-full min-h-12! rounded border bg-white transition-shadow cursor-pointer!',
{
'border-red-500! ring-2 ring-red-200': isError,
'border-indigo-500 ring-2 ring-indigo-200': isFocused,
'border-gray-300': !isError && !isFocused,
'bg-gray-100 text-gray-400 cursor-not-allowed': isDisabled,
}
),
valueContainer: () => cn('flex-1 px-4! py-2! gap-1'),
}),
placeholder: () =>
cn({ 'text-gray-400': !isError, 'text-red-300!': isError }),
singleValue: () =>
@@ -190,7 +236,7 @@ const SelectInput = <T extends OptionType>(props: SelectInputProps<T>) => {
cn('border border-gray-200 rounded! bg-base-100 shadow-lg!'),
menuList: () => cn('p-2! max-h-60 overflow-auto'),
option: ({ isFocused, isSelected }) =>
cn('mt-1 px-3 py-2 rounded cursor-pointer!', {
cn('mt-1 px-3 py-2 rounded-md cursor-pointer!', {
'bg-indigo-600 text-white': isFocused,
'bg-blue-500!': isSelected,
'text-gray-700': !isFocused && !isSelected,
@@ -211,8 +257,14 @@ const SelectInput = <T extends OptionType>(props: SelectInputProps<T>) => {
...components,
...(optionComponent ? { Option: optionComponent } : {}),
}}
{...(startAdornment && {
shouldShowAdornment,
startAdornment,
})}
menuPortalTarget={
typeof document !== 'undefined' ? document.body : undefined
typeof document !== 'undefined'
? (menuPortalTarget ?? document.body)
: undefined
}
styles={{
menuPortal: (base) => ({ ...base, zIndex: 9999 }),
@@ -229,8 +281,8 @@ const SelectInput = <T extends OptionType>(props: SelectInputProps<T>) => {
const useSelect = <T,>(
basePath: string,
valueKey: keyof T,
labelKey: keyof T,
valueKey: keyof T | string,
labelKey: keyof T | string,
searchKey: string = 'search',
params?: { [key: string]: string }
) => {
@@ -241,7 +293,7 @@ const useSelect = <T,>(
[searchKey]: inputValue ?? '',
...params,
}).toString();
}, [inputValue, searchKey]);
}, [inputValue, searchKey, params]);
const optionsUrl = `${basePath}?${optionsUrlParams}`;
+1 -1
View File
@@ -83,7 +83,7 @@ const TextArea = ({
<textarea
className={cn(
'input h-auto px-4 py-2 text-base font-normal leading-6 w-full rounded outline-none! transition-all bg-white',
'textarea h-auto px-4 py-2 text-base font-normal leading-6 w-full rounded outline-none! transition-all bg-white',
{
'border-error': isError,
'border-success!': isValid,
+111 -29
View File
@@ -31,6 +31,8 @@ export interface TextInputProps {
errorMessage?: string;
startAdornment?: ReactNode;
endAdornment?: ReactNode;
inputPrefix?: ReactNode;
inputSuffix?: ReactNode;
onChange?: ChangeEventHandler<HTMLInputElement>;
onBlur?: FocusEventHandler<HTMLInputElement>;
}
@@ -48,6 +50,8 @@ const TextInput = ({
errorMessage,
startAdornment,
endAdornment,
inputPrefix,
inputSuffix,
disabled = false,
required = false,
onChange,
@@ -85,39 +89,117 @@ const TextInput = ({
</label>
)}
<div
className={cn(
'input h-12 px-4 py-2 text-base font-normal leading-6 w-full rounded outline-none! transition-all duration-200',
{
'border-error': isError,
'border-success!': isValid,
},
className?.inputWrapper
)}
>
{startAdornment && startAdornment}
{inputPrefix || inputSuffix ? (
<div className='relative flex'>
{inputPrefix && (
<div
className={cn(
'inline-flex items-center px-4 py-2 border border-r-0 rounded-l-md transition-all duration-200',
{
'bg-gray-100 border-gray-300': !disabled,
'bg-gray-50 border-gray-200': disabled,
}
)}
>
{inputPrefix}
</div>
)}
<input
type={type}
id={name}
name={name}
placeholder={placeholder}
value={value}
onChange={onChange}
onBlur={onBlur}
disabled={disabled}
className={cn('grow', className?.input)}
readOnly={readOnly}
/>
<div
className={cn(
'input h-12 text-base font-normal leading-6 flex-1 rounded-lg! outline-none! transition-all duration-200 flex items-center bg-white',
{
'border-error': isError,
'border-success!': isValid,
'rounded-l-none!': inputPrefix,
'rounded-r-none!': inputSuffix,
'input-disabled': disabled,
'cursor-not-allowed': disabled,
'bg-gray-50': disabled,
},
className?.inputWrapper
)}
>
{startAdornment && startAdornment}
{(isLoading || endAdornment) && (
<div className='flex flex-row gap-2'>
{isLoading && <span className='loading loading-spinner' />}
<input
type={type}
id={name}
name={name}
placeholder={placeholder}
value={value}
onChange={onChange}
onBlur={onBlur}
disabled={disabled}
className={cn(
'grow bg-transparent outline-none',
{
'cursor-not-allowed': disabled,
'text-gray-500': disabled,
},
className?.input
)}
readOnly={readOnly}
/>
{endAdornment && endAdornment}
{(isLoading || endAdornment) && (
<div className='flex flex-row gap-2'>
{isLoading && <span className='loading loading-spinner' />}
{endAdornment && endAdornment}
</div>
)}
</div>
)}
</div>
{inputSuffix && (
<div
className={cn(
'inline-flex items-center px-4 py-2 border border-l-0 rounded-r-md transition-all duration-200',
{
'bg-gray-100 border-gray-300': !disabled,
'bg-gray-50 border-gray-200': disabled,
}
)}
>
{inputSuffix}
</div>
)}
</div>
) : (
<div
className={cn(
'input h-12 px-4 py-2 text-base font-normal leading-6 w-full rounded-lg! outline-none! transition-all duration-200 bg-white',
{
'border-error': isError,
'border-success!': isValid,
},
className?.inputWrapper
)}
>
{startAdornment && startAdornment}
<input
type={type}
id={name}
name={name}
placeholder={placeholder}
value={value}
onChange={onChange}
onBlur={onBlur}
disabled={disabled}
className={cn('grow', className?.input)}
readOnly={readOnly}
/>
{(isLoading || endAdornment) && (
<div className='flex flex-row gap-2'>
{isLoading && <span className='loading loading-spinner' />}
{endAdornment && endAdornment}
</div>
)}
</div>
)}
{!isError && bottomLabel && (
<p className='w-full text-sm opacity-60'>{bottomLabel}</p>
+20 -4
View File
@@ -1,16 +1,32 @@
import { ReactNode } from 'react';
import { cn } from '@/lib/helper';
import { Size } from '@/types/theme';
interface MenuProps {
children?: ReactNode;
size?: Size;
direction?: 'vertical' | 'horizontal';
className?: string;
}
const Menu = ({ children, className }: MenuProps) => {
return (
<ul className={cn('menu w-full p-0 gap-0.5', className)}>{children}</ul>
);
const Menu = ({
children,
size = 'md',
direction = 'vertical',
className,
}: MenuProps) => {
const menuBaseClassName = cn('menu w-full', {
'menu-xs': size === 'xs',
'menu-sm': size === 'sm',
'menu-md': size === 'md',
'menu-lg': size === 'lg',
'menu-xl': size === 'xl',
'menu-vertical': direction === 'vertical',
'menu-horizontal': direction === 'horizontal',
});
return <ul className={cn(menuBaseClassName, className)}>{children}</ul>;
};
export default Menu;
+40 -17
View File
@@ -1,35 +1,29 @@
'use client';
import { RefObject } from 'react';
import { MouseEventHandler, RefObject, useState } from 'react';
import { Icon } from '@iconify/react';
import Modal from '@/components/Modal';
import Button from '@/components/Button';
import Button, { ButtonProps } from '@/components/Button';
import { cn } from '@/lib/helper';
import { Color } from '@/types/theme';
interface ConfirmationModalProps {
export interface ConfirmationModalProps {
ref: RefObject<HTMLDialogElement | null>;
type?: 'info' | 'success' | 'error';
text?: string;
closeOnBackdrop?: boolean;
primaryButton?: {
primaryButton?: ButtonProps & {
text?: string;
color?: Color;
isLoading?: boolean;
onClick?: () => void;
};
secondaryButton?: {
secondaryButton?: ButtonProps & {
text?: string;
color?: Color;
isLoading?: boolean;
onClick?: () => void;
};
className?: {
modal?: string;
modalBox?: string;
};
children?: React.ReactNode;
}
const ConfirmationModal = ({
@@ -40,11 +34,24 @@ const ConfirmationModal = ({
primaryButton,
secondaryButton,
className,
children,
}: ConfirmationModalProps) => {
const [isPrimaryButtonLoading, setIsPrimaryButtonLoading] = useState(false);
const closeModalHandler = () => {
ref.current?.close();
};
const primaryButtonClickHandler: MouseEventHandler<
HTMLButtonElement
> = async (event) => {
setIsPrimaryButtonLoading(true);
await primaryButton?.onClick?.(event);
setIsPrimaryButtonLoading(false);
};
return (
<Modal ref={ref} closeOnBackdrop={closeOnBackdrop} className={className}>
<div className='w-full flex flex-col gap-4'>
@@ -90,13 +97,20 @@ const ConfirmationModal = ({
{text ?? 'Apakah anda yakin ingin melakukan hal ini?'}
</p>
{children && <div className='w-full'>{children}</div>}
<div className='w-full flex flex-row gap-2'>
{secondaryButton && secondaryButton.text && (
<Button
{...secondaryButton}
variant='ghost'
color={secondaryButton?.color ?? 'none'}
color={secondaryButton?.color}
isLoading={secondaryButton?.isLoading}
disabled={secondaryButton?.isLoading}
disabled={
secondaryButton?.isLoading !== undefined
? secondaryButton?.isLoading
: isPrimaryButtonLoading
}
onClick={closeModalHandler}
className='grow'
>
@@ -106,10 +120,19 @@ const ConfirmationModal = ({
{primaryButton && primaryButton.text && (
<Button
{...primaryButton}
color={primaryButton?.color ?? 'info'}
onClick={primaryButton?.onClick}
isLoading={primaryButton?.isLoading}
disabled={primaryButton?.isLoading}
onClick={primaryButtonClickHandler}
isLoading={
primaryButton?.isLoading !== undefined
? primaryButton?.isLoading
: isPrimaryButtonLoading
}
disabled={
primaryButton?.isLoading !== undefined
? primaryButton?.isLoading
: isPrimaryButtonLoading
}
className='grow'
>
{primaryButton?.text ?? 'Ya'}
@@ -0,0 +1,70 @@
'use client';
import { ChangeEventHandler, useId, useState } from 'react';
import ConfirmationModal, {
ConfirmationModalProps,
} from '@/components/modal/ConfirmationModal';
import TextArea from '@/components/input/TextArea';
import { Color } from '@/types/theme';
interface ConfirmationModalWithNotesProps
extends Omit<ConfirmationModalProps, 'children' | 'primaryButton'> {
rows?: number;
placeholder?: string;
primaryButton?: {
text?: string;
color?: Color;
isLoading?: boolean;
onClick?: (notes: string) => void;
};
}
const ConfirmationModalWithNotes: React.FC<ConfirmationModalWithNotesProps> = ({
ref,
type = 'info',
text,
closeOnBackdrop,
primaryButton,
secondaryButton,
className,
rows = 3,
placeholder = 'Catatan...',
}) => {
const randomId = useId();
const [notes, setNotes] = useState('');
const notesChangeHandler: ChangeEventHandler<HTMLTextAreaElement> = (e) => {
setNotes(e.target.value);
};
return (
<ConfirmationModal
ref={ref}
type={type}
text={text}
closeOnBackdrop={closeOnBackdrop}
primaryButton={{
...primaryButton,
onClick: () => {
primaryButton?.onClick?.(notes);
setNotes('');
},
}}
secondaryButton={secondaryButton}
className={className}
>
<TextArea
name={randomId}
placeholder={placeholder}
value={notes}
onChange={notesChangeHandler}
rows={rows}
/>
</ConfirmationModal>
);
};
export default ConfirmationModalWithNotes;
+92
View File
@@ -0,0 +1,92 @@
import Link from 'next/link';
import Menu from '@/components/menu/Menu';
import { Icon } from '@iconify/react';
import { cn, isPathActive } from '@/lib/helper';
export interface SidebarMenuItem {
type?: 'item' | 'title';
text: string;
link: string;
icon?: string;
submenu?: SidebarMenuItem[];
}
interface SidebarMenuItemProps {
item: SidebarMenuItem;
activeLink: string;
}
interface SidebarMenuProps {
menu: SidebarMenuItem[];
activeLink: string;
}
const SidebarMenuItem = ({ item, activeLink }: SidebarMenuItemProps) => {
const isItemActive = isPathActive(activeLink, item.link);
const menuItemWithoutSubmenu = (
<li>
<Link
href={item.link}
className={cn(
{
'menu-active border-2 border-solid border-base-300': isItemActive,
},
'px-3 py-1.5'
)}
>
{item.icon && <Icon icon={item.icon} width={20} height={20} />}
<span className='text-base'>{item.text}</span>
</Link>
</li>
);
if (!item.submenu || item.submenu.length === 0) {
return menuItemWithoutSubmenu;
}
const menuItemWithSubmenu = (
<li>
<details open={isItemActive}>
<summary
className={cn({
'text-primary': isItemActive,
})}
>
{item.icon && <Icon icon={item.icon} width={20} height={20} />}
<span className='text-base'>{item.text}</span>
</summary>
<ul>
{item.submenu.map((submenuItem, submenuIdx) => (
<SidebarMenuItem
key={`submenu#${submenuIdx}`}
item={submenuItem}
activeLink={activeLink}
/>
))}
</ul>
</details>
</li>
);
return menuItemWithSubmenu;
};
const SidebarMenu = ({ menu, activeLink }: SidebarMenuProps) => {
return (
<Menu>
{menu.map((menuItem, menuIdx) => (
<SidebarMenuItem
key={menuIdx}
item={menuItem}
activeLink={activeLink}
/>
))}
</Menu>
);
};
export default SidebarMenu;
+313 -50
View File
@@ -4,12 +4,21 @@ import StepItem from '@/components/steps/StepItem';
import Tooltip from '@/components/Tooltip';
import { cn, formatDate } from '@/lib/helper';
import { BaseApproval, BaseGroupedApproval } from '@/types/api/api-general';
import {
BaseApiResponse,
BaseApproval,
BaseGroupedApproval,
} from '@/types/api/api-general';
import { ApprovalLine } from '@/types/config/constant';
import useSWR from 'swr';
import { httpClientFetcher } from '@/services/http/client';
import { isResponseSuccess } from '@/lib/api-helper';
import { useCallback, useMemo } from 'react';
export type ApprovalStepStatus = 'APPROVED' | 'REJECTED' | 'WAITING' | 'IDLE';
export type ApprovalStepLog = {
action: string;
action_by?: string;
date?: string;
notes?: string | null;
@@ -57,28 +66,55 @@ const ApprovalSteps = ({ approvals }: ApprovalStepsProps) => {
position='right'
className={{
wrapper: 'md:tooltip-bottom',
content: 'p-0 rounded overflow-hidden',
}}
content={
<>
{approval.logs && approval.logs.length > 0 && (
<div className='flex flex-col gap-2'>
{approval.logs?.map((approvalLog, logIdx) => (
<div
key={logIdx}
className='flex flex-col text-base text-start'
>
{approvalLog.date && (
<span>
{formatDate(
approvalLog.date,
'YYYY-MM-DD, HH:mm:ss'
)}
</span>
)}
<span>Oleh: {approvalLog.action_by ?? '-'}</span>
<span>Catatan: {approvalLog.notes ?? '-'}</span>
</div>
))}
<div className='flex flex-col gap-0'>
{approval.logs?.map((approvalLog, logIdx) => {
const action =
approvalLog.action === 'CREATED'
? 'Dibuat'
: approvalLog.action === 'UPDATED'
? 'Diperbarui'
: approvalLog.action === 'APPROVED'
? 'Disetujui'
: approvalLog.action === 'REJECTED'
? 'Ditolak'
: '-';
return (
<div
key={logIdx}
className={cn(
'p-2 flex flex-col text-base text-start',
{
'bg-success text-success-content':
approvalLog.action === 'APPROVED',
'bg-error text-error-content':
approvalLog.action === 'REJECTED',
'bg-info text-info-content':
approvalLog.action === 'CREATED',
'bg-warning text-warning-content':
approvalLog.action === 'UPDATED',
}
)}
>
{approvalLog.date && (
<span>
{formatDate(
approvalLog.date,
'YYYY-MM-DD, HH:mm:ss'
)}
</span>
)}
<span>Aksi: {action}</span>
<span>Oleh: {approvalLog.action_by ?? '-'}</span>
<span>Catatan: {approvalLog.notes ?? '-'}</span>
</div>
);
})}
</div>
)}
</>
@@ -108,65 +144,98 @@ const ApprovalSteps = ({ approvals }: ApprovalStepsProps) => {
export const formatGroupedApprovalsToApprovalSteps = (
approvalLine: ApprovalLine,
groupedApprovals: BaseGroupedApproval[],
latestApproval: BaseApproval
groupedApprovals: BaseGroupedApproval[] | undefined,
latestApproval: BaseApproval | undefined
): ApprovalStepsProps['approvals'] => {
const formattedApprovalSteps: ApprovalStepsProps['approvals'] =
approvalLine.map((approvalLineItem) => {
const approvalGroup = groupedApprovals.find(
const approvalGroup = groupedApprovals?.find(
(approvalGroupItem) =>
approvalGroupItem.step_number === approvalLineItem.step_number
);
const currentStepNumber = approvalLineItem.step_number;
const lastStepNumber =
groupedApprovals[groupedApprovals.length - 1].step_number;
groupedApprovals?.[groupedApprovals.length - 1]?.step_number;
if (!approvalGroup && currentStepNumber <= lastStepNumber) {
throw new Error(
`Approval dengan ${approvalLineItem.step_name} tidak ditemukan!`
);
const isLatestApprovalRejected = latestApproval?.action === 'REJECTED';
// Only throw error if we have a valid lastStepNumber to compare against
if (
!approvalGroup &&
lastStepNumber !== undefined &&
currentStepNumber <= lastStepNumber
) {
// throw new Error(
// `Approval dengan ${approvalLineItem.step_name} tidak ditemukan!`
// );
}
if (!approvalGroup) {
const isWaiting = currentStepNumber === latestApproval.step_number + 1;
// Check if this step is waiting (only if we have latestApproval)
const isWaiting =
latestApproval?.step_number !== undefined &&
currentStepNumber === latestApproval.step_number + 1;
// Check if previous approval was rejected
const isPreviousApprovalRejected =
groupedApprovals &&
groupedApprovals.length > 0 &&
groupedApprovals[groupedApprovals.length - 1]?.approvals?.[0]
?.action === 'REJECTED';
return {
name: approvalLineItem.step_name,
status: isWaiting ? 'WAITING' : 'IDLE',
status: isPreviousApprovalRejected
? 'IDLE'
: isWaiting
? 'WAITING'
: 'IDLE',
};
}
let approvalStatus: ApprovalStepStatus;
let approvalStatus: ApprovalStepStatus = 'IDLE';
if (approvalGroup.step_number <= latestApproval.step_number) {
switch (approvalGroup.approvals[0].action) {
case 'CREATED':
case 'APPROVED':
approvalStatus = 'APPROVED';
break;
// Only compare if latestApproval and its step_number exist
if (
latestApproval?.step_number !== undefined &&
approvalGroup.step_number <= latestApproval.step_number
) {
if (approvalGroup.approvals) {
switch (approvalGroup?.approvals[0]?.action) {
case 'CREATED':
case 'UPDATED':
case 'APPROVED':
approvalStatus = 'APPROVED';
break;
case 'REJECTED':
approvalStatus = 'REJECTED';
break;
case 'REJECTED':
approvalStatus = 'REJECTED';
break;
default:
approvalStatus = 'IDLE';
break;
default:
approvalStatus = 'IDLE';
break;
}
}
} else if (approvalGroup.step_number === latestApproval.step_number + 1) {
} else if (
latestApproval?.step_number !== undefined &&
approvalGroup.step_number === latestApproval.step_number + 1 &&
!isLatestApprovalRejected
) {
approvalStatus = 'WAITING';
} else {
approvalStatus = 'IDLE';
}
const approvalLogs: ApprovalStepLog[] = approvalGroup.approvals.map(
(approval) => ({
action_by: approval.action_by.name,
date: approval.action_at,
notes: approval.notes,
})
);
const approvalLogs: ApprovalStepLog[] = approvalGroup.approvals
? approvalGroup.approvals.map((approval) => ({
action_by: approval.action_by.name,
date: approval.action_at,
notes: approval.notes,
action: approval.action,
}))
: [];
return {
name: approvalGroup.step_name,
@@ -179,3 +248,197 @@ export const formatGroupedApprovalsToApprovalSteps = (
};
export default ApprovalSteps;
/**
* Mengubah array BaseApproval (datar) menjadi BaseGroupedApproval (berkelompok).
*/
const groupApprovalsByStep = (
approvals: BaseApproval[]
): BaseGroupedApproval[] => {
const groups: Record<number, BaseGroupedApproval> = {};
for (const approval of approvals) {
if (!groups[approval.step_number]) {
groups[approval.step_number] = {
step_number: approval.step_number,
step_name: approval.step_name,
approvals: [],
};
}
groups[approval.step_number].approvals.push(approval);
}
return Object.values(groups);
};
/**
* Mengubah array BaseGroupedApproval (berkelompok) kembali menjadi BaseApproval[] (datar).
*/
const flattenGroupedApprovals = (
groupedApprovals: BaseGroupedApproval[]
): BaseApproval[] => {
return groupedApprovals.flatMap((group) => group.approvals);
};
/**
* Type guard untuk memeriksa apakah data adalah BaseGroupedApproval[].
*/
const isGroupedApprovalData = (
data: BaseApproval[] | BaseGroupedApproval[]
): data is BaseGroupedApproval[] => {
if (!data || data.length === 0) {
return true;
}
const firstElement = data[0];
return (
typeof firstElement === 'object' &&
firstElement !== null &&
'approvals' in firstElement &&
Array.isArray(firstElement.approvals)
);
};
const useApprovalSteps = ({
latestApproval,
approvalLines,
moduleName,
moduleId,
params,
}: {
latestApproval: BaseApproval | undefined;
approvalLines: ApprovalLine;
moduleName: string;
moduleId: string;
params?: {
page?: number;
limit: number;
search?: string;
group_step_number?: boolean;
};
}) => {
// Membuat URL Parameters
const paramString = new URLSearchParams({
page: params?.page?.toString() || '',
limit: params?.limit?.toString() || '',
search: params?.search || '',
}).toString();
// fetching data approvals
const SWR_KEY_APPROVALS =
moduleName && moduleId
? `/approvals?module_name=${moduleName}&module_id=${moduleId}${
params ? `&${paramString}` : ''
}`
: null;
const {
data: approvalData,
isLoading: approvalIsLoading,
mutate: mutateApprovals,
} = useSWR(SWR_KEY_APPROVALS, async (url) => {
return await httpClientFetcher<
BaseApiResponse<BaseApproval[] | BaseGroupedApproval[]>
>(url);
});
// Fungsi Refresh
const refresh = useCallback(async () => {
await mutateApprovals();
}, [mutateApprovals]);
const { groupedApprovals } = useMemo(() => {
const rawData = isResponseSuccess(approvalData)
? approvalData.data
: undefined;
let processedGroupedApprovals: BaseGroupedApproval[] = [];
if (rawData) {
if (isGroupedApprovalData(rawData)) {
processedGroupedApprovals = rawData;
} else {
processedGroupedApprovals = groupApprovalsByStep(
rawData as BaseApproval[]
);
}
}
return {
groupedApprovals: processedGroupedApprovals,
};
}, [approvalData]);
const isLoading = approvalIsLoading;
// Formatting Akhir
const approvals = useMemo(() => {
if (isLoading || !approvalLines.length) {
return [];
}
// Try to derive latestApproval from groupedApprovals if not provided
let effectiveLatestApproval = latestApproval;
if (!effectiveLatestApproval && groupedApprovals.length > 0) {
// Get all approvals from grouped data
const allApprovals = groupedApprovals.flatMap((group) => group.approvals);
if (allApprovals.length > 0) {
// Use the most recent approval (last in array)
effectiveLatestApproval = allApprovals[allApprovals.length - 1];
}
}
// If still no latestApproval, return empty
if (!effectiveLatestApproval) {
return [];
}
try {
return formatGroupedApprovalsToApprovalSteps(
approvalLines,
groupedApprovals,
effectiveLatestApproval
);
} catch (error) {
console.warn('Gagal memformat approval steps:', error);
return [];
}
}, [isLoading, approvalLines, groupedApprovals, latestApproval]);
// Raw Data Approvals
const rawDataApprovals = useMemo(() => {
const rawData = isResponseSuccess(approvalData)
? approvalData.data
: undefined;
if (!rawData) {
return undefined;
}
const isDataCurrentlyGrouped = isGroupedApprovalData(rawData);
const wantsGrouped = params?.group_step_number !== false;
if (wantsGrouped) {
if (isDataCurrentlyGrouped) {
return rawData as BaseGroupedApproval[];
} else {
return groupApprovalsByStep(rawData as BaseApproval[]);
}
} else {
if (isDataCurrentlyGrouped) {
return flattenGroupedApprovals(rawData as BaseGroupedApproval[]);
} else {
return rawData as BaseApproval[];
}
}
}, [approvalData, params?.group_step_number]);
// Return Hook
return {
approvals,
isLoading,
rawDataApprovals: rawDataApprovals,
refresh,
};
};
export { useApprovalSteps };
@@ -0,0 +1,106 @@
'use client';
import { useMemo, useState } from 'react';
import { Icon } from '@iconify/react';
import Button from '@/components/Button';
import Tabs from '@/components/Tabs';
import ClosingGeneralInformationTable from '@/components/pages/closing/ClosingGeneralInformationTable';
import {
ClosingGeneralInformation,
BaseClosingSales,
} from '@/types/api/closing';
import ClosingSapronakTabContent from './ClosingSapronakTabContent';
import ClosingSapronakCalculationTabContent from '@/components/pages/closing/ClosingSapronakCalculationTabContent';
import ClosingOverheadTabContent from '@/components/pages/closing/ClosingOverheadTabContent';
import SalesReportTable from './sale/SalesReportTable';
interface ClosingDetailProps {
id: number;
initialValue?: ClosingGeneralInformation;
salesData?: BaseClosingSales;
}
const ClosingDetail: React.FC<ClosingDetailProps> = ({
id,
initialValue,
salesData,
}) => {
const [activeTab, setActiveTab] = useState<string>('sapronak');
const closingDetailTabs = useMemo(() => {
const validTabs = [
{
id: 'sapronak',
label: 'Sapronak',
content: <ClosingSapronakTabContent projectFlockId={id} />,
},
{
id: 'perhitunganSapronak',
label: 'Perhitungan Sapronak',
content: <ClosingSapronakCalculationTabContent projectFlockId={id} />,
},
{
id: 'penjualan',
label: 'Penjualan',
content: <SalesReportTable initialValues={salesData} />,
},
{
id: 'overhead',
label: 'Overhead',
content: <ClosingOverheadTabContent projectFlockId={id} />,
},
{
id: 'hppEkspedisi',
label: 'HPP Ekspedisi',
content: 'HPP Ekspedisi',
},
{
id: 'dataProduksi',
label: 'Data Produksi',
content: 'Data Produksi',
},
{
id: 'keuangan',
label: 'Keuangan',
content: 'Keuangan',
},
];
return validTabs;
}, [initialValue]);
return (
<>
<section className='w-full max-w-7xl pb-16'>
<header className='flex flex-col gap-4'>
<Button
href='/closing'
variant='link'
className='w-fit p-0 text-primary'
>
<Icon icon='uil:arrow-left' width={24} height={24} />
Kembali
</Button>
<h1 className='text-2xl font-bold text-center'>Detail Closing</h1>
</header>
<ClosingGeneralInformationTable initialValue={initialValue} />
<Tabs
activeTabId={activeTab}
onTabChange={setActiveTab}
tabs={closingDetailTabs}
variant='lifted'
className={{
wrapper: 'w-full mt-4',
}}
/>
</section>
</>
);
};
export default ClosingDetail;
@@ -0,0 +1,100 @@
import { ClosingGeneralInformation } from '@/types/api/closing';
interface ClosingGeneralInformationProps {
initialValue?: ClosingGeneralInformation;
}
const ClosingGeneralInformationTable = ({
initialValue,
}: ClosingGeneralInformationProps) => {
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'>
<table className='table table-zebra table-sm'>
<tbody>
<tr>
<td>Lokasi</td>
<td>:</td>
<td>{initialValue?.location_name}</td>
</tr>
<tr>
<td>Periode</td>
<td>:</td>
<td>{initialValue?.period}</td>
</tr>
<tr>
<td>Kategori</td>
<td>:</td>
<td>{initialValue?.project_category}</td>
</tr>
<tr>
<td>Populasi</td>
<td>:</td>
<td>{initialValue?.population} Ekor</td>
</tr>
<tr>
<td>Jenis Project</td>
<td>:</td>
<td>{initialValue?.project_type}</td>
</tr>
<tr className='table-row @sm:hidden'>
<td>Kandang Aktif</td>
<td>:</td>
<td>{initialValue?.active_house_count} Kandang</td>
</tr>
<tr className='table-row @sm:hidden'>
<td>Status Pembayaran Penjualan</td>
<td>:</td>
<td>{initialValue?.sales_payment_status}</td>
</tr>
<tr className='table-row @sm:hidden'>
<td>Status Project</td>
<td>:</td>
<td>{initialValue?.project_status}</td>
</tr>
<tr className='table-row @sm:hidden'>
<td>Status Closing</td>
<td>:</td>
<td>{initialValue?.closing_status}</td>
</tr>
</tbody>
</table>
</div>
</div>
<div className='w-full hidden @sm:block'>
<div className='overflow-x-auto'>
<table className='table table-zebra table-sm'>
<tbody>
<tr>
<td>Kandang Aktif</td>
<td>:</td>
<td>{initialValue?.active_house_count} Kandang</td>
</tr>
<tr>
<td>Status Pembayaran Penjualan</td>
<td>:</td>
<td>{initialValue?.sales_payment_status}</td>
</tr>
<tr>
<td>Status Project</td>
<td>:</td>
<td>{initialValue?.project_status}</td>
</tr>
<tr>
<td>Status Closing</td>
<td>:</td>
<td>{initialValue?.closing_status}</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
);
};
export default ClosingGeneralInformationTable;
@@ -0,0 +1,209 @@
'use client';
import { ChangeEventHandler, useEffect, useState } from 'react';
import useSWR from 'swr';
import { ColumnDef, SortingState } from '@tanstack/react-table';
import { Icon } from '@iconify/react';
import Table from '@/components/Table';
import DebouncedTextInput from '@/components/input/DebouncedTextInput';
import Card from '@/components/Card';
import Collapse from '@/components/Collapse';
import { cn, formatDate, formatNumber } from '@/lib/helper';
import { isResponseSuccess } from '@/lib/api-helper';
import { useTableFilter } from '@/services/hooks/useTableFilter';
import { ClosingApi } from '@/services/api/closing';
import { ClosingIncomingSapronak } from '@/types/api/closing';
interface ClosingIncomingSapronaksTableProps {
projectFlockId: number;
}
const ClosingIncomingSapronaksTable = ({
projectFlockId,
}: ClosingIncomingSapronaksTableProps) => {
const {
state: tableFilterState,
updateFilter,
setPage,
setPageSize,
toQueryString: getTableFilterQueryString,
} = useTableFilter({
initial: {
search: '',
nameSort: '',
},
paramMap: {
page: 'page',
pageSize: 'limit',
nameSort: 'sort_name',
},
});
const { data: incomingSapronaks, isLoading: isLoadingIncomingSapronaks } =
useSWR(
`${ClosingApi.basePath}/${projectFlockId}/sapronak${getTableFilterQueryString()}&type=incoming`,
ClosingApi.getAllIncomingSapronakFetcher,
{
keepPreviousData: true,
}
);
const [open, setOpen] = useState(true);
const [sorting, setSorting] = useState<SortingState>([]);
const [rowSelection, setRowSelection] = useState<Record<string, boolean>>({});
const incomingSapronaksColumns: ColumnDef<ClosingIncomingSapronak>[] = [
{
header: '#',
cell: (props) => props.row.index + 1,
},
{
accessorKey: 'date',
header: 'Tanggal',
cell: (props) => formatDate(props.row.original.date, 'DD MMM YYYY'),
},
{
accessorKey: 'reference_number',
header: 'No. Referensi',
},
{
accessorKey: 'transaction_type',
header: 'Jenis Transaksi',
},
{
accessorKey: 'product_name',
header: 'Produk',
},
{
accessorKey: 'product_category',
header: 'Kategori Produk',
},
{
accessorKey: 'source_warehouse',
header: 'Gudang Asal',
},
{
accessorKey: 'destination_warehouse',
header: 'Gudang Tujuan',
},
{
accessorKey: 'quantity',
header: 'Kuantitas',
cell: (props) =>
`${formatNumber(props.row.original.quantity)} ${props.row.original.unit}`,
},
{
accessorKey: 'notes',
header: 'Keterangan',
},
];
const searchChangeHandler: ChangeEventHandler<HTMLInputElement> = (e) => {
updateFilter('search', e.target.value);
};
// track sorting
useEffect(() => {
const isNameSorted = sorting.find((sortItem) => sortItem.id === 'name');
if (!isNameSorted) {
updateFilter('nameSort', '');
} else {
updateFilter('nameSort', isNameSorted.desc ? 'desc' : 'asc');
}
}, [sorting, updateFilter]);
useEffect(() => {
if (!open) {
setOpen(
isResponseSuccess(incomingSapronaks)
? incomingSapronaks.data.length > 0
: false
);
}
}, [incomingSapronaks, isResponseSuccess]);
return (
<Card
className={{
wrapper: 'w-full',
body: 'p-4 shadow',
}}
>
<Collapse
open={open}
onOpenChange={setOpen}
title={
<div className='card-actions p-4 justify-between items-center w-full'>
<div className='card-title'>Sapronak Masuk</div>
<Icon
icon='material-symbols:keyboard-arrow-down'
width={24}
height={24}
className={cn('text-primary transition-transform', {
'-rotate-180': open,
})}
/>
</div>
}
className='w-full!'
titleClassName='w-full p-0!'
>
<div className='w-full p-0'>
<div className='flex flex-col gap-2 mb-4'>
<div className='w-full flex flex-col sm:flex-row justify-start items-end sm:items-center gap-4'>
<DebouncedTextInput
name='search'
placeholder='Cari Sapronak Masuk'
value={tableFilterState.search}
onChange={searchChangeHandler}
className={{ wrapper: 'sm:max-w-3xs' }}
/>
</div>
</div>
<Table<ClosingIncomingSapronak>
data={
isResponseSuccess(incomingSapronaks)
? incomingSapronaks?.data
: []
}
columns={incomingSapronaksColumns}
pageSize={tableFilterState.pageSize}
onPageSizeChange={setPageSize}
rowOptions={[10, 20, 50, 100]}
page={
isResponseSuccess(incomingSapronaks)
? incomingSapronaks?.meta?.page
: 0
}
totalItems={
isResponseSuccess(incomingSapronaks)
? incomingSapronaks?.meta?.total_results
: 0
}
onPageChange={setPage}
isLoading={isLoadingIncomingSapronaks}
sorting={sorting}
setSorting={setSorting}
rowSelection={rowSelection}
setRowSelection={setRowSelection}
className={{
containerClassName: cn({
'w-full mb-20':
isResponseSuccess(incomingSapronaks) &&
incomingSapronaks?.data?.length === 0,
}),
}}
/>
</div>
</Collapse>
</Card>
);
};
export default ClosingIncomingSapronaksTable;
@@ -0,0 +1,209 @@
'use client';
import { ChangeEventHandler, useEffect, useState } from 'react';
import useSWR from 'swr';
import { ColumnDef, SortingState } from '@tanstack/react-table';
import { Icon } from '@iconify/react';
import Table from '@/components/Table';
import DebouncedTextInput from '@/components/input/DebouncedTextInput';
import Card from '@/components/Card';
import Collapse from '@/components/Collapse';
import { cn, formatDate, formatNumber } from '@/lib/helper';
import { isResponseSuccess } from '@/lib/api-helper';
import { useTableFilter } from '@/services/hooks/useTableFilter';
import { ClosingApi } from '@/services/api/closing';
import { ClosingOutgoingSapronak } from '@/types/api/closing';
interface ClosingOutgoingSapronaksTableProps {
projectFlockId: number;
}
const ClosingOutgoingSapronaksTable = ({
projectFlockId,
}: ClosingOutgoingSapronaksTableProps) => {
const {
state: tableFilterState,
updateFilter,
setPage,
setPageSize,
toQueryString: getTableFilterQueryString,
} = useTableFilter({
initial: {
search: '',
nameSort: '',
},
paramMap: {
page: 'page',
pageSize: 'limit',
nameSort: 'sort_name',
},
});
const { data: outgoingSapronaks, isLoading: isLoadingOutgoingSapronaks } =
useSWR(
`${ClosingApi.basePath}/${projectFlockId}/sapronak${getTableFilterQueryString()}&type=outgoing`,
ClosingApi.getAllOutgoingSapronakFetcher,
{
keepPreviousData: true,
}
);
const [open, setOpen] = useState(true);
const [sorting, setSorting] = useState<SortingState>([]);
const [rowSelection, setRowSelection] = useState<Record<string, boolean>>({});
const outgoingSapronaksColumns: ColumnDef<ClosingOutgoingSapronak>[] = [
{
header: '#',
cell: (props) => props.row.index + 1,
},
{
accessorKey: 'date',
header: 'Tanggal',
cell: (props) => formatDate(props.row.original.date, 'DD MMM YYYY'),
},
{
accessorKey: 'reference_number',
header: 'No. Referensi',
},
{
accessorKey: 'transaction_type',
header: 'Jenis Transaksi',
},
{
accessorKey: 'product_name',
header: 'Produk',
},
{
accessorKey: 'product_category',
header: 'Kategori Produk',
},
{
accessorKey: 'source_warehouse',
header: 'Gudang Asal',
},
{
accessorKey: 'destination_warehouse',
header: 'Gudang Tujuan',
},
{
accessorKey: 'quantity',
header: 'Kuantitas',
cell: (props) =>
`${formatNumber(props.row.original.quantity)} ${props.row.original.unit}`,
},
{
accessorKey: 'notes',
header: 'Keterangan',
},
];
const searchChangeHandler: ChangeEventHandler<HTMLInputElement> = (e) => {
updateFilter('search', e.target.value);
};
// track sorting
useEffect(() => {
const isNameSorted = sorting.find((sortItem) => sortItem.id === 'name');
if (!isNameSorted) {
updateFilter('nameSort', '');
} else {
updateFilter('nameSort', isNameSorted.desc ? 'desc' : 'asc');
}
}, [sorting, updateFilter]);
useEffect(() => {
if (!open) {
setOpen(
isResponseSuccess(outgoingSapronaks)
? outgoingSapronaks.data.length > 0
: false
);
}
}, [outgoingSapronaks, isResponseSuccess]);
return (
<Card
className={{
wrapper: 'w-full',
body: 'p-4 shadow',
}}
>
<Collapse
open={open}
onOpenChange={setOpen}
title={
<div className='card-actions p-4 justify-between items-center w-full'>
<div className='card-title'>Sapronak Keluar</div>
<Icon
icon='material-symbols:keyboard-arrow-down'
width={24}
height={24}
className={cn('text-primary transition-transform', {
'-rotate-180': open,
})}
/>
</div>
}
className='w-full!'
titleClassName='w-full p-0!'
>
<div className='w-full p-0'>
<div className='flex flex-col gap-2 mb-4'>
<div className='w-full flex flex-col sm:flex-row justify-start items-end sm:items-center gap-4'>
<DebouncedTextInput
name='search'
placeholder='Cari Sapronak Keluar'
value={tableFilterState.search}
onChange={searchChangeHandler}
className={{ wrapper: 'sm:max-w-3xs' }}
/>
</div>
</div>
<Table<ClosingOutgoingSapronak>
data={
isResponseSuccess(outgoingSapronaks)
? outgoingSapronaks?.data
: []
}
columns={outgoingSapronaksColumns}
pageSize={tableFilterState.pageSize}
onPageSizeChange={setPageSize}
rowOptions={[10, 20, 50, 100]}
page={
isResponseSuccess(outgoingSapronaks)
? outgoingSapronaks?.meta?.page
: 0
}
totalItems={
isResponseSuccess(outgoingSapronaks)
? outgoingSapronaks?.meta?.total_results
: 0
}
onPageChange={setPage}
isLoading={isLoadingOutgoingSapronaks}
sorting={sorting}
setSorting={setSorting}
rowSelection={rowSelection}
setRowSelection={setRowSelection}
className={{
containerClassName: cn({
'w-full mb-20':
isResponseSuccess(outgoingSapronaks) &&
outgoingSapronaks?.data?.length === 0,
}),
}}
/>
</div>
</Collapse>
</Card>
);
};
export default ClosingOutgoingSapronaksTable;
@@ -0,0 +1,19 @@
import ClosingOverheadTable from '@/components/pages/closing/ClosingOverheadTable';
interface ClosingOverheadTabContentProps {
projectFlockId: number;
}
const ClosingOverheadTabContent = ({
projectFlockId,
}: ClosingOverheadTabContentProps) => {
return (
<div className='flex flex-col gap-4'>
{projectFlockId && (
<ClosingOverheadTable projectFlockId={projectFlockId} />
)}
</div>
);
};
export default ClosingOverheadTabContent;
@@ -0,0 +1,162 @@
import Card from '@/components/Card';
import Table, { TABLE_DEFAULT_STYLING } from '@/components/Table';
import { isResponseSuccess } from '@/lib/api-helper';
import { cn, formatCurrency, formatDate, formatNumber } from '@/lib/helper';
import { ClosingApi } from '@/services/api/closing';
import { Overhead, OverheadTotal } from '@/types/api/closing';
import { ColumnDef } from '@tanstack/react-table';
import { useMemo } from 'react';
import useSWR from 'swr';
interface ClosingOverheadTableProps {
type?: 'detail';
projectFlockId: number;
}
const ClosingOverheadTable = ({
type,
projectFlockId,
}: ClosingOverheadTableProps) => {
const { data: overhead, isLoading: isLoadingOverhead } = useSWR(
`${ClosingApi.basePath}/${projectFlockId}/overhead`,
() => ClosingApi.getOverhead(projectFlockId),
{
keepPreviousData: true,
}
);
// Helper function to create columns with footer support
const createColumns = (total?: OverheadTotal): ColumnDef<Overhead>[] => [
// Group untuk kolom tanpa footer
{
header: 'Nama Item',
accessorFn: (props) => props.item_name,
footer: 'Total Pengeluaran Overhead',
},
{
header: 'Satuan',
accessorFn: (props) => props.uom_name,
},
{
header: 'Budget Pengajuan',
footer: '',
columns: [
{
id: 'budget_quantity',
header: 'Jumlah',
accessorFn: (props) =>
props.budget_quantity ? formatNumber(props.budget_quantity) : '-',
footer: total ? () => formatNumber(total.budget_quantity) : '',
},
{
id: 'budget_unit_price',
header: 'Harga Satuan',
accessorFn: (props) =>
props.budget_unit_price
? formatCurrency(props.budget_unit_price)
: '-',
footer: '',
},
{
id: 'budget_total_amount',
header: 'Total',
accessorFn: (props) =>
props.budget_total_amount
? formatCurrency(props.budget_total_amount)
: '-',
footer: total ? () => formatCurrency(total.budget_total_amount) : '',
},
],
},
{
header: 'Realisasi',
footer: '',
columns: [
{
id: 'actual_date',
header: 'Tanggal',
accessorFn: (props) =>
props.actual_date
? formatDate(props.actual_date, 'DD MMM, YYYY')
: '-',
footer: '',
},
{
id: 'actual_quantity',
header: 'Jumlah',
accessorFn: (props) =>
props.actual_quantity ? formatNumber(props.actual_quantity) : '-',
footer: total ? () => formatNumber(total.actual_quantity) : '',
},
{
id: 'actual_unit_price',
header: 'Harga Satuan',
accessorFn: (props) =>
props.actual_unit_price
? formatCurrency(props.actual_unit_price)
: '-',
footer: '',
},
{
id: 'actual_total_amount',
header: 'Total',
accessorFn: (props) =>
props.actual_total_amount
? formatCurrency(props.actual_total_amount)
: '-',
footer: total ? () => formatCurrency(total.actual_total_amount) : '',
},
],
},
{
id: 'cost_per_bird',
header: 'Rp/Ekor',
accessorFn: (props) =>
props.cost_per_bird ? formatCurrency(props.cost_per_bird) : '-',
footer: total ? () => formatCurrency(total.cost_per_bird) : '',
},
];
const columns = useMemo(
() =>
isResponseSuccess(overhead)
? createColumns(overhead.data?.total)
: createColumns(),
[overhead]
);
return (
<>
<Card
title='Pengeluaran Overhead'
collapsible
defaultCollapsed={false}
className={{
wrapper: 'w-full',
body: 'p-4 shadow',
}}
>
<Table<Overhead>
data={
isResponseSuccess(overhead) ? (overhead.data?.overheads ?? []) : []
}
columns={columns}
className={{
containerClassName: 'my-4',
headerColumnClassName: cn(
TABLE_DEFAULT_STYLING.headerColumnClassName,
'whitespace-nowrap'
),
}}
renderFooter={
isResponseSuccess(overhead)
? overhead.data?.overheads.length > 0
: false
}
/>
</Card>
</>
);
};
export default ClosingOverheadTable;
@@ -0,0 +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';
interface ClosingSapronakCalculationTabContentProps {
projectFlockId?: number;
}
const ClosingSapronakCalculationTabContent = ({
projectFlockId,
}: ClosingSapronakCalculationTabContentProps) => {
return (
<div className='flex flex-col gap-4'>
{projectFlockId && (
<>
<ClosingSapronakCalculationTable projectFlockId={projectFlockId} />
</>
)}
</div>
);
};
export default ClosingSapronakCalculationTabContent;
@@ -0,0 +1,221 @@
'use client';
import Card from '@/components/Card';
import Table from '@/components/Table';
import { cn, formatCurrency, formatNumber } from '@/lib/helper';
import {
RowSapronakCalculation,
TotalSapronakCalculation,
} from '@/types/api/closing';
import { ColumnDef } from '@tanstack/react-table';
import { useMemo } from 'react';
import useSWR from 'swr';
import { ClosingApi } from '@/services/api/closing';
import { isResponseSuccess } from '@/lib/api-helper';
interface ClosingSapronakCalculationTableProps {
type?: 'detail';
projectFlockId: number;
}
const ClosingSapronakCalculationTable = ({
type,
projectFlockId,
}: ClosingSapronakCalculationTableProps) => {
const { data: sapronakCalculation, isLoading } = useSWR(
`/closing/sapronak-calculation/${projectFlockId}`,
() => ClosingApi.getPerhitunganSapronak(projectFlockId),
{
keepPreviousData: true,
}
);
// Helper function to create columns with footer support
const createColumns = (
total?: TotalSapronakCalculation
): ColumnDef<RowSapronakCalculation>[] => [
{
header: 'Tanggal',
accessorKey: 'tanggal',
cell: (props) => (props.getValue() as string) || '-',
footer: 'Total',
},
{
header: 'No. Referensi',
accessorKey: 'no_referensi',
cell: (props) => (props.getValue() as string) || '-',
footer: '',
},
{
header: 'QTY Masuk',
accessorKey: 'qty_masuk',
cell: (props) => formatNumber(props.getValue() as number),
footer: total
? () => (
<div className='font-semibold text-gray-900'>
{formatNumber(total.qty_masuk)}
</div>
)
: '',
},
{
header: 'QTY Keluar',
accessorKey: 'qty_keluar',
cell: (props) => formatNumber(props.getValue() as number),
footer: total
? () => (
<div className='font-semibold text-gray-900'>
{formatNumber(total.qty_keluar)}
</div>
)
: '',
},
{
header: 'QTY Pakai',
accessorKey: 'qty_pakai',
cell: (props) => formatNumber(props.getValue() as number),
footer: total
? () => (
<div className='font-semibold text-gray-900'>
{formatNumber(total.qty_pakai)}
</div>
)
: '',
},
{
header: 'Uraian',
accessorKey: 'uraian',
cell: (props) => (props.getValue() as string) || '-',
footer: '',
},
{
header: 'Kategori Produk',
accessorKey: 'kategori_produk',
cell: (props) => (props.getValue() as string) || '-',
footer: '',
},
{
header: 'Harga Beli/Qty (Rp)',
accessorKey: 'harga_beli_per_qty',
cell: (props) => formatCurrency(props.getValue() as number),
footer: total
? () => (
<div className='font-semibold text-gray-900'>
{formatCurrency(total.harga_beli_per_qty)}
</div>
)
: '',
},
{
header: 'Total Harga (Rp)',
accessorKey: 'total_harga',
cell: (props) => formatCurrency(props.getValue() as number),
footer: total
? () => (
<div className='font-semibold text-gray-900'>
{formatCurrency(total.total_harga)}
</div>
)
: '',
},
{
header: 'Keterangan',
accessorKey: 'keterangan',
cell: (props) => (props.getValue() as string) || '-',
footer: '',
},
];
// Memoize columns untuk setiap kategori
const docBroilerColumns = useMemo(
() =>
isResponseSuccess(sapronakCalculation)
? createColumns(sapronakCalculation.data?.doc_broiler.total)
: createColumns(),
[sapronakCalculation]
);
const ovkColumns = useMemo(
() =>
isResponseSuccess(sapronakCalculation)
? createColumns(sapronakCalculation.data?.ovk.total)
: createColumns(),
[sapronakCalculation]
);
const pakanColumns = useMemo(
() =>
isResponseSuccess(sapronakCalculation)
? 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>
<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='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>
</>
)}
</div>
);
};
export default ClosingSapronakCalculationTable;
@@ -0,0 +1,26 @@
'use client';
import ClosingIncomingSapronaksTable from '@/components/pages/closing/ClosingIncomingSapronaksTable';
import ClosingOutgoingSapronaksTable from '@/components/pages/closing/ClosingOutgoingSapronaksTable';
interface ClosingSapronakTableProps {
projectFlockId?: number;
}
const ClosingSapronakTabContent = ({
projectFlockId,
}: ClosingSapronakTableProps) => {
return (
<div className='flex flex-col gap-4'>
{projectFlockId && (
<>
<ClosingIncomingSapronaksTable projectFlockId={projectFlockId} />
<ClosingOutgoingSapronaksTable projectFlockId={projectFlockId} />
</>
)}
</div>
);
};
export default ClosingSapronakTabContent;
@@ -0,0 +1,299 @@
'use client';
import { ChangeEventHandler, useEffect, useState } from 'react';
import useSWR from 'swr';
import { CellContext, ColumnDef, SortingState } from '@tanstack/react-table';
import { Icon } from '@iconify/react';
import Table from '@/components/Table';
import DebouncedTextInput from '@/components/input/DebouncedTextInput';
import Button from '@/components/Button';
import SelectInput, {
OptionType,
useSelect,
} from '@/components/input/SelectInput';
import RowDropdownOptions from '@/components/table/RowDropdownOptions';
import RowCollapseOptions from '@/components/table/RowCollapseOptions';
import RowOptionsMenuWrapper from '@/components/table/RowOptionsMenuWrapper';
import { cn, formatCurrency, formatDate } from '@/lib/helper';
import { isResponseSuccess } from '@/lib/api-helper';
import { useTableFilter } from '@/services/hooks/useTableFilter';
import { LocationApi } from '@/services/api/master-data';
import { Location } from '@/types/api/master-data/location';
import { ClosingApi } from '@/services/api/closing';
import { Closing } from '@/types/api/closing';
const PROJECT_STATUS_OPTIONS = [
{
value: 1,
label: 'Pengajuan',
},
{
value: 2,
label: 'Aktif',
},
];
const RowOptionsMenu = ({
type = 'dropdown',
props,
}: {
type: 'dropdown' | 'collapse';
props: CellContext<Closing, unknown>;
}) => {
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>
</div>
</RowOptionsMenuWrapper>
);
};
const ClosingsTable = () => {
const {
state: tableFilterState,
updateFilter,
setPage,
setPageSize,
toQueryString: getTableFilterQueryString,
} = useTableFilter({
initial: {
search: '',
nameSort: '',
transactionDate: '',
realizationDate: '',
locationId: '',
projectStatus: '',
userId: '',
},
paramMap: {
page: 'page',
pageSize: 'limit',
nameSort: 'sort_name',
transactionDate: 'transaction_date',
realizationDate: 'realization_date',
locationId: 'location_id',
projectStatus: 'project_status',
userId: 'user_id',
},
});
const { data: closings, isLoading: isLoadingClosings } = useSWR(
`${ClosingApi.basePath}${getTableFilterQueryString()}`,
ClosingApi.getAllFetcher
);
const [sorting, setSorting] = useState<SortingState>([]);
const [rowSelection, setRowSelection] = useState<Record<string, boolean>>({});
const closingsColumns: ColumnDef<Closing>[] = [
{
header: '#',
cell: (props) => props.row.index + 1,
},
{
accessorKey: 'location_name',
header: 'Lokasi',
},
{
accessorKey: 'project_category',
header: 'Kategori',
},
{
accessorKey: 'period',
header: 'Periode',
},
{
accessorKey: 'closing_date',
header: 'Periode',
cell: (props) =>
formatDate(props.row.original.closing_date, 'DD MMM YYYY'),
},
{
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',
},
{
header: 'Aksi',
cell: (props) => {
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 - 3;
return (
<>
{currentPageSize > 3 && (
<RowDropdownOptions isLast2Rows={isLast2Rows}>
<RowOptionsMenu type='dropdown' props={props} />
</RowDropdownOptions>
)}
{currentPageSize <= 3 && (
<RowCollapseOptions>
<RowOptionsMenu type='collapse' props={props} />
</RowCollapseOptions>
)}
</>
);
},
},
];
const {
setInputValue: setLocationInputValue,
options: locationOptions,
isLoadingOptions: isLoadingLocationOptions,
} = useSelect<Location>(LocationApi.basePath, 'id', 'name');
const [selectedLocation, setSelectedLocation] = useState<OptionType | null>(
null
);
const locationChangeHandler = (val: OptionType | OptionType[] | null) => {
setSelectedLocation(val as OptionType);
updateFilter(
'locationId',
val ? ((val as OptionType).value as string) : ''
);
};
const [selectedProjectStatus, setSelectedProjectStatus] =
useState<OptionType | null>(null);
const projectStatusChangeHandler = (
val: OptionType | OptionType[] | null
) => {
setSelectedProjectStatus(val as OptionType);
updateFilter(
'projectStatus',
val ? ((val as OptionType).value as string) : ''
);
};
const searchChangeHandler: ChangeEventHandler<HTMLInputElement> = (e) => {
updateFilter('search', e.target.value);
};
// track sorting
useEffect(() => {
const isNameSorted = sorting.find((sortItem) => sortItem.id === 'name');
if (!isNameSorted) {
updateFilter('nameSort', '');
} else {
updateFilter('nameSort', isNameSorted.desc ? 'desc' : 'asc');
}
}, [sorting, updateFilter]);
return (
<>
<div className='w-full p-0 sm:p-4'>
<div className='flex flex-col gap-2 mb-4'>
<div className='flex flex-col gap-2 mb-4'>
<div className='w-full flex flex-col sm:flex-row justify-end items-end sm:items-center gap-4'>
<DebouncedTextInput
name='search'
placeholder='Cari Closing'
value={tableFilterState.search}
onChange={searchChangeHandler}
className={{ wrapper: 'sm:max-w-3xs' }}
/>
</div>
<div className='grid grid-cols-12 justify-end gap-2'>
<SelectInput
label='Lokasi'
options={locationOptions}
isLoading={isLoadingLocationOptions}
value={selectedLocation}
onChange={locationChangeHandler}
onInputChange={setLocationInputValue}
isClearable
className={{
wrapper: 'col-span-12 sm:col-span-6',
}}
/>
<SelectInput
label='Status Project'
placeholder='Pilih Status'
options={PROJECT_STATUS_OPTIONS}
value={selectedProjectStatus}
onChange={projectStatusChangeHandler}
isClearable
className={{
wrapper: 'col-span-12 sm:col-span-6',
}}
/>
</div>
</div>
</div>
<Table<Closing>
data={isResponseSuccess(closings) ? closings?.data : []}
columns={closingsColumns}
pageSize={tableFilterState.pageSize}
onPageSizeChange={setPageSize}
rowOptions={[10, 20, 50, 100]}
page={isResponseSuccess(closings) ? closings?.meta?.page : 0}
totalItems={
isResponseSuccess(closings) ? closings?.meta?.total_results : 0
}
onPageChange={setPage}
isLoading={isLoadingClosings}
sorting={sorting}
setSorting={setSorting}
rowSelection={rowSelection}
setRowSelection={setRowSelection}
className={{
containerClassName: cn({
'w-full mb-20':
isResponseSuccess(closings) && closings?.data?.length === 0,
}),
}}
/>
</div>
</>
);
};
export default ClosingsTable;

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