diff --git a/.gitignore b/.gitignore index 4d29575..f21726c 100644 --- a/.gitignore +++ b/.gitignore @@ -17,6 +17,7 @@ .env.development.local .env.test.local .env.production.local +.env npm-debug.log* yarn-debug.log* diff --git a/db.json b/db.json deleted file mode 100644 index af86354..0000000 --- a/db.json +++ /dev/null @@ -1,75 +0,0 @@ -{ - "reports": [ - { - "status": true, - "dollar": "6", - "score": "100", - "device_model": "B60", - "imei_number": "865784054670651", - "install_date": "1403/04/30 18:26:43", - "install_iemi": "1403/04/31 10:17:24" - }, - { - "status": false, - "dollar": "10", - "score": "250", - "device_model": "A76", - "imei_number": "865784054680547", - "install_date": "1403/05/01 18:26:43", - "install_iemi": "1403/05/31 10:17:24" - } - ], - "transactions": [ - { - "status": true, - "amount": "1558900", - "request_date": "1403/04/30 18:26:43", - "traking_number": "930482", - "deposit_date": "1403/04/31" - }, - { - "status": false, - "amount": "1558900", - "request_date": "1403/04/30 18:26:43", - "traking_number": "930482", - "deposit_date": "1403/04/31" - }, - { - "status": true, - "amount": "1558900", - "request_date": "1403/04/30 18:26:43", - "traking_number": "930482", - "deposit_date": "1403/04/31" - } - ], - "score": [ - { - "title": "نصب دستگاه", - "score": 30, - "date": "1403/04/31 10:17:24" - }, - { - "title": "IMEI registration", - "score": 5, - "date": "1403/05/31 10:17:24" - } - ], - "subscriptions": [ - { - "imei_number": "865784054680547", - "renewal_date": "1403/05/31 10:17:24", - "renewal_type": "2 ساله", - "amount": "500200", - "contribution": "20500", - "percentage": "10%" - }, - { - "imei_number": "865784054681250", - "renewal_date": "1403/05/31 10:17:24", - "renewal_type": "4 ساله", - "amount": "750000", - "contribution": "300000", - "percentage": "15%" - } - ] -} \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 58aaf86..ab40081 100644 --- a/package-lock.json +++ b/package-lock.json @@ -25,10 +25,10 @@ "iconsax-react": "^0.0.8", "iranianbanklogos": "^3.1.2", "jalaali-js": "^1.2.7", - "json-server": "^1.0.0-beta.1", "react": "^18.3.1", "react-dom": "^18.3.1", "react-hook-form": "^7.52.2", + "react-hot-toast": "^2.4.1", "react-modern-calendar-datepicker": "^3.1.6", "react-multi-date-picker": "^4.5.2", "react-otp-input": "^3.1.1", @@ -36,7 +36,8 @@ "react-scripts": "5.0.1", "typescript": "^4.9.5", "web-vitals": "^2.1.4", - "yup": "^1.4.0" + "yup": "^1.4.0", + "zustand": "^4.5.4" }, "devDependencies": { "@tanstack/eslint-plugin-query": "^5.51.15", @@ -3626,12 +3627,6 @@ } } }, - "node_modules/@polka/url": { - "version": "1.0.0-next.25", - "resolved": "https://registry.npmjs.org/@polka/url/-/url-1.0.0-next.25.tgz", - "integrity": "sha512-j7P6Rgr3mmtdkeDGTe0E/aYyWEWVtc5yFXtHCRHs28/jptDEWfaVOc5T7cblqy1XKPPfCxJc/8DwQ5YgLOZOVQ==", - "license": "MIT" - }, "node_modules/@react-aria/focus": { "version": "3.18.1", "resolved": "https://registry.npmjs.org/@react-aria/focus/-/focus-3.18.1.tgz", @@ -4651,290 +4646,6 @@ "@testing-library/dom": ">=7.21.4" } }, - "node_modules/@tinyhttp/accepts": { - "version": "2.2.2", - "resolved": "https://registry.npmjs.org/@tinyhttp/accepts/-/accepts-2.2.2.tgz", - "integrity": "sha512-DmngnwOaPgNUGgTpX1UdlNrXaGG6k5rHFzslcYlvSQIg7s0PI6bF86U0fYq3q+yhJhKbnwzFez0wU1lAP+bKvA==", - "license": "MIT", - "dependencies": { - "mime": "4.0.1", - "negotiator": "^0.6.3" - }, - "engines": { - "node": ">=12.20.0" - }, - "funding": { - "type": "individual", - "url": "https://github.com/tinyhttp/tinyhttp?sponsor=1" - } - }, - "node_modules/@tinyhttp/accepts/node_modules/mime": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/mime/-/mime-4.0.1.tgz", - "integrity": "sha512-5lZ5tyrIfliMXzFtkYyekWbtRXObT9OWa8IwQ5uxTBDHucNNwniRqo0yInflj+iYi5CBa6qxadGzGarDfuEOxA==", - "funding": [ - "https://github.com/sponsors/broofa" - ], - "license": "MIT", - "bin": { - "mime": "bin/cli.js" - }, - "engines": { - "node": ">=16" - } - }, - "node_modules/@tinyhttp/app": { - "version": "2.3.1", - "resolved": "https://registry.npmjs.org/@tinyhttp/app/-/app-2.3.1.tgz", - "integrity": "sha512-46sHcWTERHAHaBWRypXLH+qRXoYq1j9GfXr/TR2HIsuXWbXlirD77JbwabbTuGHFb5Cg8cisWEa+pTU7lp9t5A==", - "license": "MIT", - "dependencies": { - "@tinyhttp/cookie": "2.1.1", - "@tinyhttp/proxy-addr": "2.2.0", - "@tinyhttp/req": "2.2.3", - "@tinyhttp/res": "2.2.3", - "@tinyhttp/router": "2.2.2", - "header-range-parser": "1.1.3", - "regexparam": "^2.0.2" - }, - "engines": { - "node": ">=14.21.3" - }, - "funding": { - "type": "individual", - "url": "https://github.com/tinyhttp/tinyhttp?sponsor=1" - } - }, - "node_modules/@tinyhttp/content-disposition": { - "version": "2.2.1", - "resolved": "https://registry.npmjs.org/@tinyhttp/content-disposition/-/content-disposition-2.2.1.tgz", - "integrity": "sha512-PQ5IWdOn7arScqTV+usIDJvwbanoAXtaopzgxjMS9y7TFwLSIelCblihRBEVIPIkIpsdhSJFH3RF+Daosyj+Aw==", - "license": "MIT", - "engines": { - "node": ">=12.20.0" - }, - "funding": { - "type": "individual", - "url": "https://github.com/tinyhttp/tinyhttp?sponsor=1" - } - }, - "node_modules/@tinyhttp/content-type": { - "version": "0.1.4", - "resolved": "https://registry.npmjs.org/@tinyhttp/content-type/-/content-type-0.1.4.tgz", - "integrity": "sha512-dl6f3SHIJPYbhsW1oXdrqOmLSQF/Ctlv3JnNfXAE22kIP7FosqJHxkz/qj2gv465prG8ODKH5KEyhBkvwrueKQ==", - "license": "MIT", - "engines": { - "node": ">=12.4" - } - }, - "node_modules/@tinyhttp/cookie": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/@tinyhttp/cookie/-/cookie-2.1.1.tgz", - "integrity": "sha512-h/kL9jY0e0Dvad+/QU3efKZww0aTvZJslaHj3JTPmIPC9Oan9+kYqmh3M6L5JUQRuTJYFK2nzgL2iJtH2S+6dA==", - "license": "MIT", - "engines": { - "node": ">=12.20.0" - }, - "funding": { - "type": "individual", - "url": "https://github.com/tinyhttp/tinyhttp?sponsor=1" - } - }, - "node_modules/@tinyhttp/cookie-signature": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/@tinyhttp/cookie-signature/-/cookie-signature-2.1.1.tgz", - "integrity": "sha512-VDsSMY5OJfQJIAtUgeQYhqMPSZptehFSfvEEtxr+4nldPA8IImlp3QVcOVuK985g4AFR4Hl1sCbWCXoqBnVWnw==", - "license": "MIT", - "engines": { - "node": ">=12.20.0" - } - }, - "node_modules/@tinyhttp/cors": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/@tinyhttp/cors/-/cors-2.0.1.tgz", - "integrity": "sha512-qrmo6WJuaiCzKWagv2yA/kw6hIISfF/hOqPWwmI6w0o8apeTMmRN3DoCFvQ/wNVuWVdU5J4KU7OX8aaSOEq51A==", - "license": "MIT", - "dependencies": { - "@tinyhttp/vary": "^0.1.3" - }, - "engines": { - "node": ">=12.20 || 14.x || >=16" - } - }, - "node_modules/@tinyhttp/encode-url": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/@tinyhttp/encode-url/-/encode-url-2.1.1.tgz", - "integrity": "sha512-AhY+JqdZ56qV77tzrBm0qThXORbsVjs/IOPgGCS7x/wWnsa/Bx30zDUU/jPAUcSzNOzt860x9fhdGpzdqbUeUw==", - "license": "MIT", - "engines": { - "node": ">=12.20.0" - } - }, - "node_modules/@tinyhttp/etag": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/@tinyhttp/etag/-/etag-2.1.2.tgz", - "integrity": "sha512-j80fPKimGqdmMh6962y+BtQsnYPVCzZfJw0HXjyH70VaJBHLKGF+iYhcKqzI3yef6QBNa8DKIPsbEYpuwApXTw==", - "license": "MIT", - "engines": { - "node": ">=12.20.0" - } - }, - "node_modules/@tinyhttp/forwarded": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/@tinyhttp/forwarded/-/forwarded-2.1.1.tgz", - "integrity": "sha512-nO3kq0R1LRl2+CAMlnggm22zE6sT8gfvGbNvSitV6F9eaUSurHP0A8YZFMihSkugHxK+uIegh1TKrqgD8+lyGQ==", - "license": "MIT", - "engines": { - "node": ">=12.20.0" - } - }, - "node_modules/@tinyhttp/proxy-addr": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/@tinyhttp/proxy-addr/-/proxy-addr-2.2.0.tgz", - "integrity": "sha512-WM/PPL9xNvrs7/8Om5nhKbke5FHrP3EfjOOR+wBnjgESfibqn0K7wdUTnzSLp1lBmemr88os1XvzwymSgaibyA==", - "license": "MIT", - "dependencies": { - "@tinyhttp/forwarded": "2.1.1", - "ipaddr.js": "^2.2.0" - }, - "engines": { - "node": ">=12.20.0" - } - }, - "node_modules/@tinyhttp/req": { - "version": "2.2.3", - "resolved": "https://registry.npmjs.org/@tinyhttp/req/-/req-2.2.3.tgz", - "integrity": "sha512-HtIa4Gaa8QFTlmsvoif/B7yMK5H0WBUegH2kKW6scNwOpFXyxEk+VsctrIVgORrP5lybXAIRXlRhGuBBAMlVhw==", - "license": "MIT", - "dependencies": { - "@tinyhttp/accepts": "2.2.2", - "@tinyhttp/type-is": "2.2.3", - "@tinyhttp/url": "2.1.1", - "header-range-parser": "^1.1.3" - }, - "engines": { - "node": ">=12.20.0" - } - }, - "node_modules/@tinyhttp/res": { - "version": "2.2.3", - "resolved": "https://registry.npmjs.org/@tinyhttp/res/-/res-2.2.3.tgz", - "integrity": "sha512-PGl88OOdmMcOuKZaTbhGKAWPoJJf3+EfKIad8ydzjdenVjrTZZjIYJtmwYiUBeEice+YkOCO67qCIekVO5mHlw==", - "license": "MIT", - "dependencies": { - "@tinyhttp/content-disposition": "2.2.1", - "@tinyhttp/cookie": "2.1.1", - "@tinyhttp/cookie-signature": "2.1.1", - "@tinyhttp/encode-url": "2.1.1", - "@tinyhttp/req": "2.2.3", - "@tinyhttp/send": "2.2.2", - "@tinyhttp/vary": "^0.1.3", - "es-escape-html": "^0.1.1", - "mime": "4.0.0-beta.1" - }, - "engines": { - "node": ">=12.20.0" - } - }, - "node_modules/@tinyhttp/res/node_modules/mime": { - "version": "4.0.0-beta.1", - "resolved": "https://registry.npmjs.org/mime/-/mime-4.0.0-beta.1.tgz", - "integrity": "sha512-8/p99P1RV17prytee/A6D+8shNqdDzyvGJ/CVfiuXwh4cTsv3P3qGyaYSx2hdqnqbKKqYUfTC5zAjCtcd1BShw==", - "funding": [ - "https://github.com/sponsors/broofa" - ], - "license": "MIT", - "bin": { - "mime": "bin/cli.js" - }, - "engines": { - "node": ">=16" - } - }, - "node_modules/@tinyhttp/router": { - "version": "2.2.2", - "resolved": "https://registry.npmjs.org/@tinyhttp/router/-/router-2.2.2.tgz", - "integrity": "sha512-i+1ouhPyTqcuJuOsKqmo7i+YD++0RF2lQLhBpcTnsaegD2gTEa3xW2Pcz7spYQGo7K8PQYtOrL7m9b14+BEXqg==", - "license": "MIT", - "engines": { - "node": ">=12.20.0" - } - }, - "node_modules/@tinyhttp/send": { - "version": "2.2.2", - "resolved": "https://registry.npmjs.org/@tinyhttp/send/-/send-2.2.2.tgz", - "integrity": "sha512-TZkGy9EdGk+vwYWQnjArQftaXAUIgp/fFlgaxlpamsCZKy7o+CNJ75xty4H3SaY3ZPgN47wv8rnJ50rDRQdFFQ==", - "license": "MIT", - "dependencies": { - "@tinyhttp/content-type": "^0.1.4", - "@tinyhttp/etag": "2.1.2", - "mime": "4.0.0-beta.1" - }, - "engines": { - "node": ">=12.20.0" - } - }, - "node_modules/@tinyhttp/send/node_modules/mime": { - "version": "4.0.0-beta.1", - "resolved": "https://registry.npmjs.org/mime/-/mime-4.0.0-beta.1.tgz", - "integrity": "sha512-8/p99P1RV17prytee/A6D+8shNqdDzyvGJ/CVfiuXwh4cTsv3P3qGyaYSx2hdqnqbKKqYUfTC5zAjCtcd1BShw==", - "funding": [ - "https://github.com/sponsors/broofa" - ], - "license": "MIT", - "bin": { - "mime": "bin/cli.js" - }, - "engines": { - "node": ">=16" - } - }, - "node_modules/@tinyhttp/type-is": { - "version": "2.2.3", - "resolved": "https://registry.npmjs.org/@tinyhttp/type-is/-/type-is-2.2.3.tgz", - "integrity": "sha512-RsZ4+or5xI+wrTlrd+/cLZELoJDMd1HSp+1P23VOZSu1xPAsO1XLf1FgluO8GbEW9Ll/l2yC7mO6diKzjc06HA==", - "license": "MIT", - "dependencies": { - "@tinyhttp/content-type": "^0.1.4", - "mime": "4.0.1" - }, - "engines": { - "node": ">=12.20.0" - } - }, - "node_modules/@tinyhttp/type-is/node_modules/mime": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/mime/-/mime-4.0.1.tgz", - "integrity": "sha512-5lZ5tyrIfliMXzFtkYyekWbtRXObT9OWa8IwQ5uxTBDHucNNwniRqo0yInflj+iYi5CBa6qxadGzGarDfuEOxA==", - "funding": [ - "https://github.com/sponsors/broofa" - ], - "license": "MIT", - "bin": { - "mime": "bin/cli.js" - }, - "engines": { - "node": ">=16" - } - }, - "node_modules/@tinyhttp/url": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/@tinyhttp/url/-/url-2.1.1.tgz", - "integrity": "sha512-POJeq2GQ5jI7Zrdmj22JqOijB5/GeX+LEX7DUdml1hUnGbJOTWDx7zf2b5cCERj7RoXL67zTgyzVblBJC+NJWg==", - "license": "MIT", - "engines": { - "node": ">=12.20.0" - } - }, - "node_modules/@tinyhttp/vary": { - "version": "0.1.3", - "resolved": "https://registry.npmjs.org/@tinyhttp/vary/-/vary-0.1.3.tgz", - "integrity": "sha512-SoL83sQXAGiHN1jm2VwLUWQSQeDAAl1ywOm6T0b0Cg1CZhVsjoiZadmjhxF6FHCCY7OHHVaLnTgSMxTPIDLxMg==", - "license": "MIT", - "engines": { - "node": ">=12.20" - } - }, "node_modules/@tootallnate/once": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/@tootallnate/once/-/once-1.1.2.tgz", @@ -8212,33 +7923,6 @@ "tslib": "^2.0.3" } }, - "node_modules/dot-prop": { - "version": "9.0.0", - "resolved": "https://registry.npmjs.org/dot-prop/-/dot-prop-9.0.0.tgz", - "integrity": "sha512-1gxPBJpI/pcjQhKgIU91II6Wkay+dLcN3M6rf2uwP8hRur3HtQXjVrdAK3sjC0piaEuxzMwjXChcETiJl47lAQ==", - "license": "MIT", - "dependencies": { - "type-fest": "^4.18.2" - }, - "engines": { - "node": ">=18" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/dot-prop/node_modules/type-fest": { - "version": "4.24.0", - "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-4.24.0.tgz", - "integrity": "sha512-spAaHzc6qre0TlZQQ2aA/nGMe+2Z/wyGk5Z+Ru2VUfdNwT6kWO6TjevOlpebsATEG1EIQ2sOiDszud3lO5mt/Q==", - "license": "(MIT OR CC0-1.0)", - "engines": { - "node": ">=16" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, "node_modules/dotenv": { "version": "10.0.0", "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-10.0.0.tgz", @@ -8456,15 +8140,6 @@ "node": ">= 0.4" } }, - "node_modules/es-escape-html": { - "version": "0.1.1", - "resolved": "https://registry.npmjs.org/es-escape-html/-/es-escape-html-0.1.1.tgz", - "integrity": "sha512-yUx1o+8RsG7UlszmYPtks+dm6Lho2m8lgHMOsLJQsFI0R8XwUJwiMhM1M4E/S8QLeGyf6MkDV/pWgjQ0tdTSyQ==", - "license": "MIT", - "engines": { - "node": ">=12.x" - } - }, "node_modules/es-get-iterator": { "version": "1.1.3", "resolved": "https://registry.npmjs.org/es-get-iterator/-/es-get-iterator-1.1.3.tgz", @@ -9339,18 +9014,6 @@ "node": ">=0.10.0" } }, - "node_modules/eta": { - "version": "3.4.1", - "resolved": "https://registry.npmjs.org/eta/-/eta-3.4.1.tgz", - "integrity": "sha512-a5+UIcEuj3wYx3FoXFh05O5GAs10uTd2GTEYlaCALE2Ds03ZkKlAXzHpXA/6ZSZ6Xwka/IuDjFY+wKDmw2RNDg==", - "license": "MIT", - "engines": { - "node": ">=6.0.0" - }, - "funding": { - "url": "https://github.com/eta-dev/eta?sponsor=1" - } - }, "node_modules/etag": { "version": "1.8.1", "resolved": "https://registry.npmjs.org/etag/-/etag-1.8.1.tgz", @@ -10292,6 +9955,15 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/goober": { + "version": "2.1.14", + "resolved": "https://registry.npmjs.org/goober/-/goober-2.1.14.tgz", + "integrity": "sha512-4UpC0NdGyAFqLNPnhCT2iHpza2q+RAY3GV85a/mRPdzyPQMsj0KmMMuetdIkzWRbJ+Hgau1EZztq8ImmiMGhsg==", + "license": "MIT", + "peerDependencies": { + "csstype": "^3.0.10" + } + }, "node_modules/gopd": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/gopd/-/gopd-1.0.1.tgz", @@ -10433,15 +10105,6 @@ "he": "bin/he" } }, - "node_modules/header-range-parser": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/header-range-parser/-/header-range-parser-1.1.3.tgz", - "integrity": "sha512-B9zCFt3jH8g09LR1vHL4pcAn8yMEtlSlOUdQemzHMRKMImNIhhszdeosYFfNW0WXKQtXIlWB+O4owHJKvEJYaA==", - "license": "MIT", - "engines": { - "node": ">=12.22.0" - } - }, "node_modules/hoopy": { "version": "0.1.4", "resolved": "https://registry.npmjs.org/hoopy/-/hoopy-0.1.4.tgz", @@ -10842,15 +10505,6 @@ "node": ">=8" } }, - "node_modules/inflection": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/inflection/-/inflection-3.0.0.tgz", - "integrity": "sha512-1zEJU1l19SgJlmwqsEyFTbScw/tkMHFenUo//Y0i+XEP83gDFdMvPizAD/WGcE+l1ku12PcTVHQhO6g5E0UCMw==", - "license": "MIT", - "engines": { - "node": ">=18.0.0" - } - }, "node_modules/inflight": { "version": "1.0.6", "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", @@ -13790,44 +13444,6 @@ "integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==", "license": "MIT" }, - "node_modules/json-server": { - "version": "1.0.0-beta.1", - "resolved": "https://registry.npmjs.org/json-server/-/json-server-1.0.0-beta.1.tgz", - "integrity": "sha512-xOKYyxkVai66OTFZq5ulAaXYkqiKMbzVED9tRZ+CMg6v6iaSdIVYas5tIjSMw/mYwDL/nJFTCca308gaL0coyA==", - "license": "SEE LICENSE IN ./LICENSE", - "dependencies": { - "@tinyhttp/app": "^2.2.3", - "@tinyhttp/cors": "^2.0.0", - "chalk": "^5.3.0", - "chokidar": "^3.6.0", - "dot-prop": "^9.0.0", - "eta": "^3.4.0", - "inflection": "^3.0.0", - "json5": "^2.2.3", - "lowdb": "^7.0.1", - "milliparsec": "^2.3.0", - "sirv": "^2.0.4", - "sort-on": "^6.0.0" - }, - "bin": { - "json-server": "lib/bin.js" - }, - "engines": { - "node": ">=18.3" - } - }, - "node_modules/json-server/node_modules/chalk": { - "version": "5.3.0", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-5.3.0.tgz", - "integrity": "sha512-dLitG79d+GV1Nb/VYcCDFivJeK1hiukt9QjRNVOsUtTy1rR1YJsmpGGTZ3qJos+uw7WmWF4wUwBd9jxjocFC2w==", - "license": "MIT", - "engines": { - "node": "^12.17.0 || ^14.13 || >=16.0.0" - }, - "funding": { - "url": "https://github.com/chalk/chalk?sponsor=1" - } - }, "node_modules/json-stable-stringify-without-jsonify": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/json-stable-stringify-without-jsonify/-/json-stable-stringify-without-jsonify-1.0.1.tgz", @@ -14089,21 +13705,6 @@ "loose-envify": "cli.js" } }, - "node_modules/lowdb": { - "version": "7.0.1", - "resolved": "https://registry.npmjs.org/lowdb/-/lowdb-7.0.1.tgz", - "integrity": "sha512-neJAj8GwF0e8EpycYIDFqEPcx9Qz4GUho20jWFR7YiFeXzF1YMLdxB36PypcTSPMA+4+LvgyMacYhlr18Zlymw==", - "license": "MIT", - "dependencies": { - "steno": "^4.0.2" - }, - "engines": { - "node": ">=18" - }, - "funding": { - "url": "https://github.com/sponsors/typicode" - } - }, "node_modules/lower-case": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/lower-case/-/lower-case-2.0.2.tgz", @@ -14243,15 +13844,6 @@ "node": ">=8.6" } }, - "node_modules/milliparsec": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/milliparsec/-/milliparsec-2.3.0.tgz", - "integrity": "sha512-b+6KYJw+DwQjk24qCUuq+lZvRXDpXJ02qsllKgKaDurHpQ0v7D5op9VAkdYM/pXRhFeh7uLYHmnwFnYvdXGa3A==", - "license": "MIT", - "engines": { - "node": ">=12.4" - } - }, "node_modules/mime": { "version": "1.6.0", "resolved": "https://registry.npmjs.org/mime/-/mime-1.6.0.tgz", @@ -14371,15 +13963,6 @@ "mkdirp": "bin/cmd.js" } }, - "node_modules/mrmime": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/mrmime/-/mrmime-2.0.0.tgz", - "integrity": "sha512-eu38+hdgojoyq63s+yTpN4XMBdt5l8HhMhc4VKLO9KM5caLIBvUm4thi7fFaxyTmCKeNnXZ5pAlBwCUnhA09uw==", - "license": "MIT", - "engines": { - "node": ">=10" - } - }, "node_modules/ms": { "version": "2.1.2", "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", @@ -16921,6 +16504,22 @@ "react": "^16.8.0 || ^17 || ^18 || ^19" } }, + "node_modules/react-hot-toast": { + "version": "2.4.1", + "resolved": "https://registry.npmjs.org/react-hot-toast/-/react-hot-toast-2.4.1.tgz", + "integrity": "sha512-j8z+cQbWIM5LY37pR6uZR6D4LfseplqnuAO4co4u8917hBUvXlEqyP1ZzqVLcqoyUesZZv/ImreoCeHVDpE5pQ==", + "license": "MIT", + "dependencies": { + "goober": "^2.1.10" + }, + "engines": { + "node": ">=10" + }, + "peerDependencies": { + "react": ">=16", + "react-dom": ">=16" + } + }, "node_modules/react-is": { "version": "17.0.2", "resolved": "https://registry.npmjs.org/react-is/-/react-is-17.0.2.tgz", @@ -17216,15 +16815,6 @@ "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/regexparam": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/regexparam/-/regexparam-2.0.2.tgz", - "integrity": "sha512-A1PeDEYMrkLrfyOwv2jwihXbo9qxdGD3atBYQA9JJgreAx8/7rC6IUkWOw2NQlOxLp2wL0ifQbh1HuidDfYA6w==", - "license": "MIT", - "engines": { - "node": ">=8" - } - }, "node_modules/regexpu-core": { "version": "5.3.2", "resolved": "https://registry.npmjs.org/regexpu-core/-/regexpu-core-5.3.2.tgz", @@ -18009,20 +17599,6 @@ "integrity": "sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ==", "license": "ISC" }, - "node_modules/sirv": { - "version": "2.0.4", - "resolved": "https://registry.npmjs.org/sirv/-/sirv-2.0.4.tgz", - "integrity": "sha512-94Bdh3cC2PKrbgSOUqTiGPWVZeSiXfKOVZNJniWoqrWrRkB1CJzBU3NEbiTsPcYy1lDsANA/THzS+9WBiy5nfQ==", - "license": "MIT", - "dependencies": { - "@polka/url": "^1.0.0-next.24", - "mrmime": "^2.0.0", - "totalist": "^3.0.0" - }, - "engines": { - "node": ">= 10" - } - }, "node_modules/sisteransi": { "version": "1.0.5", "resolved": "https://registry.npmjs.org/sisteransi/-/sisteransi-1.0.5.tgz", @@ -18049,48 +17625,6 @@ "websocket-driver": "^0.7.4" } }, - "node_modules/sort-on": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/sort-on/-/sort-on-6.0.0.tgz", - "integrity": "sha512-d51VlJWoFQjp+cIZRyNusCyJdP5pLAw+H+sC4C2q6RhPBv+RAb/QXXck5q3Kdm7h/ot/kD2AlpGPDee8v+0qiA==", - "license": "MIT", - "dependencies": { - "dot-prop": "^8.0.2" - }, - "engines": { - "node": ">=18" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/sort-on/node_modules/dot-prop": { - "version": "8.0.2", - "resolved": "https://registry.npmjs.org/dot-prop/-/dot-prop-8.0.2.tgz", - "integrity": "sha512-xaBe6ZT4DHPkg0k4Ytbvn5xoxgpG0jOS1dYxSOwAHPuNLjP3/OzN0gH55SrLqpx8cBfSaVt91lXYkApjb+nYdQ==", - "license": "MIT", - "dependencies": { - "type-fest": "^3.8.0" - }, - "engines": { - "node": ">=16" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/sort-on/node_modules/type-fest": { - "version": "3.13.1", - "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-3.13.1.tgz", - "integrity": "sha512-tLq3bSNx+xSpwvAJnzrK0Ep5CLNWjvFTOp71URMaAEWBfRb9nnJiBoUe0tF8bI4ZFO3omgBR6NvnbzVUT3Ly4g==", - "license": "(MIT OR CC0-1.0)", - "engines": { - "node": ">=14.16" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, "node_modules/source-list-map": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/source-list-map/-/source-list-map-2.0.1.tgz", @@ -18341,18 +17875,6 @@ "node": ">= 0.8" } }, - "node_modules/steno": { - "version": "4.0.2", - "resolved": "https://registry.npmjs.org/steno/-/steno-4.0.2.tgz", - "integrity": "sha512-yhPIQXjrlt1xv7dyPQg2P17URmXbuM5pdGkpiMB3RenprfiBlvK415Lctfe0eshk90oA7/tNq7WEiMK8RSP39A==", - "license": "MIT", - "engines": { - "node": ">=18" - }, - "funding": { - "url": "https://github.com/sponsors/typicode" - } - }, "node_modules/stop-iteration-iterator": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/stop-iteration-iterator/-/stop-iteration-iterator-1.0.0.tgz", @@ -19167,15 +18689,6 @@ "integrity": "sha512-0a5EOkAUp8D4moMi2W8ZF8jcga7BgZd91O/yabJCFY8az+XSzeGyTKs0Aoo897iV1Nj6guFq8orWDS96z91oGg==", "license": "MIT" }, - "node_modules/totalist": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/totalist/-/totalist-3.0.1.tgz", - "integrity": "sha512-sf4i37nQ2LBx4m3wB74y+ubopq6W/dIzXg0FDGjsYnZHVa1Da8FH853wlL2gtUhg+xJXjfk3kUZS3BRoQeoQBQ==", - "license": "MIT", - "engines": { - "node": ">=6" - } - }, "node_modules/tough-cookie": { "version": "4.1.4", "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-4.1.4.tgz", @@ -19594,6 +19107,15 @@ "requires-port": "^1.0.0" } }, + "node_modules/use-sync-external-store": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/use-sync-external-store/-/use-sync-external-store-1.2.0.tgz", + "integrity": "sha512-eEgnFxGQ1Ife9bzYs6VLi8/4X6CObHMw9Qr9tPY43iKwsPw8xE8+EFsf/2cFZ5S3esXgpWgtSCtLNS41F+sKPA==", + "license": "MIT", + "peerDependencies": { + "react": "^16.8.0 || ^17.0.0 || ^18.0.0" + } + }, "node_modules/util-deprecate": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", @@ -20707,6 +20229,34 @@ "funding": { "url": "https://github.com/sponsors/sindresorhus" } + }, + "node_modules/zustand": { + "version": "4.5.4", + "resolved": "https://registry.npmjs.org/zustand/-/zustand-4.5.4.tgz", + "integrity": "sha512-/BPMyLKJPtFEvVL0E9E9BTUM63MNyhPGlvxk1XjrfWTUlV+BR8jufjsovHzrtR6YNcBEcL7cMHovL1n9xHawEg==", + "license": "MIT", + "dependencies": { + "use-sync-external-store": "1.2.0" + }, + "engines": { + "node": ">=12.7.0" + }, + "peerDependencies": { + "@types/react": ">=16.8", + "immer": ">=9.0.6", + "react": ">=16.8" + }, + "peerDependenciesMeta": { + "@types/react": { + "optional": true + }, + "immer": { + "optional": true + }, + "react": { + "optional": true + } + } } } } diff --git a/package.json b/package.json index 2ffb964..33fb4b1 100644 --- a/package.json +++ b/package.json @@ -20,10 +20,10 @@ "iconsax-react": "^0.0.8", "iranianbanklogos": "^3.1.2", "jalaali-js": "^1.2.7", - "json-server": "^1.0.0-beta.1", "react": "^18.3.1", "react-dom": "^18.3.1", "react-hook-form": "^7.52.2", + "react-hot-toast": "^2.4.1", "react-modern-calendar-datepicker": "^3.1.6", "react-multi-date-picker": "^4.5.2", "react-otp-input": "^3.1.1", @@ -31,7 +31,8 @@ "react-scripts": "5.0.1", "typescript": "^4.9.5", "web-vitals": "^2.1.4", - "yup": "^1.4.0" + "yup": "^1.4.0", + "zustand": "^4.5.4" }, "scripts": { "start": "react-scripts start", diff --git a/src/components/common/button.tsx b/src/components/common/button.tsx new file mode 100644 index 0000000..6cdd875 --- /dev/null +++ b/src/components/common/button.tsx @@ -0,0 +1,27 @@ +import { Button } from "@headlessui/react" +import clsx from "clsx" +import { FC } from "react" + +type Props = { + title: string + type?: "reset" | "button" | "submit" | undefined, + pending?: boolean, + theme?: "primary" | "secondary" | "glass" | "light" +} + +export const ButtonComponent: FC = ({ title, type = "button", pending = false, theme = "primary" }) => { + return ( + + ) +} \ No newline at end of file diff --git a/src/components/forms/login-form.tsx b/src/components/forms/login-form.tsx index 4e5e25d..f29420e 100644 --- a/src/components/forms/login-form.tsx +++ b/src/components/forms/login-form.tsx @@ -1,13 +1,22 @@ -import { Link } from "react-router-dom" +import { Link, useNavigate } from "react-router-dom" import { Input } from "../common/input" -import { Button } from "@headlessui/react" import { Controller, SubmitHandler, useForm } from "react-hook-form" import { LoginFormInterface } from "../../types" import { loginSchema } from "../../schema" import { ErrorComponent } from "../common/error" import { yupResolver } from '@hookform/resolvers/yup' +import { useMutation } from "@tanstack/react-query" +import { loginMutation } from "../../services/api/auth" +import { useAuthStore } from "../../store/auth-token" +import { ButtonComponent } from "../common/button" +import toast from "react-hot-toast" export const LoginForm = () => { + const navigate = useNavigate() + const { setToken: setLoginToken } = useAuthStore() + const { mutate, isPending } = useMutation({ + mutationFn: loginMutation + }) const { handleSubmit, formState: { errors }, @@ -15,9 +24,22 @@ export const LoginForm = () => { } = useForm({ resolver: yupResolver(loginSchema) }) - const handleLoginSubmit: SubmitHandler = async (data) => { - console.log("data=>", data) + const handleLoginSubmit: SubmitHandler = async (data) => { + mutate({ + ...data, + remember_me: true + }, { + onSuccess: (data: any) => { + setLoginToken(data?.data?.token) + toast.success("با موفقیت وارد شدین") + navigate("/") + }, + onError: () => { + toast.error("نام کاربری یا رمز عبور اشتباه است") + } + }) } + return (
@@ -33,10 +55,10 @@ export const LoginForm = () => {
- ( + (
- - + +
)} /> ( @@ -48,7 +70,7 @@ export const LoginForm = () => {

فراموشی رمز عبور

- +

ورود با رمز یکبار مصرف

diff --git a/src/index.tsx b/src/index.tsx index 380a931..6f346e1 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -4,10 +4,9 @@ import { RouterProvider } from 'react-router-dom'; import { router } from './router'; import './index.css' import "iranianbanklogos/dist/ibl.css"; +import { Toaster } from 'react-hot-toast'; import { RQProvider } from './rq-provider'; - - const root = ReactDOM.createRoot( document.getElementById('root') as HTMLElement ); @@ -16,6 +15,9 @@ root.render( + ); diff --git a/src/schema/index.ts b/src/schema/index.ts index 056c7f0..857215f 100644 --- a/src/schema/index.ts +++ b/src/schema/index.ts @@ -1,11 +1,11 @@ import * as yup from 'yup' export const loginSchema = yup.object({ - phoneNumber: yup.string() - .required("وارد کردن شماره تماس الزامی میباشد") - .min(11, "شماره تماس نمیتوند کمتر از 11 رقم باشد") - .max(11, "شماره تماس نمیتواند بیشتر از 11 رقم باشد") - .matches(/^[0-9]{11}$/, "شماره تماس نامعتبر"), + username: yup.string() + .required("وارد کردن نام کاربری الزامی میباشد") + .min(10, "نام کاربری نمیتوند کمتر از 10 رقم باشد") + .max(10, "نام کاربری نمیتواند بیشتر از 10 رقم باشد") + .matches(/^[0-9]{10}$/, "شماره تماس نامعتبر"), password: yup.string() .required("وارد کردن رمزعبور الزامی میباشد") .min(8, "رمزعبور نمیتواند کمتر از 8 کاراکتر باشد") diff --git a/src/services/api/auth.ts b/src/services/api/auth.ts new file mode 100644 index 0000000..415e24c --- /dev/null +++ b/src/services/api/auth.ts @@ -0,0 +1,3 @@ +import { axiosInstance } from "../axios"; + +export const loginMutation = (payload: any) => axiosInstance.post("/auth/gps/login", payload) \ No newline at end of file diff --git a/src/services/axios.ts b/src/services/axios.ts index e3ef73c..42f5f05 100644 --- a/src/services/axios.ts +++ b/src/services/axios.ts @@ -1,7 +1,7 @@ import axios, { AxiosRequestConfig } from "axios"; const axiosParam: AxiosRequestConfig = { - baseURL: "http://localhost:4000" + baseURL: process.env.REACT_APP_API_Address } export const axiosInstance = axios.create(axiosParam) \ No newline at end of file diff --git a/src/store/auth-token.ts b/src/store/auth-token.ts new file mode 100644 index 0000000..27e7d73 --- /dev/null +++ b/src/store/auth-token.ts @@ -0,0 +1,11 @@ +import create from 'zustand'; + +interface AuthState { + token: string | null; + setToken: (token: string | null) => void; +} + +export const useAuthStore = create((set) => ({ + token: null, + setToken: (token) => set({ token }), +})); \ No newline at end of file diff --git a/src/types/index.ts b/src/types/index.ts index cebe8d6..80653a1 100644 --- a/src/types/index.ts +++ b/src/types/index.ts @@ -1,7 +1,7 @@ import React from "react" export interface LoginFormInterface { - phoneNumber: string, + username: string, password: string } diff --git a/tailwind.config.js b/tailwind.config.js index 323cdf8..e8665d5 100644 --- a/tailwind.config.js +++ b/tailwind.config.js @@ -11,7 +11,9 @@ module.exports = { "secondary-text-color": "#777577", "primary-color": "#015699", "secondary-color": "#E6E8EA", - "border-color": "#D9D9D9" + "border-color": "#D9D9D9", + "dark-blue": "#013C6B", + "sky-blue": "#4D88B7", }, backgroundImage: { 'mehr_iran': "url('/public/svgs/banks/mehr_iran.svg')",