added some settings page
This commit is contained in:
601
package-lock.json
generated
601
package-lock.json
generated
@@ -12,6 +12,9 @@
|
||||
"@fontsource-variable/inter": "^5.2.8",
|
||||
"@tanstack/react-query": "^5.100.8",
|
||||
"@tanstack/react-table": "^8.21.3",
|
||||
"@tiptap/extension-link": "^3.23.2",
|
||||
"@tiptap/react": "^3.23.2",
|
||||
"@tiptap/starter-kit": "^3.23.2",
|
||||
"axios": "^1.15.2",
|
||||
"class-variance-authority": "^0.7.1",
|
||||
"clsx": "^2.1.1",
|
||||
@@ -809,6 +812,7 @@
|
||||
"resolved": "https://registry.npmjs.org/@floating-ui/dom/-/dom-1.7.6.tgz",
|
||||
"integrity": "sha512-9gZSAI5XM36880PPMm//9dfiEngYoC6Am2izES1FF406YFsjvyBMmeJ2g4SAju3xWwtuynNRFL2s9hgxpLI5SQ==",
|
||||
"license": "MIT",
|
||||
"peer": true,
|
||||
"dependencies": {
|
||||
"@floating-ui/core": "^1.7.5",
|
||||
"@floating-ui/utils": "^0.2.11"
|
||||
@@ -3434,6 +3438,438 @@
|
||||
"url": "https://github.com/sponsors/tannerlinsley"
|
||||
}
|
||||
},
|
||||
"node_modules/@tiptap/core": {
|
||||
"version": "3.23.2",
|
||||
"resolved": "https://registry.npmjs.org/@tiptap/core/-/core-3.23.2.tgz",
|
||||
"integrity": "sha512-yjv2N7gaQMbIVfsSZHBMscLoybgetcTraXsSMrELAerl/jfRipg5S1dBXMFvgRy8Kh48+TGoH+5nqshxdOEGoQ==",
|
||||
"license": "MIT",
|
||||
"peer": true,
|
||||
"funding": {
|
||||
"type": "github",
|
||||
"url": "https://github.com/sponsors/ueberdosis"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@tiptap/pm": "3.23.2"
|
||||
}
|
||||
},
|
||||
"node_modules/@tiptap/extension-blockquote": {
|
||||
"version": "3.23.2",
|
||||
"resolved": "https://registry.npmjs.org/@tiptap/extension-blockquote/-/extension-blockquote-3.23.2.tgz",
|
||||
"integrity": "sha512-BBN22/nUErRzUr1HI/Q4iPFBNavWoNC5Fx0KXp9oDOCCrCvj55rtGwLn2dB3r4vLfhjYvhEZ38wN+r7Y9RhORA==",
|
||||
"license": "MIT",
|
||||
"funding": {
|
||||
"type": "github",
|
||||
"url": "https://github.com/sponsors/ueberdosis"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@tiptap/core": "3.23.2"
|
||||
}
|
||||
},
|
||||
"node_modules/@tiptap/extension-bold": {
|
||||
"version": "3.23.2",
|
||||
"resolved": "https://registry.npmjs.org/@tiptap/extension-bold/-/extension-bold-3.23.2.tgz",
|
||||
"integrity": "sha512-onPFP260enNkjMGhR7sDSqaF80A4sgvMZ/VZLxp7zGa6DAfcuN4PyUQhZN61KmYgbUdr+qrAAMx+tPuid22F4g==",
|
||||
"license": "MIT",
|
||||
"funding": {
|
||||
"type": "github",
|
||||
"url": "https://github.com/sponsors/ueberdosis"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@tiptap/core": "3.23.2"
|
||||
}
|
||||
},
|
||||
"node_modules/@tiptap/extension-bubble-menu": {
|
||||
"version": "3.23.2",
|
||||
"resolved": "https://registry.npmjs.org/@tiptap/extension-bubble-menu/-/extension-bubble-menu-3.23.2.tgz",
|
||||
"integrity": "sha512-S0LZg6EMdkr5CiYAGmOwzuNPd2T18ZR5pWrgHHHZjt0IFqU01tBJa3zLzC1Vd7noPCec64ygW9S8+p8CHBgOIA==",
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"dependencies": {
|
||||
"@floating-ui/dom": "^1.0.0"
|
||||
},
|
||||
"funding": {
|
||||
"type": "github",
|
||||
"url": "https://github.com/sponsors/ueberdosis"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@tiptap/core": "3.23.2",
|
||||
"@tiptap/pm": "3.23.2"
|
||||
}
|
||||
},
|
||||
"node_modules/@tiptap/extension-bullet-list": {
|
||||
"version": "3.23.2",
|
||||
"resolved": "https://registry.npmjs.org/@tiptap/extension-bullet-list/-/extension-bullet-list-3.23.2.tgz",
|
||||
"integrity": "sha512-jhvu1qa8F53r//6DrLdA2OkTbRgY73NkQL51Ruozzi+JrfVIo3IfaTNRq01BXO5qcvNH7P/aDBF5cByvuiUMzQ==",
|
||||
"license": "MIT",
|
||||
"funding": {
|
||||
"type": "github",
|
||||
"url": "https://github.com/sponsors/ueberdosis"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@tiptap/extension-list": "3.23.2"
|
||||
}
|
||||
},
|
||||
"node_modules/@tiptap/extension-code": {
|
||||
"version": "3.23.2",
|
||||
"resolved": "https://registry.npmjs.org/@tiptap/extension-code/-/extension-code-3.23.2.tgz",
|
||||
"integrity": "sha512-5yHYavvBEkxgWL6DCPYNHujxBXF7c812MFNoU62ljNJjIYDc2Mu8ftOie/ajNJbMLqwSVzCuGfG9swEuEKxY5g==",
|
||||
"license": "MIT",
|
||||
"funding": {
|
||||
"type": "github",
|
||||
"url": "https://github.com/sponsors/ueberdosis"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@tiptap/core": "3.23.2"
|
||||
}
|
||||
},
|
||||
"node_modules/@tiptap/extension-code-block": {
|
||||
"version": "3.23.2",
|
||||
"resolved": "https://registry.npmjs.org/@tiptap/extension-code-block/-/extension-code-block-3.23.2.tgz",
|
||||
"integrity": "sha512-oWwjsLi+m7zHTqM0kYnnogjS3vFENCaLk3ue/1XE9ccpZlmmPzmK70hodB/UPylFJmgr3g726rhxViYv9LRS7A==",
|
||||
"license": "MIT",
|
||||
"funding": {
|
||||
"type": "github",
|
||||
"url": "https://github.com/sponsors/ueberdosis"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@tiptap/core": "3.23.2",
|
||||
"@tiptap/pm": "3.23.2"
|
||||
}
|
||||
},
|
||||
"node_modules/@tiptap/extension-document": {
|
||||
"version": "3.23.2",
|
||||
"resolved": "https://registry.npmjs.org/@tiptap/extension-document/-/extension-document-3.23.2.tgz",
|
||||
"integrity": "sha512-Ff/MAaWPzFtb7nhPG6ETdu7/OqkD6cAmJfViBAiRqh9PPULH98fGDaMBm3TGa1s3XB7hGO7c/xVKxEdjYij5rg==",
|
||||
"license": "MIT",
|
||||
"funding": {
|
||||
"type": "github",
|
||||
"url": "https://github.com/sponsors/ueberdosis"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@tiptap/core": "3.23.2"
|
||||
}
|
||||
},
|
||||
"node_modules/@tiptap/extension-dropcursor": {
|
||||
"version": "3.23.2",
|
||||
"resolved": "https://registry.npmjs.org/@tiptap/extension-dropcursor/-/extension-dropcursor-3.23.2.tgz",
|
||||
"integrity": "sha512-T7pVfIF5uDj043CDJlurNoMAmXPy36EjBz/YQVYrVMSSUbvUlOaL3xxoDODRmir29jVrmCROjaKwVExqooQTqQ==",
|
||||
"license": "MIT",
|
||||
"funding": {
|
||||
"type": "github",
|
||||
"url": "https://github.com/sponsors/ueberdosis"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@tiptap/extensions": "3.23.2"
|
||||
}
|
||||
},
|
||||
"node_modules/@tiptap/extension-floating-menu": {
|
||||
"version": "3.23.2",
|
||||
"resolved": "https://registry.npmjs.org/@tiptap/extension-floating-menu/-/extension-floating-menu-3.23.2.tgz",
|
||||
"integrity": "sha512-1rfxx5X52h44jSS9R1fUx8sOaRpNq8CM0IR3EdjpthVvaRZ9XD1tKX4h5EcwGFqNiwtWXxNne2mV7ZJuH2UYsQ==",
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"funding": {
|
||||
"type": "github",
|
||||
"url": "https://github.com/sponsors/ueberdosis"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@floating-ui/dom": "^1.0.0",
|
||||
"@tiptap/core": "3.23.2",
|
||||
"@tiptap/pm": "3.23.2"
|
||||
}
|
||||
},
|
||||
"node_modules/@tiptap/extension-gapcursor": {
|
||||
"version": "3.23.2",
|
||||
"resolved": "https://registry.npmjs.org/@tiptap/extension-gapcursor/-/extension-gapcursor-3.23.2.tgz",
|
||||
"integrity": "sha512-I3LKYVwyxRaiVaJxss98QWOXzZZrHmsJD3RgAZ0Uoguu3pL29Krn2tXfwp4FAd9NG79wdQHj20c+XuqJLNkAbw==",
|
||||
"license": "MIT",
|
||||
"funding": {
|
||||
"type": "github",
|
||||
"url": "https://github.com/sponsors/ueberdosis"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@tiptap/extensions": "3.23.2"
|
||||
}
|
||||
},
|
||||
"node_modules/@tiptap/extension-hard-break": {
|
||||
"version": "3.23.2",
|
||||
"resolved": "https://registry.npmjs.org/@tiptap/extension-hard-break/-/extension-hard-break-3.23.2.tgz",
|
||||
"integrity": "sha512-3p00oC2caRAVtkOweJ9IjTgjhzm34R9tNyMCykzMRygC8CdO08Jv2JKvUaOeMVVmWZI+O9wkGUpaA2Drg6pY4g==",
|
||||
"license": "MIT",
|
||||
"funding": {
|
||||
"type": "github",
|
||||
"url": "https://github.com/sponsors/ueberdosis"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@tiptap/core": "3.23.2"
|
||||
}
|
||||
},
|
||||
"node_modules/@tiptap/extension-heading": {
|
||||
"version": "3.23.2",
|
||||
"resolved": "https://registry.npmjs.org/@tiptap/extension-heading/-/extension-heading-3.23.2.tgz",
|
||||
"integrity": "sha512-ldQh38ZWTIedSY6XsOkn1ULtk+mD/mezLogrvcVv8neez0qM/S25vyMZKqP7i2/x4i4ds1JYIJLw9y3HX/B69Q==",
|
||||
"license": "MIT",
|
||||
"funding": {
|
||||
"type": "github",
|
||||
"url": "https://github.com/sponsors/ueberdosis"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@tiptap/core": "3.23.2"
|
||||
}
|
||||
},
|
||||
"node_modules/@tiptap/extension-horizontal-rule": {
|
||||
"version": "3.23.2",
|
||||
"resolved": "https://registry.npmjs.org/@tiptap/extension-horizontal-rule/-/extension-horizontal-rule-3.23.2.tgz",
|
||||
"integrity": "sha512-LbLACqe/OiTdYIq3zbsY7Ue7WOP+mYTGufNDfs8rSGcUbWI2GwUwoGRrTPBbLIesnuCdH6FyMB60Tg/HzjKaYw==",
|
||||
"license": "MIT",
|
||||
"funding": {
|
||||
"type": "github",
|
||||
"url": "https://github.com/sponsors/ueberdosis"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@tiptap/core": "3.23.2",
|
||||
"@tiptap/pm": "3.23.2"
|
||||
}
|
||||
},
|
||||
"node_modules/@tiptap/extension-italic": {
|
||||
"version": "3.23.2",
|
||||
"resolved": "https://registry.npmjs.org/@tiptap/extension-italic/-/extension-italic-3.23.2.tgz",
|
||||
"integrity": "sha512-pauWOkom8riyZoIGn8I8uFE//uRgE6kL46Pd6PdSd5Wt6w/ao/le9Ju2Ln947NGjz/6whaDiFnBrkSbZEAhpmw==",
|
||||
"license": "MIT",
|
||||
"funding": {
|
||||
"type": "github",
|
||||
"url": "https://github.com/sponsors/ueberdosis"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@tiptap/core": "3.23.2"
|
||||
}
|
||||
},
|
||||
"node_modules/@tiptap/extension-link": {
|
||||
"version": "3.23.2",
|
||||
"resolved": "https://registry.npmjs.org/@tiptap/extension-link/-/extension-link-3.23.2.tgz",
|
||||
"integrity": "sha512-h0D3Lwom0hGDsbpZ6tW0+DRKgBP0qSl4rO/iBfGk3Krb2CoyEn1yII3pSTd1PwAld7bHt/buURi6DWudQsIhgg==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"linkifyjs": "^4.3.2"
|
||||
},
|
||||
"funding": {
|
||||
"type": "github",
|
||||
"url": "https://github.com/sponsors/ueberdosis"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@tiptap/core": "3.23.2",
|
||||
"@tiptap/pm": "3.23.2"
|
||||
}
|
||||
},
|
||||
"node_modules/@tiptap/extension-list": {
|
||||
"version": "3.23.2",
|
||||
"resolved": "https://registry.npmjs.org/@tiptap/extension-list/-/extension-list-3.23.2.tgz",
|
||||
"integrity": "sha512-tRbbjpOPrY4ApIHtn3ctnKIhkkioewMsZa5gJzqVB47LJFNyzLXLo/aID4sJRKTIMi1wd1fA9TiBKPe6KqczPA==",
|
||||
"license": "MIT",
|
||||
"peer": true,
|
||||
"funding": {
|
||||
"type": "github",
|
||||
"url": "https://github.com/sponsors/ueberdosis"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@tiptap/core": "3.23.2",
|
||||
"@tiptap/pm": "3.23.2"
|
||||
}
|
||||
},
|
||||
"node_modules/@tiptap/extension-list-item": {
|
||||
"version": "3.23.2",
|
||||
"resolved": "https://registry.npmjs.org/@tiptap/extension-list-item/-/extension-list-item-3.23.2.tgz",
|
||||
"integrity": "sha512-I9Yed0mmBE6AAhc4Cc5UhZLZUMCft9XdPkdBM/wjcjpLwdMhdzelVQXEhNDyPfRkA1TTGs5VHlc6twjCPCTgLg==",
|
||||
"license": "MIT",
|
||||
"funding": {
|
||||
"type": "github",
|
||||
"url": "https://github.com/sponsors/ueberdosis"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@tiptap/extension-list": "3.23.2"
|
||||
}
|
||||
},
|
||||
"node_modules/@tiptap/extension-list-keymap": {
|
||||
"version": "3.23.2",
|
||||
"resolved": "https://registry.npmjs.org/@tiptap/extension-list-keymap/-/extension-list-keymap-3.23.2.tgz",
|
||||
"integrity": "sha512-aE4PzCy+OWXXFc8UsrrYjcfEbyXCh8f7LuGgFPl8jf0JjgIK0FHmzWDg3912zWb5Ww66AF2j0KJzTB9NFOMWlw==",
|
||||
"license": "MIT",
|
||||
"funding": {
|
||||
"type": "github",
|
||||
"url": "https://github.com/sponsors/ueberdosis"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@tiptap/extension-list": "3.23.2"
|
||||
}
|
||||
},
|
||||
"node_modules/@tiptap/extension-ordered-list": {
|
||||
"version": "3.23.2",
|
||||
"resolved": "https://registry.npmjs.org/@tiptap/extension-ordered-list/-/extension-ordered-list-3.23.2.tgz",
|
||||
"integrity": "sha512-ZhMejT4jXfOEECqI60AVBzULl8AVN8BXk/9vjVnJHxBtcQxW+tIu5GHVZ4DPaCfTX7mH+hsceFMhQ2BvV7qvbg==",
|
||||
"license": "MIT",
|
||||
"funding": {
|
||||
"type": "github",
|
||||
"url": "https://github.com/sponsors/ueberdosis"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@tiptap/extension-list": "3.23.2"
|
||||
}
|
||||
},
|
||||
"node_modules/@tiptap/extension-paragraph": {
|
||||
"version": "3.23.2",
|
||||
"resolved": "https://registry.npmjs.org/@tiptap/extension-paragraph/-/extension-paragraph-3.23.2.tgz",
|
||||
"integrity": "sha512-UzHx5zOi9fjhC9TAqHeD7BV5eJIA3t65pa2Mq8b54V9nrIg1yAlgiafU0WDWoom11TF+IWxz5JBsjlW0/P/VeQ==",
|
||||
"license": "MIT",
|
||||
"funding": {
|
||||
"type": "github",
|
||||
"url": "https://github.com/sponsors/ueberdosis"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@tiptap/core": "3.23.2"
|
||||
}
|
||||
},
|
||||
"node_modules/@tiptap/extension-strike": {
|
||||
"version": "3.23.2",
|
||||
"resolved": "https://registry.npmjs.org/@tiptap/extension-strike/-/extension-strike-3.23.2.tgz",
|
||||
"integrity": "sha512-m1BN3EXwYagzVdReGoI7McvuZFyolFwuXLgzU6c+RN7E+u+K68EY+2U3pJI5ee8UgPYGW4eBs/3BT/5k+0so3Q==",
|
||||
"license": "MIT",
|
||||
"funding": {
|
||||
"type": "github",
|
||||
"url": "https://github.com/sponsors/ueberdosis"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@tiptap/core": "3.23.2"
|
||||
}
|
||||
},
|
||||
"node_modules/@tiptap/extension-text": {
|
||||
"version": "3.23.2",
|
||||
"resolved": "https://registry.npmjs.org/@tiptap/extension-text/-/extension-text-3.23.2.tgz",
|
||||
"integrity": "sha512-Ny4FC+BivfwACTuJO3QPe+BXtVFfzWQVBcfhlFlA7xTaeBktFeBavH2cEyXR8Qbez3Wio/Hn+bibT4d44EBLyg==",
|
||||
"license": "MIT",
|
||||
"funding": {
|
||||
"type": "github",
|
||||
"url": "https://github.com/sponsors/ueberdosis"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@tiptap/core": "3.23.2"
|
||||
}
|
||||
},
|
||||
"node_modules/@tiptap/extension-underline": {
|
||||
"version": "3.23.2",
|
||||
"resolved": "https://registry.npmjs.org/@tiptap/extension-underline/-/extension-underline-3.23.2.tgz",
|
||||
"integrity": "sha512-HdPX1nZarOF8UkDccu6gBy6brZd4vDFCa5Mz1liw3B3D6UBiC+8vzE1YGHtggO+KEBBQYf4GgjT3qqIgOcsTEQ==",
|
||||
"license": "MIT",
|
||||
"funding": {
|
||||
"type": "github",
|
||||
"url": "https://github.com/sponsors/ueberdosis"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@tiptap/core": "3.23.2"
|
||||
}
|
||||
},
|
||||
"node_modules/@tiptap/extensions": {
|
||||
"version": "3.23.2",
|
||||
"resolved": "https://registry.npmjs.org/@tiptap/extensions/-/extensions-3.23.2.tgz",
|
||||
"integrity": "sha512-kRHQ3nSbAfkFdxj9FtDdr4hpREndGgWFA6ZEAwlLeGUxf8QYTpuF9zb2yxdBPBlTc5+JsbPcskNt+u1PazGKYw==",
|
||||
"license": "MIT",
|
||||
"peer": true,
|
||||
"funding": {
|
||||
"type": "github",
|
||||
"url": "https://github.com/sponsors/ueberdosis"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@tiptap/core": "3.23.2",
|
||||
"@tiptap/pm": "3.23.2"
|
||||
}
|
||||
},
|
||||
"node_modules/@tiptap/pm": {
|
||||
"version": "3.23.2",
|
||||
"resolved": "https://registry.npmjs.org/@tiptap/pm/-/pm-3.23.2.tgz",
|
||||
"integrity": "sha512-1kvsBqGNu2ZJ0P/lkxN0pAMqSyUcpkMIzE4xwGUIyAiD0pZV6dr+OCMwGWOTLllSyrn91xI5K7OLk3pYeCPKqA==",
|
||||
"license": "MIT",
|
||||
"peer": true,
|
||||
"dependencies": {
|
||||
"prosemirror-changeset": "^2.3.0",
|
||||
"prosemirror-commands": "^1.6.2",
|
||||
"prosemirror-dropcursor": "^1.8.1",
|
||||
"prosemirror-gapcursor": "^1.3.2",
|
||||
"prosemirror-history": "^1.4.1",
|
||||
"prosemirror-keymap": "^1.2.2",
|
||||
"prosemirror-model": "^1.24.1",
|
||||
"prosemirror-schema-list": "^1.5.0",
|
||||
"prosemirror-state": "^1.4.3",
|
||||
"prosemirror-tables": "^1.6.4",
|
||||
"prosemirror-transform": "^1.10.2",
|
||||
"prosemirror-view": "^1.38.1"
|
||||
},
|
||||
"funding": {
|
||||
"type": "github",
|
||||
"url": "https://github.com/sponsors/ueberdosis"
|
||||
}
|
||||
},
|
||||
"node_modules/@tiptap/react": {
|
||||
"version": "3.23.2",
|
||||
"resolved": "https://registry.npmjs.org/@tiptap/react/-/react-3.23.2.tgz",
|
||||
"integrity": "sha512-qfl70xRDQbwov8y5QvK+EiYk6JyoyzUimNtOmLSfeun2NjQwv67hW1iQ+c3geDbcwfUY5+h3XYMy1Lm+Bt46NQ==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@types/use-sync-external-store": "^0.0.6",
|
||||
"fast-equals": "^5.3.3",
|
||||
"use-sync-external-store": "^1.4.0"
|
||||
},
|
||||
"funding": {
|
||||
"type": "github",
|
||||
"url": "https://github.com/sponsors/ueberdosis"
|
||||
},
|
||||
"optionalDependencies": {
|
||||
"@tiptap/extension-bubble-menu": "^3.23.2",
|
||||
"@tiptap/extension-floating-menu": "^3.23.2"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@tiptap/core": "3.23.2",
|
||||
"@tiptap/pm": "3.23.2",
|
||||
"@types/react": "^17.0.0 || ^18.0.0 || ^19.0.0",
|
||||
"@types/react-dom": "^17.0.0 || ^18.0.0 || ^19.0.0",
|
||||
"react": "^17.0.0 || ^18.0.0 || ^19.0.0",
|
||||
"react-dom": "^17.0.0 || ^18.0.0 || ^19.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@tiptap/starter-kit": {
|
||||
"version": "3.23.2",
|
||||
"resolved": "https://registry.npmjs.org/@tiptap/starter-kit/-/starter-kit-3.23.2.tgz",
|
||||
"integrity": "sha512-t0o//bLmlUW/3j9ke1wIrrKkvfVYcBiC/cowCUNwN/YQx9Bc3S++yInkR6hat4qI4+O49+NRknVeaF/Sp247QA==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@tiptap/core": "^3.23.2",
|
||||
"@tiptap/extension-blockquote": "^3.23.2",
|
||||
"@tiptap/extension-bold": "^3.23.2",
|
||||
"@tiptap/extension-bullet-list": "^3.23.2",
|
||||
"@tiptap/extension-code": "^3.23.2",
|
||||
"@tiptap/extension-code-block": "^3.23.2",
|
||||
"@tiptap/extension-document": "^3.23.2",
|
||||
"@tiptap/extension-dropcursor": "^3.23.2",
|
||||
"@tiptap/extension-gapcursor": "^3.23.2",
|
||||
"@tiptap/extension-hard-break": "^3.23.2",
|
||||
"@tiptap/extension-heading": "^3.23.2",
|
||||
"@tiptap/extension-horizontal-rule": "^3.23.2",
|
||||
"@tiptap/extension-italic": "^3.23.2",
|
||||
"@tiptap/extension-link": "^3.23.2",
|
||||
"@tiptap/extension-list": "^3.23.2",
|
||||
"@tiptap/extension-list-item": "^3.23.2",
|
||||
"@tiptap/extension-list-keymap": "^3.23.2",
|
||||
"@tiptap/extension-ordered-list": "^3.23.2",
|
||||
"@tiptap/extension-paragraph": "^3.23.2",
|
||||
"@tiptap/extension-strike": "^3.23.2",
|
||||
"@tiptap/extension-text": "^3.23.2",
|
||||
"@tiptap/extension-underline": "^3.23.2",
|
||||
"@tiptap/extensions": "^3.23.2",
|
||||
"@tiptap/pm": "^3.23.2"
|
||||
},
|
||||
"funding": {
|
||||
"type": "github",
|
||||
"url": "https://github.com/sponsors/ueberdosis"
|
||||
}
|
||||
},
|
||||
"node_modules/@ts-morph/common": {
|
||||
"version": "0.27.0",
|
||||
"resolved": "https://registry.npmjs.org/@ts-morph/common/-/common-0.27.0.tgz",
|
||||
@@ -3554,7 +3990,6 @@
|
||||
"version": "19.2.14",
|
||||
"resolved": "https://registry.npmjs.org/@types/react/-/react-19.2.14.tgz",
|
||||
"integrity": "sha512-ilcTH/UniCkMdtexkoCN0bI7pMcJDvmQFPvuPvmEaYA/NSfFTAgdUSLAoVjaRJm7+6PvcM+q1zYOwS4wTYMF9w==",
|
||||
"devOptional": true,
|
||||
"license": "MIT",
|
||||
"peer": true,
|
||||
"dependencies": {
|
||||
@@ -3565,7 +4000,6 @@
|
||||
"version": "19.2.3",
|
||||
"resolved": "https://registry.npmjs.org/@types/react-dom/-/react-dom-19.2.3.tgz",
|
||||
"integrity": "sha512-jp2L/eY6fn+KgVVQAOqYItbF0VY/YApe5Mz2F0aykSO8gx31bYCZyvSeYxCHKvzHG5eZjc+zyaS5BrBWya2+kQ==",
|
||||
"devOptional": true,
|
||||
"license": "MIT",
|
||||
"peer": true,
|
||||
"peerDependencies": {
|
||||
@@ -4555,7 +4989,6 @@
|
||||
"version": "3.2.3",
|
||||
"resolved": "https://registry.npmjs.org/csstype/-/csstype-3.2.3.tgz",
|
||||
"integrity": "sha512-z1HGKcYy2xA8AGQfwrn0PAy+PB7X/GSj3UVJW9qKyn43xWa+gl5nXmU4qqLMRzWVLFC8KusUX8T/0kCiOYpAIQ==",
|
||||
"devOptional": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/d3-array": {
|
||||
@@ -5351,6 +5784,15 @@
|
||||
"integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/fast-equals": {
|
||||
"version": "5.4.0",
|
||||
"resolved": "https://registry.npmjs.org/fast-equals/-/fast-equals-5.4.0.tgz",
|
||||
"integrity": "sha512-jt2DW/aNFNwke7AUd+Z+e6pz39KO5rzdbbFCg2sGafS4mk13MI7Z8O5z9cADNn5lhGODIgLwug6TZO2ctf7kcw==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=6.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/fast-glob": {
|
||||
"version": "3.3.3",
|
||||
"resolved": "https://registry.npmjs.org/fast-glob/-/fast-glob-3.3.3.tgz",
|
||||
@@ -6734,6 +7176,12 @@
|
||||
"integrity": "sha512-7ylylesZQ/PV29jhEDl3Ufjo6ZX7gCqJr5F7PKrqc93v7fzSymt1BpwEU8nAUXs8qzzvqhbjhK5QZg6Mt/HkBg==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/linkifyjs": {
|
||||
"version": "4.3.2",
|
||||
"resolved": "https://registry.npmjs.org/linkifyjs/-/linkifyjs-4.3.2.tgz",
|
||||
"integrity": "sha512-NT1CJtq3hHIreOianA8aSXn6Cw0JzYOuDQbOrSPe7gqFnCpKP++MQe3ODgO3oh2GJFORkAAdqredOa60z63GbA==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/locate-path": {
|
||||
"version": "6.0.0",
|
||||
"resolved": "https://registry.npmjs.org/locate-path/-/locate-path-6.0.0.tgz",
|
||||
@@ -7261,6 +7709,12 @@
|
||||
"url": "https://github.com/sponsors/sindresorhus"
|
||||
}
|
||||
},
|
||||
"node_modules/orderedmap": {
|
||||
"version": "2.1.1",
|
||||
"resolved": "https://registry.npmjs.org/orderedmap/-/orderedmap-2.1.1.tgz",
|
||||
"integrity": "sha512-TvAWxi0nDe1j/rtMcWcIj94+Ffe6n7zhow33h40SKxmsmozs6dz/e+EajymfoFcHd7sxNn8yHM8839uixMOV6g==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/outvariant": {
|
||||
"version": "1.4.3",
|
||||
"resolved": "https://registry.npmjs.org/outvariant/-/outvariant-1.4.3.tgz",
|
||||
@@ -7516,6 +7970,135 @@
|
||||
"node": ">=6"
|
||||
}
|
||||
},
|
||||
"node_modules/prosemirror-changeset": {
|
||||
"version": "2.4.1",
|
||||
"resolved": "https://registry.npmjs.org/prosemirror-changeset/-/prosemirror-changeset-2.4.1.tgz",
|
||||
"integrity": "sha512-96WBLhOaYhJ+kPhLg3uW359Tz6I/MfcrQfL4EGv4SrcqKEMC1gmoGrXHecPE8eOwTVCJ4IwgfzM8fFad25wNfw==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"prosemirror-transform": "^1.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/prosemirror-commands": {
|
||||
"version": "1.7.1",
|
||||
"resolved": "https://registry.npmjs.org/prosemirror-commands/-/prosemirror-commands-1.7.1.tgz",
|
||||
"integrity": "sha512-rT7qZnQtx5c0/y/KlYaGvtG411S97UaL6gdp6RIZ23DLHanMYLyfGBV5DtSnZdthQql7W+lEVbpSfwtO8T+L2w==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"prosemirror-model": "^1.0.0",
|
||||
"prosemirror-state": "^1.0.0",
|
||||
"prosemirror-transform": "^1.10.2"
|
||||
}
|
||||
},
|
||||
"node_modules/prosemirror-dropcursor": {
|
||||
"version": "1.8.2",
|
||||
"resolved": "https://registry.npmjs.org/prosemirror-dropcursor/-/prosemirror-dropcursor-1.8.2.tgz",
|
||||
"integrity": "sha512-CCk6Gyx9+Tt2sbYk5NK0nB1ukHi2ryaRgadV/LvyNuO3ena1payM2z6Cg0vO1ebK8cxbzo41ku2DE5Axj1Zuiw==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"prosemirror-state": "^1.0.0",
|
||||
"prosemirror-transform": "^1.1.0",
|
||||
"prosemirror-view": "^1.1.0"
|
||||
}
|
||||
},
|
||||
"node_modules/prosemirror-gapcursor": {
|
||||
"version": "1.4.1",
|
||||
"resolved": "https://registry.npmjs.org/prosemirror-gapcursor/-/prosemirror-gapcursor-1.4.1.tgz",
|
||||
"integrity": "sha512-pMdYaEnjNMSwl11yjEGtgTmLkR08m/Vl+Jj443167p9eB3HVQKhYCc4gmHVDsLPODfZfjr/MmirsdyZziXbQKw==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"prosemirror-keymap": "^1.0.0",
|
||||
"prosemirror-model": "^1.0.0",
|
||||
"prosemirror-state": "^1.0.0",
|
||||
"prosemirror-view": "^1.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/prosemirror-history": {
|
||||
"version": "1.5.0",
|
||||
"resolved": "https://registry.npmjs.org/prosemirror-history/-/prosemirror-history-1.5.0.tgz",
|
||||
"integrity": "sha512-zlzTiH01eKA55UAf1MEjtssJeHnGxO0j4K4Dpx+gnmX9n+SHNlDqI2oO1Kv1iPN5B1dm5fsljCfqKF9nFL6HRg==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"prosemirror-state": "^1.2.2",
|
||||
"prosemirror-transform": "^1.0.0",
|
||||
"prosemirror-view": "^1.31.0",
|
||||
"rope-sequence": "^1.3.0"
|
||||
}
|
||||
},
|
||||
"node_modules/prosemirror-keymap": {
|
||||
"version": "1.2.3",
|
||||
"resolved": "https://registry.npmjs.org/prosemirror-keymap/-/prosemirror-keymap-1.2.3.tgz",
|
||||
"integrity": "sha512-4HucRlpiLd1IPQQXNqeo81BGtkY8Ai5smHhKW9jjPKRc2wQIxksg7Hl1tTI2IfT2B/LgX6bfYvXxEpJl7aKYKw==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"prosemirror-state": "^1.0.0",
|
||||
"w3c-keyname": "^2.2.0"
|
||||
}
|
||||
},
|
||||
"node_modules/prosemirror-model": {
|
||||
"version": "1.25.4",
|
||||
"resolved": "https://registry.npmjs.org/prosemirror-model/-/prosemirror-model-1.25.4.tgz",
|
||||
"integrity": "sha512-PIM7E43PBxKce8OQeezAs9j4TP+5yDpZVbuurd1h5phUxEKIu+G2a+EUZzIC5nS1mJktDJWzbqS23n1tsAf5QA==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"orderedmap": "^2.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/prosemirror-schema-list": {
|
||||
"version": "1.5.1",
|
||||
"resolved": "https://registry.npmjs.org/prosemirror-schema-list/-/prosemirror-schema-list-1.5.1.tgz",
|
||||
"integrity": "sha512-927lFx/uwyQaGwJxLWCZRkjXG0p48KpMj6ueoYiu4JX05GGuGcgzAy62dfiV8eFZftgyBUvLx76RsMe20fJl+Q==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"prosemirror-model": "^1.0.0",
|
||||
"prosemirror-state": "^1.0.0",
|
||||
"prosemirror-transform": "^1.7.3"
|
||||
}
|
||||
},
|
||||
"node_modules/prosemirror-state": {
|
||||
"version": "1.4.4",
|
||||
"resolved": "https://registry.npmjs.org/prosemirror-state/-/prosemirror-state-1.4.4.tgz",
|
||||
"integrity": "sha512-6jiYHH2CIGbCfnxdHbXZ12gySFY/fz/ulZE333G6bPqIZ4F+TXo9ifiR86nAHpWnfoNjOb3o5ESi7J8Uz1jXHw==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"prosemirror-model": "^1.0.0",
|
||||
"prosemirror-transform": "^1.0.0",
|
||||
"prosemirror-view": "^1.27.0"
|
||||
}
|
||||
},
|
||||
"node_modules/prosemirror-tables": {
|
||||
"version": "1.8.5",
|
||||
"resolved": "https://registry.npmjs.org/prosemirror-tables/-/prosemirror-tables-1.8.5.tgz",
|
||||
"integrity": "sha512-V/0cDCsHKHe/tfWkeCmthNUcEp1IVO3p6vwN8XtwE9PZQLAZJigbw3QoraAdfJPir4NKJtNvOB8oYGKRl+t0Dw==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"prosemirror-keymap": "^1.2.3",
|
||||
"prosemirror-model": "^1.25.4",
|
||||
"prosemirror-state": "^1.4.4",
|
||||
"prosemirror-transform": "^1.10.5",
|
||||
"prosemirror-view": "^1.41.4"
|
||||
}
|
||||
},
|
||||
"node_modules/prosemirror-transform": {
|
||||
"version": "1.12.0",
|
||||
"resolved": "https://registry.npmjs.org/prosemirror-transform/-/prosemirror-transform-1.12.0.tgz",
|
||||
"integrity": "sha512-GxboyN4AMIsoHNtz5uf2r2Ru551i5hWeCMD6E2Ib4Eogqoub0NflniaBPVQ4MrGE5yZ8JV9tUHg9qcZTTrcN4w==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"prosemirror-model": "^1.21.0"
|
||||
}
|
||||
},
|
||||
"node_modules/prosemirror-view": {
|
||||
"version": "1.41.8",
|
||||
"resolved": "https://registry.npmjs.org/prosemirror-view/-/prosemirror-view-1.41.8.tgz",
|
||||
"integrity": "sha512-TnKDdohEatgyZNGCDWIdccOHXhYloJwbwU+phw/a23KBvJIR9lWQWW7WHHK3vBdOLDNuF7TaX98GObUZOWkOnA==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"prosemirror-model": "^1.20.0",
|
||||
"prosemirror-state": "^1.0.0",
|
||||
"prosemirror-transform": "^1.1.0"
|
||||
}
|
||||
},
|
||||
"node_modules/proxy-addr": {
|
||||
"version": "2.0.7",
|
||||
"resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.7.tgz",
|
||||
@@ -8084,6 +8667,12 @@
|
||||
"node_modules/root": {
|
||||
"resolved": "git+ssh://git@github.com/tanstack/react-query.git#9800c8f1a3f7907956410c23426a26d981e7d694"
|
||||
},
|
||||
"node_modules/rope-sequence": {
|
||||
"version": "1.3.4",
|
||||
"resolved": "https://registry.npmjs.org/rope-sequence/-/rope-sequence-1.3.4.tgz",
|
||||
"integrity": "sha512-UT5EDe2cu2E/6O4igUr5PSFs23nvvukicWHx6GnOPlHAiiYbzNuCRQCuiUdHJQcqKalLKlrYJnjY0ySGsXNQXQ==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/router": {
|
||||
"version": "2.2.0",
|
||||
"resolved": "https://registry.npmjs.org/router/-/router-2.2.0.tgz",
|
||||
@@ -9047,6 +9636,12 @@
|
||||
"node": ">=0.10.0"
|
||||
}
|
||||
},
|
||||
"node_modules/w3c-keyname": {
|
||||
"version": "2.2.8",
|
||||
"resolved": "https://registry.npmjs.org/w3c-keyname/-/w3c-keyname-2.2.8.tgz",
|
||||
"integrity": "sha512-dpojBhNsCNN7T82Tm7k26A6G9ML3NkhDsnw9n/eoxSRlVBB4CEtIQ/KTCLI2Fwf3ataSXRhYFkQi3SlnFwPvPQ==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/web-streams-polyfill": {
|
||||
"version": "3.3.3",
|
||||
"resolved": "https://registry.npmjs.org/web-streams-polyfill/-/web-streams-polyfill-3.3.3.tgz",
|
||||
|
||||
@@ -14,6 +14,9 @@
|
||||
"@fontsource-variable/inter": "^5.2.8",
|
||||
"@tanstack/react-query": "^5.100.8",
|
||||
"@tanstack/react-table": "^8.21.3",
|
||||
"@tiptap/extension-link": "^3.23.2",
|
||||
"@tiptap/react": "^3.23.2",
|
||||
"@tiptap/starter-kit": "^3.23.2",
|
||||
"axios": "^1.15.2",
|
||||
"class-variance-authority": "^0.7.1",
|
||||
"clsx": "^2.1.1",
|
||||
|
||||
@@ -137,6 +137,16 @@ const PermissionCreatePage = lazy(() => import("@/pages/settings/users/permissio
|
||||
const PermissionsViewPage = lazy(() => import("@/pages/settings/users/permissionsView"));
|
||||
const PermissionEditPage = lazy(() => import("@/pages/settings/users/permissionsEdit"));
|
||||
|
||||
const LoanTypesPage = lazy(() => import("@/pages/settings/loan/loanTypes"));
|
||||
const LoanTypeCreatePage = lazy(() => import("@/pages/settings/loan/loanTypesCreate"));
|
||||
const LoanTypesViewPage = lazy(() => import("@/pages/settings/loan/loanTypesView"));
|
||||
const LoanTypeEditPage = lazy(() => import("@/pages/settings/loan/loanTypesEdit"));
|
||||
|
||||
const RequiredDocumentsPage = lazy(() => import("@/pages/settings/loan/requiredDocuments"));
|
||||
const RequiredDocumentCreatePage = lazy(() => import("@/pages/settings/loan/requiredDocumentsCreate"));
|
||||
const RequiredDocumentsViewPage = lazy(() => import("@/pages/settings/loan/requiredDocumentsView"));
|
||||
const RequiredDocumentEditPage = lazy(() => import("@/pages/settings/loan/requiredDocumentsEdit"));
|
||||
|
||||
function AuthGuard() {
|
||||
const isAuthenticated = useAuthStore((s) => s.isAuthenticated);
|
||||
if (!isAuthenticated) return <Navigate to="/login" replace />;
|
||||
@@ -753,6 +763,70 @@ export const router = createBrowserRouter([
|
||||
</Suspense>
|
||||
),
|
||||
},
|
||||
{
|
||||
path: "/settings/loan/loan-types",
|
||||
element: (
|
||||
<Suspense fallback={<PageLoader />}>
|
||||
<LoanTypesPage />
|
||||
</Suspense>
|
||||
),
|
||||
},
|
||||
{
|
||||
path: "/settings/loan/loan-types/create",
|
||||
element: (
|
||||
<Suspense fallback={<PageLoader />}>
|
||||
<LoanTypeCreatePage />
|
||||
</Suspense>
|
||||
),
|
||||
},
|
||||
{
|
||||
path: "/settings/loan/loan-types/:id",
|
||||
element: (
|
||||
<Suspense fallback={<PageLoader />}>
|
||||
<LoanTypesViewPage />
|
||||
</Suspense>
|
||||
),
|
||||
},
|
||||
{
|
||||
path: "/settings/loan/loan-types/:id/edit",
|
||||
element: (
|
||||
<Suspense fallback={<PageLoader />}>
|
||||
<LoanTypeEditPage />
|
||||
</Suspense>
|
||||
),
|
||||
},
|
||||
{
|
||||
path: "/settings/loan/required-documents",
|
||||
element: (
|
||||
<Suspense fallback={<PageLoader />}>
|
||||
<RequiredDocumentsPage />
|
||||
</Suspense>
|
||||
),
|
||||
},
|
||||
{
|
||||
path: "/settings/loan/required-documents/create",
|
||||
element: (
|
||||
<Suspense fallback={<PageLoader />}>
|
||||
<RequiredDocumentCreatePage />
|
||||
</Suspense>
|
||||
),
|
||||
},
|
||||
{
|
||||
path: "/settings/loan/required-documents/:id",
|
||||
element: (
|
||||
<Suspense fallback={<PageLoader />}>
|
||||
<RequiredDocumentsViewPage />
|
||||
</Suspense>
|
||||
),
|
||||
},
|
||||
{
|
||||
path: "/settings/loan/required-documents/:id/edit",
|
||||
element: (
|
||||
<Suspense fallback={<PageLoader />}>
|
||||
<RequiredDocumentEditPage />
|
||||
</Suspense>
|
||||
),
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
|
||||
169
src/features/loanTypes/api/loanTypesApi.ts
Normal file
169
src/features/loanTypes/api/loanTypesApi.ts
Normal file
@@ -0,0 +1,169 @@
|
||||
// features/loanTypes/api/loanTypesApi.ts
|
||||
|
||||
export interface LoanTypeTranslation {
|
||||
tk: string
|
||||
ru: string
|
||||
en: string
|
||||
}
|
||||
|
||||
export interface LoanType {
|
||||
id: number
|
||||
name: LoanTypeTranslation
|
||||
tax: number
|
||||
loanTerm: number
|
||||
notes: LoanTypeTranslation | null
|
||||
isActive: boolean
|
||||
createdAt: string
|
||||
updatedAt: string
|
||||
}
|
||||
|
||||
export interface LoanTypeListParams {
|
||||
page?: number
|
||||
perPage?: number
|
||||
search?: string
|
||||
}
|
||||
|
||||
export interface LoanTypeListResponse {
|
||||
data: LoanType[]
|
||||
total: number
|
||||
page: number
|
||||
perPage: number
|
||||
totalPages: number
|
||||
}
|
||||
|
||||
export interface CreateLoanTypePayload {
|
||||
name: LoanTypeTranslation
|
||||
tax: number
|
||||
loanTerm: number
|
||||
notes: LoanTypeTranslation | null
|
||||
isActive: boolean
|
||||
}
|
||||
|
||||
export type UpdateLoanTypePayload = CreateLoanTypePayload
|
||||
|
||||
// ─── Mock Data ────────────────────────────────────────────────────────────────
|
||||
|
||||
const MOCK_LOAN_TYPES: LoanType[] = [
|
||||
{
|
||||
id: 5,
|
||||
name: { tk: 'Talyp karzy', ru: 'Студенческий кредит', en: 'Student Loan' },
|
||||
tax: 1,
|
||||
loanTerm: 30,
|
||||
notes: { tk: 'Bellik', ru: 'Примечание', en: 'Note' },
|
||||
isActive: true,
|
||||
createdAt: '2026-01-10T08:00:00Z',
|
||||
updatedAt: '2026-03-15T10:30:00Z',
|
||||
},
|
||||
{
|
||||
id: 4,
|
||||
name: {
|
||||
tk: 'Üpjünçiligine girew emlägi bolan sarp ediş karzy',
|
||||
ru: 'Потребительский кредит под залог имущества',
|
||||
en: 'Consumer Loan Secured by Property',
|
||||
},
|
||||
tax: 1,
|
||||
loanTerm: 30,
|
||||
notes: null,
|
||||
isActive: true,
|
||||
createdAt: '2026-01-08T09:00:00Z',
|
||||
updatedAt: '2026-02-20T11:00:00Z',
|
||||
},
|
||||
{
|
||||
id: 3,
|
||||
name: { tk: 'Kiçi göwrümli karzlar', ru: 'Микрокредиты', en: 'Micro Loans' },
|
||||
tax: 1,
|
||||
loanTerm: 30,
|
||||
notes: null,
|
||||
isActive: true,
|
||||
createdAt: '2026-01-05T07:00:00Z',
|
||||
updatedAt: '2026-01-05T07:00:00Z',
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
name: {
|
||||
tk: 'Üpjünçiligine zamunlyk bolan sarp ediş karzy',
|
||||
ru: 'Потребительский кредит под поручительство',
|
||||
en: 'Consumer Loan with Guarantor',
|
||||
},
|
||||
tax: 1,
|
||||
loanTerm: 30,
|
||||
notes: null,
|
||||
isActive: true,
|
||||
createdAt: '2026-01-03T06:00:00Z',
|
||||
updatedAt: '2026-01-03T06:00:00Z',
|
||||
},
|
||||
{
|
||||
id: 1,
|
||||
name: { tk: 'Ýaş çatynjalara', ru: 'Молодожёнам', en: 'Newlyweds Loan' },
|
||||
tax: 1,
|
||||
loanTerm: 30,
|
||||
notes: null,
|
||||
isActive: true,
|
||||
createdAt: '2026-01-01T00:00:00Z',
|
||||
updatedAt: '2026-01-01T00:00:00Z',
|
||||
},
|
||||
]
|
||||
|
||||
let _mockStore: LoanType[] = [...MOCK_LOAN_TYPES]
|
||||
let _nextId = 6
|
||||
|
||||
const delay = (ms = 400) => new Promise<void>((res) => setTimeout(res, ms))
|
||||
|
||||
// ─── API Functions ────────────────────────────────────────────────────────────
|
||||
|
||||
export async function fetchLoanTypes(params: LoanTypeListParams = {}): Promise<LoanTypeListResponse> {
|
||||
await delay()
|
||||
const { page = 1, perPage = 25, search = '' } = params
|
||||
|
||||
const filtered = search.trim()
|
||||
? _mockStore.filter((lt) =>
|
||||
lt.name.tk.toLowerCase().includes(search.toLowerCase()) ||
|
||||
lt.name.ru.toLowerCase().includes(search.toLowerCase()) ||
|
||||
lt.name.en.toLowerCase().includes(search.toLowerCase())
|
||||
)
|
||||
: _mockStore
|
||||
|
||||
const sorted = [...filtered].sort((a, b) => b.id - a.id)
|
||||
const start = (page - 1) * perPage
|
||||
const data = sorted.slice(start, start + perPage)
|
||||
|
||||
return {
|
||||
data,
|
||||
total: filtered.length,
|
||||
page,
|
||||
perPage,
|
||||
totalPages: Math.max(1, Math.ceil(filtered.length / perPage)),
|
||||
}
|
||||
}
|
||||
|
||||
export async function fetchLoanTypeById(id: number): Promise<LoanType> {
|
||||
await delay()
|
||||
const found = _mockStore.find((lt) => lt.id === id)
|
||||
if (!found) throw new Error(`LoanType with id=${id} not found`)
|
||||
return { ...found }
|
||||
}
|
||||
|
||||
export async function createLoanType(payload: CreateLoanTypePayload): Promise<LoanType> {
|
||||
await delay()
|
||||
const newItem: LoanType = {
|
||||
id: _nextId++,
|
||||
...payload,
|
||||
createdAt: new Date().toISOString(),
|
||||
updatedAt: new Date().toISOString(),
|
||||
}
|
||||
_mockStore = [newItem, ..._mockStore]
|
||||
return { ...newItem }
|
||||
}
|
||||
|
||||
export async function updateLoanType(id: number, payload: UpdateLoanTypePayload): Promise<LoanType> {
|
||||
await delay()
|
||||
const idx = _mockStore.findIndex((lt) => lt.id === id)
|
||||
if (idx === -1) throw new Error(`LoanType with id=${id} not found`)
|
||||
_mockStore[idx] = { ..._mockStore[idx], ...payload, updatedAt: new Date().toISOString() }
|
||||
return { ..._mockStore[idx] }
|
||||
}
|
||||
|
||||
export async function deleteLoanType(id: number): Promise<void> {
|
||||
await delay()
|
||||
_mockStore = _mockStore.filter((lt) => lt.id !== id)
|
||||
}
|
||||
268
src/features/loanTypes/components/loanTypesForm.tsx
Normal file
268
src/features/loanTypes/components/loanTypesForm.tsx
Normal file
@@ -0,0 +1,268 @@
|
||||
// features/loanTypes/components/LoanTypeForm.tsx
|
||||
|
||||
import { useState, useEffect } from 'react'
|
||||
import { useNavigate } from 'react-router-dom'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import { FormInput } from '@/components/formInput'
|
||||
import { Button } from '@/components/ui/button'
|
||||
import { Label } from '@/components/ui/label'
|
||||
import { Checkbox } from '@/components/ui/checkbox'
|
||||
import { useCreateLoanType, useUpdateLoanType } from '../hooks/useLoanTypes'
|
||||
import type { LoanType, CreateLoanTypePayload } from '../api/loanTypesApi'
|
||||
|
||||
// ─── Types ────────────────────────────────────────────────────────────────────
|
||||
|
||||
type FormMode = 'create' | 'edit'
|
||||
|
||||
interface LoanTypeFormProps {
|
||||
mode: FormMode
|
||||
initialData?: LoanType
|
||||
loanTypeId?: number
|
||||
}
|
||||
|
||||
interface FormErrors {
|
||||
nameTk?: string
|
||||
nameRu?: string
|
||||
nameEn?: string
|
||||
tax?: string
|
||||
loanTerm?: string
|
||||
}
|
||||
|
||||
// ─── Language Tab ─────────────────────────────────────────────────────────────
|
||||
|
||||
type Lang = 'tk' | 'ru' | 'en'
|
||||
|
||||
const LANG_TABS: { key: Lang; label: string }[] = [
|
||||
{ key: 'tk', label: 'Türkmen' },
|
||||
{ key: 'ru', label: 'Русский' },
|
||||
{ key: 'en', label: 'English' },
|
||||
]
|
||||
|
||||
// ─── Validation ───────────────────────────────────────────────────────────────
|
||||
|
||||
function validate(
|
||||
nameTk: string,
|
||||
nameRu: string,
|
||||
nameEn: string,
|
||||
tax: string,
|
||||
loanTerm: string,
|
||||
t: (key: string, fallback: string) => string
|
||||
): FormErrors {
|
||||
const errors: FormErrors = {}
|
||||
if (!nameTk.trim()) errors.nameTk = t('validation.required', 'Hökmany meýdan')
|
||||
if (!nameRu.trim()) errors.nameRu = t('validation.required', 'Hökmany meýdan')
|
||||
if (!nameEn.trim()) errors.nameEn = t('validation.required', 'Hökmany meýdan')
|
||||
if (!tax || Number(tax) <= 0) errors.tax = t('validation.positiveNumber', 'Oňyn san gerek')
|
||||
if (!loanTerm || Number(loanTerm) <= 0) errors.loanTerm = t('validation.positiveNumber', 'Oňyn san gerek')
|
||||
return errors
|
||||
}
|
||||
|
||||
// ─── LoanTypeForm ─────────────────────────────────────────────────────────────
|
||||
|
||||
export function LoanTypeForm({ mode, initialData, loanTypeId }: LoanTypeFormProps) {
|
||||
const { t } = useTranslation()
|
||||
const navigate = useNavigate()
|
||||
|
||||
const createMutation = useCreateLoanType()
|
||||
const updateMutation = useUpdateLoanType(loanTypeId ?? 0)
|
||||
|
||||
const isPending = createMutation.isPending || updateMutation.isPending
|
||||
|
||||
// ── State ──────────────────────────────────────────────────────────────────
|
||||
const [activeLang, setActiveLang] = useState<Lang>('tk')
|
||||
const [nameTk, setNameTk] = useState('')
|
||||
const [nameRu, setNameRu] = useState('')
|
||||
const [nameEn, setNameEn] = useState('')
|
||||
const [notesTk, setNotesTk] = useState('')
|
||||
const [notesRu, setNotesRu] = useState('')
|
||||
const [notesEn, setNotesEn] = useState('')
|
||||
const [tax, setTax] = useState('')
|
||||
const [loanTerm, setLoanTerm] = useState('')
|
||||
const [isActive, setIsActive] = useState(true)
|
||||
const [errors, setErrors] = useState<FormErrors>({})
|
||||
|
||||
// ── Populate on edit ───────────────────────────────────────────────────────
|
||||
useEffect(() => {
|
||||
if (mode === 'edit' && initialData) {
|
||||
setNameTk(initialData.name.tk)
|
||||
setNameRu(initialData.name.ru)
|
||||
setNameEn(initialData.name.en)
|
||||
setNotesTk(initialData.notes?.tk ?? '')
|
||||
setNotesRu(initialData.notes?.ru ?? '')
|
||||
setNotesEn(initialData.notes?.en ?? '')
|
||||
setTax(String(initialData.tax))
|
||||
setLoanTerm(String(initialData.loanTerm))
|
||||
setIsActive(initialData.isActive)
|
||||
}
|
||||
}, [mode, initialData])
|
||||
|
||||
// ── Submit ─────────────────────────────────────────────────────────────────
|
||||
const handleSubmit = async () => {
|
||||
const validationErrors = validate(nameTk, nameRu, nameEn, tax, loanTerm, t)
|
||||
if (Object.keys(validationErrors).length > 0) {
|
||||
setErrors(validationErrors)
|
||||
return
|
||||
}
|
||||
setErrors({})
|
||||
|
||||
const payload: CreateLoanTypePayload = {
|
||||
name: { tk: nameTk.trim(), ru: nameRu.trim(), en: nameEn.trim() },
|
||||
tax: Number(tax),
|
||||
loanTerm: Number(loanTerm),
|
||||
notes:
|
||||
notesTk.trim() || notesRu.trim() || notesEn.trim()
|
||||
? { tk: notesTk.trim(), ru: notesRu.trim(), en: notesEn.trim() }
|
||||
: null,
|
||||
isActive,
|
||||
}
|
||||
|
||||
if (mode === 'create') {
|
||||
const result = await createMutation.mutateAsync(payload)
|
||||
navigate(`/resources/loan-types/${result.id}`)
|
||||
} else {
|
||||
await updateMutation.mutateAsync(payload)
|
||||
navigate(`/resources/loan-types/${loanTypeId}`)
|
||||
}
|
||||
}
|
||||
|
||||
const handleCancel = () => navigate('/resources/loan-types')
|
||||
|
||||
// ── Name fields per lang ───────────────────────────────────────────────────
|
||||
const nameFields: Record<Lang, { value: string; onChange: (v: string) => void; error?: string }> = {
|
||||
tk: { value: nameTk, onChange: setNameTk, error: errors.nameTk },
|
||||
ru: { value: nameRu, onChange: setNameRu, error: errors.nameRu },
|
||||
en: { value: nameEn, onChange: setNameEn, error: errors.nameEn },
|
||||
}
|
||||
|
||||
const notesFields: Record<Lang, { value: string; onChange: (v: string) => void }> = {
|
||||
tk: { value: notesTk, onChange: setNotesTk },
|
||||
ru: { value: notesRu, onChange: setNotesRu },
|
||||
en: { value: notesEn, onChange: setNotesEn },
|
||||
}
|
||||
|
||||
// ─────────────────────────────────────────────────────────────────────────
|
||||
|
||||
return (
|
||||
<div className="space-y-0">
|
||||
{/* Language tabs row */}
|
||||
<div className="flex items-center justify-end gap-1 mb-0 pb-0">
|
||||
{LANG_TABS.map((tab) => (
|
||||
<button
|
||||
key={tab.key}
|
||||
type="button"
|
||||
onClick={() => setActiveLang(tab.key)}
|
||||
className={`px-3 py-1 text-sm rounded-md transition-colors ${
|
||||
activeLang === tab.key
|
||||
? 'text-primary font-semibold'
|
||||
: 'text-muted-foreground hover:text-foreground'
|
||||
}`}
|
||||
>
|
||||
{tab.label}
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
|
||||
{/* Form card */}
|
||||
<div className="bg-card border border-border rounded-xl overflow-hidden divide-y divide-border">
|
||||
{/* Ady */}
|
||||
<div className="grid grid-cols-[220px_1fr] items-center px-4 py-3">
|
||||
<span className="text-sm text-muted-foreground">
|
||||
{t('loanTypes.fields.name', 'Ady')}
|
||||
<span className="text-destructive ml-0.5">*</span>
|
||||
</span>
|
||||
<FormInput
|
||||
type="text"
|
||||
value={nameFields[activeLang].value}
|
||||
onChange={nameFields[activeLang].onChange}
|
||||
placeholder={t('loanTypes.fields.name', 'Ady')}
|
||||
error={nameFields[activeLang].error}
|
||||
/>
|
||||
</div>
|
||||
|
||||
{/* Salgyt */}
|
||||
<div className="grid grid-cols-[220px_1fr] items-center px-4 py-3">
|
||||
<span className="text-sm text-muted-foreground">
|
||||
{t('loanTypes.fields.tax', 'Salgyt')}
|
||||
<span className="text-destructive ml-0.5">*</span>
|
||||
</span>
|
||||
<FormInput
|
||||
type="number"
|
||||
value={tax}
|
||||
onChange={setTax}
|
||||
placeholder={t('loanTypes.fields.tax', 'Salgyt')}
|
||||
error={errors.tax}
|
||||
/>
|
||||
</div>
|
||||
|
||||
{/* Karz möhleti */}
|
||||
<div className="grid grid-cols-[220px_1fr] items-center px-4 py-3">
|
||||
<span className="text-sm text-muted-foreground">
|
||||
{t('loanTypes.fields.loanTerm', 'Karz möhleti')}
|
||||
<span className="text-destructive ml-0.5">*</span>
|
||||
</span>
|
||||
<FormInput
|
||||
type="number"
|
||||
value={loanTerm}
|
||||
onChange={setLoanTerm}
|
||||
placeholder={t('loanTypes.fields.loanTerm', 'Karz möhleti')}
|
||||
error={errors.loanTerm}
|
||||
/>
|
||||
</div>
|
||||
|
||||
{/* Bellikler */}
|
||||
<div className="grid grid-cols-[220px_1fr] items-center px-4 py-3">
|
||||
<span className="text-sm text-muted-foreground">
|
||||
{t('loanTypes.fields.notes', 'Bellikler')}
|
||||
</span>
|
||||
<FormInput
|
||||
type="text"
|
||||
value={notesFields[activeLang].value}
|
||||
onChange={notesFields[activeLang].onChange}
|
||||
placeholder={t('loanTypes.fields.notes', 'Bellikler')}
|
||||
/>
|
||||
</div>
|
||||
|
||||
{/* Işjeň */}
|
||||
<div className="grid grid-cols-[220px_1fr] items-center px-4 py-3">
|
||||
<span className="text-sm text-muted-foreground">
|
||||
{t('loanTypes.fields.isActive', 'Işjeň')}
|
||||
</span>
|
||||
<div className="flex items-center gap-2">
|
||||
<Checkbox
|
||||
id="isActive"
|
||||
checked={isActive}
|
||||
/>
|
||||
<Label htmlFor="isActive" className="text-sm text-foreground cursor-pointer">
|
||||
{isActive
|
||||
? t('common.active', 'Işjeň')
|
||||
: t('common.inactive', 'Işjeň däl')}
|
||||
</Label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Actions */}
|
||||
<div className="flex items-center justify-end gap-3 pt-4">
|
||||
<Button
|
||||
type="button"
|
||||
variant="ghost"
|
||||
onClick={handleCancel}
|
||||
disabled={isPending}
|
||||
>
|
||||
{t('common.cancel', 'Ýatyr')}
|
||||
</Button>
|
||||
<Button
|
||||
type="button"
|
||||
onClick={handleSubmit}
|
||||
disabled={isPending}
|
||||
>
|
||||
{isPending
|
||||
? t('common.saving', 'Saklanýar...')
|
||||
: mode === 'create'
|
||||
? t('loanTypes.actions.create', 'Karz görnüşi dörediň')
|
||||
: t('loanTypes.actions.save', 'Ýatda sakla')}
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
97
src/features/loanTypes/hooks/useLoanTypes.ts
Normal file
97
src/features/loanTypes/hooks/useLoanTypes.ts
Normal file
@@ -0,0 +1,97 @@
|
||||
// features/loanTypes/hooks/useLoanTypes.ts
|
||||
|
||||
import { useQuery, useMutation, useQueryClient } from '@tanstack/react-query'
|
||||
import { toast } from 'sonner'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import {
|
||||
fetchLoanTypes,
|
||||
fetchLoanTypeById,
|
||||
createLoanType,
|
||||
updateLoanType,
|
||||
deleteLoanType,
|
||||
type LoanTypeListParams,
|
||||
type CreateLoanTypePayload,
|
||||
type UpdateLoanTypePayload,
|
||||
} from '../api/loanTypesApi'
|
||||
|
||||
// ─── Query Keys ───────────────────────────────────────────────────────────────
|
||||
|
||||
export const loanTypeKeys = {
|
||||
all: () => ['loanTypes'] as const,
|
||||
list: (params: LoanTypeListParams) => ['loanTypes', 'list', params] as const,
|
||||
detail: (id: number) => ['loanTypes', 'detail', id] as const,
|
||||
}
|
||||
|
||||
// ─── useGetLoanTypes ──────────────────────────────────────────────────────────
|
||||
|
||||
export function useGetLoanTypes(params: LoanTypeListParams = {}) {
|
||||
return useQuery({
|
||||
queryKey: loanTypeKeys.list(params),
|
||||
queryFn: () => fetchLoanTypes(params),
|
||||
placeholderData: (prev) => prev,
|
||||
})
|
||||
}
|
||||
|
||||
// ─── useGetLoanTypeById ───────────────────────────────────────────────────────
|
||||
|
||||
export function useGetLoanTypeById(id: number | undefined) {
|
||||
return useQuery({
|
||||
queryKey: loanTypeKeys.detail(id!),
|
||||
queryFn: () => fetchLoanTypeById(id!),
|
||||
enabled: !!id,
|
||||
})
|
||||
}
|
||||
|
||||
// ─── useCreateLoanType ────────────────────────────────────────────────────────
|
||||
|
||||
export function useCreateLoanType() {
|
||||
const queryClient = useQueryClient()
|
||||
const { t } = useTranslation()
|
||||
|
||||
return useMutation({
|
||||
mutationFn: (payload: CreateLoanTypePayload) => createLoanType(payload),
|
||||
onSuccess: () => {
|
||||
queryClient.invalidateQueries({ queryKey: loanTypeKeys.all() })
|
||||
toast.success(t('loanTypes.toast.created', 'Karz görnüşi üstünlikli döredildi'))
|
||||
},
|
||||
onError: (error: Error) => {
|
||||
toast.error(error.message || t('loanTypes.toast.createError', 'Döretmek başartmady'))
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
// ─── useUpdateLoanType ────────────────────────────────────────────────────────
|
||||
|
||||
export function useUpdateLoanType(id: number) {
|
||||
const queryClient = useQueryClient()
|
||||
const { t } = useTranslation()
|
||||
|
||||
return useMutation({
|
||||
mutationFn: (payload: UpdateLoanTypePayload) => updateLoanType(id, payload),
|
||||
onSuccess: () => {
|
||||
queryClient.invalidateQueries({ queryKey: loanTypeKeys.all() })
|
||||
toast.success(t('loanTypes.toast.updated', 'Karz görnüşi üstünlikli täzelendi'))
|
||||
},
|
||||
onError: (error: Error) => {
|
||||
toast.error(error.message || t('loanTypes.toast.updateError', 'Täzelemek başartmady'))
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
// ─── useDeleteLoanType ────────────────────────────────────────────────────────
|
||||
|
||||
export function useDeleteLoanType() {
|
||||
const queryClient = useQueryClient()
|
||||
const { t } = useTranslation()
|
||||
|
||||
return useMutation({
|
||||
mutationFn: (id: number) => deleteLoanType(id),
|
||||
onSuccess: () => {
|
||||
queryClient.invalidateQueries({ queryKey: loanTypeKeys.all() })
|
||||
toast.success(t('loanTypes.toast.deleted', 'Karz görnüşi üstünlikli pozuldy'))
|
||||
},
|
||||
onError: (error: Error) => {
|
||||
toast.error(error.message || t('loanTypes.toast.deleteError', 'Pozmak başartmady'))
|
||||
},
|
||||
})
|
||||
}
|
||||
163
src/features/requiredDocuments/api/requiredDocumentsApi.ts
Normal file
163
src/features/requiredDocuments/api/requiredDocumentsApi.ts
Normal file
@@ -0,0 +1,163 @@
|
||||
// ─── Types ────────────────────────────────────────────────────────────────────
|
||||
|
||||
export interface LoanDocumentTranslation {
|
||||
tk: string
|
||||
ru: string
|
||||
en: string
|
||||
}
|
||||
|
||||
export interface LoanDocument {
|
||||
id: number
|
||||
name: LoanDocumentTranslation
|
||||
description: LoanDocumentTranslation
|
||||
createdAt: string
|
||||
updatedAt: string
|
||||
}
|
||||
|
||||
export interface LoanDocumentPayload {
|
||||
name: LoanDocumentTranslation
|
||||
description: LoanDocumentTranslation
|
||||
}
|
||||
|
||||
export interface PaginatedResponse<T> {
|
||||
data: T[]
|
||||
total: number
|
||||
page: number
|
||||
perPage: number
|
||||
totalPages: number
|
||||
}
|
||||
|
||||
export interface ListParams {
|
||||
page?: number
|
||||
perPage?: number
|
||||
search?: string
|
||||
}
|
||||
|
||||
// ─── Mock Data ────────────────────────────────────────────────────────────────
|
||||
|
||||
const MOCK_LOAN_DOCUMENTS: LoanDocument[] = [
|
||||
{
|
||||
id: 1,
|
||||
name: {
|
||||
tk: 'Hormatly müşderi! Siziň ýüztutmaňyz kanagatlandyryldy!',
|
||||
ru: 'Уважаемый клиент! Ваше обращение удовлетворено!',
|
||||
en: 'Dear customer! Your request has been approved!',
|
||||
},
|
||||
description: {
|
||||
tk: 'Siziň karz sargydyňyz üstünlikli kabul edildi we tassyklandy.',
|
||||
ru: 'Ваша заявка на кредит успешно принята и подтверждена.',
|
||||
en: 'Your loan application has been successfully received and confirmed.',
|
||||
},
|
||||
createdAt: '2026-01-15T10:30:00Z',
|
||||
updatedAt: '2026-01-15T10:30:00Z',
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
name: {
|
||||
tk: 'Hormatly müşderi! Siziň ýüztutmaňyz kanagatlandyrylmady!',
|
||||
ru: 'Уважаемый клиент! Ваше обращение не удовлетворено!',
|
||||
en: 'Dear customer! Your request has been rejected!',
|
||||
},
|
||||
description: {
|
||||
tk: 'Siziň bank kart maglumatlaryňyz tapylmandygy sebäpli Siziň ýüztutmaňyz kanagatlandyrylmady! Bank kartyňyz boýunça hyzmat ediji bankyňyza ýüz tutmagyňyzy Sizden haýyş edýäris.',
|
||||
ru: 'Ваше обращение не удовлетворено в связи с тем, что данные вашей банковской карты не найдены! Просим вас обратиться в банк, обслуживающий вашу банковскую карту.',
|
||||
en: 'Your request has been rejected because your bank card information was not found! We kindly ask you to contact the bank that services your card.',
|
||||
},
|
||||
createdAt: '2026-02-20T14:15:00Z',
|
||||
updatedAt: '2026-03-10T09:00:00Z',
|
||||
},
|
||||
{
|
||||
id: 3,
|
||||
name: {
|
||||
tk: 'Karz resminama talap edilýär',
|
||||
ru: 'Требуется документ для кредита',
|
||||
en: 'Loan document required',
|
||||
},
|
||||
description: {
|
||||
tk: 'Karz almak üçin zerur resminamalary tabşyrmagyňyzy haýyş edýäris.',
|
||||
ru: 'Просим вас предоставить необходимые документы для получения кредита.',
|
||||
en: 'Please submit the required documents to obtain the loan.',
|
||||
},
|
||||
createdAt: '2026-03-05T08:00:00Z',
|
||||
updatedAt: '2026-03-05T08:00:00Z',
|
||||
},
|
||||
]
|
||||
|
||||
let mockStore = [...MOCK_LOAN_DOCUMENTS]
|
||||
let nextId = mockStore.length + 1
|
||||
|
||||
// ─── Simulated delay ──────────────────────────────────────────────────────────
|
||||
|
||||
const delay = (ms = 400) => new Promise((r) => setTimeout(r, ms))
|
||||
|
||||
// ─── API Functions ────────────────────────────────────────────────────────────
|
||||
|
||||
export async function fetchLoanDocuments(
|
||||
params: ListParams = {}
|
||||
): Promise<PaginatedResponse<LoanDocument>> {
|
||||
await delay()
|
||||
const { page = 1, perPage = 10, search = '' } = params
|
||||
|
||||
let filtered = mockStore
|
||||
if (search.trim()) {
|
||||
const q = search.toLowerCase()
|
||||
filtered = mockStore.filter(
|
||||
(d) =>
|
||||
d.name.tk.toLowerCase().includes(q) ||
|
||||
d.name.ru.toLowerCase().includes(q) ||
|
||||
d.name.en.toLowerCase().includes(q)
|
||||
)
|
||||
}
|
||||
|
||||
const total = filtered.length
|
||||
const totalPages = Math.ceil(total / perPage)
|
||||
const start = (page - 1) * perPage
|
||||
const data = filtered.slice(start, start + perPage)
|
||||
|
||||
return { data, total, page, perPage, totalPages }
|
||||
}
|
||||
|
||||
export async function fetchLoanDocumentById(id: number): Promise<LoanDocument> {
|
||||
await delay()
|
||||
const doc = mockStore.find((d) => d.id === id)
|
||||
if (!doc) throw new Error(`LoanDocument with id ${id} not found`)
|
||||
return { ...doc }
|
||||
}
|
||||
|
||||
export async function createLoanDocument(
|
||||
payload: LoanDocumentPayload
|
||||
): Promise<LoanDocument> {
|
||||
await delay(600)
|
||||
const now = new Date().toISOString()
|
||||
const newDoc: LoanDocument = {
|
||||
id: nextId++,
|
||||
...payload,
|
||||
createdAt: now,
|
||||
updatedAt: now,
|
||||
}
|
||||
mockStore = [newDoc, ...mockStore]
|
||||
return { ...newDoc }
|
||||
}
|
||||
|
||||
export async function updateLoanDocument(
|
||||
id: number,
|
||||
payload: LoanDocumentPayload
|
||||
): Promise<LoanDocument> {
|
||||
await delay(600)
|
||||
const index = mockStore.findIndex((d) => d.id === id)
|
||||
if (index === -1) throw new Error(`LoanDocument with id ${id} not found`)
|
||||
const updated: LoanDocument = {
|
||||
...mockStore[index],
|
||||
...payload,
|
||||
updatedAt: new Date().toISOString(),
|
||||
}
|
||||
mockStore = mockStore.map((d) => (d.id === id ? updated : d))
|
||||
return { ...updated }
|
||||
}
|
||||
|
||||
export async function deleteLoanDocument(id: number): Promise<void> {
|
||||
await delay(400)
|
||||
const exists = mockStore.some((d) => d.id === id)
|
||||
if (!exists) throw new Error(`LoanDocument with id ${id} not found`)
|
||||
mockStore = mockStore.filter((d) => d.id !== id)
|
||||
}
|
||||
@@ -0,0 +1,311 @@
|
||||
import { useState, useEffect } from 'react'
|
||||
import { useNavigate } from 'react-router-dom'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import { useEditor, EditorContent } from '@tiptap/react'
|
||||
import StarterKit from '@tiptap/starter-kit'
|
||||
import Link from '@tiptap/extension-link'
|
||||
import {
|
||||
Bold,
|
||||
Italic,
|
||||
Strikethrough,
|
||||
Link2,
|
||||
Heading2,
|
||||
Quote,
|
||||
Code,
|
||||
List,
|
||||
ListOrdered,
|
||||
Minus,
|
||||
WrapText,
|
||||
Paperclip,
|
||||
Type,
|
||||
} from 'lucide-react'
|
||||
import { cn } from '@/lib/utils'
|
||||
import { FormInput } from '@/components/formInput'
|
||||
import { Button } from '@/components/ui/button'
|
||||
import { useCreateRequiredDocument, useUpdateRequiredDocument } from '../hooks/useRequiredDocuments'
|
||||
import type { LoanDocument, LoanDocumentPayload, LoanDocumentTranslation } from '../api/requiredDocumentsApi'
|
||||
|
||||
// ─── Types ────────────────────────────────────────────────────────────────────
|
||||
|
||||
type Locale = 'tk' | 'ru' | 'en'
|
||||
|
||||
interface RequiredDocumentFormProps {
|
||||
mode: 'create' | 'edit'
|
||||
initialData?: LoanDocument
|
||||
requiredDocumentId?: number
|
||||
}
|
||||
|
||||
// ─── Lang tabs ────────────────────────────────────────────────────────────────
|
||||
|
||||
const LOCALES: { code: Locale; label: string }[] = [
|
||||
{ code: 'tk', label: 'Türkmen' },
|
||||
{ code: 'ru', label: 'Русский' },
|
||||
{ code: 'en', label: 'English' },
|
||||
]
|
||||
|
||||
// ─── Tiptap Toolbar ───────────────────────────────────────────────────────────
|
||||
|
||||
interface RichTextToolbarProps {
|
||||
editor: ReturnType<typeof useEditor>
|
||||
}
|
||||
|
||||
function RichTextToolbar({ editor }: RichTextToolbarProps) {
|
||||
if (!editor) return null
|
||||
|
||||
const tools = [
|
||||
{ icon: Bold, action: () => editor.chain().focus().toggleBold().run(), active: editor.isActive('bold'), title: 'Bold' },
|
||||
{ icon: Italic, action: () => editor.chain().focus().toggleItalic().run(), active: editor.isActive('italic'), title: 'Italic' },
|
||||
{ icon: Strikethrough, action: () => editor.chain().focus().toggleStrike().run(), active: editor.isActive('strike'), title: 'Strike' },
|
||||
{ icon: Link2, action: () => {
|
||||
const url = prompt('URL giriziň:')
|
||||
if (url) editor.chain().focus().setLink({ href: url }).run()
|
||||
}, active: editor.isActive('link'), title: 'Link' },
|
||||
{ icon: Heading2, action: () => editor.chain().focus().toggleHeading({ level: 2 }).run(), active: editor.isActive('heading', { level: 2 }), title: 'H2' },
|
||||
{ icon: Quote, action: () => editor.chain().focus().toggleBlockquote().run(), active: editor.isActive('blockquote'), title: 'Quote' },
|
||||
{ icon: Code, action: () => editor.chain().focus().toggleCode().run(), active: editor.isActive('code'), title: 'Code' },
|
||||
{ icon: List, action: () => editor.chain().focus().toggleBulletList().run(), active: editor.isActive('bulletList'), title: 'Bullet List' },
|
||||
{ icon: ListOrdered, action: () => editor.chain().focus().toggleOrderedList().run(), active: editor.isActive('orderedList'), title: 'Ordered List' },
|
||||
{ icon: Minus, action: () => editor.chain().focus().setHorizontalRule().run(), active: false, title: 'Divider' },
|
||||
{ icon: WrapText, action: () => editor.chain().focus().setHardBreak().run(), active: false, title: 'Hard Break' },
|
||||
{ icon: Paperclip, action: () => {}, active: false, title: 'Attachment' },
|
||||
{ icon: Type, action: () => editor.chain().focus().clearNodes().unsetAllMarks().run(), active: false, title: 'Clear format' },
|
||||
]
|
||||
|
||||
return (
|
||||
<div className="flex flex-wrap items-center gap-0.5 p-1.5 border-b border-border bg-muted/30">
|
||||
{tools.map(({ icon: Icon, action, active, title }) => (
|
||||
<button
|
||||
key={title}
|
||||
type="button"
|
||||
title={title}
|
||||
onMouseDown={(e) => { e.preventDefault(); action() }}
|
||||
className={cn(
|
||||
'flex items-center justify-center w-7 h-7 rounded text-muted-foreground',
|
||||
'hover:bg-muted hover:text-foreground transition-colors',
|
||||
active && 'bg-primary/10 text-primary'
|
||||
)}
|
||||
>
|
||||
<Icon size={14} />
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
// ─── RichTextEditor ───────────────────────────────────────────────────────────
|
||||
|
||||
interface RichTextEditorProps {
|
||||
value: string
|
||||
onChange: (html: string) => void
|
||||
error?: string
|
||||
}
|
||||
|
||||
function RichTextEditor({ value, onChange, error }: RichTextEditorProps) {
|
||||
const editor = useEditor({
|
||||
extensions: [StarterKit, Link.configure({ openOnClick: false })],
|
||||
content: value,
|
||||
onUpdate: ({ editor }) => onChange(editor.getHTML()),
|
||||
})
|
||||
|
||||
// Sync external value changes (e.g. tab switch)
|
||||
useEffect(() => {
|
||||
if (editor && editor.getHTML() !== value) {
|
||||
editor.commands.setContent(value, { emitUpdate: false })
|
||||
}
|
||||
}, [value, editor])
|
||||
|
||||
return (
|
||||
<div
|
||||
className={cn(
|
||||
'rounded-md border bg-background overflow-hidden',
|
||||
error ? 'border-destructive' : 'border-input',
|
||||
'focus-within:ring-1 focus-within:ring-ring'
|
||||
)}
|
||||
>
|
||||
<RichTextToolbar editor={editor} />
|
||||
<EditorContent
|
||||
editor={editor}
|
||||
className="min-h-[120px] px-3 py-2 text-sm text-foreground prose prose-sm dark:prose-invert max-w-none focus:outline-none [&_.ProseMirror]:focus:outline-none"
|
||||
/>
|
||||
{error && (
|
||||
<p className="px-3 pb-2 text-xs text-destructive font-medium flex items-center gap-1.5">
|
||||
<span className="inline-block w-1 h-1 rounded-full bg-destructive shrink-0" />
|
||||
{error}
|
||||
</p>
|
||||
)}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
// ─── LangTabs ────────────────────────────────────────────────────────────────
|
||||
|
||||
interface LangTabsProps {
|
||||
active: Locale
|
||||
onChange: (locale: Locale) => void
|
||||
}
|
||||
|
||||
function LangTabs({ active, onChange }: LangTabsProps) {
|
||||
return (
|
||||
<div className="flex items-center justify-end gap-3 mb-2">
|
||||
{LOCALES.map(({ code, label }) => (
|
||||
<button
|
||||
key={code}
|
||||
type="button"
|
||||
onClick={() => onChange(code)}
|
||||
className={cn(
|
||||
'text-sm transition-colors',
|
||||
active === code
|
||||
? 'text-primary font-semibold underline underline-offset-4'
|
||||
: 'text-muted-foreground hover:text-foreground'
|
||||
)}
|
||||
>
|
||||
{label}
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
// ─── Empty translation ────────────────────────────────────────────────────────
|
||||
|
||||
const emptyTranslation = (): LoanDocumentTranslation => ({ tk: '', ru: '', en: '' })
|
||||
|
||||
// ─── RequiredDocumentForm ─────────────────────────────────────────────────────────
|
||||
|
||||
export function RequiredDocumentForm({ mode, initialData, requiredDocumentId }: RequiredDocumentFormProps) {
|
||||
const { t } = useTranslation()
|
||||
const navigate = useNavigate()
|
||||
|
||||
// Per-field locale tabs
|
||||
const [nameLang, setNameLang] = useState<Locale>('tk')
|
||||
const [descLang, setDescLang] = useState<Locale>('tk')
|
||||
|
||||
// Form state
|
||||
const [name, setName] = useState<LoanDocumentTranslation>(
|
||||
initialData?.name ?? emptyTranslation()
|
||||
)
|
||||
const [description, setDescription] = useState<LoanDocumentTranslation>(
|
||||
initialData?.description ?? emptyTranslation()
|
||||
)
|
||||
|
||||
// Errors
|
||||
const [errors, setErrors] = useState<Partial<Record<`name_${Locale}` | `desc_${Locale}`, string>>>({})
|
||||
|
||||
// Sync initial data on edit mode load
|
||||
useEffect(() => {
|
||||
if (initialData) {
|
||||
setName(initialData.name)
|
||||
setDescription(initialData.description)
|
||||
}
|
||||
}, [initialData])
|
||||
|
||||
const createMutation = useCreateRequiredDocument()
|
||||
const updateMutation = useUpdateRequiredDocument(requiredDocumentId ?? 0)
|
||||
|
||||
const isPending = createMutation.isPending || updateMutation.isPending
|
||||
|
||||
// ── Validation ──────────────────────────────────────────────────────────────
|
||||
|
||||
const validate = (): boolean => {
|
||||
const errs: typeof errors = {}
|
||||
LOCALES.forEach(({ code }) => {
|
||||
if (!name[code].trim()) {
|
||||
errs[`name_${code}`] = t('validation.required', 'Bu meýdan hökmany')
|
||||
}
|
||||
if (!description[code].replace(/<[^>]*>/g, '').trim()) {
|
||||
errs[`desc_${code}`] = t('validation.required', 'Bu meýdan hökmany')
|
||||
}
|
||||
})
|
||||
setErrors(errs)
|
||||
return Object.keys(errs).length === 0
|
||||
}
|
||||
|
||||
// ── Submit ──────────────────────────────────────────────────────────────────
|
||||
|
||||
const handleSubmit = async (e: React.FormEvent) => {
|
||||
e.preventDefault()
|
||||
if (!validate()) return
|
||||
|
||||
const payload: LoanDocumentPayload = { name, description }
|
||||
|
||||
if (mode === 'create') {
|
||||
await createMutation.mutateAsync(payload)
|
||||
navigate('/settings/loan/loan-documents')
|
||||
} else {
|
||||
await updateMutation.mutateAsync(payload)
|
||||
navigate('/settings/loan/loan-documents')
|
||||
}
|
||||
}
|
||||
|
||||
const submitLabel =
|
||||
mode === 'create'
|
||||
? t('loanDocuments.form.create', 'Karz gerekli resminamalary döretiň')
|
||||
: t('loanDocuments.form.update', 'Karz gerekli resminamalary täzele')
|
||||
|
||||
return (
|
||||
<form onSubmit={handleSubmit} noValidate>
|
||||
<div className="bg-card border border-border rounded-xl overflow-hidden divide-y divide-border">
|
||||
|
||||
{/* ── Name field ──────────────────────────────────────────────────── */}
|
||||
<div className="grid grid-cols-[220px_1fr] items-start py-4 px-4">
|
||||
<label className="text-sm text-muted-foreground pt-1">
|
||||
{t('loanDocuments.fields.name', 'Ady')}
|
||||
<span className="text-destructive ml-0.5">*</span>
|
||||
</label>
|
||||
<div>
|
||||
<LangTabs active={nameLang} onChange={setNameLang} />
|
||||
<FormInput
|
||||
type="text"
|
||||
value={name[nameLang]}
|
||||
onChange={(val) => setName((prev) => ({ ...prev, [nameLang]: val }))}
|
||||
placeholder={t('loanDocuments.fields.namePlaceholder', 'Ady')}
|
||||
error={errors[`name_${nameLang}`]}
|
||||
/>
|
||||
{/* Show errors for other locales as hints */}
|
||||
{LOCALES.filter((l) => l.code !== nameLang && errors[`name_${l.code}`]).map(({ code, label }) => (
|
||||
<p key={code} className="mt-1 text-xs text-destructive/70">
|
||||
{label}: {errors[`name_${code}`]}
|
||||
</p>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* ── Description field ────────────────────────────────────────────── */}
|
||||
<div className="grid grid-cols-[220px_1fr] items-start py-4 px-4">
|
||||
<label className="text-sm text-muted-foreground pt-1">
|
||||
{t('loanDocuments.fields.description', 'Yazgy')}
|
||||
<span className="text-destructive ml-0.5">*</span>
|
||||
</label>
|
||||
<div>
|
||||
<LangTabs active={descLang} onChange={setDescLang} />
|
||||
<RichTextEditor
|
||||
value={description[descLang]}
|
||||
onChange={(val) => setDescription((prev) => ({ ...prev, [descLang]: val }))}
|
||||
error={errors[`desc_${descLang}`]}
|
||||
/>
|
||||
{LOCALES.filter((l) => l.code !== descLang && errors[`desc_${l.code}`]).map(({ code, label }) => (
|
||||
<p key={code} className="mt-1 text-xs text-destructive/70">
|
||||
{label}: {errors[`desc_${code}`]}
|
||||
</p>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* ── Actions ──────────────────────────────────────────────────────────── */}
|
||||
<div className="flex items-center justify-end gap-3 mt-4">
|
||||
<Button
|
||||
type="button"
|
||||
variant="ghost"
|
||||
onClick={() => navigate('/settings/loan/loan-documents')}
|
||||
disabled={isPending}
|
||||
>
|
||||
{t('common.cancel', 'Ýatyr')}
|
||||
</Button>
|
||||
<Button type="submit" disabled={isPending} className="bg-primary text-primary-foreground hover:bg-primary/90">
|
||||
{isPending ? t('common.saving', 'Saklanylýar...') : submitLabel}
|
||||
</Button>
|
||||
</div>
|
||||
</form>
|
||||
)
|
||||
}
|
||||
96
src/features/requiredDocuments/hooks/useRequiredDocuments.ts
Normal file
96
src/features/requiredDocuments/hooks/useRequiredDocuments.ts
Normal file
@@ -0,0 +1,96 @@
|
||||
import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query'
|
||||
import { toast } from 'sonner'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import {
|
||||
fetchLoanDocuments,
|
||||
fetchLoanDocumentById,
|
||||
createLoanDocument,
|
||||
updateLoanDocument,
|
||||
deleteLoanDocument,
|
||||
type ListParams,
|
||||
type LoanDocumentPayload,
|
||||
} from '../api/requiredDocumentsApi'
|
||||
|
||||
// ─── Query Keys ───────────────────────────────────────────────────────────────
|
||||
|
||||
export const requiredDocumentsKeys = {
|
||||
all: ['requiredDocuments'] as const,
|
||||
lists: () => [...requiredDocumentsKeys.all, 'list'] as const,
|
||||
list: (params: ListParams) => [...requiredDocumentsKeys.lists(), params] as const,
|
||||
details: () => [...requiredDocumentsKeys.all, 'detail'] as const,
|
||||
detail: (id: number) => [...requiredDocumentsKeys.details(), id] as const,
|
||||
}
|
||||
|
||||
// ─── useGetLoanDocuments ──────────────────────────────────────────────────────
|
||||
|
||||
export function useGetRequiredDocuments(params: ListParams) {
|
||||
return useQuery({
|
||||
queryKey: requiredDocumentsKeys.list(params),
|
||||
queryFn: () => fetchLoanDocuments(params),
|
||||
})
|
||||
}
|
||||
|
||||
// ─── useGetLoanDocumentById ───────────────────────────────────────────────────
|
||||
|
||||
export function useGetRequiredDocumentById(id: number) {
|
||||
return useQuery({
|
||||
queryKey: requiredDocumentsKeys.detail(id),
|
||||
queryFn: () => fetchLoanDocumentById(id),
|
||||
enabled: !!id,
|
||||
})
|
||||
}
|
||||
|
||||
// ─── useCreateLoanDocument ────────────────────────────────────────────────────
|
||||
|
||||
export function useCreateRequiredDocument() {
|
||||
const queryClient = useQueryClient()
|
||||
const { t } = useTranslation()
|
||||
|
||||
return useMutation({
|
||||
mutationFn: (payload: LoanDocumentPayload) => createLoanDocument(payload),
|
||||
onSuccess: () => {
|
||||
queryClient.invalidateQueries({ queryKey: requiredDocumentsKeys.lists() })
|
||||
toast.success(t('loanDocuments.toast.created', 'Resminama üstünlikli döredildi!'))
|
||||
},
|
||||
onError: () => {
|
||||
toast.error(t('loanDocuments.toast.createError', 'Resminama döredilende ýalňyşlyk ýüze çykdy!'))
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
// ─── useUpdateLoanDocument ────────────────────────────────────────────────────
|
||||
|
||||
export function useUpdateRequiredDocument(id: number) {
|
||||
const queryClient = useQueryClient()
|
||||
const { t } = useTranslation()
|
||||
|
||||
return useMutation({
|
||||
mutationFn: (payload: LoanDocumentPayload) => updateLoanDocument(id, payload),
|
||||
onSuccess: () => {
|
||||
queryClient.invalidateQueries({ queryKey: requiredDocumentsKeys.lists() })
|
||||
queryClient.invalidateQueries({ queryKey: requiredDocumentsKeys.detail(id) })
|
||||
toast.success(t('loanDocuments.toast.updated', 'Resminama üstünlikli täzelendi!'))
|
||||
},
|
||||
onError: () => {
|
||||
toast.error(t('loanDocuments.toast.updateError', 'Resminama täzelenende ýalňyşlyk ýüze çykdy!'))
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
// ─── useDeleteLoanDocument ────────────────────────────────────────────────────
|
||||
|
||||
export function useDeleteRequiredDocument() {
|
||||
const queryClient = useQueryClient()
|
||||
const { t } = useTranslation()
|
||||
|
||||
return useMutation({
|
||||
mutationFn: (id: number) => deleteLoanDocument(id),
|
||||
onSuccess: () => {
|
||||
queryClient.invalidateQueries({ queryKey: requiredDocumentsKeys.lists() })
|
||||
toast.success(t('loanDocuments.toast.deleted', 'Resminama üstünlikli öçürildi!'))
|
||||
},
|
||||
onError: () => {
|
||||
toast.error(t('loanDocuments.toast.deleteError', 'Resminama öçürilende ýalňyşlyk ýüze çykdy!'))
|
||||
},
|
||||
})
|
||||
}
|
||||
@@ -378,11 +378,11 @@ function AppSidebar() {
|
||||
items: [
|
||||
{
|
||||
title: t("Loan types", "Karz görnüşleri"),
|
||||
url: "/settings/loan/types",
|
||||
url: "/settings/loan/loan-types",
|
||||
},
|
||||
{
|
||||
title: t("Required Documents", "Gerekli resminamalar"),
|
||||
url: "/settings/loan/documents",
|
||||
url: "/settings/loan/required-documents",
|
||||
},
|
||||
],
|
||||
},
|
||||
|
||||
@@ -403,10 +403,25 @@
|
||||
"loanOrderStatus.RED_EDILDI": "RED EDILDI",
|
||||
"loanOrderStatus.IŞLENÝÄR": "IŞLENÝÄR",
|
||||
"Dashboards": "Dolandyryş panelleri",
|
||||
"Card Issuance Reasons": "Kartyň çykarylmagynyň sebäpleri",
|
||||
"Locale Manager": "Locale dolandyryjy",
|
||||
"Resources": "Çeşmeler",
|
||||
"Currency rates": "Walýuta kurslary",
|
||||
"Loan balance": "Karzyň galyndysy"
|
||||
|
||||
"Card Issuance Reasons": "Kartyň çykarylmagynyň sebäpleri",
|
||||
"Locale Manager": "Locale dolandyryjy",
|
||||
"Resources": "Çeşmeler",
|
||||
"Currency rates": "Walýuta kurslary",
|
||||
"Loan balance": "Karzyň galyndysy",
|
||||
"loanDocuments.title": "Karz gerekli resminamalary",
|
||||
"loanDocuments.createBtn": "Karz gerekli resminamalary dörediň",
|
||||
"loanDocuments.editTitle": "Karz gerekli resminamalary redaktirle",
|
||||
"loanDocuments.columns.name": "ADY",
|
||||
"loanDocuments.deleteConfirm": "Bu resminamany öçürmek isleýärsiňizmi?",
|
||||
"loanDocuments.form.create": "Karz gerekli resminamalary döretiň",
|
||||
"loanDocuments.form.update": "Karz gerekli resminamalary täzele",
|
||||
"loanDocuments.fields.name": "Ady",
|
||||
"loanDocuments.fields.namePlaceholder": "Ady",
|
||||
"loanDocuments.fields.description": "Yazgy",
|
||||
"loanDocuments.toast.created": "Resminama üstünlikli döredildi!",
|
||||
"loanDocuments.toast.createError": "Resminama döredilende ýalňyşlyk ýüze çykdy!",
|
||||
"loanDocuments.toast.updated": "Resminama üstünlikli täzelendi!",
|
||||
"loanDocuments.toast.updateError": "Resminama täzelenende ýalňyşlyk ýüze çykdy!",
|
||||
"loanDocuments.toast.deleted": "Resminama üstünlikli öçürildi!",
|
||||
"loanDocuments.toast.deleteError": "Resminama öçürilende ýalňyşlyk ýüze çykdy!"
|
||||
}
|
||||
219
src/pages/settings/loan/loanTypes/index.tsx
Normal file
219
src/pages/settings/loan/loanTypes/index.tsx
Normal file
@@ -0,0 +1,219 @@
|
||||
// pages/LoanTypesListPage.tsx
|
||||
|
||||
import { useState } from 'react'
|
||||
import { useNavigate } from 'react-router-dom'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import { Eye, Pencil, Trash2, CheckCircle2, XCircle } from 'lucide-react'
|
||||
import { DataTable, type ColumnDef } from '@/components/dataTable'
|
||||
import { DataTableToolbar } from '@/components/dataTableToolbar'
|
||||
import { useGetLoanTypes, useDeleteLoanType } from '@/features/loanTypes/hooks/useLoanTypes'
|
||||
import type { LoanType } from '@/features/loanTypes/api/loanTypesApi'
|
||||
import {
|
||||
AlertDialog,
|
||||
AlertDialogAction,
|
||||
AlertDialogCancel,
|
||||
AlertDialogContent,
|
||||
AlertDialogDescription,
|
||||
AlertDialogFooter,
|
||||
AlertDialogHeader,
|
||||
AlertDialogTitle,
|
||||
} from '@/components/ui/alert-dialog'
|
||||
|
||||
// ─── Column definitions ───────────────────────────────────────────────────────
|
||||
|
||||
function useLoanTypeColumns(
|
||||
onView: (id: number) => void,
|
||||
onEdit: (id: number) => void,
|
||||
onDelete: (id: number) => void
|
||||
): ColumnDef<LoanType>[] {
|
||||
const { t, i18n } = useTranslation()
|
||||
const lang = (i18n.language ?? 'tk') as 'tk' | 'ru' | 'en'
|
||||
|
||||
return [
|
||||
{
|
||||
accessorKey: 'id',
|
||||
header: 'ID',
|
||||
size: 60,
|
||||
cell: ({ row }) => (
|
||||
<span className="text-primary font-semibold text-sm">{row.original.id}</span>
|
||||
),
|
||||
},
|
||||
{
|
||||
accessorKey: 'name',
|
||||
header: t('loanTypes.columns.name', 'ADY'),
|
||||
cell: ({ row }) => (
|
||||
<span className="text-sm text-foreground">{row.original.name[lang]}</span>
|
||||
),
|
||||
},
|
||||
{
|
||||
accessorKey: 'tax',
|
||||
header: t('loanTypes.columns.tax', 'SALGYT'),
|
||||
size: 90,
|
||||
cell: ({ row }) => (
|
||||
<span className="text-sm text-foreground">{row.original.tax}</span>
|
||||
),
|
||||
},
|
||||
{
|
||||
accessorKey: 'loanTerm',
|
||||
header: t('loanTypes.columns.loanTerm', 'KARZ MÖHLETI'),
|
||||
size: 130,
|
||||
cell: ({ row }) => (
|
||||
<span className="text-sm text-foreground">{row.original.loanTerm}</span>
|
||||
),
|
||||
},
|
||||
{
|
||||
accessorKey: 'notes',
|
||||
header: t('loanTypes.columns.notes', 'BELLIKLER'),
|
||||
cell: ({ row }) => {
|
||||
const notes = row.original.notes
|
||||
return (
|
||||
<span className="text-sm text-foreground">
|
||||
{notes ? notes[lang] || '—' : '—'}
|
||||
</span>
|
||||
)
|
||||
},
|
||||
},
|
||||
{
|
||||
accessorKey: 'isActive',
|
||||
header: t('loanTypes.columns.isActive', 'IŞJEŇ'),
|
||||
size: 80,
|
||||
cell: ({ row }) =>
|
||||
row.original.isActive ? (
|
||||
<CheckCircle2 size={18} className="text-emerald-500" />
|
||||
) : (
|
||||
<XCircle size={18} className="text-muted-foreground" />
|
||||
),
|
||||
},
|
||||
{
|
||||
id: 'actions',
|
||||
header: '',
|
||||
size: 120,
|
||||
enableSorting: false,
|
||||
cell: ({ row }) => (
|
||||
<div className="flex items-center gap-1">
|
||||
<button
|
||||
onClick={() => onView(row.original.id)}
|
||||
className="p-1.5 rounded hover:bg-muted/60 text-muted-foreground hover:text-foreground transition-colors"
|
||||
title={t('common.view', 'Görmek')}
|
||||
>
|
||||
<Eye size={14} />
|
||||
</button>
|
||||
<button
|
||||
onClick={() => onEdit(row.original.id)}
|
||||
className="p-1.5 rounded hover:bg-muted/60 text-muted-foreground hover:text-foreground transition-colors"
|
||||
title={t('common.edit', 'Redaktirlemek')}
|
||||
>
|
||||
<Pencil size={14} />
|
||||
</button>
|
||||
<button
|
||||
onClick={() => onDelete(row.original.id)}
|
||||
className="p-1.5 rounded hover:bg-destructive/10 text-muted-foreground hover:text-destructive transition-colors"
|
||||
title={t('common.delete', 'Pozmak')}
|
||||
>
|
||||
<Trash2 size={14} />
|
||||
</button>
|
||||
</div>
|
||||
),
|
||||
},
|
||||
]
|
||||
}
|
||||
|
||||
// ─── LoanTypesListPage ────────────────────────────────────────────────────────
|
||||
|
||||
export default function LoanTypesListPage() {
|
||||
const { t } = useTranslation()
|
||||
const navigate = useNavigate()
|
||||
|
||||
const [page, setPage] = useState(1)
|
||||
const [perPage] = useState(25)
|
||||
const [search, setSearch] = useState('')
|
||||
const [deleteId, setDeleteId] = useState<number | null>(null)
|
||||
|
||||
const [columnVisibility, setColumnVisibility] = useState<Record<string, boolean>>({})
|
||||
const [columnOrder, setColumnOrder] = useState<string[]>([])
|
||||
|
||||
const { data, isLoading } = useGetLoanTypes({ page, perPage, search })
|
||||
const deleteMutation = useDeleteLoanType()
|
||||
|
||||
const handleView = (id: number) => navigate(`/settings/loan/loan-types/${id}`)
|
||||
const handleEdit = (id: number) => navigate(`/settings/loan/loan-types/${id}/edit`)
|
||||
const handleDelete = (id: number) => setDeleteId(id)
|
||||
|
||||
const confirmDelete = async () => {
|
||||
if (deleteId === null) return
|
||||
await deleteMutation.mutateAsync(deleteId)
|
||||
setDeleteId(null)
|
||||
}
|
||||
|
||||
const columns = useLoanTypeColumns(handleView, handleEdit, handleDelete)
|
||||
|
||||
const columnMeta = columns
|
||||
.filter((c) => c.id !== 'actions' && 'accessorKey' in c)
|
||||
.map((c) => ({
|
||||
id: 'accessorKey' in c ? String(c.accessorKey) : String(c.id),
|
||||
label: typeof c.header === 'string' ? c.header : String(c.id ?? ''),
|
||||
}))
|
||||
|
||||
return (
|
||||
<div className="p-6">
|
||||
|
||||
|
||||
<h1 className="text-xl font-semibold text-foreground mb-5">
|
||||
{t('loanTypes.title', 'Karz görnüşleri')}
|
||||
</h1>
|
||||
|
||||
<DataTableToolbar
|
||||
searchValue={search}
|
||||
onSearchChange={(v) => { setSearch(v); setPage(1) }}
|
||||
searchPlaceholder={t('common.search', 'Gözlemek')}
|
||||
columns={columnMeta}
|
||||
columnVisibility={columnVisibility}
|
||||
onColumnVisibilityChange={setColumnVisibility}
|
||||
columnOrder={columnOrder}
|
||||
onColumnOrderChange={setColumnOrder}
|
||||
actionLabel={t('loanTypes.actions.create', 'Karz görnüşi dörediň')}
|
||||
onAction={() => navigate('/settings/loan/loan-types/create')}
|
||||
/>
|
||||
|
||||
<DataTable<LoanType>
|
||||
columns={columns}
|
||||
data={data?.data ?? []}
|
||||
isLoading={isLoading}
|
||||
columnVisibility={columnVisibility}
|
||||
onColumnVisibilityChange={setColumnVisibility}
|
||||
columnOrder={columnOrder}
|
||||
onColumnOrderChange={setColumnOrder}
|
||||
enableRowSelection
|
||||
getRowId={(row) => String(row.id)}
|
||||
currentPage={page}
|
||||
totalPages={data?.totalPages ?? 1}
|
||||
totalCount={data?.total}
|
||||
onPageChange={setPage}
|
||||
/>
|
||||
|
||||
{/* Delete confirmation dialog */}
|
||||
<AlertDialog open={deleteId !== null} onOpenChange={(open) => !open && setDeleteId(null)}>
|
||||
<AlertDialogContent>
|
||||
<AlertDialogHeader>
|
||||
<AlertDialogTitle>{t('loanTypes.deleteDialog.title', 'Pozmak')}</AlertDialogTitle>
|
||||
<AlertDialogDescription>
|
||||
{t('loanTypes.deleteDialog.description', 'Bu karz görnüşini pozmak isleýärsiňizmi? Bu amal yzyna gaýtarylyp bilinmez.')}
|
||||
</AlertDialogDescription>
|
||||
</AlertDialogHeader>
|
||||
<AlertDialogFooter>
|
||||
<AlertDialogCancel disabled={deleteMutation.isPending}>
|
||||
{t('common.cancel', 'Ýatyr')}
|
||||
</AlertDialogCancel>
|
||||
<AlertDialogAction
|
||||
onClick={confirmDelete}
|
||||
disabled={deleteMutation.isPending}
|
||||
className="bg-destructive hover:bg-destructive/90"
|
||||
>
|
||||
{deleteMutation.isPending ? t('common.deleting', 'Pozulýar...') : t('common.delete', 'Pozmak')}
|
||||
</AlertDialogAction>
|
||||
</AlertDialogFooter>
|
||||
</AlertDialogContent>
|
||||
</AlertDialog>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
20
src/pages/settings/loan/loanTypesCreate/index.tsx
Normal file
20
src/pages/settings/loan/loanTypesCreate/index.tsx
Normal file
@@ -0,0 +1,20 @@
|
||||
// pages/LoanTypeCreatePage.tsx
|
||||
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import { LoanTypeForm } from '@/features/loanTypes/components/loanTypesForm'
|
||||
|
||||
export default function LoanTypeCreatePage() {
|
||||
const { t } = useTranslation()
|
||||
|
||||
return (
|
||||
<div className="p-6 max-w-3xl">
|
||||
|
||||
|
||||
<h1 className="text-xl font-semibold text-foreground mb-5">
|
||||
{t('loanTypes.actions.create', 'Karz görnüşi dörediň')}
|
||||
</h1>
|
||||
|
||||
<LoanTypeForm mode="create" />
|
||||
</div>
|
||||
)
|
||||
}
|
||||
47
src/pages/settings/loan/loanTypesEdit/index.tsx
Normal file
47
src/pages/settings/loan/loanTypesEdit/index.tsx
Normal file
@@ -0,0 +1,47 @@
|
||||
// pages/LoanTypeEditPage.tsx
|
||||
|
||||
import { useParams } from 'react-router-dom'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import { LoanTypeForm } from '@/features/loanTypes/components/loanTypesForm'
|
||||
import { useGetLoanTypeById } from '@/features/loanTypes/hooks/useLoanTypes'
|
||||
import { Skeleton } from '@/components/ui/skeleton'
|
||||
|
||||
export default function LoanTypeEditPage() {
|
||||
const { t } = useTranslation()
|
||||
const { id } = useParams<{ id: string }>()
|
||||
const loanTypeId = Number(id)
|
||||
|
||||
const { data, isLoading, isError } = useGetLoanTypeById(loanTypeId)
|
||||
|
||||
return (
|
||||
<div className="p-6 max-w-3xl">
|
||||
|
||||
<h1 className="text-xl font-semibold text-foreground mb-5">
|
||||
{isLoading
|
||||
? t('common.loading', 'Ýüklenýär...')
|
||||
: `${t('loanTypes.editTitle', 'Karz görnüşi redaktirle')}: ${data?.name.tk ?? ''}`}
|
||||
</h1>
|
||||
|
||||
{isLoading ? (
|
||||
<div className="bg-card border border-border rounded-xl overflow-hidden divide-y divide-border">
|
||||
{Array.from({ length: 5 }).map((_, i) => (
|
||||
<div key={i} className="grid grid-cols-[220px_1fr] items-center px-4 py-3">
|
||||
<Skeleton className="h-4 w-24" />
|
||||
<Skeleton className="h-8 w-full" />
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
) : isError ? (
|
||||
<div className="flex items-center justify-center py-20 text-destructive text-sm">
|
||||
{t('common.error', 'Ýalňyşlyk ýüze çykdy')}
|
||||
</div>
|
||||
) : (
|
||||
<LoanTypeForm
|
||||
mode="edit"
|
||||
initialData={data}
|
||||
loanTypeId={loanTypeId}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
206
src/pages/settings/loan/loanTypesView/index.tsx
Normal file
206
src/pages/settings/loan/loanTypesView/index.tsx
Normal file
@@ -0,0 +1,206 @@
|
||||
// pages/LoanTypeViewPage.tsx
|
||||
|
||||
import { useState } from 'react'
|
||||
import { useNavigate, useParams } from 'react-router-dom'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import { Pencil, Trash2, CheckCircle2, XCircle } from 'lucide-react'
|
||||
import { Button } from '@/components/ui/button'
|
||||
import { Skeleton } from '@/components/ui/skeleton'
|
||||
import {
|
||||
AlertDialog,
|
||||
AlertDialogAction,
|
||||
AlertDialogCancel,
|
||||
AlertDialogContent,
|
||||
AlertDialogDescription,
|
||||
AlertDialogFooter,
|
||||
AlertDialogHeader,
|
||||
AlertDialogTitle,
|
||||
} from '@/components/ui/alert-dialog'
|
||||
import { Section, InfoRow } from '@/components/viewPageComponents'
|
||||
import { useGetLoanTypeById, useDeleteLoanType } from '@/features/loanTypes/hooks/useLoanTypes'
|
||||
|
||||
// ─── LoanTypeViewPage ─────────────────────────────────────────────────────────
|
||||
|
||||
export default function LoanTypeViewPage() {
|
||||
const { t, i18n } = useTranslation()
|
||||
const navigate = useNavigate()
|
||||
const { id } = useParams<{ id: string }>()
|
||||
const loanTypeId = Number(id)
|
||||
|
||||
const [showDeleteDialog, setShowDeleteDialog] = useState(false)
|
||||
|
||||
const { data, isLoading, isError } = useGetLoanTypeById(loanTypeId)
|
||||
const deleteMutation = useDeleteLoanType()
|
||||
|
||||
const lang = (i18n.language ?? 'tk') as 'tk' | 'ru' | 'en'
|
||||
|
||||
const handleDelete = async () => {
|
||||
await deleteMutation.mutateAsync(loanTypeId)
|
||||
navigate('/resources/loan-types')
|
||||
}
|
||||
|
||||
// ── Skeleton ───────────────────────────────────────────────────────────────
|
||||
if (isLoading) {
|
||||
return (
|
||||
<div className="p-6 max-w-3xl">
|
||||
<Skeleton className="h-4 w-64 mb-4" />
|
||||
<Skeleton className="h-7 w-80 mb-6" />
|
||||
<div className="bg-card border border-border rounded-xl overflow-hidden divide-y divide-border">
|
||||
{Array.from({ length: 5 }).map((_, i) => (
|
||||
<div key={i} className="grid grid-cols-[220px_1fr] items-center px-4 py-3">
|
||||
<Skeleton className="h-4 w-20" />
|
||||
<Skeleton className="h-4 w-40" />
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
// ── Error ──────────────────────────────────────────────────────────────────
|
||||
if (isError || !data) {
|
||||
return (
|
||||
<div className="p-6 flex items-center justify-center py-20 text-destructive text-sm">
|
||||
{t('common.error', 'Ýalňyşlyk ýüze çykdy')}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
// ── View ───────────────────────────────────────────────────────────────────
|
||||
return (
|
||||
<div className="p-6 max-w-3xl">
|
||||
{/* Breadcrumb */}
|
||||
<div className="flex items-center gap-2 text-sm text-muted-foreground mb-4">
|
||||
<span
|
||||
className="hover:text-foreground cursor-pointer transition-colors"
|
||||
onClick={() => navigate('/resources')}
|
||||
>
|
||||
{t('nav.resources', 'Resurslar')}
|
||||
</span>
|
||||
<span>/</span>
|
||||
<span
|
||||
className="hover:text-foreground cursor-pointer transition-colors text-primary"
|
||||
onClick={() => navigate('/resources/loan-types')}
|
||||
>
|
||||
{t('loanTypes.title', 'Karz görnüşleri')}
|
||||
</span>
|
||||
<span>/</span>
|
||||
<span className="text-foreground font-medium">
|
||||
{t('loanTypes.viewTitle', 'Karz görnüşi giňişleýin')}: {data.name[lang]}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
{/* Page header */}
|
||||
<div className="flex items-start justify-between mb-5">
|
||||
<h1 className="text-xl font-semibold text-foreground">
|
||||
{t('loanTypes.viewTitle', 'Karz görnüşi giňişleýin')}: {data.name[lang]}
|
||||
</h1>
|
||||
<div className="flex items-center gap-2">
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="icon"
|
||||
onClick={() => setShowDeleteDialog(true)}
|
||||
className="text-muted-foreground hover:text-destructive hover:bg-destructive/10 transition-colors"
|
||||
title={t('common.delete', 'Pozmak')}
|
||||
>
|
||||
<Trash2 size={16} />
|
||||
</Button>
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="icon"
|
||||
onClick={() => navigate(`/resources/loan-types/${loanTypeId}/edit`)}
|
||||
className="text-muted-foreground hover:text-foreground transition-colors"
|
||||
title={t('common.edit', 'Redaktirlemek')}
|
||||
>
|
||||
<Pencil size={16} />
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Detail section */}
|
||||
<Section>
|
||||
<InfoRow label="ID" value={data.id} />
|
||||
|
||||
{/* Multilingual name rows */}
|
||||
<div className="grid grid-cols-[220px_1fr] items-start py-2.5 px-4 border-b border-border">
|
||||
<span className="text-sm text-muted-foreground pt-1">
|
||||
{t('loanTypes.fields.name', 'Ady')}
|
||||
</span>
|
||||
<div className="space-y-1">
|
||||
<div className="flex items-center gap-3">
|
||||
<span className="text-xs font-semibold text-muted-foreground w-6">TK</span>
|
||||
<span className="text-sm text-foreground">{data.name.tk}</span>
|
||||
</div>
|
||||
<div className="flex items-center gap-3">
|
||||
<span className="text-xs font-semibold text-muted-foreground w-6">RU</span>
|
||||
<span className="text-sm text-foreground">{data.name.ru}</span>
|
||||
</div>
|
||||
<div className="flex items-center gap-3">
|
||||
<span className="text-xs font-semibold text-muted-foreground w-6">EN</span>
|
||||
<span className="text-sm text-foreground">{data.name.en}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<InfoRow
|
||||
label={t('loanTypes.fields.tax', 'Salgyt')}
|
||||
value={data.tax}
|
||||
/>
|
||||
|
||||
<InfoRow
|
||||
label={t('loanTypes.fields.loanTerm', 'Karz möhleti')}
|
||||
value={data.loanTerm}
|
||||
/>
|
||||
|
||||
<div className="grid grid-cols-[220px_1fr] items-center py-2.5 px-4 border-b border-border">
|
||||
<span className="text-sm text-muted-foreground">
|
||||
{t('loanTypes.fields.notes', 'Bellikler')}
|
||||
</span>
|
||||
<span className="text-sm text-foreground">
|
||||
{data.notes ? data.notes[lang] || '—' : '—'}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div className="grid grid-cols-[220px_1fr] items-center py-2.5 px-4 border-b border-border last:border-0">
|
||||
<span className="text-sm text-muted-foreground">
|
||||
{t('loanTypes.fields.isActive', 'Işjeň')}
|
||||
</span>
|
||||
{data.isActive ? (
|
||||
<CheckCircle2 size={20} className="text-emerald-500" />
|
||||
) : (
|
||||
<XCircle size={20} className="text-muted-foreground" />
|
||||
)}
|
||||
</div>
|
||||
</Section>
|
||||
|
||||
{/* Delete dialog */}
|
||||
<AlertDialog open={showDeleteDialog} onOpenChange={setShowDeleteDialog}>
|
||||
<AlertDialogContent>
|
||||
<AlertDialogHeader>
|
||||
<AlertDialogTitle>{t('loanTypes.deleteDialog.title', 'Pozmak')}</AlertDialogTitle>
|
||||
<AlertDialogDescription>
|
||||
{t(
|
||||
'loanTypes.deleteDialog.description',
|
||||
'Bu karz görnüşini pozmak isleýärsiňizmi? Bu amal yzyna gaýtarylyp bilinmez.'
|
||||
)}
|
||||
</AlertDialogDescription>
|
||||
</AlertDialogHeader>
|
||||
<AlertDialogFooter>
|
||||
<AlertDialogCancel disabled={deleteMutation.isPending}>
|
||||
{t('common.cancel', 'Ýatyr')}
|
||||
</AlertDialogCancel>
|
||||
<AlertDialogAction
|
||||
onClick={handleDelete}
|
||||
disabled={deleteMutation.isPending}
|
||||
className="bg-destructive hover:bg-destructive/90"
|
||||
>
|
||||
{deleteMutation.isPending
|
||||
? t('common.deleting', 'Pozulýar...')
|
||||
: t('common.delete', 'Pozmak')}
|
||||
</AlertDialogAction>
|
||||
</AlertDialogFooter>
|
||||
</AlertDialogContent>
|
||||
</AlertDialog>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
138
src/pages/settings/loan/requiredDocuments/index.tsx
Normal file
138
src/pages/settings/loan/requiredDocuments/index.tsx
Normal file
@@ -0,0 +1,138 @@
|
||||
import { useState } from 'react'
|
||||
import { useNavigate } from 'react-router-dom'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import { Eye, Pencil, Trash2 } from 'lucide-react'
|
||||
import { DataTable, type ColumnDef } from '@/components/dataTable'
|
||||
import { DataTableToolbar } from '@/components/dataTableToolbar'
|
||||
import { useGetRequiredDocuments, useDeleteRequiredDocument } from '@/features/requiredDocuments/hooks/useRequiredDocuments'
|
||||
import type { LoanDocument } from '@/features/requiredDocuments/api/requiredDocumentsApi'
|
||||
import type { VisibilityState } from '@tanstack/react-table'
|
||||
|
||||
// ─── Column visibility defaults ───────────────────────────────────────────────
|
||||
|
||||
const DEFAULT_VISIBILITY: VisibilityState = {}
|
||||
const DEFAULT_ORDER = ['id', 'name', 'actions']
|
||||
|
||||
export default function RequiredDocumentsListPage() {
|
||||
const { t } = useTranslation()
|
||||
const navigate = useNavigate()
|
||||
|
||||
// ── Table state ─────────────────────────────────────────────────────────────
|
||||
const [search, setSearch] = useState('')
|
||||
const [page, setPage] = useState(1)
|
||||
const [perPage] = useState(10)
|
||||
const [columnVisibility, setColumnVisibility] = useState<VisibilityState>(DEFAULT_VISIBILITY)
|
||||
const [columnOrder, setColumnOrder] = useState<string[]>(DEFAULT_ORDER)
|
||||
|
||||
// ── Data ────────────────────────────────────────────────────────────────────
|
||||
const { data, isLoading } = useGetRequiredDocuments({ page, perPage, search })
|
||||
const deleteMutation = useDeleteRequiredDocument()
|
||||
|
||||
const handleDelete = (id: number) => {
|
||||
if (window.confirm(t('loanDocuments.deleteConfirm', 'Bu resminamany öçürmek isleýärsiňizmi?'))) {
|
||||
deleteMutation.mutate(id)
|
||||
}
|
||||
}
|
||||
|
||||
// ── Columns ─────────────────────────────────────────────────────────────────
|
||||
const columns: ColumnDef<LoanDocument>[] = [
|
||||
{
|
||||
id: 'id',
|
||||
accessorKey: 'id',
|
||||
header: 'ID',
|
||||
size: 72,
|
||||
cell: ({ row }) => (
|
||||
<span
|
||||
className="text-primary font-semibold cursor-pointer hover:underline"
|
||||
onClick={() => navigate(`/settings/loan/required-documents/${row.original.id}`)}
|
||||
>
|
||||
{row.original.id}
|
||||
</span>
|
||||
),
|
||||
},
|
||||
{
|
||||
id: 'name',
|
||||
header: t('loanDocuments.columns.name', 'ADY'),
|
||||
accessorFn: (row) => row.name.tk,
|
||||
cell: ({ row }) => (
|
||||
<span className="text-sm text-foreground">{row.original.name.tk}</span>
|
||||
),
|
||||
},
|
||||
{
|
||||
id: 'actions',
|
||||
header: '',
|
||||
size: 100,
|
||||
enableSorting: false,
|
||||
cell: ({ row }) => (
|
||||
<div className="flex items-center justify-end gap-1">
|
||||
<button
|
||||
onClick={() => navigate(`/settings/loan/required-documents/${row.original.id}`)}
|
||||
className="p-1.5 rounded hover:bg-muted/60 text-muted-foreground hover:text-foreground transition-colors"
|
||||
title={t('common.view', 'Görüntüle')}
|
||||
>
|
||||
<Eye size={15} />
|
||||
</button>
|
||||
<button
|
||||
onClick={() => navigate(`/settings/loan/required-documents/${row.original.id}/edit`)}
|
||||
className="p-1.5 rounded hover:bg-muted/60 text-muted-foreground hover:text-foreground transition-colors"
|
||||
title={t('common.edit', 'Düzet')}
|
||||
>
|
||||
<Pencil size={15} />
|
||||
</button>
|
||||
<button
|
||||
onClick={() => handleDelete(row.original.id)}
|
||||
disabled={deleteMutation.isPending}
|
||||
className="p-1.5 rounded hover:bg-destructive/10 text-muted-foreground hover:text-destructive transition-colors"
|
||||
title={t('common.delete', 'Öçür')}
|
||||
>
|
||||
<Trash2 size={15} />
|
||||
</button>
|
||||
</div>
|
||||
),
|
||||
},
|
||||
]
|
||||
|
||||
const columnMetas = columns
|
||||
.filter((c) => c.id !== 'actions' && c.id !== 'select')
|
||||
.map((c) => ({ id: c.id as string, label: typeof c.header === 'string' ? c.header : c.id as string }))
|
||||
|
||||
return (
|
||||
<div>
|
||||
{/* Page heading */}
|
||||
<h1 className="text-xl font-semibold text-foreground mb-4">
|
||||
{t('loanDocuments.title', 'Karz gerekli resminamalary')}
|
||||
</h1>
|
||||
|
||||
{/* Toolbar */}
|
||||
<DataTableToolbar
|
||||
searchValue={search}
|
||||
onSearchChange={(v) => { setSearch(v); setPage(1) }}
|
||||
searchPlaceholder={t('common.search', 'Gözlemek')}
|
||||
columns={columnMetas}
|
||||
columnVisibility={columnVisibility}
|
||||
onColumnVisibilityChange={setColumnVisibility}
|
||||
columnOrder={columnOrder}
|
||||
onColumnOrderChange={setColumnOrder}
|
||||
actionLabel={t('loanDocuments.createBtn', 'Karz gerekli resminamalary döretiň')}
|
||||
onAction={() => navigate('/settings/loan/required-documents/create')}
|
||||
/>
|
||||
|
||||
{/* Table */}
|
||||
<DataTable
|
||||
columns={columns}
|
||||
data={data?.data ?? []}
|
||||
isLoading={isLoading}
|
||||
columnVisibility={columnVisibility}
|
||||
onColumnVisibilityChange={setColumnVisibility}
|
||||
columnOrder={columnOrder}
|
||||
onColumnOrderChange={setColumnOrder}
|
||||
getRowId={(row) => String(row.id)}
|
||||
enableRowSelection
|
||||
currentPage={page}
|
||||
totalPages={data?.totalPages ?? 1}
|
||||
totalCount={data?.total}
|
||||
onPageChange={setPage}
|
||||
/>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
16
src/pages/settings/loan/requiredDocumentsCreate/index.tsx
Normal file
16
src/pages/settings/loan/requiredDocumentsCreate/index.tsx
Normal file
@@ -0,0 +1,16 @@
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import { RequiredDocumentForm } from '@/features/requiredDocuments/components/requiredDocumentsForm'
|
||||
|
||||
export default function RequiredDocumentsCreatePage() {
|
||||
const { t } = useTranslation()
|
||||
|
||||
return (
|
||||
<div className="p-6 max-w-5xl">
|
||||
<h1 className="text-xl font-semibold text-foreground mb-5">
|
||||
{t('loanDocuments.createBtn', 'Karz gerekli resminamalary dörediň')}
|
||||
</h1>
|
||||
|
||||
<RequiredDocumentForm mode="create" />
|
||||
</div>
|
||||
)
|
||||
}
|
||||
47
src/pages/settings/loan/requiredDocumentsEdit/index.tsx
Normal file
47
src/pages/settings/loan/requiredDocumentsEdit/index.tsx
Normal file
@@ -0,0 +1,47 @@
|
||||
import { useParams } from 'react-router-dom'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import { RequiredDocumentForm } from '@/features/requiredDocuments/components/requiredDocumentsForm'
|
||||
import { useGetRequiredDocumentById } from '@/features/requiredDocuments/hooks/useRequiredDocuments'
|
||||
import { Skeleton } from '@/components/ui/skeleton'
|
||||
|
||||
export default function RequiredDocumentsEditPage() {
|
||||
const { t } = useTranslation()
|
||||
const { id } = useParams<{ id: string }>()
|
||||
const documentId = Number(id)
|
||||
|
||||
const { data, isLoading, isError } = useGetRequiredDocumentById(documentId)
|
||||
|
||||
return (
|
||||
<div className="p-6 max-w-5xl">
|
||||
<h1 className="text-xl font-semibold text-foreground mb-5">
|
||||
{isLoading
|
||||
? t('common.loading', 'Ýüklenýär...')
|
||||
: `${t('loanDocuments.editTitle', 'Karz gerekli resminamalary redaktirle')}: ${data?.name.tk ?? ''}`}
|
||||
</h1>
|
||||
|
||||
{isLoading ? (
|
||||
<div className="bg-card border border-border rounded-xl overflow-hidden divide-y divide-border">
|
||||
{Array.from({ length: 2 }).map((_, i) => (
|
||||
<div key={i} className="grid grid-cols-[220px_1fr] items-start px-4 py-4">
|
||||
<Skeleton className="h-4 w-24 mt-2" />
|
||||
<div>
|
||||
<Skeleton className="h-10 w-full mb-2" />
|
||||
<Skeleton className="h-32 w-full" />
|
||||
</div>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
) : isError ? (
|
||||
<div className="flex items-center justify-center py-20 text-destructive text-sm">
|
||||
{t('common.error', 'Ýalňyşlyk ýüze çykdy')}
|
||||
</div>
|
||||
) : (
|
||||
<RequiredDocumentForm
|
||||
mode="edit"
|
||||
initialData={data}
|
||||
requiredDocumentId={documentId}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
117
src/pages/settings/loan/requiredDocumentsView/index.tsx
Normal file
117
src/pages/settings/loan/requiredDocumentsView/index.tsx
Normal file
@@ -0,0 +1,117 @@
|
||||
import { useParams, useNavigate } from 'react-router-dom'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import { Pencil, Trash2 } from 'lucide-react'
|
||||
import { Button } from '@/components/ui/button'
|
||||
import { Section, InfoRow } from '@/components/viewPageComponents'
|
||||
import { useGetRequiredDocumentById, useDeleteRequiredDocument } from '@/features/requiredDocuments/hooks/useRequiredDocuments'
|
||||
|
||||
export default function RequiredDocumentsViewPage() {
|
||||
const { id } = useParams<{ id: string }>()
|
||||
const navigate = useNavigate()
|
||||
const { t } = useTranslation()
|
||||
|
||||
const docId = Number(id)
|
||||
const { data, isLoading } = useGetRequiredDocumentById(docId)
|
||||
const deleteMutation = useDeleteRequiredDocument()
|
||||
|
||||
const handleDelete = async () => {
|
||||
if (window.confirm(t('loanDocuments.deleteConfirm', 'Bu resminamany öçürmek isleýärsiňizmi?'))) {
|
||||
await deleteMutation.mutateAsync(docId)
|
||||
navigate('/settings/loan/loan-documents')
|
||||
}
|
||||
}
|
||||
|
||||
if (isLoading) {
|
||||
return (
|
||||
<div className="space-y-2">
|
||||
{Array.from({ length: 3 }).map((_, i) => (
|
||||
<div key={i} className="h-12 bg-muted rounded-lg animate-pulse" />
|
||||
))}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
if (!data) {
|
||||
return (
|
||||
<div className="text-center py-16 text-muted-foreground">
|
||||
{t('common.notFound', 'Maglumat tapylmady')}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
return (
|
||||
<div>
|
||||
{/* Page heading */}
|
||||
<div className="flex items-start justify-between mb-4 gap-4">
|
||||
<h1 className="text-xl font-semibold text-foreground leading-snug line-clamp-2">
|
||||
{t('loanDocuments.viewTitle', 'Karz gerekli resminamalary giňişleýin')}: {data.name.tk}
|
||||
</h1>
|
||||
<div className="flex items-center gap-2 shrink-0">
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="icon"
|
||||
onClick={handleDelete}
|
||||
disabled={deleteMutation.isPending}
|
||||
className="text-muted-foreground hover:text-destructive hover:bg-destructive/10"
|
||||
>
|
||||
<Trash2 size={16} />
|
||||
</Button>
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="icon"
|
||||
onClick={() => navigate(`/settings/loan/loan-documents/${docId}/edit`)}
|
||||
className="text-muted-foreground hover:text-foreground"
|
||||
>
|
||||
<Pencil size={16} />
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Main info */}
|
||||
<Section>
|
||||
<InfoRow label="ID" value={data.id} />
|
||||
|
||||
{/* Name — multilingual */}
|
||||
<div className="grid grid-cols-[220px_1fr] items-start py-2.5 px-4 border-b border-border">
|
||||
<span className="text-sm text-muted-foreground pt-1">
|
||||
{t('loanDocuments.fields.name', 'Ady')}
|
||||
</span>
|
||||
<div className="space-y-3">
|
||||
{(['tk', 'ru', 'en'] as const).map((lang) => (
|
||||
<div key={lang}>
|
||||
<span className="text-xs font-semibold text-muted-foreground uppercase tracking-wider block mb-0.5">
|
||||
{lang === 'tk' ? 'Türkmen' : lang === 'ru' ? 'Русский' : 'English'}
|
||||
</span>
|
||||
<span className="text-sm text-foreground">{data.name[lang] || '—'}</span>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Description — multilingual */}
|
||||
<div className="grid grid-cols-[220px_1fr] items-start py-2.5 px-4">
|
||||
<span className="text-sm text-muted-foreground pt-1">
|
||||
{t('loanDocuments.fields.description', 'Yazgy')}
|
||||
</span>
|
||||
<div className="space-y-4">
|
||||
{(['tk', 'ru', 'en'] as const).map((lang) => (
|
||||
<div key={lang}>
|
||||
<span className="text-xs font-semibold text-muted-foreground uppercase tracking-wider block mb-1">
|
||||
{lang === 'tk' ? 'Türkmen' : lang === 'ru' ? 'Русский' : 'English'}
|
||||
</span>
|
||||
{data.description[lang] ? (
|
||||
<div
|
||||
className="text-sm text-foreground prose prose-sm dark:prose-invert max-w-none"
|
||||
dangerouslySetInnerHTML={{ __html: data.description[lang] }}
|
||||
/>
|
||||
) : (
|
||||
<span className="text-muted-foreground/40 text-sm">—</span>
|
||||
)}
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
</Section>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user