mirror of
https://gitlab.com/mbugroup/lti-web-client.git
synced 2026-05-20 21:41:57 +00:00
Compare commits
1158 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| ee0c47b0a1 | |||
| 93d4ff9339 | |||
| 39cb38a23f | |||
| c1087b37fb | |||
| c4e27edd56 | |||
| b020f2b187 | |||
| 375de4c86c | |||
| 8f361c4327 | |||
| 710be88794 | |||
| 0f7a2bd796 | |||
| 0c8a833e00 | |||
| 0c42bfd70c | |||
| 85dee607e0 | |||
| 6c7e310e67 | |||
| 85f6677c2a | |||
| 811850857d | |||
| 5494cb0ff2 | |||
| 11eeac3289 | |||
| 1621f2ab7d | |||
| 5540787154 | |||
| 1b499bc967 | |||
| 44a5c51023 | |||
| aa13e989c1 | |||
| ebe7c367e7 | |||
| 2f085c287f | |||
| 058f9f403d | |||
| 8b8b7be4b7 | |||
| efcecf4f66 | |||
| a6c63a7dcb | |||
| 0263db9fae | |||
| cc08e3af15 | |||
| 0929461ec5 | |||
| ace6633f79 | |||
| f1a952ca6b | |||
| ed34a99117 | |||
| 4beaba1f15 | |||
| 8ea029efdd | |||
| 02e4dba288 | |||
| c42fdbf33d | |||
| 2cfa8c046b | |||
| 30d5516161 | |||
| f83abc91da | |||
| 918c51e83b | |||
| f1a4d9b648 | |||
| 29e33560f8 | |||
| fb9e863862 | |||
| 1b3e5f94f1 | |||
| e1856926ea | |||
| 2b096099d3 | |||
| ea25417e8d | |||
| deabb1c3ee | |||
| 121c44070c | |||
| 0dbad23cd5 | |||
| b9a17f472b | |||
| c07b245eeb | |||
| d7e32f8f5b | |||
| 698fe2e851 | |||
| cdf0442a2b | |||
| 422c7c9fb0 | |||
| 3042b54577 | |||
| e5a686e5ee | |||
| 37d5a6b675 | |||
| 2ff32094ce | |||
| 7207f1ba75 | |||
| 41d2e8737b | |||
| b2016314f5 | |||
| 7366d6490c | |||
| e5e9b517fd | |||
| b6629b0bbb | |||
| bac6766fa2 | |||
| 9389fa0354 | |||
| 37bc7a85e5 | |||
| 667eb41eb2 | |||
| e64b55e527 | |||
| 9710998dc6 | |||
| ca0b216ba0 | |||
| 9ff6f3a35d | |||
| 333dd01f92 | |||
| 75f765ee69 | |||
| 945bdb8b27 | |||
| 77eae32a3d | |||
| a5ebc6d1ae | |||
| 15c7452d7b | |||
| 5dac900a1a | |||
| 4b49cd18f5 | |||
| a4cb4e202b | |||
| 4a69eef294 | |||
| 2de6636bbf | |||
| a7951b6c28 | |||
| 03baba40a6 | |||
| 96ef6f8496 | |||
| 94ab48d3f6 | |||
| ea88c3ce8e | |||
| 267ef9d812 | |||
| b5fc1d4310 | |||
| c98e7d8cb3 | |||
| 1acbc91cfe | |||
| 807041834b | |||
| 4de21561b3 | |||
| 1938f6cbda | |||
| f4a522fc0c | |||
| 7ae04b3f3e | |||
| b786acf71a | |||
| bb28ae8613 | |||
| 080592ff01 | |||
| 6d41203a5e | |||
| 89d7d3ef91 | |||
| 18ebf75aa7 | |||
| 6e7dfebacc | |||
| 4b93cb4589 | |||
| 58f1ab82c7 | |||
| 1fb9687142 | |||
| 4f6d71f1f4 | |||
| d502ec707c | |||
| fa86f488e1 | |||
| 5e5400f56b | |||
| 741884ac29 | |||
| 4e278c5687 | |||
| 3d2e40518b | |||
| cbab7f52f2 | |||
| ceb316d3da | |||
| 9ea152aef9 | |||
| 910ea85b62 | |||
| 968243c370 | |||
| f1ba577a97 | |||
| c6b906a28e | |||
| eafcfd2f28 | |||
| 0e5d38f75c | |||
| f2b59ded3c | |||
| 1341b1ff53 | |||
| 9c4c750664 | |||
| d3501e5f3d | |||
| d96388e5f4 | |||
| 749b7d6f1a | |||
| aadf10b8b9 | |||
| 7db6ae4077 | |||
| 7eaf6b7a3a | |||
| 8397d76171 | |||
| 56d4b8a5c9 | |||
| ef9d820c0d | |||
| 4e3c6736ab | |||
| aa1ef7a559 | |||
| 04b5a7bd4d | |||
| 3aec412599 | |||
| 80a94c48c3 | |||
| 9bd4a73a90 | |||
| d1c6fe8fb4 | |||
| a4378ebd04 | |||
| 16f2f2bc06 | |||
| 64843a36ab | |||
| 396a5ab5ba | |||
| 9f4c041ec8 | |||
| 5e3d2273d1 | |||
| 0b01eefe20 | |||
| 43045b3f8b | |||
| d3ce60d3ba | |||
| 8c7577dcc5 | |||
| da3cadc37d | |||
| 2e6aa1b83a | |||
| 8811976f53 | |||
| 9fb65bdacd | |||
| 53e018aece | |||
| 6f6f54571f | |||
| 3099588141 | |||
| 47ee911852 | |||
| b4d0ed1537 | |||
| 36f2368e95 | |||
| a4d5cbb117 | |||
| c926a81756 | |||
| 2476b6a4b4 | |||
| 01c1843fd5 | |||
| f86498e350 | |||
| 5cd24f2c46 | |||
| da0be9cb52 | |||
| da1cdfb59e | |||
| a991150262 | |||
| ee49c91fba | |||
| 75463326e3 | |||
| e98c49ac5a | |||
| aeeb0b721c | |||
| b14bc00af4 | |||
| e2a4088e77 | |||
| ebe80358ee | |||
| 9d4e9f6318 | |||
| e5007a285a | |||
| da82c704d5 | |||
| 88b9c890e5 | |||
| 5a67901722 | |||
| 0031a65f97 | |||
| a89e83af29 | |||
| a75d84556a | |||
| 0af7b172a0 | |||
| 8be33b230b | |||
| 4fda2f661a | |||
| 22b1102454 | |||
| e2e64f093f | |||
| 90942b41b9 | |||
| 93a2d99b7f | |||
| dae9a24a7c | |||
| f701ab0d91 | |||
| 47a2439777 | |||
| cce84a3a6f | |||
| f92622cc22 | |||
| f0041ca938 | |||
| 6566b881b2 | |||
| 1a2e38568b | |||
| ced3970aae | |||
| 9de31c991d | |||
| bdca10e0ac | |||
| 9a5e2987d5 | |||
| a5b4deaac4 | |||
| 82953f4c9c | |||
| 509fc5476d | |||
| 6a10849a84 | |||
| 50424a25fc | |||
| 35b09b514f | |||
| 81e4e1fc6a | |||
| 62c9ab014d | |||
| ba28d64562 | |||
| 75ee058818 | |||
| 755bddc74c | |||
| 08aa1900a8 | |||
| 7e1166b5e8 | |||
| 75e9b06a83 | |||
| ca58e19a48 | |||
| ac2d83a666 | |||
| 03e0cebe35 | |||
| 1cc0e16c01 | |||
| 1f2f3acebb | |||
| de0f9ae985 | |||
| a0e79168b2 | |||
| 797f88fe15 | |||
| 4c3e7c615f | |||
| b35b6c2ab8 | |||
| 0971e6ddeb | |||
| bbbd767cf2 | |||
| 3e30dcb04e | |||
| 1a137e7500 | |||
| 3be6d5bb26 | |||
| e22f95cc58 | |||
| 6ac903313c | |||
| a4ff92520a | |||
| 608cf4cbe7 | |||
| 60e360537e | |||
| e9784bd5ed | |||
| 4f018eb2b1 | |||
| 40b3d779bc | |||
| 1bdf413650 | |||
| 495b1b2869 | |||
| a231140bc0 | |||
| a0af934002 | |||
| 82975219a8 | |||
| 60ae670f24 | |||
| 7d79b6b957 | |||
| 8a1e0f080f | |||
| c3a69bc66a | |||
| 4c1f11d859 | |||
| 350ff0fbbe | |||
| 4c70ec7cab | |||
| 944db8dba7 | |||
| befc1c1217 | |||
| 8fe19feaac | |||
| 9c953ca382 | |||
| c53430fa1f | |||
| 1fe722cb81 | |||
| d9bd73d8c1 | |||
| 0235494d46 | |||
| 32354e3c2d | |||
| 14e1c59a69 | |||
| 42cc0f2661 | |||
| 2f5d518e15 | |||
| d085b18788 | |||
| d68bedf5ce | |||
| 2169c0ea62 | |||
| 02165df89c | |||
| 15289951e6 | |||
| 62674044e7 | |||
| e94967ea4c | |||
| ed576fc8eb | |||
| d4c6a05c0c | |||
| da27f4c581 | |||
| 9d6cc90162 | |||
| 512ccddfc7 | |||
| f5b16b68e9 | |||
| e8e4f7b877 | |||
| b6edd8f10c | |||
| ec3a0367dd | |||
| e9da5210ad | |||
| 67f2a80f23 | |||
| ceb594a4cc | |||
| d312da4c66 | |||
| 3a676723e4 | |||
| 684f67593f | |||
| d5962f94a1 | |||
| 5c00893ea3 | |||
| 211622c7b0 | |||
| dbb523c710 | |||
| 6aae18df54 | |||
| cb171118ee | |||
| 45ac8348fe | |||
| 5d92e6774e | |||
| 6595ff7a6e | |||
| dc4e945a35 | |||
| b154b478bc | |||
| 510573e66f | |||
| dbcf469123 | |||
| 325fb373a8 | |||
| 4b6a8b2773 | |||
| 5e4619fac7 | |||
| 43d26b4833 | |||
| 6d2855d117 | |||
| 25fbf95062 | |||
| ee53ea61cc | |||
| 322b519def | |||
| e23b53d797 | |||
| fd78ca6ac1 | |||
| 28dabcbeb6 | |||
| 62dd1de150 | |||
| 166e95930b | |||
| 52d58d0921 | |||
| 14d0dc590f | |||
| ed781da372 | |||
| 4e5745d237 | |||
| b03ef4923e | |||
| d7486e8b8a | |||
| 498602a2c9 | |||
| 1b4d373fea | |||
| 4215b0ea7d | |||
| c3dee6b292 | |||
| 3834982fca | |||
| 539de03a5b | |||
| 0f1d2ce477 | |||
| 70b63f7773 | |||
| 02d13efc25 | |||
| 1227b7639f | |||
| 5593463eab | |||
| be7b2a0f93 | |||
| 4c6ac6e8e1 | |||
| 5cc51c52d9 | |||
| 59eb781a22 | |||
| 2af83bed8a | |||
| 4775c1e115 | |||
| d0dea834c1 | |||
| def894e5f4 | |||
| 4f9401ed34 | |||
| 80763acc53 | |||
| 5fb065de3e | |||
| d6b9161500 | |||
| bcc2070ed2 | |||
| e4e6e563c9 | |||
| efec9b6265 | |||
| 4cf2f77265 | |||
| c86f0379b5 | |||
| 606380460e | |||
| a3bcabe5c2 | |||
| 89ffad398f | |||
| 35986aab56 | |||
| 4717330bc8 | |||
| 291eee3bce | |||
| e6a572ac17 | |||
| bd5b614bf8 | |||
| ba0753428d | |||
| 862cf38f92 | |||
| 1dc6ffca5c | |||
| b7fd5d3569 | |||
| 911136981a | |||
| 6cbe14b36e | |||
| 80c79cc14b | |||
| cb498b01d9 | |||
| cd95b1f8ff | |||
| 60ace68dae | |||
| b2f6c6c485 | |||
| a8dce9da46 | |||
| b85e47f601 | |||
| fc4a0a58e2 | |||
| 039dfd529e | |||
| 3b42709577 | |||
| 3dee5c1828 | |||
| 5ac958231a | |||
| 54a6e7e247 | |||
| 4e80c1a703 | |||
| 9ee5e95d0b | |||
| 3bacc59dc6 | |||
| 4d23929924 | |||
| c9a5a91970 | |||
| 08d1447d11 | |||
| 304be4f432 | |||
| 5e9ce70320 | |||
| 42088e51a8 | |||
| 9dc8f05534 | |||
| cc86151631 | |||
| e16fa9a167 | |||
| 869110ad2e | |||
| d415bbba82 | |||
| 1ecca83339 | |||
| a6c827bb40 | |||
| 968d9e1f2a | |||
| 7b9ba48204 | |||
| 6e2e9da1be | |||
| 980a5674e2 | |||
| f5b9c52e71 | |||
| ade8fefe0d | |||
| 6b54b49443 | |||
| 8fb16903f8 | |||
| f0637e2ce9 | |||
| f6cf4a29ad | |||
| 66f017549c | |||
| db7219e261 | |||
| ac6c77bb92 | |||
| d5eeadc9a7 | |||
| 70a9fa15ec | |||
| 4fd4374e64 | |||
| b4353cf834 | |||
| eb95afe9a0 | |||
| 92886fe5e2 | |||
| fb1b310d1d | |||
| 3b221795ba | |||
| d41600d8e2 | |||
| 856674de75 | |||
| 1af2b72bea | |||
| e66f30e703 | |||
| ca32af592f | |||
| 372b439ff0 | |||
| 4aa9d54b1e | |||
| b45c7c8ea6 | |||
| c164977bb9 | |||
| 3153423f14 | |||
| ac3fbedccd | |||
| 755f3fa0bb | |||
| 9004de06fa | |||
| 4d7bd5213e | |||
| 2f1c4e3c87 | |||
| 43dcbf73ee | |||
| cb22fd1037 | |||
| dfd86a04e0 | |||
| 09cd6395e6 | |||
| a8c9b697e3 | |||
| 25a89b8987 | |||
| 760e9ccd89 | |||
| c019162390 | |||
| 428d9f33d9 | |||
| c3f4c9b1ec | |||
| 2918500585 | |||
| b48bf06f7d | |||
| 2b343b893e | |||
| 0c25751401 | |||
| 9be5bb35c4 | |||
| c24cf7ed1a | |||
| 7b398bc2ee | |||
| d9ee2bc7be | |||
| f31eb8db59 | |||
| 40411b0417 | |||
| fbbe5532a0 | |||
| c102a4043c | |||
| ab694270c4 | |||
| 0febc9d8f3 | |||
| 1ee92f1064 | |||
| 15e53d2c2d | |||
| 0093410d5b | |||
| 7f4eb2ad35 | |||
| f9e00a3f4f | |||
| 2d13564538 | |||
| 4fef966428 | |||
| e29097499a | |||
| d4c8f9bbbc | |||
| 43afd35e54 | |||
| 489e8a31f3 | |||
| 12c7e56604 | |||
| eb6071aaf8 | |||
| f01765d2f8 | |||
| e5d6be446a | |||
| bb83acbe81 | |||
| 758a0cd9a7 | |||
| 1a938b4218 | |||
| dc5bd6b329 | |||
| 68f3c95b81 | |||
| d826746f29 | |||
| 39b18f7efc | |||
| e123ca9b13 | |||
| 17589cb2b4 | |||
| 0c0ad04c20 | |||
| d327af814f | |||
| 8637d1c2c2 | |||
| 68feef77fc | |||
| 4dec97b57c | |||
| d776c73a03 | |||
| dc26da7404 | |||
| 2425316fea | |||
| ff2e0ed114 | |||
| 0efae3089d | |||
| 1a9f5424a5 | |||
| c19a7cba68 | |||
| ec7427b948 | |||
| e169068e1c | |||
| 85556c0db0 | |||
| 7ac92ff451 | |||
| 448cf5ceae | |||
| 995d20bdf3 | |||
| 3ca4b324d3 | |||
| 8fa2a444f0 | |||
| 4a1464185b | |||
| 448fb51c81 | |||
| a57f65a420 | |||
| 70bb40d4f2 | |||
| ce1114d724 | |||
| 128b765045 | |||
| 66c8f67245 | |||
| 5b167db6c3 | |||
| c6b9ed4f12 | |||
| 9928997dd8 | |||
| 92c07e7841 | |||
| 1aba297920 | |||
| d92a63db41 | |||
| 73319bbdfa | |||
| d12374e5d9 | |||
| 507cf710e1 | |||
| 8ce72b21e1 | |||
| 92cc082c54 | |||
| 24f2b94bb8 | |||
| 67cf459216 | |||
| e3a2b41342 | |||
| fcea485286 | |||
| 0b7ff6f3f1 | |||
| 190792affe | |||
| 0a81790049 | |||
| b9b02f285f | |||
| d3be683b69 | |||
| 2c27b2e41d | |||
| 8b0dd6deea | |||
| a5613980c0 | |||
| 12a02cd15d | |||
| aecf470173 | |||
| 64bd57cad4 | |||
| ae0d03ddc0 | |||
| 2a12bc4ba4 | |||
| ace3018539 | |||
| fbf7cb2d21 | |||
| c0b1da89f1 | |||
| 2aef6522bb | |||
| 4b0397903d | |||
| 48a7cd168a | |||
| 93b2496f55 | |||
| 15c167d24d | |||
| 8947d48a43 | |||
| 3de19d495e | |||
| 8bf0f067bb | |||
| 970278f684 | |||
| 99f8e5dcf3 | |||
| 3bab96c325 | |||
| d40d352418 | |||
| 359cdb2534 | |||
| 8a64780135 | |||
| 7956ce5b6f | |||
| 8babb4e3d7 | |||
| de8fda9360 | |||
| 3b7836c8ba | |||
| ba1d462a0a | |||
| b2670f76bf | |||
| 89f711241d | |||
| 352688054e | |||
| 06c4631ca5 | |||
| 2b6676b4eb | |||
| 14c208f494 | |||
| 27ab373ebb | |||
| 4e801bf744 | |||
| ab4e9fbd39 | |||
| dd586f07d2 | |||
| 9d70f94b33 | |||
| 5ebeeeedb3 | |||
| a9ff4579b0 | |||
| a1fe08fdeb | |||
| fc81fa9ad3 | |||
| e980320d00 | |||
| 5509f52464 | |||
| 0ed6c246b1 | |||
| c7818cefbb | |||
| b004877584 | |||
| a51a020dfa | |||
| a3670271de | |||
| adaac46236 | |||
| 49e843f3b2 | |||
| b9ed7df063 | |||
| 60d5551dff | |||
| c5269c4fc5 | |||
| 4e00ded843 | |||
| db33247d6c | |||
| aab8e0c5ce | |||
| 6c6634fa1d | |||
| e93a9c8011 | |||
| b8031448ff | |||
| c63df91e08 | |||
| 0e43957e6e | |||
| dada6a542f | |||
| b305d43ce6 | |||
| 8d5b195691 | |||
| 6c2baca807 | |||
| d9a1d340bb | |||
| 8511a75842 | |||
| 4452b6fd03 | |||
| 1ed83351e0 | |||
| 9817864c3d | |||
| 564d6d0da1 | |||
| 2c8160f816 | |||
| 23402370b8 | |||
| e3d929435a | |||
| ef3797e724 | |||
| cddb1422f6 | |||
| f28aeda74c | |||
| 75dfd96934 | |||
| 079d69dffb | |||
| 711536975c | |||
| 97bf785fe9 | |||
| dce913815e | |||
| 737d8e943c | |||
| 0bdf27de2c | |||
| 9cff99cba9 | |||
| 46cfc2539e | |||
| 34f93f8dcc | |||
| 1a800a1157 | |||
| 3c96855b86 | |||
| 607bf28121 | |||
| d8361be28f | |||
| 031d51947a | |||
| 554037bfe5 | |||
| 9f93200bd5 | |||
| 70fcbf795b | |||
| 406befc21b | |||
| 847772616e | |||
| 344140e973 | |||
| 558f219e8b | |||
| 8671f37ada | |||
| 15dc04bb95 | |||
| f801378ad2 | |||
| 73e8697097 | |||
| b3f6f36c00 | |||
| b9c4f44e3f | |||
| 5a7b750203 | |||
| bb30b6cb21 | |||
| 0cc857378f | |||
| e68e5a6d51 | |||
| c20b1c5942 | |||
| 0a5efbe383 | |||
| 2e769b234d | |||
| f87736154a | |||
| 3ce1299091 | |||
| ca0d379c2c | |||
| 87492876e5 | |||
| 3d8d0d9e4d | |||
| 956f1ce500 | |||
| a11b648bf9 | |||
| 31581e963f | |||
| c63882fbd7 | |||
| ab84f59929 | |||
| 5fe0236686 | |||
| 8f6597e7df | |||
| c4f4775a48 | |||
| 81e5a180ba | |||
| 1d65cf0d08 | |||
| 4ef5ee7142 | |||
| 19a90c9045 | |||
| fcbb34624d | |||
| 68ccb66e5c | |||
| a094eb94a5 | |||
| 4db2bc187a | |||
| e8ff69b43f | |||
| b03a47ddc6 | |||
| 62a78b8619 | |||
| 7f43ef6c56 | |||
| 51ad37cc48 | |||
| 9a00d4b98e | |||
| 6528899aaf | |||
| f94c8ba799 | |||
| df4b513739 | |||
| 50477d0850 | |||
| 79f0e2b7b7 | |||
| 63c3818766 | |||
| f6a360ee2b | |||
| aa39478318 | |||
| 02fbd677fc | |||
| 98608576b9 | |||
| 80d9dd689a | |||
| 0d1907f729 | |||
| 3aab90d3d6 | |||
| 6f96f20b49 | |||
| 142ce7fe3a | |||
| b7085f5d2a | |||
| 628facb23d | |||
| 27c112e479 | |||
| aea35d4b9f | |||
| 5b134148a5 | |||
| b19340536a | |||
| 163d225dba | |||
| f07db1be7a | |||
| 4323040bd3 | |||
| 97a753133e | |||
| 273810804d | |||
| 2be417ac0a | |||
| f98e9d6930 | |||
| 4c336f81c7 | |||
| 1389cb7ed6 | |||
| a7958166bf | |||
| 34f01abb32 | |||
| 66c537ec10 | |||
| 2847f50bf7 | |||
| 7b4d69b0b0 | |||
| 37ab614a97 | |||
| 7c73e8e5c6 | |||
| 85f4a5deaa | |||
| 4011d26193 | |||
| afb0c40fd2 | |||
| 2a03eae8a2 | |||
| e9238e2bb5 | |||
| 40eaa729ef | |||
| 47e51e0105 | |||
| 56326cc8d2 | |||
| 860a2d988e | |||
| 79701fbcfe | |||
| 8b1e43cdb9 | |||
| 4768a7d6fd | |||
| caba77d871 | |||
| 37c0c1cf42 | |||
| 1d06c6f02a | |||
| 32f4cf411f | |||
| 04d01970aa | |||
| ae206b9426 | |||
| d3d3859021 | |||
| 447ef81871 | |||
| 2507f733fb | |||
| 2d6e8480f5 | |||
| 9d0fdb346d | |||
| 08f3372b46 | |||
| 84cbbaf238 | |||
| 9176373072 | |||
| 6307cdc0dc | |||
| 52213fc8c4 | |||
| 826e83b025 | |||
| c300bdcb0f | |||
| 84a7b0e50f | |||
| 839bf4daac | |||
| 38955b96de | |||
| 5c50e4a0c1 | |||
| 542992eaab | |||
| 982d0294b6 | |||
| 42ebf1015f | |||
| 4991b1160f | |||
| 71a430c99c | |||
| db1e224c3b | |||
| bb74b90790 | |||
| a890ed571b | |||
| 2d81b0dfba | |||
| ab390ab461 | |||
| 335b254a60 | |||
| 5e53f8764e | |||
| f0051b58bb | |||
| 8c73a8f61a | |||
| 7e64ec0f79 | |||
| 6636648813 | |||
| 151af5707d | |||
| 716f064858 | |||
| be87bc7c1d | |||
| 111531b803 | |||
| d59cf359ee | |||
| 2f7ae0ae66 | |||
| 8cc7f2f526 | |||
| 25074edaa1 | |||
| 0b1349ca8d | |||
| 6c70dc93ce | |||
| ed3d525c06 | |||
| af9c4bbdb9 | |||
| 5a88718454 | |||
| d1a0cdc1b9 | |||
| 196db657e8 | |||
| 51c3277b6c | |||
| abc35314a0 | |||
| 146a63fc70 | |||
| d46652cb68 | |||
| b46f06a739 | |||
| 6cc5e5e931 | |||
| 7b82888aa6 | |||
| 762fb08568 | |||
| b7c0a80a04 | |||
| 143674533a | |||
| b046b64ed2 | |||
| 9f6fec5a3c | |||
| e386d2a389 | |||
| cdef3e797e | |||
| 6af2609f44 | |||
| 6f5540eb91 | |||
| 5c286128e4 | |||
| df875eda1d | |||
| ae2b27521e | |||
| d026a3b5ae | |||
| ed9a8021c1 | |||
| 31d9c5e38d | |||
| e749faedca | |||
| 27c696c797 | |||
| 28b58d9cac | |||
| 1d0d42dc16 | |||
| 1b3dd34add | |||
| 1d29f62bf2 | |||
| e35f857057 | |||
| bcc2f71623 | |||
| 359f0f7b01 | |||
| 6a9f672d27 | |||
| 8c976b6d0b | |||
| e00a81cebb | |||
| a82860cb68 | |||
| 52a18dac24 | |||
| c2272ee5e0 | |||
| e2be39af18 | |||
| 9322d6298c | |||
| c012f39a38 | |||
| 0f72a14fde | |||
| 1c35c7db32 | |||
| 1f6ce36976 | |||
| 756701722a | |||
| 8e48c4d7cf | |||
| 282f651d96 | |||
| 49abb129e3 | |||
| 9d6148e877 | |||
| d914eb86f2 | |||
| e8a6bf05c3 | |||
| ffa0b23b82 | |||
| 49e9e958fa | |||
| b17ccd502e | |||
| 1a7b969c3f | |||
| eca8bd7026 | |||
| 1e421e4230 | |||
| 9cffa53122 | |||
| 2ff217efcb | |||
| 475467cca6 | |||
| d0f6e965f0 | |||
| 9a1be88bce | |||
| e9cd84e89e | |||
| 89cfd31155 | |||
| 76fb5a2625 | |||
| b75ed86949 | |||
| 426b6bfc85 | |||
| c7ffae68d8 | |||
| 362ae16c7d | |||
| 149b14e0f8 | |||
| 4d7bbaf771 | |||
| 99fc3f8cae | |||
| 507f53ace8 | |||
| fd4b584ccd | |||
| f73672f65c | |||
| b62424af18 | |||
| 951d2bca0a | |||
| 4081a326e3 | |||
| 0dbcb83c54 | |||
| 248d4f75d8 | |||
| 4b2e00d91a | |||
| d679b5b54e | |||
| b2fa4786b2 | |||
| aaca46356a | |||
| 1f03222e42 | |||
| c472375f38 | |||
| 469542bd2e | |||
| 98e1623c19 | |||
| 480e8a3226 | |||
| 7317eb7129 | |||
| c4f8051fba | |||
| 7be811f2b1 | |||
| 5053ce35df | |||
| 9bd4df3f4c | |||
| 6c4672e38e | |||
| c695afa1e7 | |||
| 93513c4a3a | |||
| ead338fa0f | |||
| afbb007309 | |||
| 732fe85cde | |||
| 43fe8ad1b3 | |||
| d53afb6b74 | |||
| e13f3358f4 | |||
| 26d89c35a5 | |||
| 7a45926c49 | |||
| 0439c21ec6 | |||
| 696ec3a69c | |||
| 6b2f95b9a3 | |||
| 324b6b69e2 | |||
| 876217d1af | |||
| 7a2bdb25e4 | |||
| 1a3ea5be8c | |||
| 572e5233b4 | |||
| 6ece591d2b | |||
| 122bdbbf54 | |||
| 5eb1296391 | |||
| 3cc85a894f | |||
| 71e6ac9c63 | |||
| 596e2d0095 | |||
| 4cb8343f74 | |||
| fc785bc63c | |||
| ec5962bccc | |||
| 0eb4fa99a7 | |||
| defbcd9867 | |||
| f69fc08ef8 | |||
| 41bf12846d | |||
| bbb9c5f190 | |||
| de11534e20 | |||
| 8b0a6f054b | |||
| 46b819c200 | |||
| 72356917ff | |||
| 28a32cb6c4 | |||
| 0e179f1643 | |||
| 6319b6d5fe | |||
| a538c3ea90 | |||
| cbc54eb501 | |||
| 67f7a68f1b | |||
| b1981867ff | |||
| 8a84542c60 | |||
| f091b4be43 | |||
| 6e4c214821 | |||
| aa6d205491 | |||
| 2e6e11984e | |||
| 0824225080 | |||
| e4ae1566f1 | |||
| 0f21731008 | |||
| 9b2b5d8307 | |||
| ff6f6136cc | |||
| 4ad2b54128 | |||
| 7b939f57af | |||
| 18f3295562 | |||
| 9c540e7cd8 | |||
| eefec93811 | |||
| 04e54044e9 | |||
| e143668f82 | |||
| 949b5cbc12 | |||
| 0f64baca23 | |||
| d9c154997d | |||
| b3f8fc451d | |||
| da040a4f7e | |||
| 200290a0b3 | |||
| 366864582f | |||
| 876d564f26 | |||
| 979f803d75 | |||
| f4166f4dbd | |||
| 56d4eca034 | |||
| 24ff7a080f | |||
| ee1f759a37 | |||
| 23c758b0cf | |||
| 1c002a1b95 | |||
| fb980c38c9 | |||
| dc2c2228a8 | |||
| 6def4e0fcd | |||
| aaaa126c42 | |||
| 70a15d3044 | |||
| 5c8e97ebf9 | |||
| f8ae023c45 | |||
| d03414f7ab | |||
| 3cda11c66e | |||
| 55b50d4184 | |||
| a9c22d778b | |||
| c576933ba2 | |||
| b66054c9a2 | |||
| ccf535cbd9 | |||
| df550abc46 | |||
| 0aa96b9c46 | |||
| 4391fe1de7 | |||
| 6377557ef0 | |||
| 4d319ca9c8 | |||
| 93c886551d | |||
| d31c1deaa2 | |||
| aad08593c7 | |||
| 36da05890a | |||
| a82c5e5593 | |||
| 08715e39c2 | |||
| 138ad6a7c9 | |||
| 2ef8b2dc9f | |||
| 9ae5bdd969 | |||
| d19b1e885e | |||
| f4abfd4279 | |||
| 1152b6d2c3 | |||
| 0cdbff6954 | |||
| f32b77c552 | |||
| cd9fa31ad7 | |||
| 4c4c70e10f | |||
| aed1a1ed01 | |||
| 67d695303e | |||
| b85bace073 | |||
| 835ba077d8 | |||
| 13abc6d7ce | |||
| a26919f037 | |||
| 2c9c2660c0 | |||
| e6cbb3013d | |||
| c55081f358 | |||
| b840f42ae0 | |||
| ff9ad8237c | |||
| f371d06386 | |||
| 79cb89b9a0 | |||
| 9a3617edf1 | |||
| 80dfbcb858 | |||
| db51619fbe | |||
| 6395a32f43 | |||
| 3c6f7ce0d3 | |||
| 01b8841e3c | |||
| 40e8f52fe4 | |||
| 8c6a87c011 | |||
| a17089f4bb | |||
| 45700be730 | |||
| 228e79bb31 | |||
| 87bf474cf6 | |||
| b25418b51e | |||
| 0a24c4541f | |||
| 7d3a4c1ecc | |||
| 8fe51c976b | |||
| 5a4e3ab5ab | |||
| a1bbe4e2d7 | |||
| 6c8e901a99 | |||
| a2e04dad9f | |||
| 73100aa1ce | |||
| e349b9dfa4 | |||
| 4a9cbdc219 | |||
| 76c1b2f628 | |||
| 0a5414a3ac | |||
| c7b4361cb6 | |||
| 6bc86af32f | |||
| 00e0bc387b | |||
| 4285e2e269 | |||
| 9df64eeafa | |||
| 34901aa11c | |||
| b2ce9c93b7 | |||
| 0c4448f396 | |||
| 7114470c13 | |||
| 0de4f9d745 | |||
| a6fe07de07 | |||
| 438082c94c | |||
| 081048f0c5 | |||
| fce2cfee73 | |||
| bd64694c73 | |||
| 105d23e4f7 | |||
| 68f9e27b5f | |||
| d786b7b5ba | |||
| 23e8487a97 | |||
| 02b97117eb | |||
| 0f6e224870 | |||
| e15b7e11d3 | |||
| 8f55ced55a | |||
| 781a5ca0d9 | |||
| ac84841b05 | |||
| a08ab7abaf | |||
| 1d689da546 | |||
| 96f96f6c5a | |||
| a403800fb0 | |||
| 49b7ca4be5 | |||
| dd080b1d19 | |||
| 1603ae62e0 | |||
| 63461173e5 | |||
| 9d7140beb6 | |||
| 817420ee62 | |||
| f3b1091890 | |||
| c9bace04ec | |||
| dc3b4f1850 | |||
| 27a398a1c8 | |||
| 9a87f1c404 | |||
| fc1a0d6a3f | |||
| 6a7990e722 | |||
| 294c843bd4 | |||
| 12f22833c9 | |||
| d46355f7f0 | |||
| bf38178969 | |||
| 790b590668 | |||
| 3952704643 | |||
| 57a148b6cf | |||
| 8a7245f5dd | |||
| b02a3c5eee | |||
| a1301121ac | |||
| 3bc5030a3d | |||
| 4b88b684af | |||
| cf332b5346 | |||
| 94c6d82967 | |||
| c75563491f | |||
| 3827204f13 | |||
| 76e15d13ad | |||
| 5e7f55000a | |||
| 427c8aec34 | |||
| f1dba4012a | |||
| a72fbec5ce | |||
| d8e134d404 | |||
| 359326e575 | |||
| dbe9b26818 | |||
| b290f7692a | |||
| 7a6bee57c2 | |||
| b52a414eb0 | |||
| 4137683d05 | |||
| 9237d4e731 | |||
| efde742518 | |||
| 916de1432b | |||
| e134f0994b | |||
| f22ba83dd0 | |||
| 3cb11f6158 | |||
| c5baff6f33 | |||
| ab2175d903 | |||
| 524036a6bf | |||
| 6c320ce59a | |||
| cb8a1a17ac | |||
| 08c28f4077 | |||
| 66fa65e4bb | |||
| 01e94b57c1 | |||
| 8d586e7cb4 | |||
| 447a953ed3 | |||
| 141d695a7d | |||
| ae35d42484 | |||
| 3f285a74bc | |||
| c81f7faf93 | |||
| c81b250cbb | |||
| fc71defa08 | |||
| 54e05b7150 | |||
| d28fa77405 | |||
| 53277b5893 | |||
| 97d131be12 | |||
| 3937c27c77 | |||
| bdf84c3802 | |||
| ba679865c4 | |||
| 8d7adbbd27 | |||
| adb8d0f69e | |||
| 8fd442621a | |||
| e6eac6b62d | |||
| e87f9087e1 | |||
| 35471fc597 | |||
| c4b505047c | |||
| fee9328699 | |||
| b90fdabc4b | |||
| a5d2d85572 | |||
| 4560073f6a | |||
| a205e57d39 | |||
| 582b971c09 | |||
| 54ce9e5458 | |||
| 8481b77c90 | |||
| e77a43300a | |||
| bd4242c4fd | |||
| 56bde974ad | |||
| 34d7310cc9 | |||
| 38258e4311 | |||
| 8998d815a5 | |||
| e5ec0f8deb | |||
| 60eaec261d | |||
| 92bfef850a | |||
| 502564da0a | |||
| 8b99be34ae | |||
| a781431683 | |||
| d34413fa3a | |||
| b9212d1241 | |||
| 6a58be8c67 | |||
| d4b8d25bd5 | |||
| 19c4e0fd4b | |||
| 9ffa60b935 | |||
| 55376e9631 | |||
| 06accca19e | |||
| 0f5ac917d2 | |||
| 149e525ff4 | |||
| 8fb761f02c | |||
| 3bc5a5b75e | |||
| 79112e0da8 | |||
| bf9eb91ea2 | |||
| e8c8ffadfe | |||
| 2ae1c5b382 | |||
| 961f81411b | |||
| de439275e0 |
+30
-2
@@ -15,7 +15,7 @@ default:
|
|||||||
# ==========================================================
|
# ==========================================================
|
||||||
.build_template: &build_template
|
.build_template: &build_template
|
||||||
stage: build
|
stage: build
|
||||||
image: node:20-alpine
|
image: public.ecr.aws/docker/library/node:20-alpine
|
||||||
cache:
|
cache:
|
||||||
key: npm-cache
|
key: npm-cache
|
||||||
paths:
|
paths:
|
||||||
@@ -56,7 +56,7 @@ default:
|
|||||||
.deploy_template: &deploy_template
|
.deploy_template: &deploy_template
|
||||||
stage: deploy
|
stage: deploy
|
||||||
image:
|
image:
|
||||||
name: amazon/aws-cli:latest
|
name: public.ecr.aws/aws-cli/aws-cli:latest
|
||||||
entrypoint: ['/bin/sh', '-c']
|
entrypoint: ['/bin/sh', '-c']
|
||||||
script:
|
script:
|
||||||
- set -e
|
- set -e
|
||||||
@@ -183,3 +183,31 @@ deploy:staging:
|
|||||||
environment:
|
environment:
|
||||||
name: staging
|
name: staging
|
||||||
url: https://stg-lti-erp.mbugroup.id
|
url: https://stg-lti-erp.mbugroup.id
|
||||||
|
|
||||||
|
# ==========================================================
|
||||||
|
# ====== STAGING (Branch production) ======
|
||||||
|
# ==========================================================
|
||||||
|
build:production:
|
||||||
|
<<: *build_template
|
||||||
|
rules:
|
||||||
|
- if: '$CI_COMMIT_BRANCH == "production"'
|
||||||
|
environment:
|
||||||
|
name: staging
|
||||||
|
variables:
|
||||||
|
NEXT_PUBLIC_LTI_URL: 'https://lti-erp.mbugroup.id'
|
||||||
|
NEXT_PUBLIC_SSO_LOGIN_URL: 'https://auth-erp.mbugroup.id'
|
||||||
|
NEXT_PUBLIC_API_BASE_URL: 'https://api-lti.mbugroup.id/api'
|
||||||
|
NEXT_PUBLIC_CLIENT_ID: 'Lumbung-Telur-Indonesia'
|
||||||
|
|
||||||
|
deploy:production:
|
||||||
|
<<: *deploy_template
|
||||||
|
needs: ['build:production']
|
||||||
|
rules:
|
||||||
|
- if: '$CI_COMMIT_BRANCH == "production"'
|
||||||
|
variables:
|
||||||
|
S3_BUCKET: 'production-lti-erp.mbugroup.id'
|
||||||
|
AWS_REGION: 'ap-southeast-3'
|
||||||
|
CLOUDFRONT_DISTRIBUTION_ID: 'E1SSLXKYYITASJ'
|
||||||
|
environment:
|
||||||
|
name: staging
|
||||||
|
url: https://lti-erp.mbugroup.id
|
||||||
|
|||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
FROM node:20-alpine
|
FROM public.ecr.aws/docker/library/node:20-alpine
|
||||||
|
|
||||||
RUN apk add --no-cache git bash build-base curl
|
RUN apk add --no-cache git bash build-base curl
|
||||||
|
|
||||||
|
|||||||
Generated
+914
-10
File diff suppressed because it is too large
Load Diff
+5
-2
@@ -8,7 +8,8 @@
|
|||||||
"start": "next start",
|
"start": "next start",
|
||||||
"lint": "eslint",
|
"lint": "eslint",
|
||||||
"prepare": "husky",
|
"prepare": "husky",
|
||||||
"format": "prettier --write ."
|
"format": "prettier --write .",
|
||||||
|
"pre-commit": "npm run format && npm run lint && npx tsc --noEmit && npm run build"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@react-pdf/renderer": "^4.3.1",
|
"@react-pdf/renderer": "^4.3.1",
|
||||||
@@ -19,7 +20,9 @@
|
|||||||
"clsx": "^2.1.1",
|
"clsx": "^2.1.1",
|
||||||
"cmdk": "^1.1.1",
|
"cmdk": "^1.1.1",
|
||||||
"embla-carousel-react": "^8.6.0",
|
"embla-carousel-react": "^8.6.0",
|
||||||
|
"exceljs": "^4.4.0",
|
||||||
"formik": "^2.4.6",
|
"formik": "^2.4.6",
|
||||||
|
"html-to-image": "^1.11.13",
|
||||||
"input-otp": "^1.4.2",
|
"input-otp": "^1.4.2",
|
||||||
"jspdf": "^3.0.4",
|
"jspdf": "^3.0.4",
|
||||||
"jspdf-autotable": "^5.0.2",
|
"jspdf-autotable": "^5.0.2",
|
||||||
@@ -54,7 +57,7 @@
|
|||||||
"@types/node": "^20",
|
"@types/node": "^20",
|
||||||
"@types/react": "^19",
|
"@types/react": "^19",
|
||||||
"@types/react-dom": "^19",
|
"@types/react-dom": "^19",
|
||||||
"daisyui": "^5.5.8",
|
"daisyui": "^5.5.14",
|
||||||
"eslint": "^9",
|
"eslint": "^9",
|
||||||
"eslint-config-next": "^15.5.7",
|
"eslint-config-next": "^15.5.7",
|
||||||
"husky": "^9.1.7",
|
"husky": "^9.1.7",
|
||||||
|
|||||||
@@ -3,11 +3,10 @@
|
|||||||
import { useRouter, useSearchParams } from 'next/navigation';
|
import { useRouter, useSearchParams } from 'next/navigation';
|
||||||
import useSWR from 'swr';
|
import useSWR from 'swr';
|
||||||
|
|
||||||
import ClosingDetail from '@/components/pages/closing/ClosingDetail';
|
import ClosingDetail from '@/components/pages/closing/ClosingDetailTabs';
|
||||||
|
|
||||||
import { ClosingApi } from '@/services/api/closing';
|
import { ClosingApi } from '@/services/api/closing';
|
||||||
import { isResponseError, isResponseSuccess } from '@/lib/api-helper';
|
import { isResponseError, isResponseSuccess } from '@/lib/api-helper';
|
||||||
import { FlockApi } from '@/services/api/master-data';
|
|
||||||
import { ProjectFlockApi } from '@/services/api/production/project-flock';
|
import { ProjectFlockApi } from '@/services/api/production/project-flock';
|
||||||
import { ProjectFlockKandangApi } from '@/services/api/production';
|
import { ProjectFlockKandangApi } from '@/services/api/production';
|
||||||
|
|
||||||
@@ -34,16 +33,6 @@ const ClosingDetailPage = () => {
|
|||||||
() => ProjectFlockKandangApi.getSingle(Number(kandangId))
|
() => ProjectFlockKandangApi.getSingle(Number(kandangId))
|
||||||
);
|
);
|
||||||
|
|
||||||
const { data: salesData, isLoading: isLoadingSales } = useSWR(
|
|
||||||
closingId ? `sales-${closingId}` : null,
|
|
||||||
() => ClosingApi.getPenjualan(Number(closingId))
|
|
||||||
);
|
|
||||||
|
|
||||||
const { data: hppEkspedisiData, isLoading: isLoadingHppEkspedisi } = useSWR(
|
|
||||||
closingId ? `hpp-ekspedisi-${closingId}` : null,
|
|
||||||
() => ClosingApi.getHppEkspedisi(Number(closingId))
|
|
||||||
);
|
|
||||||
|
|
||||||
if (!closingId) {
|
if (!closingId) {
|
||||||
router.back();
|
router.back();
|
||||||
|
|
||||||
@@ -59,12 +48,7 @@ const ClosingDetailPage = () => {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const isLoading =
|
const isLoading = isLoadingClosing || isLoadingProject || isLoadingKandang;
|
||||||
isLoadingClosing ||
|
|
||||||
isLoadingSales ||
|
|
||||||
isLoadingHppEkspedisi ||
|
|
||||||
isLoadingProject ||
|
|
||||||
isLoadingKandang;
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className='w-full p-4 flex flex-row justify-center'>
|
<div className='w-full p-4 flex flex-row justify-center'>
|
||||||
@@ -74,12 +58,6 @@ const ClosingDetailPage = () => {
|
|||||||
<ClosingDetail
|
<ClosingDetail
|
||||||
id={Number(closingId)}
|
id={Number(closingId)}
|
||||||
initialValue={closing.data}
|
initialValue={closing.data}
|
||||||
salesData={isResponseSuccess(salesData) ? salesData.data : undefined}
|
|
||||||
hppExpeditionData={
|
|
||||||
isResponseSuccess(hppEkspedisiData)
|
|
||||||
? hppEkspedisiData.data
|
|
||||||
: undefined
|
|
||||||
}
|
|
||||||
projectData={
|
projectData={
|
||||||
isResponseSuccess(projectData) ? projectData.data : undefined
|
isResponseSuccess(projectData) ? projectData.data : undefined
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import ClosingsTable from '@/components/pages/closing/ClosingsTable';
|
|||||||
|
|
||||||
const Closing = () => {
|
const Closing = () => {
|
||||||
return (
|
return (
|
||||||
<section className='w-full p-4'>
|
<section className='w-full p-3'>
|
||||||
<ClosingsTable />
|
<ClosingsTable />
|
||||||
</section>
|
</section>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -0,0 +1,11 @@
|
|||||||
|
import { MasterKandangContent } from '@/figma-make/components/pages/master-data/kandang/MasterKandangContent';
|
||||||
|
|
||||||
|
const MasterKandangPage = () => {
|
||||||
|
return (
|
||||||
|
<section className='w-full'>
|
||||||
|
<MasterKandangContent />
|
||||||
|
</section>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default MasterKandangPage;
|
||||||
@@ -38,9 +38,11 @@ const ExpenseEditPage = () => {
|
|||||||
!isLoadingExpense &&
|
!isLoadingExpense &&
|
||||||
isResponseSuccess(expense) &&
|
isResponseSuccess(expense) &&
|
||||||
expense.data.latest_approval.step_number !== 5 &&
|
expense.data.latest_approval.step_number !== 5 &&
|
||||||
|
expense.data.latest_approval.step_number !== 6 &&
|
||||||
(expense.data.latest_approval.step_number === 1 ||
|
(expense.data.latest_approval.step_number === 1 ||
|
||||||
expense.data.latest_approval.step_number === 2 ||
|
expense.data.latest_approval.step_number === 2 ||
|
||||||
expense.data.latest_approval.step_number === 3);
|
expense.data.latest_approval.step_number === 3 ||
|
||||||
|
expense.data.latest_approval.step_number === 4);
|
||||||
|
|
||||||
if (!isLoadingExpense && !isExpenseCanBeEdited) {
|
if (!isLoadingExpense && !isExpenseCanBeEdited) {
|
||||||
router.back();
|
router.back();
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import ExpensesTable from '@/components/pages/expense/ExpensesTable';
|
|||||||
|
|
||||||
const Expense = () => {
|
const Expense = () => {
|
||||||
return (
|
return (
|
||||||
<section className='w-full p-4'>
|
<section className='w-full p-4 sm:p-0'>
|
||||||
<ExpensesTable />
|
<ExpensesTable />
|
||||||
</section>
|
</section>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -38,8 +38,8 @@ const ExpenseRealizationEditPage = () => {
|
|||||||
!isLoadingExpense &&
|
!isLoadingExpense &&
|
||||||
isResponseSuccess(expense) &&
|
isResponseSuccess(expense) &&
|
||||||
expense.data.latest_approval.action !== 'REJECTED' &&
|
expense.data.latest_approval.action !== 'REJECTED' &&
|
||||||
(expense.data.latest_approval.step_number === 4 ||
|
(expense.data.latest_approval.step_number === 5 ||
|
||||||
expense.data.latest_approval.step_number === 5);
|
expense.data.latest_approval.step_number === 6);
|
||||||
|
|
||||||
if (!isLoadingExpense && !isExpenseRealizationCanBeEdited) {
|
if (!isLoadingExpense && !isExpenseRealizationCanBeEdited) {
|
||||||
router.back();
|
router.back();
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ import useSWR from 'swr';
|
|||||||
import { FinanceApi } from '@/services/api/finance';
|
import { FinanceApi } from '@/services/api/finance';
|
||||||
import { isResponseError, isResponseSuccess } from '@/lib/api-helper';
|
import { isResponseError, isResponseSuccess } from '@/lib/api-helper';
|
||||||
import FormFinanceAdd from '@/components/pages/finance/add/FormFinanceAdd';
|
import FormFinanceAdd from '@/components/pages/finance/add/FormFinanceAdd';
|
||||||
import FormFinanceAddInitialBalance from '@/components/pages/finance/add/initial-balance/FormFinanceAddInitialBalance';
|
|
||||||
|
|
||||||
const EditFinanceTransactionPage = () => {
|
const EditFinanceTransactionPage = () => {
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import FinanceDetail from '@/components/pages/finance/FinanceDetail';
|
|||||||
import useSWR from 'swr';
|
import useSWR from 'swr';
|
||||||
import { useRouter, useSearchParams } from 'next/navigation';
|
import { useRouter, useSearchParams } from 'next/navigation';
|
||||||
import { FinanceApi } from '@/services/api/finance';
|
import { FinanceApi } from '@/services/api/finance';
|
||||||
import { isResponseError, isResponseSuccess } from '@/lib/api-helper';
|
import { isResponseSuccess } from '@/lib/api-helper';
|
||||||
|
|
||||||
const FinanceDetailPage = () => {
|
const FinanceDetailPage = () => {
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
@@ -24,8 +24,6 @@ const FinanceDetailPage = () => {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log(finance);
|
|
||||||
|
|
||||||
// if (!finance || isResponseError(finance)) {
|
// if (!finance || isResponseError(finance)) {
|
||||||
// router.replace('/404');
|
// router.replace('/404');
|
||||||
// return;
|
// return;
|
||||||
|
|||||||
@@ -3,12 +3,7 @@
|
|||||||
import FinanceTable from '@/components/pages/finance/FinanceTable';
|
import FinanceTable from '@/components/pages/finance/FinanceTable';
|
||||||
|
|
||||||
const Finance = () => {
|
const Finance = () => {
|
||||||
return (
|
return <FinanceTable />;
|
||||||
<section className='size-full p-6'>
|
|
||||||
<div className='flex flex-row gap-4'></div>
|
|
||||||
<FinanceTable />
|
|
||||||
</section>
|
|
||||||
);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export default Finance;
|
export default Finance;
|
||||||
|
|||||||
+12
-5
@@ -1,5 +1,6 @@
|
|||||||
@import 'tailwindcss';
|
@import 'tailwindcss';
|
||||||
@plugin "daisyui";
|
@plugin "daisyui";
|
||||||
|
@import '../styles/tailwind.css';
|
||||||
@import '../styles/daisyui.css';
|
@import '../styles/daisyui.css';
|
||||||
@import '../figma-make/styles/theme.css';
|
@import '../figma-make/styles/theme.css';
|
||||||
|
|
||||||
@@ -29,16 +30,16 @@
|
|||||||
--color-base-100: oklch(100% 0 0); /* #ffffff */
|
--color-base-100: oklch(100% 0 0); /* #ffffff */
|
||||||
--color-base-200: oklch(97.2% 0 0); /* #f2f2f2 */
|
--color-base-200: oklch(97.2% 0 0); /* #f2f2f2 */
|
||||||
--color-base-300: oklch(93.1% 0.002 249.7); /* #e5e6e6 */
|
--color-base-300: oklch(93.1% 0.002 249.7); /* #e5e6e6 */
|
||||||
--color-base-content: oklch(18.6% 0.024 257.7); /* #1f2937 */
|
--color-base-content: #18181b;
|
||||||
|
|
||||||
/* Status/Utility Colors */
|
/* Status/Utility Colors */
|
||||||
--color-info: oklch(67.4% 0.176 238.9);
|
--color-info: oklch(67.4% 0.176 238.9);
|
||||||
--color-info-content: oklch(0% 0 0); /* #000000 */
|
--color-info-content: oklch(0% 0 0); /* #000000 */
|
||||||
--color-success: oklch(62.3% 0.147 149);
|
--color-success: #00d390;
|
||||||
--color-success-content: oklch(100% 0 0); /* #ffffff */
|
--color-success-content: oklch(100% 0 0); /* #ffffff */
|
||||||
--color-warning: oklch(82.2% 0.165 91.9);
|
--color-warning: #fcb700;
|
||||||
--color-warning-content: oklch(0% 0 0); /* #000000 */
|
--color-warning-content: oklch(0% 0 0); /* #000000 */
|
||||||
--color-error: oklch(61.8% 0.203 27.8);
|
--color-error: #ff3a3a;
|
||||||
--color-error-content: oklch(100% 0 0); /* #fffffff */
|
--color-error-content: oklch(100% 0 0); /* #fffffff */
|
||||||
|
|
||||||
--radius-selector: 0rem;
|
--radius-selector: 0rem;
|
||||||
@@ -52,17 +53,23 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
:root {
|
:root {
|
||||||
--color-primary: #1f74bf;
|
--color-primary: #0069e0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@theme {
|
@theme {
|
||||||
--font-inter: var(--font-inter);
|
--font-inter: var(--font-inter);
|
||||||
|
--font-roboto: var(--font-roboto);
|
||||||
|
|
||||||
--container-sm: 40rem;
|
--container-sm: 40rem;
|
||||||
--container-md: 48rem;
|
--container-md: 48rem;
|
||||||
--container-lg: 64rem;
|
--container-lg: 64rem;
|
||||||
--container-xl: 80rem;
|
--container-xl: 80rem;
|
||||||
--container-2xl: 96rem;
|
--container-2xl: 96rem;
|
||||||
|
|
||||||
|
--shadow-button-soft:
|
||||||
|
0 3px 2px -2px var(--color-base-200), 0 4px 3px -2px var(--color-base-200);
|
||||||
|
|
||||||
|
--shadow-bg: 0px -2px 4px 0px #00000014;
|
||||||
}
|
}
|
||||||
|
|
||||||
html {
|
html {
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import InventoryAdjustmentTable from '@/components/pages/inventory/adjustment/In
|
|||||||
|
|
||||||
const InventoryAdjustment = () => {
|
const InventoryAdjustment = () => {
|
||||||
return (
|
return (
|
||||||
<section className='w-full p-4'>
|
<section className='w-full'>
|
||||||
<InventoryAdjustmentTable />
|
<InventoryAdjustmentTable />
|
||||||
</section>
|
</section>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import MovementTable from '@/components/pages/inventory/movement/MovementTable';
|
|||||||
|
|
||||||
const Movement = () => {
|
const Movement = () => {
|
||||||
return (
|
return (
|
||||||
<section className='w-full p-4'>
|
<section className='w-full p-4 sm:p-0'>
|
||||||
<MovementTable />
|
<MovementTable />
|
||||||
</section>
|
</section>
|
||||||
);
|
);
|
||||||
|
|||||||
+10
-2
@@ -1,5 +1,5 @@
|
|||||||
import type { Metadata, Viewport } from 'next';
|
import type { Metadata, Viewport } from 'next';
|
||||||
import { Inter } from 'next/font/google';
|
import { Inter, Roboto } from 'next/font/google';
|
||||||
import '@/app/globals.css';
|
import '@/app/globals.css';
|
||||||
|
|
||||||
import { Toaster } from 'react-hot-toast';
|
import { Toaster } from 'react-hot-toast';
|
||||||
@@ -12,6 +12,12 @@ const inter = Inter({
|
|||||||
subsets: ['latin'],
|
subsets: ['latin'],
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const roboto = Roboto({
|
||||||
|
variable: '--font-roboto',
|
||||||
|
subsets: ['latin'],
|
||||||
|
weight: ['200', '300', '400', '500', '600', '700', '900'],
|
||||||
|
});
|
||||||
|
|
||||||
export const viewport: Viewport = {
|
export const viewport: Viewport = {
|
||||||
themeColor: '#1f74bf',
|
themeColor: '#1f74bf',
|
||||||
colorScheme: 'light',
|
colorScheme: 'light',
|
||||||
@@ -30,7 +36,9 @@ export default function RootLayout({
|
|||||||
}>) {
|
}>) {
|
||||||
return (
|
return (
|
||||||
<html lang='en' data-theme='lti'>
|
<html lang='en' data-theme='lti'>
|
||||||
<body className={`${inter.variable} antialiased font-inter`}>
|
<body
|
||||||
|
className={`${inter.variable} ${roboto.variable} antialiased font-inter`}
|
||||||
|
>
|
||||||
<RequireAuth>
|
<RequireAuth>
|
||||||
<MainDrawer>{children}</MainDrawer>
|
<MainDrawer>{children}</MainDrawer>
|
||||||
</RequireAuth>
|
</RequireAuth>
|
||||||
|
|||||||
@@ -1,11 +0,0 @@
|
|||||||
import SuspenseHelper from '@/components/helper/SuspenseHelper';
|
|
||||||
|
|
||||||
const Layout = ({
|
|
||||||
children,
|
|
||||||
}: Readonly<{
|
|
||||||
children: React.ReactNode;
|
|
||||||
}>) => {
|
|
||||||
return <SuspenseHelper>{children}</SuspenseHelper>;
|
|
||||||
};
|
|
||||||
|
|
||||||
export default Layout;
|
|
||||||
@@ -1,54 +0,0 @@
|
|||||||
'use client';
|
|
||||||
|
|
||||||
import MarketingForm from '@/components/pages/marketing/form/MarketingForm';
|
|
||||||
import { isResponseError, isResponseSuccess } from '@/lib/api-helper';
|
|
||||||
import { MarketingApi } from '@/services/api/marketing/marketing';
|
|
||||||
import { useRouter, useSearchParams } from 'next/navigation';
|
|
||||||
import toast from 'react-hot-toast';
|
|
||||||
import useSWR from 'swr';
|
|
||||||
|
|
||||||
const EditMarketingDelivery = () => {
|
|
||||||
const router = useRouter();
|
|
||||||
const searchParams = useSearchParams();
|
|
||||||
|
|
||||||
const soId = searchParams.get('marketingId');
|
|
||||||
|
|
||||||
const {
|
|
||||||
data: marketing,
|
|
||||||
isLoading: isLoading,
|
|
||||||
mutate: refreshMarketing,
|
|
||||||
} = useSWR(`get-so-${soId}`, () =>
|
|
||||||
MarketingApi.getSingle(soId ? parseInt(soId) : 0)
|
|
||||||
);
|
|
||||||
|
|
||||||
if (!soId) {
|
|
||||||
router.back();
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div className='w-full flex flex-row justify-center items-center p-4'>
|
|
||||||
<span className='loading loading-spinner loading-xl' />
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!isLoading && (!marketing || isResponseError(marketing))) {
|
|
||||||
router.replace('/404');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div className='w-full p-4'>
|
|
||||||
{isLoading && <span className='loading loading-spinner loading-xl' />}
|
|
||||||
{!isLoading && isResponseSuccess(marketing) && (
|
|
||||||
<MarketingForm
|
|
||||||
formType='add_deliver'
|
|
||||||
initialValues={marketing.data}
|
|
||||||
afterSubmit={() => {
|
|
||||||
refreshMarketing();
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
export default EditMarketingDelivery;
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
import MarketingForm from '@/components/pages/marketing/form/MarketingForm';
|
|
||||||
|
|
||||||
const AddSalesOrder = () => {
|
|
||||||
return (
|
|
||||||
<div className='size-full p-4'>
|
|
||||||
<MarketingForm formType='add' />
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
export default AddSalesOrder;
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
import SuspenseHelper from '@/components/helper/SuspenseHelper';
|
|
||||||
|
|
||||||
const Layout = ({
|
|
||||||
children,
|
|
||||||
}: Readonly<{
|
|
||||||
children: React.ReactNode;
|
|
||||||
}>) => {
|
|
||||||
return <SuspenseHelper>{children}</SuspenseHelper>;
|
|
||||||
};
|
|
||||||
|
|
||||||
export default Layout;
|
|
||||||
@@ -1,62 +0,0 @@
|
|||||||
'use client';
|
|
||||||
|
|
||||||
import MarketingForm from '@/components/pages/marketing/form/MarketingForm';
|
|
||||||
import { isResponseError, isResponseSuccess } from '@/lib/api-helper';
|
|
||||||
import { MarketingApi } from '@/services/api/marketing/marketing';
|
|
||||||
import { useRouter, useSearchParams } from 'next/navigation';
|
|
||||||
import toast from 'react-hot-toast';
|
|
||||||
import useSWR from 'swr';
|
|
||||||
|
|
||||||
const EditMarketingDelivery = () => {
|
|
||||||
const router = useRouter();
|
|
||||||
const searchParams = useSearchParams();
|
|
||||||
|
|
||||||
const soId = searchParams.get('marketingId');
|
|
||||||
|
|
||||||
const {
|
|
||||||
data: marketing,
|
|
||||||
isLoading: isLoading,
|
|
||||||
mutate: refreshMarketing,
|
|
||||||
} = useSWR(`get-so-${soId}`, () =>
|
|
||||||
MarketingApi.getSingle(soId ? parseInt(soId) : 0)
|
|
||||||
);
|
|
||||||
|
|
||||||
if (!soId) {
|
|
||||||
router.back();
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div className='w-full flex flex-row justify-center items-center p-4'>
|
|
||||||
<span className='loading loading-spinner loading-xl' />
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!isLoading && (!marketing || isResponseError(marketing))) {
|
|
||||||
router.replace('/404');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (
|
|
||||||
isResponseSuccess(marketing) &&
|
|
||||||
marketing.data.latest_approval.step_number != 3
|
|
||||||
) {
|
|
||||||
toast.error('Data Marketing perlu dilakukan approval terlebih dahulu!');
|
|
||||||
router.back();
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div className='w-full p-4'>
|
|
||||||
{isLoading && <span className='loading loading-spinner loading-xl' />}
|
|
||||||
{!isLoading && isResponseSuccess(marketing) && (
|
|
||||||
<MarketingForm
|
|
||||||
formType='edit_deliver'
|
|
||||||
initialValues={marketing.data}
|
|
||||||
afterSubmit={() => {
|
|
||||||
refreshMarketing();
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
export default EditMarketingDelivery;
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
import SuspenseHelper from '@/components/helper/SuspenseHelper';
|
|
||||||
|
|
||||||
const Layout = ({
|
|
||||||
children,
|
|
||||||
}: Readonly<{
|
|
||||||
children: React.ReactNode;
|
|
||||||
}>) => {
|
|
||||||
return <SuspenseHelper>{children}</SuspenseHelper>;
|
|
||||||
};
|
|
||||||
|
|
||||||
export default Layout;
|
|
||||||
@@ -1,49 +0,0 @@
|
|||||||
'use client';
|
|
||||||
|
|
||||||
import MarketingDetail from '@/components/pages/marketing/detail/MarketingDetail';
|
|
||||||
import { isResponseError, isResponseSuccess } from '@/lib/api-helper';
|
|
||||||
import { MarketingApi } from '@/services/api/marketing/marketing';
|
|
||||||
import { useRouter, useSearchParams } from 'next/navigation';
|
|
||||||
import useSWR from 'swr';
|
|
||||||
|
|
||||||
const DetailMarketing = () => {
|
|
||||||
const router = useRouter();
|
|
||||||
const searchParams = useSearchParams();
|
|
||||||
|
|
||||||
const soId = searchParams.get('marketingId');
|
|
||||||
|
|
||||||
const {
|
|
||||||
data: marketing,
|
|
||||||
isLoading: isLoading,
|
|
||||||
mutate: refreshMarketing,
|
|
||||||
} = useSWR(soId, (id: number) => MarketingApi.getSingle(id));
|
|
||||||
|
|
||||||
if (!soId) {
|
|
||||||
router.back();
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div className='w-full flex flex-row justify-center items-center p-4'>
|
|
||||||
<span className='loading loading-spinner loading-xl' />
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!isLoading && (!marketing || isResponseError(marketing))) {
|
|
||||||
router.replace('/404');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div className='w-full p-4'>
|
|
||||||
{isLoading && <span className='loading loading-spinner loading-xl' />}
|
|
||||||
{!isLoading && isResponseSuccess(marketing) && (
|
|
||||||
<MarketingDetail
|
|
||||||
initialValues={marketing.data}
|
|
||||||
refresh={refreshMarketing}
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
export default DetailMarketing;
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
import SuspenseHelper from '@/components/helper/SuspenseHelper';
|
|
||||||
|
|
||||||
const Layout = ({
|
|
||||||
children,
|
|
||||||
}: Readonly<{
|
|
||||||
children: React.ReactNode;
|
|
||||||
}>) => {
|
|
||||||
return <SuspenseHelper>{children}</SuspenseHelper>;
|
|
||||||
};
|
|
||||||
|
|
||||||
export default Layout;
|
|
||||||
@@ -1,52 +0,0 @@
|
|||||||
'use client';
|
|
||||||
|
|
||||||
import MarketingForm from '@/components/pages/marketing/form/MarketingForm';
|
|
||||||
import { isResponseError, isResponseSuccess } from '@/lib/api-helper';
|
|
||||||
import { MarketingApi } from '@/services/api/marketing/marketing';
|
|
||||||
import { useRouter, useSearchParams } from 'next/navigation';
|
|
||||||
import useSWR from 'swr';
|
|
||||||
|
|
||||||
const EditSalesOrder = () => {
|
|
||||||
const router = useRouter();
|
|
||||||
const searchParams = useSearchParams();
|
|
||||||
|
|
||||||
const soId = searchParams.get('marketingId');
|
|
||||||
|
|
||||||
const {
|
|
||||||
data: marketing,
|
|
||||||
isLoading: isLoading,
|
|
||||||
mutate: refreshMarketing,
|
|
||||||
} = useSWR(`get-so-${soId}`, () =>
|
|
||||||
MarketingApi.getSingle(soId ? parseInt(soId) : 0)
|
|
||||||
);
|
|
||||||
|
|
||||||
if (!soId) {
|
|
||||||
router.back();
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div className='w-full flex flex-row justify-center items-center p-4'>
|
|
||||||
<span className='loading loading-spinner loading-xl' />
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!isLoading && (!marketing || isResponseError(marketing))) {
|
|
||||||
router.replace('/404');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
return (
|
|
||||||
<div className='w-full p-4'>
|
|
||||||
{isLoading && <span className='loading loading-spinner loading-xl' />}
|
|
||||||
{!isLoading && isResponseSuccess(marketing) && (
|
|
||||||
<MarketingForm
|
|
||||||
formType='edit'
|
|
||||||
initialValues={marketing.data}
|
|
||||||
afterSubmit={() => {
|
|
||||||
refreshMarketing();
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
export default EditSalesOrder;
|
|
||||||
@@ -1,9 +1,14 @@
|
|||||||
|
import DeliveryOrderFormModal from '@/components/pages/marketing/DeliveryOrderFormModal';
|
||||||
import MarketingTable from '@/components/pages/marketing/MarketingTable';
|
import MarketingTable from '@/components/pages/marketing/MarketingTable';
|
||||||
|
import SalesOrderFormModal from '@/components/pages/marketing/SalesOrderFormModal';
|
||||||
|
|
||||||
const Marketing = () => {
|
const Marketing = () => {
|
||||||
return (
|
return (
|
||||||
<div className='w-full p-4'>
|
<div className='w-full'>
|
||||||
<MarketingTable />
|
<MarketingTable />
|
||||||
|
|
||||||
|
<SalesOrderFormModal />
|
||||||
|
<DeliveryOrderFormModal />
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,11 +1,7 @@
|
|||||||
import AreasTable from '@/components/pages/master-data/area/AreasTable';
|
import AreasTable from '@/components/pages/master-data/area/AreasTable';
|
||||||
|
|
||||||
const Nonstock = () => {
|
const Nonstock = () => {
|
||||||
return (
|
return <AreasTable />;
|
||||||
<section className='w-full p-4'>
|
|
||||||
<AreasTable />
|
|
||||||
</section>
|
|
||||||
);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export default Nonstock;
|
export default Nonstock;
|
||||||
|
|||||||
@@ -1,11 +1,7 @@
|
|||||||
import BanksTable from '@/components/pages/master-data/bank/BanksTable';
|
import BanksTable from '@/components/pages/master-data/bank/BanksTable';
|
||||||
|
|
||||||
const Bank = () => {
|
const Bank = () => {
|
||||||
return (
|
return <BanksTable />;
|
||||||
<section className='w-full p-4'>
|
|
||||||
<BanksTable />
|
|
||||||
</section>
|
|
||||||
);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export default Bank;
|
export default Bank;
|
||||||
|
|||||||
@@ -1,11 +1,7 @@
|
|||||||
import CustomersTable from '@/components/pages/master-data/customer/CustomersTable';
|
import CustomersTable from '@/components/pages/master-data/customer/CustomersTable';
|
||||||
|
|
||||||
const Customer = () => {
|
const Customer = () => {
|
||||||
return (
|
return <CustomersTable />;
|
||||||
<section className='w-full p-4'>
|
|
||||||
<CustomersTable />
|
|
||||||
</section>
|
|
||||||
);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export default Customer;
|
export default Customer;
|
||||||
|
|||||||
@@ -1,11 +0,0 @@
|
|||||||
import FcrForm from '@/components/pages/master-data/fcr/form/FcrForm';
|
|
||||||
|
|
||||||
const AddFcr = () => {
|
|
||||||
return (
|
|
||||||
<div className='w-full p-4 flex flex-row justify-center'>
|
|
||||||
<FcrForm />
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
export default AddFcr;
|
|
||||||
@@ -1,52 +0,0 @@
|
|||||||
'use client';
|
|
||||||
|
|
||||||
import { useRouter, useSearchParams } from 'next/navigation';
|
|
||||||
import useSWR from 'swr';
|
|
||||||
|
|
||||||
import FcrForm from '@/components/pages/master-data/fcr/form/FcrForm';
|
|
||||||
|
|
||||||
import { FcrApi } from '@/services/api/master-data';
|
|
||||||
import { isResponseError, isResponseSuccess } from '@/lib/api-helper';
|
|
||||||
import { BaseApiResponse } from '@/types/api/api-general';
|
|
||||||
import { FcrWithStandards } from '@/types/api/master-data/fcr';
|
|
||||||
|
|
||||||
const FcrEdit = () => {
|
|
||||||
const router = useRouter();
|
|
||||||
const searchParams = useSearchParams();
|
|
||||||
|
|
||||||
const fcrId = searchParams.get('fcrId');
|
|
||||||
|
|
||||||
const { data: fcr, isLoading: isLoadingFcr } = useSWR(
|
|
||||||
fcrId,
|
|
||||||
(id: number) =>
|
|
||||||
FcrApi.getSingle(id) as Promise<
|
|
||||||
BaseApiResponse<FcrWithStandards> | undefined
|
|
||||||
>
|
|
||||||
);
|
|
||||||
|
|
||||||
if (!fcrId) {
|
|
||||||
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 (!isLoadingFcr && (!fcr || isResponseError(fcr))) {
|
|
||||||
router.replace('/404');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div className='w-full p-4 flex flex-row justify-center'>
|
|
||||||
{isLoadingFcr && <span className='loading loading-spinner loading-xl' />}
|
|
||||||
{!isLoadingFcr && isResponseSuccess(fcr) && (
|
|
||||||
<FcrForm type='edit' initialValues={fcr.data} />
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
export default FcrEdit;
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
import SuspenseHelper from '@/components/helper/SuspenseHelper';
|
|
||||||
|
|
||||||
const Layout = ({
|
|
||||||
children,
|
|
||||||
}: Readonly<{
|
|
||||||
children: React.ReactNode;
|
|
||||||
}>) => {
|
|
||||||
return <SuspenseHelper>{children}</SuspenseHelper>;
|
|
||||||
};
|
|
||||||
|
|
||||||
export default Layout;
|
|
||||||
@@ -1,52 +0,0 @@
|
|||||||
'use client';
|
|
||||||
|
|
||||||
import { useRouter, useSearchParams } from 'next/navigation';
|
|
||||||
import useSWR from 'swr';
|
|
||||||
|
|
||||||
import FcrForm from '@/components/pages/master-data/fcr/form/FcrForm';
|
|
||||||
|
|
||||||
import { FcrApi } from '@/services/api/master-data';
|
|
||||||
import { isResponseError, isResponseSuccess } from '@/lib/api-helper';
|
|
||||||
import { FcrWithStandards } from '@/types/api/master-data/fcr';
|
|
||||||
import { BaseApiResponse } from '@/types/api/api-general';
|
|
||||||
|
|
||||||
const FcrDetail = () => {
|
|
||||||
const router = useRouter();
|
|
||||||
const searchParams = useSearchParams();
|
|
||||||
|
|
||||||
const fcrId = searchParams.get('fcrId');
|
|
||||||
|
|
||||||
const { data: fcr, isLoading: isLoadingFcr } = useSWR(
|
|
||||||
fcrId,
|
|
||||||
(id: number) =>
|
|
||||||
FcrApi.getSingle(id) as Promise<
|
|
||||||
BaseApiResponse<FcrWithStandards> | undefined
|
|
||||||
>
|
|
||||||
);
|
|
||||||
|
|
||||||
if (!fcrId) {
|
|
||||||
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 (!isLoadingFcr && (!fcr || isResponseError(fcr))) {
|
|
||||||
router.replace('/404');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div className='w-full p-4 flex flex-row justify-center'>
|
|
||||||
{isLoadingFcr && <span className='loading loading-spinner loading-xl' />}
|
|
||||||
{!isLoadingFcr && isResponseSuccess(fcr) && (
|
|
||||||
<FcrForm type='detail' initialValues={fcr.data} />
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
export default FcrDetail;
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
import FcrsTable from '@/components/pages/master-data/fcr/FcrsTable';
|
|
||||||
|
|
||||||
const Fcr = () => {
|
|
||||||
return (
|
|
||||||
<section className='w-full p-4'>
|
|
||||||
<FcrsTable />
|
|
||||||
</section>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
export default Fcr;
|
|
||||||
@@ -1,11 +1,7 @@
|
|||||||
import FlockTable from '@/components/pages/master-data/flock/FlocksTable';
|
import FlockTable from '@/components/pages/master-data/flock/FlocksTable';
|
||||||
|
|
||||||
const Flock = () => {
|
const Flock = () => {
|
||||||
return (
|
return <FlockTable />;
|
||||||
<section className='w-full p-4'>
|
|
||||||
<FlockTable />
|
|
||||||
</section>
|
|
||||||
);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export default Flock;
|
export default Flock;
|
||||||
|
|||||||
@@ -1,11 +1,7 @@
|
|||||||
import KandangsTable from '@/components/pages/master-data/kandang/KandangsTable';
|
import KandangsTable from '@/components/pages/master-data/kandang/KandangsTable';
|
||||||
|
|
||||||
const Nonstock = () => {
|
const Nonstock = () => {
|
||||||
return (
|
return <KandangsTable />;
|
||||||
<section className='w-full p-4'>
|
|
||||||
<KandangsTable />
|
|
||||||
</section>
|
|
||||||
);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export default Nonstock;
|
export default Nonstock;
|
||||||
|
|||||||
@@ -1,11 +1,7 @@
|
|||||||
import LocationsTable from '@/components/pages/master-data/location/LocationsTable';
|
import LocationsTable from '@/components/pages/master-data/location/LocationsTable';
|
||||||
|
|
||||||
const Nonstock = () => {
|
const Nonstock = () => {
|
||||||
return (
|
return <LocationsTable />;
|
||||||
<section className='w-full p-4'>
|
|
||||||
<LocationsTable />
|
|
||||||
</section>
|
|
||||||
);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export default Nonstock;
|
export default Nonstock;
|
||||||
|
|||||||
@@ -1,11 +1,7 @@
|
|||||||
import NonstocksTable from '@/components/pages/master-data/nonstock/NonstocksTable';
|
import NonstocksTable from '@/components/pages/master-data/nonstock/NonstocksTable';
|
||||||
|
|
||||||
const Nonstock = () => {
|
const Nonstock = () => {
|
||||||
return (
|
return <NonstocksTable />;
|
||||||
<section className='w-full p-4'>
|
|
||||||
<NonstocksTable />
|
|
||||||
</section>
|
|
||||||
);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export default Nonstock;
|
export default Nonstock;
|
||||||
|
|||||||
@@ -1,11 +1,7 @@
|
|||||||
import ProductCategoryTable from '@/components/pages/master-data/product-category/ProductCategoryTable';
|
import ProductCategoryTable from '@/components/pages/master-data/product-category/ProductCategoryTable';
|
||||||
|
|
||||||
const ProductCategory = () => {
|
const ProductCategory = () => {
|
||||||
return (
|
return <ProductCategoryTable />;
|
||||||
<section className='w-full p-4'>
|
|
||||||
<ProductCategoryTable />
|
|
||||||
</section>
|
|
||||||
);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export default ProductCategory;
|
export default ProductCategory;
|
||||||
|
|||||||
@@ -1,11 +1,7 @@
|
|||||||
import ProductsTable from '@/components/pages/master-data/product/ProductTable';
|
import ProductsTable from '@/components/pages/master-data/product/ProductTable';
|
||||||
|
|
||||||
const Product = () => {
|
const Product = () => {
|
||||||
return (
|
return <ProductsTable />;
|
||||||
<section className='w-full p-4'>
|
|
||||||
<ProductsTable />
|
|
||||||
</section>
|
|
||||||
);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export default Product;
|
export default Product;
|
||||||
|
|||||||
@@ -1,11 +1,7 @@
|
|||||||
import ProductionStandardTable from '@/components/pages/master-data/production-standard/ProductionStandardTable';
|
import ProductionStandardTable from '@/components/pages/master-data/production-standard/ProductionStandardTable';
|
||||||
|
|
||||||
const ProductionStandardPage = () => {
|
const ProductionStandardPage = () => {
|
||||||
return (
|
return <ProductionStandardTable />;
|
||||||
<div className='w-full'>
|
|
||||||
<ProductionStandardTable />
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export default ProductionStandardPage;
|
export default ProductionStandardPage;
|
||||||
|
|||||||
@@ -1,11 +1,7 @@
|
|||||||
import SuppliersTable from '@/components/pages/master-data/supplier/SupplierTable';
|
import SuppliersTable from '@/components/pages/master-data/supplier/SupplierTable';
|
||||||
|
|
||||||
const Supplier = () => {
|
const Supplier = () => {
|
||||||
return (
|
return <SuppliersTable />;
|
||||||
<section className='w-full p-4'>
|
|
||||||
<SuppliersTable />
|
|
||||||
</section>
|
|
||||||
);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export default Supplier;
|
export default Supplier;
|
||||||
|
|||||||
@@ -1,11 +1,7 @@
|
|||||||
import UomsTable from '@/components/pages/master-data/uom/UomsTable';
|
import UomsTable from '@/components/pages/master-data/uom/UomsTable';
|
||||||
|
|
||||||
const Nonstock = () => {
|
const Nonstock = () => {
|
||||||
return (
|
return <UomsTable />;
|
||||||
<section className='w-full p-4'>
|
|
||||||
<UomsTable />
|
|
||||||
</section>
|
|
||||||
);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export default Nonstock;
|
export default Nonstock;
|
||||||
|
|||||||
@@ -1,11 +1,7 @@
|
|||||||
import WarehousesTable from '@/components/pages/master-data/warehouse/WarehousesTable';
|
import WarehousesTable from '@/components/pages/master-data/warehouse/WarehousesTable';
|
||||||
|
|
||||||
const Warehouse = () => {
|
const Warehouse = () => {
|
||||||
return (
|
return <WarehousesTable />;
|
||||||
<section className='w-full p-4'>
|
|
||||||
<WarehousesTable />
|
|
||||||
</section>
|
|
||||||
);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export default Warehouse;
|
export default Warehouse;
|
||||||
|
|||||||
@@ -0,0 +1,5 @@
|
|||||||
|
import PageNotFound from '@/components/helper/NotFoundPage';
|
||||||
|
|
||||||
|
export default function NotFound() {
|
||||||
|
return <PageNotFound />;
|
||||||
|
}
|
||||||
+6
-3
@@ -3,10 +3,9 @@
|
|||||||
import { useEffect } from 'react';
|
import { useEffect } from 'react';
|
||||||
import { usePathname, useRouter } from 'next/navigation';
|
import { usePathname, useRouter } from 'next/navigation';
|
||||||
import { useAuth } from '@/services/hooks/useAuth';
|
import { useAuth } from '@/services/hooks/useAuth';
|
||||||
import { redirectToSSO } from '@/lib/auth-helper';
|
|
||||||
|
|
||||||
export default function Home() {
|
export default function Home() {
|
||||||
const { user, isLoadingUser } = useAuth();
|
const { isLoadingUser } = useAuth();
|
||||||
|
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const pathname = usePathname();
|
const pathname = usePathname();
|
||||||
@@ -25,5 +24,9 @@ export default function Home() {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return <>Loading...</>;
|
return (
|
||||||
|
<main className='w-full h-full min-h-screen flex flex-row justify-center items-center'>
|
||||||
|
<span className='loading loading-spinner loading-lg'></span>
|
||||||
|
</main>
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
'use client';
|
'use client';
|
||||||
|
|
||||||
import ProjectFlockForm from '@/components/pages/production/project-flock/form/ProjectFlockForm';
|
import ProjectFlockForm from '@/components/pages/production/project-flock/form/ProjectFlockForm';
|
||||||
import React, { useImperativeHandle } from 'react';
|
import React from 'react';
|
||||||
import toast from 'react-hot-toast';
|
// import React, { useImperativeHandle } from 'react';
|
||||||
|
|
||||||
const AddProjectFlock = () => {
|
const AddProjectFlock = () => {
|
||||||
// useImperativeHandle(ref, () => ({
|
// useImperativeHandle(ref, () => ({
|
||||||
|
|||||||
@@ -12,11 +12,10 @@ const ProjectFlockEdit = () => {
|
|||||||
|
|
||||||
const projectFlockId = searchParams.get('projectFlockId');
|
const projectFlockId = searchParams.get('projectFlockId');
|
||||||
|
|
||||||
const {
|
const { data: projectFlock, isLoading: isLoadingProjectFlock } = useSWR(
|
||||||
data: projectFlock,
|
projectFlockId,
|
||||||
isLoading: isLoadingProjectFlock,
|
(id: number) => ProjectFlockApi.getSingle(id)
|
||||||
mutate: refreshProjectFlocks,
|
);
|
||||||
} = useSWR(projectFlockId, (id: number) => ProjectFlockApi.getSingle(id));
|
|
||||||
|
|
||||||
if (!projectFlockId) {
|
if (!projectFlockId) {
|
||||||
router.back();
|
router.back();
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
'use client';
|
'use client';
|
||||||
|
|
||||||
import ProjectFlockDetail from '@/components/pages/production/project-flock/detail/ProjectFlockDetail';
|
import ProjectFlockDetail from '@/components/pages/production/project-flock/detail/ProjectFlockDetail';
|
||||||
import ProjectFlockForm from '@/components/pages/production/project-flock/form/ProjectFlockForm';
|
|
||||||
import { isResponseError, isResponseSuccess } from '@/lib/api-helper';
|
import { isResponseError, isResponseSuccess } from '@/lib/api-helper';
|
||||||
import { ProjectFlockApi } from '@/services/api/production/project-flock';
|
import { ProjectFlockApi } from '@/services/api/production/project-flock';
|
||||||
import { useRouter, useSearchParams } from 'next/navigation';
|
import { useRouter, useSearchParams } from 'next/navigation';
|
||||||
@@ -13,11 +12,10 @@ const ProjectFlockDetailPage = () => {
|
|||||||
|
|
||||||
const projectFlockId = searchParams.get('projectFlockId');
|
const projectFlockId = searchParams.get('projectFlockId');
|
||||||
|
|
||||||
const {
|
const { data: projectFlock, isLoading: isLoadingProjectFlock } = useSWR(
|
||||||
data: projectFlock,
|
projectFlockId,
|
||||||
isLoading: isLoadingProjectFlock,
|
(id: number) => ProjectFlockApi.getSingle(id)
|
||||||
mutate: refreshProjectFlock,
|
);
|
||||||
} = useSWR(projectFlockId, (id: number) => ProjectFlockApi.getSingle(id));
|
|
||||||
|
|
||||||
if (!projectFlockId) {
|
if (!projectFlockId) {
|
||||||
router.back();
|
router.back();
|
||||||
@@ -50,5 +48,3 @@ const ProjectFlockDetailPage = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export default ProjectFlockDetailPage;
|
export default ProjectFlockDetailPage;
|
||||||
ProjectFlockDetail;
|
|
||||||
ProjectFlockDetail;
|
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
'use client';
|
'use client';
|
||||||
|
|
||||||
import { usePathname, useRouter } from 'next/navigation';
|
import { usePathname, useRouter } from 'next/navigation';
|
||||||
import Drawer from '@/components/Drawer';
|
import React, { ReactNode, useEffect } from 'react';
|
||||||
import React, { ReactNode } from 'react';
|
|
||||||
import ProjectFlockTable from '@/components/pages/production/project-flock/ProjectFlockTable';
|
import ProjectFlockTable from '@/components/pages/production/project-flock/ProjectFlockTable';
|
||||||
import { useUiStore } from '@/stores/ui/ui.store';
|
import { useUiStore } from '@/stores/ui/ui.store';
|
||||||
|
import Modal, { useModal } from '@/components/Modal';
|
||||||
|
|
||||||
export default function ProjectFlockLayout({
|
export default function ProjectFlockLayout({
|
||||||
children,
|
children,
|
||||||
@@ -23,9 +23,12 @@ export default function ProjectFlockLayout({
|
|||||||
|
|
||||||
const isOpen = isAdd || isEdit || isDetail || isChickin || isClosing;
|
const isOpen = isAdd || isEdit || isDetail || isChickin || isClosing;
|
||||||
|
|
||||||
|
const formModal = useModal();
|
||||||
|
|
||||||
const handleBackdropClick = () => {
|
const handleBackdropClick = () => {
|
||||||
const unsub = useUiStore.getState().subscribeIsValid((isValid) => {
|
const unsub = useUiStore.getState().subscribeIsValid((isValid) => {
|
||||||
if (isValid) {
|
if (isValid) {
|
||||||
|
formModal.closeModal();
|
||||||
unsub(); // berhenti listen
|
unsub(); // berhenti listen
|
||||||
router.push('/production/project-flock');
|
router.push('/production/project-flock');
|
||||||
}
|
}
|
||||||
@@ -34,6 +37,14 @@ export default function ProjectFlockLayout({
|
|||||||
toggleValidate();
|
toggleValidate();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (isOpen && !formModal.open) {
|
||||||
|
formModal.openModal();
|
||||||
|
} else {
|
||||||
|
formModal.closeModal();
|
||||||
|
}
|
||||||
|
}, [isOpen]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
{/* List page always rendered */}
|
{/* List page always rendered */}
|
||||||
@@ -43,18 +54,19 @@ export default function ProjectFlockLayout({
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* Render Drawer only on /add */}
|
{/* Render Modal only on /add */}
|
||||||
<Drawer
|
<Modal
|
||||||
open={isOpen}
|
ref={formModal.ref}
|
||||||
setOpen={(v) => {
|
position='end'
|
||||||
if (!v) router.push('/production/project-flock');
|
|
||||||
}}
|
|
||||||
closeOnBackdropClick={isDetail ? true : false}
|
|
||||||
onBackdropClick={handleBackdropClick}
|
onBackdropClick={handleBackdropClick}
|
||||||
variant='right'
|
className={{
|
||||||
zIndex='99999'
|
modalBox: 'w-full sm:w-fit p-3 rounded-xl bg-transparent shadow-none',
|
||||||
sidebarContent={isOpen && <div className=''>{children}</div>}
|
}}
|
||||||
/>
|
>
|
||||||
|
<div className='w-full sm:w-[446px] h-full flex flex-col sm:flex-row items-stretch bg-base-100 rounded-xl overflow-hidden'>
|
||||||
|
{isOpen && children}
|
||||||
|
</div>
|
||||||
|
</Modal>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import RecordingTable from '@/components/pages/production/recording/RecordingTab
|
|||||||
|
|
||||||
const Recording = () => {
|
const Recording = () => {
|
||||||
return (
|
return (
|
||||||
<section className='w-full p-4'>
|
<section className='w-full'>
|
||||||
<RecordingTable />
|
<RecordingTable />
|
||||||
</section>
|
</section>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,11 +0,0 @@
|
|||||||
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;
|
|
||||||
@@ -1,63 +0,0 @@
|
|||||||
'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';
|
|
||||||
|
|
||||||
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>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (
|
|
||||||
!isLoadingTransferToLaying &&
|
|
||||||
(!transferToLaying || isResponseError(transferToLaying))
|
|
||||||
) {
|
|
||||||
router.replace('/404');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (
|
|
||||||
isResponseSuccess(transferToLaying) &&
|
|
||||||
transferToLaying.data.approval.step_number === 2
|
|
||||||
) {
|
|
||||||
router.replace('/production/transfer-to-laying');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div className='w-full p-4 flex flex-row justify-center'>
|
|
||||||
{isLoadingTransferToLaying && (
|
|
||||||
<span className='loading loading-spinner loading-xl' />
|
|
||||||
)}
|
|
||||||
{!isLoadingTransferToLaying && isResponseSuccess(transferToLaying) && (
|
|
||||||
<TransferToLayingForm
|
|
||||||
type='edit'
|
|
||||||
initialValues={transferToLaying.data}
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
export default TransferToLayingEdit;
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
import SuspenseHelper from '@/components/helper/SuspenseHelper';
|
|
||||||
|
|
||||||
const Layout = ({
|
|
||||||
children,
|
|
||||||
}: Readonly<{
|
|
||||||
children: React.ReactNode;
|
|
||||||
}>) => {
|
|
||||||
return <SuspenseHelper>{children}</SuspenseHelper>;
|
|
||||||
};
|
|
||||||
|
|
||||||
export default Layout;
|
|
||||||
@@ -1,56 +0,0 @@
|
|||||||
'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';
|
|
||||||
|
|
||||||
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>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (
|
|
||||||
!isLoadingTransferToLaying &&
|
|
||||||
(!transferToLaying || isResponseError(transferToLaying))
|
|
||||||
) {
|
|
||||||
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}
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
export default TransferToLayingDetail;
|
|
||||||
@@ -1,9 +1,25 @@
|
|||||||
import TransferToLayingsTable from '@/components/pages/production/transfer-to-laying/TransferToLayingsTable';
|
import TransferToLayingsTable from '@/components/pages/production/transfer-to-laying/TransferToLayingsTable';
|
||||||
|
import TransferToLayingFormModal from '@/components/pages/production/transfer-to-laying/TransferToLayingFormModal';
|
||||||
|
import TransferToLayingDetailModal from '@/components/pages/production/transfer-to-laying/TransferToLayingDetailModal';
|
||||||
|
import RequirePermission from '@/components/helper/RequirePermission';
|
||||||
|
|
||||||
const TransferToLaying = () => {
|
const TransferToLaying = () => {
|
||||||
return (
|
return (
|
||||||
<section className='w-full p-4'>
|
<section className='w-full'>
|
||||||
<TransferToLayingsTable />
|
<TransferToLayingsTable />
|
||||||
|
|
||||||
|
<RequirePermission
|
||||||
|
permissions={[
|
||||||
|
'lti.production.transfer_to_laying.create',
|
||||||
|
'lti.production.transfer_to_laying.update',
|
||||||
|
]}
|
||||||
|
>
|
||||||
|
<TransferToLayingFormModal />
|
||||||
|
</RequirePermission>
|
||||||
|
|
||||||
|
<RequirePermission permissions='lti.production.transfer_to_laying.detail'>
|
||||||
|
<TransferToLayingDetailModal />
|
||||||
|
</RequirePermission>
|
||||||
</section>
|
</section>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import PurchaseTable from '@/components/pages/purchase/PurchaseTable';
|
|||||||
|
|
||||||
const Purchase = () => {
|
const Purchase = () => {
|
||||||
return (
|
return (
|
||||||
<section className='w-full p-4'>
|
<section className='w-full p-4 sm:p-0'>
|
||||||
<PurchaseTable />
|
<PurchaseTable />
|
||||||
</section>
|
</section>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,13 +1,9 @@
|
|||||||
'use client';
|
'use client';
|
||||||
|
|
||||||
import ReportExpenseTable from '@/components/pages/report/expense/ReportExpenseTable';
|
import ReportExpenseTabs from '@/components/pages/report/expense/ReportExpenseTabs';
|
||||||
|
|
||||||
const ReportExpense = () => {
|
const ReportExpense = () => {
|
||||||
return (
|
return <ReportExpenseTabs />;
|
||||||
<div className='w-full p-4'>
|
|
||||||
<ReportExpenseTable />
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export default ReportExpense;
|
export default ReportExpense;
|
||||||
|
|||||||
@@ -1,11 +1,7 @@
|
|||||||
import MarketingReportContent from '@/components/pages/report/MarketingReportContent';
|
import MarketingReportContent from '@/components/pages/report/marketing/MarketingTabs';
|
||||||
|
|
||||||
const MarketingReportPage = () => {
|
const MarketingReportPage = () => {
|
||||||
return (
|
return <MarketingReportContent />;
|
||||||
<section className='w-full p-4'>
|
|
||||||
<MarketingReportContent />
|
|
||||||
</section>
|
|
||||||
);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export default MarketingReportPage;
|
export default MarketingReportPage;
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
import ProductionResultContent from '@/components/pages/report/production-result/ProductionResultContent';
|
import ProductionResultTabs from '@/components/pages/report/production-result/ProductionResultTabs';
|
||||||
|
|
||||||
const ProductionResultReportPage = () => {
|
const ProductionResultReportPage = () => {
|
||||||
return (
|
return (
|
||||||
<section className='w-full max-w-7xl pb-16'>
|
<section className='w-full max-w-full'>
|
||||||
<ProductionResultContent />
|
<ProductionResultTabs />
|
||||||
</section>
|
</section>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,15 +1,16 @@
|
|||||||
import { ReactNode } from 'react';
|
import { ReactNode, Ref } from 'react';
|
||||||
|
|
||||||
import { cn } from '@/lib/helper';
|
import { cn } from '@/lib/helper';
|
||||||
|
|
||||||
interface AlertProps {
|
interface AlertProps {
|
||||||
|
ref?: Ref<HTMLDivElement> | undefined;
|
||||||
variant?: 'outline' | 'dash' | 'soft';
|
variant?: 'outline' | 'dash' | 'soft';
|
||||||
color?: 'info' | 'success' | 'warning' | 'error';
|
color?: 'info' | 'success' | 'warning' | 'error';
|
||||||
children?: ReactNode;
|
children?: ReactNode;
|
||||||
className?: string;
|
className?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
const Alert = ({ children, variant, color, className }: AlertProps) => {
|
const Alert = ({ children, ref, variant, color, className }: AlertProps) => {
|
||||||
const alertBaseClassName = cn('alert', {
|
const alertBaseClassName = cn('alert', {
|
||||||
'alert-soft': variant === 'soft',
|
'alert-soft': variant === 'soft',
|
||||||
'alert-outline': variant === 'outline',
|
'alert-outline': variant === 'outline',
|
||||||
@@ -21,7 +22,11 @@ const Alert = ({ children, variant, color, className }: AlertProps) => {
|
|||||||
'alert-error': color === 'error',
|
'alert-error': color === 'error',
|
||||||
});
|
});
|
||||||
|
|
||||||
return <div className={cn(alertBaseClassName, className)}>{children}</div>;
|
return (
|
||||||
|
<div ref={ref} className={cn(alertBaseClassName, className)}>
|
||||||
|
{children}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export default Alert;
|
export default Alert;
|
||||||
|
|||||||
@@ -0,0 +1,263 @@
|
|||||||
|
import React, { useId } from 'react';
|
||||||
|
import Link from 'next/link';
|
||||||
|
import { Icon } from '@iconify/react';
|
||||||
|
import { cn, findMenuPath } from '@/lib/helper';
|
||||||
|
import { Size } from '@/types/theme';
|
||||||
|
import Button from '@/components/Button';
|
||||||
|
import { MAIN_DRAWER_LINKS } from '@/config/constant';
|
||||||
|
|
||||||
|
interface BreadcrumbItem {
|
||||||
|
label: string;
|
||||||
|
href?: string;
|
||||||
|
icon?: React.ReactNode;
|
||||||
|
isActive?: boolean;
|
||||||
|
isDisabled?: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface BreadcrumbsProps extends React.HTMLAttributes<HTMLElement> {
|
||||||
|
items: BreadcrumbItem[];
|
||||||
|
size?: Size;
|
||||||
|
maxVisibleItems?: number;
|
||||||
|
showEllipsisDropdown?: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function buildBreadcrumbs(pathname: string): BreadcrumbItem[] {
|
||||||
|
const menuPath = findMenuPath(MAIN_DRAWER_LINKS, pathname);
|
||||||
|
|
||||||
|
if (!menuPath) return [];
|
||||||
|
|
||||||
|
return menuPath.map((menu, index) => {
|
||||||
|
const isLast = index === menuPath.length - 1;
|
||||||
|
|
||||||
|
return {
|
||||||
|
label: menu.text,
|
||||||
|
href: isLast ? menu.link : undefined,
|
||||||
|
isActive: isLast,
|
||||||
|
icon: menu.icon ? (
|
||||||
|
<Icon icon={menu.icon} width={16} height={16} />
|
||||||
|
) : undefined,
|
||||||
|
};
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
const EllipsisDropdown = ({
|
||||||
|
hiddenItems,
|
||||||
|
}: {
|
||||||
|
hiddenItems: BreadcrumbItem[];
|
||||||
|
}) => {
|
||||||
|
const dropdownId = useId();
|
||||||
|
const anchorId = useId();
|
||||||
|
|
||||||
|
return (
|
||||||
|
<li>
|
||||||
|
{/* Ellipsis Button */}
|
||||||
|
<Button
|
||||||
|
popoverTarget={dropdownId}
|
||||||
|
variant='ghost'
|
||||||
|
color='none'
|
||||||
|
style={
|
||||||
|
{
|
||||||
|
anchorName: `--breadcrumb-ellipsis-anchor-${anchorId}`,
|
||||||
|
} as React.CSSProperties
|
||||||
|
}
|
||||||
|
>
|
||||||
|
<Icon icon='material-symbols:more-horiz' width={16} height={16} />
|
||||||
|
</Button>
|
||||||
|
|
||||||
|
{/* Dropdown Menu using popover API */}
|
||||||
|
<ul
|
||||||
|
className='dropdown menu rounded-box bg-base-100 border border-base-300 shadow-lg z-[9999] [&_a:hover]:no-underline [&_a:focus]:no-underline [&&]:no-underline [&&_a]:no-underline [&&]:hover:no-underline [&&]:flex [&&]:items-start [&&]:justify-start w-max'
|
||||||
|
popover='auto'
|
||||||
|
id={dropdownId}
|
||||||
|
style={
|
||||||
|
{
|
||||||
|
positionAnchor: `--breadcrumb-ellipsis-anchor-${anchorId}`,
|
||||||
|
} as React.CSSProperties
|
||||||
|
}
|
||||||
|
>
|
||||||
|
{hiddenItems.map((item, index) => {
|
||||||
|
const itemStyles = cn(
|
||||||
|
'[&]:flex [&]:items-center [&]:justify-start py-1 text-sm',
|
||||||
|
// Disabled state
|
||||||
|
item.isDisabled && 'text-base-content/40 opacity-50',
|
||||||
|
// Active/Last state
|
||||||
|
(item.isActive || item.isDisabled) && 'text-primary',
|
||||||
|
// Regular clickable state
|
||||||
|
!item.isDisabled && 'text-base-content/50'
|
||||||
|
);
|
||||||
|
|
||||||
|
const itemContent = (
|
||||||
|
<div className={itemStyles}>
|
||||||
|
{item.icon && (
|
||||||
|
<span className='inline-flex mr-2'>{item.icon}</span>
|
||||||
|
)}
|
||||||
|
{item.label}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<li
|
||||||
|
key={`ellipsis-${index}`}
|
||||||
|
className='[&&]:text-left [&&]:block w-full'
|
||||||
|
>
|
||||||
|
{item.href && !item.isDisabled ? (
|
||||||
|
<Link
|
||||||
|
href={item.href}
|
||||||
|
className='block !no-underline [&&]:text-left w-full'
|
||||||
|
onClick={(e) => e.stopPropagation()}
|
||||||
|
>
|
||||||
|
{itemContent}
|
||||||
|
</Link>
|
||||||
|
) : (
|
||||||
|
<div className='block !no-underline [&&]:cursor-default [&&]:hover:cursor-default [&&]:hover:bg-base-100 [&&]:text-left'>
|
||||||
|
{itemContent}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</li>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
</ul>
|
||||||
|
</li>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
const Breadcrumb = ({
|
||||||
|
items,
|
||||||
|
size = 'md',
|
||||||
|
maxVisibleItems = 3,
|
||||||
|
showEllipsisDropdown = true,
|
||||||
|
className,
|
||||||
|
...props
|
||||||
|
}: BreadcrumbsProps) => {
|
||||||
|
const sizeClasses = {
|
||||||
|
xs: 'text-xs',
|
||||||
|
sm: 'text-sm',
|
||||||
|
md: 'text-base',
|
||||||
|
lg: 'text-lg',
|
||||||
|
xl: 'text-xl',
|
||||||
|
};
|
||||||
|
|
||||||
|
const getItemStyles = (
|
||||||
|
item: BreadcrumbItem,
|
||||||
|
position: 'first' | 'middle' | 'last' = 'middle'
|
||||||
|
) => {
|
||||||
|
const baseClasses = 'inline-flex items-center gap-2';
|
||||||
|
|
||||||
|
// Disabled state
|
||||||
|
if (item.isDisabled) {
|
||||||
|
return `${baseClasses} text-base-content/40 !cursor-default opacity-50 hover:!no-underline`;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Active/Last state (no underline)
|
||||||
|
if (item.isActive || position === 'last') {
|
||||||
|
return `${baseClasses} text-primary !cursor-pointer hover:!no-underline`;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Regular clickable state
|
||||||
|
return `${baseClasses} text-base-content/60`;
|
||||||
|
};
|
||||||
|
|
||||||
|
const renderItem = (
|
||||||
|
item: BreadcrumbItem,
|
||||||
|
position: 'first' | 'middle' | 'last' = 'middle'
|
||||||
|
) => {
|
||||||
|
const styles = getItemStyles(item, position);
|
||||||
|
|
||||||
|
// Disabled items
|
||||||
|
if (item.isDisabled) {
|
||||||
|
return (
|
||||||
|
<span className={styles}>
|
||||||
|
{item.icon && item.icon}
|
||||||
|
{item.label}
|
||||||
|
</span>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Active/Last items
|
||||||
|
if (item.isActive || position === 'last') {
|
||||||
|
if (item.href) {
|
||||||
|
return (
|
||||||
|
<Link href={item.href} className={styles}>
|
||||||
|
{item.icon && (
|
||||||
|
<span className='inline-flex gap-2'>{item.icon}</span>
|
||||||
|
)}
|
||||||
|
{item.label}
|
||||||
|
</Link>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return (
|
||||||
|
<span className={styles}>
|
||||||
|
{item.icon && item.icon}
|
||||||
|
{item.label}
|
||||||
|
</span>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Regular items
|
||||||
|
if (item.href) {
|
||||||
|
return (
|
||||||
|
<Link href={item.href} className={styles}>
|
||||||
|
{item.icon && <span className='inline-flex gap-2'>{item.icon}</span>}
|
||||||
|
{item.label}
|
||||||
|
</Link>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<span className={styles}>
|
||||||
|
{item.icon && item.icon}
|
||||||
|
{item.label}
|
||||||
|
</span>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
const renderBreadcrumbList = () => {
|
||||||
|
// Show all items if within limit
|
||||||
|
if (items.length <= maxVisibleItems) {
|
||||||
|
return items.map((item, index) => {
|
||||||
|
const position =
|
||||||
|
index === 0
|
||||||
|
? 'first'
|
||||||
|
: index === items.length - 1
|
||||||
|
? 'last'
|
||||||
|
: 'middle';
|
||||||
|
return <li key={index}>{renderItem(item, position)}</li>;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Collapsed items indexing when exceeding limit
|
||||||
|
const firstItem = items[0];
|
||||||
|
const lastItem = items[items.length - 1];
|
||||||
|
const visibleMiddleItems = items.slice(1, -1).slice(-(maxVisibleItems - 2));
|
||||||
|
const hiddenItems = items.slice(1, -1).slice(0, -(maxVisibleItems - 2));
|
||||||
|
const showEllipsis = showEllipsisDropdown && hiddenItems.length > 0;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<li>{renderItem(firstItem, 'first')}</li>
|
||||||
|
|
||||||
|
{/* Ellipsis for hidden items with dropdown */}
|
||||||
|
{showEllipsis && <EllipsisDropdown hiddenItems={hiddenItems} />}
|
||||||
|
|
||||||
|
{/* Middle items */}
|
||||||
|
{visibleMiddleItems.map((item, index) => (
|
||||||
|
<li key={`middle-${index}`}>{renderItem(item, 'middle')}</li>
|
||||||
|
))}
|
||||||
|
|
||||||
|
<li>{renderItem(lastItem, 'last')}</li>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<nav
|
||||||
|
aria-label='Breadcrumb'
|
||||||
|
className={cn('breadcrumbs', sizeClasses[size], className)}
|
||||||
|
{...props}
|
||||||
|
>
|
||||||
|
<ul className='text-sm'>{renderBreadcrumbList()}</ul>
|
||||||
|
</nav>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default Breadcrumb;
|
||||||
@@ -2,11 +2,12 @@ import react from 'react';
|
|||||||
import Link from 'next/link';
|
import Link from 'next/link';
|
||||||
import { cn } from '@/lib/helper';
|
import { cn } from '@/lib/helper';
|
||||||
import { Color } from '@/types/theme';
|
import { Color } from '@/types/theme';
|
||||||
|
import { UrlObject } from 'url';
|
||||||
|
|
||||||
export interface ButtonProps extends react.ComponentProps<'button'> {
|
export interface ButtonProps extends react.ComponentProps<'button'> {
|
||||||
variant?: 'soft' | 'outline' | 'dash' | 'ghost' | 'link' | 'active';
|
variant?: 'soft' | 'outline' | 'dash' | 'ghost' | 'link' | 'active';
|
||||||
color?: Color;
|
color?: Color;
|
||||||
href?: string;
|
href?: string | UrlObject;
|
||||||
isLoading?: boolean;
|
isLoading?: boolean;
|
||||||
target?: string;
|
target?: string;
|
||||||
rel?: string;
|
rel?: string;
|
||||||
|
|||||||
+17
-3
@@ -22,6 +22,7 @@ export interface CardProps
|
|||||||
onCollapsedChange?: (collapsed: boolean) => void;
|
onCollapsedChange?: (collapsed: boolean) => void;
|
||||||
className?: {
|
className?: {
|
||||||
wrapper?: string;
|
wrapper?: string;
|
||||||
|
wrapperContent?: string;
|
||||||
image?: string;
|
image?: string;
|
||||||
body?: string;
|
body?: string;
|
||||||
title?: string;
|
title?: string;
|
||||||
@@ -122,6 +123,10 @@ const Card = ({
|
|||||||
return cn(baseClasses, 'p-6', className?.body);
|
return cn(baseClasses, 'p-6', className?.body);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const getCollapsibleClasses = () => {
|
||||||
|
return cn('', className?.collapsible);
|
||||||
|
};
|
||||||
|
|
||||||
const getTitleClasses = () => {
|
const getTitleClasses = () => {
|
||||||
const sizeClasses = {
|
const sizeClasses = {
|
||||||
sm: 'text-lg',
|
sm: 'text-lg',
|
||||||
@@ -144,11 +149,19 @@ const Card = ({
|
|||||||
return cn('border-t border-base-300 mt-4 pt-4', className?.footer);
|
return cn('border-t border-base-300 mt-4 pt-4', className?.footer);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const getWrapperContentClasses = () => {
|
||||||
|
return cn('space-y-4', className?.wrapperContent);
|
||||||
|
};
|
||||||
|
|
||||||
const renderCardContent = () => {
|
const renderCardContent = () => {
|
||||||
const hasContent = children || actions || footer;
|
const hasContent = children || actions || footer;
|
||||||
|
|
||||||
const titleContent = (
|
const titleContent = (
|
||||||
<div className='group flex items-center !justify-between w-full'>
|
<div
|
||||||
|
className={
|
||||||
|
`group flex items-center justify-between! w-full` + getTitleClasses()
|
||||||
|
}
|
||||||
|
>
|
||||||
<div className='flex-1'>
|
<div className='flex-1'>
|
||||||
{title && <h2 className={getTitleClasses()}>{title}</h2>}
|
{title && <h2 className={getTitleClasses()}>{title}</h2>}
|
||||||
{subtitle && <p className={getSubtitleClasses()}>{subtitle}</p>}
|
{subtitle && <p className={getSubtitleClasses()}>{subtitle}</p>}
|
||||||
@@ -156,7 +169,7 @@ const Card = ({
|
|||||||
{collapsible && (
|
{collapsible && (
|
||||||
<button
|
<button
|
||||||
onClick={() => handleCollapsedChange(!isCollapsed)}
|
onClick={() => handleCollapsedChange(!isCollapsed)}
|
||||||
className='btn btn-ghost btn-sm btn-circle'
|
className={`btn btn-ghost btn-sm btn-circle` + getTitleClasses()}
|
||||||
aria-label={isCollapsed ? 'Expand content' : 'Collapse content'}
|
aria-label={isCollapsed ? 'Expand content' : 'Collapse content'}
|
||||||
>
|
>
|
||||||
<Icon
|
<Icon
|
||||||
@@ -173,7 +186,7 @@ const Card = ({
|
|||||||
);
|
);
|
||||||
|
|
||||||
const cardContent = (
|
const cardContent = (
|
||||||
<div className='space-y-4'>
|
<div className={getWrapperContentClasses()}>
|
||||||
{children}
|
{children}
|
||||||
{actions && <div className={getActionsClasses()}>{actions}</div>}
|
{actions && <div className={getActionsClasses()}>{actions}</div>}
|
||||||
{footer && <div className={getFooterClasses()}>{footer}</div>}
|
{footer && <div className={getFooterClasses()}>{footer}</div>}
|
||||||
@@ -204,6 +217,7 @@ const Card = ({
|
|||||||
titleClassName='w-full cursor-pointer'
|
titleClassName='w-full cursor-pointer'
|
||||||
contentClassName='p-0'
|
contentClassName='p-0'
|
||||||
fullWidth={true}
|
fullWidth={true}
|
||||||
|
className={getCollapsibleClasses()}
|
||||||
>
|
>
|
||||||
{cardContent}
|
{cardContent}
|
||||||
</Collapse>
|
</Collapse>
|
||||||
|
|||||||
@@ -16,7 +16,6 @@ interface DrawerProps {
|
|||||||
onBackdropClick?: () => void;
|
onBackdropClick?: () => void;
|
||||||
closeOnBackdropClick?: boolean;
|
closeOnBackdropClick?: boolean;
|
||||||
expandedContent?: ReactNode;
|
expandedContent?: ReactNode;
|
||||||
expandedWidth?: string;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type DrawerClassName = {
|
type DrawerClassName = {
|
||||||
@@ -25,6 +24,7 @@ type DrawerClassName = {
|
|||||||
drawerSide?: string;
|
drawerSide?: string;
|
||||||
drawerOverlay?: string;
|
drawerOverlay?: string;
|
||||||
drawerSidebarContent?: string;
|
drawerSidebarContent?: string;
|
||||||
|
drawerExpandedContent?: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
const Drawer = ({
|
const Drawer = ({
|
||||||
@@ -39,7 +39,6 @@ const Drawer = ({
|
|||||||
onBackdropClick,
|
onBackdropClick,
|
||||||
closeOnBackdropClick = true,
|
closeOnBackdropClick = true,
|
||||||
expandedContent,
|
expandedContent,
|
||||||
expandedWidth = 'w-[400px]',
|
|
||||||
}: DrawerProps) => {
|
}: DrawerProps) => {
|
||||||
const getDrawerClassNames = (): DrawerClassName => {
|
const getDrawerClassNames = (): DrawerClassName => {
|
||||||
const baseClassNames = {
|
const baseClassNames = {
|
||||||
@@ -56,6 +55,9 @@ const Drawer = ({
|
|||||||
? 'w-full lg:min-w-[600px] lg:max-w-[600px]'
|
? 'w-full lg:min-w-[600px] lg:max-w-[600px]'
|
||||||
: 'w-full max-w-[300px] lg:w-[300px]';
|
: 'w-full max-w-[300px] lg:w-[300px]';
|
||||||
}
|
}
|
||||||
|
if (className?.drawerSidebarContent) {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
return 'w-full sm:min-w-120 sm:w-fit';
|
return 'w-full sm:min-w-120 sm:w-fit';
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -106,7 +108,9 @@ const Drawer = ({
|
|||||||
if (closeOnBackdropClick) {
|
if (closeOnBackdropClick) {
|
||||||
setOpen(false);
|
setOpen(false);
|
||||||
}
|
}
|
||||||
onBackdropClick && onBackdropClick();
|
if (onBackdropClick) {
|
||||||
|
onBackdropClick();
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -162,7 +166,7 @@ const Drawer = ({
|
|||||||
<div
|
<div
|
||||||
className={cn(
|
className={cn(
|
||||||
varianClassName?.drawerSidebarContent,
|
varianClassName?.drawerSidebarContent,
|
||||||
className?.drawerContent,
|
className?.drawerSidebarContent,
|
||||||
'overflow-y-auto'
|
'overflow-y-auto'
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
@@ -174,7 +178,7 @@ const Drawer = ({
|
|||||||
<div
|
<div
|
||||||
className={cn(
|
className={cn(
|
||||||
'border-l border-gray-200 bg-white flex flex-col h-full',
|
'border-l border-gray-200 bg-white flex flex-col h-full',
|
||||||
expandedWidth
|
className?.drawerExpandedContent
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
<div className='overflow-y-auto flex-1 h-full'>
|
<div className='overflow-y-auto flex-1 h-full'>
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
'use client';
|
'use client';
|
||||||
|
|
||||||
import { useCallback } from 'react';
|
|
||||||
import { usePathname } from 'next/navigation';
|
import { usePathname } from 'next/navigation';
|
||||||
|
|
||||||
import Image from 'next/image';
|
import Image from 'next/image';
|
||||||
@@ -13,7 +12,6 @@ import PermissionNotFound from '@/components/helper/PermissionNotFound';
|
|||||||
|
|
||||||
import { useUiStore } from '@/stores/ui/ui.store';
|
import { useUiStore } from '@/stores/ui/ui.store';
|
||||||
import { MAIN_DRAWER_LINKS } from '@/config/constant';
|
import { MAIN_DRAWER_LINKS } from '@/config/constant';
|
||||||
import { isPathActive } from '@/lib/helper';
|
|
||||||
import { ROUTE_PERMISSIONS } from '@/config/route-permission';
|
import { ROUTE_PERMISSIONS } from '@/config/route-permission';
|
||||||
import { useAuth } from '@/services/hooks/useAuth';
|
import { useAuth } from '@/services/hooks/useAuth';
|
||||||
|
|
||||||
@@ -26,29 +24,34 @@ const MainDrawerContent = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className='w-full p-4 flex flex-col gap-4'>
|
<div className='w-full flex flex-col'>
|
||||||
<div className='flex flex-row items-center gap-4'>
|
<div className='p-3 flex flex-row items-center gap-4 border-b border-base-content/10'>
|
||||||
<Image
|
<div className='flex flex-row items-center gap-2'>
|
||||||
src='/assets/img/lti-logo.png'
|
<Image
|
||||||
alt='MBU Logo'
|
src='/assets/img/lti-logo.png'
|
||||||
width={256}
|
alt='LTI Logo'
|
||||||
height={256}
|
width={40}
|
||||||
className='w-full max-w-16 h-auto'
|
height={40}
|
||||||
/>
|
className='w-full max-w-10 h-auto'
|
||||||
|
/>
|
||||||
|
|
||||||
<h1 className='text-xl font-bold'>LTI ERP</h1>
|
<div className='font-roboto'>
|
||||||
|
<h1 className='text-sm font-semibold'>LTI ERP</h1>
|
||||||
|
<p className='text-sm text-black/50'>Lumbung Telur Indonesia</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div className='grow flex flex-row justify-end sm:hidden'>
|
<div className='grow flex flex-row justify-end sm:hidden'>
|
||||||
<Button
|
<Button
|
||||||
variant='soft'
|
variant='soft'
|
||||||
color='error'
|
color='error'
|
||||||
onClick={closeMainDrawerHandler}
|
onClick={closeMainDrawerHandler}
|
||||||
className='rounded-full'
|
className='p-1 rounded-full'
|
||||||
>
|
>
|
||||||
<Icon
|
<Icon
|
||||||
icon='material-symbols:close-rounded'
|
icon='material-symbols:close-rounded'
|
||||||
width={24}
|
width={16}
|
||||||
height={24}
|
height={16}
|
||||||
/>
|
/>
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
@@ -69,61 +72,37 @@ const MainDrawer = ({
|
|||||||
|
|
||||||
const formattedPathname = pathname.endsWith('/') ? pathname : `${pathname}/`;
|
const formattedPathname = pathname.endsWith('/') ? pathname : `${pathname}/`;
|
||||||
|
|
||||||
|
const isPathnameNotFoundPage = formattedPathname === '/404/';
|
||||||
|
|
||||||
const isPermitted = ROUTE_PERMISSIONS[formattedPathname]?.some((permission) =>
|
const isPermitted = ROUTE_PERMISSIONS[formattedPathname]?.some((permission) =>
|
||||||
permissionCheck(permission)
|
permissionCheck(permission)
|
||||||
);
|
);
|
||||||
|
|
||||||
const getPageTitle = useCallback(() => {
|
|
||||||
let title = '';
|
|
||||||
|
|
||||||
const activeMenu = MAIN_DRAWER_LINKS.find((item) =>
|
|
||||||
isPathActive(pathname, item.link)
|
|
||||||
);
|
|
||||||
|
|
||||||
const traverseMenuTitle = (menu: typeof activeMenu) => {
|
|
||||||
if (!menu) return;
|
|
||||||
|
|
||||||
const hasSubmenu = menu?.submenu && menu?.submenu.length > 0;
|
|
||||||
|
|
||||||
if (!title) {
|
|
||||||
title += menu?.text;
|
|
||||||
} else {
|
|
||||||
title += ' - ' + menu?.text;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!hasSubmenu || !menu.submenu) return;
|
|
||||||
|
|
||||||
const activeSubmenu = menu.submenu?.find((item) =>
|
|
||||||
isPathActive(pathname, item.link)
|
|
||||||
);
|
|
||||||
|
|
||||||
traverseMenuTitle(activeSubmenu);
|
|
||||||
};
|
|
||||||
|
|
||||||
traverseMenuTitle(activeMenu);
|
|
||||||
|
|
||||||
return title;
|
|
||||||
}, [pathname]);
|
|
||||||
|
|
||||||
const pageTitle = getPageTitle();
|
|
||||||
|
|
||||||
const toggleSidebar = () => {
|
const toggleSidebar = () => {
|
||||||
setMainDrawerOpen(!mainDrawerOpen);
|
setMainDrawerOpen(!mainDrawerOpen);
|
||||||
};
|
};
|
||||||
|
|
||||||
if (!isPermitted) {
|
if (!isPermitted && !isPathnameNotFoundPage) {
|
||||||
return <PermissionNotFound />;
|
return <PermissionNotFound />;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (isPathnameNotFoundPage) {
|
||||||
|
return children;
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Drawer
|
<Drawer
|
||||||
open={mainDrawerOpen}
|
open={mainDrawerOpen}
|
||||||
setOpen={setMainDrawerOpen}
|
setOpen={setMainDrawerOpen}
|
||||||
openOnLarge
|
openOnLarge
|
||||||
sidebarContent={<MainDrawerContent />}
|
sidebarContent={<MainDrawerContent />}
|
||||||
|
className={{
|
||||||
|
drawerSide: 'border-r border-base-content/10',
|
||||||
|
drawerSidebarContent: 'min-w-[244px] lg:w-[244px]',
|
||||||
|
}}
|
||||||
>
|
>
|
||||||
<main className='w-full h-full flex flex-col'>
|
<main className='w-full h-full flex flex-col'>
|
||||||
<Navbar title={pageTitle as string} toggleSidebar={toggleSidebar} />
|
<Navbar toggleSidebar={toggleSidebar} />
|
||||||
|
|
||||||
{children}
|
{children}
|
||||||
</main>
|
</main>
|
||||||
|
|||||||
@@ -31,7 +31,11 @@ export const useModal = (isNestingModal = false) => {
|
|||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
const toggle = useCallback(() => {
|
const toggle = useCallback(() => {
|
||||||
open ? closeModal() : openModal();
|
if (open) {
|
||||||
|
closeModal();
|
||||||
|
} else {
|
||||||
|
openModal();
|
||||||
|
}
|
||||||
}, [open, closeModal, openModal]);
|
}, [open, closeModal, openModal]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@@ -53,15 +57,25 @@ interface ModalProps {
|
|||||||
ref: RefObject<HTMLDialogElement | null>;
|
ref: RefObject<HTMLDialogElement | null>;
|
||||||
children?: ReactNode;
|
children?: ReactNode;
|
||||||
closeOnBackdrop?: boolean;
|
closeOnBackdrop?: boolean;
|
||||||
|
onBackdropClick?: () => void;
|
||||||
|
position?: 'top' | 'middle' | 'bottom' | 'start' | 'end';
|
||||||
className?: {
|
className?: {
|
||||||
modal?: string;
|
modal?: string;
|
||||||
modalBox?: string;
|
modalBox?: string;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
const Modal = ({ ref, children, closeOnBackdrop, className }: ModalProps) => {
|
const Modal = ({
|
||||||
|
ref,
|
||||||
|
children,
|
||||||
|
closeOnBackdrop,
|
||||||
|
onBackdropClick,
|
||||||
|
position = 'middle',
|
||||||
|
className,
|
||||||
|
}: ModalProps) => {
|
||||||
const handleBackdropClick = (e: React.MouseEvent<HTMLDialogElement>) => {
|
const handleBackdropClick = (e: React.MouseEvent<HTMLDialogElement>) => {
|
||||||
if (closeOnBackdrop && e.target === ref.current) {
|
if (closeOnBackdrop && e.target === ref.current) {
|
||||||
|
onBackdropClick?.();
|
||||||
ref.current?.close();
|
ref.current?.close();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -69,7 +83,17 @@ const Modal = ({ ref, children, closeOnBackdrop, className }: ModalProps) => {
|
|||||||
return (
|
return (
|
||||||
<dialog
|
<dialog
|
||||||
ref={ref}
|
ref={ref}
|
||||||
className={cn('modal', className?.modal)}
|
className={cn(
|
||||||
|
'modal',
|
||||||
|
{
|
||||||
|
'modal-top': position === 'top',
|
||||||
|
'modal-middle': position === 'middle',
|
||||||
|
'modal-bottom': position === 'bottom',
|
||||||
|
'modal-start': position === 'start',
|
||||||
|
'modal-end': position === 'end',
|
||||||
|
},
|
||||||
|
className?.modal
|
||||||
|
)}
|
||||||
onClick={handleBackdropClick}
|
onClick={handleBackdropClick}
|
||||||
>
|
>
|
||||||
<div className={cn('modal-box', className?.modalBox)}>{children}</div>
|
<div className={cn('modal-box', className?.modalBox)}>{children}</div>
|
||||||
|
|||||||
+51
-33
@@ -1,76 +1,94 @@
|
|||||||
'use client';
|
'use client';
|
||||||
|
|
||||||
import toast from 'react-hot-toast';
|
import toast from 'react-hot-toast';
|
||||||
import { useRouter } from 'next/navigation';
|
import { usePathname, useRouter } from 'next/navigation';
|
||||||
|
|
||||||
import { Icon } from '@iconify/react';
|
import { Icon } from '@iconify/react';
|
||||||
import Menu from '@/components/menu/Menu';
|
|
||||||
import MenuItem from '@/components/menu/MenuItem';
|
|
||||||
import Button from '@/components/Button';
|
import Button from '@/components/Button';
|
||||||
import Dropdown from '@/components/Dropdown';
|
import Breadcrumb, { buildBreadcrumbs } from '@/components/Breadcrumb';
|
||||||
|
import PopoverButton from '@/components/popover/PopoverButton';
|
||||||
|
import PopoverContent from '@/components/popover/PopoverContent';
|
||||||
|
|
||||||
import { useAuth } from '@/services/hooks/useAuth';
|
import { useAuth } from '@/services/hooks/useAuth';
|
||||||
import { AuthApi } from '@/services/api/auth';
|
import { AuthApi } from '@/services/api/auth';
|
||||||
import { isResponseError } from '@/lib/api-helper';
|
import { isResponseError } from '@/lib/api-helper';
|
||||||
|
import { useUiStore } from '@/stores/ui/ui.store';
|
||||||
|
|
||||||
interface NavbarProps {
|
interface NavbarProps {
|
||||||
title: string;
|
|
||||||
toggleSidebar?: () => void;
|
toggleSidebar?: () => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
const Navbar = ({ title, toggleSidebar }: NavbarProps) => {
|
const Navbar = ({ toggleSidebar }: NavbarProps) => {
|
||||||
const { setUser } = useAuth();
|
const { setUser } = useAuth();
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
|
const pathname = usePathname();
|
||||||
|
const navbarActions = useUiStore((state) => state.navbarActions);
|
||||||
|
|
||||||
const logoutClickHandler = async () => {
|
const logoutClickHandler = async () => {
|
||||||
const logoutRes = await AuthApi.logout();
|
const logoutRes = await AuthApi.logout();
|
||||||
|
|
||||||
if (isResponseError(logoutRes)) {
|
if (isResponseError(logoutRes)) {
|
||||||
toast.error('Gagal logout! Coba lagi!');
|
toast.error('Gagal logout! Coba lagi!');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
setUser(undefined);
|
setUser(undefined);
|
||||||
|
const redirect = (logoutRes as { redirect?: string })?.redirect;
|
||||||
|
if (redirect) {
|
||||||
|
window.location.href = redirect;
|
||||||
|
return;
|
||||||
|
}
|
||||||
router.replace(process.env.NEXT_PUBLIC_SSO_LOGIN_URL as string);
|
router.replace(process.env.NEXT_PUBLIC_SSO_LOGIN_URL as string);
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className='navbar px-4 bg-base-100 shadow-sm'>
|
<div className='navbar p-3 bg-base-100 border-b border-base-content/10'>
|
||||||
<div className='flex-1'>
|
<div className='flex-1'>
|
||||||
<div className='flex flex-row items-center gap-4'>
|
<div className='flex flex-row items-center gap-4'>
|
||||||
{toggleSidebar && (
|
{toggleSidebar && (
|
||||||
<Button onClick={toggleSidebar} className='block lg:hidden'>
|
<Button
|
||||||
<Icon
|
variant='ghost'
|
||||||
icon='material-symbols:menu-rounded'
|
color='none'
|
||||||
width={24}
|
onClick={toggleSidebar}
|
||||||
height={24}
|
className='block lg:hidden p-[9px] text-base-content/50 border border-base-content/10 rounded-xl shadow-button-soft'
|
||||||
/>
|
>
|
||||||
|
<Icon icon='heroicons:bars-3' width={20} height={20} />
|
||||||
</Button>
|
</Button>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
<span className='font-bold text-xl text-primary'>{title}</span>
|
<Breadcrumb items={buildBreadcrumbs(pathname)} />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className='flex gap-2'>
|
<div className='flex gap-2 items-center'>
|
||||||
<Dropdown
|
{/* Page-specific actions */}
|
||||||
align='end'
|
{navbarActions && <div className='mr-2'>{navbarActions}</div>}
|
||||||
direction='bottom'
|
<PopoverButton
|
||||||
trigger={
|
tabIndex={0}
|
||||||
<div className='btn btn-ghost btn-circle avatar'>
|
variant='ghost'
|
||||||
<div className='w-10 rounded-full border flex justify-center items-center'>
|
color='none'
|
||||||
<Icon icon='uil:user' width={40} height={40} />
|
popoverTarget='accountNavbar'
|
||||||
</div>
|
anchorName='--account-navbar'
|
||||||
</div>
|
className='p-[9px] text-base-content/50 border border-base-content/10 rounded-xl shadow-button-soft'
|
||||||
}
|
|
||||||
className={{
|
|
||||||
content: 'w-52 mt-3',
|
|
||||||
}}
|
|
||||||
>
|
>
|
||||||
<Menu>
|
<Icon icon='heroicons:user' width={20} height={20} />
|
||||||
<MenuItem title='Logout' onClick={logoutClickHandler} />
|
</PopoverButton>
|
||||||
</Menu>
|
|
||||||
</Dropdown>
|
<PopoverContent
|
||||||
|
id='accountNavbar'
|
||||||
|
anchorName='--account-navbar'
|
||||||
|
position='bottom-start'
|
||||||
|
className='rounded-xl border border-base-content/5 shadow-sm'
|
||||||
|
>
|
||||||
|
<Button
|
||||||
|
onClick={logoutClickHandler}
|
||||||
|
variant='ghost'
|
||||||
|
color='error'
|
||||||
|
className='p-3 justify-start text-sm font-semibold w-full'
|
||||||
|
>
|
||||||
|
<Icon icon='heroicons-outline:logout' width={20} height={20} />
|
||||||
|
Logout
|
||||||
|
</Button>
|
||||||
|
</PopoverContent>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|||||||
+195
-54
@@ -1,11 +1,12 @@
|
|||||||
'use client';
|
'use client';
|
||||||
|
|
||||||
import { ReactNode, useCallback, useEffect, useState } from 'react';
|
import { Fragment, ReactNode, useCallback, useEffect, useState } from 'react';
|
||||||
import {
|
import {
|
||||||
flexRender,
|
flexRender,
|
||||||
getCoreRowModel,
|
getCoreRowModel,
|
||||||
getFilteredRowModel,
|
getFilteredRowModel,
|
||||||
getPaginationRowModel,
|
getPaginationRowModel,
|
||||||
|
getExpandedRowModel,
|
||||||
getSortedRowModel,
|
getSortedRowModel,
|
||||||
TableOptions,
|
TableOptions,
|
||||||
useReactTable,
|
useReactTable,
|
||||||
@@ -15,6 +16,7 @@ import {
|
|||||||
OnChangeFn,
|
OnChangeFn,
|
||||||
Row,
|
Row,
|
||||||
HeaderContext,
|
HeaderContext,
|
||||||
|
ExpandedState,
|
||||||
} from '@tanstack/react-table';
|
} from '@tanstack/react-table';
|
||||||
import { rankItem } from '@tanstack/match-sorter-utils';
|
import { rankItem } from '@tanstack/match-sorter-utils';
|
||||||
import { Icon } from '@iconify/react';
|
import { Icon } from '@iconify/react';
|
||||||
@@ -31,11 +33,16 @@ interface TableClassNames {
|
|||||||
headerColumnClassName?: string;
|
headerColumnClassName?: string;
|
||||||
tableBodyClassName?: string;
|
tableBodyClassName?: string;
|
||||||
bodyRowClassName?: string;
|
bodyRowClassName?: string;
|
||||||
|
selectedBodyRowClassName?: string;
|
||||||
bodyColumnClassName?: string;
|
bodyColumnClassName?: string;
|
||||||
|
bodySubRowClassName?: (depth: number) => string;
|
||||||
|
selectedBodySubRowClassName?: (depth: number) => string;
|
||||||
|
bodySubRowColumnClassName?: (depth: number) => string;
|
||||||
tableFooterClassName?: string;
|
tableFooterClassName?: string;
|
||||||
footerRowClassName?: string;
|
footerRowClassName?: string;
|
||||||
footerColumnClassName?: string;
|
footerColumnClassName?: string;
|
||||||
paginationClassName?: string;
|
paginationClassName?: string;
|
||||||
|
skeletonCellClassName?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface TableProps<TData extends object> {
|
export interface TableProps<TData extends object> {
|
||||||
@@ -59,6 +66,7 @@ export interface TableProps<TData extends object> {
|
|||||||
enableRowSelection?: boolean | ((row: Row<TData>) => boolean);
|
enableRowSelection?: boolean | ((row: Row<TData>) => boolean);
|
||||||
renderFooter?: boolean;
|
renderFooter?: boolean;
|
||||||
withCheckbox?: boolean;
|
withCheckbox?: boolean;
|
||||||
|
withPagination?: boolean;
|
||||||
rowOptions?: number[];
|
rowOptions?: number[];
|
||||||
/**
|
/**
|
||||||
* Custom row renderer. Should return a complete <tr> element or null.
|
* Custom row renderer. Should return a complete <tr> element or null.
|
||||||
@@ -66,13 +74,19 @@ export interface TableProps<TData extends object> {
|
|||||||
* Return null to render the default row.
|
* Return null to render the default row.
|
||||||
*/
|
*/
|
||||||
renderCustomRow?: (row: Row<TData>) => ReactNode | null;
|
renderCustomRow?: (row: Row<TData>) => ReactNode | null;
|
||||||
|
getRowCanExpand?: (row: Row<TData>) => boolean;
|
||||||
|
renderSubComponent?: (props: { row: Row<TData> }) => React.ReactElement;
|
||||||
|
expanded?: ExpandedState;
|
||||||
|
getSubRows?: (originalRow: TData, index: number) => TData[] | undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
const DUMMY_SKELETON_DATA = [{}, {}, {}, {}, {}];
|
const DUMMY_SKELETON_DATA = Array.from({ length: 10 }, (_, index) => ({
|
||||||
|
id: index,
|
||||||
|
}));
|
||||||
|
|
||||||
const emptyContentDefaultValue = (
|
const emptyContentDefaultValue = (
|
||||||
<div className='w-full p-5 text-center'>
|
<div className='w-full text-center py-4'>
|
||||||
<span className='text-lg opacity-50'>
|
<span className='text-sm opacity-50'>
|
||||||
Tidak ada data yang dapat ditampilkan...
|
Tidak ada data yang dapat ditampilkan...
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
@@ -86,11 +100,18 @@ export const TABLE_DEFAULT_STYLING = {
|
|||||||
tableHeaderClassName: '',
|
tableHeaderClassName: '',
|
||||||
headerRowClassName: '',
|
headerRowClassName: '',
|
||||||
headerColumnClassName:
|
headerColumnClassName:
|
||||||
'px-4 py-3 border-base-content/10 text-base-content/50',
|
'px-4 py-3 border-base-content/10 text-base-content/50 text-sm font-medium',
|
||||||
tableBodyClassName: '',
|
tableBodyClassName: '',
|
||||||
bodyRowClassName: 'border-t border-base-content/10',
|
bodyRowClassName:
|
||||||
bodyColumnClassName: 'px-4 py-3 text-base-content',
|
'transition-all duration-200 border-t border-base-content/10 bg-transparent',
|
||||||
paginationClassName: '',
|
selectedBodyRowClassName: 'bg-primary/5',
|
||||||
|
bodyColumnClassName: 'px-4 py-3 text-base-content font-medium',
|
||||||
|
bodySubRowClassName: (depth: number) =>
|
||||||
|
'transition-all duration-200 border-t border-base-content/10 bg-transparent',
|
||||||
|
selectedBodySubRowClassName: (depth: number) => 'bg-primary/5',
|
||||||
|
bodySubRowColumnClassName: (depth: number) =>
|
||||||
|
'px-4 py-3 text-base-content font-medium',
|
||||||
|
paginationClassName: 'px-3',
|
||||||
tableFooterClassName: 'font-semibold border-base-content/10',
|
tableFooterClassName: 'font-semibold border-base-content/10',
|
||||||
footerRowClassName: 'bg-base-200 border-t-2 border-base-content/10',
|
footerRowClassName: 'bg-base-200 border-t-2 border-base-content/10',
|
||||||
footerColumnClassName: 'p-4 text-base-content whitespace-nowrap',
|
footerColumnClassName: 'p-4 text-base-content whitespace-nowrap',
|
||||||
@@ -117,8 +138,13 @@ const Table = <TData extends object>({
|
|||||||
enableRowSelection,
|
enableRowSelection,
|
||||||
renderFooter = false,
|
renderFooter = false,
|
||||||
withCheckbox = false,
|
withCheckbox = false,
|
||||||
|
withPagination = true,
|
||||||
rowOptions = [10, 20, 50, 100],
|
rowOptions = [10, 20, 50, 100],
|
||||||
renderCustomRow,
|
renderCustomRow,
|
||||||
|
getRowCanExpand,
|
||||||
|
renderSubComponent,
|
||||||
|
expanded = {},
|
||||||
|
getSubRows,
|
||||||
}: TableProps<TData>) => {
|
}: TableProps<TData>) => {
|
||||||
const isServerSideTable =
|
const isServerSideTable =
|
||||||
totalItems !== undefined &&
|
totalItems !== undefined &&
|
||||||
@@ -151,10 +177,14 @@ const Table = <TData extends object>({
|
|||||||
getSortedRowModel: getSortedRowModel(),
|
getSortedRowModel: getSortedRowModel(),
|
||||||
getPaginationRowModel: getPaginationRowModel(),
|
getPaginationRowModel: getPaginationRowModel(),
|
||||||
onPaginationChange: setPagination,
|
onPaginationChange: setPagination,
|
||||||
|
getExpandedRowModel: getExpandedRowModel(),
|
||||||
|
getRowCanExpand: getRowCanExpand ?? (getSubRows ? undefined : () => false),
|
||||||
|
getSubRows,
|
||||||
manualSorting,
|
manualSorting,
|
||||||
state: {
|
state: {
|
||||||
pagination,
|
pagination,
|
||||||
globalFilter: fuzzySearchValue,
|
globalFilter: fuzzySearchValue,
|
||||||
|
expanded,
|
||||||
},
|
},
|
||||||
filterFns: {
|
filterFns: {
|
||||||
fuzzy: fuzzyFilter,
|
fuzzy: fuzzyFilter,
|
||||||
@@ -222,14 +252,40 @@ const Table = <TData extends object>({
|
|||||||
}, [pageSize, setPageSize]);
|
}, [pageSize, setPageSize]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={tableClassNames.containerClassName}>
|
<div
|
||||||
<div className={tableClassNames.tableWrapperClassName}>
|
className={cn(
|
||||||
<table className={tableClassNames.tableClassName}>
|
TABLE_DEFAULT_STYLING.containerClassName,
|
||||||
<thead className={tableClassNames.tableHeaderClassName}>
|
tableClassNames.containerClassName,
|
||||||
|
{
|
||||||
|
'mb-0': !withPagination,
|
||||||
|
}
|
||||||
|
)}
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
className={cn(
|
||||||
|
TABLE_DEFAULT_STYLING.tableWrapperClassName,
|
||||||
|
tableClassNames.tableWrapperClassName
|
||||||
|
)}
|
||||||
|
>
|
||||||
|
<table
|
||||||
|
className={cn(
|
||||||
|
TABLE_DEFAULT_STYLING.tableClassName,
|
||||||
|
tableClassNames.tableClassName
|
||||||
|
)}
|
||||||
|
>
|
||||||
|
<thead
|
||||||
|
className={cn(
|
||||||
|
TABLE_DEFAULT_STYLING.tableHeaderClassName,
|
||||||
|
tableClassNames.tableHeaderClassName
|
||||||
|
)}
|
||||||
|
>
|
||||||
{table.getHeaderGroups().map((headerGroup) => (
|
{table.getHeaderGroups().map((headerGroup) => (
|
||||||
<tr
|
<tr
|
||||||
key={headerGroup.id}
|
key={headerGroup.id}
|
||||||
className={tableClassNames.headerRowClassName}
|
className={cn(
|
||||||
|
TABLE_DEFAULT_STYLING.headerRowClassName,
|
||||||
|
tableClassNames.headerRowClassName
|
||||||
|
)}
|
||||||
>
|
>
|
||||||
{headerGroup.headers.map((header) => {
|
{headerGroup.headers.map((header) => {
|
||||||
const columnRelativeDepth =
|
const columnRelativeDepth =
|
||||||
@@ -262,6 +318,7 @@ const Table = <TData extends object>({
|
|||||||
{
|
{
|
||||||
'border-b': header.colSpan > 1,
|
'border-b': header.colSpan > 1,
|
||||||
},
|
},
|
||||||
|
TABLE_DEFAULT_STYLING.headerColumnClassName,
|
||||||
tableClassNames.headerColumnClassName
|
tableClassNames.headerColumnClassName
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
@@ -311,7 +368,12 @@ const Table = <TData extends object>({
|
|||||||
))}
|
))}
|
||||||
</thead>
|
</thead>
|
||||||
|
|
||||||
<tbody className={tableClassNames.tableBodyClassName}>
|
<tbody
|
||||||
|
className={cn(
|
||||||
|
TABLE_DEFAULT_STYLING.tableBodyClassName,
|
||||||
|
tableClassNames.tableBodyClassName
|
||||||
|
)}
|
||||||
|
>
|
||||||
{table.getRowModel().rows.map((row) => {
|
{table.getRowModel().rows.map((row) => {
|
||||||
const customRowContent = renderCustomRow?.(row);
|
const customRowContent = renderCustomRow?.(row);
|
||||||
|
|
||||||
@@ -320,36 +382,110 @@ const Table = <TData extends object>({
|
|||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<tr key={row.id} className={tableClassNames.bodyRowClassName}>
|
<Fragment key={row.id}>
|
||||||
{row.getVisibleCells().map((cell) => (
|
<tr
|
||||||
<td
|
data-depth={row.depth}
|
||||||
key={cell.id}
|
className={cn(
|
||||||
className={cn(
|
row.depth > 0
|
||||||
{ 'first:w-9 first:pr-0': withCheckbox },
|
? tableClassNames.bodySubRowClassName(row.depth)
|
||||||
tableClassNames.bodyColumnClassName
|
: tableClassNames.bodyRowClassName,
|
||||||
)}
|
{
|
||||||
>
|
[tableClassNames.selectedBodyRowClassName!]:
|
||||||
{!isLoading &&
|
row.getIsSelected() && row.depth === 0,
|
||||||
flexRender(
|
[tableClassNames.selectedBodySubRowClassName(
|
||||||
cell.column.columnDef.cell,
|
row.depth
|
||||||
cell.getContext()
|
)!]: row.getIsSelected() && row.depth > 0,
|
||||||
|
}
|
||||||
|
)}
|
||||||
|
>
|
||||||
|
{row.getVisibleCells().map((cell) => (
|
||||||
|
<td
|
||||||
|
key={cell.id}
|
||||||
|
className={cn(
|
||||||
|
{ 'first:w-9 first:pr-0': withCheckbox },
|
||||||
|
TABLE_DEFAULT_STYLING.bodyColumnClassName,
|
||||||
|
row.depth > 0
|
||||||
|
? tableClassNames.bodySubRowColumnClassName(
|
||||||
|
row.depth
|
||||||
|
)
|
||||||
|
: tableClassNames.bodyColumnClassName
|
||||||
)}
|
)}
|
||||||
|
>
|
||||||
|
{!isLoading &&
|
||||||
|
flexRender(
|
||||||
|
cell.column.columnDef.cell,
|
||||||
|
cell.getContext()
|
||||||
|
)}
|
||||||
|
|
||||||
{isLoading && <div className='skeleton w-full h-4' />}
|
{isLoading && (
|
||||||
</td>
|
<div
|
||||||
))}
|
className={cn(
|
||||||
</tr>
|
'skeleton w-full h-4',
|
||||||
|
tableClassNames.skeletonCellClassName
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
</td>
|
||||||
|
))}
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
{row.getIsExpanded() && (
|
||||||
|
<>
|
||||||
|
{renderSubComponent && (
|
||||||
|
<tr
|
||||||
|
className={cn(
|
||||||
|
TABLE_DEFAULT_STYLING.bodySubRowClassName(1),
|
||||||
|
tableClassNames.bodySubRowClassName(1),
|
||||||
|
{
|
||||||
|
[tableClassNames.selectedBodySubRowClassName(1)]:
|
||||||
|
row.getIsSelected(),
|
||||||
|
}
|
||||||
|
)}
|
||||||
|
>
|
||||||
|
<td colSpan={row.getVisibleCells().length}>
|
||||||
|
{renderSubComponent({ row })}
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
)}
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
</Fragment>
|
||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
|
|
||||||
|
{(data.length === 0 || table.getRowModel().rows.length === 0) &&
|
||||||
|
!isLoading && (
|
||||||
|
<tr>
|
||||||
|
<td
|
||||||
|
colSpan={
|
||||||
|
table.getAllLeafColumns().length + (withCheckbox ? 1 : 0)
|
||||||
|
}
|
||||||
|
className='p-0'
|
||||||
|
>
|
||||||
|
{emptyContent}
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
)}
|
||||||
</tbody>
|
</tbody>
|
||||||
<tfoot className={cn(tableClassNames.tableFooterClassName)}>
|
<tfoot
|
||||||
|
className={cn(
|
||||||
|
TABLE_DEFAULT_STYLING.tableFooterClassName,
|
||||||
|
tableClassNames.tableFooterClassName
|
||||||
|
)}
|
||||||
|
>
|
||||||
{renderFooter && (
|
{renderFooter && (
|
||||||
<tr className={cn(tableClassNames.footerRowClassName)}>
|
<tr
|
||||||
|
className={cn(
|
||||||
|
TABLE_DEFAULT_STYLING.footerRowClassName,
|
||||||
|
tableClassNames.footerRowClassName
|
||||||
|
)}
|
||||||
|
>
|
||||||
{table.getAllLeafColumns().map((column) => (
|
{table.getAllLeafColumns().map((column) => (
|
||||||
<td
|
<td
|
||||||
key={column.id}
|
key={column.id}
|
||||||
className={cn(
|
className={cn(
|
||||||
{ 'first:w-9 first:pr-0': withCheckbox },
|
{ 'first:w-9 first:pr-0': withCheckbox },
|
||||||
|
TABLE_DEFAULT_STYLING.footerColumnClassName,
|
||||||
tableClassNames.footerColumnClassName
|
tableClassNames.footerColumnClassName
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
@@ -367,28 +503,33 @@ const Table = <TData extends object>({
|
|||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{(data.length === 0 || table.getRowModel().rows.length === 0) &&
|
{data.length > 0 &&
|
||||||
|
table.getRowModel().rows.length > 0 &&
|
||||||
!isLoading &&
|
!isLoading &&
|
||||||
emptyContent}
|
withPagination && (
|
||||||
|
<div
|
||||||
{data.length > 0 && table.getRowModel().rows.length > 0 && !isLoading && (
|
className={cn(
|
||||||
<div className={cn('mt-5', tableClassNames.paginationClassName)}>
|
'mt-5',
|
||||||
<Pagination
|
TABLE_DEFAULT_STYLING.paginationClassName,
|
||||||
totalItems={isServerSideTable ? totalItems : table.getRowCount()}
|
tableClassNames.paginationClassName
|
||||||
itemsPerPage={table.getState().pagination.pageSize}
|
)}
|
||||||
currentPage={
|
>
|
||||||
isServerSideTable
|
<Pagination
|
||||||
? page
|
totalItems={isServerSideTable ? totalItems : table.getRowCount()}
|
||||||
: table.getState().pagination.pageIndex + 1
|
itemsPerPage={table.getState().pagination.pageSize}
|
||||||
}
|
currentPage={
|
||||||
onPrevPage={prevPageClickHandler}
|
isServerSideTable
|
||||||
onNextPage={nextPageClickHandler}
|
? page
|
||||||
onPageChange={pageChangeHandler}
|
: table.getState().pagination.pageIndex + 1
|
||||||
rowOptions={rowOptions}
|
}
|
||||||
onRowChange={onPageSizeChange}
|
onPrevPage={prevPageClickHandler}
|
||||||
/>
|
onNextPage={nextPageClickHandler}
|
||||||
</div>
|
onPageChange={pageChangeHandler}
|
||||||
)}
|
rowOptions={rowOptions}
|
||||||
|
onRowChange={onPageSizeChange}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
+24
-13
@@ -1,4 +1,4 @@
|
|||||||
import { HTMLAttributes, ReactNode, useEffect, useState } from 'react';
|
import { HTMLAttributes, ReactNode, useState } from 'react';
|
||||||
import { cn } from '@/lib/helper';
|
import { cn } from '@/lib/helper';
|
||||||
|
|
||||||
export interface TabItem {
|
export interface TabItem {
|
||||||
@@ -25,8 +25,10 @@ export interface TabsProps
|
|||||||
wrapper?: string;
|
wrapper?: string;
|
||||||
tab?: string;
|
tab?: string;
|
||||||
content?: string;
|
content?: string;
|
||||||
|
tabHeaderWrapper?: string;
|
||||||
};
|
};
|
||||||
onTabChange?: (tabId: string) => void;
|
onTabChange?: (tabId: string) => void;
|
||||||
|
sideContent?: ReactNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
const Tabs = ({
|
const Tabs = ({
|
||||||
@@ -38,6 +40,7 @@ const Tabs = ({
|
|||||||
activeTabId: controlledActiveId,
|
activeTabId: controlledActiveId,
|
||||||
className,
|
className,
|
||||||
onTabChange,
|
onTabChange,
|
||||||
|
sideContent,
|
||||||
...props
|
...props
|
||||||
}: TabsProps) => {
|
}: TabsProps) => {
|
||||||
// State internal hanya dipakai kalau `activeTabId` (controlled) tidak diset
|
// State internal hanya dipakai kalau `activeTabId` (controlled) tidak diset
|
||||||
@@ -59,6 +62,7 @@ const Tabs = ({
|
|||||||
wrapper: wrapperClassName,
|
wrapper: wrapperClassName,
|
||||||
tab: tabClassName,
|
tab: tabClassName,
|
||||||
content: contentClassName,
|
content: contentClassName,
|
||||||
|
tabHeaderWrapper: tabHeaderWrapperClassName,
|
||||||
} = typeof className === 'object'
|
} = typeof className === 'object'
|
||||||
? className
|
? className
|
||||||
: { wrapper: className, tab: undefined };
|
: { wrapper: className, tab: undefined };
|
||||||
@@ -102,6 +106,10 @@ const Tabs = ({
|
|||||||
tabClassName
|
tabClassName
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const getSideContentClasses = () => {
|
||||||
|
return cn('flex flex-row', tabHeaderWrapperClassName);
|
||||||
|
};
|
||||||
|
|
||||||
const activeContent = tabs.find((tab) => tab.id === activeTabId)?.content;
|
const activeContent = tabs.find((tab) => tab.id === activeTabId)?.content;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -112,18 +120,21 @@ const Tabs = ({
|
|||||||
typeof className === 'string' ? className : containerClassName
|
typeof className === 'string' ? className : containerClassName
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
<div role='tablist' className={getTabsClasses()}>
|
<div className={getSideContentClasses()}>
|
||||||
{tabs.map(({ id, label, disabled }) => (
|
<div role='tablist' className={getTabsClasses()}>
|
||||||
<button
|
{tabs.map(({ id, label, disabled }) => (
|
||||||
key={id}
|
<button
|
||||||
role='tab'
|
key={id}
|
||||||
className={getTabClasses(id === activeTabId, disabled)}
|
role='tab'
|
||||||
onClick={() => !disabled && handleTabChange(id)}
|
className={getTabClasses(id === activeTabId, disabled)}
|
||||||
disabled={disabled}
|
onClick={() => !disabled && handleTabChange(id)}
|
||||||
>
|
disabled={disabled}
|
||||||
{label}
|
>
|
||||||
</button>
|
{label}
|
||||||
))}
|
</button>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
{sideContent && sideContent}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{activeContent && (
|
{activeContent && (
|
||||||
|
|||||||
@@ -0,0 +1,205 @@
|
|||||||
|
'use client';
|
||||||
|
|
||||||
|
import { useEffect, useMemo, useState } from 'react';
|
||||||
|
|
||||||
|
import { Icon } from '@iconify/react';
|
||||||
|
import { BaseApproval } from '@/types/api/api-general';
|
||||||
|
import Button from '@/components/Button';
|
||||||
|
|
||||||
|
import { cn, formatDate } from '@/lib/helper';
|
||||||
|
|
||||||
|
interface ApprovalStepsV2Props {
|
||||||
|
title?: string;
|
||||||
|
approvals?: BaseApproval[];
|
||||||
|
steps: {
|
||||||
|
step_number: number;
|
||||||
|
step_name: string;
|
||||||
|
}[];
|
||||||
|
maxVisibleSteps?: number;
|
||||||
|
className?: {
|
||||||
|
wrapper?: string;
|
||||||
|
stepsWrapper?: string;
|
||||||
|
stepsContainer?: string;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
const ApprovalStepsV2 = ({
|
||||||
|
title = 'Progress Details',
|
||||||
|
approvals,
|
||||||
|
steps,
|
||||||
|
maxVisibleSteps = 2,
|
||||||
|
className,
|
||||||
|
}: ApprovalStepsV2Props) => {
|
||||||
|
const [isSeeAll, setIsSeeAll] = useState(false);
|
||||||
|
const [formattedApprovals, setFormattedApprovals] = useState<
|
||||||
|
(BaseApproval & { isActive: boolean })[]
|
||||||
|
>([]);
|
||||||
|
|
||||||
|
const latestApprovalStepNumber =
|
||||||
|
approvals?.[approvals.length - 1].step_number ?? 0;
|
||||||
|
|
||||||
|
const lastStepNumber = steps[steps.length - 1].step_number;
|
||||||
|
|
||||||
|
const isLatestApprovalStepNumberLessThanLastStepNumber =
|
||||||
|
latestApprovalStepNumber < lastStepNumber;
|
||||||
|
|
||||||
|
const slicedFormattedApprovals = useMemo(() => {
|
||||||
|
return formattedApprovals.slice(0, isSeeAll ? undefined : maxVisibleSteps);
|
||||||
|
}, [formattedApprovals, isSeeAll]);
|
||||||
|
|
||||||
|
const seeMoreClickHandler = () => {
|
||||||
|
setIsSeeAll((prevVal) => !prevVal);
|
||||||
|
};
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (approvals) {
|
||||||
|
const tempFormattedApprovals: (BaseApproval & { isActive: boolean })[] =
|
||||||
|
[];
|
||||||
|
|
||||||
|
approvals.forEach((approval) => {
|
||||||
|
tempFormattedApprovals.push({
|
||||||
|
...approval,
|
||||||
|
isActive: true,
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
if (isLatestApprovalStepNumberLessThanLastStepNumber) {
|
||||||
|
const latestApprovalStepNumberIndexInSteps = steps.findIndex(
|
||||||
|
(step) => step.step_number === latestApprovalStepNumber
|
||||||
|
);
|
||||||
|
|
||||||
|
const slicedSteps = steps.slice(
|
||||||
|
latestApprovalStepNumberIndexInSteps + 1
|
||||||
|
);
|
||||||
|
|
||||||
|
slicedSteps.forEach((step) => {
|
||||||
|
tempFormattedApprovals.push({
|
||||||
|
action: 'APPROVED',
|
||||||
|
action_at: new Date().toISOString(),
|
||||||
|
action_by: {
|
||||||
|
id: 0,
|
||||||
|
id_user: 0,
|
||||||
|
email: '',
|
||||||
|
name: '',
|
||||||
|
},
|
||||||
|
step_name: step.step_name,
|
||||||
|
step_number: step.step_number,
|
||||||
|
isActive: false,
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
setFormattedApprovals(tempFormattedApprovals);
|
||||||
|
}
|
||||||
|
}, [approvals]);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div
|
||||||
|
className={cn(
|
||||||
|
'w-full p-4 flex flex-col border-b border-base-content/10',
|
||||||
|
className?.wrapper
|
||||||
|
)}
|
||||||
|
>
|
||||||
|
<h4 className='text-base font-medium text-base-content/50 font-roboto'>
|
||||||
|
{title}
|
||||||
|
</h4>
|
||||||
|
|
||||||
|
<div
|
||||||
|
className={cn(
|
||||||
|
'mt-6 mb-8 flex flex-col gap-10',
|
||||||
|
className?.stepsWrapper
|
||||||
|
)}
|
||||||
|
>
|
||||||
|
{slicedFormattedApprovals.map((approval, idx) => {
|
||||||
|
const isApprovalActionCreated = approval.action === 'CREATED';
|
||||||
|
const isApprovalActionUpdated = approval.action === 'UPDATED';
|
||||||
|
const isApprovalActionRejected = approval.action === 'REJECTED';
|
||||||
|
const isApprovalActionApproved = approval.action === 'APPROVED';
|
||||||
|
|
||||||
|
const approvalIcon =
|
||||||
|
isApprovalActionCreated || isApprovalActionUpdated
|
||||||
|
? 'heroicons:clock-solid'
|
||||||
|
: isApprovalActionRejected
|
||||||
|
? 'heroicons:x-circle-solid'
|
||||||
|
: isApprovalActionApproved
|
||||||
|
? 'heroicons:check-badge-solid'
|
||||||
|
: 'heroicons:check-badge-solid';
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div key={idx} className='w-full flex flex-row items-stretch gap-3'>
|
||||||
|
<div className='w-fit self-stretch relative'>
|
||||||
|
<div className='w-fit h-fit flex flex-col items-start'>
|
||||||
|
<Icon
|
||||||
|
icon={approvalIcon}
|
||||||
|
width={24}
|
||||||
|
height={24}
|
||||||
|
className={cn({
|
||||||
|
'text-warning':
|
||||||
|
isApprovalActionCreated || isApprovalActionUpdated,
|
||||||
|
'text-error': isApprovalActionRejected,
|
||||||
|
'text-success': isApprovalActionApproved,
|
||||||
|
'text-base-content/20': !approval.isActive,
|
||||||
|
})}
|
||||||
|
/>
|
||||||
|
|
||||||
|
{idx < formattedApprovals.length - 1 && (
|
||||||
|
<div className='absolute top-6 left-1/2 -translate-x-1/2 w-0 min-h-full h-[calc(100%)] mx-auto my-2 border border-dashed border-base-content/10' />
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div
|
||||||
|
className={cn('w-full flex flex-col gap-1 text-base-content', {
|
||||||
|
'text-base-content/20': !approval.isActive,
|
||||||
|
})}
|
||||||
|
>
|
||||||
|
<div className='flex flex-col'>
|
||||||
|
<span className='text-xs'>{approval.step_name}</span>
|
||||||
|
<span className='text-sm font-semibold'>
|
||||||
|
{(isApprovalActionCreated || isApprovalActionUpdated) &&
|
||||||
|
'Diajukan oleh '}
|
||||||
|
{isApprovalActionRejected && 'Ditolak oleh '}
|
||||||
|
{isApprovalActionApproved && 'Disetujui oleh '}
|
||||||
|
{approval.isActive ? approval.action_by.name : '...'}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{approval.isActive && (
|
||||||
|
<p className='w-full max-w-60 p-3 bg-base-content/5 rounded-xl text-xs text-base-content/50'>
|
||||||
|
Created at :{' '}
|
||||||
|
{formatDate(approval.action_at, 'DD-MM-YYYY, HH:mm')}
|
||||||
|
<br />
|
||||||
|
Notes : {approval.notes ?? '-'}
|
||||||
|
</p>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{formattedApprovals.length > maxVisibleSteps && (
|
||||||
|
<Button
|
||||||
|
variant='outline'
|
||||||
|
color='none'
|
||||||
|
onClick={seeMoreClickHandler}
|
||||||
|
className={cn(
|
||||||
|
'px-3 py-2 gap-2.5 text-sm text-base-content/50 border border-base-content/10 rounded-lg transition-all'
|
||||||
|
)}
|
||||||
|
>
|
||||||
|
<Icon
|
||||||
|
icon='heroicons-outline:chevron-double-down'
|
||||||
|
width={20}
|
||||||
|
height={20}
|
||||||
|
className={cn('transition-all duration-300', {
|
||||||
|
'-rotate-180': isSeeAll,
|
||||||
|
})}
|
||||||
|
/>
|
||||||
|
See {isSeeAll ? 'Less' : 'More'}
|
||||||
|
</Button>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default ApprovalStepsV2;
|
||||||
@@ -0,0 +1,82 @@
|
|||||||
|
import Button, { ButtonProps } from '@/components/Button';
|
||||||
|
import { getFilledFormikValuesCount } from '@/lib/formik-helper';
|
||||||
|
import { cn } from '@/lib/helper';
|
||||||
|
import { Icon } from '@iconify/react';
|
||||||
|
import { FormikValues } from 'formik';
|
||||||
|
import { useMemo } from 'react';
|
||||||
|
|
||||||
|
export type ButtonFilterProps = ButtonProps & {
|
||||||
|
values: FormikValues;
|
||||||
|
onClick: () => void;
|
||||||
|
excludeFields?: string[];
|
||||||
|
fieldGroups?: string[][];
|
||||||
|
};
|
||||||
|
|
||||||
|
// 'bg-gradient-to-t from-blue-50 to-blue-100 border-blue-500 text-blue-600 hover:from-blue-100 hover:to-blue-200
|
||||||
|
|
||||||
|
const ButtonFilter = ({
|
||||||
|
values,
|
||||||
|
onClick,
|
||||||
|
excludeFields = [],
|
||||||
|
fieldGroups = [],
|
||||||
|
...props
|
||||||
|
}: ButtonFilterProps) => {
|
||||||
|
const activeCount = useMemo(() => {
|
||||||
|
const filteredValues: FormikValues = {};
|
||||||
|
Object.keys(values).forEach((key) => {
|
||||||
|
if (!excludeFields.includes(key)) {
|
||||||
|
filteredValues[key] = values[key];
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
let count = getFilledFormikValuesCount(filteredValues);
|
||||||
|
|
||||||
|
fieldGroups.forEach((group) => {
|
||||||
|
const groupFields = group.filter(
|
||||||
|
(field) => !excludeFields.includes(field)
|
||||||
|
);
|
||||||
|
const filledGroupFields = groupFields.filter(
|
||||||
|
(field) => filteredValues[field]
|
||||||
|
);
|
||||||
|
if (
|
||||||
|
filledGroupFields.length === groupFields.length &&
|
||||||
|
groupFields.length > 1
|
||||||
|
) {
|
||||||
|
count -= groupFields.length - 1;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return count;
|
||||||
|
}, [values, excludeFields, fieldGroups]);
|
||||||
|
return (
|
||||||
|
<Button
|
||||||
|
{...props}
|
||||||
|
onClick={onClick}
|
||||||
|
variant='outline'
|
||||||
|
color='none'
|
||||||
|
className={cn(
|
||||||
|
'rounded-lg max-h-10 font-semibold text-sm gap-1.5',
|
||||||
|
'text-sm text-base-content/50 border border-base-content/10 shadow-button-soft',
|
||||||
|
activeCount > 0
|
||||||
|
? 'border-primary-gradient text-primary rounded-lg!'
|
||||||
|
: 'rounded-lg',
|
||||||
|
props.className
|
||||||
|
)}
|
||||||
|
>
|
||||||
|
<Icon
|
||||||
|
icon='heroicons:funnel'
|
||||||
|
width={20}
|
||||||
|
height={20}
|
||||||
|
className={activeCount > 0 ? 'text-blue-600' : ''}
|
||||||
|
/>
|
||||||
|
Filter
|
||||||
|
{activeCount > 0 && (
|
||||||
|
<span className='w-5 h-5 text-white bg-[#FF3535] rounded-lg border border-base-300 flex items-center justify-center text-xs'>
|
||||||
|
{activeCount}
|
||||||
|
</span>
|
||||||
|
)}
|
||||||
|
</Button>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default ButtonFilter;
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
import Button from '@/components/Button';
|
||||||
|
|
||||||
|
const PageNotFound = () => {
|
||||||
|
return (
|
||||||
|
<div className='w-full h-full flex-1 flex flex-col justify-center items-center gap-4'>
|
||||||
|
<h2 className='text-2xl font-bold text-error'>Halaman Tidak Ditemukan</h2>
|
||||||
|
<p className='text-gray-600 text-center'>
|
||||||
|
Halaman atau data yang anda cari tidak ditemukan.
|
||||||
|
</p>
|
||||||
|
<Button href='/dashboard' className='text-base-100'>
|
||||||
|
Kembali ke Dashboard
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default PageNotFound;
|
||||||
@@ -1,10 +1,17 @@
|
|||||||
|
import Button from '@/components/Button';
|
||||||
|
|
||||||
const PermissionNotFound = () => {
|
const PermissionNotFound = () => {
|
||||||
return (
|
return (
|
||||||
<div className='w-full h-screen flex flex-col justify-center items-center gap-4'>
|
<div className='w-full h-screen flex flex-col justify-center items-center gap-4'>
|
||||||
<h2 className='text-2xl font-bold text-error'>Permission Not Found</h2>
|
<h2 className='text-2xl font-bold text-error'>
|
||||||
|
Hak Akses Tidak Ditemukan
|
||||||
|
</h2>
|
||||||
<p className='text-gray-600 text-center'>
|
<p className='text-gray-600 text-center'>
|
||||||
You do not have permission to access this page.
|
Anda tidak memiliki hak akses untuk mengakses halaman ini.
|
||||||
</p>
|
</p>
|
||||||
|
<Button href='/dashboard' className='text-base-100'>
|
||||||
|
Kembali ke Dashboard
|
||||||
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -72,8 +72,10 @@ const RequireAuth = ({ children }: RequireAuthProps) => {
|
|||||||
await AuthApi.refresh();
|
await AuthApi.refresh();
|
||||||
};
|
};
|
||||||
|
|
||||||
refreshUserSession();
|
if (user) {
|
||||||
}, []);
|
refreshUserSession();
|
||||||
|
}
|
||||||
|
}, [user]);
|
||||||
|
|
||||||
if (
|
if (
|
||||||
(isLoadingUserResponse && !userResponse && !userErrorResponse) ||
|
(isLoadingUserResponse && !userResponse && !userErrorResponse) ||
|
||||||
|
|||||||
@@ -0,0 +1,66 @@
|
|||||||
|
import { ReactNode } from 'react';
|
||||||
|
|
||||||
|
import Badge from '@/components/Badge';
|
||||||
|
|
||||||
|
import { cn } from '@/lib/helper';
|
||||||
|
import { Color } from '@/types/theme';
|
||||||
|
|
||||||
|
interface StatusBadgeProps {
|
||||||
|
color: Color;
|
||||||
|
text: ReactNode;
|
||||||
|
className?: {
|
||||||
|
badge?: string;
|
||||||
|
status?: string;
|
||||||
|
};
|
||||||
|
onClick?: () => void;
|
||||||
|
}
|
||||||
|
|
||||||
|
const StatusBadge = ({
|
||||||
|
color = 'neutral',
|
||||||
|
text,
|
||||||
|
className,
|
||||||
|
onClick,
|
||||||
|
}: StatusBadgeProps) => {
|
||||||
|
return (
|
||||||
|
<Badge
|
||||||
|
variant='soft'
|
||||||
|
onClick={onClick}
|
||||||
|
className={{
|
||||||
|
badge: cn(
|
||||||
|
'px-2 py-1 w-full flex flex-row justify-start gap-1 rounded-lg border border-base-content/10 text-xs font-medium text-base-content',
|
||||||
|
{
|
||||||
|
'bg-base-content/5': color === 'neutral',
|
||||||
|
'bg-success/30': color === 'success',
|
||||||
|
'bg-error/20': color === 'error',
|
||||||
|
'bg-primary/20': color === 'info',
|
||||||
|
'bg-[#FF9A20]/12': color === 'warning',
|
||||||
|
'bg-[#1166EF]/12': color === 'primary',
|
||||||
|
},
|
||||||
|
className?.badge
|
||||||
|
),
|
||||||
|
status: cn(className?.status),
|
||||||
|
}}
|
||||||
|
color={color}
|
||||||
|
>
|
||||||
|
<svg
|
||||||
|
height='12'
|
||||||
|
width='12'
|
||||||
|
xmlns='http://www.w3.org/2000/svg'
|
||||||
|
className={cn({
|
||||||
|
'text-base-content/10': color === 'neutral',
|
||||||
|
'text-[#008000]': color === 'success',
|
||||||
|
'text-error': color === 'error',
|
||||||
|
'text-primary': color === 'info',
|
||||||
|
'text-[#FF9A20]': color === 'warning',
|
||||||
|
'text-[#1166EF]': color === 'primary',
|
||||||
|
})}
|
||||||
|
>
|
||||||
|
<circle r='6' cx='6' cy='6' fill='currentColor' />
|
||||||
|
</svg>
|
||||||
|
|
||||||
|
{text}
|
||||||
|
</Badge>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default StatusBadge;
|
||||||
@@ -27,7 +27,7 @@ export interface DrawerHeaderProps {
|
|||||||
|
|
||||||
const DrawerHeader = ({
|
const DrawerHeader = ({
|
||||||
leftIcon = 'mdi:close',
|
leftIcon = 'mdi:close',
|
||||||
leftIconSize = 24,
|
leftIconSize = 20,
|
||||||
leftIconHref,
|
leftIconHref,
|
||||||
leftIconOnClick,
|
leftIconOnClick,
|
||||||
leftIconClassName,
|
leftIconClassName,
|
||||||
@@ -43,7 +43,7 @@ const DrawerHeader = ({
|
|||||||
icon={leftIcon}
|
icon={leftIcon}
|
||||||
width={leftIconSize}
|
width={leftIconSize}
|
||||||
height={leftIconSize}
|
height={leftIconSize}
|
||||||
className={cn('cursor-pointer', leftIconClassName)}
|
className={cn('cursor-pointer text-base-content ', leftIconClassName)}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -58,6 +58,7 @@ const DrawerHeader = ({
|
|||||||
if (leftIconOnClick) {
|
if (leftIconOnClick) {
|
||||||
return (
|
return (
|
||||||
<button
|
<button
|
||||||
|
type='button'
|
||||||
onClick={leftIconOnClick}
|
onClick={leftIconOnClick}
|
||||||
className='hover:text-gray-400 bg-transparent border-none p-0'
|
className='hover:text-gray-400 bg-transparent border-none p-0'
|
||||||
>
|
>
|
||||||
@@ -72,20 +73,25 @@ const DrawerHeader = ({
|
|||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
className={cn(
|
className={cn(
|
||||||
'flex flex-row justify-between items-center px-4 pt-4',
|
'flex flex-row justify-between items-center p-4 border-b border-base-content/10',
|
||||||
className
|
className
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
{/* Left Side */}
|
{/* Left Side */}
|
||||||
<div className='flex flex-row h-full gap-2 items-center'>
|
<div className='flex flex-row h-full gap-3 items-center'>
|
||||||
{renderLeftIcon()}
|
{renderLeftIcon()}
|
||||||
|
|
||||||
{showDivider && subtitle && (
|
{showDivider && subtitle && (
|
||||||
<div className='divider divider-horizontal p-0 m-0'></div>
|
<div className='w-px h-full border-none bg-base-content/10' />
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{subtitle && (
|
{subtitle && (
|
||||||
<div className={cn('text-sm text-neutral', subtitleClassName)}>
|
<div
|
||||||
|
className={cn(
|
||||||
|
'text-sm font-medium text-base-content/50',
|
||||||
|
subtitleClassName
|
||||||
|
)}
|
||||||
|
>
|
||||||
{subtitle}
|
{subtitle}
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|||||||
@@ -1,7 +1,10 @@
|
|||||||
|
'use client';
|
||||||
|
|
||||||
import Alert from '@/components/Alert';
|
import Alert from '@/components/Alert';
|
||||||
import Button from '@/components/Button';
|
import Button from '@/components/Button';
|
||||||
|
import { cn } from '@/lib/helper';
|
||||||
import { Icon } from '@iconify/react';
|
import { Icon } from '@iconify/react';
|
||||||
import { useState } from 'react';
|
import { useEffect, useRef } from 'react';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Alert Unique Error List
|
* Alert Unique Error List
|
||||||
@@ -10,34 +13,81 @@ import { useState } from 'react';
|
|||||||
*/
|
*/
|
||||||
const AlertErrorList = ({
|
const AlertErrorList = ({
|
||||||
formErrorList,
|
formErrorList,
|
||||||
|
className,
|
||||||
onClose,
|
onClose,
|
||||||
|
title,
|
||||||
}: {
|
}: {
|
||||||
formErrorList: string[];
|
formErrorList: string[];
|
||||||
|
className?: {
|
||||||
|
alert?: string;
|
||||||
|
button?: string;
|
||||||
|
headerWrapper?: string;
|
||||||
|
headerIcon?: string;
|
||||||
|
headerText?: string;
|
||||||
|
titleWrapper?: string;
|
||||||
|
ul?: string;
|
||||||
|
li?: string;
|
||||||
|
};
|
||||||
onClose: () => void;
|
onClose: () => void;
|
||||||
|
title?: string;
|
||||||
}) => {
|
}) => {
|
||||||
|
const alertRef = useRef<HTMLDivElement | null>(null);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (formErrorList.length > 0) {
|
||||||
|
alertRef.current?.scrollIntoView({
|
||||||
|
behavior: 'smooth',
|
||||||
|
block: 'start',
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}, [formErrorList.length]);
|
||||||
|
|
||||||
if (formErrorList.length === 0) return null;
|
if (formErrorList.length === 0) return null;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Alert color='error' className='w-full flex flex-col gap-2 px-4 m-4'>
|
<Alert
|
||||||
<div className='flex justify-between items-center gap-2 w-full'>
|
ref={alertRef}
|
||||||
<div className='flex items-center gap-2'>
|
color='error'
|
||||||
<Icon icon='material-symbols:error-outline' width={24} height={24} />
|
className={cn(
|
||||||
<span className='font-semibold'>
|
'w-full flex flex-col gap-2 px-3 rounded-lg',
|
||||||
Terdapat {formErrorList.length} error pada form:
|
className?.alert
|
||||||
|
)}
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
className={cn(
|
||||||
|
'flex justify-between items-center gap-2 w-full',
|
||||||
|
className?.headerWrapper
|
||||||
|
)}
|
||||||
|
>
|
||||||
|
<div className={cn('flex items-center gap-2', className?.titleWrapper)}>
|
||||||
|
<Icon
|
||||||
|
icon='material-symbols:error-outline'
|
||||||
|
className={cn(className?.headerIcon)}
|
||||||
|
width={20}
|
||||||
|
height={20}
|
||||||
|
/>
|
||||||
|
<span className={cn('font-semibold text-sm', className?.headerText)}>
|
||||||
|
{title || `Terdapat ${formErrorList.length} error pada form:`}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<Button
|
<Button
|
||||||
|
type='button'
|
||||||
onClick={onClose}
|
onClick={onClose}
|
||||||
variant='link'
|
variant='link'
|
||||||
className='ml-auto p-0 w-fit text-white'
|
className={cn('ml-auto p-0 w-fit text-white', className?.button)}
|
||||||
color='none'
|
color='none'
|
||||||
>
|
>
|
||||||
<Icon icon='material-symbols:close' width={24} height={24} />
|
<Icon icon='material-symbols:close' width={20} height={20} />
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
<ul className='list-disc list-inside pl-8 space-y-1 w-full'>
|
<ul
|
||||||
|
className={cn(
|
||||||
|
'list-disc list-inside pl-4 space-y-1.5 w-full',
|
||||||
|
className?.ul
|
||||||
|
)}
|
||||||
|
>
|
||||||
{formErrorList.map((error, index) => (
|
{formErrorList.map((error, index) => (
|
||||||
<li key={index} className='text-sm'>
|
<li key={index} className={cn('text-sm', className?.li)}>
|
||||||
{error}
|
{error}
|
||||||
</li>
|
</li>
|
||||||
))}
|
))}
|
||||||
|
|||||||
@@ -0,0 +1,27 @@
|
|||||||
|
import { Text, View, StyleSheet } from '@react-pdf/renderer';
|
||||||
|
import type { Style } from '@react-pdf/types';
|
||||||
|
|
||||||
|
type PdfParamBadgeProps = {
|
||||||
|
children: React.ReactNode;
|
||||||
|
style?: Style;
|
||||||
|
};
|
||||||
|
|
||||||
|
const styles = StyleSheet.create({
|
||||||
|
parameterBadge: {
|
||||||
|
backgroundColor: '#F5F5F5',
|
||||||
|
color: '#333333',
|
||||||
|
padding: 4,
|
||||||
|
borderRadius: 4,
|
||||||
|
fontSize: 8,
|
||||||
|
marginRight: 8,
|
||||||
|
marginBottom: 4,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
export const PdfParamBadge = ({ children, style }: PdfParamBadgeProps) => {
|
||||||
|
return (
|
||||||
|
<View style={[styles.parameterBadge, ...(style ? [style] : [])]}>
|
||||||
|
<Text>{children}</Text>
|
||||||
|
</View>
|
||||||
|
);
|
||||||
|
};
|
||||||
@@ -0,0 +1,54 @@
|
|||||||
|
import { Text, View, StyleSheet } from '@react-pdf/renderer';
|
||||||
|
import type { Style } from '@react-pdf/types';
|
||||||
|
|
||||||
|
type PdfStatusBadgeProps = {
|
||||||
|
children: React.ReactNode;
|
||||||
|
style?: Style;
|
||||||
|
};
|
||||||
|
|
||||||
|
const styles = StyleSheet.create({
|
||||||
|
statusBadge: {
|
||||||
|
paddingVertical: 2,
|
||||||
|
paddingHorizontal: 4,
|
||||||
|
borderRadius: 12,
|
||||||
|
fontSize: 7,
|
||||||
|
fontWeight: 'bold',
|
||||||
|
borderWidth: 1,
|
||||||
|
borderStyle: 'solid',
|
||||||
|
backgroundColor: '#F5F5F5',
|
||||||
|
borderColor: '#E5E7EB',
|
||||||
|
},
|
||||||
|
statusBadgeText: {
|
||||||
|
fontSize: 7,
|
||||||
|
fontWeight: 'bold',
|
||||||
|
color: '#333333',
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
export const PdfStatusBadge = ({ children, style }: PdfStatusBadgeProps) => {
|
||||||
|
const styleRecord = style as Record<string, unknown>;
|
||||||
|
const color = styleRecord?.color as string | undefined;
|
||||||
|
|
||||||
|
const viewStyle = Object.entries(styleRecord || {}).reduce(
|
||||||
|
(acc, [key, value]) => {
|
||||||
|
if (key !== 'color') {
|
||||||
|
acc[key] = value;
|
||||||
|
}
|
||||||
|
return acc;
|
||||||
|
},
|
||||||
|
{} as Record<string, unknown>
|
||||||
|
);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<View
|
||||||
|
style={[
|
||||||
|
styles.statusBadge,
|
||||||
|
...(Object.keys(viewStyle).length > 0 ? [viewStyle as Style] : []),
|
||||||
|
]}
|
||||||
|
>
|
||||||
|
<Text style={[styles.statusBadgeText, ...(color ? [{ color }] : [])]}>
|
||||||
|
{children}
|
||||||
|
</Text>
|
||||||
|
</View>
|
||||||
|
);
|
||||||
|
};
|
||||||
@@ -0,0 +1,48 @@
|
|||||||
|
import { Text, View, StyleSheet } from '@react-pdf/renderer';
|
||||||
|
import type { Style } from '@react-pdf/types';
|
||||||
|
|
||||||
|
type PdfPageNumberProps = {
|
||||||
|
style?: Style;
|
||||||
|
/**
|
||||||
|
* Format template for page number.
|
||||||
|
* Use {pageNumber} and {totalPages} as placeholders.
|
||||||
|
* Default: "{pageNumber} / {totalPages}"
|
||||||
|
*/
|
||||||
|
format?: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
const styles = StyleSheet.create({
|
||||||
|
footer: {
|
||||||
|
width: '100%',
|
||||||
|
display: 'flex',
|
||||||
|
flexDirection: 'row',
|
||||||
|
justifyContent: 'space-between',
|
||||||
|
alignItems: 'center',
|
||||||
|
paddingHorizontal: 16,
|
||||||
|
position: 'absolute',
|
||||||
|
fontSize: 8,
|
||||||
|
bottom: 30,
|
||||||
|
left: 0,
|
||||||
|
right: 0,
|
||||||
|
textAlign: 'center',
|
||||||
|
color: 'grey',
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
export const PdfPageNumber = ({
|
||||||
|
style,
|
||||||
|
format = '{pageNumber} / {totalPages}',
|
||||||
|
}: PdfPageNumberProps) => {
|
||||||
|
return (
|
||||||
|
<View style={style || styles.footer} fixed>
|
||||||
|
<Text
|
||||||
|
render={({ pageNumber, totalPages }) =>
|
||||||
|
format
|
||||||
|
.replace('{pageNumber}', String(pageNumber))
|
||||||
|
.replace('{totalPages}', String(totalPages))
|
||||||
|
}
|
||||||
|
fixed
|
||||||
|
/>
|
||||||
|
</View>
|
||||||
|
);
|
||||||
|
};
|
||||||
@@ -0,0 +1,52 @@
|
|||||||
|
'use client';
|
||||||
|
|
||||||
|
import { View, StyleSheet } from '@react-pdf/renderer';
|
||||||
|
import type { PdfColumn } from './types';
|
||||||
|
import { PdfThead } from './PdfThead';
|
||||||
|
import { PdfTbody } from './PdfTbody';
|
||||||
|
import { PdfTfoot } from './PdfTfoot';
|
||||||
|
|
||||||
|
const styles = StyleSheet.create({
|
||||||
|
table: {
|
||||||
|
borderWidth: 1,
|
||||||
|
borderColor: '#000000',
|
||||||
|
marginBottom: 15,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
interface PdfTableProps<TData = Record<string, unknown>> {
|
||||||
|
columns: PdfColumn<TData>[];
|
||||||
|
data: TData[];
|
||||||
|
showFooter?: boolean;
|
||||||
|
footerLabel?: string;
|
||||||
|
firstRow?: {
|
||||||
|
valueKey: string;
|
||||||
|
value: number;
|
||||||
|
align?: 'right';
|
||||||
|
color?: string;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
export const PdfTable = <TData = Record<string, unknown>,>({
|
||||||
|
columns,
|
||||||
|
data,
|
||||||
|
showFooter = false,
|
||||||
|
footerLabel = 'Total',
|
||||||
|
firstRow,
|
||||||
|
}: PdfTableProps<TData>) => {
|
||||||
|
// Check if any column has footer defined
|
||||||
|
const hasFooter =
|
||||||
|
showFooter || columns.some((col) => col.footer !== undefined);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<View style={styles.table}>
|
||||||
|
<PdfThead columns={columns} data={data} />
|
||||||
|
<PdfTbody columns={columns} data={data} firstRow={firstRow} />
|
||||||
|
{hasFooter && data.length > 0 && (
|
||||||
|
<PdfTfoot columns={columns} data={data} label={footerLabel} />
|
||||||
|
)}
|
||||||
|
</View>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export type { PdfColumn };
|
||||||
@@ -0,0 +1,209 @@
|
|||||||
|
'use client';
|
||||||
|
|
||||||
|
import { Text, View, StyleSheet } from '@react-pdf/renderer';
|
||||||
|
import { ReactNode } from 'react';
|
||||||
|
import type { PdfColumn } from './types';
|
||||||
|
|
||||||
|
const styles = StyleSheet.create({
|
||||||
|
tableRow: {
|
||||||
|
flexDirection: 'row',
|
||||||
|
},
|
||||||
|
tableBorderBottom: {
|
||||||
|
borderBottomWidth: 1,
|
||||||
|
borderBottomColor: '#000000',
|
||||||
|
borderBottomStyle: 'solid',
|
||||||
|
},
|
||||||
|
tableCell: {
|
||||||
|
flex: 1,
|
||||||
|
borderRightWidth: 1,
|
||||||
|
borderRightColor: '#000000',
|
||||||
|
borderRightStyle: 'solid',
|
||||||
|
padding: 4,
|
||||||
|
fontSize: 7,
|
||||||
|
textAlign: 'left',
|
||||||
|
},
|
||||||
|
tableCellLast: {
|
||||||
|
flex: 1,
|
||||||
|
padding: 4,
|
||||||
|
fontSize: 7,
|
||||||
|
borderRightWidth: 0,
|
||||||
|
},
|
||||||
|
tableCellRight: {
|
||||||
|
flex: 1,
|
||||||
|
borderRightWidth: 1,
|
||||||
|
borderRightColor: '#000000',
|
||||||
|
borderRightStyle: 'solid',
|
||||||
|
padding: 4,
|
||||||
|
fontSize: 7,
|
||||||
|
textAlign: 'right',
|
||||||
|
},
|
||||||
|
tableCellCenter: {
|
||||||
|
flex: 1,
|
||||||
|
borderRightWidth: 1,
|
||||||
|
borderRightColor: '#000000',
|
||||||
|
borderRightStyle: 'solid',
|
||||||
|
padding: 4,
|
||||||
|
fontSize: 7,
|
||||||
|
textAlign: 'center',
|
||||||
|
},
|
||||||
|
tableCellNo: {
|
||||||
|
flex: 0.5,
|
||||||
|
borderRightWidth: 1,
|
||||||
|
borderRightColor: '#000000',
|
||||||
|
borderRightStyle: 'solid',
|
||||||
|
padding: 4,
|
||||||
|
fontSize: 7,
|
||||||
|
textAlign: 'center',
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
interface PdfTbodyProps<TData = Record<string, unknown>> {
|
||||||
|
columns: PdfColumn<TData>[];
|
||||||
|
data: TData[];
|
||||||
|
firstRow?: {
|
||||||
|
valueKey: string;
|
||||||
|
value: number;
|
||||||
|
align?: 'right';
|
||||||
|
color?: string;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
export const PdfTbody = <TData = Record<string, unknown>,>({
|
||||||
|
columns,
|
||||||
|
data,
|
||||||
|
firstRow,
|
||||||
|
}: PdfTbodyProps<TData>) => {
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
{/* First Row */}
|
||||||
|
{firstRow && (
|
||||||
|
<View style={[styles.tableRow, styles.tableBorderBottom]}>
|
||||||
|
{columns.map((column, index) => {
|
||||||
|
const isLastColumn = index === columns.length - 1;
|
||||||
|
const isFirstRowColumn = column.key === firstRow.valueKey;
|
||||||
|
const align = column.align || 'left';
|
||||||
|
|
||||||
|
const cellStyle =
|
||||||
|
column.key === 'no'
|
||||||
|
? [styles.tableCellNo, { flex: column.flex || 1 }]
|
||||||
|
: isFirstRowColumn
|
||||||
|
? [
|
||||||
|
styles.tableCellRight,
|
||||||
|
{
|
||||||
|
flex: column.flex || 1,
|
||||||
|
color: firstRow.color || 'black',
|
||||||
|
borderRightWidth: isLastColumn ? 0 : 1,
|
||||||
|
},
|
||||||
|
]
|
||||||
|
: align === 'right'
|
||||||
|
? [
|
||||||
|
styles.tableCellRight,
|
||||||
|
{
|
||||||
|
flex: column.flex || 1,
|
||||||
|
borderRightWidth: isLastColumn ? 0 : 1,
|
||||||
|
},
|
||||||
|
]
|
||||||
|
: align === 'center'
|
||||||
|
? [
|
||||||
|
styles.tableCellCenter,
|
||||||
|
{
|
||||||
|
flex: column.flex || 1,
|
||||||
|
borderRightWidth: isLastColumn ? 0 : 1,
|
||||||
|
},
|
||||||
|
]
|
||||||
|
: isLastColumn
|
||||||
|
? [
|
||||||
|
styles.tableCellLast,
|
||||||
|
{
|
||||||
|
flex: column.flex || 1,
|
||||||
|
borderRightWidth: 0,
|
||||||
|
},
|
||||||
|
]
|
||||||
|
: [styles.tableCell, { flex: column.flex || 1 }];
|
||||||
|
|
||||||
|
return (
|
||||||
|
<View key={column.key} style={cellStyle}>
|
||||||
|
<Text>{isFirstRowColumn ? firstRow.value : ''}</Text>
|
||||||
|
</View>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
</View>
|
||||||
|
)}
|
||||||
|
|
||||||
|
{/* Data Rows */}
|
||||||
|
{data.map((row, rowIndex) => {
|
||||||
|
const isLastRow = rowIndex === data.length - 1;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<View
|
||||||
|
key={rowIndex}
|
||||||
|
style={[
|
||||||
|
styles.tableRow,
|
||||||
|
!isLastRow ? styles.tableBorderBottom : {},
|
||||||
|
]}
|
||||||
|
>
|
||||||
|
{columns.map((column, colIndex) => {
|
||||||
|
const isLastColumn = colIndex === columns.length - 1;
|
||||||
|
const align = column.align || 'left';
|
||||||
|
|
||||||
|
// Get cell content from column.cell function or fallback to row value
|
||||||
|
let cellContent: ReactNode;
|
||||||
|
if (column.cell) {
|
||||||
|
cellContent = column.cell({ row, index: rowIndex });
|
||||||
|
} else {
|
||||||
|
cellContent =
|
||||||
|
((row as Record<string, unknown>)[column.key] as ReactNode) ??
|
||||||
|
'-';
|
||||||
|
}
|
||||||
|
|
||||||
|
const cellStyle =
|
||||||
|
column.key === 'no'
|
||||||
|
? [styles.tableCellNo, { flex: column.flex || 1 }]
|
||||||
|
: align === 'right'
|
||||||
|
? [
|
||||||
|
styles.tableCellRight,
|
||||||
|
{
|
||||||
|
flex: column.flex || 1,
|
||||||
|
borderRightWidth: isLastColumn ? 0 : 1,
|
||||||
|
},
|
||||||
|
]
|
||||||
|
: align === 'center'
|
||||||
|
? [
|
||||||
|
styles.tableCellCenter,
|
||||||
|
{
|
||||||
|
flex: column.flex || 1,
|
||||||
|
borderRightWidth: isLastColumn ? 0 : 1,
|
||||||
|
},
|
||||||
|
]
|
||||||
|
: isLastColumn
|
||||||
|
? [
|
||||||
|
styles.tableCellLast,
|
||||||
|
{ flex: column.flex || 1, borderRightWidth: 0 },
|
||||||
|
]
|
||||||
|
: [
|
||||||
|
styles.tableCell,
|
||||||
|
{
|
||||||
|
flex: column.flex || 1,
|
||||||
|
borderRightWidth: isLastColumn ? 0 : 1,
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
return (
|
||||||
|
<View key={column.key} style={cellStyle}>
|
||||||
|
{typeof cellContent === 'string' ||
|
||||||
|
typeof cellContent === 'number' ? (
|
||||||
|
<Text>{String(cellContent)}</Text>
|
||||||
|
) : (
|
||||||
|
cellContent
|
||||||
|
)}
|
||||||
|
</View>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
</View>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export type { PdfColumn };
|
||||||
@@ -0,0 +1,141 @@
|
|||||||
|
'use client';
|
||||||
|
|
||||||
|
import { Text, View, StyleSheet } from '@react-pdf/renderer';
|
||||||
|
import { ReactNode } from 'react';
|
||||||
|
import type { PdfColumn } from './types';
|
||||||
|
|
||||||
|
const styles = StyleSheet.create({
|
||||||
|
tableRow: {
|
||||||
|
flexDirection: 'row',
|
||||||
|
},
|
||||||
|
summaryRow: {
|
||||||
|
backgroundColor: '#F0F0F0',
|
||||||
|
fontWeight: 'bold',
|
||||||
|
},
|
||||||
|
tableCell: {
|
||||||
|
flex: 1,
|
||||||
|
borderRightWidth: 1,
|
||||||
|
borderRightColor: '#000000',
|
||||||
|
borderRightStyle: 'solid',
|
||||||
|
padding: 4,
|
||||||
|
fontSize: 7,
|
||||||
|
textAlign: 'left',
|
||||||
|
},
|
||||||
|
tableCellLast: {
|
||||||
|
flex: 1,
|
||||||
|
padding: 4,
|
||||||
|
fontSize: 7,
|
||||||
|
borderRightWidth: 0,
|
||||||
|
},
|
||||||
|
tableCellRight: {
|
||||||
|
flex: 1,
|
||||||
|
borderRightWidth: 1,
|
||||||
|
borderRightColor: '#000000',
|
||||||
|
borderRightStyle: 'solid',
|
||||||
|
padding: 4,
|
||||||
|
fontSize: 7,
|
||||||
|
textAlign: 'right',
|
||||||
|
},
|
||||||
|
tableCellCenter: {
|
||||||
|
flex: 1,
|
||||||
|
borderRightWidth: 1,
|
||||||
|
borderRightColor: '#000000',
|
||||||
|
borderRightStyle: 'solid',
|
||||||
|
padding: 4,
|
||||||
|
fontSize: 7,
|
||||||
|
textAlign: 'center',
|
||||||
|
},
|
||||||
|
tableCellNo: {
|
||||||
|
flex: 0.5,
|
||||||
|
borderRightWidth: 1,
|
||||||
|
borderRightColor: '#000000',
|
||||||
|
borderRightStyle: 'solid',
|
||||||
|
padding: 4,
|
||||||
|
fontSize: 7,
|
||||||
|
textAlign: 'center',
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
interface PdfTfootProps<TData = Record<string, unknown>> {
|
||||||
|
columns: PdfColumn<TData>[];
|
||||||
|
data: TData[];
|
||||||
|
label?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export const PdfTfoot = <TData = Record<string, unknown>,>({
|
||||||
|
columns,
|
||||||
|
data,
|
||||||
|
label = 'Total',
|
||||||
|
}: PdfTfootProps<TData>) => {
|
||||||
|
return (
|
||||||
|
<View style={[styles.tableRow, styles.summaryRow]}>
|
||||||
|
{columns.map((column, index) => {
|
||||||
|
const isLastColumn = index === columns.length - 1;
|
||||||
|
|
||||||
|
// Get footer content from column definition
|
||||||
|
let footerContent: ReactNode;
|
||||||
|
if (typeof column.footer === 'function') {
|
||||||
|
footerContent = column.footer(data);
|
||||||
|
} else {
|
||||||
|
footerContent = column.footer;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Use label for first column (usually 'no' column)
|
||||||
|
const displayContent = column.key === 'no' ? label : footerContent;
|
||||||
|
|
||||||
|
// Determine alignment
|
||||||
|
const align = column.footerAlign || column.align || 'left';
|
||||||
|
const color = column.footerColor || 'black';
|
||||||
|
|
||||||
|
const cellStyle =
|
||||||
|
column.key === 'no'
|
||||||
|
? [
|
||||||
|
styles.tableCellNo,
|
||||||
|
{
|
||||||
|
flex: column.flex || 1,
|
||||||
|
borderRightWidth: isLastColumn ? 0 : 1,
|
||||||
|
color,
|
||||||
|
},
|
||||||
|
]
|
||||||
|
: align === 'right'
|
||||||
|
? [
|
||||||
|
styles.tableCellRight,
|
||||||
|
{
|
||||||
|
flex: column.flex || 1,
|
||||||
|
color,
|
||||||
|
borderRightWidth: isLastColumn ? 0 : 1,
|
||||||
|
},
|
||||||
|
]
|
||||||
|
: align === 'center'
|
||||||
|
? [
|
||||||
|
styles.tableCellCenter,
|
||||||
|
{
|
||||||
|
flex: column.flex || 1,
|
||||||
|
color,
|
||||||
|
borderRightWidth: isLastColumn ? 0 : 1,
|
||||||
|
},
|
||||||
|
]
|
||||||
|
: isLastColumn
|
||||||
|
? [styles.tableCellLast, { flex: column.flex || 1, color }]
|
||||||
|
: [styles.tableCell, { flex: column.flex || 1, color }];
|
||||||
|
|
||||||
|
return (
|
||||||
|
<View key={column.key} style={cellStyle}>
|
||||||
|
{displayContent !== undefined && displayContent !== null ? (
|
||||||
|
typeof displayContent === 'string' ||
|
||||||
|
typeof displayContent === 'number' ? (
|
||||||
|
<Text>{String(displayContent)}</Text>
|
||||||
|
) : (
|
||||||
|
displayContent
|
||||||
|
)
|
||||||
|
) : (
|
||||||
|
<Text>-</Text>
|
||||||
|
)}
|
||||||
|
</View>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
</View>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export type { PdfColumn };
|
||||||
@@ -0,0 +1,104 @@
|
|||||||
|
'use client';
|
||||||
|
|
||||||
|
import { Text, View, StyleSheet } from '@react-pdf/renderer';
|
||||||
|
import { ReactNode } from 'react';
|
||||||
|
import type { PdfColumn } from './types';
|
||||||
|
|
||||||
|
const styles = StyleSheet.create({
|
||||||
|
tableRow: {
|
||||||
|
flexDirection: 'row',
|
||||||
|
},
|
||||||
|
tableHeader: {
|
||||||
|
backgroundColor: '#F5F5F5',
|
||||||
|
},
|
||||||
|
tableCellHeader: {
|
||||||
|
flex: 1,
|
||||||
|
borderRightWidth: 1,
|
||||||
|
borderRightColor: '#000000',
|
||||||
|
borderRightStyle: 'solid',
|
||||||
|
padding: 4,
|
||||||
|
fontSize: 7,
|
||||||
|
fontWeight: 'bold',
|
||||||
|
backgroundColor: '#F5F5F5',
|
||||||
|
borderBottomWidth: 1,
|
||||||
|
borderBottomColor: '#000000',
|
||||||
|
borderBottomStyle: 'solid',
|
||||||
|
paddingVertical: 12,
|
||||||
|
textAlign: 'center',
|
||||||
|
},
|
||||||
|
tableCellHeaderRight: {
|
||||||
|
flex: 1,
|
||||||
|
borderRightWidth: 1,
|
||||||
|
borderRightColor: '#000000',
|
||||||
|
borderRightStyle: 'solid',
|
||||||
|
padding: 4,
|
||||||
|
fontSize: 7,
|
||||||
|
fontWeight: 'bold',
|
||||||
|
backgroundColor: '#F5F5F5',
|
||||||
|
textAlign: 'right',
|
||||||
|
borderBottomWidth: 1,
|
||||||
|
borderBottomColor: '#000000',
|
||||||
|
borderBottomStyle: 'solid',
|
||||||
|
paddingVertical: 12,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
interface PdfTheadProps<TData = Record<string, unknown>> {
|
||||||
|
columns: PdfColumn<TData>[];
|
||||||
|
data?: TData[];
|
||||||
|
}
|
||||||
|
|
||||||
|
export const PdfThead = <TData = Record<string, unknown>,>({
|
||||||
|
columns,
|
||||||
|
data,
|
||||||
|
}: PdfTheadProps<TData>) => {
|
||||||
|
return (
|
||||||
|
<View style={[styles.tableRow, styles.tableHeader]}>
|
||||||
|
{columns.map((column, index) => {
|
||||||
|
const isLastColumn = index === columns.length - 1;
|
||||||
|
|
||||||
|
// Get header content from column definition
|
||||||
|
let headerContent: ReactNode;
|
||||||
|
if (typeof column.header === 'function') {
|
||||||
|
headerContent = column.header(data || []);
|
||||||
|
} else {
|
||||||
|
headerContent = column.header || column.key;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Determine alignment - columns align right by default for numeric data
|
||||||
|
const align = column.align || 'left';
|
||||||
|
|
||||||
|
const cellStyle =
|
||||||
|
align === 'right'
|
||||||
|
? [
|
||||||
|
styles.tableCellHeaderRight,
|
||||||
|
{
|
||||||
|
flex: column.flex || 1,
|
||||||
|
textAlign: 'right' as const,
|
||||||
|
borderRightWidth: isLastColumn ? 0 : 1,
|
||||||
|
},
|
||||||
|
]
|
||||||
|
: [
|
||||||
|
styles.tableCellHeader,
|
||||||
|
{
|
||||||
|
flex: column.flex || 1,
|
||||||
|
textAlign: align as 'left' | 'center' | 'right',
|
||||||
|
borderRightWidth: isLastColumn ? 0 : 1,
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
return (
|
||||||
|
<View key={column.key} style={cellStyle}>
|
||||||
|
{typeof headerContent === 'string' ? (
|
||||||
|
<Text>{headerContent}</Text>
|
||||||
|
) : (
|
||||||
|
headerContent
|
||||||
|
)}
|
||||||
|
</View>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
</View>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export type { PdfColumn };
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
export { PdfTable } from './PdfTable';
|
||||||
|
export { PdfThead } from './PdfThead';
|
||||||
|
export { PdfTbody } from './PdfTbody';
|
||||||
|
export { PdfTfoot } from './PdfTfoot';
|
||||||
|
export type { PdfColumn } from './types';
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
import { ReactNode } from 'react';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* PdfColumn - Mirip dengan ColumnDef di TanStack Table
|
||||||
|
* Mengatur header (thead), body (tbody), dan footer (tfoot) dalam satu definisi
|
||||||
|
*/
|
||||||
|
export interface PdfColumn<TData = Record<string, unknown>> {
|
||||||
|
key: string;
|
||||||
|
flex?: number;
|
||||||
|
|
||||||
|
// Header configuration (thead)
|
||||||
|
header?: string | ((data: TData[]) => ReactNode);
|
||||||
|
|
||||||
|
// Body configuration (tbody)
|
||||||
|
align?: 'left' | 'center' | 'right';
|
||||||
|
cell?: (props: { row: TData; index: number }) => ReactNode | string | number;
|
||||||
|
|
||||||
|
// Footer configuration (tfoot)
|
||||||
|
footer?: string | number | ((data: TData[]) => ReactNode | string | number);
|
||||||
|
footerAlign?: 'left' | 'center' | 'right';
|
||||||
|
footerColor?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export type { PdfColumn as default };
|
||||||
@@ -0,0 +1,80 @@
|
|||||||
|
import { Color } from '@/types/theme';
|
||||||
|
import { Text, StyleSheet } from '@react-pdf/renderer';
|
||||||
|
import type { Style } from '@react-pdf/types';
|
||||||
|
|
||||||
|
type TypographySize = 'h1' | 'h2' | 'h3' | 'h4' | 'p' | 'small' | 'label';
|
||||||
|
|
||||||
|
type TypographyVariant = Color | 'default';
|
||||||
|
|
||||||
|
type PdfTypographyProps = {
|
||||||
|
children: React.ReactNode;
|
||||||
|
size?: TypographySize;
|
||||||
|
variant?: TypographyVariant;
|
||||||
|
color?: string;
|
||||||
|
style?: Style;
|
||||||
|
};
|
||||||
|
|
||||||
|
const styles = StyleSheet.create({
|
||||||
|
h1: {
|
||||||
|
fontSize: 14,
|
||||||
|
fontWeight: 'bold',
|
||||||
|
marginBottom: 5,
|
||||||
|
},
|
||||||
|
h2: {
|
||||||
|
fontSize: 12,
|
||||||
|
fontWeight: 'bold',
|
||||||
|
marginBottom: 8,
|
||||||
|
},
|
||||||
|
h3: {
|
||||||
|
fontSize: 10,
|
||||||
|
fontWeight: 'bold',
|
||||||
|
marginBottom: 4,
|
||||||
|
},
|
||||||
|
h4: {
|
||||||
|
fontSize: 9,
|
||||||
|
fontWeight: 'bold',
|
||||||
|
marginBottom: 3,
|
||||||
|
},
|
||||||
|
p: {
|
||||||
|
fontSize: 10,
|
||||||
|
marginBottom: 4,
|
||||||
|
},
|
||||||
|
small: {
|
||||||
|
fontSize: 8,
|
||||||
|
marginBottom: 2,
|
||||||
|
},
|
||||||
|
label: {
|
||||||
|
fontSize: 9,
|
||||||
|
marginBottom: 5,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const variantColors: Record<TypographyVariant, string> = {
|
||||||
|
default: '#333333',
|
||||||
|
primary: '#1f74bf',
|
||||||
|
secondary: '#6B7280',
|
||||||
|
accent: '#8B5CF6',
|
||||||
|
neutral: '#6B7280',
|
||||||
|
info: '#3B82F6',
|
||||||
|
success: '#065F46',
|
||||||
|
warning: '#92400E',
|
||||||
|
error: '#DC2626',
|
||||||
|
none: '#333333',
|
||||||
|
};
|
||||||
|
|
||||||
|
export const PdfTypography = ({
|
||||||
|
children,
|
||||||
|
size = 'p',
|
||||||
|
variant = 'default',
|
||||||
|
color,
|
||||||
|
style,
|
||||||
|
}: PdfTypographyProps) => {
|
||||||
|
const sizeStyle = styles[size];
|
||||||
|
const textColor = color || variantColors[variant];
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Text style={[sizeStyle, { color: textColor }, ...(style ? [style] : [])]}>
|
||||||
|
{children}
|
||||||
|
</Text>
|
||||||
|
);
|
||||||
|
};
|
||||||
@@ -0,0 +1,65 @@
|
|||||||
|
export type StatusColor = {
|
||||||
|
bg: string;
|
||||||
|
text: string;
|
||||||
|
border: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
// Due status colors (for debt supplier reports)
|
||||||
|
export const dueStatusColors: Record<string, StatusColor> = {
|
||||||
|
'SUDAH JATUH TEMPO': {
|
||||||
|
bg: '#FEE2E2',
|
||||||
|
text: '#991B1B',
|
||||||
|
border: '#F87171',
|
||||||
|
}, // error/red
|
||||||
|
'BELUM JATUH TEMPO': {
|
||||||
|
bg: '#D1FAE5',
|
||||||
|
text: '#065F46',
|
||||||
|
border: '#34D399',
|
||||||
|
}, // success/green
|
||||||
|
'MENDEKATI JATUH TEMPO': {
|
||||||
|
bg: '#FEF3C7',
|
||||||
|
text: '#92400E',
|
||||||
|
border: '#FBBF24',
|
||||||
|
}, // warning/yellow
|
||||||
|
};
|
||||||
|
|
||||||
|
// Payment status colors (for customer payment & debt supplier reports)
|
||||||
|
export const paymentStatusColors: Record<string, StatusColor> = {
|
||||||
|
'BELUM LUNAS': {
|
||||||
|
bg: '#FEF3C7',
|
||||||
|
text: '#92400E',
|
||||||
|
border: '#FBBF24',
|
||||||
|
}, // warning/yellow
|
||||||
|
LUNAS: {
|
||||||
|
bg: '#DBEAFE',
|
||||||
|
text: '#1E40AF',
|
||||||
|
border: '#60A5FA',
|
||||||
|
}, // primary/blue
|
||||||
|
'PEMBAYARAN SEBAGIAN': { bg: '#D1FAE5', text: '#065F46', border: '#34D399' }, // success/green
|
||||||
|
PEMBAYARAN: {
|
||||||
|
bg: '#D1FAE5',
|
||||||
|
text: '#065F46',
|
||||||
|
border: '#34D399',
|
||||||
|
}, // success/green
|
||||||
|
};
|
||||||
|
|
||||||
|
// Fallback color for unknown statuses
|
||||||
|
export const fallbackStatusColor: StatusColor = {
|
||||||
|
bg: '#F3F4F6',
|
||||||
|
text: '#374151',
|
||||||
|
border: '#D1D5DB',
|
||||||
|
}; // neutral
|
||||||
|
|
||||||
|
export const getPDFBadgeStyle = (
|
||||||
|
statusText: string,
|
||||||
|
type: 'due' | 'payment' = 'payment'
|
||||||
|
): StatusColor => {
|
||||||
|
const normalizedStatus = statusText.toUpperCase().trim();
|
||||||
|
|
||||||
|
const colors =
|
||||||
|
type === 'due'
|
||||||
|
? dueStatusColors[normalizedStatus]
|
||||||
|
: paymentStatusColors[normalizedStatus];
|
||||||
|
|
||||||
|
return colors || fallbackStatusColor;
|
||||||
|
};
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
import IconSkeleton from '@/components/helper/skeleton/IconSkeleton';
|
||||||
|
|
||||||
|
const DataStateSkeleton = ({
|
||||||
|
icon,
|
||||||
|
title,
|
||||||
|
description,
|
||||||
|
}: {
|
||||||
|
icon: React.ReactNode;
|
||||||
|
title: string;
|
||||||
|
description: string;
|
||||||
|
}) => {
|
||||||
|
return (
|
||||||
|
<div className='flex flex-col items-center justify-center'>
|
||||||
|
<IconSkeleton
|
||||||
|
className={{
|
||||||
|
outer: 'mb-2.25',
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{icon}
|
||||||
|
</IconSkeleton>
|
||||||
|
<h3 className='text-base-content/50 font-semibold text-sm mb-1'>
|
||||||
|
{title}
|
||||||
|
</h3>
|
||||||
|
<p className='text-base-content/50 text-xs text-center max-w-xs'>
|
||||||
|
{description}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default DataStateSkeleton;
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
import { cn } from '@/lib/helper';
|
||||||
|
import { ReactNode } from 'react';
|
||||||
|
|
||||||
|
const IconSkeleton = ({
|
||||||
|
children,
|
||||||
|
className,
|
||||||
|
}: {
|
||||||
|
children: ReactNode;
|
||||||
|
className?: {
|
||||||
|
outer?: string;
|
||||||
|
inner?: string;
|
||||||
|
};
|
||||||
|
}) => {
|
||||||
|
return (
|
||||||
|
<div
|
||||||
|
className={cn(
|
||||||
|
'w-12.5 h-12.5 bg-[var(--main-color-base-100,#FFFFFF)] border border-base-content/10 rounded-[0.875rem] shadow-[0px_25px_50px_-12px_#00000040] flex items-center justify-center',
|
||||||
|
className?.outer
|
||||||
|
)}
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
className={cn(
|
||||||
|
'w-9.5 h-9.5 bg-primary rounded-lg border border-primary flex items-center justify-center shadow-[inset_0px_4px_4px_0px_#FFFFFF80,inset_0px_2px_0px_0px_#FFFFFF80]',
|
||||||
|
className?.inner
|
||||||
|
)}
|
||||||
|
>
|
||||||
|
{children}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default IconSkeleton;
|
||||||
@@ -113,7 +113,15 @@ const DateInput = ({
|
|||||||
};
|
};
|
||||||
|
|
||||||
const handleSelectSingle = (selectedDate?: Date) => {
|
const handleSelectSingle = (selectedDate?: Date) => {
|
||||||
if (!selectedDate) return;
|
if (!selectedDate) {
|
||||||
|
setSelected(undefined);
|
||||||
|
setDisplayValue('');
|
||||||
|
const syntheticEvent = {
|
||||||
|
target: { name, value: '' },
|
||||||
|
} as unknown as React.ChangeEvent<HTMLInputElement>;
|
||||||
|
onChange?.(syntheticEvent);
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (minDate && selectedDate < minDate) {
|
if (minDate && selectedDate < minDate) {
|
||||||
setInternalError(`Tanggal tidak boleh sebelum ${min}`);
|
setInternalError(`Tanggal tidak boleh sebelum ${min}`);
|
||||||
return;
|
return;
|
||||||
@@ -136,7 +144,15 @@ const DateInput = ({
|
|||||||
};
|
};
|
||||||
|
|
||||||
const handleSelectRange = (range?: { from?: Date; to?: Date }) => {
|
const handleSelectRange = (range?: { from?: Date; to?: Date }) => {
|
||||||
if (!range) return;
|
if (!range) {
|
||||||
|
setSelectedRange({});
|
||||||
|
setDisplayValue('');
|
||||||
|
const syntheticEvent = {
|
||||||
|
target: { name, value: { from: '', to: '' } },
|
||||||
|
} as unknown as React.ChangeEvent<HTMLInputElement>;
|
||||||
|
onChange?.(syntheticEvent);
|
||||||
|
return;
|
||||||
|
}
|
||||||
setSelectedRange(range);
|
setSelectedRange(range);
|
||||||
|
|
||||||
const fromStr = range.from ? formatDate(range.from, 'DD/MM/YYYY') : '';
|
const fromStr = range.from ? formatDate(range.from, 'DD/MM/YYYY') : '';
|
||||||
@@ -188,17 +204,12 @@ const DateInput = ({
|
|||||||
const finalErrorMessage = internalError || externalErrorMessage;
|
const finalErrorMessage = internalError || externalErrorMessage;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div className={cn('w-full flex flex-col text-start', className?.wrapper)}>
|
||||||
className={cn(
|
|
||||||
'w-full flex flex-col gap-2 text-start',
|
|
||||||
className?.wrapper
|
|
||||||
)}
|
|
||||||
>
|
|
||||||
{label && (
|
{label && (
|
||||||
<label
|
<label
|
||||||
htmlFor={name}
|
htmlFor={name}
|
||||||
className={cn(
|
className={cn(
|
||||||
'w-full text-sm font-normal leading-5',
|
'w-full py-2 text-xs font-semibold leading-5',
|
||||||
{ 'text-error': finalIsError },
|
{ 'text-error': finalIsError },
|
||||||
className?.label
|
className?.label
|
||||||
)}
|
)}
|
||||||
@@ -215,7 +226,7 @@ const DateInput = ({
|
|||||||
|
|
||||||
<div
|
<div
|
||||||
className={cn(
|
className={cn(
|
||||||
'input h-12 bg-inherit px-4 py-2 text-base font-normal leading-6 w-full rounded transition-all duration-200 flex items-center border',
|
'input h-fit bg-inherit px-3 py-2.5 text-base font-normal leading-6 w-full rounded-lg transition-all duration-200 flex items-center border border-base-content/10',
|
||||||
{
|
{
|
||||||
'border-error': finalIsError,
|
'border-error': finalIsError,
|
||||||
'border-success': externalValid && !finalIsError,
|
'border-success': externalValid && !finalIsError,
|
||||||
@@ -234,7 +245,10 @@ const DateInput = ({
|
|||||||
disabled={disabled}
|
disabled={disabled}
|
||||||
readOnly // ✅ tidak bisa diketik manual
|
readOnly // ✅ tidak bisa diketik manual
|
||||||
className={cn(
|
className={cn(
|
||||||
'grow bg-transparent cursor-pointer focus:outline-none',
|
'grow bg-transparent cursor-pointer focus:outline-none text-sm leading-tight',
|
||||||
|
{
|
||||||
|
'cursor-not-allowed': readOnly,
|
||||||
|
},
|
||||||
className?.input
|
className?.input
|
||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
@@ -245,10 +259,10 @@ const DateInput = ({
|
|||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
<Icon
|
<Icon
|
||||||
icon='uil:calendar'
|
icon='heroicons:calendar-date-range'
|
||||||
width={24}
|
width={15}
|
||||||
height={24}
|
height={15}
|
||||||
className='cursor-pointer text-dark'
|
className='cursor-pointer text-base-content/20'
|
||||||
onClick={(e) =>
|
onClick={(e) =>
|
||||||
handleClick(e as unknown as React.MouseEvent<HTMLInputElement>)
|
handleClick(e as unknown as React.MouseEvent<HTMLInputElement>)
|
||||||
}
|
}
|
||||||
@@ -256,17 +270,17 @@ const DateInput = ({
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
{!finalIsError && bottomLabel && (
|
{!finalIsError && bottomLabel && (
|
||||||
<p className='w-full text-sm opacity-60'>{bottomLabel}</p>
|
<p className='w-full mt-1.5 text-xs opacity-60'>{bottomLabel}</p>
|
||||||
)}
|
)}
|
||||||
{finalIsError && finalErrorMessage && (
|
{finalIsError && finalErrorMessage && (
|
||||||
<p className='w-full text-sm text-error'>{finalErrorMessage}</p>
|
<p className='w-full mt-1.5 text-xs text-error'>{finalErrorMessage}</p>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
<Modal
|
<Modal
|
||||||
ref={calendarModal.ref}
|
ref={calendarModal.ref}
|
||||||
className={{
|
className={{
|
||||||
modal: 'rounded',
|
modal: 'rounded',
|
||||||
modalBox: `!max-w-max min-h-${isRange ? '124' : '110'} flex flex-col`,
|
modalBox: `max-w-max flex flex-col`,
|
||||||
}}
|
}}
|
||||||
closeOnBackdrop
|
closeOnBackdrop
|
||||||
>
|
>
|
||||||
@@ -282,7 +296,11 @@ const DateInput = ({
|
|||||||
endMonth={maxDate ?? new Date(new Date().getFullYear() + 5, 11)}
|
endMonth={maxDate ?? new Date(new Date().getFullYear() + 5, 11)}
|
||||||
selected={selectedRange as DateRange}
|
selected={selectedRange as DateRange}
|
||||||
onSelect={handleSelectRange}
|
onSelect={handleSelectRange}
|
||||||
footer={<div className='text-center mt-3'>{displayValue}</div>}
|
footer={
|
||||||
|
<div className='text-center py-2 text-base-content/65 font-semibold text-xs'>
|
||||||
|
{displayValue}
|
||||||
|
</div>
|
||||||
|
}
|
||||||
disabled={
|
disabled={
|
||||||
[
|
[
|
||||||
minDate ? { before: minDate } : undefined,
|
minDate ? { before: minDate } : undefined,
|
||||||
@@ -312,17 +330,26 @@ const DateInput = ({
|
|||||||
)}
|
)}
|
||||||
<div className='mt-auto flex flex-col gap-2'>
|
<div className='mt-auto flex flex-col gap-2'>
|
||||||
{isRange && (
|
{isRange && (
|
||||||
<small className='text-secondary'>
|
<small className='text-base-content/65'>
|
||||||
Tekan dua kali untuk memilih tanggal awal
|
Tekan dua kali untuk reset tanggal awal
|
||||||
</small>
|
</small>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
<div className='flex h-full justify-end items-end gap-2'>
|
<div className='flex h-full justify-end items-end gap-1.5 mt-3'>
|
||||||
<Button type='button' color='warning' onClick={handleResetDate}>
|
<Button
|
||||||
|
type='button'
|
||||||
|
color='none'
|
||||||
|
className='bg-transparent hover:bg-base-content/10 border-none text-base text-base-content/65 px-3'
|
||||||
|
onClick={handleResetDate}
|
||||||
|
>
|
||||||
Reset
|
Reset
|
||||||
</Button>
|
</Button>
|
||||||
{isRange && (
|
{isRange && (
|
||||||
<Button type='button' onClick={handleSaveDate}>
|
<Button
|
||||||
|
type='button'
|
||||||
|
className='rounded-lg px-3 py-2 text-white'
|
||||||
|
onClick={handleSaveDate}
|
||||||
|
>
|
||||||
Simpan
|
Simpan
|
||||||
</Button>
|
</Button>
|
||||||
)}
|
)}
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import TextArea, { TextAreaProps } from '@/components/input/TextArea';
|
|||||||
|
|
||||||
interface DebouncedTextAreaProps extends TextAreaProps {
|
interface DebouncedTextAreaProps extends TextAreaProps {
|
||||||
delay?: number;
|
delay?: number;
|
||||||
|
ref?: React.RefObject<HTMLTextAreaElement | null>;
|
||||||
}
|
}
|
||||||
|
|
||||||
const DebouncedTextArea = (props: DebouncedTextAreaProps) => {
|
const DebouncedTextArea = (props: DebouncedTextAreaProps) => {
|
||||||
@@ -19,6 +20,11 @@ const DebouncedTextArea = (props: DebouncedTextAreaProps) => {
|
|||||||
const [debouncedChangeEvent] = useDebounce(internalChangeEvent, delay ?? 300);
|
const [debouncedChangeEvent] = useDebounce(internalChangeEvent, delay ?? 300);
|
||||||
const [debouncedValue] = useDebounce(internalValue, delay ?? 300);
|
const [debouncedValue] = useDebounce(internalValue, delay ?? 300);
|
||||||
|
|
||||||
|
// Sync internal value with external props.value when it changes (e.g., form reset)
|
||||||
|
useEffect(() => {
|
||||||
|
setInternalValue(props.value);
|
||||||
|
}, [props.value]);
|
||||||
|
|
||||||
const internalChangeHandler: ChangeEventHandler<HTMLTextAreaElement> = (
|
const internalChangeHandler: ChangeEventHandler<HTMLTextAreaElement> = (
|
||||||
e
|
e
|
||||||
) => {
|
) => {
|
||||||
@@ -35,6 +41,7 @@ const DebouncedTextArea = (props: DebouncedTextAreaProps) => {
|
|||||||
return (
|
return (
|
||||||
<TextArea
|
<TextArea
|
||||||
{...props}
|
{...props}
|
||||||
|
ref={props.ref}
|
||||||
value={internalValue}
|
value={internalValue}
|
||||||
onChange={internalChangeHandler}
|
onChange={internalChangeHandler}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -134,14 +134,20 @@ const DropFileInput: React.FC<DropFileInputProps> = ({
|
|||||||
|
|
||||||
{!isError && bottomLabel && (
|
{!isError && bottomLabel && (
|
||||||
<p
|
<p
|
||||||
className={cn('w-full text-sm opacity-60', className?.bottomLabel)}
|
className={cn(
|
||||||
|
'w-full mt-1.5 text-xs opacity-60',
|
||||||
|
className?.bottomLabel
|
||||||
|
)}
|
||||||
>
|
>
|
||||||
{bottomLabel}
|
{bottomLabel}
|
||||||
</p>
|
</p>
|
||||||
)}
|
)}
|
||||||
{isError && (
|
{isError && (
|
||||||
<p
|
<p
|
||||||
className={cn('w-full text-sm text-error', className?.errorMessage)}
|
className={cn(
|
||||||
|
'w-full mt-1.5 text-xs text-error',
|
||||||
|
className?.errorMessage
|
||||||
|
)}
|
||||||
>
|
>
|
||||||
{errorMessage}
|
{errorMessage}
|
||||||
</p>
|
</p>
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ const FileInput = ({
|
|||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
className={cn(
|
className={cn(
|
||||||
'w-full flex flex-col gap-2 text-start',
|
'w-full flex flex-col gap-0 text-start rounded-lg',
|
||||||
className?.wrapper
|
className?.wrapper
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
@@ -49,7 +49,7 @@ const FileInput = ({
|
|||||||
<label
|
<label
|
||||||
htmlFor={name}
|
htmlFor={name}
|
||||||
className={cn(
|
className={cn(
|
||||||
'w-full text-sm font-normal leading-5',
|
'w-full py-2 text-xs font-semibold leading-5',
|
||||||
{
|
{
|
||||||
'text-error': isError,
|
'text-error': isError,
|
||||||
},
|
},
|
||||||
@@ -77,15 +77,19 @@ const FileInput = ({
|
|||||||
onChange={onChange}
|
onChange={onChange}
|
||||||
onBlur={onBlur}
|
onBlur={onBlur}
|
||||||
disabled={disabled}
|
disabled={disabled}
|
||||||
className={cn('grow file-input w-full h-12 rounded', className?.input)}
|
className={cn(
|
||||||
|
'grow file-input w-full h-fit px-3 py-1.5 text-sm font-normal leading-6 rounded-lg! outline-none! transition-all duration-200 bg-white border-base-content/10',
|
||||||
|
className?.input
|
||||||
|
)}
|
||||||
readOnly={readOnly}
|
readOnly={readOnly}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
{bottomLabel && (
|
{!isError && bottomLabel && (
|
||||||
<p className='w-full text-sm opacity-60'>{bottomLabel}</p>
|
<p className='w-full mt-1.5 text-xs opacity-60'>{bottomLabel}</p>
|
||||||
|
)}
|
||||||
|
{isError && errorMessage && (
|
||||||
|
<p className='w-full mt-1.5 text-xs text-error'>{errorMessage}</p>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{isError && <p className='w-full text-sm text-error'>{errorMessage}</p>}
|
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ import { ChangeEvent } from 'react';
|
|||||||
import {
|
import {
|
||||||
PatternFormat,
|
PatternFormat,
|
||||||
NumberFormatBase,
|
NumberFormatBase,
|
||||||
NumberFormatBaseProps,
|
|
||||||
OnValueChange,
|
OnValueChange,
|
||||||
} from 'react-number-format';
|
} from 'react-number-format';
|
||||||
import TextInput, { TextInputProps } from '@/components/input/TextInput';
|
import TextInput, { TextInputProps } from '@/components/input/TextInput';
|
||||||
|
|||||||
@@ -144,12 +144,12 @@ export const RadioGroup = ({
|
|||||||
|
|
||||||
{/* Label bawah */}
|
{/* Label bawah */}
|
||||||
{!isError && bottomLabel && (
|
{!isError && bottomLabel && (
|
||||||
<p className='text-sm opacity-60'>{bottomLabel}</p>
|
<p className='mt-1.5 text-xs opacity-60'>{bottomLabel}</p>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{/* Pesan error */}
|
{/* Pesan error */}
|
||||||
{isError && errorMessage && (
|
{isError && errorMessage && (
|
||||||
<p className='text-sm text-error'>{errorMessage}</p>
|
<p className='mt-1.5 text-xs text-error'>{errorMessage}</p>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
</RadioGroupContext.Provider>
|
</RadioGroupContext.Provider>
|
||||||
|
|||||||
@@ -9,18 +9,23 @@ import Select, {
|
|||||||
SingleValue,
|
SingleValue,
|
||||||
components as ReactSelectComponents,
|
components as ReactSelectComponents,
|
||||||
ControlProps,
|
ControlProps,
|
||||||
|
MenuListProps,
|
||||||
} from 'react-select';
|
} from 'react-select';
|
||||||
import CreatableSelect from 'react-select/creatable';
|
import CreatableSelect from 'react-select/creatable';
|
||||||
import makeAnimated from 'react-select/animated';
|
import makeAnimated from 'react-select/animated';
|
||||||
import { useDebounce } from 'use-debounce';
|
import { useDebounce } from 'use-debounce';
|
||||||
import { cn, getByPath } from '@/lib/helper';
|
import { cn, getByPath } from '@/lib/helper';
|
||||||
import useSWR from 'swr';
|
import useSWRInfinite from 'swr/infinite';
|
||||||
import { httpClientFetcher } from '@/services/http/client';
|
import { httpClientFetcher } from '@/services/http/client';
|
||||||
import { BaseApiResponse } from '@/types/api/api-general';
|
import {
|
||||||
import { isResponseSuccess } from '@/lib/api-helper';
|
BaseApiResponse,
|
||||||
|
ErrorApiResponse,
|
||||||
|
SuccessApiResponse,
|
||||||
|
} from '@/types/api/api-general';
|
||||||
|
import { isResponseError, isResponseSuccess } from '@/lib/api-helper';
|
||||||
|
|
||||||
export interface OptionType {
|
export interface OptionType<T = string | number> {
|
||||||
value: string | number;
|
value: T;
|
||||||
label: string;
|
label: string;
|
||||||
className?: string;
|
className?: string;
|
||||||
labelClassName?: string;
|
labelClassName?: string;
|
||||||
@@ -35,7 +40,9 @@ interface SelectInputBaseProps<T = OptionType> {
|
|||||||
bottomLabel?: ReactNode;
|
bottomLabel?: ReactNode;
|
||||||
options: T[];
|
options: T[];
|
||||||
optionComponent?: OptionComponent<T>;
|
optionComponent?: OptionComponent<T>;
|
||||||
|
components?: Partial<typeof ReactSelectComponents>;
|
||||||
isDisabled?: boolean;
|
isDisabled?: boolean;
|
||||||
|
readOnly?: boolean;
|
||||||
isLoading?: boolean;
|
isLoading?: boolean;
|
||||||
isClearable?: boolean;
|
isClearable?: boolean;
|
||||||
isRtl?: boolean;
|
isRtl?: boolean;
|
||||||
@@ -47,6 +54,9 @@ interface SelectInputBaseProps<T = OptionType> {
|
|||||||
wrapper?: string;
|
wrapper?: string;
|
||||||
label?: string;
|
label?: string;
|
||||||
select?: string;
|
select?: string;
|
||||||
|
inputPrefix?: string;
|
||||||
|
inputSuffix?: string;
|
||||||
|
inputPrefixSuffixWrapper?: string;
|
||||||
};
|
};
|
||||||
isError?: boolean;
|
isError?: boolean;
|
||||||
errorMessage?: string;
|
errorMessage?: string;
|
||||||
@@ -55,10 +65,16 @@ interface SelectInputBaseProps<T = OptionType> {
|
|||||||
delay?: number;
|
delay?: number;
|
||||||
onInputChange?: (search: string) => void;
|
onInputChange?: (search: string) => void;
|
||||||
startAdornment?: ReactNode;
|
startAdornment?: ReactNode;
|
||||||
|
inputPrefix?: ReactNode;
|
||||||
|
inputSuffix?: ReactNode;
|
||||||
menuPortalTarget?: HTMLElement | null;
|
menuPortalTarget?: HTMLElement | null;
|
||||||
|
closeMenuOnSelect?: boolean;
|
||||||
|
hideSelectedOptions?: boolean;
|
||||||
|
onMenuScrollToBottom?: ((event: WheelEvent | TouchEvent) => void) | undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface SelectInputProps<T = OptionType> extends SelectInputBaseProps<T> {
|
export interface SelectInputProps<T = OptionType>
|
||||||
|
extends SelectInputBaseProps<T> {
|
||||||
createables?: boolean;
|
createables?: boolean;
|
||||||
value?: T | T[] | null;
|
value?: T | T[] | null;
|
||||||
onChange?: (val: T | T[] | null) => void;
|
onChange?: (val: T | T[] | null) => void;
|
||||||
@@ -73,7 +89,7 @@ const CustomControl = <
|
|||||||
>(
|
>(
|
||||||
props: ControlProps<Option, IsMulti, Group>
|
props: ControlProps<Option, IsMulti, Group>
|
||||||
) => {
|
) => {
|
||||||
const { children } = props;
|
const { children, innerProps } = props;
|
||||||
|
|
||||||
const customProps = props.selectProps as unknown as {
|
const customProps = props.selectProps as unknown as {
|
||||||
shouldShowAdornment?: boolean;
|
shouldShowAdornment?: boolean;
|
||||||
@@ -85,7 +101,7 @@ const CustomControl = <
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<ReactSelectComponents.Control {...props}>
|
<ReactSelectComponents.Control {...props}>
|
||||||
<div className='flex-1 px-4! py-1.5 gap-1 flex items-center'>
|
<div className='flex-1 pl-3 gap-1 flex items-center' {...innerProps}>
|
||||||
{shouldShowAdornment && startAdornment}
|
{shouldShowAdornment && startAdornment}
|
||||||
{children}
|
{children}
|
||||||
</div>
|
</div>
|
||||||
@@ -93,6 +109,29 @@ const CustomControl = <
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const CustomMenuList = <
|
||||||
|
Option,
|
||||||
|
IsMulti extends boolean,
|
||||||
|
Group extends GroupBase<Option>,
|
||||||
|
>(
|
||||||
|
props: MenuListProps<Option, IsMulti, Group>
|
||||||
|
) => {
|
||||||
|
const { children, selectProps, options } = props;
|
||||||
|
const { isLoading } = selectProps;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<ReactSelectComponents.MenuList {...props}>
|
||||||
|
{children}
|
||||||
|
|
||||||
|
{options.length > 0 && isLoading && (
|
||||||
|
<div className='px-3 py-2 rounded-md text-center text-gray-400'>
|
||||||
|
<span className='loading loading-spinner loading-md' />
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</ReactSelectComponents.MenuList>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
const SelectInput = <T extends OptionType>(props: SelectInputProps<T>) => {
|
const SelectInput = <T extends OptionType>(props: SelectInputProps<T>) => {
|
||||||
const {
|
const {
|
||||||
label,
|
label,
|
||||||
@@ -101,6 +140,7 @@ const SelectInput = <T extends OptionType>(props: SelectInputProps<T>) => {
|
|||||||
onChange,
|
onChange,
|
||||||
options,
|
options,
|
||||||
optionComponent,
|
optionComponent,
|
||||||
|
components: customComponents,
|
||||||
isDisabled,
|
isDisabled,
|
||||||
isLoading,
|
isLoading,
|
||||||
isClearable,
|
isClearable,
|
||||||
@@ -118,7 +158,13 @@ const SelectInput = <T extends OptionType>(props: SelectInputProps<T>) => {
|
|||||||
createables = false,
|
createables = false,
|
||||||
onInputChange,
|
onInputChange,
|
||||||
startAdornment,
|
startAdornment,
|
||||||
|
inputPrefix,
|
||||||
|
inputSuffix,
|
||||||
menuPortalTarget,
|
menuPortalTarget,
|
||||||
|
closeMenuOnSelect,
|
||||||
|
hideSelectedOptions,
|
||||||
|
onMenuScrollToBottom,
|
||||||
|
readOnly,
|
||||||
} = props;
|
} = props;
|
||||||
|
|
||||||
const [internalInputValue, setInternalInputValue] = useState('');
|
const [internalInputValue, setInternalInputValue] = useState('');
|
||||||
@@ -128,14 +174,18 @@ const SelectInput = <T extends OptionType>(props: SelectInputProps<T>) => {
|
|||||||
|
|
||||||
const components = useMemo(() => {
|
const components = useMemo(() => {
|
||||||
const base = isAnimated ? animatedComponents : {};
|
const base = isAnimated ? animatedComponents : {};
|
||||||
const customComponents = { ...base, IndicatorSeparator: () => null };
|
const mergedComponents = { ...base, IndicatorSeparator: () => null };
|
||||||
|
|
||||||
if (startAdornment) {
|
if (startAdornment) {
|
||||||
customComponents.Control = CustomControl;
|
mergedComponents.Control = CustomControl;
|
||||||
}
|
}
|
||||||
|
|
||||||
return customComponents;
|
if (customComponents) {
|
||||||
}, [isAnimated, startAdornment]);
|
Object.assign(mergedComponents, customComponents);
|
||||||
|
}
|
||||||
|
|
||||||
|
return mergedComponents;
|
||||||
|
}, [isAnimated, startAdornment, customComponents]);
|
||||||
|
|
||||||
const internalInputChangeHandler = (val: string, meta: InputActionMeta) => {
|
const internalInputChangeHandler = (val: string, meta: InputActionMeta) => {
|
||||||
if (meta.action === 'input-change') setInternalInputValue(val);
|
if (meta.action === 'input-change') setInternalInputValue(val);
|
||||||
@@ -163,16 +213,11 @@ const SelectInput = <T extends OptionType>(props: SelectInputProps<T>) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div className={cn('w-full flex flex-col text-start', className?.wrapper)}>
|
||||||
className={cn(
|
|
||||||
'w-full flex flex-col gap-2 text-start',
|
|
||||||
className?.wrapper
|
|
||||||
)}
|
|
||||||
>
|
|
||||||
{label && (
|
{label && (
|
||||||
<span
|
<span
|
||||||
className={cn(
|
className={cn(
|
||||||
'w-full text-sm font-normal leading-5',
|
'w-full py-2 text-xs font-semibold leading-5',
|
||||||
{ 'text-error': isError },
|
{ 'text-error': isError },
|
||||||
className?.label
|
className?.label
|
||||||
)}
|
)}
|
||||||
@@ -189,98 +234,272 @@ const SelectInput = <T extends OptionType>(props: SelectInputProps<T>) => {
|
|||||||
</span>
|
</span>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
<SelectComponent<T, boolean, GroupBase<T>>
|
{inputPrefix || inputSuffix ? (
|
||||||
instanceId='select'
|
<div
|
||||||
value={value ?? (isMulti ? [] : null)}
|
className={cn(
|
||||||
onChange={onChange ? handleChange : undefined}
|
'relative flex text-sm',
|
||||||
options={options}
|
className?.inputPrefixSuffixWrapper
|
||||||
menuIsOpen={openMenu}
|
)}
|
||||||
inputValue={internalInputValue}
|
>
|
||||||
onInputChange={internalInputChangeHandler}
|
{inputPrefix && (
|
||||||
onMenuClose={() => setInternalInputValue('')}
|
<div
|
||||||
isMulti={isMulti}
|
className={cn(
|
||||||
isDisabled={isDisabled}
|
'inline-flex items-center px-3 border border-r-0 border-base-content/10 rounded-l-lg transition-all duration-200',
|
||||||
isLoading={isLoading}
|
|
||||||
isClearable={isClearable}
|
|
||||||
isRtl={isRtl}
|
|
||||||
isSearchable={isSearchable}
|
|
||||||
placeholder={placeholder}
|
|
||||||
className={cn('w-full', className?.select)}
|
|
||||||
classNames={{
|
|
||||||
...(!startAdornment && {
|
|
||||||
control: ({ isFocused, isDisabled }) =>
|
|
||||||
cn(
|
|
||||||
'w-full min-h-12! rounded border bg-white transition-shadow cursor-pointer!',
|
|
||||||
{
|
{
|
||||||
'border-red-500! ring-2 ring-red-200': isError,
|
'bg-base-100 border-base-content/10': !isDisabled,
|
||||||
'border-indigo-500 ring-2 ring-indigo-200': isFocused,
|
'bg-base-200 border-base-content/10': isDisabled,
|
||||||
'border-gray-300': !isError && !isFocused,
|
'border-error': isError,
|
||||||
'bg-gray-100 text-gray-400 cursor-not-allowed': isDisabled,
|
},
|
||||||
}
|
className?.inputPrefix
|
||||||
),
|
)}
|
||||||
valueContainer: () => cn('flex-1 px-4! py-2! gap-1'),
|
>
|
||||||
}),
|
{inputPrefix}
|
||||||
placeholder: () =>
|
</div>
|
||||||
cn({ 'text-gray-400': !isError, 'text-red-300!': isError }),
|
)}
|
||||||
singleValue: () =>
|
|
||||||
cn({ 'text-gray-900': !isError, 'text-error!': isError }),
|
|
||||||
input: () => cn('text-gray-900'),
|
|
||||||
indicatorsContainer: () => cn('flex items-center gap-1 pr-2'),
|
|
||||||
dropdownIndicator: ({ isFocused }) =>
|
|
||||||
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! bg-base-100 shadow-lg!'),
|
|
||||||
menuList: () => cn('p-2! max-h-60 overflow-auto'),
|
|
||||||
option: ({ isFocused, isSelected }) =>
|
|
||||||
cn('mt-1 px-3 py-2 rounded-md cursor-pointer!', {
|
|
||||||
'bg-indigo-600 text-white': isFocused,
|
|
||||||
'bg-blue-500!': isSelected,
|
|
||||||
'text-gray-700': !isFocused && !isSelected,
|
|
||||||
}),
|
|
||||||
multiValue: ({ getValue, index }) => {
|
|
||||||
const selectedValues = getValue() as T[];
|
|
||||||
return cn(
|
|
||||||
'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() as T[];
|
|
||||||
return cn('text-indigo-700', selectedValues[index]?.labelClassName);
|
|
||||||
},
|
|
||||||
}}
|
|
||||||
components={{
|
|
||||||
...components,
|
|
||||||
...(optionComponent ? { Option: optionComponent } : {}),
|
|
||||||
}}
|
|
||||||
{...(startAdornment && {
|
|
||||||
shouldShowAdornment,
|
|
||||||
startAdornment,
|
|
||||||
})}
|
|
||||||
menuPortalTarget={
|
|
||||||
typeof document !== 'undefined'
|
|
||||||
? (menuPortalTarget ?? document.body)
|
|
||||||
: undefined
|
|
||||||
}
|
|
||||||
styles={{
|
|
||||||
menuPortal: (base) => ({ ...base, zIndex: 9999 }),
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
|
|
||||||
{isError && <p className='w-full text-sm text-error'>{errorMessage}</p>}
|
<SelectComponent<T, boolean, GroupBase<T>>
|
||||||
|
instanceId='select'
|
||||||
|
value={value ?? (isMulti ? [] : null)}
|
||||||
|
onChange={onChange ? handleChange : undefined}
|
||||||
|
options={options}
|
||||||
|
menuIsOpen={openMenu}
|
||||||
|
inputValue={internalInputValue}
|
||||||
|
onInputChange={internalInputChangeHandler}
|
||||||
|
onMenuClose={() => setInternalInputValue('')}
|
||||||
|
isMulti={isMulti}
|
||||||
|
isDisabled={isDisabled || readOnly}
|
||||||
|
isLoading={isLoading}
|
||||||
|
isClearable={isClearable}
|
||||||
|
isRtl={isRtl}
|
||||||
|
isSearchable={isSearchable}
|
||||||
|
placeholder={placeholder}
|
||||||
|
closeMenuOnSelect={closeMenuOnSelect}
|
||||||
|
hideSelectedOptions={hideSelectedOptions}
|
||||||
|
className={cn('w-full flex-1', className?.select)}
|
||||||
|
classNames={{
|
||||||
|
control: ({ isFocused, isDisabled }) =>
|
||||||
|
cn('w-full border transition-shadow', 'rounded-lg!', {
|
||||||
|
'bg-base-100!': !isDisabled && !readOnly,
|
||||||
|
'bg-base-200! text-gray-400 cursor-not-allowed':
|
||||||
|
isDisabled && !readOnly,
|
||||||
|
'bg-transparent! cursor-not-allowed!': readOnly,
|
||||||
|
'cursor-pointer!': !readOnly && !isDisabled,
|
||||||
|
'border-error!': isError,
|
||||||
|
'ring-2 ring-error/20': isError,
|
||||||
|
'border-indigo-500 ring-2 ring-indigo-200':
|
||||||
|
isFocused && !startAdornment && !isError,
|
||||||
|
'border-base-content/10!': !isError && !isFocused,
|
||||||
|
'rounded-l-none!': inputPrefix && !startAdornment,
|
||||||
|
'rounded-r-none!': inputSuffix && !startAdornment,
|
||||||
|
}),
|
||||||
|
valueContainer: () => cn('flex-1 px-3! pr-2! py-2.5! gap-1'),
|
||||||
|
placeholder: () =>
|
||||||
|
cn('text-gray-400 text-sm leading-tight', {
|
||||||
|
'text-error!': isError,
|
||||||
|
}),
|
||||||
|
singleValue: () =>
|
||||||
|
cn('m-0! text-gray-900 text-sm leading-tight', {
|
||||||
|
'text-error!': isError && !readOnly,
|
||||||
|
'text-gray-900!': readOnly,
|
||||||
|
}),
|
||||||
|
input: () => cn('text-gray-900 m-0! p-0! text-sm leading-tight'),
|
||||||
|
indicatorsContainer: () =>
|
||||||
|
cn('flex items-center gap-1 pr-3 py-2'),
|
||||||
|
dropdownIndicator: ({ isFocused }) =>
|
||||||
|
cn('p-0! rounded hover:bg-gray-100', {
|
||||||
|
'text-gray-900': isFocused,
|
||||||
|
'text-gray-500': !isFocused,
|
||||||
|
'text-error!': isError,
|
||||||
|
}),
|
||||||
|
clearIndicator: () => cn('p-0! rounded hover:bg-gray-100'),
|
||||||
|
menu: () =>
|
||||||
|
cn(
|
||||||
|
'border border-base-content/5 rounded-xl! bg-base-100 shadow-lg! my-1.5!'
|
||||||
|
),
|
||||||
|
menuList: () => cn('p-0! max-h-60 overflow-auto'),
|
||||||
|
option: ({ isFocused, isSelected }) =>
|
||||||
|
cn('px-3 py-2 rounded-md cursor-pointer!', {
|
||||||
|
'bg-indigo-600 text-white': isFocused,
|
||||||
|
'bg-blue-500!': isSelected,
|
||||||
|
'text-gray-700': !isFocused && !isSelected,
|
||||||
|
}),
|
||||||
|
multiValue: ({ getValue, index }) => {
|
||||||
|
const selectedValues = getValue() as T[];
|
||||||
|
return cn(
|
||||||
|
'bg-base-200! rounded-lg! py-[3px] px-2.5 m-0! flex items-center gap-1! w-fit gap-2!',
|
||||||
|
selectedValues[index]?.className
|
||||||
|
);
|
||||||
|
},
|
||||||
|
multiValueRemove: () => cn('p-0! w-3 h-3'),
|
||||||
|
multiValueLabel: ({ getValue, index }) => {
|
||||||
|
const selectedValues = getValue() as T[];
|
||||||
|
return cn(
|
||||||
|
'p-0! text-base-content! text-xs!',
|
||||||
|
selectedValues[index]?.labelClassName
|
||||||
|
);
|
||||||
|
},
|
||||||
|
}}
|
||||||
|
components={{
|
||||||
|
...components,
|
||||||
|
...(optionComponent ? { Option: optionComponent } : {}),
|
||||||
|
MenuList: CustomMenuList,
|
||||||
|
}}
|
||||||
|
{...(startAdornment && {
|
||||||
|
shouldShowAdornment,
|
||||||
|
startAdornment,
|
||||||
|
})}
|
||||||
|
menuPortalTarget={
|
||||||
|
typeof document !== 'undefined'
|
||||||
|
? (menuPortalTarget ?? document.body)
|
||||||
|
: undefined
|
||||||
|
}
|
||||||
|
styles={{
|
||||||
|
menuPortal: (base) => ({ ...base, zIndex: 9999 }),
|
||||||
|
multiValue(base) {
|
||||||
|
return {
|
||||||
|
...base,
|
||||||
|
borderRadius: '8px',
|
||||||
|
};
|
||||||
|
},
|
||||||
|
}}
|
||||||
|
onMenuScrollToBottom={onMenuScrollToBottom}
|
||||||
|
/>
|
||||||
|
|
||||||
|
{inputSuffix && (
|
||||||
|
<div
|
||||||
|
className={cn(
|
||||||
|
'inline-flex items-center px-3 border border-l-0 border-base-content/10 rounded-r-lg transition-all duration-200',
|
||||||
|
{
|
||||||
|
'bg-base-100 border-base-content/10': !isDisabled,
|
||||||
|
'bg-base-200 border-base-content/10': isDisabled,
|
||||||
|
'border-error': isError,
|
||||||
|
},
|
||||||
|
className?.inputSuffix
|
||||||
|
)}
|
||||||
|
>
|
||||||
|
{inputSuffix}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
) : (
|
||||||
|
<SelectComponent<T, boolean, GroupBase<T>>
|
||||||
|
instanceId='select'
|
||||||
|
value={value ?? (isMulti ? [] : null)}
|
||||||
|
onChange={onChange ? handleChange : undefined}
|
||||||
|
options={options}
|
||||||
|
menuIsOpen={openMenu}
|
||||||
|
inputValue={internalInputValue}
|
||||||
|
onInputChange={internalInputChangeHandler}
|
||||||
|
onMenuClose={() => setInternalInputValue('')}
|
||||||
|
isMulti={isMulti}
|
||||||
|
isDisabled={isDisabled || readOnly}
|
||||||
|
isLoading={isLoading}
|
||||||
|
isClearable={isClearable}
|
||||||
|
isRtl={isRtl}
|
||||||
|
isSearchable={isSearchable}
|
||||||
|
placeholder={placeholder}
|
||||||
|
closeMenuOnSelect={closeMenuOnSelect}
|
||||||
|
hideSelectedOptions={hideSelectedOptions}
|
||||||
|
className={cn('w-full', className?.select)}
|
||||||
|
classNames={{
|
||||||
|
control: ({ isFocused, isDisabled }) =>
|
||||||
|
cn('w-full border transition-shadow rounded-lg!', {
|
||||||
|
'bg-base-100!': !isDisabled && !readOnly,
|
||||||
|
'bg-base-200! text-gray-400 cursor-not-allowed':
|
||||||
|
isDisabled && !readOnly,
|
||||||
|
'bg-transparent! cursor-not-allowed!': readOnly,
|
||||||
|
'cursor-pointer!': !readOnly && !isDisabled,
|
||||||
|
'border-error!': isError,
|
||||||
|
'ring-2 ring-error/20': isError,
|
||||||
|
'border-indigo-500 ring-2 ring-indigo-200':
|
||||||
|
isFocused && !startAdornment && !isError,
|
||||||
|
'border-base-content/10!': !isError && !isFocused,
|
||||||
|
}),
|
||||||
|
valueContainer: () => cn('flex-1 px-3! pr-2! py-2.5! gap-1'),
|
||||||
|
placeholder: () =>
|
||||||
|
cn('text-gray-400 text-sm leading-tight', {
|
||||||
|
'text-error!': isError,
|
||||||
|
}),
|
||||||
|
singleValue: () =>
|
||||||
|
cn('m-0! text-gray-900 text-sm leading-tight', {
|
||||||
|
'text-error!': isError && !readOnly,
|
||||||
|
'text-gray-900!': readOnly,
|
||||||
|
}),
|
||||||
|
input: () => cn('text-gray-900 m-0! p-0! text-sm leading-tight'),
|
||||||
|
indicatorsContainer: () => cn('flex items-center gap-1 pr-3 py-2'),
|
||||||
|
dropdownIndicator: ({ isFocused }) =>
|
||||||
|
cn('p-0! rounded hover:bg-gray-100', {
|
||||||
|
'text-gray-900': isFocused,
|
||||||
|
'text-gray-500': !isFocused,
|
||||||
|
'text-error!': isError,
|
||||||
|
}),
|
||||||
|
clearIndicator: () => cn('p-0! rounded hover:bg-gray-100'),
|
||||||
|
menu: () =>
|
||||||
|
cn(
|
||||||
|
'border border-base-content/5 rounded-xl! bg-base-100 shadow-lg! my-1.5!'
|
||||||
|
),
|
||||||
|
menuList: () => cn('p-0! max-h-60 overflow-auto'),
|
||||||
|
option: ({ isFocused, isSelected }) =>
|
||||||
|
cn('px-3 py-2 rounded-md cursor-pointer!', {
|
||||||
|
'bg-indigo-600 text-white': isFocused,
|
||||||
|
'bg-blue-500!': isSelected,
|
||||||
|
'text-gray-700': !isFocused && !isSelected,
|
||||||
|
}),
|
||||||
|
multiValue: ({ getValue, index }) => {
|
||||||
|
const selectedValues = getValue() as T[];
|
||||||
|
return cn(
|
||||||
|
'bg-base-200! rounded-lg! py-[3px] px-2.5 m-0! flex items-center gap-1! w-fit gap-2!',
|
||||||
|
selectedValues[index]?.className
|
||||||
|
);
|
||||||
|
},
|
||||||
|
multiValueRemove: () => cn('p-0! w-3 h-3'),
|
||||||
|
multiValueLabel: ({ getValue, index }) => {
|
||||||
|
const selectedValues = getValue() as T[];
|
||||||
|
return cn(
|
||||||
|
'p-0! text-base-content! text-xs!',
|
||||||
|
selectedValues[index]?.labelClassName
|
||||||
|
);
|
||||||
|
},
|
||||||
|
}}
|
||||||
|
components={{
|
||||||
|
...components,
|
||||||
|
...(optionComponent ? { Option: optionComponent } : {}),
|
||||||
|
MenuList: CustomMenuList,
|
||||||
|
}}
|
||||||
|
{...(startAdornment && {
|
||||||
|
shouldShowAdornment,
|
||||||
|
startAdornment,
|
||||||
|
})}
|
||||||
|
menuPortalTarget={
|
||||||
|
typeof document !== 'undefined'
|
||||||
|
? (menuPortalTarget ?? document.body)
|
||||||
|
: undefined
|
||||||
|
}
|
||||||
|
styles={{
|
||||||
|
menuPortal: (base) => ({ ...base, zIndex: 9999 }),
|
||||||
|
multiValue(base) {
|
||||||
|
return {
|
||||||
|
...base,
|
||||||
|
borderRadius: '8px',
|
||||||
|
};
|
||||||
|
},
|
||||||
|
}}
|
||||||
|
onMenuScrollToBottom={onMenuScrollToBottom}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
|
||||||
|
{isError && (
|
||||||
|
<p className='w-full mt-1.5 text-xs text-error'>{errorMessage}</p>
|
||||||
|
)}
|
||||||
{!isError && bottomLabel && (
|
{!isError && bottomLabel && (
|
||||||
<p className='w-full text-sm opacity-60'>{bottomLabel}</p>
|
<p className='w-full mt-1.5 text-xs opacity-60'>{bottomLabel}</p>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
const useSelect = <T,>(
|
const useSelect = <T,>(
|
||||||
basePath: string,
|
basePath: string | null,
|
||||||
valueKey: keyof T | string,
|
valueKey: keyof T | string,
|
||||||
labelKey: keyof T | string,
|
labelKey: keyof T | string,
|
||||||
searchKey: string = 'search',
|
searchKey: string = 'search',
|
||||||
@@ -288,34 +507,96 @@ const useSelect = <T,>(
|
|||||||
) => {
|
) => {
|
||||||
const [inputValue, setInputValue] = useState('');
|
const [inputValue, setInputValue] = useState('');
|
||||||
|
|
||||||
const optionsUrlParams = useMemo(() => {
|
const pageKey = 'page';
|
||||||
return new URLSearchParams({
|
const limitKey = 'limit';
|
||||||
|
const limit = params?.['limit'] ?? 10;
|
||||||
|
|
||||||
|
const getKey = (
|
||||||
|
pageIndex: number,
|
||||||
|
previousPageData?: BaseApiResponse<T[]>
|
||||||
|
) => {
|
||||||
|
// stop when backend says no more pages
|
||||||
|
if (previousPageData && isResponseSuccess(previousPageData)) {
|
||||||
|
const meta = previousPageData.meta;
|
||||||
|
if (meta && meta.page >= meta.total_pages) return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
const qs = new URLSearchParams({
|
||||||
|
...(params ?? {}),
|
||||||
[searchKey]: inputValue ?? '',
|
[searchKey]: inputValue ?? '',
|
||||||
...params,
|
[pageKey]: String(pageIndex + 1),
|
||||||
|
[limitKey]: String(limit),
|
||||||
}).toString();
|
}).toString();
|
||||||
}, [inputValue, searchKey, params]);
|
|
||||||
|
|
||||||
const optionsUrl = `${basePath}?${optionsUrlParams}`;
|
return basePath ? `${basePath}?${qs}` : null;
|
||||||
|
};
|
||||||
|
|
||||||
const { data, isLoading } = useSWR(optionsUrl, async (url) => {
|
const {
|
||||||
return await httpClientFetcher<BaseApiResponse<T[]>>(url);
|
data: pages,
|
||||||
});
|
isLoading,
|
||||||
|
isValidating,
|
||||||
|
size,
|
||||||
|
setSize,
|
||||||
|
} = useSWRInfinite<BaseApiResponse<T[]>>(getKey, (url) =>
|
||||||
|
httpClientFetcher<BaseApiResponse<T[]>>(url)
|
||||||
|
);
|
||||||
|
|
||||||
const options = isResponseSuccess(data)
|
const options = useMemo(() => {
|
||||||
? data.data.map((item) => {
|
if (!pages) return [];
|
||||||
return {
|
|
||||||
value: getByPath<T, number>(item, valueKey as string),
|
return pages.flatMap((page) =>
|
||||||
label: getByPath<T, string>(item, labelKey as string),
|
isResponseSuccess(page)
|
||||||
};
|
? page.data.map((item) => ({
|
||||||
})
|
value: getByPath<T, number>(item, valueKey as string),
|
||||||
: [];
|
label: getByPath<T, string>(item, labelKey as string),
|
||||||
|
}))
|
||||||
|
: []
|
||||||
|
);
|
||||||
|
}, [pages, valueKey, labelKey]);
|
||||||
|
|
||||||
|
const lastPage = pages?.[pages.length - 1];
|
||||||
|
const hasMore =
|
||||||
|
!!lastPage &&
|
||||||
|
isResponseSuccess(lastPage) &&
|
||||||
|
!!lastPage.meta &&
|
||||||
|
lastPage.meta.page < lastPage.meta.total_pages;
|
||||||
|
|
||||||
|
const loadMore = () => {
|
||||||
|
if (!hasMore) return;
|
||||||
|
setSize(size + 1);
|
||||||
|
};
|
||||||
|
|
||||||
|
let formattedSuccessRawData: SuccessApiResponse<T[]> | undefined = undefined;
|
||||||
|
let formattedErrorRawData: ErrorApiResponse | undefined = undefined;
|
||||||
|
|
||||||
|
const latestPagesIndex = pages?.length ? pages.length - 1 : 0;
|
||||||
|
|
||||||
|
if (isResponseSuccess(pages?.[latestPagesIndex])) {
|
||||||
|
formattedSuccessRawData = {
|
||||||
|
...pages?.[latestPagesIndex],
|
||||||
|
data:
|
||||||
|
pages?.flatMap((page) => (isResponseSuccess(page) ? page.data : [])) ??
|
||||||
|
[],
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isResponseError(pages?.[latestPagesIndex])) {
|
||||||
|
formattedErrorRawData = pages?.[latestPagesIndex];
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
inputValue,
|
inputValue,
|
||||||
setInputValue,
|
setInputValue,
|
||||||
|
|
||||||
options,
|
options,
|
||||||
isLoadingOptions: isLoading,
|
rawData: isResponseSuccess(pages?.[latestPagesIndex])
|
||||||
rawData: data,
|
? formattedSuccessRawData
|
||||||
|
: formattedErrorRawData,
|
||||||
|
|
||||||
|
isLoadingOptions: isLoading || isValidating,
|
||||||
|
isLoadingMore: isValidating && size > 1,
|
||||||
|
hasMore,
|
||||||
|
loadMore,
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,89 @@
|
|||||||
|
'use client';
|
||||||
|
|
||||||
|
import { useMemo } from 'react';
|
||||||
|
import {
|
||||||
|
OptionProps,
|
||||||
|
GroupBase,
|
||||||
|
components as ReactSelectComponents,
|
||||||
|
} from 'react-select';
|
||||||
|
import SelectInput, { OptionType, SelectInputProps } from './SelectInput';
|
||||||
|
import { cn } from '@/lib/helper';
|
||||||
|
|
||||||
|
interface SelectInputCheckboxProps<T = OptionType>
|
||||||
|
extends Omit<
|
||||||
|
SelectInputProps<T>,
|
||||||
|
'closeMenuOnSelect' | 'hideSelectedOptions' | 'optionComponent'
|
||||||
|
> {
|
||||||
|
closeMenuOnSelect?: boolean;
|
||||||
|
hideSelectedOptions?: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
const CheckboxOption = <
|
||||||
|
T extends OptionType,
|
||||||
|
IsMulti extends boolean,
|
||||||
|
Group extends GroupBase<T>,
|
||||||
|
>(
|
||||||
|
props: OptionProps<T, IsMulti, Group>
|
||||||
|
) => {
|
||||||
|
const { isSelected, label, innerRef, innerProps, className, isFocused } =
|
||||||
|
props;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div
|
||||||
|
ref={innerRef}
|
||||||
|
{...innerProps}
|
||||||
|
className={cn(
|
||||||
|
'flex items-center gap-3 p-3 cursor-pointer transition-all hover:bg-primary/5',
|
||||||
|
{
|
||||||
|
'bg-primary/5': isFocused,
|
||||||
|
},
|
||||||
|
className
|
||||||
|
)}
|
||||||
|
>
|
||||||
|
<input
|
||||||
|
type='checkbox'
|
||||||
|
checked={isSelected}
|
||||||
|
onChange={() => null}
|
||||||
|
className='checkbox checkbox-sm rounded-md checkbox-primary pointer-events-none border-base-content/10'
|
||||||
|
/>
|
||||||
|
|
||||||
|
<label className='cursor-pointer flex-1 select-none text-sm text-base-content/50 font-medium'>
|
||||||
|
{label}
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
const SelectInputCheckbox = <T extends OptionType>(
|
||||||
|
props: SelectInputCheckboxProps<T>
|
||||||
|
) => {
|
||||||
|
const {
|
||||||
|
closeMenuOnSelect = false,
|
||||||
|
hideSelectedOptions = false,
|
||||||
|
isMulti = true,
|
||||||
|
className,
|
||||||
|
...restProps
|
||||||
|
} = props;
|
||||||
|
|
||||||
|
const customComponents = useMemo(() => {
|
||||||
|
return {
|
||||||
|
Option: CheckboxOption as typeof ReactSelectComponents.Option,
|
||||||
|
};
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<SelectInput<T>
|
||||||
|
{...restProps}
|
||||||
|
isMulti={isMulti}
|
||||||
|
closeMenuOnSelect={closeMenuOnSelect}
|
||||||
|
hideSelectedOptions={hideSelectedOptions}
|
||||||
|
className={{
|
||||||
|
...className,
|
||||||
|
select: cn(className?.select, 'select-checkbox'),
|
||||||
|
}}
|
||||||
|
components={customComponents}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default SelectInputCheckbox;
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user