diff --git a/db-1720504233338.json b/db-1720504233338.json
new file mode 100644
index 0000000..f2ae48d
--- /dev/null
+++ b/db-1720504233338.json
@@ -0,0 +1,19 @@
+{
+ "posts": [
+ {
+ "id": 1,
+ "title": "json-server",
+ "author": "typicode"
+ }
+ ],
+ "comments": [
+ {
+ "id": 1,
+ "body": "some comment",
+ "postId": 1
+ }
+ ],
+ "profile": {
+ "name": "typicode"
+ }
+}
\ No newline at end of file
diff --git a/db.json b/db.json
new file mode 100644
index 0000000..f126f68
--- /dev/null
+++ b/db.json
@@ -0,0 +1,67 @@
+{
+ "users": [
+ {
+ "id": 1,
+ "email": "employee@example.com",
+ "password": "password123",
+ "role": "employee"
+ },
+ {
+ "id": 2,
+ "email": "admin@example.com",
+ "password": "admin123",
+ "role": "admin"
+ },
+ {
+ "email": "employee@example.com",
+ "password": "password123",
+ "id": 3,
+ "role": "employee"
+ },
+ {
+ "id": 4,
+ "email": "suraj@gmail.com",
+ "password": "pass",
+ "role": "employee"
+ },
+ {
+ "id": 5
+ },
+ {
+ "id": 6
+ },
+ {
+ "id": 7
+ },
+ {
+ "id": 8
+ },
+ {
+ "id": 9
+ },
+ {
+ "id": 10
+ },
+ {
+ "id": 11,
+ "email": "urhtuhreiuuryuihd@gmail.com",
+ "password": "password12",
+ "role": "employee"
+ },
+ {
+ "id": 12
+ },
+ {
+ "id": 13
+ },
+ {
+ "id": 14
+ },
+ {
+ "id": 15
+ },
+ {
+ "id": 16
+ }
+ ]
+}
\ No newline at end of file
diff --git a/lib/api/axiosConfig.js b/lib/api/axiosConfig.js
new file mode 100644
index 0000000..b2f0722
--- /dev/null
+++ b/lib/api/axiosConfig.js
@@ -0,0 +1,7 @@
+import axios from 'axios';
+
+const axiosInstance = axios.create({
+ baseURL: 'http://localhost:5000'
+});
+
+export default axiosInstance;
\ No newline at end of file
diff --git a/package-lock.json b/package-lock.json
index d83a362..e8078a9 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -24,6 +24,7 @@
"eslint-plugin-react": "^7.34.1",
"eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-react-refresh": "^0.4.6",
+ "json-server": "^1.0.0-beta.1",
"postcss": "^8.4.38",
"tailwindcss": "^3.4.4",
"vite": "^5.2.0"
@@ -860,6 +861,13 @@
"node": ">=14"
}
},
+ "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==",
+ "dev": true,
+ "license": "MIT"
+ },
"node_modules/@rc-component/async-validator": {
"version": "5.0.4",
"resolved": "https://registry.npmjs.org/@rc-component/async-validator/-/async-validator-5.0.4.tgz",
@@ -1014,6 +1022,280 @@
"win32"
]
},
+ "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==",
+ "dev": true,
+ "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/app": {
+ "version": "2.2.4",
+ "resolved": "https://registry.npmjs.org/@tinyhttp/app/-/app-2.2.4.tgz",
+ "integrity": "sha512-vFCgE+RncK9+AHpSXHiOxpbaEbpOxYcYHz4K/15Ckh8Sb7WvjA+vveN7bwMqfifyW2uvV3xTKTitUVohf+kDnA==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "@tinyhttp/cookie": "2.1.1",
+ "@tinyhttp/proxy-addr": "2.1.4",
+ "@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==",
+ "dev": true,
+ "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==",
+ "dev": true,
+ "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==",
+ "dev": true,
+ "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==",
+ "dev": true,
+ "license": "MIT",
+ "engines": {
+ "node": ">=12.20.0"
+ }
+ },
+ "node_modules/@tinyhttp/cors": {
+ "version": "2.0.0",
+ "resolved": "https://registry.npmjs.org/@tinyhttp/cors/-/cors-2.0.0.tgz",
+ "integrity": "sha512-IwQsPBnK+gRrhTsPA4FPOfbNzZZt8cVsOIMNFb6HzoScaiWcoLEogL0Bz/aBSm8KM13uieVXoVT6udMqhqUS2A==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "es-vary": "^0.1.1"
+ },
+ "engines": {
+ "node": ">=12.4 || 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==",
+ "dev": true,
+ "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==",
+ "dev": true,
+ "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==",
+ "dev": true,
+ "license": "MIT",
+ "engines": {
+ "node": ">=12.20.0"
+ }
+ },
+ "node_modules/@tinyhttp/proxy-addr": {
+ "version": "2.1.4",
+ "resolved": "https://registry.npmjs.org/@tinyhttp/proxy-addr/-/proxy-addr-2.1.4.tgz",
+ "integrity": "sha512-Xb57jBQW3UcwKST1XSkJpyZPyjOVQJjUfXiHULVXf7FZCgnl273+aj0oP15BzpYLuGhO9IjydY5gvYeg2Cny+A==",
+ "dev": true,
+ "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==",
+ "dev": true,
+ "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==",
+ "dev": true,
+ "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==",
+ "dev": true,
+ "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==",
+ "dev": true,
+ "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==",
+ "dev": true,
+ "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==",
+ "dev": true,
+ "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==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "@tinyhttp/content-type": "^0.1.4",
+ "mime": "4.0.1"
+ },
+ "engines": {
+ "node": ">=12.20.0"
+ }
+ },
+ "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==",
+ "dev": true,
+ "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==",
+ "dev": true,
+ "license": "MIT",
+ "engines": {
+ "node": ">=12.20"
+ }
+ },
"node_modules/@types/babel__core": {
"version": "7.20.5",
"resolved": "https://registry.npmjs.org/@types/babel__core/-/babel__core-7.20.5.tgz",
@@ -1957,6 +2239,35 @@
"node": ">=0.10.0"
}
},
+ "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==",
+ "dev": true,
+ "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.21.0",
+ "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-4.21.0.tgz",
+ "integrity": "sha512-ADn2w7hVPcK6w1I0uWnM//y1rLXZhzB9mr0a3OirzclKF1Wp6VzevUmzz/NRAWunOT6E8HrnpGY7xOfc6K57fA==",
+ "dev": true,
+ "license": "(MIT OR CC0-1.0)",
+ "engines": {
+ "node": ">=16"
+ },
+ "funding": {
+ "url": "https://github.com/sponsors/sindresorhus"
+ }
+ },
"node_modules/eastasianwidth": {
"version": "0.2.0",
"resolved": "https://registry.npmjs.org/eastasianwidth/-/eastasianwidth-0.2.0.tgz",
@@ -2060,6 +2371,16 @@
"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==",
+ "dev": true,
+ "license": "MIT",
+ "engines": {
+ "node": ">=12.x"
+ }
+ },
"node_modules/es-iterator-helpers": {
"version": "1.0.19",
"resolved": "https://registry.npmjs.org/es-iterator-helpers/-/es-iterator-helpers-1.0.19.tgz",
@@ -2142,6 +2463,16 @@
"url": "https://github.com/sponsors/ljharb"
}
},
+ "node_modules/es-vary": {
+ "version": "0.1.2",
+ "resolved": "https://registry.npmjs.org/es-vary/-/es-vary-0.1.2.tgz",
+ "integrity": "sha512-pLqqZoOutAXQXyBJrUYVNM5fZngiOJYi1Xl4svQMrluTsqDUOQlBMw9EYgLrsWL6niDYn/Yd1y2Pj6GC+j/yjA==",
+ "dev": true,
+ "license": "MIT",
+ "engines": {
+ "node": ">=12.x"
+ }
+ },
"node_modules/esbuild": {
"version": "0.21.5",
"resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.21.5.tgz",
@@ -2423,6 +2754,19 @@
"node": ">=0.10.0"
}
},
+ "node_modules/eta": {
+ "version": "3.4.0",
+ "resolved": "https://registry.npmjs.org/eta/-/eta-3.4.0.tgz",
+ "integrity": "sha512-tCsc7WXTjrTx4ZjYLplcqrI3o4mYJ+Z6YspeuGL8tbt/hHoMchwBwtKfwM09svEY86iRapY93vUqQttcNuIO5Q==",
+ "dev": true,
+ "license": "MIT",
+ "engines": {
+ "node": ">=6.0.0"
+ },
+ "funding": {
+ "url": "https://github.com/eta-dev/eta?sponsor=1"
+ }
+ },
"node_modules/fast-deep-equal": {
"version": "3.1.3",
"resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz",
@@ -2900,6 +3244,16 @@
"node": ">= 0.4"
}
},
+ "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==",
+ "dev": true,
+ "license": "MIT",
+ "engines": {
+ "node": ">=12.22.0"
+ }
+ },
"node_modules/ignore": {
"version": "5.3.1",
"resolved": "https://registry.npmjs.org/ignore/-/ignore-5.3.1.tgz",
@@ -2937,6 +3291,16 @@
"node": ">=0.8.19"
}
},
+ "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==",
+ "dev": true,
+ "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",
@@ -2970,6 +3334,16 @@
"node": ">= 0.4"
}
},
+ "node_modules/ipaddr.js": {
+ "version": "2.2.0",
+ "resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-2.2.0.tgz",
+ "integrity": "sha512-Ag3wB2o37wslZS19hZqorUnrnzSkpOVy+IiiDEiTqNubEYpYuHWIf6K4psgN2ZWKExS4xhVCrRVfb/wfW8fWJA==",
+ "dev": true,
+ "license": "MIT",
+ "engines": {
+ "node": ">= 10"
+ }
+ },
"node_modules/is-array-buffer": {
"version": "3.0.4",
"resolved": "https://registry.npmjs.org/is-array-buffer/-/is-array-buffer-3.0.4.tgz",
@@ -3463,6 +3837,46 @@
"dev": true,
"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==",
+ "dev": true,
+ "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==",
+ "dev": true,
+ "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",
@@ -3582,6 +3996,22 @@
"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==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "steno": "^4.0.2"
+ },
+ "engines": {
+ "node": ">=18"
+ },
+ "funding": {
+ "url": "https://github.com/sponsors/typicode"
+ }
+ },
"node_modules/lru-cache": {
"version": "5.1.1",
"resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-5.1.1.tgz",
@@ -3614,6 +4044,32 @@
"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==",
+ "dev": true,
+ "license": "MIT",
+ "engines": {
+ "node": ">=12.4"
+ }
+ },
+ "node_modules/mime": {
+ "version": "4.0.1",
+ "resolved": "https://registry.npmjs.org/mime/-/mime-4.0.1.tgz",
+ "integrity": "sha512-5lZ5tyrIfliMXzFtkYyekWbtRXObT9OWa8IwQ5uxTBDHucNNwniRqo0yInflj+iYi5CBa6qxadGzGarDfuEOxA==",
+ "dev": true,
+ "funding": [
+ "https://github.com/sponsors/broofa"
+ ],
+ "license": "MIT",
+ "bin": {
+ "mime": "bin/cli.js"
+ },
+ "engines": {
+ "node": ">=16"
+ }
+ },
"node_modules/mime-db": {
"version": "1.52.0",
"resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz",
@@ -3655,6 +4111,16 @@
"node": ">=16 || 14 >=14.17"
}
},
+ "node_modules/mrmime": {
+ "version": "2.0.0",
+ "resolved": "https://registry.npmjs.org/mrmime/-/mrmime-2.0.0.tgz",
+ "integrity": "sha512-eu38+hdgojoyq63s+yTpN4XMBdt5l8HhMhc4VKLO9KM5caLIBvUm4thi7fFaxyTmCKeNnXZ5pAlBwCUnhA09uw==",
+ "dev": true,
+ "license": "MIT",
+ "engines": {
+ "node": ">=10"
+ }
+ },
"node_modules/ms": {
"version": "2.1.2",
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz",
@@ -3699,6 +4165,16 @@
"dev": true,
"license": "MIT"
},
+ "node_modules/negotiator": {
+ "version": "0.6.3",
+ "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.3.tgz",
+ "integrity": "sha512-+EUsqGPLsM+j/zdChZjsnX51g4XrHFOIXwfnCVPGlQk/k5giakcKsuxCObBRu6DSm9opw/O6slWbJdghQM4bBg==",
+ "dev": true,
+ "license": "MIT",
+ "engines": {
+ "node": ">= 0.6"
+ }
+ },
"node_modules/node-releases": {
"version": "2.0.14",
"resolved": "https://registry.npmjs.org/node-releases/-/node-releases-2.0.14.tgz",
@@ -5027,6 +5503,16 @@
"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==",
+ "dev": true,
+ "license": "MIT",
+ "engines": {
+ "node": ">=8"
+ }
+ },
"node_modules/resize-observer-polyfill": {
"version": "1.5.1",
"resolved": "https://registry.npmjs.org/resize-observer-polyfill/-/resize-observer-polyfill-1.5.1.tgz",
@@ -5301,6 +5787,66 @@
"url": "https://github.com/sponsors/isaacs"
}
},
+ "node_modules/sirv": {
+ "version": "2.0.4",
+ "resolved": "https://registry.npmjs.org/sirv/-/sirv-2.0.4.tgz",
+ "integrity": "sha512-94Bdh3cC2PKrbgSOUqTiGPWVZeSiXfKOVZNJniWoqrWrRkB1CJzBU3NEbiTsPcYy1lDsANA/THzS+9WBiy5nfQ==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "@polka/url": "^1.0.0-next.24",
+ "mrmime": "^2.0.0",
+ "totalist": "^3.0.0"
+ },
+ "engines": {
+ "node": ">= 10"
+ }
+ },
+ "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==",
+ "dev": true,
+ "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==",
+ "dev": true,
+ "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==",
+ "dev": true,
+ "license": "(MIT OR CC0-1.0)",
+ "engines": {
+ "node": ">=14.16"
+ },
+ "funding": {
+ "url": "https://github.com/sponsors/sindresorhus"
+ }
+ },
"node_modules/source-map-js": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.2.0.tgz",
@@ -5311,6 +5857,19 @@
"node": ">=0.10.0"
}
},
+ "node_modules/steno": {
+ "version": "4.0.2",
+ "resolved": "https://registry.npmjs.org/steno/-/steno-4.0.2.tgz",
+ "integrity": "sha512-yhPIQXjrlt1xv7dyPQg2P17URmXbuM5pdGkpiMB3RenprfiBlvK415Lctfe0eshk90oA7/tNq7WEiMK8RSP39A==",
+ "dev": true,
+ "license": "MIT",
+ "engines": {
+ "node": ">=18"
+ },
+ "funding": {
+ "url": "https://github.com/sponsors/typicode"
+ }
+ },
"node_modules/string-convert": {
"version": "0.2.1",
"resolved": "https://registry.npmjs.org/string-convert/-/string-convert-0.2.1.tgz",
@@ -5720,6 +6279,16 @@
"integrity": "sha512-BiZS+C1OS8g/q2RRbJmy59xpyghNBqrr6k5L/uKBGRsTfxmu3ffiRnd8mlGPUVayg8pvfi5urfnu8TU7DVOkLQ==",
"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==",
+ "dev": true,
+ "license": "MIT",
+ "engines": {
+ "node": ">=6"
+ }
+ },
"node_modules/ts-interface-checker": {
"version": "0.1.13",
"resolved": "https://registry.npmjs.org/ts-interface-checker/-/ts-interface-checker-0.1.13.tgz",
diff --git a/package.json b/package.json
index 21a9aa0..0e77ecc 100644
--- a/package.json
+++ b/package.json
@@ -7,8 +7,13 @@
"dev": "vite",
"build": "vite build",
"lint": "eslint . --ext js,jsx --report-unused-disable-directives --max-warnings 0",
- "preview": "vite preview"
+ "preview": "vite preview",
+ "start": "react-scripts start",
+ "test": "react-scripts test",
+ "eject": "react-scripts eject",
+ "server": "json-server --watch db.json --port 5000"
},
+ "proxy": "http://localhost:5000",
"dependencies": {
"@ant-design/icons": "^5.3.7",
"antd": "^5.18.2",
@@ -26,6 +31,7 @@
"eslint-plugin-react": "^7.34.1",
"eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-react-refresh": "^0.4.6",
+ "json-server": "^1.0.0-beta.1",
"postcss": "^8.4.38",
"tailwindcss": "^3.4.4",
"vite": "^5.2.0"
diff --git a/public/customers.json b/public/customers.json
new file mode 100644
index 0000000..6e2594c
--- /dev/null
+++ b/public/customers.json
@@ -0,0 +1,8 @@
+
+[
+ { "id": "12d22", "name": "Jane Cooper" },
+ { "id": "5d255", "name": "Esther Howard" },
+ { "id": "147r7", "name": "Guy Hawkins" },
+ { "id": "124fd", "name": "Savannah Nguyen" }
+ ]
+
\ No newline at end of file
diff --git a/public/db.json b/public/db.json
new file mode 100644
index 0000000..c61529e
--- /dev/null
+++ b/public/db.json
@@ -0,0 +1,27 @@
+{
+ "posts": [
+ { "id": "1", "title": "a title", "views": 100 },
+ { "id": "2", "title": "another title", "views": 200 }
+ ],
+ "comments": [
+ { "id": "1", "text": "a comment about post 1", "postId": "1" },
+ { "id": "2", "text": "another comment about post 1", "postId": "1" }
+ ],
+ "profile": {
+ "name": "suraj"
+ },
+ "users": [
+ {
+ "id": "1",
+ "email": "admin@example.com",
+ "password": "adminpassword",
+ "role": "admin"
+ },
+ {
+ "id": "2",
+ "email": "employee@example.com",
+ "password": "employeepassword",
+ "role": "employee"
+ }
+ ]
+}
diff --git a/src/api/axiosConfig.jsx b/src/api/axiosConfig.jsx
index 52b6a8f..30c0e54 100644
--- a/src/api/axiosConfig.jsx
+++ b/src/api/axiosConfig.jsx
@@ -1,12 +1,22 @@
// src/api/axiosConfig.js
+
import axios from 'axios';
const axiosInstance = axios.create({
- baseURL: 'http://your-backend-url.com', // Replace with your backend URL
- timeout: 10000, // Timeout after 10 seconds
+ baseURL: '/api',
headers: {
'Content-Type': 'application/json',
},
});
+axiosInstance.interceptors.request.use((config) => {
+ const token = localStorage.getItem('token');
+ if (token) {
+ config.headers.Authorization = `Bearer ${token}`;
+ }
+ return config;
+}, (error) => {
+ return Promise.reject(error);
+});
+
export default axiosInstance;
diff --git a/src/components/Auth/LoginPage.jsx b/src/components/Auth/LoginPage.jsx
index 6957f4e..39cc383 100644
--- a/src/components/Auth/LoginPage.jsx
+++ b/src/components/Auth/LoginPage.jsx
@@ -11,24 +11,35 @@ const LoginPage = () => {
const handleLogin = async (e) => {
e.preventDefault();
- setError(''); // Reset error message
-
+ setError('');
+
try {
- const response = await axios.post('/login', { email, password });
- const { role } = response.data;
-
- if (role === 'admin') {
- navigate('/admin');
- } else if (role === 'employee') {
- navigate('/employee');
+ const response = await axiosInstance.get('http://localhost:5000/users');
+
+ const user = response.data.find(user => user.email === email && user.password === password);
+
+ if (user) {
+ if (user.role === 'admin') {
+ navigate('/admin');
+ } else if (user.role === 'employee') {
+ navigate('/employee');
+ } else {
+ setError('Invalid credentials');
+ }
} else {
setError('Invalid credentials');
}
} catch (err) {
- setError('Login failed. Please try again.');
+ if (err.response) {
+ setError(`Login failed: ${err.response.data.message}`);
+ } else if (err.request) {
+ setError('Login failed. No response from server.');
+ } else {
+ setError('Login failed. Please try again.');
+ }
}
};
-
+
return (
@@ -37,9 +48,7 @@ const LoginPage = () => {
Be among the first to experience 3D magic! Register for private alpha.
{error &&
{error}
}
diff --git a/src/components/UserList.jsx b/src/components/UserList.jsx
new file mode 100644
index 0000000..cc85387
--- /dev/null
+++ b/src/components/UserList.jsx
@@ -0,0 +1,29 @@
+import React, { useEffect, useState } from 'react';
+import axiosInstance from '../api/axiosInstance';
+
+const UsersList = () => {
+ const [users, setUsers] = useState([]);
+
+ useEffect(() => {
+ axiosInstance.get('/users')
+ .then(response => {
+ setUsers(response.data);
+ })
+ .catch(error => {
+ console.error('There was an error fetching the users!', error);
+ });
+ }, []);
+
+ return (
+
+
Users List
+
+ {users.map(user => (
+ - {user.name}
+ ))}
+
+
+ );
+};
+
+export default UsersList;
diff --git a/src/components/customer/AddCustomer.jsx b/src/components/customer/AddCustomer.jsx
index 0877038..87229d0 100644
--- a/src/components/customer/AddCustomer.jsx
+++ b/src/components/customer/AddCustomer.jsx
@@ -6,8 +6,8 @@ const AddCustomer = () => {
return (
-
-
+
+
Add Customer
skip for now
diff --git a/src/components/customer/CustomerList.jsx b/src/components/customer/CustomerList.jsx
index 15bb713..d32623c 100644
--- a/src/components/customer/CustomerList.jsx
+++ b/src/components/customer/CustomerList.jsx
@@ -1,16 +1,18 @@
-import React from 'react';
+import React, { useState, useEffect } from 'react';
import { useNavigate } from 'react-router-dom';
import Sidebar from '../sidebar/Sidebar';
const CustomerList = () => {
+ const [customers, setCustomers] = useState([]);
const navigate = useNavigate();
- const customers = [
- { id: '12d22', name: 'jane cooper' },
- { id: '5d255', name: 'esther howard' },
- { id: '147r7', name: 'guy hawkins' },
- { id: '124fd', name: 'savannah nguyen' },
- ];
+ useEffect(() => {
+ // Fetch the customers data from the JSON file
+ fetch('/customers.json')
+ .then((response) => response.json())
+ .then((data) => setCustomers(data))
+ .catch((error) => console.error('Error fetching customers:', error));
+ }, []);
const handleAddCustomer = () => {
navigate('/add-customer');
@@ -22,27 +24,27 @@ const CustomerList = () => {
-
customers list
-
-
total customers ({customers.length})
+
Total Customers ({customers.length})
# |
- customer id |
- customer name |
+ Customer ID |
+ Customer Name |
diff --git a/src/components/customer/CustomerMeasurements.jsx b/src/components/customer/CustomerMeasurements.jsx
index af44b1e..616397e 100644
--- a/src/components/customer/CustomerMeasurements.jsx
+++ b/src/components/customer/CustomerMeasurements.jsx
@@ -1,68 +1,81 @@
import React from 'react';
import { Button, Input, Form } from 'antd';
import { Link } from 'react-router-dom';
+import axios from 'axios';
import Sidebar from '../sidebar/Sidebar';
+
const CustomerMeasurements = () => {
- const onFinish = (values) => {
- console.log('Measurements:', values);
+ const onFinish = async (values) => {
+ const token = localStorage.getItem('token'); // Assuming the token is stored in localStorage
+
+ try {
+ const response = await axios.post('http://localhost:8080/measurements', values, {
+ headers: {
+ Authorization: `Bearer ${token}`,
+ },
+ });
+
+ console.log(response.data);
+ } catch (error) {
+ console.error('Error saving measurements:', error);
+ }
};
return (
-
-
);
};
diff --git a/src/components/employee/EmployeeDashboard.jsx b/src/components/employee/EmployeeDashboard.jsx
index 3e6ad6e..97f5cb9 100644
--- a/src/components/employee/EmployeeDashboard.jsx
+++ b/src/components/employee/EmployeeDashboard.jsx
@@ -9,8 +9,8 @@ const HomePage = () => {
return (
-
-
+
+
home
@@ -29,13 +29,13 @@ const HomePage = () => {
handleClick('/customers')}
+ onClick={() => handleClick('')}
>
view orders
handleClick('/customers')}
+ onClick={() => handleClick('')}
>
view customers
diff --git a/src/components/sidebar/EmployeeSidebar.jsx b/src/components/sidebar/EmployeeSidebar.jsx
index cb4f385..2ded640 100644
--- a/src/components/sidebar/EmployeeSidebar.jsx
+++ b/src/components/sidebar/EmployeeSidebar.jsx
@@ -1,6 +1,10 @@
-import React from 'react';
-import { Layout } from 'antd';
+import React, { useState } from 'react';
+import { Layout, Drawer, Button } from 'antd';
import { Link } from 'react-router-dom';
+import {
+ MenuFoldOutlined,
+ MenuUnfoldOutlined,
+} from '@ant-design/icons';
import HomeIcon from '../../assets/thob-data/HomeIcon.svg';
import AddCustomerIcon from '../../assets/thob-data/AddCustomerIcon.svg';
import OrdersIcon from '../../assets/thob-data/OrdersIcon.svg';
@@ -8,35 +12,89 @@ import CategoriesIcon from '../../assets/thob-data/CategoriesIcon.svg';
import ProfileIcon from '../../assets/thob-data/ProfileIcon.svg';
import LogoutIcon from '../../assets/thob-data/LogoutIcon.svg';
+
const { Sider } = Layout;
const EmployeeSidebar = () => {
+ const [visible, setVisible] = useState(false);
+
+ const showDrawer = () => {
+ setVisible(true);
+ };
+
+ const closeDrawer = () => {
+ setVisible(false);
+ };
+
return (
-
-
-
-
-

-
-
-

-
-
-

-
-
-

-
-
-

-
-
-

-
-
-
+ <>
+ : }
+ />
+
+
+
+

+
+
+

+
+
+

+
+
+

+
+
+

+
+
+

+
+
+
+
+
+
+
+

+
+
+

+
+
+

+
+
+

+
+
+

+
+
+

+
+
+
+ >
);
};
diff --git a/src/components/sidebar/Sidebar.jsx b/src/components/sidebar/Sidebar.jsx
index ca38ff1..987060d 100644
--- a/src/components/sidebar/Sidebar.jsx
+++ b/src/components/sidebar/Sidebar.jsx
@@ -22,7 +22,7 @@ const Sidebar = () => {
// return user.role === 'admin' ? : ;
return (
-
+
t.