Compare commits

...

273 Commits

Author SHA1 Message Date
GitLab Deploy Bot b62427c5f4 update Dockerfile 2025-11-09 16:08:22 +07:00
GitLab Deploy Bot 73d2de6dfb edit Dockerfile 2025-11-09 15:21:15 +07:00
GitLab Deploy Bot d3cc38aed5 edit Dockerfile 2025-11-09 15:15:26 +07:00
GitLab Deploy Bot 66b6579f27 edit .gitlab-ci 2025-11-09 15:01:10 +07:00
GitLab Deploy Bot 29ff1bb50a edit .gitlab-ci 2025-11-09 14:53:49 +07:00
GitLab Deploy Bot 52e8fb4a3b build with tag docker 2025-11-09 14:44:58 +07:00
GitLab Deploy Bot 8a11c176aa build docker via gitlab 2025-11-09 14:21:58 +07:00
Adnan Zahir d679c9f278 Merge branch 'fix/ISSUE-236/table-dropdown-issue' into 'development'
Fix: LTI Issue #236

See merge request mbugroup/lti-web-client!41
2025-11-03 09:08:21 +07:00
ValdiANS 0ae4fe0831 chore: format code using prettier 2025-11-01 15:58:47 +07:00
ValdiANS f01dae5f97 chore: add format script 2025-11-01 15:58:03 +07:00
ValdiANS 42b4206e66 chore: install prettier 2025-11-01 15:53:37 +07:00
ValdiANS 46572fd992 chore: update add button styling 2025-11-01 15:36:21 +07:00
ValdiANS b2540f1d43 chore: use RowOptionsMenuWrapper 2025-11-01 15:36:11 +07:00
ValdiANS ad10ffbba3 chore: set min width for RowCollapseOptions 2025-11-01 15:35:49 +07:00
ValdiANS 8a3c7d35ec chore: update add button styling and copywriting 2025-11-01 15:35:34 +07:00
ValdiANS d853b43e17 fix: use RowOptionsMenuWrapper component for RowOptionsMenu 2025-11-01 15:31:11 +07:00
ValdiANS e6187555ce chore: create RowOptionsMenuWrapper component 2025-11-01 15:26:25 +07:00
ValdiANS bba8fb15e5 chore: change a element to button 2025-11-01 15:24:52 +07:00
Adnan Zahir e708911429 Merge branch 'fix/FE/US-82/approval-workflow-steps-component' into 'development'
[FIX/FE][US#82] Rework Approval Steps component

See merge request mbugroup/lti-web-client!40
2025-10-30 11:04:04 +07:00
ValdiANS 79cfcad026 chore(FE-91): set formatCurrency default currency to indonesian currency 2025-10-30 11:03:22 +07:00
ValdiANS 37afcc76c3 Merge branch 'development' into fix/FE/US-82/approval-workflow-steps-component 2025-10-30 10:50:57 +07:00
ValdiANS f7eb89c113 feat(FE-91): create constant type file 2025-10-30 10:49:50 +07:00
ValdiANS c9c343b840 chore(FE-91): create BaseGroupedApproval, Approvals, and GroupedApprovals api types 2025-10-30 10:49:36 +07:00
ValdiANS 5c3b1c489f chore(FE-91): set color for step-warning 2025-10-30 10:48:37 +07:00
ValdiANS dd3a0079db chore(FE-91): set formatNumber locale to id-ID as default 2025-10-30 10:48:18 +07:00
ValdiANS bce58c585d feat(FE-91): create approval-line config file 2025-10-30 10:47:51 +07:00
ValdiANS b720c1411b chore(FE-91): make warning step icon glow 2025-10-30 10:47:29 +07:00
ValdiANS 82c1645d92 chore(FE-91): rework ApprovalSteps and create helper function for formatting approval workflow 2025-10-30 10:45:41 +07:00
Adnan Zahir d0d201bf3a Merge branch 'feat/FE/US-77/transfer-to-laying' into 'development'
[FIX/FE][US#77] Transfer to Laying

See merge request mbugroup/lti-web-client!36
2025-10-29 15:07:40 +07:00
ValdiANS f88af89562 Merge branch 'development' into feat/FE/US-77/transfer-to-laying 2025-10-28 09:48:41 +07:00
Adnan Zahir 883d68032a Merge branch 'feat/FE/US-75/chick-in-doc' into 'development'
[FEAT/FE][US#75] Chick In DOC

See merge request mbugroup/lti-web-client!34
2025-10-27 17:23:06 +07:00
Rivaldi A N S e45a9ba5e4 Merge branch 'dev/randy' into 'feat/FE/US-75/chick-in-doc'
[FIX/FE][US#75/TASK#94] Resolve merge conflict from development branch

See merge request mbugroup/lti-web-client!35
2025-10-27 06:14:27 +00:00
ValdiANS de7076e513 Merge branch 'development' into feat/FE/US-77/transfer-to-laying 2025-10-27 13:07:09 +07:00
randy-ar 6706f361d8 refactor(FE): change number input to reuseablecomponent from ui-component 2025-10-27 13:03:38 +07:00
randy-ar 4bd6fe8c35 fix(FE-86): resolve merge conflict 2025-10-27 11:27:08 +07:00
randy-ar cbb4f7421e fix(FE-86): fixing error null value 2025-10-27 10:58:49 +07:00
Rivaldi A N S 459605f133 Merge branch 'dev/randy' into 'feat/FE/US-75/chick-in-doc'
[FEAT/FE][US#75/TASK#92-93-94-105] Slicing UI detail, create and edit Chickin and integrate with API

See merge request mbugroup/lti-web-client!33
2025-10-27 03:27:19 +00:00
randy-ar a65d00edc8 fix(FE): fixing pipeline run error 2025-10-25 17:01:02 +07:00
randy-ar 1e9d02b4b7 feat(FE-92-94): Slicing UI detail chickin & refactor number input chickin form 2025-10-25 16:27:15 +07:00
randy-ar f0f6ec53cb refactor(FE-84-87) refactor checkbox using reuseable component checkboxinput 2025-10-25 13:58:46 +07:00
Adnan Zahir 48c31373bf Merge branch 'feat/FE/US-76/daily-recording-growing' into 'development'
[FEAT/FE][US#76] Daily Recording Growing

See merge request mbugroup/lti-web-client!31
2025-10-25 13:37:39 +07:00
randy-ar 4f3dfb4221 Merge branch 'development' of https://gitlab.com/mbugroup/lti-web-client into dev/randy 2025-10-25 06:16:15 +07:00
randy-ar a13a51a16f fix(FE-92-93-105): adding input note and quantity for create/edit chickin 2025-10-25 06:15:29 +07:00
Rivaldi A N S fa21fe8da4 Merge branch 'feat/FE/US-76/TASK-114-129-136-slicing-ui-and-validation-create-edit-daily-recording-growing-form' into 'feat/FE/US-76/daily-recording-growing'
[FEAT/FE][US#76/TASK#114-129-130-131-136] Slicing UI Feature Daily Recording Growing

See merge request mbugroup/lti-web-client!32
2025-10-24 03:03:12 +00:00
rstubryan 8337fa5f55 fix(merge): resolve merge conflict 2025-10-24 09:53:04 +07:00
Adnan Zahir 54bff12e1a Merge branch 'feat/FE/US-75/chick-in-doc' into 'development'
[FEAT/FE][US#75] Chick In DOC

See merge request mbugroup/lti-web-client!30
2025-10-24 09:35:56 +07:00
Adnan Zahir aa17143532 Merge branch 'feat/FE/US-76/TASK-114-129-136-slicing-ui-and-validation-create-edit-daily-recording-growing-form' into 'feat/FE/US-76/daily-recording-growing'
[FEAT/FE][US#76/TASK#114-129-130-131-136] Slicing UI Feature Daily Recording Growing

See merge request mbugroup/lti-web-client!29
2025-10-24 09:34:51 +07:00
rstubryan 4381e42aaf refactor(FE-114): update input handling for vaccination stock, mortality count, and feed stock with improved parsing and formatting 2025-10-24 09:24:28 +07:00
Rivaldi A N S 24ed2cccbe Merge branch 'dev/randy' into 'feat/FE/US-75/chick-in-doc'
[FEAT/FE][US#75/TASK#92-93-106] Slicing UI list, create, and edit Chickin DOC

See merge request mbugroup/lti-web-client!24
2025-10-24 02:18:23 +00:00
rstubryan a9b0c084f8 refactor(FE-114): update input handling for vaccination stock, mortality count, and feed stock with improved parsing and formatting 2025-10-24 09:15:01 +07:00
rstubryan 16823fa84a refactor(FE-114): implement custom handlers for vaccination stock and mortality count input parsing 2025-10-24 09:00:29 +07:00
randy-ar 51bce1a2c7 feat(FE-86-88): Adding reject button and integrate with approval api 2025-10-23 20:23:25 +07:00
rstubryan e76d881d8a refactor(FE-114): add foreign key fields to enhance data relationships in project-flock type definitions 2025-10-23 20:00:42 +07:00
Rivaldi A N S b2044ac7bd Merge branch 'feat/FE/US-77/TASK-140-slicing-transfer-to-laying-edit-form' into 'feat/FE/US-77/transfer-to-laying'
[FEAT/FE][US#77/TASK#140] Slicing Transfer to Laying Edit Form

See merge request mbugroup/lti-web-client!27
2025-10-23 11:48:38 +00:00
randy-ar 8a467c2d65 fix(FE-92-93-105-106): fixing chickin form, after submit event and chickin modal trigger 2025-10-23 18:43:26 +07:00
ValdiANS d1d152ef5a feat(FE-140): create Edit Transfer to Laying page 2025-10-23 17:50:18 +07:00
Rivaldi A N S 82950b0ec0 Merge branch 'feat/FE/US-77/TASK-141-slicing-detail-page-for-transfer-to-laying' into 'feat/FE/US-77/transfer-to-laying'
[FEAT/FE][US#77/TASK#141] Slicing detail page for Transfer to Laying

See merge request mbugroup/lti-web-client!26
2025-10-23 10:37:31 +00:00
ValdiANS 3110b96305 feat(FE-141): add approve and reject method 2025-10-23 17:34:52 +07:00
ValdiANS 7e44226a6d feat(FE-141): add approve and reject functionality in Transfer to Laying Detail Page 2025-10-23 17:34:14 +07:00
rstubryan 3f76cb58fe refactor(FE-114): improve alignment and styling of checkbox inputs in RecordingForm 2025-10-23 17:15:17 +07:00
rstubryan 3cf8f4c89b refactor(FE-114): enhance numeric input handling for chicken weight and count with improved formatting 2025-10-23 16:49:32 +07:00
rstubryan 90ae7c469a refactor(FE-114): swap thousand and decimal separators for improved usability 2025-10-23 16:48:55 +07:00
rstubryan ae967c5ddb refactor(FE-114): integrate inputmask for enhanced numeric input handling and validation 2025-10-23 16:00:24 +07:00
rstubryan e801ba08ad chore(FE-114): add inputmask and its type definitions to package.json 2025-10-23 15:09:39 +07:00
rstubryan e6f5b2493b refactor(FE-Storyless): update input components to include consistent background styling 2025-10-23 13:51:34 +07:00
rstubryan 5f677f5076 Merge branch 'development' of gitlab.com:mbugroup/lti-web-client into feat/FE/US-76/TASK-114-129-136-slicing-ui-and-validation-create-edit-daily-recording-growing-form 2025-10-23 13:50:23 +07:00
rstubryan 2de32dc944 refactor(FE-114): simplify CheckboxInput component and enhance styling options 2025-10-23 13:49:43 +07:00
ValdiANS ab534e203a Merge branch 'development' into feat/FE/US-77/TASK-141-slicing-detail-page-for-transfer-to-laying 2025-10-23 13:40:24 +07:00
randy-ar eaf41805d7 feat(FE-92-93-105-106): slicing ui chickin DOC and integrate with API 2025-10-23 13:30:27 +07:00
Adnan Zahir 631ebb9346 Merge branch 'feat/husky-setup' into 'development'
[FEAT/FE] Husky Setup

See merge request mbugroup/lti-web-client!23
2025-10-23 13:25:41 +07:00
rstubryan 7e53743b07 refactor(FE-114): remove FieldMessage component usage and streamline error message handling in form inputs 2025-10-23 13:14:16 +07:00
ValdiANS 70e1aca6c7 feat: create husky pre-commit file 2025-10-23 13:13:34 +07:00
ValdiANS d0d323954b feat: install husky 2025-10-23 13:10:03 +07:00
Rivaldi A N S d1c24bc486 Merge branch 'feat/FE/US-77/TASK-147-slicing-list-page-of-transfer-to-laying' into 'feat/FE/US-77/transfer-to-laying'
[FEAT/FE][US#77/TASK#147] Slicing List page of Transfer to Laying

See merge request mbugroup/lti-web-client!22
2025-10-23 06:06:03 +00:00
ValdiANS f998d32b0a chore(FE-147): add ApproveAction type 2025-10-23 12:55:31 +07:00
ValdiANS 3226b22dfb chore(FE-147): use dummy data 2025-10-23 12:55:12 +07:00
ValdiANS 9a51b2876f chore(FE-113,140,141): adjust back button link 2025-10-23 12:54:46 +07:00
ValdiANS ab9fbc9032 feat(FE-147): create TransferToLayingsTable component 2025-10-23 12:54:02 +07:00
ValdiANS d2f24723fc chore(FE-141): set dummy data for Transfer to Laying detail page 2025-10-23 12:53:41 +07:00
ValdiANS 5e710a792f chore(FE-147): set moment locale to 'id' globally 2025-10-23 12:52:51 +07:00
ValdiANS 3c8bdfbdac chore(FE-147): set generic when using getByPath function 2025-10-23 12:52:29 +07:00
ValdiANS 204369e0fe feat(FE-147): add CheckboxInput component 2025-10-23 12:51:39 +07:00
ValdiANS 1e2ea79a6a chore(FE-147): add close button for MainDrawer 2025-10-23 12:51:20 +07:00
ValdiANS c24c0817ae chore(FE-147): add rowSelection and setRowSelection props 2025-10-23 11:53:35 +07:00
ValdiANS e53325cdc5 feat(FE-147): show Transfer to Laying table 2025-10-23 11:53:12 +07:00
rstubryan 6687f4af98 feat(FE-Storyless): add Badge component with customizable variants, colors, and sizes 2025-10-23 11:18:57 +07:00
rstubryan 575a317eed refactor(FE-Storyless): update input components to ensure consistent background styling 2025-10-22 15:31:59 +07:00
rstubryan bdb3ab1a50 refactor(FE-114): refactor card native to card component 2025-10-22 14:49:38 +07:00
rstubryan f486a659d0 feat(FE-114): add Card component with customizable layout and styling options 2025-10-22 14:49:05 +07:00
rstubryan 58b4204aab refactor(FE-62): enhance MovementForm by integrating NumberInput for delivery cost fields and improving layout 2025-10-22 14:10:35 +07:00
rstubryan c249585bc2 refactor(FE-114): enhance form UI by adding required field indicators for multiple inputs 2025-10-22 13:55:12 +07:00
rstubryan 9c114628c7 refactor(FE-114,136): improve form validation handling and set touched state asynchronously 2025-10-22 10:54:20 +07:00
rstubryan b35d513e44 refactor(FE-114): update flock accessor key in RecordingTable component 2025-10-22 09:50:09 +07:00
rstubryan a904c35b7f refactor(FE-114): simplify project flock types and update flock reference in recording 2025-10-22 09:41:00 +07:00
rstubryan 2e595b5e86 refactor(FE-114): update import paths from flock to production for recording components 2025-10-22 09:11:23 +07:00
rstubryan 46fa3e57cd Merge branch 'development' of gitlab.com:mbugroup/lti-web-client into feat/FE/US-76/TASK-114-129-136-slicing-ui-and-validation-create-edit-daily-recording-growing-form 2025-10-21 16:10:40 +07:00
Rivaldi A N S 79b6d6917d Merge branch 'feat/FE/US-77/TASK-113-slicing-transfer-to-laying-create-form' into 'feat/FE/US-77/transfer-to-laying'
[FEAT/FE][US#77/TASK#113] Slicing Transfer to Laying Create Form

See merge request mbugroup/lti-web-client!21
2025-10-21 09:10:07 +00:00
ValdiANS 9f24d22a2c feat(FE-113): create FlockWithKandangs type 2025-10-21 15:54:50 +07:00
ValdiANS 06f1d3f6a4 fix(FE-113): fix merge error 2025-10-21 15:54:25 +07:00
ValdiANS e29613a37e chore(FE-113): add status field 2025-10-21 15:54:11 +07:00
ValdiANS 6e6675d0a7 feat(FE-113): change title and add Transfer ke Laying link 2025-10-21 15:37:25 +07:00
ValdiANS 32d4c0268f Merge branch 'development' into feat/FE/US-77/TASK-113-slicing-transfer-to-laying-create-form 2025-10-21 15:29:10 +07:00
rstubryan 2ab26153fd fix(resolve): fix resolve mismatch conflict path on merge 2025-10-21 15:24:55 +07:00
ValdiANS a29bbc9a42 chore(FE-113): comment Inventory Product link 2025-10-21 15:23:13 +07:00
rstubryan e7e0e308c7 fix(resolve): fix resolve mismatch conflict path on merge 2025-10-21 15:20:15 +07:00
ValdiANS 1ade8f8a38 Merge branch 'development' into feat/FE/US-77/TASK-113-slicing-transfer-to-laying-create-form 2025-10-21 15:18:34 +07:00
Adnan Zahir 791e8e787c Merge branch 'feat/FE/US-74/flock-request' into 'development'
[FEAT/FE][US#74/TASK#84-85-86-87-88-89-102] Project Flock

See merge request mbugroup/lti-web-client!20
2025-10-21 15:17:06 +07:00
ValdiANS a2c43a7f1e feat(FE-141): create Transfer to Laying Detail page 2025-10-21 15:12:09 +07:00
rstubryan 12202c2021 fix(resolve): fix resolve mismatch conflict path on merge 2025-10-21 15:10:57 +07:00
ValdiANS 4127075b13 feat(FE-113): create Transfer to Laying Create Form Schema 2025-10-21 15:09:33 +07:00
ValdiANS d9fa685ae6 feat(FE-113): create Transfer to Laying Create Form 2025-10-21 15:08:11 +07:00
ValdiANS 2f4daea253 feat(FE-113): create API Service for Transfer to Laying 2025-10-21 15:07:51 +07:00
ValdiANS bac72b8eb3 feat(FE-113): create Transfer to Laying type 2025-10-21 15:06:39 +07:00
ValdiANS 5af9c3ee27 chore(FE-113): change api route for getting user info to /auth/sso/userinfo 2025-10-21 15:06:10 +07:00
ValdiANS 1a76913f3f chore(FE-113): set vertical-align to top 2025-10-21 15:05:36 +07:00
ValdiANS 8b403a4208 feat(FE-113): create useSelect hook 2025-10-21 15:01:48 +07:00
ValdiANS 0bab704163 chore(FE-113): create getByPath helper function 2025-10-21 15:01:19 +07:00
ValdiANS d550dcbf48 feat(FE-141): create layout for detail Transfer to Laying route 2025-10-21 14:57:32 +07:00
ValdiANS 7fdbfe6dfb feat(FE-113): create Add Transfer to Laying page 2025-10-21 14:56:58 +07:00
ValdiANS 4e6d2088e1 feat(FE-147): create Transfer to Laying list page 2025-10-21 14:55:37 +07:00
rstubryan 67b180bf7c fix(resolve): fix resolve conflict 2025-10-21 14:36:27 +07:00
Rivaldi A N S 7853899486 Merge branch 'dev/randy' into 'feat/FE/US-74/flock-request'
[FEAT/FE][US#74/TASK#84-85-86-87-88-89-102] Create Feature Project Flocks and Feature Master Data Flocks

See merge request mbugroup/lti-web-client!13
2025-10-21 07:24:58 +00:00
randy-ar 9a04724095 fix(FE-86): fixing approve button and delete button 2025-10-21 14:11:08 +07:00
rstubryan 831995e8e4 refactor(FE-114): translate RecordingForm titles and table headers to Indonesian 2025-10-21 13:59:26 +07:00
randy-ar c8cdb3e772 fix(FE-88): fix error build 2025-10-21 13:22:49 +07:00
randy-ar e5b3af3239 fix(FE-88): fix project flock data types 2025-10-21 13:19:50 +07:00
rstubryan 0740f2d094 refactor(FE-114): ensure fields are marked as touched on change for better validation handling 2025-10-21 13:01:56 +07:00
rstubryan 25a97e34c7 refactor(FE-114): use React's useId hook for generating unique checkbox IDs in CheckboxInput 2025-10-21 11:54:57 +07:00
rstubryan 1ee1cf9ea9 refactor(FE-62): update errorMessage handling and setFieldTouched for form fields 2025-10-21 11:49:55 +07:00
randy-ar e4a1138d8d fix(FE-86-87-88) Hapus tombol edit di index, tambah tombol approve dan delete di detail, dan hit endpoint approve yang udah ada di hoppscocth 2025-10-21 11:37:33 +07:00
rstubryan 41bb05413c feat(FE-62): replace native checkboxes with CheckboxInput component in MovementForm 2025-10-21 11:26:15 +07:00
rstubryan c746bd94b2 Merge branch 'development' of gitlab.com:mbugroup/lti-web-client into feat/FE/US-76/TASK-114-129-136-slicing-ui-and-validation-create-edit-daily-recording-growing-form 2025-10-21 10:42:04 +07:00
rstubryan acea3a3063 refactor(FE-114): replace native checkboxes with CheckboxInput component in RecordingForm 2025-10-21 10:38:26 +07:00
rstubryan b269728ecd feat(FE-114): add CheckboxInput component with customizable props and styling 2025-10-21 10:38:07 +07:00
Adnan Zahir e7a861d8a1 Merge branch 'chore/CI/ignore-build-script' into 'development'
chore(CI): added build-filter.sh to only deploy master and development branch

See merge request mbugroup/lti-web-client!19
2025-10-21 10:21:03 +07:00
Adnan Zahir 1a5a76c0f1 chore(CI): added build-filter.sh to only deploy master and development branch 2025-10-21 10:20:09 +07:00
randy-ar 838d7277c3 fix(FE) resolve merge conflict 2025-10-21 10:19:03 +07:00
randy-ar 1672705464 fix(FE-88-89) adjust category flock dengan API backend & set disabled input period 2025-10-21 10:14:17 +07:00
rstubryan 9ef4484fb3 Merge remote-tracking branch 'origin/feat/FE/US-76/TASK-114-129-136-slicing-ui-and-validation-create-edit-daily-recording-growing-form' into feat/FE/US-76/TASK-114-129-136-slicing-ui-and-validation-create-edit-daily-recording-growing-form 2025-10-21 09:55:21 +07:00
rstubryan 645668e1f9 refactor(FE-114): enhance body weight calculations in RecordingForm with auto-update for average weight 2025-10-21 09:55:12 +07:00
rstubryan fb29cea8d2 refactor(FE-114): enhance body weight calculations in RecordingForm with auto-update for average weight 2025-10-21 09:54:28 +07:00
rstubryan 1ecdff855e refactor(FE-114): enhance NumberInput component with improved styling and disabled state handling 2025-10-21 09:54:14 +07:00
rstubryan 7c6e079f56 refactor(FE-114): improve data handling in RecordingForm for numeric fields 2025-10-21 09:33:31 +07:00
rstubryan 41f8067727 refactor(FE-114): enhance NumberInput component with improved props and validation handling 2025-10-21 09:33:17 +07:00
Adnan Zahir f733b0750a Merge branch 'feat/FE/US-35/stock-transfer' into 'development'
[FEAT/FE][US#35/TASK#61-62-63-64-65] Transfer Stock

See merge request mbugroup/lti-web-client!18
2025-10-20 20:56:42 +07:00
rstubryan 83d31b7047 refactor(FE-114): remove unnecessary FieldMessage component from checkbox 2025-10-20 20:20:39 +07:00
rstubryan 966e0886e1 Merge remote-tracking branch 'origin/feat/FE/US-76/TASK-114-129-136-slicing-ui-and-validation-create-edit-daily-recording-growing-form' into feat/FE/US-76/TASK-114-129-136-slicing-ui-and-validation-create-edit-daily-recording-growing-form 2025-10-20 20:19:51 +07:00
rstubryan a67d353bcb refactor(FE-114): integrate FieldMessage component for improved field feedback in checkboxes 2025-10-20 20:19:42 +07:00
rstubryan ac2f246988 refactor(FE-114): integrate FieldMessage component for improved field feedback in checkboxes 2025-10-20 20:00:43 +07:00
rstubryan e0ce571000 refactor(FE-114): streamline cost field validation messages and enhance layout with FieldMessage component 2025-10-20 18:54:31 +07:00
rstubryan 1bcfd9bbb4 feat(FE-Storyless): add FieldMessage component for consistent field feedback across inputs 2025-10-20 18:54:02 +07:00
Rivaldi A N S c561c47eae Merge branch 'dev/restu' into 'feat/FE/US-35/stock-transfer'
[FEAT/FE][US#35/TASK#61-62-63-64-65] Create Feature Transfer Stock

See merge request mbugroup/lti-web-client!14
2025-10-20 08:28:22 +00:00
rstubryan c3338d3e05 feat(FE-62): add button for document path in MovementForm with link functionality 2025-10-20 15:23:18 +07:00
rstubryan ba9ae07455 refactor(FE-114): improve validation messages and update layout for better responsiveness 2025-10-20 13:10:41 +07:00
rstubryan c64ff527dd Merge branch 'dev/restu' of gitlab.com:mbugroup/lti-web-client into feat/FE/US-76/TASK-114-129-136-slicing-ui-and-validation-create-edit-daily-recording-growing-form 2025-10-20 12:56:43 +07:00
rstubryan f27e34128e refactor(FE-62): update layout and remove unused delete confirmation in MovementForm 2025-10-20 12:03:58 +07:00
rstubryan c8db992b17 feat(FE-62,63,65): add document_path field to deliveries in MovementForm 2025-10-20 11:50:19 +07:00
rstubryan d76f897840 refactor(FE-62): update wrapper class names for improved layout in MovementForm 2025-10-20 11:32:35 +07:00
rstubryan 5e0cc3699f Merge branch 'dev/restu' of gitlab.com:mbugroup/lti-web-client into feat/FE/US-76/TASK-114-129-136-slicing-ui-and-validation-create-edit-daily-recording-growing-form 2025-10-20 10:46:21 +07:00
rstubryan 895b7afa25 refactor(FE-114): improve product filtering logic for location and flag validation 2025-10-20 10:38:10 +07:00
ValdiANS a088189ed1 chore(FE-140): add Produksi and Transfer ke Laying menu 2025-10-20 10:14:22 +07:00
ValdiANS 406cfad31a chore(FE-140): adjust border radius 2025-10-20 10:14:04 +07:00
rstubryan 6c9c0e1839 Merge branch 'development' of gitlab.com:mbugroup/lti-web-client into dev/restu 2025-10-20 10:10:30 +07:00
rstubryan eb02a8b6f7 refactor(storyless): update border class for consistent styling 2025-10-20 10:09:58 +07:00
rstubryan 73f379832c Merge branch 'development' of gitlab.com:mbugroup/lti-web-client into feat/FE/US-76/TASK-114-129-136-slicing-ui-and-validation-create-edit-daily-recording-growing-form 2025-10-20 10:09:18 +07:00
rstubryan 4233c19dc9 refactor(FE-114): rearrange code for better readability 2025-10-20 10:06:26 +07:00
Adnan Zahir 403765a2b5 Merge branch 'feat/FE/US-77/transfer-to-laying' into 'development'
[FEAT/FE][US#77] Transfer to Laying

See merge request mbugroup/lti-web-client!16
2025-10-20 10:03:03 +07:00
Rivaldi A N S d30d7328cf Merge branch 'feat/FE/US-77/TASK-113-slicing-transfer-to-laying-create-form' into 'feat/FE/US-77/transfer-to-laying'
[FEAT/FE][US#77/TASK#113] Slicing Transfer to Laying Create Form

See merge request mbugroup/lti-web-client!17
2025-10-20 02:57:58 +00:00
ValdiANS 376fa29f7e fix(FE-40): wrap master data detail with SuspenseHelper 2025-10-20 09:55:08 +07:00
rstubryan 16d72ebf6f feat(FE-114,136): integrate location selection and update flock handling in RecordingForm 2025-10-20 09:51:32 +07:00
Rivaldi A N S 52ad696178 Merge branch 'feat/FE/US-77/TASK-113-slicing-transfer-to-laying-create-form' into 'feat/FE/US-77/transfer-to-laying'
[FEAT/FE][US#77/TASK#113] Slicing Transfer to Laying create form

See merge request mbugroup/lti-web-client!15
2025-10-20 02:42:52 +00:00
ValdiANS 2b3aa9c3ee feat(FE-113): create permissionCheck helper function 2025-10-18 13:40:32 +07:00
ValdiANS 6fe85fac13 feat(FE-113): add Client, Permission, Role, and RoleWithPermission types 2025-10-18 13:40:08 +07:00
randy-ar 9964e1797a feat(FE-87): slicing ui multiple approval checkbox and approval modal confirmation 2025-10-18 12:58:18 +07:00
rstubryan e4f554bcd4 refactor(FE-114,136): update RecordingForm validation and input handling for feed and vaccination data 2025-10-18 12:25:04 +07:00
rstubryan c25b49c179 feat(FE-114): add NumberInput component and integrate into RecordingForm for enhanced numeric input handling 2025-10-18 11:39:18 +07:00
randy-ar a573551110 feat(FE-85-87-88): slicing ui and integrate api for search and edit 2025-10-18 10:46:47 +07:00
rstubryan 881e2bfc4a feat(FE-114,136): enhance product label display in RecordingForm with warehouse and stock information 2025-10-18 09:04:39 +07:00
rstubryan 474c2a1f7d Merge branch 'dev/restu' of gitlab.com:mbugroup/lti-web-client into feat/FE/US-76/TASK-114-129-136-slicing-ui-and-validation-create-edit-daily-recording-growing-form 2025-10-18 08:45:26 +07:00
rstubryan c4de085e11 feat(FE-62,63): enhance warehouse stock information display in MovementForm 2025-10-18 08:40:06 +07:00
rstubryan 0676411dd5 refactor(FE-62,65): enhance product quantity display and stock information in MovementForm 2025-10-17 19:23:19 +07:00
rstubryan f05d367a5d refactor(FE-65): enhance delivery cost validation and calculation in MovementForm 2025-10-17 18:51:35 +07:00
rstubryan edb5f30d6c refactor(FE-62): remove unused product fetching logic from MovementForm 2025-10-17 16:48:52 +07:00
rstubryan 7abe9b7dc6 refactor(FE-63,65): update Movement types and schema to include area and location for warehouses 2025-10-17 16:48:35 +07:00
rstubryan caf68d438f refactor(FE-114,136,137): update feed and vaccination fields to use IDs instead of names and add stock validation 2025-10-17 13:59:28 +07:00
rstubryan fa60f884c1 merge: resolve conflict 2025-10-17 13:18:34 +07:00
rstubryan c77968940e refactor(FE-114,136): update flock references to use ProjectFlock and adjust RecordingForm for new API 2025-10-17 13:16:54 +07:00
rstubryan cfb9b53b54 refactor(FE-63): simplify createMovementHandler by removing unnecessary payload checks 2025-10-17 10:13:14 +07:00
rstubryan caac9c20e6 refactor(FE-62): update MovementForm layout to improve responsiveness with grid system 2025-10-17 10:12:53 +07:00
rstubryan 8bf7603f66 refactor(FE-64): update MovementTable and TableRowOptions to conditionally show edit and delete options 2025-10-17 09:46:07 +07:00
rstubryan 8c662a5152 refactor(FE-65): update DeliveryObjectSchema to enforce minimum delivery costs of 1 2025-10-17 09:22:49 +07:00
randy-ar da92874a40 Merge branch 'feat/FE/US-74/flock-request' of https://gitlab.com/mbugroup/lti-web-client into dev/randy 2025-10-16 16:52:58 +07:00
randy-ar 5113bf4d3f feat(84-85-86-87-88-89-102): create feature project flocks and adjust master data flock feature 2025-10-16 16:49:44 +07:00
rstubryan 1bdec0c9ae refactor(FE-62,63): update MovementForm to handle 'detail' type with appropriate validations and stock checks 2025-10-16 16:46:33 +07:00
rstubryan 57dbcf3624 Merge remote-tracking branch 'origin/dev/restu' into dev/restu 2025-10-16 16:26:03 +07:00
rstubryan 501a68267e refactor(FE-63,63,65): enhance MovementForm to fetch and display product details from ProductWarehouse 2025-10-16 16:25:54 +07:00
rstubryan a2a57f758c refactor(FE-63,63,65): enhance MovementForm to fetch and display product details from ProductWarehouse 2025-10-16 16:24:42 +07:00
rstubryan 157dfc75ed refactor(FE-63): remove debug logging from form submission and movement handlers 2025-10-16 15:47:29 +07:00
rstubryan f5ce898bd2 feat(FE-62,63,65): enhance MovementForm with product warehouse selection, delivery document handling, and stock validation 2025-10-16 15:29:26 +07:00
rstubryan c6a0c542aa refactor(FE-62,63,65): refactor Movement and ProductWarehouse APIs, update MovementForm schema, and enhance MovementTable functionality 2025-10-16 14:33:49 +07:00
Adnan Zahir b0e11095f4 Merge branch 'feat/FE/US-82/approval-workflow-steps-component' into 'development'
[FEAT/FE][US#82] Slicing Approval Steps component

See merge request mbugroup/lti-web-client!12
2025-10-16 11:04:52 +07:00
rstubryan 79acdb4b7b merge: resolve conflict 2025-10-16 10:59:36 +07:00
rstubryan 19db9a4eac refactor(FE-114,136): enhance validation and default values in RecordingForm schema 2025-10-16 10:54:36 +07:00
Rivaldi A N S 1e0b342bbc Merge branch 'feat/FE/US-82/TASK-91-slicing-approval-steps-component' into 'feat/FE/US-82/approval-workflow-steps-component'
[FEAT/FE][US#82/TASK#91] Slicing Approval Steps component

See merge request mbugroup/lti-web-client!11
2025-10-16 03:16:47 +00:00
rstubryan 23d5a41d56 refactor(FE-114): improve recording date handling in RecordingForm 2025-10-16 10:08:49 +07:00
ValdiANS b7a30cc73a chore(FE-91): create ApprovalsLine type 2025-10-16 10:01:50 +07:00
ValdiANS 93beb86f91 feat(FE-91): create ApprovalSteps component 2025-10-16 10:01:40 +07:00
ValdiANS 0577f6ce1d feat(FE-91): create StepItem component 2025-10-16 10:01:29 +07:00
ValdiANS 76dd2e4c54 feat(FE-91): create Steps component 2025-10-16 10:01:23 +07:00
ValdiANS 156de6112b feat(FE-91): create Tooltip component 2025-10-16 10:01:14 +07:00
ValdiANS eb0f04310e chore(FE-91): create daisyui.css file for extending daisyUI style 2025-10-16 10:01:00 +07:00
rstubryan 27d2792a9c refactor(FE-114): enhance layout and structure of RecordingForm component 2025-10-16 09:24:00 +07:00
rstubryan ec387637ed refactor(FE-114): remove bulk delete functionality from RecordingTable 2025-10-16 09:12:21 +07:00
rstubryan 64e6724664 feat(FE-114): add bulk action functionality for approving, rejecting, and deleting recordings in RecordingTable 2025-10-16 09:07:12 +07:00
rstubryan f319a9b5d1 feat(FE-114): implement RecordingEdit and RecordingDetail components with error handling and loading states 2025-10-16 08:39:32 +07:00
randy-ar e2b35e765c feat(FE-102) create master data flock and add LTI theme 2025-10-15 20:01:41 +07:00
rstubryan 8bfce061e6 refactor(FE-114,136): improve location and coop field handling in RecordingForm 2025-10-15 17:53:08 +07:00
rstubryan 64a32fd214 refactor(FE-114,136): update RecordingForm schema and types to include location and coop fields 2025-10-15 17:39:27 +07:00
rstubryan 2ee88a2742 refactor(FE-114): enhance tanggal_recording handling and improve error messaging in RecordingForm 2025-10-15 13:45:48 +07:00
rstubryan aa21088e99 feat(FE-62): enhance MovementForm with delivery product input error handling and validation 2025-10-15 12:30:59 +07:00
rstubryan 06dc869b84 feat(FE-64): update MovementTable structure for improved data clarity and consistency 2025-10-15 12:08:52 +07:00
rstubryan df73ee1fdf feat(FE-62,63,65): refactor MovementForm and related types for improved clarity and consistency 2025-10-15 12:00:17 +07:00
rstubryan cf78687315 merge: resolve conflict 2025-10-15 11:05:37 +07:00
rstubryan 66e6fa84c8 Merge remote-tracking branch 'origin/dev/restu' into dev/restu 2025-10-15 10:56:16 +07:00
rstubryan dcd5d2692f feat(FE-62,65): enhance MovementForm and FormActions to improve form validation and reset behavior 2025-10-15 10:56:06 +07:00
rstubryan 3c4333021f feat(FE-62,65): enhance MovementForm and FormActions to improve form validation and reset behavior 2025-10-15 10:54:38 +07:00
rstubryan 56a9fc2349 refactor(FE-62,65): simplify error handling in MovementForm by consolidating error checks 2025-10-15 10:51:06 +07:00
rstubryan 24144f01d4 feat(FE-114,136): add error handling for repeater inputs in RecordingForm 2025-10-15 10:37:04 +07:00
Adnan Zahir 212fd3b4f2 Merge branch 'feat/FE/US-34/stock-adjustment' into 'development'
[FEAR/FE/US#34/TASK#51-52-53-54] Implement Feature Adjustment Inventory

See merge request mbugroup/lti-web-client!9
2025-10-15 10:26:14 +07:00
rstubryan 6f0467918b feat(FE-114): add tanggal_recording field to RecordingForm and update schema validation 2025-10-15 09:50:21 +07:00
rstubryan 53ee4cdc1b feat(FE-114): add Layout and AddRecording components with routing link 2025-10-15 09:29:29 +07:00
rstubryan b1a3796eca feat(FE-114,136): implement RecordingForm component with data handling and validation 2025-10-15 09:28:57 +07:00
rstubryan 89318407ea feat(FE-136): update RecordingForm schema to remove tanggal and add flock object 2025-10-14 23:01:01 +07:00
rstubryan 6dcb97bcac feat(FE-114,129): add RecordingForm and RecordingTable components with handlers 2025-10-14 22:03:51 +07:00
rstubryan 1869fa8dc5 feat(FE-136): add flock and recording management with validation in forms 2025-10-14 22:03:09 +07:00
rstubryan 4b4b74d07c feat(FE-65): add validation for quantity and required fields in MovementForm 2025-10-14 18:00:34 +07:00
rstubryan ff9e35eb52 Merge remote-tracking branch 'origin/dev/restu' into dev/restu
# Conflicts:
#	src/components/pages/inventory/movement/form/MovementForm.tsx
2025-10-14 14:04:24 +07:00
rstubryan 19bca9ec73 feat(FE-65): enhance MovementForm to support file uploads with FormData conversion 2025-10-14 14:03:46 +07:00
rstubryan 6facfd3d3c feat(FE-65): enhance MovementForm to support file uploads with FormData conversion 2025-10-14 14:00:58 +07:00
rstubryan b2f0bd6698 feat(FE-65): add file type validation for dokumen in MovementForm 2025-10-14 10:31:34 +07:00
rstubryan e7085ab4ff feat(FE-65): add file size validation for dokumen in MovementForm 2025-10-14 10:02:56 +07:00
rstubryan 44e07ddc50 feat(FE-64): refactor MovementTable with new TableToolbar and TableRowSizeSelector components 2025-10-14 09:26:21 +07:00
Rivaldi A N S 46860a93b9 Merge branch 'dev/randy' into 'feat/FE/US-34/stock-adjustment'
[FEAT/FE][US#33][TASK#51-54] Form Validation and UI/UX Adjustment

See merge request mbugroup/lti-web-client!10
2025-10-13 06:53:00 +00:00
randy-ar 302da65c59 fix(FE-51) adjust textarea component ui 2025-10-13 13:09:53 +07:00
randy-ar ce8471343c fix(FE-54) fix form input state inventory adjustment 2025-10-13 12:59:05 +07:00
randy-ar 880ff5740d fix(FE-42): fix validation supplier form and multi select component 2025-10-13 11:26:37 +07:00
randy-ar 9b53c75f2f fix(FE-42): fix validation supplier form and multi select component 2025-10-13 11:25:39 +07:00
rstubryan a4ff4f7b2a feat: add Layout component to wrap children with SuspenseHelper 2025-10-12 20:32:02 +07:00
rstubryan 754e3d526b feat(FE-64): add hatchery and npwp fields to MovementTable data structure 2025-10-12 19:15:14 +07:00
randy-ar f662f2951e fix(FE-51-54): fixing bug and layout form adjustment 2025-10-11 23:26:30 +07:00
randy-ar 1fd4b2aba5 Merge branch 'development' of https://gitlab.com/mbugroup/lti-web-client into feat/FE/US-34/stock-adjustment 2025-10-11 13:18:15 +07:00
randy-ar b75b5956eb feat/FE/US-34/TASK-52-53-slicing-ui-table-adjust-form-with-api 2025-10-11 13:12:05 +07:00
rstubryan 478f52c94b feat(FE-62,65): add biaya_ekspedisi_per_item field and calculation in MovementForm 2025-10-11 08:33:48 +07:00
randy-ar aa7b6581d9 feat/FE/US-34/TASK-54-51-slicing-ui-client-side-validation-stock-adjustment 2025-10-11 02:03:10 +07:00
rstubryan 757893c757 feat(FE-62): add quantity validation for ekspedisi in MovementForm and filter product options 2025-10-10 13:43:30 +07:00
rstubryan a1dc13ceb4 feat(FE-62): enhance MovementForm with area and location display for warehouse selection 2025-10-10 13:36:22 +07:00
rstubryan 157235433e feat(FE-62): implement bulk removal functionality for selected products and ekspedisi in MovementForm 2025-10-10 13:14:39 +07:00
rstubryan 57831646d9 refactor(FE-62): optimize product and ekspedisi removal logic in MovementForm 2025-10-10 11:14:59 +07:00
rstubryan 095190d757 refactor(FE-62,65): refactor MovementForm schema and component for improved product and ekspedisi handling 2025-10-10 10:19:56 +07:00
rstubryan 27f58051ad Merge branch 'development' of gitlab.com:mbugroup/lti-web-client into feat/FE/US-35/stock-transfer 2025-10-10 08:40:39 +07:00
rstubryan a9cdea7318 feat(FE-65): enhance MovementForm with initial values handling and refactor components 2025-10-10 08:40:17 +07:00
rstubryan 7dbf880228 feat(FE-62): add FormActions and FormHeader components for form management 2025-10-10 08:39:34 +07:00
Adnan Zahir 24b702548d Merge branch 'feat/FE/US-33/master-data-management' into 'development'
[FEAT/FE][US#33/TASK#40-41-42-43] Master Data Management

See merge request mbugroup/lti-web-client!8
2025-10-09 17:43:27 +07:00
rstubryan aacdbf0742 Merge branch 'feat/FE/US-33/TASK-40-slicing-ui-for-master-data-forms' of gitlab.com:mbugroup/lti-web-client into feat/FE/US-35/stock-transfer 2025-10-09 16:33:31 +07:00
rstubryan c17ffc6aff feat(FE-62): add MovementEdit and MovementDetail components for inventory movement management 2025-10-09 14:34:25 +07:00
rstubryan 1ea9ee3069 feat(FE-62,63,65): implement MovementForm component for managing inventory movements 2025-10-09 14:30:05 +07:00
Restu Bumi Ryan Ramadhan 558a1788dc Merge branch 'feat/FE/US-35/TASK-62-65-slicing-ui-for-inventory-movement-forms' into 'feat/FE/US-35/stock-transfer'
Feat/fe/us 35/task 62 65 slicing ui for inventory movement forms

See merge request mbugroup/lti-web-client!5
2025-10-09 06:11:39 +00:00
rstubryan e2036ab3dc chore: resolve conflict pull request 2025-10-09 13:05:27 +07:00
rstubryan ddbf8b0896 refactor(FE-62): rename Product component to Movement for clarity 2025-10-08 16:16:12 +07:00
rstubryan 3f97ec45f8 feat(FE-64): add MovementTable component for inventory movement management 2025-10-08 16:06:19 +07:00
rstubryan 7ceb25ea71 feat(FE-62,65): add inventory movement management with API and form validation 2025-10-08 15:26:45 +07:00
Adnan Zahir 7723e2a8d3 Merge branch 'chore/CI/merge-request-notify-workflow' into 'development'
chore(CI): added gitlab ci yaml file for notify MR and MR-merged events

See merge request mbugroup/lti-web-client!2
2025-10-03 22:01:25 +07:00
Adnan Zahir 88fe135cb4 chore(CI): added gitlab ci yaml file for notify MR and MR-merged events 2025-10-03 21:58:55 +07:00
162 changed files with 15340 additions and 1162 deletions
+44
View File
@@ -0,0 +1,44 @@
stages:
- build
variables:
# 🔧 Aktifkan Docker BuildKit (build lebih cepat & caching layer)
DOCKER_BUILDKIT: "1"
COMPOSE_DOCKER_CLI_BUILD: "1"
DOCKER_DRIVER: overlay2
# 🧠 Nama image (pakai commit short SHA)
IMAGE_NAME: "$CI_REGISTRY_IMAGE/web-lti:development_${CI_COMMIT_SHORT_SHA}"
# Cache npm (disimpan antar pipeline)
NPM_CACHE_DIR: "$CI_PROJECT_DIR/.npm"
cache:
key: npm-cache
paths:
- .npm/
build-image:
stage: build
image: docker:27.0.3
services:
- docker:dind
before_script:
- echo "🔐 Logging in to GitLab Container Registry..."
- echo "$CI_REGISTRY_PASSWORD" | docker login -u "$CI_REGISTRY_USER" --password-stdin "$CI_REGISTRY"
script:
- echo "🚧 Building optimized Docker image..."
- docker build --build-arg BUILDKIT_INLINE_CACHE=1 --cache-from $CI_REGISTRY_IMAGE/web-lti:latest -t "$IMAGE_NAME" .
- docker push "$IMAGE_NAME"
# 🧹 Keep only last 3 images (hapus yang lama)
- echo "🧹 Cleaning old images..."
- docker image prune -af --filter "until=72h"
after_script:
- echo "✅ Build complete: $IMAGE_NAME"
rules:
- if: '$CI_COMMIT_BRANCH == "development"'
+2
View File
@@ -0,0 +1,2 @@
npm run lint
npm run build
+15
View File
@@ -0,0 +1,15 @@
{
"singleQuote": true,
"jsxSingleQuote": true,
"endOfLine": "lf",
"arrowParens": "always",
"bracketSpacing": true,
"embeddedLanguageFormatting": "auto",
"htmlWhitespaceSensitivity": "css",
"printWidth": 80,
"proseWrap": "preserve",
"quoteProps": "as-needed",
"semi": true,
"tabWidth": 2,
"trailingComma": "es5"
}
+25
View File
@@ -0,0 +1,25 @@
FROM node:20-alpine
RUN apk add --no-cache git bash build-base curl
WORKDIR /app
COPY package*.json ./
RUN npm ci
COPY . .
# Buat config agar Next tahu output: export
RUN echo "const config = { output: 'export', images: { unoptimized: true } }; export default config;" > next.config.mjs
# Build project (Next.js 15 otomatis static export)
RUN NEXT_DISABLE_TURBOPACK=1 npx next build
# Copy static assets dan hasil build agar bisa diakses
RUN mkdir -p .next/server/app/_next && \
cp -r .next/static .next/server/app/_next/static && \
cp -r public/* .next/server/app/
EXPOSE 3000
CMD ["npx", "serve", ".next/server/app", "-l", "3000"]
+11
View File
@@ -0,0 +1,11 @@
#!/bin/bash
echo "VERCEL_GIT_COMMIT_REF: $VERCEL_GIT_COMMIT_REF"
if [[ "$VERCEL_GIT_COMMIT_REF" == "master" || "$VERCEL_GIT_COMMIT_REF" == "development" ]]; then
echo "✅ - Build can proceed"
exit 1
else
echo "🛑 - Build cancelled"
exit 0
fi
+39
View File
@@ -0,0 +1,39 @@
version: "3.9"
services:
dev-web-lti:
container_name: dev-web-lti
build:
context: .
dockerfile: Dockerfile
ports:
- "3002:3000"
env_file:
- .env
environment:
NODE_ENV: production
APP_ENV: production
networks:
- dev-lti-network
restart: always
deploy:
resources:
limits:
cpus: "3.0"
memory: 3G
reservations:
cpus: "1.0"
memory: 512M
extra_hosts:
- "host.docker.internal:host-gateway"
# Optional: aktifkan healthcheck jika punya endpoint
# healthcheck:
# test: ["CMD-SHELL", "curl -fsS http://localhost:3000/api/healthz || exit 1"]
# interval: 10s
# timeout: 3s
# retries: 10
# start_period: 15s
networks:
dev-lti-network:
external: true
+9 -9
View File
@@ -1,6 +1,6 @@
import { dirname } from "path";
import { fileURLToPath } from "url";
import { FlatCompat } from "@eslint/eslintrc";
import { dirname } from 'path';
import { fileURLToPath } from 'url';
import { FlatCompat } from '@eslint/eslintrc';
const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);
@@ -10,14 +10,14 @@ const compat = new FlatCompat({
});
const eslintConfig = [
...compat.extends("next/core-web-vitals", "next/typescript"),
...compat.extends('next/core-web-vitals', 'next/typescript'),
{
ignores: [
"node_modules/**",
".next/**",
"out/**",
"build/**",
"next-env.d.ts",
'node_modules/**',
'.next/**',
'out/**',
'build/**',
'next-env.d.ts',
],
},
];
+505 -537
View File
File diff suppressed because it is too large Load Diff
+8 -1
View File
@@ -6,7 +6,9 @@
"dev": "eslint && next dev --turbopack",
"build": "next build --turbopack",
"start": "next start",
"lint": "eslint"
"lint": "eslint",
"prepare": "husky",
"format": "prettier --write ."
},
"dependencies": {
"@tanstack/match-sorter-utils": "^8.19.4",
@@ -14,11 +16,13 @@
"axios": "^1.12.2",
"clsx": "^2.1.1",
"formik": "^2.4.6",
"inputmask": "^5.0.9",
"moment": "^2.30.1",
"next": "15.5.3",
"react": "19.1.0",
"react-dom": "19.1.0",
"react-hot-toast": "^2.6.0",
"react-number-format": "^5.4.4",
"react-select": "^5.10.2",
"swr": "^2.3.6",
"tailwind-merge": "^3.3.1",
@@ -30,12 +34,15 @@
"@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",
"eslint": "^9",
"eslint-config-next": "15.5.3",
"husky": "^9.1.7",
"prettier": "^3.6.2",
"tailwindcss": "^4",
"typescript": "^5"
}
+1 -1
View File
@@ -1,5 +1,5 @@
const config = {
plugins: ["@tailwindcss/postcss"],
plugins: ['@tailwindcss/postcss'],
};
export default config;
+36
View File
@@ -1,5 +1,41 @@
@import 'tailwindcss';
@plugin "daisyui";
@import '../styles/daisyui.css';
@plugin "daisyui/theme" {
name: 'lti';
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);
--radius-selector: 0rem;
--radius-field: 0.25rem;
--radius-box: 0.25rem;
--size-selector: 0.21875rem;
--size-field: 0.1875rem;
--border: 1px;
--depth: 0;
--noise: 0;
}
:root {
--color-primary: #1f74bf;
+11
View File
@@ -0,0 +1,11 @@
import InventoryAdjustmentForm from '@/components/pages/inventory/adjustment/form/InventoryAdjustmentForm';
const CreateInventoryAdjustment = () => {
return (
<section className='w-full p-4 flex flex-row justify-center'>
<InventoryAdjustmentForm />
</section>
);
};
export default CreateInventoryAdjustment;
@@ -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,47 @@
'use client';
import { useEffect, useState } from 'react';
import { useRouter } from 'next/navigation';
import InventoryAdjustmentForm from '@/components/pages/inventory/adjustment/form/InventoryAdjustmentForm';
import type { InventoryAdjustment } from '@/types/api/inventory/adjustment';
const DetailInventoryAdjustment = () => {
const router = useRouter();
const [inventoryAdjustment, setInventoryAdjustment] =
useState<InventoryAdjustment | null>(null);
// 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;
if (state?.inventoryAdjustment) {
// jika object dikirim via router.push(state)
setInventoryAdjustment(state.inventoryAdjustment);
}
}, [router]);
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'>
<span className='loading loading-spinner loading-xl' />
</div>
);
}
return (
<section className='w-full p-4 flex flex-row justify-center'>
<InventoryAdjustmentForm initialValues={finalData} />
</section>
);
};
export default DetailInventoryAdjustment;
+11
View File
@@ -0,0 +1,11 @@
import InventoryAdjustmentTable from '@/components/pages/inventory/adjustment/InventoryAdjustmentTable';
const InventoryAdjustment = () => {
return (
<section className='w-full p-4'>
<InventoryAdjustmentTable />
</section>
);
};
export default InventoryAdjustment;
+11
View File
@@ -0,0 +1,11 @@
import MovementForm from '@/components/pages/inventory/movement/form/MovementForm';
const AddMovement = () => {
return (
<div className='w-full p-4 flex flex-row justify-center'>
<MovementForm />
</div>
);
};
export default AddMovement;
@@ -0,0 +1,48 @@
'use client';
import { useRouter, useSearchParams } from 'next/navigation';
import useSWR from 'swr';
import MovementForm from '@/components/pages/inventory/movement/form/MovementForm';
import { MovementApi } from '@/services/api/inventory';
import { isResponseError, isResponseSuccess } from '@/lib/api-helper';
const MovementEdit = () => {
const router = useRouter();
const searchParams = useSearchParams();
const movementId = searchParams.get('movementId');
const { data: movement, isLoading: isLoadingMovement } = useSWR(
movementId,
(id: number) => MovementApi.getSingle(id)
);
if (!movementId) {
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 (!isLoadingMovement && (!movement || isResponseError(movement))) {
router.replace('/404');
return;
}
return (
<div className='w-full p-4 flex flex-row justify-center'>
{isLoadingMovement && (
<span className='loading loading-spinner loading-xl' />
)}
{!isLoadingMovement && isResponseSuccess(movement) && (
<MovementForm type='edit' initialValues={movement.data} />
)}
</div>
);
};
export default MovementEdit;
@@ -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,48 @@
'use client';
import { useRouter, useSearchParams } from 'next/navigation';
import useSWR from 'swr';
import MovementForm from '@/components/pages/inventory/movement/form/MovementForm';
import { MovementApi } from '@/services/api/inventory';
import { isResponseError, isResponseSuccess } from '@/lib/api-helper';
const MovementDetail = () => {
const router = useRouter();
const searchParams = useSearchParams();
const movementId = searchParams.get('movementId');
const { data: movement, isLoading: isLoadingMovement } = useSWR(
movementId,
(id: number) => MovementApi.getSingle(id)
);
if (!movementId) {
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 (!isLoadingMovement && (!movement || isResponseError(movement))) {
router.replace('/404');
return;
}
return (
<div className='w-full p-4 flex flex-row justify-center'>
{isLoadingMovement && (
<span className='loading loading-spinner loading-xl' />
)}
{!isLoadingMovement && isResponseSuccess(movement) && (
<MovementForm type='detail' initialValues={movement.data} />
)}
</div>
);
};
export default MovementDetail;
+11
View File
@@ -0,0 +1,11 @@
import MovementTable from '@/components/pages/inventory/movement/MovementTable';
const Movement = () => {
return (
<section className='w-full p-4'>
<MovementTable />
</section>
);
};
export default Movement;
+1 -1
View File
@@ -28,7 +28,7 @@ export default function RootLayout({
children: React.ReactNode;
}>) {
return (
<html lang='en'>
<html lang='en' data-theme='lti'>
<body className={`${inter.variable} antialiased font-inter`}>
<RequireAuth>
<MainDrawer>{children}</MainDrawer>
+5 -5
View File
@@ -1,11 +1,11 @@
import CustomerForm from "@/components/pages/master-data/customer/form/CustomerForm";
import CustomerForm from '@/components/pages/master-data/customer/form/CustomerForm';
const AddCustomer = () => {
return (
<section className="w-full p-4 flex flex-row justify-center">
<CustomerForm/>
<section className='w-full p-4 flex flex-row justify-center'>
<CustomerForm />
</section>
);
}
};
export default AddCustomer;
export default AddCustomer;
@@ -0,0 +1,11 @@
import SuspenseHelper from '@/components/helper/SuspenseHelper';
const Layout = ({
children,
}: Readonly<{
children: React.ReactNode;
}>) => {
return <SuspenseHelper>{children}</SuspenseHelper>;
};
export default Layout;
+17 -15
View File
@@ -1,45 +1,47 @@
'use client'
'use client';
import { useRouter, useSearchParams } from "next/navigation";
import useSWR from "swr";
import { useRouter, useSearchParams } from 'next/navigation';
import useSWR from 'swr';
import { CustomerApi } from '@/services/api/master-data';
import { isResponseError, isResponseSuccess } from "@/lib/api-helper";
import CustomerForm from "@/components/pages/master-data/customer/form/CustomerForm";
import { isResponseError, isResponseSuccess } from '@/lib/api-helper';
import CustomerForm from '@/components/pages/master-data/customer/form/CustomerForm';
const CustomerDetail = () => {
const router = useRouter();
const searchParams = useSearchParams();
const costumerId = searchParams.get("customerId");
const costumerId = searchParams.get('customerId');
const { data: costumer, isLoading: isLoadingCostumer } = useSWR(
costumerId,
(id: number) => CustomerApi.getSingle(id)
);
if(!costumerId){
if (!costumerId) {
router.back();
return (
<div className="w-full flex flex-row justify-center items-center p-4">
<span className="loading loading-spinner loading-xl" />
<div className='w-full flex flex-row justify-center items-center p-4'>
<span className='loading loading-spinner loading-xl' />
</div>
);
}
if(!isLoadingCostumer && (!costumer || isResponseError(costumer))){
router.replace("/404");
if (!isLoadingCostumer && (!costumer || isResponseError(costumer))) {
router.replace('/404');
return;
}
return (
<div className="w-full p-4 flex flex-row justify-center">
{isLoadingCostumer && <span className="loading loading-spinner loading-xl" />}
<div className='w-full p-4 flex flex-row justify-center'>
{isLoadingCostumer && (
<span className='loading loading-spinner loading-xl' />
)}
{!isLoadingCostumer && isResponseSuccess(costumer) && (
<CustomerForm formType="detail" initialValues={costumer.data} />
<CustomerForm formType='detail' initialValues={costumer.data} />
)}
</div>
)
);
};
export default CustomerDetail;
+4 -4
View File
@@ -1,11 +1,11 @@
import CustomersTable from "@/components/pages/master-data/customer/CustomersTable";
import CustomersTable from '@/components/pages/master-data/customer/CustomersTable';
const Customer = () => {
return (
<section className="w-full p-4">
<section className='w-full p-4'>
<CustomersTable />
</section>
)
);
};
export default Customer;
export default Customer;
+11
View File
@@ -0,0 +1,11 @@
import FlockForm from '@/components/pages/master-data/flock/form/FlockForm';
const AddFlock = () => {
return (
<section className='w-full p-4 flex flex-row justify-center'>
<FlockForm />
</section>
);
};
export default AddFlock;
@@ -0,0 +1,49 @@
'use client';
import FlockForm from '@/components/pages/master-data/flock/form/FlockForm';
import { isResponseError, isResponseSuccess } from '@/lib/api-helper';
import { FlockApi } from '@/services/api/master-data';
import { useRouter, useSearchParams } from 'next/navigation';
import useSWR from 'swr';
const FlockEdit = () => {
const router = useRouter();
const searchParams = useSearchParams();
// Get Query Params
const flockId = searchParams.get('flockId');
// Fetch Data
const { data: flock, isLoading: isLoadingFlock } = useSWR(
flockId,
(id: number) => FlockApi.getSingle(id)
);
if (!flockId) {
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 (!isLoadingFlock && (!flock || isResponseError(flock))) {
router.replace('/404');
return;
}
return (
<div className='w-full p-4 flex flex-row justify-center'>
{isLoadingFlock && (
<span className='loading loading-spinner loading-xl' />
)}
{!isLoadingFlock && isResponseSuccess(flock) && (
<FlockForm formType='edit' initialValues={flock.data} />
)}
</div>
);
};
export default FlockEdit;
@@ -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 FlockForm from '@/components/pages/master-data/flock/form/FlockForm';
import { isResponseError, isResponseSuccess } from '@/lib/api-helper';
import { FlockApi } from '@/services/api/master-data';
import { useRouter, useSearchParams } from 'next/navigation';
import useSWR from 'swr';
const FlockDetail = () => {
const router = useRouter();
const searchParams = useSearchParams();
// Get Query Params
const flockId = searchParams.get('flockId');
// Fetch Data
const { data: flock, isLoading: isLoadingFlock } = useSWR(
flockId,
(id: number) => FlockApi.getSingle(id)
);
if (!flockId) {
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 (!isLoadingFlock && (!flock || isResponseError(flock))) {
router.replace('/404');
return;
}
return (
<div className='w-full p-4 flex flex-row justify-center'>
{isLoadingFlock && (
<span className='loading loading-spinner loading-xl' />
)}
{!isLoadingFlock && isResponseSuccess(flock) && (
<FlockForm formType='detail' initialValues={flock.data} />
)}
</div>
);
};
export default FlockDetail;
+11
View File
@@ -0,0 +1,11 @@
import FlockTable from '@/components/pages/master-data/flock/FlocksTable';
const Flock = () => {
return (
<section className='w-full p-4'>
<FlockTable />
</section>
);
};
export default Flock;
@@ -1,11 +1,11 @@
import ProductCategoryForm from "@/components/pages/master-data/product-category/form/ProductCategoryForm";
import ProductCategoryForm from '@/components/pages/master-data/product-category/form/ProductCategoryForm';
const AddProductCategory = () => {
return (
<div className="w-full p-4 flex flex-row justify-center">
<div className='w-full p-4 flex flex-row justify-center'>
<ProductCategoryForm />
</div>
);
};
export default AddProductCategory;
export default AddProductCategory;
@@ -9,39 +9,44 @@ import { ProductCategoryApi } from '@/services/api/master-data';
import { isResponseError, isResponseSuccess } from '@/lib/api-helper';
const ProductCategoryEdit = () => {
const router = useRouter();
const searchParams = useSearchParams();
const router = useRouter();
const searchParams = useSearchParams();
const productCategoryId = searchParams.get('productCategoryId');
const productCategoryId = searchParams.get('productCategoryId');
const { data: productCategory, isLoading: isLoadingProductCategory } = useSWR(
productCategoryId,
(id: number) => ProductCategoryApi.getSingle(id)
);
const { data: productCategory, isLoading: isLoadingProductCategory } = useSWR(
productCategoryId,
(id: number) => ProductCategoryApi.getSingle(id)
);
if (!productCategoryId) {
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 (!isLoadingProductCategory && (!productCategory || isResponseError(productCategory))) {
router.replace('/404');
return;
}
if (!productCategoryId) {
router.back();
return (
<div className='w-full p-4 flex flex-row justify-center'>
{isLoadingProductCategory && <span className='loading loading-spinner loading-xl' />}
{!isLoadingProductCategory && isResponseSuccess(productCategory) && (
<ProductCategoryForm type='edit' initialValues={productCategory.data} />
)}
</div>
<div className='w-full flex flex-row justify-center items-center p-4'>
<span className='loading loading-spinner loading-xl' />
</div>
);
}
}
export default ProductCategoryEdit;
if (
!isLoadingProductCategory &&
(!productCategory || isResponseError(productCategory))
) {
router.replace('/404');
return;
}
return (
<div className='w-full p-4 flex flex-row justify-center'>
{isLoadingProductCategory && (
<span className='loading loading-spinner loading-xl' />
)}
{!isLoadingProductCategory && isResponseSuccess(productCategory) && (
<ProductCategoryForm type='edit' initialValues={productCategory.data} />
)}
</div>
);
};
export default ProductCategoryEdit;
@@ -29,16 +29,24 @@ const ProductCategoryDetail = () => {
);
}
if (!isLoadingProductCategory && (!productCategory || isResponseError(productCategory))) {
if (
!isLoadingProductCategory &&
(!productCategory || isResponseError(productCategory))
) {
router.replace('/404');
return;
}
return (
<div className='w-full p-4 flex flex-row justify-center'>
{isLoadingProductCategory && <span className='loading loading-spinner loading-xl' />}
{isLoadingProductCategory && (
<span className='loading loading-spinner loading-xl' />
)}
{!isLoadingProductCategory && isResponseSuccess(productCategory) && (
<ProductCategoryForm type='detail' initialValues={productCategory.data} />
<ProductCategoryForm
type='detail'
initialValues={productCategory.data}
/>
)}
</div>
);
@@ -1,11 +1,11 @@
import ProductCategoryTable from "@/components/pages/master-data/product-category/ProductCategoryTable";
import ProductCategoryTable from '@/components/pages/master-data/product-category/ProductCategoryTable';
const ProductCategory = () => {
return (
<section className="w-full p-4">
<section className='w-full p-4'>
<ProductCategoryTable />
</section>
);
};
export default ProductCategory;
export default ProductCategory;
+2 -2
View File
@@ -2,10 +2,10 @@ import ProductForm from '@/components/pages/master-data/product/form/ProductForm
const AddProduct = () => {
return (
<div className="w-full p-4 flex flex-row justify-center">
<div className='w-full p-4 flex flex-row justify-center'>
<ProductForm />
</div>
);
};
export default AddProduct;
export default AddProduct;
@@ -13,9 +13,8 @@ const ProductEdit = () => {
const productId = searchParams.get('productId');
const { data: product, isLoading } = useSWR(
productId,
(id: number) => ProductApi.getSingle(id)
const { data: product, isLoading } = useSWR(productId, (id: number) =>
ProductApi.getSingle(id)
);
if (!productId) {
@@ -42,4 +41,4 @@ const ProductEdit = () => {
);
};
export default ProductEdit;
export default ProductEdit;
+3 -4
View File
@@ -13,9 +13,8 @@ const ProductDetail = () => {
const productId = searchParams.get('productId');
const { data: product, isLoading } = useSWR(
productId,
(id: number) => ProductApi.getSingle(id)
const { data: product, isLoading } = useSWR(productId, (id: number) =>
ProductApi.getSingle(id)
);
if (!productId) {
@@ -42,4 +41,4 @@ const ProductDetail = () => {
);
};
export default ProductDetail;
export default ProductDetail;
+4 -4
View File
@@ -1,11 +1,11 @@
import ProductsTable from "@/components/pages/master-data/product/ProductTable";
import ProductsTable from '@/components/pages/master-data/product/ProductTable';
const Product = () => {
return (
<section className="w-full p-4">
<ProductsTable />
<section className='w-full p-4'>
<ProductsTable />
</section>
);
};
export default Product;
export default Product;
+1 -1
View File
@@ -8,4 +8,4 @@ const AddSupplier = () => {
);
};
export default AddSupplier;
export default AddSupplier;
@@ -0,0 +1,11 @@
import SuspenseHelper from '@/components/helper/SuspenseHelper';
const Layout = ({
children,
}: Readonly<{
children: React.ReactNode;
}>) => {
return <SuspenseHelper>{children}</SuspenseHelper>;
};
export default Layout;
+1 -1
View File
@@ -46,4 +46,4 @@ const SupplierDetail = () => {
);
};
export default SupplierDetail;
export default SupplierDetail;
+1 -1
View File
@@ -1,4 +1,4 @@
import SuppliersTable from "@/components/pages/master-data/supplier/SupplierTable";
import SuppliersTable from '@/components/pages/master-data/supplier/SupplierTable';
const Supplier = () => {
return (
+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;
+270
View File
@@ -0,0 +1,270 @@
'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;
@@ -0,0 +1,11 @@
import SuspenseHelper from '@/components/helper/SuspenseHelper';
const Layout = ({
children,
}: Readonly<{
children: React.ReactNode;
}>) => {
return <SuspenseHelper>{children}</SuspenseHelper>;
};
export default Layout;
+351
View File
@@ -0,0 +1,351 @@
'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;
+10
View File
@@ -0,0 +1,10 @@
import ChickinTable from '@/components/pages/production/chickin/ChickinTable';
const Chickin = () => {
return (
<section className='w-full p-4'>
<ChickinTable />
</section>
);
};
export default Chickin;
@@ -0,0 +1,13 @@
'use client';
import ProjectFlockForm from '@/components/pages/production/project-flock/form/ProjectFlockForm';
const AddProjectFlock = () => {
return (
<section className='w-full p-4 flex flex-row justify-center'>
<ProjectFlockForm formType='add' />
</section>
);
};
export default AddProjectFlock;
@@ -0,0 +1,47 @@
'use client';
import ProjectFlockForm from '@/components/pages/production/project-flock/form/ProjectFlockForm';
import { isResponseError, isResponseSuccess } from '@/lib/api-helper';
import { ProjectFlockApi } from '@/services/api/production';
import { useRouter, useSearchParams } from 'next/navigation';
import useSWR from 'swr';
const ProjectFlockEdit = () => {
const router = useRouter();
const searchParams = useSearchParams();
const projectFlockId = searchParams.get('projectFlockId');
const { data: projectFlock, isLoading: isLoadingCostumer } = useSWR(
projectFlockId,
(id: number) => ProjectFlockApi.getSingle(id)
);
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 (!isLoadingCostumer && (!projectFlock || isResponseError(projectFlock))) {
router.replace('/404');
return;
}
return (
<div className='w-full p-4 flex flex-row justify-center'>
{isLoadingCostumer && (
<span className='loading loading-spinner loading-xl' />
)}
{!isLoadingCostumer && isResponseSuccess(projectFlock) && (
<ProjectFlockForm formType='edit' initialValues={projectFlock.data} />
)}
</div>
);
};
export default ProjectFlockEdit;
@@ -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,55 @@
'use client';
import ProjectFlockForm from '@/components/pages/production/project-flock/form/ProjectFlockForm';
import { isResponseError, isResponseSuccess } from '@/lib/api-helper';
import { ProjectFlockApi } from '@/services/api/production';
import { useRouter, useSearchParams } from 'next/navigation';
import useSWR from 'swr';
const ProjectFlockDetail = () => {
const router = useRouter();
const searchParams = useSearchParams();
const projectFlockId = searchParams.get('projectFlockId');
const {
data: projectFlock,
isLoading: isLoadingProjectFlock,
mutate: refreshProjectFlock,
} = useSWR(projectFlockId, (id: number) => ProjectFlockApi.getSingle(id));
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;
}
return (
<div className='w-full p-4 flex flex-row justify-center'>
{isLoadingProjectFlock && (
<span className='loading loading-spinner loading-xl' />
)}
{!isLoadingProjectFlock && isResponseSuccess(projectFlock) && (
<ProjectFlockForm
formType='detail'
initialValues={projectFlock.data}
refreshProjectFlocks={refreshProjectFlock}
/>
)}
</div>
);
};
export default ProjectFlockDetail;
+11
View File
@@ -0,0 +1,11 @@
import ProjectFlockTable from '@/components/pages/production/project-flock/ProjectFlockTable';
const ProjectFlock = () => {
return (
<section className='w-full p-4'>
<ProjectFlockTable />
</section>
);
};
export default ProjectFlock;
+11
View File
@@ -0,0 +1,11 @@
import RecordingForm from '@/components/pages/production/recording/form/RecordingForm';
const AddRecording = () => {
return (
<div className='w-full p-4 flex flex-row justify-center'>
<RecordingForm />
</div>
);
};
export default AddRecording;
@@ -0,0 +1,47 @@
'use client';
import { useRouter, useSearchParams } from 'next/navigation';
import useSWR from 'swr';
import RecordingForm from '@/components/pages/production/recording/form/RecordingForm';
import { RecordingApi } from '@/services/api/production';
import { isResponseError, isResponseSuccess } from '@/lib/api-helper';
const RecordingEdit = () => {
const router = useRouter();
const searchParams = useSearchParams();
const recordingId = searchParams.get('recordingId');
const { data: recording, isLoading: isLoadingRecording } = useSWR(
recordingId,
(id: number) => RecordingApi.getSingle(id) // Gunakan RecordingApi
);
if (!recordingId) {
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 (!isLoadingRecording && (!recording || isResponseError(recording))) {
router.replace('/404');
return;
}
return (
<div className='w-full p-4 flex flex-row justify-center'>
{isLoadingRecording && (
<span className='loading loading-spinner loading-xl' />
)}
{!isLoadingRecording && isResponseSuccess(recording) && (
<RecordingForm type='edit' initialValues={recording.data} />
)}
</div>
);
};
export default RecordingEdit;
@@ -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,47 @@
'use client';
import { useRouter, useSearchParams } from 'next/navigation';
import useSWR from 'swr';
import RecordingForm from '@/components/pages/production/recording/form/RecordingForm';
import { RecordingApi } from '@/services/api/production';
import { isResponseError, isResponseSuccess } from '@/lib/api-helper';
const RecordingDetail = () => {
const router = useRouter();
const searchParams = useSearchParams();
const recordingId = searchParams.get('recordingId');
const { data: recording, isLoading: isLoadingRecording } = useSWR(
recordingId,
(id: number) => RecordingApi.getSingle(id)
);
if (!recordingId) {
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 (!isLoadingRecording && (!recording || isResponseError(recording))) {
router.replace('/404');
return;
}
return (
<div className='w-full p-4 flex flex-row justify-center'>
{isLoadingRecording && (
<span className='loading loading-spinner loading-xl' />
)}
{!isLoadingRecording && isResponseSuccess(recording) && (
<RecordingForm type='detail' initialValues={recording.data} />
)}
</div>
);
};
export default RecordingDetail;
+11
View File
@@ -0,0 +1,11 @@
import RecordingTable from '@/components/pages/production/recording/RecordingTable';
const Recording = () => {
return (
<section className='w-full p-4'>
<RecordingTable />
</section>
);
};
export default Recording;
@@ -0,0 +1,11 @@
import TransferToLayingForm from '@/components/pages/production/transfer-to-laying/form/TransferToLayingForm';
const AddTransferToLaying = () => {
return (
<div className='w-full p-4 flex flex-row justify-center'>
<TransferToLayingForm />
</div>
);
};
export default AddTransferToLaying;
@@ -0,0 +1,148 @@
'use client';
import { useRouter, useSearchParams } from 'next/navigation';
import useSWR from 'swr';
import TransferToLayingForm from '@/components/pages/production/transfer-to-laying/form/TransferToLayingForm';
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();
const transferToLayingId = searchParams.get('transferToLayingId');
const { data: transferToLaying, isLoading: isLoadingTransferToLaying } =
useSWR(transferToLayingId, (id: number) =>
TransferToLayingApi.getSingle(id)
);
if (!transferToLayingId) {
router.back();
return (
<div className='w-full flex flex-row justify-center items-center p-4'>
<span className='loading loading-spinner loading-xl' />
</div>
);
}
// TODO: remove dummy data and integrate with real API
if (
!isLoadingTransferToLaying &&
(!transferToLaying ||
(isResponseError(transferToLaying) && !DUMMY_TRANSFER_TO_LAYING_EDIT))
) {
router.replace('/404');
return;
}
return (
<div className='w-full p-4 flex flex-row justify-center'>
{isLoadingTransferToLaying && (
<span className='loading loading-spinner loading-xl' />
)}
{/* {!isLoadingTransferToLaying && isResponseSuccess(transferToLaying) && (
<TransferToLayingForm
type='detail'
initialValues={transferToLaying.data}
/>
)} */}
{/* TODO: remove this dummy data and integrate to real API */}
<TransferToLayingForm
type='edit'
initialValues={DUMMY_TRANSFER_TO_LAYING_EDIT}
/>
</div>
);
};
export default TransferToLayingEdit;
@@ -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,148 @@
'use client';
import { useRouter, useSearchParams } from 'next/navigation';
import useSWR from 'swr';
import TransferToLayingForm from '@/components/pages/production/transfer-to-laying/form/TransferToLayingForm';
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();
const transferToLayingId = searchParams.get('transferToLayingId');
const { data: transferToLaying, isLoading: isLoadingTransferToLaying } =
useSWR(transferToLayingId, (id: number) =>
TransferToLayingApi.getSingle(id)
);
if (!transferToLayingId) {
router.back();
return (
<div className='w-full flex flex-row justify-center items-center p-4'>
<span className='loading loading-spinner loading-xl' />
</div>
);
}
// TODO: remove dummy data and integrate with real API
if (
!isLoadingTransferToLaying &&
(!transferToLaying ||
(isResponseError(transferToLaying) && !DUMMY_TRANSFER_TO_LAYING_DETAIL))
) {
router.replace('/404');
return;
}
return (
<div className='w-full p-4 flex flex-row justify-center'>
{isLoadingTransferToLaying && (
<span className='loading loading-spinner loading-xl' />
)}
{/* {!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>
);
};
export default TransferToLayingDetail;
@@ -0,0 +1,11 @@
import TransferToLayingsTable from '@/components/pages/production/transfer-to-laying/TransferToLayingsTable';
const TransferToLaying = () => {
return (
<section className='w-full p-4'>
<TransferToLayingsTable />
</section>
);
};
export default TransferToLaying;
+80
View File
@@ -0,0 +1,80 @@
'use client';
import { HTMLAttributes, ReactNode } from 'react';
import { cn } from '@/lib/helper';
export interface BadgeProps
extends Omit<HTMLAttributes<HTMLSpanElement>, 'className'> {
children?: ReactNode;
className?: {
badge?: string;
};
variant?: 'default' | 'outline' | 'ghost' | 'soft' | 'dash';
color?:
| 'neutral'
| 'primary'
| 'secondary'
| 'accent'
| 'info'
| 'success'
| 'warning'
| 'error';
size?: 'xs' | 'sm' | 'md' | 'lg' | 'xl';
}
const Badge = ({
children,
className,
variant = 'default',
color,
size = 'md',
...props
}: BadgeProps) => {
const getBadgeClasses = () => {
const baseClasses = 'badge';
const variantClasses = {
default: '',
outline: 'badge-outline',
ghost: 'badge-ghost',
soft: 'badge-soft',
dash: 'badge-dash',
};
const colorClasses = {
neutral: 'badge-neutral',
primary: 'badge-primary',
secondary: 'badge-secondary',
accent: 'badge-accent',
info: 'badge-info',
success: 'badge-success',
warning: 'badge-warning',
error: 'badge-error',
};
const sizeClasses = {
xs: 'badge-xs',
sm: 'badge-sm',
md: 'badge-md',
lg: 'badge-lg',
xl: 'badge-xl',
};
return cn(
baseClasses,
variantClasses[variant],
color && colorClasses[color],
sizeClasses[size],
className?.badge
);
};
return (
<span className={getBadgeClasses()} {...props}>
{children}
</span>
);
};
export default Badge;
+7 -3
View File
@@ -1,7 +1,5 @@
import react from 'react';
import Link from 'next/link';
import { cn } from '@/lib/helper';
import { Color } from '@/types/theme';
@@ -10,6 +8,8 @@ interface ButtonProps extends react.ComponentProps<'button'> {
color?: Color;
href?: string;
isLoading?: boolean;
target?: string;
rel?: string;
}
const Button = ({
@@ -22,6 +22,8 @@ const Button = ({
className,
disabled,
onClick,
target,
rel,
...props
}: ButtonProps) => {
const btnBaseClassName = cn(
@@ -43,7 +45,7 @@ const Button = ({
'btn-warning': color === 'warning',
'btn-error': color === 'error',
},
'h-fit justify-center items-center gap-2 rounded-xl p-2 text-base transition-all'
'h-fit justify-center items-center gap-2 rounded p-2 text-base transition-all'
);
return (
@@ -68,6 +70,8 @@ const Button = ({
{href && (
<Link
href={disabled ? '#' : href}
target={target}
rel={rel}
aria-disabled={disabled}
className={cn(
btnBaseClassName,
+148
View File
@@ -0,0 +1,148 @@
'use client';
import { HTMLAttributes, ReactNode } from 'react';
import { cn } from '@/lib/helper';
export interface CardProps
extends Omit<HTMLAttributes<HTMLDivElement>, 'className'> {
title?: string;
subtitle?: string;
image?: string;
imageAlt?: string;
actions?: ReactNode;
footer?: ReactNode;
className?: {
wrapper?: string;
image?: string;
body?: string;
title?: string;
subtitle?: string;
actions?: string;
footer?: string;
};
variant?: 'default' | 'compact' | 'bordered' | 'shadow' | 'image-full';
size?: 'sm' | 'md' | 'lg';
}
const Card = ({
title,
subtitle,
image,
imageAlt,
actions,
footer,
className,
variant = 'default',
size = 'md',
children,
...props
}: CardProps) => {
const getCardClasses = () => {
const baseClasses = 'card bg-base-100';
const variantClasses = {
default: '',
compact: 'card-compact',
bordered: 'border border-base-300',
shadow: 'shadow-xl',
'image-full': 'card-side card-compact shadow-xl',
};
const sizeClasses = {
sm: 'w-64',
md: 'w-96',
lg: 'w-[28rem]',
};
return cn(
baseClasses,
variantClasses[variant],
variant !== 'image-full' ? sizeClasses[size] : '',
className?.wrapper
);
};
const getImageClasses = () => {
if (variant === 'image-full') {
return cn('w-32 h-32 object-cover', className?.image);
}
return cn('h-48 object-cover', className?.image);
};
const getBodyClasses = () => {
const baseClasses = 'card-body';
if (variant === 'compact' || variant === 'image-full') {
return cn(baseClasses, 'p-4', className?.body);
}
return cn(baseClasses, 'p-6', className?.body);
};
const getTitleClasses = () => {
const sizeClasses = {
sm: 'text-lg',
md: 'text-xl',
lg: 'text-2xl',
};
return cn('card-title font-bold', sizeClasses[size], className?.title);
};
const getSubtitleClasses = () => {
return cn('text-base-content/70 text-sm mt-1', className?.subtitle);
};
const getActionsClasses = () => {
return cn('card-actions justify-end mt-4', className?.actions);
};
const getFooterClasses = () => {
return cn('border-t border-base-300 mt-4 pt-4', className?.footer);
};
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>}
</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>}
</div>
);
};
export default Card;
+1 -1
View File
@@ -68,7 +68,7 @@ export const Collapse = ({
'collapse',
variant === 'arrow' && 'collapse-arrow',
variant === 'plus' && 'collapse-plus',
bordered && 'border base-content/20 border-opacity-20 rounded-box',
bordered && 'border base-content/20 border-opacity-20 rounded',
disabled && 'opacity-60 pointer-events-none',
!open && 'w-fit',
className
+23 -1
View File
@@ -10,6 +10,7 @@ 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 { useUiStore } from '@/stores/ui/ui.store';
import { MAIN_DRAWER_LINKS } from '@/config/constant';
@@ -155,9 +156,15 @@ const MainDrawerMenu = () => {
};
const MainDrawerContent = () => {
const { setMainDrawerOpen } = useUiStore();
const closeMainDrawerHandler = () => {
setMainDrawerOpen(false);
};
return (
<div className='w-full p-4 flex flex-col gap-4'>
<div className='flex items-center gap-4'>
<div className='flex flex-row items-center gap-4'>
<Image
src='/assets/img/lti-logo.png'
alt='MBU Logo'
@@ -167,6 +174,21 @@ const MainDrawerContent = () => {
/>
<h1 className='text-xl font-bold'>LTI ERP</h1>
<div className='grow flex flex-row justify-end sm:hidden'>
<Button
variant='soft'
color='error'
onClick={closeMainDrawerHandler}
className='rounded-full'
>
<Icon
icon='material-symbols:close-rounded'
width={24}
height={24}
/>
</Button>
</div>
</div>
<MainDrawerMenu />
+10 -10
View File
@@ -185,17 +185,17 @@ const Pagination = ({
currentPage <= 2
? currentPage + 2
: currentPage === totalPages - 2
? 3
: currentPage >= totalPages - 1
? 4
: 1
? 3
: currentPage >= totalPages - 1
? 4
: 1
}
endPage={
currentPage <= 2 || currentPage >= totalPages - 1
? totalPages - 3
: currentPage === totalPages - 2
? totalPages - 4
: 2
? totalPages - 4
: 2
}
onPageItemClick={pageChangeHandler}
/>
@@ -242,15 +242,15 @@ const Pagination = ({
currentPage <= 3
? currentPage + 2
: currentPage >= 4
? currentPage + 2
: 1
? currentPage + 2
: 1
}
endPage={
currentPage <= 3
? totalPages - 2
: currentPage >= 4
? totalPages - 1
: 0
? totalPages - 1
: 0
}
onPageItemClick={pageChangeHandler}
/>
+31
View File
@@ -0,0 +1,31 @@
import { ReactNode } from 'react';
import { cn } from '@/lib/helper';
interface PillBadgeProps {
content: ReactNode;
color?: 'yellow' | 'blue' | 'green' | 'red' | 'purple' | 'gray';
className?: string;
}
const PillBadge = ({ content, color = 'gray', className }: PillBadgeProps) => {
return (
<div
className={cn(
'w-fit min-w-max px-2 py-0.5 flex justify-center items-center gap-1 rounded-full border border-gray-200 bg-gray-50 text-gray-500 drop-shadow-xs capitalize',
{
'border-yellow-200 bg-yellow-50 text-yellow-500': color === 'yellow',
'border-blue-200 bg-blue-50 text-blue-500': color === 'blue',
'border-green-200 bg-green-50 text-green-500': color === 'green',
'border-red-200 bg-red-50 text-red-500': color === 'red',
'border-purple-200 bg-purple-50 text-purple-500': color === 'purple',
'border-neutral-200 bg-neutral-50 text-neutral-500': color === 'gray',
},
className
)}
>
{content}
</div>
);
};
export default PillBadge;
+13
View File
@@ -48,6 +48,8 @@ export interface TableProps<TData extends object> {
sorting?: SortingState;
setSorting?: OnChangeFn<SortingState>;
manualSorting?: boolean;
rowSelection?: Record<string, boolean>;
setRowSelection?: OnChangeFn<Record<string, boolean>>;
}
const DUMMY_SKELETON_DATA = [{}, {}, {}, {}, {}];
@@ -86,6 +88,8 @@ const Table = <TData extends object>({
sorting,
setSorting,
manualSorting = false,
rowSelection,
setRowSelection,
}: TableProps<TData>) => {
const isServerSideTable =
totalItems !== undefined &&
@@ -137,6 +141,15 @@ const Table = <TData extends object>({
};
}
if (rowSelection && setRowSelection) {
tableOptions.onRowSelectionChange = setRowSelection;
tableOptions.state = {
...tableOptions.state,
rowSelection,
};
tableOptions.getRowId = (row) => (row as { id: string }).id;
}
const table = useReactTable(tableOptions);
const { setPageSize } = table;
+60
View File
@@ -0,0 +1,60 @@
import { ReactNode } from 'react';
import { cn } from '@/lib/helper';
import { Color } from '@/types/theme';
interface TooltipProps {
children?: ReactNode;
content?: ReactNode;
className?: {
wrapper?: string;
content?: string;
};
open?: boolean;
color?: Color;
position?: 'top' | 'bottom' | 'left' | 'right';
}
const Tooltip = ({
children,
content,
className,
open,
color,
position,
}: TooltipProps) => {
const tooltipBaseClassName = cn('tooltip', {
'tooltip-open': typeof open === 'boolean' && open,
'tooltip-top': position === 'top',
'tooltip-bottom': position === 'bottom',
'tooltip-left': position === 'left',
'tooltip-right': position === 'right',
'tooltip-primary': color === 'primary',
'tooltip-secondary': color === 'secondary',
'tooltip-accent': color === 'accent',
'tooltip-neutral': color === 'neutral',
'tooltip-info': color === 'info',
'tooltip-success': color === 'success',
'tooltip-warning': color === 'warning',
'tooltip-error': color === 'error',
});
return (
<div className={cn(tooltipBaseClassName, className?.wrapper)}>
<div
className={cn(
'tooltip-content',
'max-w-60 sm:max-w-xs',
className?.content
)}
>
{content}
</div>
{children}
</div>
);
};
export default Tooltip;
+2 -2
View File
@@ -158,7 +158,7 @@ const RequireAuth = ({ children }: RequireAuthProps) => {
const { data: userResponse, isLoading: isLoadingUserResponse } =
useSWRImmutable<GetMeResponse & { ok?: boolean }, unknown, SWRHttpKey>(
'/auth/get-me',
'/auth/sso/userinfo',
httpClientFetcher,
{
shouldRetryOnError: false,
@@ -194,4 +194,4 @@ const RequireAuth = ({ children }: RequireAuthProps) => {
return <>{children}</>;
};
export default RequireAuth;
export default RequireAuth;
@@ -0,0 +1,87 @@
import { Icon } from '@iconify/react';
import { FormikContextType } from 'formik';
import Button from '@/components/Button';
import { cn } from '@/lib/helper';
interface FormActionsProps<T> {
type: 'add' | 'edit' | 'detail';
formik: FormikContextType<T>;
editUrl?: string;
onDelete?: () => void;
disableSubmit?: boolean;
}
export const FormActions = <T,>({
type,
formik,
editUrl,
onDelete,
disableSubmit = false,
}: FormActionsProps<T>) => {
return (
<div className='flex flex-row justify-between gap-2 flex-wrap'>
{type !== 'add' && onDelete && (
<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>
{type !== 'edit' && editUrl && (
<Button
type='button'
color='warning'
href={editUrl}
className='px-4'
>
<Icon
icon='material-symbols:edit-outline'
width={24}
height={24}
className='justify-start text-sm'
/>
Edit
</Button>
)}
</div>
)}
{type !== 'detail' && (
<div
className={cn('flex flex-row justify-end gap-2', {
'w-full': type === 'add',
})}
>
<Button
type='reset'
color='warning'
className='px-4'
onClick={() => {
formik.handleReset();
formik.validateForm();
}}
>
Reset
</Button>
<Button
type='submit'
color='primary'
className='px-4'
isLoading={formik.isSubmitting}
disabled={disableSubmit || !formik.isValid || formik.isSubmitting}
>
Submit
</Button>
</div>
)}
</div>
);
};
+24
View File
@@ -0,0 +1,24 @@
import Button from '@/components/Button';
import { Icon } from '@iconify/react';
interface FormHeaderProps {
type: 'add' | 'edit' | 'detail';
title: string;
backUrl: string;
}
export const FormHeader = ({ type, title, backUrl }: FormHeaderProps) => {
return (
<header className='flex flex-col gap-4'>
<Button href={backUrl} 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'>
{type === 'add' && `Tambah ${title}`}
{type === 'edit' && `Edit ${title}`}
{type === 'detail' && `Detail ${title}`}
</h1>
</header>
);
};
+89
View File
@@ -0,0 +1,89 @@
'use client';
import { HTMLProps, useEffect, useRef } from 'react';
import { cn } from '@/lib/helper';
interface CheckboxInputProps extends HTMLProps<HTMLInputElement> {
name: string;
label?: string;
indeterminate?: boolean;
classNames?: {
wrapper?: string;
inputWrapper?: string;
checkbox?: string;
label?: string;
};
isError?: boolean;
isValid?: boolean;
errorMessage?: string;
}
const CheckboxInput = ({
indeterminate,
name,
label,
className,
classNames,
isValid,
isError,
errorMessage,
...rest
}: CheckboxInputProps) => {
const ref = useRef<HTMLInputElement>(null!);
useEffect(() => {
if (typeof indeterminate === 'boolean') {
ref.current.indeterminate = !rest.checked && indeterminate;
}
}, [ref, indeterminate]);
return (
<div
className={cn('flex flex-col items-center gap-1', classNames?.wrapper)}
>
<div
className={cn(
'flex flex-row justify-center items-center gap-2',
classNames?.inputWrapper
)}
>
<input
type='checkbox'
ref={ref}
id={name}
name={name}
className={cn(
'checkbox cursor-pointer',
{
'border-error': isError,
'border-success': isValid,
},
className,
classNames?.checkbox
)}
{...rest}
/>
{label && (
<label
htmlFor={name}
className={cn(
'text-inherit',
{
'text-error': isError,
'text-success': isValid,
},
classNames?.label
)}
>
{label}
</label>
)}
</div>
{errorMessage && <span className='text-error'>{errorMessage}</span>}
</div>
);
};
export default CheckboxInput;
+130
View File
@@ -0,0 +1,130 @@
'use client';
import { ChangeEventHandler, FocusEventHandler, ReactNode } from 'react';
import { cn } from '@/lib/helper';
export interface DateInputProps {
label?: string;
bottomLabel?: string;
name: string;
value?: string;
placeholder?: string;
min?: string;
max?: string;
className?: {
wrapper?: string;
label?: string;
inputWrapper?: string;
input?: string;
};
isError?: boolean;
isValid?: boolean;
disabled?: boolean;
readOnly?: boolean;
required?: boolean;
isLoading?: boolean;
errorMessage?: string;
startAdornment?: ReactNode;
endAdornment?: ReactNode;
onChange?: ChangeEventHandler<HTMLInputElement>;
onBlur?: FocusEventHandler<HTMLInputElement>;
}
const DateInput = ({
label,
bottomLabel,
name,
value,
placeholder,
min,
max,
className,
isError,
isValid,
errorMessage,
startAdornment,
endAdornment,
disabled = false,
required = false,
onChange,
onBlur,
readOnly = false,
isLoading = false,
}: DateInputProps) => {
return (
<div
className={cn(
'w-full flex flex-col gap-2 text-start',
className?.wrapper
)}
>
{label && (
<label
htmlFor={name}
className={cn(
'w-full text-sm font-normal leading-5',
{
'text-error': isError,
},
className?.label
)}
>
{label}
{required && (
<>
{' '}
<span className='tooltip tooltip-error' data-tip='required'>
<span className='text-error'>*</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',
{
'border-error': isError,
'border-success!': isValid,
},
className?.inputWrapper
)}
>
{startAdornment && startAdornment}
<input
type='date'
id={name}
name={name}
placeholder={placeholder}
value={value}
onChange={onChange}
onBlur={onBlur}
min={min}
max={max}
disabled={disabled}
className={cn('grow bg-transparent cursor-pointer', 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>
)}
{isError && errorMessage && (
<p className='w-full text-sm text-error'>{errorMessage}</p>
)}
</div>
);
};
export default DateInput;
+1 -4
View File
@@ -69,10 +69,7 @@ const FileInput = ({
onChange={onChange}
onBlur={onBlur}
disabled={disabled}
className={cn(
'grow file-input w-full h-12 rounded-lg!',
className?.input
)}
className={cn('grow file-input w-full h-12 rounded', className?.input)}
readOnly={readOnly}
/>
+59
View File
@@ -0,0 +1,59 @@
'use client';
import { ChangeEvent, ReactNode } from 'react';
import { NumericFormat, OnValueChange } from 'react-number-format';
import TextInput, { TextInputProps } from '@/components/input/TextInput';
interface NumberInputProps extends Omit<TextInputProps, 'type'> {
thousandSeparator?: string;
decimalSeparator?: string;
decimalScale?: number;
allowNegative?: boolean;
prefix?: string;
suffix?: string;
fixedDecimalScale?: boolean;
inputPrefix?: ReactNode;
inputSuffix?: ReactNode;
}
const NumberInput = ({
thousandSeparator = ',',
decimalSeparator = '.',
decimalScale = 5,
allowNegative = true,
onChange,
inputPrefix,
inputSuffix,
...restProps
}: NumberInputProps) => {
const valueChangeHandler: OnValueChange = (
numberFormatValues,
sourceInfo
) => {
const newChangeEvent = sourceInfo.event as
| ChangeEvent<HTMLInputElement>
| undefined;
if (newChangeEvent) {
newChangeEvent.target.value = numberFormatValues.value;
onChange?.(newChangeEvent);
}
};
return (
<NumericFormat
thousandSeparator={thousandSeparator}
decimalSeparator={decimalSeparator}
customInput={TextInput}
onValueChange={valueChangeHandler}
decimalScale={decimalScale}
allowNegative={allowNegative}
startAdornment={inputPrefix}
endAdornment={inputSuffix}
{...restProps}
/>
);
};
export default NumberInput;
+113
View File
@@ -0,0 +1,113 @@
'use client';
import { ChangeEventHandler, ReactNode } from 'react';
import { cn } from '@/lib/helper';
export interface RadioOption {
label: string;
value: string;
}
export interface RadioInputProps {
label?: string;
bottomLabel?: string;
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;
disabled?: boolean;
startAdornment?: ReactNode;
endAdornment?: ReactNode;
onChange?: ChangeEventHandler<HTMLInputElement>;
onBlur?: (e: React.FocusEvent<HTMLInputElement>) => void;
}
const RadioInput = ({
label,
bottomLabel,
name,
value,
options,
variant = 'radio-primary',
className,
isError,
errorMessage,
required = false,
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>
)}
{/* Daftar opsi radio */}
<div
className={cn(
'flex flex-row flex-wrap gap-4 items-center',
className?.radioWrapper
)}
>
{options.map((option) => (
<label
key={option.value}
className={cn(
'flex flex-row items-center gap-2 cursor-pointer',
disabled && 'opacity-60 cursor-not-allowed'
)}
>
<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>
))}
</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>
);
};
export default RadioInput;
+130 -81
View File
@@ -1,28 +1,37 @@
'use client';
import { ComponentType, ReactNode, useEffect, useMemo, useState } from 'react';
import Select, { OptionProps, GroupBase, InputActionMeta } from 'react-select';
import useSWR from 'swr';
import Select, {
OptionProps,
GroupBase,
InputActionMeta,
MultiValue,
SingleValue,
} from 'react-select';
import CreatableSelect from 'react-select/creatable';
import makeAnimated from 'react-select/animated';
import { useDebounce } from 'use-debounce';
import { cn } from '@/lib/helper';
import { cn, getByPath } from '@/lib/helper';
import { httpClientFetcher } from '@/services/http/client';
import { isResponseSuccess } from '@/lib/api-helper';
import { BaseApiResponse } from '@/types/api/api-general';
export interface OptionType {
value: string | number;
label: string;
className?: string; // for multi select
labelClassName?: string; // for multi select
className?: string;
labelClassName?: string;
}
export type OptionComponent<T = OptionType> = ComponentType<
OptionProps<T, boolean, GroupBase<T>>
>;
interface SelectInputProps<T = OptionType> {
interface SelectInputBaseProps<T = OptionType> {
label?: ReactNode;
bottomLabel?: ReactNode;
value?: T | T[];
onChange?: (val: T | T[] | null) => void;
options: T[];
optionComponent?: OptionComponent<T>;
isDisabled?: boolean;
@@ -46,52 +55,73 @@ interface SelectInputProps<T = OptionType> {
onInputChange?: (search: string) => void;
}
interface SelectInputProps<T = OptionType> extends SelectInputBaseProps<T> {
createables?: boolean;
value?: T | T[] | null;
onChange?: (val: T | T[] | null) => void;
}
const animatedComponents = makeAnimated();
const SelectInput = <T extends OptionType>({
label,
bottomLabel,
value,
onChange,
options,
optionComponent,
isDisabled,
isLoading,
isClearable,
isRtl,
isSearchable = true,
isMulti,
placeholder,
required,
className,
isError,
errorMessage,
isAnimated = true,
openMenu,
delay = 300,
onInputChange,
}: SelectInputProps) => {
const [internalInputValue, setInternalInputValue] = useState('');
const SelectInput = <T extends OptionType>(props: SelectInputProps<T>) => {
const {
label,
bottomLabel,
value,
onChange,
options,
optionComponent,
isDisabled,
isLoading,
isClearable,
isRtl,
isSearchable = true,
isMulti,
placeholder,
required,
className,
isError,
errorMessage,
isAnimated = true,
openMenu,
delay = 300,
createables = false,
onInputChange,
} = props;
const [debouncedInputValue] = useDebounce(internalInputValue, delay ?? 300);
const [internalInputValue, setInternalInputValue] = useState('');
const [debouncedInputValue] = useDebounce(internalInputValue, delay);
const components = useMemo(() => {
const base = isAnimated ? animatedComponents : {};
return {
...base,
IndicatorSeparator: () => null,
};
return { ...base, IndicatorSeparator: () => null };
}, [isAnimated]);
const internalInputChangeHandler = (value: string, meta: InputActionMeta) => {
if (meta.action === 'input-change') setInternalInputValue(value);
const internalInputChangeHandler = (val: string, meta: InputActionMeta) => {
if (meta.action === 'input-change') setInternalInputValue(val);
if (meta.action === 'menu-close') setInternalInputValue('');
};
useEffect(() => {
onInputChange?.(debouncedInputValue);
}, [debouncedInputValue]);
}, [onInputChange, debouncedInputValue]);
const SelectComponent = createables ? CreatableSelect : Select;
/** 🎯 handleChange tanpa any */
const handleChange = (val: MultiValue<T> | SingleValue<T>): void => {
if (!val) {
onChange?.(null);
return;
}
if (isMulti) {
onChange?.(val as T[]);
} else {
onChange?.(val as T);
}
};
return (
<div
className={cn(
@@ -103,28 +133,23 @@ const SelectInput = <T extends OptionType>({
<span
className={cn(
'w-full text-sm font-normal leading-5',
{
'text-error': isError,
},
{ 'text-error': isError },
className?.label
)}
>
{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>
)}
<Select
<SelectComponent<T, boolean, GroupBase<T>>
instanceId='select'
value={value}
onChange={(val) => onChange?.(val as T)}
value={value ?? (isMulti ? [] : null)}
onChange={handleChange}
options={options}
menuIsOpen={openMenu}
inputValue={internalInputValue}
@@ -136,14 +161,13 @@ const SelectInput = <T extends OptionType>({
isRtl={isRtl}
isSearchable={isSearchable}
placeholder={placeholder}
className={cn('w-full', className)}
className={cn('w-full', className?.select)}
classNames={{
control: ({ isFocused, isDisabled }) =>
cn(
'w-full min-h-12! rounded-lg! border bg-white transition-shadow cursor-pointer!',
'w-full min-h-12! rounded border bg-white transition-shadow cursor-pointer!',
{
'border-red-500! focus-within:border-red-500 focus-within:ring-2 focus-within:ring-red-200':
isError,
'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,
@@ -156,57 +180,41 @@ const SelectInput = <T extends OptionType>({
cn({ 'text-gray-900': !isError, 'text-error!': isError }),
input: () => cn('text-gray-900'),
indicatorsContainer: () => cn('flex items-center gap-1 pr-2'),
indicatorSeparator: () => cn('mx-1 h-4 w-px bg-gray-200'),
clearIndicator: () => cn('p-1 rounded-md hover:bg-gray-100'),
dropdownIndicator: ({ isFocused }) =>
cn('p-1 rounded-md hover:bg-gray-100', {
cn('p-1 rounded hover:bg-gray-100', {
'text-gray-900': isFocused,
'text-gray-500': !isFocused,
'text-error!': isError,
}),
menu: () =>
cn(
'border border-gray-200 rounded-lg bg-white shadow-lg rounded-lg!'
),
cn('border border-gray-200 rounded! bg-base-100 shadow-lg!'),
menuList: () => cn('p-2! max-h-60 overflow-auto'),
groupHeading: () =>
cn('ml-2 mt-2 mb-1 text-xs font-medium text-gray-500'),
option: ({ isFocused, isSelected, isDisabled }) =>
cn('mt-1 px-3 py-2 rounded-md cursor-pointer! select-none', {
'text-gray-300': isDisabled,
option: ({ isFocused, isSelected }) =>
cn('mt-1 px-3 py-2 rounded cursor-pointer!', {
'bg-indigo-600 text-white': isFocused,
'text-gray-700': !isDisabled && !isFocused,
'active:bg-indigo-50': !isDisabled,
'bg-blue-500!': isSelected,
'text-gray-700': !isFocused && !isSelected,
}),
noOptionsMessage: () => cn('px-3 py-2 text-gray-500'),
loadingMessage: () => cn('px-3 py-2 text-gray-500'),
multiValue: ({ getValue, index }) => {
const selectedValues = getValue();
const selectedValues = getValue() as T[];
return cn(
'bg-indigo-50 rounded-md py-0.5 pl-2 pr-1 flex items-center gap-1 rounded-md!',
'bg-indigo-50 rounded py-0.5 pl-2 pr-1 flex items-center gap-1!',
selectedValues[index]?.className
);
},
multiValueLabel: ({ getValue, index }) => {
const selectedValues = getValue();
const selectedValues = getValue() as T[];
return cn('text-indigo-700', selectedValues[index]?.labelClassName);
},
multiValueRemove: () =>
cn('p-1 rounded-sm! hover:bg-indigo-100 hover:text-indigo-800'),
}}
components={{
...components,
...(optionComponent ? { Option: optionComponent } : {}),
}}
// make the menu float above modals/etc.
menuPortalTarget={
typeof document !== 'undefined' ? document.body : undefined
}
styles={{
// Tailwind can't set inline z-index on a portal; use styles here:
menuPortal: (base) => ({ ...base, zIndex: 9999 }),
}}
/>
@@ -219,4 +227,45 @@ const SelectInput = <T extends OptionType>({
);
};
const useSelect = <T,>(
basePath: string,
valueKey: keyof T,
labelKey: keyof T,
searchKey: string = 'search',
params?: { [key: string]: string }
) => {
const [inputValue, setInputValue] = useState('');
const optionsUrlParams = useMemo(() => {
return new URLSearchParams({
[searchKey]: inputValue ?? '',
...params,
}).toString();
}, [inputValue, searchKey]);
const optionsUrl = `${basePath}?${optionsUrlParams}`;
const { data, isLoading } = useSWR(optionsUrl, async (url) => {
return await httpClientFetcher<BaseApiResponse<T[]>>(url);
});
const options = isResponseSuccess(data)
? data.data.map((item) => {
return {
value: getByPath<T, number>(item, valueKey as string),
label: getByPath<T, string>(item, labelKey as string),
};
})
: [];
return {
inputValue,
setInputValue,
options,
isLoadingOptions: isLoading,
rawData: data,
};
};
export { useSelect };
export default SelectInput;
+30 -34
View File
@@ -1,10 +1,6 @@
'use client';
import {
ChangeEventHandler,
FocusEventHandler,
ReactNode,
} from 'react';
import { ChangeEventHandler, FocusEventHandler, ReactNode } from 'react';
import { cn } from '@/lib/helper';
@@ -31,7 +27,7 @@ export interface TextAreaProps {
endAdornment?: ReactNode;
onChange?: ChangeEventHandler<HTMLTextAreaElement>;
onBlur?: FocusEventHandler<HTMLTextAreaElement>;
cols?: number;
rows?: number;
}
const TextArea = ({
@@ -52,7 +48,7 @@ const TextArea = ({
onBlur,
readOnly = false,
isLoading = false,
cols = 3
rows = 3,
}: TextAreaProps) => {
return (
<div
@@ -83,35 +79,35 @@ const TextArea = ({
)}
</label>
)}
{startAdornment && startAdornment}
{startAdornment && startAdornment}
<textarea
className={cn(
'input h-12 px-4 py-2 text-base font-normal leading-6 w-full rounded-lg! outline-none! transition-all',
{
'border-error': isError,
'border-success!': isValid,
},
className?.inputWrapper
)}
id={name}
name={name}
placeholder={placeholder}
value={value}
cols={cols}
onChange={onChange}
onBlur={onBlur}
disabled={disabled}
readOnly={readOnly}
/>
{(isLoading || endAdornment) && (
<div className='flex flex-row gap-2'>
{isLoading && <span className='loading loading-spinner' />}
{endAdornment && endAdornment}
</div>
<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',
{
'border-error': isError,
'border-success!': isValid,
},
className?.inputWrapper
)}
id={name}
name={name}
placeholder={placeholder}
value={value}
rows={rows}
onChange={onChange}
onBlur={onBlur}
disabled={disabled}
readOnly={readOnly}
/>
{(isLoading || endAdornment) && (
<div className='flex flex-row gap-2'>
{isLoading && <span className='loading loading-spinner' />}
{endAdornment && endAdornment}
</div>
)}
{!isError && bottomLabel && (
<p className='w-full text-sm opacity-60'>{bottomLabel}</p>
+1 -1
View File
@@ -87,7 +87,7 @@ const TextInput = ({
<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',
'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,
+6 -2
View File
@@ -49,14 +49,18 @@ const MenuItem = ({
);
return (
<li onClick={onClick}>
<li>
{href && (
<Link href={href} className={menuItemBaseClassName}>
{menuItemContent}
</Link>
)}
{!href && <a className={menuItemBaseClassName}>{menuItemContent}</a>}
{!href && (
<button className={menuItemBaseClassName} onClick={onClick}>
{menuItemContent}
</button>
)}
</li>
);
};
+181
View File
@@ -0,0 +1,181 @@
import { Icon } from '@iconify/react';
import Steps from '@/components/steps/Steps';
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 { ApprovalLine } from '@/types/config/constant';
export type ApprovalStepStatus = 'APPROVED' | 'REJECTED' | 'WAITING' | 'IDLE';
export type ApprovalStepLog = {
action_by?: string;
date?: string;
notes?: string | null;
};
interface ApprovalStepsProps {
approvals: {
name?: string;
status: ApprovalStepStatus;
logs?: ApprovalStepLog[];
}[];
}
const ApprovalSteps = ({ approvals }: ApprovalStepsProps) => {
return (
<Steps direction='vertical' className='w-full md:steps-horizontal'>
{approvals.map((approval, idx) => {
const stepItemColor =
approval.status === 'APPROVED'
? 'success'
: approval.status === 'REJECTED'
? 'error'
: approval.status === 'WAITING'
? 'warning'
: undefined;
const stepItemIcon =
approval.status === 'APPROVED'
? 'material-symbols:check-rounded'
: approval.status === 'REJECTED'
? 'material-symbols:close-rounded'
: approval.status === 'WAITING'
? 'pajamas:dash-circle'
: approval.logs && approval.logs.length > 0
? 'material-symbols:info-outline-rounded'
: 'bxs:hourglass';
return (
<StepItem
key={idx}
color={stepItemColor}
icon={
<Tooltip
color={stepItemColor}
position='right'
className={{
wrapper: 'md:tooltip-bottom',
}}
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>
)}
</>
}
>
<Icon
icon={stepItemIcon}
width={24}
height={24}
className={cn({
invisible:
approval.status === 'IDLE' &&
(!approval.logs ||
(approval.logs && approval.logs.length === 0)),
})}
/>
</Tooltip>
}
>
{approval.name}
</StepItem>
);
})}
</Steps>
);
};
export const formatGroupedApprovalsToApprovalSteps = (
approvalLine: ApprovalLine,
groupedApprovals: BaseGroupedApproval[],
latestApproval: BaseApproval
): ApprovalStepsProps['approvals'] => {
const formattedApprovalSteps: ApprovalStepsProps['approvals'] =
approvalLine.map((approvalLineItem) => {
const approvalGroup = groupedApprovals.find(
(approvalGroupItem) =>
approvalGroupItem.step_number === approvalLineItem.step_number
);
const currentStepNumber = approvalLineItem.step_number;
const lastStepNumber =
groupedApprovals[groupedApprovals.length - 1].step_number;
if (!approvalGroup && currentStepNumber <= lastStepNumber) {
throw new Error(
`Approval dengan ${approvalLineItem.step_name} tidak ditemukan!`
);
}
if (!approvalGroup) {
const isWaiting = currentStepNumber === latestApproval.step_number + 1;
return {
name: approvalLineItem.step_name,
status: isWaiting ? 'WAITING' : 'IDLE',
};
}
let approvalStatus: ApprovalStepStatus;
if (approvalGroup.step_number <= latestApproval.step_number) {
switch (approvalGroup.approvals[0].action) {
case 'CREATED':
case 'APPROVED':
approvalStatus = 'APPROVED';
break;
case 'REJECTED':
approvalStatus = 'REJECTED';
break;
default:
approvalStatus = 'IDLE';
break;
}
} else if (approvalGroup.step_number === latestApproval.step_number + 1) {
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,
})
);
return {
name: approvalGroup.step_name,
status: approvalStatus,
logs: approvalLogs,
};
});
return formattedApprovalSteps;
};
export default ApprovalSteps;
@@ -0,0 +1,261 @@
'use client';
import Button from '@/components/Button';
import SelectInput, { OptionType } from '@/components/input/SelectInput';
import Table from '@/components/Table';
import { ROWS_OPTIONS } from '@/config/constant';
import { isResponseSuccess } from '@/lib/api-helper';
import { cn } from '@/lib/helper';
import { inventoryAdjustmentApi } from '@/services/api/inventory';
import { useTableFilter } from '@/services/hooks/useTableFilter';
import { InventoryAdjustment } from '@/types/api/inventory/adjustment';
import { Icon } from '@iconify/react';
import { ColumnDef, ColumnSort, SortingState } from '@tanstack/react-table';
import { useCallback, useEffect, useState } from 'react';
import useSWR from 'swr';
const InventoryAdjustmentTable = () => {
const {
state: tableFilterState,
updateFilter,
setPage,
setPageSize,
toQueryString: getTableFilterQueryString,
} = useTableFilter({
initial: {
search: '',
productCategorySort: '',
productSort: '',
warehouseSort: '',
stockSort: '',
},
paramMap: {
page: 'page',
pageSize: 'limit',
productCategorySort: 'sort_product_category',
productSort: 'sort_product',
warehouseSort: 'sort_warehouse',
stockSort: 'sort_stock',
},
});
// Fetch Data
const { data: inventoryAdjustments, isLoading } = useSWR(
`${inventoryAdjustmentApi.basePath}${getTableFilterQueryString()}`,
inventoryAdjustmentApi.getAllFetcher
);
// State
const [sorting, setSorting] = useState<SortingState>([]);
// Columns
const inventoryAdjustmentsColumns: ColumnDef<InventoryAdjustment>[] = [
{
header: '#',
cell: (props) =>
tableFilterState.pageSize * (tableFilterState.page - 1) +
props.row.index +
1,
},
{
id: 'product_name',
header: 'Nama Produk',
accessorFn: (row) => row.product_warehouse?.product?.name ?? '-',
},
{
id: 'warehouse_name',
header: 'Gudang',
accessorFn: (row) => row.product_warehouse?.warehouse?.name ?? '-',
},
{
id: 'created_at',
header: 'Tanggal',
accessorFn: (row) =>
new Date(row.created_at).toLocaleDateString('id-ID', {
day: '2-digit',
month: 'short',
year: 'numeric',
}),
},
{
id: 'before_quantity',
header: 'Stok Sebelum',
accessorFn: (row) => formatNumber(String(row.before_quantity)),
},
{
id: 'after_quantity',
header: 'Stok Sesudah',
accessorFn: (row) => formatNumber(String(row.after_quantity)),
},
{
id: 'quantity',
header: 'Kuantitas',
accessorFn: (row) => formatNumber(String(row.quantity)),
},
{
id: 'transaction_type',
header: 'Tipe Transaksi',
accessorFn: (row) => {
if (row.transaction_type === 'INCREASE') return 'Peningkatan';
if (row.transaction_type === 'DECREASE') return 'Penurunan';
return '-';
},
cell: (props) => {
const type = props.row.original.transaction_type;
const label =
type === 'INCREASE'
? 'Peningkatan'
: type === 'DECREASE'
? 'Penurunan'
: '-';
return (
<div
className={`small mx-auto badge badge-soft ${
type === 'INCREASE' ? 'badge-success' : 'badge-error'
}`}
>
{label}
</div>
);
},
},
{
id: 'created_by',
header: 'Oleh',
accessorFn: (row) => row.created_user?.name ?? '-',
},
];
// Handler
const pageSizeChangeHandler = (val: OptionType | OptionType[] | null) => {
const newVal = val as OptionType;
setPageSize(newVal.value as number);
};
const updateSortingFilter = useCallback(
(
sortName: Exclude<keyof typeof tableFilterState, 'page' | 'pageSize'>,
sortFilter: ColumnSort | undefined
) => {
if (!sortFilter) {
updateFilter(sortName, '');
} else {
updateFilter(sortName, sortFilter.desc ? 'desc' : 'asc');
}
},
[updateFilter]
);
// Effect
useEffect(() => {
const productCategorySortFilter = sorting.find(
(sortItem) => sortItem.id === 'productCategory'
);
const productSortFilter = sorting.find(
(sortItem) => sortItem.id === 'product'
);
const warehouseSortFilter = sorting.find(
(sortItem) => sortItem.id === 'warehouse'
);
const stockSortFilter = sorting.find((sortItem) => sortItem.id === 'stock');
updateSortingFilter('productCategorySort', productCategorySortFilter);
updateSortingFilter('productSort', productSortFilter);
updateSortingFilter('warehouseSort', warehouseSortFilter);
updateSortingFilter('stockSort', stockSortFilter);
}, [sorting, updateSortingFilter]);
// Utils Function
const formatNumber = (value: string) => {
const numericValue = value.replace(/[^0-9.]/g, '');
const [integer, decimal] = numericValue.split('.');
const formattedInteger = integer.replace(/\B(?=(\d{3})+(?!\d))/g, ',');
return decimal ? `${formattedInteger}.${decimal}` : formattedInteger;
};
// Render
return (
<>
<div className='w-full p-0 sm:p-4'>
<div className='flex flex-col gap-2 mb-4'>
<div className='w-full flex flex-col sm:flex-row justify-between items-end sm:items-center gap-2'>
<div className='w-full flex flex-row'>
<Button
href='/inventory/adjustment/add'
variant='outline'
color='primary'
className='w-full sm:w-fit'
>
<Icon icon='ic:round-plus' width={24} height={24} />
Tambah
</Button>
{/* <DebouncedTextInput
name='search'
placeholder='Cari Stock Adjustment'
value={tableFilterState.search}
onChange={searchChangeHandler}
className={{ wrapper: 'sm:max-w-3xs' }}
/> */}
</div>
<div className='flex flex-row justify-end'>
<SelectInput
label='Baris'
options={ROWS_OPTIONS}
value={{
label: String(tableFilterState.pageSize),
value: tableFilterState.pageSize,
}}
onChange={pageSizeChangeHandler}
className={{ wrapper: 'min-w-28' }}
/>
</div>
</div>
<Table<InventoryAdjustment>
data={
isResponseSuccess(inventoryAdjustments)
? inventoryAdjustments?.data
: []
}
columns={inventoryAdjustmentsColumns}
pageSize={tableFilterState.pageSize}
page={
isResponseSuccess(inventoryAdjustments)
? inventoryAdjustments?.meta?.page
: 0
}
totalItems={
isResponseSuccess(inventoryAdjustments)
? inventoryAdjustments?.meta?.total_results
: 0
}
onPageChange={setPage}
isLoading={isLoading}
sorting={sorting}
setSorting={setSorting}
className={{
containerClassName: cn({
'mb-20':
isResponseSuccess(inventoryAdjustments) &&
inventoryAdjustments?.data?.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',
}}
/>
</div>
</div>
</>
);
};
export default InventoryAdjustmentTable;
@@ -0,0 +1,40 @@
import * as Yup from 'yup';
export const InventoryAdjustmentFormSchema = Yup.object({
product_category: Yup.object({
value: Yup.number().required('ID Kategori Produk wajib diisi!'),
label: Yup.string().required('Nama Kategori Produk wajib diisi!'),
}).nullable(),
product_category_id: Yup.number().nullable(),
product: Yup.object({
value: Yup.number().required('ID Produk wajib diisi!'),
label: Yup.string().required('Nama Produk wajib diisi!'),
}).nullable(),
product_id: Yup.number().nullable(),
warehouse: Yup.object({
value: Yup.number().required('ID Gudang wajib diisi!'),
label: Yup.string().required('Nama Gudang wajib diisi!'),
}).nullable(),
warehouse_id: Yup.number().nullable(),
transaction_type: Yup.string()
.oneOf(['increase', 'decrease'], 'Tipe transaksi tidak valid')
.nullable()
.required('Tipe transaksi wajib diisi'),
quantity: Yup.number()
.typeError('Kuantitas harus berupa angka')
.min(1, 'Minimal kuantitas adalah 1')
.required('Kuantitas wajib diisi'),
note: Yup.string().required('Catatan wajib diisi!'),
});
export type InventoryAdjustmentFormValues = Yup.InferType<
typeof InventoryAdjustmentFormSchema
>;
@@ -0,0 +1,464 @@
'use client';
import { isResponseError, isResponseSuccess } from '@/lib/api-helper';
import { inventoryAdjustmentApi } from '@/services/api/inventory';
import {
CreateInventoryAdjustmentPayload,
InventoryAdjustment,
} from '@/types/api/inventory/adjustment';
import { useFormik } from 'formik';
import { useRouter } from 'next/navigation';
import { useCallback, useEffect, useMemo, useState } from 'react';
import toast from 'react-hot-toast';
import {
InventoryAdjustmentFormSchema,
InventoryAdjustmentFormValues,
} from '@/components/pages/inventory/adjustment/form/InventoryAdjustmentForm.schema';
import useSWR from 'swr';
import {
ProductApi,
ProductCategoryApi,
WarehouseApi,
} from '@/services/api/master-data';
import Button from '@/components/Button';
import { Icon } from '@iconify/react';
import SelectInput, { OptionType } from '@/components/input/SelectInput';
import TextInput from '@/components/input/TextInput';
import RadioInput from '@/components/input/RadioInput';
import TextArea from '@/components/input/TextArea';
interface InventoryAdjustmentFormProps {
type?: 'add' | 'edit' | 'detail';
initialValues?: InventoryAdjustment;
}
const InventoryAdjustmentForm = ({
type = 'add',
initialValues,
}: InventoryAdjustmentFormProps) => {
// State
const router = useRouter();
const [
InventoryAdjustmentFormErrorMessage,
setInventoryAdjustmentFormErrorMessage,
] = useState('');
const [selectedProductCategories, setSelectedProductCategories] =
useState('');
const [disabledProduct, setDisabledProduct] = useState(true);
const [optionsProduct, setOptionsProduct] = useState<OptionType[]>([]);
const [quantityLabel, setQuantityLabel] = useState('Tambah Stok');
// Submit Handler
const createInventoryAdjustmentHandler = useCallback(
async (payload: CreateInventoryAdjustmentPayload) => {
const createInventoryAdjustmentRes =
await inventoryAdjustmentApi.create(payload);
if (isResponseError(createInventoryAdjustmentRes)) {
setInventoryAdjustmentFormErrorMessage(
createInventoryAdjustmentRes.message
);
return;
}
toast.success(createInventoryAdjustmentRes?.message as string);
router.push('/inventory/adjustment');
},
[router]
);
const formikInitialValues = useMemo<
Partial<InventoryAdjustmentFormValues>
>(() => {
return {
product_category_id: initialValues?.product_category?.id ?? 0,
product_id: initialValues?.product?.id ?? 0,
warehouse_id: initialValues?.warehouse?.id ?? 0,
product_category: undefined,
product: undefined,
warehouse: undefined,
quantity: initialValues?.quantity ?? 0,
transaction_type: undefined,
note: initialValues?.note ?? '',
};
}, [initialValues]);
// Formik
const formik = useFormik<InventoryAdjustmentFormValues>({
enableReinitialize: true,
initialValues: formikInitialValues as InventoryAdjustmentFormValues,
validationSchema: InventoryAdjustmentFormSchema,
onSubmit: async (values) => {
setInventoryAdjustmentFormErrorMessage('');
const payload: CreateInventoryAdjustmentPayload = {
product_id: values.product_id as number,
warehouse_id: values.warehouse_id as number,
quantity: values.quantity as number,
transaction_type: values.transaction_type as string,
note: values.note,
};
switch (type) {
case 'add':
await createInventoryAdjustmentHandler(payload);
break;
}
},
});
// Fetch Data
const productCategoriesUrl = `${
ProductCategoryApi.basePath
}?${new URLSearchParams({
search: '',
}).toString()}`;
const { data: productCategories, isLoading: isLoadingProductCategories } =
useSWR(productCategoriesUrl, ProductCategoryApi.getAllFetcher);
const productUrl = `${ProductApi.basePath}?${new URLSearchParams({
search: '',
product_category_id: selectedProductCategories,
}).toString()}`;
const { data: products, isLoading: isLoadingProducts } = useSWR(
productUrl,
ProductApi.getAllFetcher
);
const warehouseUrl = `${WarehouseApi.basePath}?${new URLSearchParams({
search: '',
}).toString()}`;
const { data: warehouses, isLoading: isLoadingWarehouses } = useSWR(
warehouseUrl,
WarehouseApi.getAllFetcher
);
// Map Data to Options
const optionsProductCategory = isResponseSuccess(productCategories)
? productCategories?.data.map((productCategory) => ({
value: productCategory.id,
label: productCategory.name,
}))
: [];
const optionsWarehouse = isResponseSuccess(warehouses)
? warehouses?.data.map((warehouse) => ({
value: warehouse.id,
label: warehouse.name,
}))
: [];
// Options Handler
const productCategoryChangeHandler = (
val: OptionType | OptionType[] | null
) => {
formik.setFieldTouched('product_category_id', true);
formik.setFieldValue('product_category_id', (val as OptionType)?.value);
formik.setFieldValue('product_category', val);
setSelectedProductCategories((val as OptionType)?.value as string);
const disabled = (val as OptionType)?.value == null;
setDisabledProduct(disabled);
formik.setFieldValue('product_id', 0);
formik.setFieldValue('product', null);
formik.setFieldTouched('product', false);
formik.setFieldTouched('product_id', false);
};
const productChangeHandler = (val: OptionType | OptionType[] | null) => {
formik.setFieldValue('product', val);
formik.setFieldTouched('product_id', true);
formik.setFieldValue('product_id', (val as OptionType)?.value);
};
const warehouseChangeHandler = (val: OptionType | OptionType[] | null) => {
formik.setFieldValue('warehouse', val);
formik.setFieldTouched('warehouse_id', true);
formik.setFieldValue('warehouse_id', (val as OptionType)?.value);
};
const resetHandler = () => {
formik.resetForm();
setQuantityLabel('Tambah Stok');
productCategoryChangeHandler(null);
productChangeHandler(null);
warehouseChangeHandler(null);
};
const { setValues: formikSetValues } = formik;
// Effect
useEffect(() => {
if (initialValues?.product_warehouse?.product?.id) {
setSelectedProductCategories(
String(initialValues.product_warehouse.product.id)
);
setDisabledProduct(false);
formik.setFieldValue(
'product_id',
initialValues.product_warehouse.product.id
);
formik.setFieldValue('product', {
value: initialValues.product_warehouse.product.id,
label: initialValues.product_warehouse.product.name,
});
formik.setFieldValue(
'warehouse_id',
initialValues.product_warehouse.warehouse.id
);
formik.setFieldValue('warehouse', {
value: initialValues.product_warehouse.warehouse.id,
label: initialValues.product_warehouse.warehouse.name,
});
formik.setFieldValue(
'quantity',
initialValues.product_warehouse.quantity
);
formik.setFieldValue(
'transaction_type',
initialValues.transaction_type.toLowerCase()
);
formik.setFieldValue('note', initialValues.note);
}
if (initialValues?.transaction_type) {
const type = initialValues.transaction_type.toLowerCase();
setQuantityLabel(type === 'increase' ? 'Tambah Stok' : 'Kurangi Stok');
}
}, [
formik,
initialValues,
setQuantityLabel,
setDisabledProduct,
setSelectedProductCategories,
]);
useEffect(() => {
formikSetValues(formikInitialValues as InventoryAdjustmentFormValues);
}, [formikSetValues, formikInitialValues]);
useEffect(() => {
if (isResponseSuccess(products)) {
const options = products.data.map((p) => ({
value: p.id,
label: p.name,
}));
setOptionsProduct(options);
}
}, [products]);
// Utils Function
const formatNumber = (value: string) => {
const numericValue = value.replace(/[^0-9.]/g, '');
const [integer, decimal] = numericValue.split('.');
const formattedInteger = integer.replace(/\B(?=(\d{3})+(?!\d))/g, ',');
return decimal ? `${formattedInteger}.${decimal}` : formattedInteger;
};
// Render
return (
<>
<section className='w-full max-w-xl'>
<header className='flex flex-col gap-4'>
<Button
href='/inventory/adjustment'
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'>
{type === 'add' && 'Tambah Penyesuaian Persediaan'}
{type === 'detail' && 'Detail Penyesuaian Persediaan'}
</h1>
</header>
<form
onSubmit={formik.handleSubmit}
onReset={formik.handleReset}
className='w-full mt-8 flex flex-col gap-6'
>
<div className='flex flex-col gap-4'>
{/* Text Input Before Quantity */}
{type === 'detail' && initialValues && (
<>
<TextInput
label='Stok Sebelum'
name='before_quantity'
type='text'
value={formatNumber(String(initialValues.before_quantity))}
readOnly={true}
/>
<TextInput
label='Stok Setelah'
name='after_quantity'
type='text'
readOnly={true}
value={formatNumber(String(initialValues.after_quantity))}
/>
</>
)}
{/* Select Input Product Category */}
<SelectInput
required
label='Kategori Produk'
value={formik.values.product_category as OptionType}
onChange={productCategoryChangeHandler}
onInputChange={setSelectedProductCategories}
options={optionsProductCategory}
isLoading={isLoadingProductCategories}
isError={
formik.touched.product_category &&
Boolean(formik.errors.product_category)
}
errorMessage={formik.errors.product_category as string}
isDisabled={type === 'detail'}
isClearable
/>
{/* Select Input Product */}
<SelectInput
required
label='Produk'
value={formik.values.product as OptionType}
onChange={productChangeHandler}
options={optionsProduct}
isLoading={isLoadingProducts}
isError={formik.touched.product && Boolean(formik.errors.product)}
errorMessage={formik.errors.product as string}
isDisabled={type === 'detail' || disabledProduct}
isClearable
/>
{/* Select Input Warehouse */}
<SelectInput
required
label='Warehouse'
value={formik.values.warehouse as OptionType}
onChange={warehouseChangeHandler}
options={optionsWarehouse}
isLoading={isLoadingWarehouses}
isError={
formik.touched.warehouse && Boolean(formik.errors.warehouse)
}
errorMessage={formik.errors.warehouse as string}
isDisabled={type === 'detail'}
isClearable
/>
{/* Radio Button Flag Stock */}
<RadioInput
name='transaction_type'
label='Tipe Transaksi'
options={[
{ label: 'Tambah', value: 'increase' },
{ label: 'Kurang', value: 'decrease' },
]}
value={formik.values.transaction_type}
onChange={(e) => {
formik.handleChange(e);
setQuantityLabel(
e.target.value === 'increase' ? 'Tambah Stok' : 'Kurangi Stok'
);
}}
onBlur={formik.handleBlur}
isError={
formik.touched.transaction_type &&
Boolean(formik.errors.transaction_type)
}
errorMessage={formik.errors.transaction_type as string}
variant='radio-primary'
required
bottomLabel={
formik.values.transaction_type == undefined
? 'Pilih salah satu tipe transaksi'
: undefined
}
disabled={type === 'detail'}
/>
{/* Number Input Stock */}
<TextInput
className={{
wrapper: `${formik.values.transaction_type != undefined ? '' : 'hidden'}`,
}}
required
label={quantityLabel}
name='quantity'
type='text'
value={formatNumber(String(formik.values.quantity))}
onChange={(e) => {
const rawValue = e.target.value.replace(/,/g, '');
const numericValue = parseFloat(rawValue);
if (!isNaN(numericValue)) {
formik.setFieldValue('quantity', numericValue);
} else {
formik.setFieldValue('quantity', 0);
}
}}
onBlur={formik.handleBlur}
isError={
formik.touched.quantity && Boolean(formik.errors.quantity)
}
errorMessage={formik.errors.quantity as string}
readOnly={type === 'detail'}
/>
{/* Text Area Input Reason */}
<TextArea
required
label='Alasan'
name='note'
value={formik.values.note as string}
onChange={formik.handleChange}
onBlur={formik.handleBlur}
isError={formik.touched.note && Boolean(formik.errors.note)}
errorMessage={formik.errors.note as string}
readOnly={type === 'detail'}
/>
</div>
<div className='flex flex-row justify-between gap-2 flex-wrap'>
{type !== 'detail' && (
<div className='flex flex-row justify-end gap-2'>
<Button
type='button'
color='warning'
className='px-4'
onClick={resetHandler}
>
Reset
</Button>
<Button
type='submit'
color='primary'
isLoading={formik.isSubmitting}
disabled={
!formik.isValid ||
formik.isSubmitting ||
formik.values.product == undefined
}
className='px-4'
>
Submit
</Button>
</div>
)}
</div>
{InventoryAdjustmentFormErrorMessage && (
<div role='alert' className='alert alert-error'>
<Icon
icon='material-symbols:error-outline'
width={24}
height={24}
/>
<span>{InventoryAdjustmentFormErrorMessage}</span>
</div>
)}
</form>
</section>
</>
);
};
export default InventoryAdjustmentForm;
@@ -0,0 +1,227 @@
'use client';
import { useState } from 'react';
import useSWR from 'swr';
import { SortingState } from '@tanstack/react-table';
import Table from '@/components/Table';
import { useModal } from '@/components/Modal';
import ConfirmationModal from '@/components/modal/ConfirmationModal';
import { Movement } from '@/types/api/inventory/movement';
import { MovementApi } from '@/services/api/inventory';
import { cn } from '@/lib/helper';
import { isResponseSuccess } from '@/lib/api-helper';
import { useTableFilter } from '@/services/hooks/useTableFilter';
import { ROWS_OPTIONS } from '@/config/constant';
import { TableToolbar } from '@/components/table/TableToolbar';
import { TableRowSizeSelector } from '@/components/table/TableRowSizeSelector';
import { OptionType } from '@/components/input/SelectInput';
import RowDropdownOptions from '@/components/table/RowDropdownOptions';
import RowCollapseOptions from '@/components/table/RowCollapseOptions';
import { TableRowOptions } from '@/components/table/TableRowOptions';
const MovementTable = () => {
const {
state: tableFilterState,
updateFilter,
setPage,
setPageSize,
toQueryString: getTableFilterQueryString,
} = useTableFilter({
initial: { search: '' },
paramMap: { page: 'page', pageSize: 'limit' },
});
const [sorting, setSorting] = useState<SortingState>([]);
const [selectedMovement, setSelectedMovement] = useState<
Movement | undefined
>(undefined);
const [isDeleteLoading, setIsDeleteLoading] = useState(false);
const deleteModal = useModal();
const {
data: movements,
isLoading,
mutate: refreshMovements,
} = useSWR(
`${MovementApi.basePath}${getTableFilterQueryString()}`,
MovementApi.getAllFetcher
);
const searchChangeHandler = (e: React.ChangeEvent<HTMLInputElement>) => {
updateFilter('search', e.target.value);
setPage(1);
};
const pageSizeChangeHandler = (val: OptionType | OptionType[] | null) => {
const newVal = val as OptionType;
setPageSize(newVal.value as number);
setPage(1);
};
const confirmationModalDeleteClickHandler = async () => {
setIsDeleteLoading(true);
try {
await MovementApi.delete(selectedMovement?.id as number);
refreshMovements();
deleteModal.closeModal();
} finally {
setIsDeleteLoading(false);
}
};
return (
<div className='flex flex-col gap-4'>
<div className='flex flex-col gap-2 mb-4'>
<TableToolbar
addButton={{
href: '/inventory/movement/add',
label: 'Tambah',
}}
search={{
value: tableFilterState.search,
onChange: searchChangeHandler,
placeholder: 'Cari Movement',
}}
/>
<TableRowSizeSelector
value={tableFilterState.pageSize}
onChange={pageSizeChangeHandler}
options={ROWS_OPTIONS}
/>
</div>
<Table<Movement>
data={isResponseSuccess(movements) ? movements?.data : []}
columns={[
{
header: '#',
cell: (props) =>
tableFilterState.pageSize * (tableFilterState.page - 1) +
props.row.index +
1,
},
{
accessorFn: (row) => row.source_warehouse?.name,
header: 'Gudang Asal',
},
{
accessorFn: (row) => row.destination_warehouse?.name,
header: 'Gudang Tujuan',
},
{
accessorKey: 'transfer_reason',
header: 'Catatan',
},
{
accessorKey: 'transfer_date',
header: 'Tanggal',
cell: (props) =>
new Date(props.row.original.transfer_date).toLocaleDateString(
'id-ID'
),
},
{
accessorFn: (row) => {
const totalCost = row.deliveries?.reduce(
(sum, d) => sum + (d.shipping_cost_total || 0),
0
);
return totalCost?.toLocaleString('id-ID');
},
header: 'Biaya Pengiriman',
},
{
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 - 2;
const deleteClickHandler = () => {
setSelectedMovement(props.row.original);
deleteModal.openModal();
};
return (
<>
{currentPageSize > 2 && (
<RowDropdownOptions isLast2Rows={isLast2Rows}>
<TableRowOptions
type='dropdown'
recordId={props.row.original.id}
basePath='/inventory/movement'
queryParam='movementId'
showEdit={false}
showDelete={false}
/>
</RowDropdownOptions>
)}
{currentPageSize <= 2 && (
<RowCollapseOptions>
<TableRowOptions
type='collapse'
recordId={props.row.original.id}
basePath='/inventory/movement'
queryParam='movementId'
showEdit={false}
showDelete={false}
/>
</RowCollapseOptions>
)}
</>
);
},
},
]}
pageSize={tableFilterState.pageSize}
page={isResponseSuccess(movements) ? movements?.meta?.page : 0}
totalItems={
isResponseSuccess(movements) ? movements?.meta?.total_results : 0
}
onPageChange={setPage}
isLoading={isLoading}
sorting={sorting}
setSorting={setSorting}
className={{
containerClassName: cn({
'mb-20':
isResponseSuccess(movements) && movements?.data?.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',
}}
/>
<ConfirmationModal
ref={deleteModal.ref}
type='error'
text={`Apakah anda yakin ingin menghapus data Movement ini?`}
secondaryButton={{
text: 'Tidak',
}}
primaryButton={{
text: 'Ya',
color: 'error',
isLoading: isDeleteLoading,
onClick: confirmationModalDeleteClickHandler,
}}
/>
</div>
);
};
export default MovementTable;
@@ -0,0 +1,210 @@
import * as Yup from 'yup';
import { Movement } from '@/types/api/inventory/movement';
export type ProductSchema = {
product: {
value: number;
label: string;
} | null;
product_id: number;
product_qty: number;
};
export type DeliverySchema = {
delivery_cost?: number | undefined;
delivery_cost_per_item?: number | undefined;
document?: File | string | null;
document_path?: string | null;
driver_name: string;
vehicle_plate: string;
supplier: {
value: number;
label: string;
} | null;
supplier_id: number;
products: {
product: {
value: number;
label: string;
} | null;
product_id: number;
product_qty: number;
}[];
};
const ProductObjectSchema: Yup.ObjectSchema<ProductSchema> = Yup.object({
product: Yup.object({
value: Yup.number().min(1).required(),
label: Yup.string().required(),
}).nullable(),
product_id: Yup.number().required('Produk wajib diisi!'),
product_qty: Yup.number()
.required('Qty wajib diisi!')
.min(1, 'Qty minimal 1!')
.typeError('Qty harus berupa angka!'),
});
const DeliveryProductObjectSchema = Yup.object({
product: Yup.object({
value: Yup.number().min(1).required(),
label: Yup.string().required(),
}).nullable(),
product_id: Yup.number().required('Produk wajib diisi!'),
product_qty: Yup.number()
.required('Qty wajib diisi!')
.min(1, 'Qty minimal 1!')
.typeError('Qty harus berupa angka!'),
});
const DeliveryObjectSchema: Yup.ObjectSchema<DeliverySchema> = Yup.object({
delivery_cost: Yup.number()
.transform((value) => (isNaN(value) || value === 0 ? undefined : value))
.min(1, 'Biaya minimal 1!')
.typeError('Biaya harus berupa angka!')
.test('one-of-cost-fields', 'Wajib diisi salah satu!', function (value) {
const { delivery_cost_per_item } = this.parent;
return (
(value !== undefined && value > 0) ||
(delivery_cost_per_item !== undefined && delivery_cost_per_item > 0)
);
}),
delivery_cost_per_item: Yup.number()
.transform((value) => (isNaN(value) || value === 0 ? undefined : value))
.min(1, 'Biaya per item minimal 1!')
.typeError('Biaya per item harus berupa angka!')
.test('one-of-cost-fields', 'Wajib diisi salah satu!', function (value) {
const { delivery_cost } = this.parent;
return (
(value !== undefined && value > 0) ||
(delivery_cost !== undefined && delivery_cost > 0)
);
}),
document_path: Yup.string().optional(),
document_index: Yup.number().optional(),
document: Yup.mixed<File | string>()
.nullable()
.test('fileSize', 'Ukuran dokumen maksimal 2 MB', (value) => {
if (!value) return true;
if (typeof value === 'string') return true;
if (value instanceof File) return value.size <= 2 * 1024 * 1024;
return false;
}),
driver_name: Yup.string().required('Nama sopir wajib diisi!'),
vehicle_plate: Yup.string().required('Plat nomor wajib diisi!'),
supplier: Yup.object({
value: Yup.number().min(1).required(),
label: Yup.string().required(),
}).nullable(),
supplier_id: Yup.number().required('Supplier wajib diisi!'),
products: Yup.array()
.of(DeliveryProductObjectSchema)
.min(1, 'Minimal harus ada 1 produk!')
.required('Produk wajib diisi!'),
});
export const MovementFormSchema = Yup.object({
transfer_reason: Yup.string().required('Alasan transfer wajib diisi!'),
transfer_date: Yup.string().required('Tanggal transfer wajib diisi!'),
source_warehouse: Yup.object({
value: Yup.number().min(1).required(),
label: Yup.string().required(),
area: Yup.string().optional(),
location: Yup.string().optional(),
}).nullable(),
source_warehouse_id: Yup.number()
.required('Gudang asal wajib diisi!')
.typeError('Gudang asal wajib diisi!'),
destination_warehouse: Yup.object({
value: Yup.number().min(1).required(),
label: Yup.string().required(),
area: Yup.string().optional(),
location: Yup.string().optional(),
}).nullable(),
destination_warehouse_id: Yup.number()
.required('Gudang tujuan wajib diisi!')
.typeError('Gudang tujuan wajib diisi!'),
products: Yup.array()
.of(ProductObjectSchema)
.min(1, 'Minimal harus ada 1 produk!')
.required('Produk wajib diisi!'),
deliveries: Yup.array()
.of(DeliveryObjectSchema)
.min(1, 'Minimal harus ada 1 pengiriman!')
.required('Pengiriman wajib diisi!'),
});
export const UpdateMovementFormSchema = MovementFormSchema;
export type MovementFormValues = Yup.InferType<typeof MovementFormSchema>;
export const getMovementFormInitialValues = (
initialValues?: Movement
): MovementFormValues => {
const detailIdToProductId = new Map<number, { id: number; name: string }>();
initialValues?.details?.forEach((detail) => {
detailIdToProductId.set(detail.id, {
id: detail.product.id,
name: detail.product.name,
});
});
return {
transfer_reason: initialValues?.transfer_reason ?? '',
transfer_date: initialValues?.transfer_date ?? '',
source_warehouse: initialValues?.source_warehouse
? {
value: initialValues.source_warehouse.id,
label: initialValues.source_warehouse.name,
area: initialValues.source_warehouse.area?.name ?? undefined,
location: initialValues.source_warehouse.location?.name ?? undefined,
}
: null,
source_warehouse_id: initialValues?.source_warehouse?.id ?? 0,
destination_warehouse: initialValues?.destination_warehouse
? {
value: initialValues.destination_warehouse.id,
label: initialValues.destination_warehouse.name,
area: initialValues.destination_warehouse.area?.name ?? undefined,
location:
initialValues.destination_warehouse.location?.name ?? undefined,
}
: null,
destination_warehouse_id: initialValues?.destination_warehouse?.id ?? 0,
products:
initialValues?.details?.map((detail) => ({
product: {
value: detail.product.id,
label: detail.product.name,
},
product_id: detail.product.id,
product_qty: detail.quantity,
})) ?? [],
deliveries:
initialValues?.deliveries?.map((d) => ({
delivery_cost: d.shipping_cost_total ?? undefined,
delivery_cost_per_item: d.shipping_cost_item ?? undefined,
document_number: d.document_number ?? '',
document: d.document_path ?? null,
document_path: d.document_path ?? null,
driver_name: d.driver_name ?? '',
vehicle_plate: d.vehicle_plate ?? '',
supplier: d.supplier
? { value: d.supplier.id, label: d.supplier.name }
: null,
supplier_id: d.supplier?.id ?? 0,
products:
d.items?.map((item) => {
const productData = detailIdToProductId.get(
item.stock_transfer_detail_id
);
return {
product: productData
? { value: productData.id, label: productData.name }
: null,
product_id: productData?.id ?? 0,
product_qty: item.quantity,
};
}) ?? [],
})) ?? [],
};
};
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,95 @@
import { useCallback, useState } from 'react';
import { useRouter } from 'next/navigation';
import { toast } from 'react-hot-toast';
import { useModal } from '@/components/Modal';
import { MovementApi } from '@/services/api/inventory';
import {
CreateMovementPayload,
UpdateMovementPayload,
} from '@/types/api/inventory/movement';
import { isResponseError } from '@/lib/api-helper';
export const useMovementFormHandlers = (initialValuesId?: number) => {
const router = useRouter();
const deleteModal = useModal();
const [movementFormErrorMessage, setMovementFormErrorMessage] = useState('');
const [isDeleteLoading, setIsDeleteLoading] = useState(false);
const createMovementHandler = useCallback(
async (payload: CreateMovementPayload, documents: File[] = []) => {
const formData = new FormData();
formData.append('data', JSON.stringify(payload));
documents.forEach((file, index) => {
formData.append(`documents[${index}]`, file);
});
const res = await MovementApi.create(
formData as unknown as CreateMovementPayload
);
if (isResponseError(res)) {
setMovementFormErrorMessage(res.message);
return;
}
toast.success(res?.message as string);
router.push('/inventory/movement');
},
[router]
);
const updateMovementHandler = useCallback(
async (
movementId: number,
payload: UpdateMovementPayload,
documents: File[] = []
) => {
let finalPayload: UpdateMovementPayload | FormData;
if (documents.length > 0) {
const formData = new FormData();
formData.append('data', JSON.stringify(payload));
documents.forEach((file, index) => {
formData.append(`documents[${index}]`, file);
});
finalPayload = formData as unknown as UpdateMovementPayload;
} else {
finalPayload = payload;
}
const res = await MovementApi.update(movementId, finalPayload);
if (res?.status === 'error') {
setMovementFormErrorMessage(res.message);
return;
}
toast.success(res?.message as string);
router.refresh();
router.push('/inventory/movement');
},
[router]
);
const deleteMovementClickHandler = useCallback(() => {
deleteModal.openModal();
}, [deleteModal]);
const confirmationModalDeleteClickHandler = useCallback(async () => {
if (!initialValuesId) return;
setIsDeleteLoading(true);
await MovementApi.delete(initialValuesId);
deleteModal.closeModal();
toast.success('Successfully delete Movement!');
setIsDeleteLoading(false);
router.push('/inventory/movement');
}, [deleteModal, initialValuesId, router]);
return {
deleteModal,
movementFormErrorMessage,
isDeleteLoading,
createMovementHandler,
updateMovementHandler,
deleteMovementClickHandler,
confirmationModalDeleteClickHandler,
};
};
@@ -14,6 +14,7 @@ import ConfirmationModal from '@/components/modal/ConfirmationModal';
import SelectInput, { OptionType } from '@/components/input/SelectInput';
import RowDropdownOptions from '@/components/table/RowDropdownOptions';
import RowCollapseOptions from '@/components/table/RowCollapseOptions';
import RowOptionsMenuWrapper from '@/components/table/RowOptionsMenuWrapper';
import { Area } from '@/types/api/master-data/area';
import { AreaApi } from '@/services/api/master-data';
@@ -32,16 +33,7 @@ const RowOptionsMenu = ({
deleteClickHandler: () => void;
}) => {
return (
<div
tabIndex={type === 'dropdown' ? 0 : undefined}
className={cn(
{
'dropdown-content': type === 'dropdown',
'mt-2': type === 'collapse',
},
'p-2.5 mr-2 flex flex-col gap-1 bg-base-100 rounded-box z-10 border border-black/10 shadow'
)}
>
<RowOptionsMenuWrapper type={type}>
<Button
href={`/master-data/area/detail/?areaId=${props.row.original.id}`}
variant='ghost'
@@ -76,7 +68,7 @@ const RowOptionsMenu = ({
/>
Delete
</Button>
</div>
</RowOptionsMenuWrapper>
);
};
@@ -150,7 +142,7 @@ const AreasTable = () => {
{currentPageSize <= 2 && (
<RowCollapseOptions>
<RowOptionsMenu
type='dropdown'
type='collapse'
props={props}
deleteClickHandler={deleteClickHandler}
/>
@@ -199,10 +191,15 @@ const AreasTable = () => {
<div className='w-full p-0 sm:p-4'>
<div className='flex flex-col gap-2 mb-4'>
<div className='w-full flex flex-col sm:flex-row justify-between items-end sm:items-center gap-2'>
<div className='flex flex-row'>
<Button href='/master-data/area/add' color='primary'>
<div className='w-full flex flex-row'>
<Button
href='/master-data/area/add'
variant='outline'
color='primary'
className='w-full sm:w-fit'
>
<Icon icon='ic:round-plus' width={24} height={24} />
Tambah Area
Tambah
</Button>
</div>
@@ -14,6 +14,7 @@ import ConfirmationModal from '@/components/modal/ConfirmationModal';
import SelectInput, { OptionType } from '@/components/input/SelectInput';
import RowDropdownOptions from '@/components/table/RowDropdownOptions';
import RowCollapseOptions from '@/components/table/RowCollapseOptions';
import RowOptionsMenuWrapper from '@/components/table/RowOptionsMenuWrapper';
import { Bank } from '@/types/api/master-data/bank';
import { BankApi } from '@/services/api/master-data';
@@ -32,16 +33,7 @@ const RowOptionsMenu = ({
deleteClickHandler: () => void;
}) => {
return (
<div
tabIndex={type === 'dropdown' ? 0 : undefined}
className={cn(
{
'dropdown-content': type === 'dropdown',
'mt-2': type === 'collapse',
},
'p-2.5 mr-2 flex flex-col gap-1 bg-base-100 rounded-box z-10 border border-black/10 shadow'
)}
>
<RowOptionsMenuWrapper type={type}>
<Button
href={`/master-data/bank/detail/?bankId=${props.row.original.id}`}
variant='ghost'
@@ -66,7 +58,7 @@ const RowOptionsMenu = ({
onClick={deleteClickHandler}
variant='ghost'
color='error'
className='text-error hover:text-inherit'
className='justify-start text-sm text-error focus-visible:text-error-content hover:text-error-content'
>
<Icon
icon='material-symbols:delete-outline-rounded'
@@ -76,7 +68,7 @@ const RowOptionsMenu = ({
/>
Delete
</Button>
</div>
</RowOptionsMenuWrapper>
);
};
@@ -163,7 +155,7 @@ const BanksTable = () => {
{currentPageSize <= 2 && (
<RowCollapseOptions>
<RowOptionsMenu
type='dropdown'
type='collapse'
props={props}
deleteClickHandler={deleteClickHandler}
/>
@@ -212,10 +204,15 @@ const BanksTable = () => {
<div className='w-full p-0 sm:p-4'>
<div className='flex flex-col gap-2 mb-4'>
<div className='w-full flex flex-col sm:flex-row justify-between items-end sm:items-center gap-2'>
<div className='flex flex-row'>
<Button href='/master-data/bank/add' color='primary'>
<div className='w-full flex flex-row'>
<Button
href='/master-data/bank/add'
variant='outline'
color='primary'
className='w-full sm:w-fit'
>
<Icon icon='ic:round-plus' width={24} height={24} />
Tambah Bank
Tambah
</Button>
</div>
@@ -8,6 +8,7 @@ import ConfirmationModal from '@/components/modal/ConfirmationModal';
import Table from '@/components/Table';
import RowCollapseOptions from '@/components/table/RowCollapseOptions';
import RowDropdownOptions from '@/components/table/RowDropdownOptions';
import RowOptionsMenuWrapper from '@/components/table/RowOptionsMenuWrapper';
import { ROWS_OPTIONS } from '@/config/constant';
import { isResponseSuccess } from '@/lib/api-helper';
import { cn } from '@/lib/helper';
@@ -15,10 +16,7 @@ import { CustomerApi } from '@/services/api/master-data';
import { useTableFilter } from '@/services/hooks/useTableFilter';
import { Customer } from '@/types/api/master-data/customer';
import { Icon } from '@iconify/react';
import {
CellContext,
ColumnDef,
} from '@tanstack/react-table';
import { CellContext, ColumnDef } from '@tanstack/react-table';
import { useState } from 'react';
import toast from 'react-hot-toast';
import useSWR from 'swr';
@@ -33,16 +31,7 @@ const RowOptionsMenu = ({
deleteClickHandler: () => void;
}) => {
return (
<div
tabIndex={type == 'dropdown' ? 0 : undefined}
className={cn(
{
'dropdown-content': type === 'dropdown',
'mt-2': type === 'collapse',
},
'p-2.5 mr-2 flex flex-col gap-1 bg-base-100 rounded-box z-10 border border-black/10 shadow'
)}
>
<RowOptionsMenuWrapper type={type}>
<Button
href={`/master-data/customer/detail/?customerId=${props.row.original.id}`}
variant='ghost'
@@ -53,10 +42,10 @@ const RowOptionsMenu = ({
Detail
</Button>
<Button
className='justify-start text-sm'
href={`/master-data/customer/detail/edit/?customerId=${props.row.original.id}`}
variant='ghost'
color='warning'
className='justify-start text-sm'
>
<Icon icon='material-symbols:edit-outline' width={16} height={16} />
Edit
@@ -65,7 +54,7 @@ const RowOptionsMenu = ({
onClick={deleteClickHandler}
variant='ghost'
color='error'
className='text-error hover:text-inherit'
className='justify-start text-sm text-error focus-visible:text-error-content hover:text-error-content'
>
<Icon
icon='material-symbols:delete-outline-rounded'
@@ -75,7 +64,7 @@ const RowOptionsMenu = ({
/>
Delete
</Button>
</div>
</RowOptionsMenuWrapper>
);
};
@@ -174,7 +163,7 @@ const CustomersTable = () => {
{currentPageSize <= 2 && (
<RowCollapseOptions>
<RowOptionsMenu
type='dropdown'
type='collapse'
props={props}
deleteClickHandler={deleteClickHandler}
/>
@@ -210,10 +199,15 @@ const CustomersTable = () => {
<div className='w-full p-0 sm:p-4'>
<div className='flex flex-col gap-2 mb-4'>
<div className='w-full flex flex-col sm:flex-row justify-between items-end sm:items-center gap-2'>
<div className='flex flex-row'>
<Button href='/master-data/customer/add' color='primary'>
<div className='w-full flex flex-row'>
<Button
href='/master-data/customer/add'
variant='outline'
color='primary'
className='w-full sm:w-fit'
>
<Icon icon='ic:round-plus' width={24} height={24} />
Tambah Customer
Tambah
</Button>
</div>
@@ -285,4 +279,4 @@ const CustomersTable = () => {
);
};
export default CustomersTable;
export default CustomersTable;
@@ -11,7 +11,11 @@ import {
import { useRouter } from 'next/navigation';
import { useCallback, useEffect, useMemo, useState } from 'react';
import toast from 'react-hot-toast';
import { CustomerFormSchema, CustomerFormValues, UpdateCustomerFormSchema } from './CustomerForm.schema';
import {
CustomerFormSchema,
CustomerFormValues,
UpdateCustomerFormSchema,
} from '@/components/pages/master-data/customer/form/CustomerForm.schema';
import { useFormik } from 'formik';
import Button from '@/components/Button';
import { Icon } from '@iconify/react';
@@ -41,7 +45,6 @@ const CustomerForm = ({
const [customerFormErrorMessage, setCustomerFormErrorMessage] = useState('');
const [isDeleteLoading, setIsDeleteLoading] = useState(false);
const [picSelectInputValue, setPicSelectInputValue] = useState('');
const [typeSelectInputValue, setTypeSelectInputValue] = useState('');
// Fetch Data
const picUrl = `${UserApi.basePath}?${new URLSearchParams({
@@ -151,7 +154,8 @@ const CustomerForm = ({
const formik = useFormik<CustomerFormValues>({
initialValues: formikInitialValues,
enableReinitialize: true,
validationSchema: formType === 'edit' ? UpdateCustomerFormSchema : CustomerFormSchema,
validationSchema:
formType === 'edit' ? UpdateCustomerFormSchema : CustomerFormSchema,
onSubmit: async (values) => {
// reset error message
setCustomerFormErrorMessage('');
@@ -252,7 +256,6 @@ const CustomerForm = ({
}
onChange={typeChangeHandler}
options={typeOptions}
onInputChange={setTypeSelectInputValue}
isError={formik.touched.type && Boolean(formik.errors.type)}
errorMessage={formik.errors.type as string}
isDisabled={formType === 'detail'}
@@ -309,7 +312,6 @@ const CustomerForm = ({
isError={formik.touched.address && Boolean(formik.errors.address)}
errorMessage={formik.errors.address}
readOnly={formType === 'detail'}
cols={8}
/>
</div>
@@ -14,6 +14,7 @@ import ConfirmationModal from '@/components/modal/ConfirmationModal';
import SelectInput, { OptionType } from '@/components/input/SelectInput';
import RowDropdownOptions from '@/components/table/RowDropdownOptions';
import RowCollapseOptions from '@/components/table/RowCollapseOptions';
import RowOptionsMenuWrapper from '@/components/table/RowOptionsMenuWrapper';
import { Fcr } from '@/types/api/master-data/fcr';
import { FcrApi } from '@/services/api/master-data';
@@ -32,16 +33,7 @@ const RowOptionsMenu = ({
deleteClickHandler: () => void;
}) => {
return (
<div
tabIndex={type === 'dropdown' ? 0 : undefined}
className={cn(
{
'dropdown-content': type === 'dropdown',
'mt-2': type === 'collapse',
},
'p-2.5 mr-2 flex flex-col gap-1 bg-base-100 rounded-box z-10 border border-black/10 shadow'
)}
>
<RowOptionsMenuWrapper type={type}>
<Button
href={`/master-data/fcr/detail/?fcrId=${props.row.original.id}`}
variant='ghost'
@@ -66,7 +58,7 @@ const RowOptionsMenu = ({
onClick={deleteClickHandler}
variant='ghost'
color='error'
className='text-error hover:text-inherit'
className='justify-start text-sm text-error focus-visible:text-error-content hover:text-error-content'
>
<Icon
icon='material-symbols:delete-outline-rounded'
@@ -76,7 +68,7 @@ const RowOptionsMenu = ({
/>
Delete
</Button>
</div>
</RowOptionsMenuWrapper>
);
};
@@ -150,7 +142,7 @@ const FcrsTable = () => {
{currentPageSize <= 2 && (
<RowCollapseOptions>
<RowOptionsMenu
type='dropdown'
type='collapse'
props={props}
deleteClickHandler={deleteClickHandler}
/>
@@ -199,10 +191,15 @@ const FcrsTable = () => {
<div className='w-full p-0 sm:p-4'>
<div className='flex flex-col gap-2 mb-4'>
<div className='w-full flex flex-col sm:flex-row justify-between items-end sm:items-center gap-2'>
<div className='flex flex-row'>
<Button href='/master-data/fcr/add' color='primary'>
<div className='w-full flex flex-row'>
<Button
href='/master-data/fcr/add'
variant='outline'
color='primary'
className='w-full sm:w-fit'
>
<Icon icon='ic:round-plus' width={24} height={24} />
Tambah FCR
Tambah
</Button>
</div>
@@ -0,0 +1,276 @@
'use client';
import { CellContext, ColumnDef } from '@tanstack/react-table';
import { Flock } from '@/types/api/master-data/flock';
import { cn } from '@/lib/helper';
import Button from '@/components/Button';
import { Icon } from '@iconify/react';
import { useTableFilter } from '@/services/hooks/useTableFilter';
import { useState } from 'react';
import useSWR from 'swr';
import { FlockApi } from '@/services/api/master-data';
import { useModal } from '@/components/Modal';
import RowDropdownOptions from '@/components/table/RowDropdownOptions';
import RowCollapseOptions from '@/components/table/RowCollapseOptions';
import RowOptionsMenuWrapper from '@/components/table/RowOptionsMenuWrapper';
import toast from 'react-hot-toast';
import DebouncedTextInput from '@/components/input/DebouncedTextInput';
import SelectInput, { OptionType } from '@/components/input/SelectInput';
import { ROWS_OPTIONS } from '@/config/constant';
import Table from '@/components/Table';
import { isResponseSuccess } from '@/lib/api-helper';
import ConfirmationModal from '@/components/modal/ConfirmationModal';
const RowsOptions = ({
type = 'dropdown',
props,
deleteClickHandler,
}: {
type: 'dropdown' | 'collapse';
props: CellContext<Flock, unknown>;
deleteClickHandler: () => void;
}) => {
return (
<RowOptionsMenuWrapper type={type}>
<Button
href={`/master-data/flock/detail/edit/?flockId=${props.row.original.id}`}
variant='ghost'
color='warning'
className='justify-start text-sm'
>
<Icon
icon='material-symbols:edit-outline'
width={16}
height={16}
className='justify-start text-sm'
/>
Edit
</Button>
<Button
href={`/master-data/flock/detail/?flockId=${props.row.original.id}`}
variant='ghost'
color='primary'
className='justify-start text-sm'
>
<Icon
icon='mdi:eye-outline'
width={16}
height={16}
className='justify-start text-sm'
/>
Detail
</Button>
<Button
onClick={deleteClickHandler}
variant='ghost'
color='error'
className='justify-start text-sm text-error focus-visible:text-error-content hover:text-error-content'
>
<Icon
icon='material-symbols:delete-outline-rounded'
width={16}
height={16}
className='justify-start text-sm'
/>
Delete
</Button>
</RowOptionsMenuWrapper>
);
};
const FlockTable = () => {
const {
state: tableFilterState,
updateFilter,
setPage,
setPageSize,
toQueryString: getTableFilterQueryString,
} = useTableFilter({
initial: { search: '', nameSort: '' },
paramMap: {
page: 'page',
pageSize: 'limit',
nameSort: 'sort_name',
},
});
// Fetch Data
const {
data: flocks,
isLoading,
mutate: refreshFlocks,
} = useSWR(
`${FlockApi.basePath}${getTableFilterQueryString()}`,
FlockApi.getAllFetcher
);
// State
const deleteModal = useModal();
const [selectedFlock, setSelectedFlock] = useState<Flock | undefined>(
undefined
);
const [isDeleteLoading, setIsDeleteLoading] = useState(false);
// Columns Definition
const flocksColumns: ColumnDef<Flock>[] = [
{
header: '#',
cell: (props) =>
tableFilterState.pageSize * (tableFilterState.page - 1) +
props.row.index +
1,
},
{
accessorKey: 'name',
header: 'Nama',
},
{
accessorKey: 'created_at',
header: 'Dibuat pada',
cell: (props) =>
new Date(props.row.original.created_at).toLocaleDateString(),
},
{
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 - 2;
const deleteClickHandler = () => {
setSelectedFlock(props.row.original);
deleteModal.openModal();
};
return (
<>
{currentPageSize > 2 && (
<RowDropdownOptions isLast2Rows={isLast2Rows}>
<RowsOptions
type='dropdown'
props={props}
deleteClickHandler={deleteClickHandler}
/>
</RowDropdownOptions>
)}
{currentPageSize <= 2 && (
<RowCollapseOptions>
<RowsOptions
type='collapse'
props={props}
deleteClickHandler={deleteClickHandler}
/>
</RowCollapseOptions>
)}
</>
);
},
},
];
// Handler
const confirmationModalDeleteClickHandler = async () => {
setIsDeleteLoading(true);
await FlockApi.delete(selectedFlock?.id as number);
refreshFlocks();
deleteModal.closeModal();
toast.success('Successfully delete Flock!');
setIsDeleteLoading(false);
};
const searchChangeHandler = (e: React.ChangeEvent<HTMLInputElement>) => {
updateFilter('search', e.target.value);
};
const pageSizeChangeHandler = (val: OptionType | OptionType[] | null) => {
const newVal = val as OptionType;
setPageSize(newVal.value as number);
};
return (
<>
<div className='w-full p-0 sm:p-4'>
<div className='flex flex-col gap-2 mb-4'>
<div className='w-full flex flex-col sm:flex-row justify-between items-end sm:items-center gap-2'>
<div className='w-full flex flex-row'>
<Button
href='/master-data/flock/add'
variant='outline'
color='primary'
className='w-full sm:w-fit'
>
<Icon icon='ic:round-plus' width={24} height={24} />
Tambah
</Button>
</div>
<DebouncedTextInput
name='search'
placeholder='Cari Flock'
value={tableFilterState.search}
onChange={searchChangeHandler}
className={{ wrapper: 'sm:max-w-3xs' }}
/>
</div>
<div className='flex flex-row justify-end'>
<SelectInput
label='Baris'
options={ROWS_OPTIONS}
value={{
label: String(tableFilterState.pageSize),
value: tableFilterState.pageSize,
}}
onChange={pageSizeChangeHandler}
className={{ wrapper: 'max-w-28' }}
/>
</div>
</div>
<Table<Flock>
data={isResponseSuccess(flocks) ? flocks?.data : []}
columns={flocksColumns}
pageSize={tableFilterState.pageSize}
page={isResponseSuccess(flocks) ? flocks?.meta?.page : 0}
totalItems={
isResponseSuccess(flocks) ? flocks?.meta?.total_results : 0
}
onPageChange={setPage}
isLoading={isLoading}
className={{
containerClassName: cn({
'mb-20': isResponseSuccess(flocks) && flocks?.data?.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',
}}
/>
</div>
<ConfirmationModal
ref={deleteModal.ref}
type='error'
text={`Apakah anda yakin ingin menghapus data Supplier ini (${selectedFlock?.name})?`}
secondaryButton={{
text: 'Tidak',
}}
primaryButton={{
text: 'Ya',
color: 'error',
isLoading: isDeleteLoading,
onClick: confirmationModalDeleteClickHandler,
}}
/>
</>
);
};
export default FlockTable;
@@ -0,0 +1,11 @@
import * as Yup from 'yup';
export const FlockFormSchema = Yup.object({
name: Yup.string()
.required('Nama wajib diisi!')
.matches(/^[\p{L}\p{N}\s]+$/u, 'Nama tidak boleh mengandung simbol'),
});
export const UpdateFlockFormSchema = FlockFormSchema;
export type FlockFormValues = Yup.InferType<typeof FlockFormSchema>;
@@ -0,0 +1,222 @@
'use client';
import { useModal } from '@/components/Modal';
import { FlockApi } from '@/services/api/master-data';
import { Flock } from '@/types/api/master-data/flock';
import { useRouter } from 'next/navigation';
import { useEffect, useMemo, useState } from 'react';
import {
FlockFormSchema,
FlockFormValues,
UpdateFlockFormSchema,
} from '@/components/pages/master-data/flock/form/FlockForm.schema';
import { useFormik } from 'formik';
import Button from '@/components/Button';
import { Icon } from '@iconify/react';
import TextInput from '@/components/input/TextInput';
import { cn } from '@/lib/helper';
import ConfirmationModal from '@/components/modal/ConfirmationModal';
interface FlockCustomProps {
formType?: 'add' | 'edit' | 'detail';
initialValues?: Flock;
}
const FlockForm = ({ formType = 'add', initialValues }: FlockCustomProps) => {
const router = useRouter();
const deleteModal = useModal();
// State
const [flockFormErrorMessage, setFlockFormErrorMessage] = useState('');
const [isDeleteLoading, setIsDeleteLoading] = useState(false);
// Handler
const confirmationModalDeleteClickHandler = async () => {
setIsDeleteLoading(true);
await FlockApi.delete(initialValues?.id as number);
deleteModal.closeModal();
setIsDeleteLoading(false);
router.push('/master-data/flock');
};
// Initital Value
const formikInitialValue = useMemo<FlockFormValues>(() => {
return {
name: initialValues?.name ?? '',
};
}, [initialValues]);
// Formik
const formik = useFormik<FlockFormValues>({
initialValues: formikInitialValue,
enableReinitialize: true,
validationSchema:
formType === 'edit' ? UpdateFlockFormSchema : FlockFormSchema,
onSubmit: async (values) => {
// reset error message
setFlockFormErrorMessage('');
// create payload
const payload = {
name: values.name,
};
// cek type form yang disubmit
switch (formType) {
case 'add':
await FlockApi.create(payload);
break;
case 'edit':
await FlockApi.update(initialValues?.id as number, payload);
break;
default:
break;
}
router.push('/master-data/flock');
},
});
// Initialize Formik
const { setValues: formikSetValues } = formik;
useEffect(() => {
formikSetValues(formikInitialValue);
}, [formikSetValues, formikInitialValue]);
// Render
return (
<>
<section className='w-full max-w-xl'>
<header className='flex flex-col gap-4'>
<Button
href='/master-data/flock'
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'>
{formType === 'add' && 'Tambah Flock'}
{formType === 'edit' && 'Ubah Flock'}
{formType === 'detail' && 'Detail Flock'}
</h1>
</header>
<form
onSubmit={formik.handleSubmit}
onReset={formik.handleReset}
className='w-full mt-8 flex flex-col gap-6'
>
{/* Fields Form */}
<div className='flex flex-col gap-4'>
<TextInput
required
label='Nama Flock'
name='name'
placeholder='Masukkan nama flock'
value={formik.values.name}
onChange={formik.handleChange}
onBlur={formik.handleBlur}
isError={formik.touched.name && Boolean(formik.errors.name)}
errorMessage={formik.errors.name}
readOnly={formType === 'detail'}
/>
</div>
{/* Action Button */}
<div className='flex flex-row justify-between gap-2 flex-wrap'>
{formType !== 'add' && (
<div className='flex flex-row justify-start gap-2'>
<Button
type='button'
color='error'
onClick={() => deleteModal.openModal()}
className='px-4'
>
<Icon
icon='material-symbols:delete-outline-rounded'
width={24}
height={24}
className='justify-start text-sm'
/>
Delete
</Button>
{formType !== 'edit' && (
<Button
type='button'
color='warning'
href={`/master-data/flock/detail/edit/?flockId=${initialValues?.id}`}
className='px-4'
>
<Icon
icon='material-symbols:edit-outline'
width={24}
height={24}
className='justify-start text-sm'
/>
Edit
</Button>
)}
</div>
)}
{formType !== 'detail' && (
<div
className={cn('flex flex-row justify-end gap-2', {
'w-full': formType === 'add',
})}
>
<Button type='reset' color='warning' className='px-4'>
Reset
</Button>
<Button
type='submit'
color='primary'
isLoading={formik.isSubmitting}
disabled={!formik.isValid || formik.isSubmitting}
className='px-4'
>
Submit
</Button>
</div>
)}
</div>
{flockFormErrorMessage && (
<div role='alert' className='alert alert-error'>
<Icon
icon='material-symbols:error-outline'
width={24}
height={24}
/>
<span>{flockFormErrorMessage}</span>
</div>
)}
</form>
</section>
{formType !== 'add' && (
<ConfirmationModal
ref={deleteModal.ref}
type='error'
text={`Apakah anda yakin ingin menghapus data Flock ini (${initialValues?.name})?`}
secondaryButton={{
text: 'Tidak',
}}
primaryButton={{
text: 'Ya',
color: 'error',
onClick: confirmationModalDeleteClickHandler,
isLoading: isDeleteLoading,
}}
/>
)}
</>
);
};
export default FlockForm;
@@ -19,6 +19,7 @@ import ConfirmationModal from '@/components/modal/ConfirmationModal';
import SelectInput, { OptionType } from '@/components/input/SelectInput';
import RowDropdownOptions from '@/components/table/RowDropdownOptions';
import RowCollapseOptions from '@/components/table/RowCollapseOptions';
import RowOptionsMenuWrapper from '@/components/table/RowOptionsMenuWrapper';
import { Kandang } from '@/types/api/master-data/kandang';
import { KandangApi } from '@/services/api/master-data';
@@ -37,16 +38,7 @@ const RowOptionsMenu = ({
deleteClickHandler: () => void;
}) => {
return (
<div
tabIndex={type === 'dropdown' ? 0 : undefined}
className={cn(
{
'dropdown-content': type === 'dropdown',
'mt-2': type === 'collapse',
},
'p-2.5 mr-2 flex flex-col gap-1 bg-base-100 rounded-box z-10 border border-black/10 shadow'
)}
>
<RowOptionsMenuWrapper type={type}>
<Button
href={`/master-data/kandang/detail/?kandangId=${props.row.original.id}`}
variant='ghost'
@@ -71,7 +63,7 @@ const RowOptionsMenu = ({
onClick={deleteClickHandler}
variant='ghost'
color='error'
className='text-error hover:text-inherit'
className='justify-start text-sm text-error focus-visible:text-error-content hover:text-error-content'
>
<Icon
icon='material-symbols:delete-outline-rounded'
@@ -81,7 +73,7 @@ const RowOptionsMenu = ({
/>
Delete
</Button>
</div>
</RowOptionsMenuWrapper>
);
};
@@ -173,7 +165,7 @@ const KandangsTable = () => {
{currentPageSize <= 2 && (
<RowCollapseOptions>
<RowOptionsMenu
type='dropdown'
type='collapse'
props={props}
deleteClickHandler={deleteClickHandler}
/>
@@ -238,10 +230,15 @@ const KandangsTable = () => {
<div className='w-full p-0 sm:p-4'>
<div className='flex flex-col gap-2 mb-4'>
<div className='w-full flex flex-col sm:flex-row justify-between items-end sm:items-center gap-2'>
<div className='flex flex-row'>
<Button href='/master-data/kandang/add' color='primary'>
<div className='w-full flex flex-row'>
<Button
href='/master-data/kandang/add'
variant='outline'
color='primary'
className='w-full sm:w-fit'
>
<Icon icon='ic:round-plus' width={24} height={24} />
Tambah Kandang
Tambah
</Button>
</div>

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