Use toasts, cleanup code blocks
This commit is contained in:
parent
cb889cc826
commit
de582afe95
16 changed files with 550 additions and 52 deletions
378
frontend/package-lock.json
generated
378
frontend/package-lock.json
generated
|
|
@ -24,6 +24,7 @@
|
|||
"react-responsive-carousel": "^3.2.23",
|
||||
"react-router-dom": "^6.3.0",
|
||||
"react-scripts": "5.0.1",
|
||||
"react-syntax-highlighter": "^15.5.0",
|
||||
"redux": "^4.1.2",
|
||||
"web-vitals": "^2.1.4"
|
||||
},
|
||||
|
|
@ -6015,6 +6016,24 @@
|
|||
"url": "https://github.com/sponsors/wooorm"
|
||||
}
|
||||
},
|
||||
"node_modules/character-entities-legacy": {
|
||||
"version": "1.1.4",
|
||||
"resolved": "https://registry.npmjs.org/character-entities-legacy/-/character-entities-legacy-1.1.4.tgz",
|
||||
"integrity": "sha512-3Xnr+7ZFS1uxeiUDvV02wQ+QDbc55o97tIV5zHScSPJpcLm/r0DFPcoY3tYRp+VZukxuMeKgXYmsXQHO05zQeA==",
|
||||
"funding": {
|
||||
"type": "github",
|
||||
"url": "https://github.com/sponsors/wooorm"
|
||||
}
|
||||
},
|
||||
"node_modules/character-reference-invalid": {
|
||||
"version": "1.1.4",
|
||||
"resolved": "https://registry.npmjs.org/character-reference-invalid/-/character-reference-invalid-1.1.4.tgz",
|
||||
"integrity": "sha512-mKKUkUbhPpQlCOfIuZkvSEgktjPFIsZKRRbC6KWVEMvlzblj3i3asQv5ODsrwt0N3pHAEvjP8KTQPHkp0+6jOg==",
|
||||
"funding": {
|
||||
"type": "github",
|
||||
"url": "https://github.com/sponsors/wooorm"
|
||||
}
|
||||
},
|
||||
"node_modules/charcodes": {
|
||||
"version": "0.2.0",
|
||||
"resolved": "https://registry.npmjs.org/charcodes/-/charcodes-0.2.0.tgz",
|
||||
|
|
@ -8301,6 +8320,18 @@
|
|||
"reusify": "^1.0.4"
|
||||
}
|
||||
},
|
||||
"node_modules/fault": {
|
||||
"version": "1.0.4",
|
||||
"resolved": "https://registry.npmjs.org/fault/-/fault-1.0.4.tgz",
|
||||
"integrity": "sha512-CJ0HCB5tL5fYTEA7ToAq5+kTwd++Borf1/bifxd9iT70QcXr4MRrO3Llf8Ifs70q+SJcGHFtnIE/Nw6giCtECA==",
|
||||
"dependencies": {
|
||||
"format": "^0.2.0"
|
||||
},
|
||||
"funding": {
|
||||
"type": "github",
|
||||
"url": "https://github.com/sponsors/wooorm"
|
||||
}
|
||||
},
|
||||
"node_modules/faye-websocket": {
|
||||
"version": "0.11.4",
|
||||
"resolved": "https://registry.npmjs.org/faye-websocket/-/faye-websocket-0.11.4.tgz",
|
||||
|
|
@ -8644,6 +8675,14 @@
|
|||
"node": ">= 6"
|
||||
}
|
||||
},
|
||||
"node_modules/format": {
|
||||
"version": "0.2.2",
|
||||
"resolved": "https://registry.npmjs.org/format/-/format-0.2.2.tgz",
|
||||
"integrity": "sha1-1hcBB+nv3E7TDJ3DkBbflCtctYs=",
|
||||
"engines": {
|
||||
"node": ">=0.4.x"
|
||||
}
|
||||
},
|
||||
"node_modules/forwarded": {
|
||||
"version": "0.2.0",
|
||||
"resolved": "https://registry.npmjs.org/forwarded/-/forwarded-0.2.0.tgz",
|
||||
|
|
@ -9028,6 +9067,15 @@
|
|||
"url": "https://github.com/sponsors/ljharb"
|
||||
}
|
||||
},
|
||||
"node_modules/hast-util-parse-selector": {
|
||||
"version": "2.2.5",
|
||||
"resolved": "https://registry.npmjs.org/hast-util-parse-selector/-/hast-util-parse-selector-2.2.5.tgz",
|
||||
"integrity": "sha512-7j6mrk/qqkSehsM92wQjdIgWM2/BW61u/53G6xmC8i1OmEdKLHbk419QKQUjz6LglWsfqoiHmyMRkP1BGjecNQ==",
|
||||
"funding": {
|
||||
"type": "opencollective",
|
||||
"url": "https://opencollective.com/unified"
|
||||
}
|
||||
},
|
||||
"node_modules/hast-util-whitespace": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/hast-util-whitespace/-/hast-util-whitespace-2.0.0.tgz",
|
||||
|
|
@ -9037,6 +9085,52 @@
|
|||
"url": "https://opencollective.com/unified"
|
||||
}
|
||||
},
|
||||
"node_modules/hastscript": {
|
||||
"version": "6.0.0",
|
||||
"resolved": "https://registry.npmjs.org/hastscript/-/hastscript-6.0.0.tgz",
|
||||
"integrity": "sha512-nDM6bvd7lIqDUiYEiu5Sl/+6ReP0BMk/2f4U/Rooccxkj0P5nm+acM5PrGJ/t5I8qPGiqZSE6hVAwZEdZIvP4w==",
|
||||
"dependencies": {
|
||||
"@types/hast": "^2.0.0",
|
||||
"comma-separated-tokens": "^1.0.0",
|
||||
"hast-util-parse-selector": "^2.0.0",
|
||||
"property-information": "^5.0.0",
|
||||
"space-separated-tokens": "^1.0.0"
|
||||
},
|
||||
"funding": {
|
||||
"type": "opencollective",
|
||||
"url": "https://opencollective.com/unified"
|
||||
}
|
||||
},
|
||||
"node_modules/hastscript/node_modules/comma-separated-tokens": {
|
||||
"version": "1.0.8",
|
||||
"resolved": "https://registry.npmjs.org/comma-separated-tokens/-/comma-separated-tokens-1.0.8.tgz",
|
||||
"integrity": "sha512-GHuDRO12Sypu2cV70d1dkA2EUmXHgntrzbpvOB+Qy+49ypNfGgFQIC2fhhXbnyrJRynDCAARsT7Ou0M6hirpfw==",
|
||||
"funding": {
|
||||
"type": "github",
|
||||
"url": "https://github.com/sponsors/wooorm"
|
||||
}
|
||||
},
|
||||
"node_modules/hastscript/node_modules/property-information": {
|
||||
"version": "5.6.0",
|
||||
"resolved": "https://registry.npmjs.org/property-information/-/property-information-5.6.0.tgz",
|
||||
"integrity": "sha512-YUHSPk+A30YPv+0Qf8i9Mbfe/C0hdPXk1s1jPVToV8pk8BQtpw10ct89Eo7OWkutrwqvT0eicAxlOg3dOAu8JA==",
|
||||
"dependencies": {
|
||||
"xtend": "^4.0.0"
|
||||
},
|
||||
"funding": {
|
||||
"type": "github",
|
||||
"url": "https://github.com/sponsors/wooorm"
|
||||
}
|
||||
},
|
||||
"node_modules/hastscript/node_modules/space-separated-tokens": {
|
||||
"version": "1.1.5",
|
||||
"resolved": "https://registry.npmjs.org/space-separated-tokens/-/space-separated-tokens-1.1.5.tgz",
|
||||
"integrity": "sha512-q/JSVd1Lptzhf5bkYm4ob4iWPjx0KiRe3sRFBNrVqbJkFaBm5vbbowy1mymoPNLRa52+oadOhJ+K49wsSeSjTA==",
|
||||
"funding": {
|
||||
"type": "github",
|
||||
"url": "https://github.com/sponsors/wooorm"
|
||||
}
|
||||
},
|
||||
"node_modules/he": {
|
||||
"version": "1.2.0",
|
||||
"resolved": "https://registry.npmjs.org/he/-/he-1.2.0.tgz",
|
||||
|
|
@ -9050,6 +9144,14 @@
|
|||
"resolved": "https://registry.npmjs.org/hey-listen/-/hey-listen-1.0.8.tgz",
|
||||
"integrity": "sha512-COpmrF2NOg4TBWUJ5UVyaCU2A88wEMkUPK4hNqyCkqHbxT92BbvfjoSozkAIIm6XhicGlJHhFdullInrdhwU8Q=="
|
||||
},
|
||||
"node_modules/highlight.js": {
|
||||
"version": "10.7.3",
|
||||
"resolved": "https://registry.npmjs.org/highlight.js/-/highlight.js-10.7.3.tgz",
|
||||
"integrity": "sha512-tzcUFauisWKNHaRkN4Wjl/ZA07gENAjFl3J/c480dprkGTg5EQstgaNFqBfUqCq54kZRIEcreTsAgF/m2quD7A==",
|
||||
"engines": {
|
||||
"node": "*"
|
||||
}
|
||||
},
|
||||
"node_modules/history": {
|
||||
"version": "5.3.0",
|
||||
"resolved": "https://registry.npmjs.org/history/-/history-5.3.0.tgz",
|
||||
|
|
@ -9468,6 +9570,28 @@
|
|||
"node": ">= 10"
|
||||
}
|
||||
},
|
||||
"node_modules/is-alphabetical": {
|
||||
"version": "1.0.4",
|
||||
"resolved": "https://registry.npmjs.org/is-alphabetical/-/is-alphabetical-1.0.4.tgz",
|
||||
"integrity": "sha512-DwzsA04LQ10FHTZuL0/grVDk4rFoVH1pjAToYwBrHSxcrBIGQuXrQMtD5U1b0U2XVgKZCTLLP8u2Qxqhy3l2Vg==",
|
||||
"funding": {
|
||||
"type": "github",
|
||||
"url": "https://github.com/sponsors/wooorm"
|
||||
}
|
||||
},
|
||||
"node_modules/is-alphanumerical": {
|
||||
"version": "1.0.4",
|
||||
"resolved": "https://registry.npmjs.org/is-alphanumerical/-/is-alphanumerical-1.0.4.tgz",
|
||||
"integrity": "sha512-UzoZUr+XfVz3t3v4KyGEniVL9BDRoQtY7tOyrRybkVNjDFWyo1yhXNGrrBTQxp3ib9BLAWs7k2YKBQsFRkZG9A==",
|
||||
"dependencies": {
|
||||
"is-alphabetical": "^1.0.0",
|
||||
"is-decimal": "^1.0.0"
|
||||
},
|
||||
"funding": {
|
||||
"type": "github",
|
||||
"url": "https://github.com/sponsors/wooorm"
|
||||
}
|
||||
},
|
||||
"node_modules/is-arrayish": {
|
||||
"version": "0.2.1",
|
||||
"resolved": "https://registry.npmjs.org/is-arrayish/-/is-arrayish-0.2.1.tgz",
|
||||
|
|
@ -9568,6 +9692,15 @@
|
|||
"url": "https://github.com/sponsors/ljharb"
|
||||
}
|
||||
},
|
||||
"node_modules/is-decimal": {
|
||||
"version": "1.0.4",
|
||||
"resolved": "https://registry.npmjs.org/is-decimal/-/is-decimal-1.0.4.tgz",
|
||||
"integrity": "sha512-RGdriMmQQvZ2aqaQq3awNA6dCGtKpiDFcOzrTWrDAT2MiWrKQVPmxLGHl7Y2nNu6led0kEyoX0enY0qXYsv9zw==",
|
||||
"funding": {
|
||||
"type": "github",
|
||||
"url": "https://github.com/sponsors/wooorm"
|
||||
}
|
||||
},
|
||||
"node_modules/is-docker": {
|
||||
"version": "2.2.1",
|
||||
"resolved": "https://registry.npmjs.org/is-docker/-/is-docker-2.2.1.tgz",
|
||||
|
|
@ -9617,6 +9750,15 @@
|
|||
"node": ">=0.10.0"
|
||||
}
|
||||
},
|
||||
"node_modules/is-hexadecimal": {
|
||||
"version": "1.0.4",
|
||||
"resolved": "https://registry.npmjs.org/is-hexadecimal/-/is-hexadecimal-1.0.4.tgz",
|
||||
"integrity": "sha512-gyPJuv83bHMpocVYoqof5VDiZveEoGoFL8m3BXNb2VW8Xs+rz9kqO8LOQ5DH6EsuvilT1ApazU0pyl+ytbPtlw==",
|
||||
"funding": {
|
||||
"type": "github",
|
||||
"url": "https://github.com/sponsors/wooorm"
|
||||
}
|
||||
},
|
||||
"node_modules/is-module": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/is-module/-/is-module-1.0.0.tgz",
|
||||
|
|
@ -11983,6 +12125,19 @@
|
|||
"tslib": "^2.0.3"
|
||||
}
|
||||
},
|
||||
"node_modules/lowlight": {
|
||||
"version": "1.20.0",
|
||||
"resolved": "https://registry.npmjs.org/lowlight/-/lowlight-1.20.0.tgz",
|
||||
"integrity": "sha512-8Ktj+prEb1RoCPkEOrPMYUN/nCggB7qAWe3a7OpMjWQkh3l2RD5wKRQ+o8Q8YuI9RG/xs95waaI/E6ym/7NsTw==",
|
||||
"dependencies": {
|
||||
"fault": "^1.0.0",
|
||||
"highlight.js": "~10.7.0"
|
||||
},
|
||||
"funding": {
|
||||
"type": "github",
|
||||
"url": "https://github.com/sponsors/wooorm"
|
||||
}
|
||||
},
|
||||
"node_modules/lru-cache": {
|
||||
"version": "6.0.0",
|
||||
"resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz",
|
||||
|
|
@ -13160,6 +13315,32 @@
|
|||
"node": ">=6"
|
||||
}
|
||||
},
|
||||
"node_modules/parse-entities": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/parse-entities/-/parse-entities-2.0.0.tgz",
|
||||
"integrity": "sha512-kkywGpCcRYhqQIchaWqZ875wzpS/bMKhz5HnN3p7wveJTkTtyAB/AlnS0f8DFSqYW1T82t6yEAkEcB+A1I3MbQ==",
|
||||
"dependencies": {
|
||||
"character-entities": "^1.0.0",
|
||||
"character-entities-legacy": "^1.0.0",
|
||||
"character-reference-invalid": "^1.0.0",
|
||||
"is-alphanumerical": "^1.0.0",
|
||||
"is-decimal": "^1.0.0",
|
||||
"is-hexadecimal": "^1.0.0"
|
||||
},
|
||||
"funding": {
|
||||
"type": "github",
|
||||
"url": "https://github.com/sponsors/wooorm"
|
||||
}
|
||||
},
|
||||
"node_modules/parse-entities/node_modules/character-entities": {
|
||||
"version": "1.2.4",
|
||||
"resolved": "https://registry.npmjs.org/character-entities/-/character-entities-1.2.4.tgz",
|
||||
"integrity": "sha512-iBMyeEHxfVnIakwOuDXpVkc54HijNgCyQB2w0VfGQThle6NXn50zU6V/u+LDhxHcDUPojn6Kpga3PTAD8W1bQw==",
|
||||
"funding": {
|
||||
"type": "github",
|
||||
"url": "https://github.com/sponsors/wooorm"
|
||||
}
|
||||
},
|
||||
"node_modules/parse-json": {
|
||||
"version": "5.2.0",
|
||||
"resolved": "https://registry.npmjs.org/parse-json/-/parse-json-5.2.0.tgz",
|
||||
|
|
@ -14646,6 +14827,14 @@
|
|||
"resolved": "https://registry.npmjs.org/react-is/-/react-is-17.0.2.tgz",
|
||||
"integrity": "sha512-w2GsyukL62IJnlaff/nRegPQR94C/XXamvMWmSHRJ4y7Ts/4ocGRmTHvOs8PSE6pB3dWOrD/nueuU5sduBsQ4w=="
|
||||
},
|
||||
"node_modules/prismjs": {
|
||||
"version": "1.28.0",
|
||||
"resolved": "https://registry.npmjs.org/prismjs/-/prismjs-1.28.0.tgz",
|
||||
"integrity": "sha512-8aaXdYvl1F7iC7Xm1spqSaY/OJBpYW3v+KJ+F17iYxvdc8sfjW194COK5wVhMZX45tGteiBQgdvD/nhxcRwylw==",
|
||||
"engines": {
|
||||
"node": ">=6"
|
||||
}
|
||||
},
|
||||
"node_modules/process-nextick-args": {
|
||||
"version": "2.0.1",
|
||||
"resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.1.tgz",
|
||||
|
|
@ -15311,6 +15500,21 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"node_modules/react-syntax-highlighter": {
|
||||
"version": "15.5.0",
|
||||
"resolved": "https://registry.npmjs.org/react-syntax-highlighter/-/react-syntax-highlighter-15.5.0.tgz",
|
||||
"integrity": "sha512-+zq2myprEnQmH5yw6Gqc8lD55QHnpKaU8TOcFeC/Lg/MQSs8UknEA0JC4nTZGFAXC2J2Hyj/ijJ7NlabyPi2gg==",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.3.1",
|
||||
"highlight.js": "^10.4.1",
|
||||
"lowlight": "^1.17.0",
|
||||
"prismjs": "^1.27.0",
|
||||
"refractor": "^3.6.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"react": ">= 0.14.0"
|
||||
}
|
||||
},
|
||||
"node_modules/readable-stream": {
|
||||
"version": "3.6.0",
|
||||
"resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.0.tgz",
|
||||
|
|
@ -15365,6 +15569,28 @@
|
|||
"@babel/runtime": "^7.9.2"
|
||||
}
|
||||
},
|
||||
"node_modules/refractor": {
|
||||
"version": "3.6.0",
|
||||
"resolved": "https://registry.npmjs.org/refractor/-/refractor-3.6.0.tgz",
|
||||
"integrity": "sha512-MY9W41IOWxxk31o+YvFCNyNzdkc9M20NoZK5vq6jkv4I/uh2zkWcfudj0Q1fovjUQJrNewS9NMzeTtqPf+n5EA==",
|
||||
"dependencies": {
|
||||
"hastscript": "^6.0.0",
|
||||
"parse-entities": "^2.0.0",
|
||||
"prismjs": "~1.27.0"
|
||||
},
|
||||
"funding": {
|
||||
"type": "github",
|
||||
"url": "https://github.com/sponsors/wooorm"
|
||||
}
|
||||
},
|
||||
"node_modules/refractor/node_modules/prismjs": {
|
||||
"version": "1.27.0",
|
||||
"resolved": "https://registry.npmjs.org/prismjs/-/prismjs-1.27.0.tgz",
|
||||
"integrity": "sha512-t13BGPUlFDR7wRB5kQDG4jjl7XeuH6jbJGt11JHPL96qwsEHNX2+68tFXqc1/k+/jALsbSWJKUOT/hcYAZ5LkA==",
|
||||
"engines": {
|
||||
"node": ">=6"
|
||||
}
|
||||
},
|
||||
"node_modules/regenerate": {
|
||||
"version": "1.4.2",
|
||||
"resolved": "https://registry.npmjs.org/regenerate/-/regenerate-1.4.2.tgz",
|
||||
|
|
@ -22548,6 +22774,16 @@
|
|||
"resolved": "https://registry.npmjs.org/character-entities/-/character-entities-2.0.1.tgz",
|
||||
"integrity": "sha512-OzmutCf2Kmc+6DrFrrPS8/tDh2+DpnrfzdICHWhcVC9eOd0N1PXmQEE1a8iM4IziIAG+8tmTq3K+oo0ubH6RRQ=="
|
||||
},
|
||||
"character-entities-legacy": {
|
||||
"version": "1.1.4",
|
||||
"resolved": "https://registry.npmjs.org/character-entities-legacy/-/character-entities-legacy-1.1.4.tgz",
|
||||
"integrity": "sha512-3Xnr+7ZFS1uxeiUDvV02wQ+QDbc55o97tIV5zHScSPJpcLm/r0DFPcoY3tYRp+VZukxuMeKgXYmsXQHO05zQeA=="
|
||||
},
|
||||
"character-reference-invalid": {
|
||||
"version": "1.1.4",
|
||||
"resolved": "https://registry.npmjs.org/character-reference-invalid/-/character-reference-invalid-1.1.4.tgz",
|
||||
"integrity": "sha512-mKKUkUbhPpQlCOfIuZkvSEgktjPFIsZKRRbC6KWVEMvlzblj3i3asQv5ODsrwt0N3pHAEvjP8KTQPHkp0+6jOg=="
|
||||
},
|
||||
"charcodes": {
|
||||
"version": "0.2.0",
|
||||
"resolved": "https://registry.npmjs.org/charcodes/-/charcodes-0.2.0.tgz",
|
||||
|
|
@ -24227,6 +24463,14 @@
|
|||
"reusify": "^1.0.4"
|
||||
}
|
||||
},
|
||||
"fault": {
|
||||
"version": "1.0.4",
|
||||
"resolved": "https://registry.npmjs.org/fault/-/fault-1.0.4.tgz",
|
||||
"integrity": "sha512-CJ0HCB5tL5fYTEA7ToAq5+kTwd++Borf1/bifxd9iT70QcXr4MRrO3Llf8Ifs70q+SJcGHFtnIE/Nw6giCtECA==",
|
||||
"requires": {
|
||||
"format": "^0.2.0"
|
||||
}
|
||||
},
|
||||
"faye-websocket": {
|
||||
"version": "0.11.4",
|
||||
"resolved": "https://registry.npmjs.org/faye-websocket/-/faye-websocket-0.11.4.tgz",
|
||||
|
|
@ -24462,6 +24706,11 @@
|
|||
"mime-types": "^2.1.12"
|
||||
}
|
||||
},
|
||||
"format": {
|
||||
"version": "0.2.2",
|
||||
"resolved": "https://registry.npmjs.org/format/-/format-0.2.2.tgz",
|
||||
"integrity": "sha1-1hcBB+nv3E7TDJ3DkBbflCtctYs="
|
||||
},
|
||||
"forwarded": {
|
||||
"version": "0.2.0",
|
||||
"resolved": "https://registry.npmjs.org/forwarded/-/forwarded-0.2.0.tgz",
|
||||
|
|
@ -24741,11 +24990,48 @@
|
|||
"has-symbols": "^1.0.2"
|
||||
}
|
||||
},
|
||||
"hast-util-parse-selector": {
|
||||
"version": "2.2.5",
|
||||
"resolved": "https://registry.npmjs.org/hast-util-parse-selector/-/hast-util-parse-selector-2.2.5.tgz",
|
||||
"integrity": "sha512-7j6mrk/qqkSehsM92wQjdIgWM2/BW61u/53G6xmC8i1OmEdKLHbk419QKQUjz6LglWsfqoiHmyMRkP1BGjecNQ=="
|
||||
},
|
||||
"hast-util-whitespace": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/hast-util-whitespace/-/hast-util-whitespace-2.0.0.tgz",
|
||||
"integrity": "sha512-Pkw+xBHuV6xFeJprJe2BBEoDV+AvQySaz3pPDRUs5PNZEMQjpXJJueqrpcHIXxnWTcAGi/UOCgVShlkY6kLoqg=="
|
||||
},
|
||||
"hastscript": {
|
||||
"version": "6.0.0",
|
||||
"resolved": "https://registry.npmjs.org/hastscript/-/hastscript-6.0.0.tgz",
|
||||
"integrity": "sha512-nDM6bvd7lIqDUiYEiu5Sl/+6ReP0BMk/2f4U/Rooccxkj0P5nm+acM5PrGJ/t5I8qPGiqZSE6hVAwZEdZIvP4w==",
|
||||
"requires": {
|
||||
"@types/hast": "^2.0.0",
|
||||
"comma-separated-tokens": "^1.0.0",
|
||||
"hast-util-parse-selector": "^2.0.0",
|
||||
"property-information": "^5.0.0",
|
||||
"space-separated-tokens": "^1.0.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"comma-separated-tokens": {
|
||||
"version": "1.0.8",
|
||||
"resolved": "https://registry.npmjs.org/comma-separated-tokens/-/comma-separated-tokens-1.0.8.tgz",
|
||||
"integrity": "sha512-GHuDRO12Sypu2cV70d1dkA2EUmXHgntrzbpvOB+Qy+49ypNfGgFQIC2fhhXbnyrJRynDCAARsT7Ou0M6hirpfw=="
|
||||
},
|
||||
"property-information": {
|
||||
"version": "5.6.0",
|
||||
"resolved": "https://registry.npmjs.org/property-information/-/property-information-5.6.0.tgz",
|
||||
"integrity": "sha512-YUHSPk+A30YPv+0Qf8i9Mbfe/C0hdPXk1s1jPVToV8pk8BQtpw10ct89Eo7OWkutrwqvT0eicAxlOg3dOAu8JA==",
|
||||
"requires": {
|
||||
"xtend": "^4.0.0"
|
||||
}
|
||||
},
|
||||
"space-separated-tokens": {
|
||||
"version": "1.1.5",
|
||||
"resolved": "https://registry.npmjs.org/space-separated-tokens/-/space-separated-tokens-1.1.5.tgz",
|
||||
"integrity": "sha512-q/JSVd1Lptzhf5bkYm4ob4iWPjx0KiRe3sRFBNrVqbJkFaBm5vbbowy1mymoPNLRa52+oadOhJ+K49wsSeSjTA=="
|
||||
}
|
||||
}
|
||||
},
|
||||
"he": {
|
||||
"version": "1.2.0",
|
||||
"resolved": "https://registry.npmjs.org/he/-/he-1.2.0.tgz",
|
||||
|
|
@ -24756,6 +25042,11 @@
|
|||
"resolved": "https://registry.npmjs.org/hey-listen/-/hey-listen-1.0.8.tgz",
|
||||
"integrity": "sha512-COpmrF2NOg4TBWUJ5UVyaCU2A88wEMkUPK4hNqyCkqHbxT92BbvfjoSozkAIIm6XhicGlJHhFdullInrdhwU8Q=="
|
||||
},
|
||||
"highlight.js": {
|
||||
"version": "10.7.3",
|
||||
"resolved": "https://registry.npmjs.org/highlight.js/-/highlight.js-10.7.3.tgz",
|
||||
"integrity": "sha512-tzcUFauisWKNHaRkN4Wjl/ZA07gENAjFl3J/c480dprkGTg5EQstgaNFqBfUqCq54kZRIEcreTsAgF/m2quD7A=="
|
||||
},
|
||||
"history": {
|
||||
"version": "5.3.0",
|
||||
"resolved": "https://registry.npmjs.org/history/-/history-5.3.0.tgz",
|
||||
|
|
@ -25067,6 +25358,20 @@
|
|||
"resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-2.0.1.tgz",
|
||||
"integrity": "sha512-1qTgH9NG+IIJ4yfKs2e6Pp1bZg8wbDbKHT21HrLIeYBTRLgMYKnMTPAuI3Lcs61nfx5h1xlXnbJtH1kX5/d/ng=="
|
||||
},
|
||||
"is-alphabetical": {
|
||||
"version": "1.0.4",
|
||||
"resolved": "https://registry.npmjs.org/is-alphabetical/-/is-alphabetical-1.0.4.tgz",
|
||||
"integrity": "sha512-DwzsA04LQ10FHTZuL0/grVDk4rFoVH1pjAToYwBrHSxcrBIGQuXrQMtD5U1b0U2XVgKZCTLLP8u2Qxqhy3l2Vg=="
|
||||
},
|
||||
"is-alphanumerical": {
|
||||
"version": "1.0.4",
|
||||
"resolved": "https://registry.npmjs.org/is-alphanumerical/-/is-alphanumerical-1.0.4.tgz",
|
||||
"integrity": "sha512-UzoZUr+XfVz3t3v4KyGEniVL9BDRoQtY7tOyrRybkVNjDFWyo1yhXNGrrBTQxp3ib9BLAWs7k2YKBQsFRkZG9A==",
|
||||
"requires": {
|
||||
"is-alphabetical": "^1.0.0",
|
||||
"is-decimal": "^1.0.0"
|
||||
}
|
||||
},
|
||||
"is-arrayish": {
|
||||
"version": "0.2.1",
|
||||
"resolved": "https://registry.npmjs.org/is-arrayish/-/is-arrayish-0.2.1.tgz",
|
||||
|
|
@ -25123,6 +25428,11 @@
|
|||
"has-tostringtag": "^1.0.0"
|
||||
}
|
||||
},
|
||||
"is-decimal": {
|
||||
"version": "1.0.4",
|
||||
"resolved": "https://registry.npmjs.org/is-decimal/-/is-decimal-1.0.4.tgz",
|
||||
"integrity": "sha512-RGdriMmQQvZ2aqaQq3awNA6dCGtKpiDFcOzrTWrDAT2MiWrKQVPmxLGHl7Y2nNu6led0kEyoX0enY0qXYsv9zw=="
|
||||
},
|
||||
"is-docker": {
|
||||
"version": "2.2.1",
|
||||
"resolved": "https://registry.npmjs.org/is-docker/-/is-docker-2.2.1.tgz",
|
||||
|
|
@ -25151,6 +25461,11 @@
|
|||
"is-extglob": "^2.1.1"
|
||||
}
|
||||
},
|
||||
"is-hexadecimal": {
|
||||
"version": "1.0.4",
|
||||
"resolved": "https://registry.npmjs.org/is-hexadecimal/-/is-hexadecimal-1.0.4.tgz",
|
||||
"integrity": "sha512-gyPJuv83bHMpocVYoqof5VDiZveEoGoFL8m3BXNb2VW8Xs+rz9kqO8LOQ5DH6EsuvilT1ApazU0pyl+ytbPtlw=="
|
||||
},
|
||||
"is-module": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/is-module/-/is-module-1.0.0.tgz",
|
||||
|
|
@ -26867,6 +27182,15 @@
|
|||
"tslib": "^2.0.3"
|
||||
}
|
||||
},
|
||||
"lowlight": {
|
||||
"version": "1.20.0",
|
||||
"resolved": "https://registry.npmjs.org/lowlight/-/lowlight-1.20.0.tgz",
|
||||
"integrity": "sha512-8Ktj+prEb1RoCPkEOrPMYUN/nCggB7qAWe3a7OpMjWQkh3l2RD5wKRQ+o8Q8YuI9RG/xs95waaI/E6ym/7NsTw==",
|
||||
"requires": {
|
||||
"fault": "^1.0.0",
|
||||
"highlight.js": "~10.7.0"
|
||||
}
|
||||
},
|
||||
"lru-cache": {
|
||||
"version": "6.0.0",
|
||||
"resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz",
|
||||
|
|
@ -27624,6 +27948,26 @@
|
|||
"callsites": "^3.0.0"
|
||||
}
|
||||
},
|
||||
"parse-entities": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/parse-entities/-/parse-entities-2.0.0.tgz",
|
||||
"integrity": "sha512-kkywGpCcRYhqQIchaWqZ875wzpS/bMKhz5HnN3p7wveJTkTtyAB/AlnS0f8DFSqYW1T82t6yEAkEcB+A1I3MbQ==",
|
||||
"requires": {
|
||||
"character-entities": "^1.0.0",
|
||||
"character-entities-legacy": "^1.0.0",
|
||||
"character-reference-invalid": "^1.0.0",
|
||||
"is-alphanumerical": "^1.0.0",
|
||||
"is-decimal": "^1.0.0",
|
||||
"is-hexadecimal": "^1.0.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"character-entities": {
|
||||
"version": "1.2.4",
|
||||
"resolved": "https://registry.npmjs.org/character-entities/-/character-entities-1.2.4.tgz",
|
||||
"integrity": "sha512-iBMyeEHxfVnIakwOuDXpVkc54HijNgCyQB2w0VfGQThle6NXn50zU6V/u+LDhxHcDUPojn6Kpga3PTAD8W1bQw=="
|
||||
}
|
||||
}
|
||||
},
|
||||
"parse-json": {
|
||||
"version": "5.2.0",
|
||||
"resolved": "https://registry.npmjs.org/parse-json/-/parse-json-5.2.0.tgz",
|
||||
|
|
@ -28550,6 +28894,11 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"prismjs": {
|
||||
"version": "1.28.0",
|
||||
"resolved": "https://registry.npmjs.org/prismjs/-/prismjs-1.28.0.tgz",
|
||||
"integrity": "sha512-8aaXdYvl1F7iC7Xm1spqSaY/OJBpYW3v+KJ+F17iYxvdc8sfjW194COK5wVhMZX45tGteiBQgdvD/nhxcRwylw=="
|
||||
},
|
||||
"process-nextick-args": {
|
||||
"version": "2.0.1",
|
||||
"resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.1.tgz",
|
||||
|
|
@ -29032,6 +29381,18 @@
|
|||
"tslib": "^2.0.0"
|
||||
}
|
||||
},
|
||||
"react-syntax-highlighter": {
|
||||
"version": "15.5.0",
|
||||
"resolved": "https://registry.npmjs.org/react-syntax-highlighter/-/react-syntax-highlighter-15.5.0.tgz",
|
||||
"integrity": "sha512-+zq2myprEnQmH5yw6Gqc8lD55QHnpKaU8TOcFeC/Lg/MQSs8UknEA0JC4nTZGFAXC2J2Hyj/ijJ7NlabyPi2gg==",
|
||||
"requires": {
|
||||
"@babel/runtime": "^7.3.1",
|
||||
"highlight.js": "^10.4.1",
|
||||
"lowlight": "^1.17.0",
|
||||
"prismjs": "^1.27.0",
|
||||
"refractor": "^3.6.0"
|
||||
}
|
||||
},
|
||||
"readable-stream": {
|
||||
"version": "3.6.0",
|
||||
"resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.0.tgz",
|
||||
|
|
@ -29076,6 +29437,23 @@
|
|||
"@babel/runtime": "^7.9.2"
|
||||
}
|
||||
},
|
||||
"refractor": {
|
||||
"version": "3.6.0",
|
||||
"resolved": "https://registry.npmjs.org/refractor/-/refractor-3.6.0.tgz",
|
||||
"integrity": "sha512-MY9W41IOWxxk31o+YvFCNyNzdkc9M20NoZK5vq6jkv4I/uh2zkWcfudj0Q1fovjUQJrNewS9NMzeTtqPf+n5EA==",
|
||||
"requires": {
|
||||
"hastscript": "^6.0.0",
|
||||
"parse-entities": "^2.0.0",
|
||||
"prismjs": "~1.27.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"prismjs": {
|
||||
"version": "1.27.0",
|
||||
"resolved": "https://registry.npmjs.org/prismjs/-/prismjs-1.27.0.tgz",
|
||||
"integrity": "sha512-t13BGPUlFDR7wRB5kQDG4jjl7XeuH6jbJGt11JHPL96qwsEHNX2+68tFXqc1/k+/jALsbSWJKUOT/hcYAZ5LkA=="
|
||||
}
|
||||
}
|
||||
},
|
||||
"regenerate": {
|
||||
"version": "1.4.2",
|
||||
"resolved": "https://registry.npmjs.org/regenerate/-/regenerate-1.4.2.tgz",
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@
|
|||
"react-responsive-carousel": "^3.2.23",
|
||||
"react-router-dom": "^6.3.0",
|
||||
"react-scripts": "5.0.1",
|
||||
"react-syntax-highlighter": "^15.5.0",
|
||||
"redux": "^4.1.2",
|
||||
"web-vitals": "^2.1.4"
|
||||
},
|
||||
|
|
|
|||
|
|
@ -10,8 +10,9 @@ import Manage from './pages/Manage/index';
|
|||
import Login from './pages/User/Login';
|
||||
import Register from './pages/User/Register';
|
||||
import Navbar from './global/components/Nav/Navbar';
|
||||
import AlertModal from './global/components/Modal/Alert';
|
||||
import AlertModal from './global/components/Notification/Modal';
|
||||
import Footer from './global/components/Footer';
|
||||
import Toast from './global/components/Notification/Toast';
|
||||
|
||||
export const Pages = [
|
||||
{
|
||||
|
|
@ -56,7 +57,7 @@ export const Pages = [
|
|||
},
|
||||
{
|
||||
name: 'Product',
|
||||
path: '/product',
|
||||
path: '/product/:id',
|
||||
icon: null,
|
||||
element: (<Product />),
|
||||
adminOnly: false,
|
||||
|
|
@ -79,6 +80,7 @@ const Routes = ({ user }) => (
|
|||
}
|
||||
</RouterRoutes>
|
||||
<AlertModal />
|
||||
<Toast />
|
||||
<Footer />
|
||||
</BrowserRouter>
|
||||
);
|
||||
|
|
|
|||
37
frontend/src/global/components/Notification/Toast.jsx
Normal file
37
frontend/src/global/components/Notification/Toast.jsx
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
import React from 'react';
|
||||
import { connect } from 'react-redux';
|
||||
import {
|
||||
Alert,
|
||||
AlertIcon,
|
||||
AlertTitle,
|
||||
AlertDescription,
|
||||
} from '@chakra-ui/react';
|
||||
import { clearToast } from '../../toast';
|
||||
|
||||
const Toast = ({
|
||||
open, header, content, status,
|
||||
}) => (open ? (
|
||||
<Alert
|
||||
position="fixed"
|
||||
bottom="1rem"
|
||||
right="1rem"
|
||||
width="unset"
|
||||
maxWidth="75vw"
|
||||
status={status}
|
||||
onClick={clearToast}
|
||||
cursor="pointer"
|
||||
>
|
||||
<AlertIcon />
|
||||
<AlertTitle>{header}</AlertTitle>
|
||||
<AlertDescription>{content}</AlertDescription>
|
||||
</Alert>
|
||||
) : (<div />));
|
||||
|
||||
const mapStateToProps = ({ toast }) => ({
|
||||
open: !!toast,
|
||||
header: toast?.header || null,
|
||||
content: toast?.content || null,
|
||||
status: toast?.status || null,
|
||||
});
|
||||
|
||||
export default connect(mapStateToProps)(Toast);
|
||||
|
|
@ -28,9 +28,6 @@ export const Home = new LocalizedStrings({
|
|||
|
||||
export const Product = new LocalizedStrings({
|
||||
en: {
|
||||
downloadFailedAlert: {
|
||||
header: 'Failed to Get Product Details',
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
|
|
@ -57,6 +54,7 @@ export const Manage = new LocalizedStrings({
|
|||
required: 'This Field is Required',
|
||||
save: 'Save Product',
|
||||
saveChanges: 'Save Changes',
|
||||
delete: 'Delete Product',
|
||||
},
|
||||
},
|
||||
});
|
||||
|
|
|
|||
13
frontend/src/global/toast.js
Normal file
13
frontend/src/global/toast.js
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
import store from '../redux/store';
|
||||
|
||||
export const clearToast = () => {
|
||||
store.dispatch({ type: 'SET_TOAST', data: null });
|
||||
};
|
||||
|
||||
export const setToast = (header, content, status) => {
|
||||
store.dispatch({
|
||||
type: 'SET_TOAST',
|
||||
data: { header, content, status },
|
||||
});
|
||||
setTimeout(clearToast, 5000);
|
||||
};
|
||||
|
|
@ -15,7 +15,7 @@ import { useNavigate } from 'react-router-dom';
|
|||
export default ({ product }) => {
|
||||
const filtered = product.images.filter((x) => x !== null);
|
||||
const images = filtered.length ? filtered : ['https://dv2ls.com/f/PpMcVb8gN'];
|
||||
const nav = useNavigate();
|
||||
const navigate = useNavigate();
|
||||
|
||||
return (
|
||||
<Box
|
||||
|
|
@ -29,7 +29,7 @@ export default ({ product }) => {
|
|||
rounded="lg"
|
||||
pos="relative"
|
||||
zIndex={1}
|
||||
onClick={() => nav(`/product?productId=${product._id}`, { replace: true })}
|
||||
onClick={() => navigate(`/product/${product._id}`, { replace: true })}
|
||||
_hover={{
|
||||
transition: 'all .3s ease',
|
||||
boxShadow: 'var(--chakra-shadows-2xl)',
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import React, { useState } from 'react';
|
||||
import {
|
||||
Box, Button, FormControl, FormLabel, Grid, GridItem, Heading,
|
||||
Box, Button, ButtonGroup, FormControl, FormLabel, Grid, GridItem, Heading,
|
||||
InputGroup, InputLeftAddon, Text, Textarea, useColorModeValue,
|
||||
} from '@chakra-ui/react';
|
||||
import CurrencyInput from 'react-currency-input-field';
|
||||
|
|
@ -13,6 +13,7 @@ import store from '../../../../redux/store';
|
|||
import FileUpload from '../FileUpload';
|
||||
import DeletableImage from '../DeletableImage';
|
||||
import { getAuthHeaders, uploadImage } from '../../../../global/api';
|
||||
import { setToast } from '../../../../global/toast';
|
||||
|
||||
const InputGroupStyle = {
|
||||
marginTop: '1rem',
|
||||
|
|
@ -49,18 +50,32 @@ export default ({ product, closeModal }) => {
|
|||
|
||||
const data = await resp.json();
|
||||
if (resp.ok) {
|
||||
store.dispatch({ type: 'SET_ALERT', data: { header: 'Item Updated Successfully!', content: 'Your Changes have Been Saved and Will Be Reflected on the Management Page' } });
|
||||
setToast('Product Updated Successfully!', '', 'success');
|
||||
setLoading(false);
|
||||
return true;
|
||||
}
|
||||
store.dispatch({ type: 'SET_ALERT', data: { header: 'Failed to Add Item', content: JSON.stringify(data) } });
|
||||
setToast('Failed to Edit Product', data?.error || '', 'error');
|
||||
} catch (ex) {
|
||||
store.dispatch({ type: 'SET_ALERT', data: { header: 'Failed to Edit Item in Catch Block', content: ex } });
|
||||
setToast('Failed to Edit Product', ex || '', 'error');
|
||||
}
|
||||
setLoading(false);
|
||||
return false;
|
||||
};
|
||||
|
||||
const del = async () => {
|
||||
// eslint-disable-next-line no-alert
|
||||
if (window.confirm('Are you sure you want to delete this Product?')) {
|
||||
// eslint-disable-next-line no-underscore-dangle
|
||||
const resp = await fetch(`/api/v1/products/${product._id}`, {
|
||||
method: 'DELETE',
|
||||
headers: getAuthHeaders(),
|
||||
});
|
||||
setToast(`Deleted ${product.name} Successfully`, '', 'info');
|
||||
return resp.ok;
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
return (
|
||||
<div>
|
||||
<Heading textAlign="center" marginBottom="1rem">
|
||||
|
|
@ -203,17 +218,25 @@ export default ({ product, closeModal }) => {
|
|||
))}
|
||||
</Grid>
|
||||
|
||||
<Button
|
||||
display="block"
|
||||
mx="auto"
|
||||
mt={4}
|
||||
colorScheme="green"
|
||||
isLoading={loading}
|
||||
type="submit"
|
||||
onClick={() => save().then((x) => { if (x) closeModal(); })}
|
||||
>
|
||||
{i18n.labels.saveChanges}
|
||||
</Button>
|
||||
<ButtonGroup textAlign="center" display="block" mx="auto" mt={4}>
|
||||
<Button
|
||||
colorScheme="green"
|
||||
isLoading={loading}
|
||||
type="submit"
|
||||
onClick={() => save().then((x) => { if (x) closeModal(); })}
|
||||
>
|
||||
{i18n.labels.saveChanges}
|
||||
</Button>
|
||||
|
||||
<Button
|
||||
colorScheme="red"
|
||||
type="button"
|
||||
onClick={() => del().then((x) => { if (x) closeModal(); })}
|
||||
>
|
||||
{i18n.labels.delete}
|
||||
</Button>
|
||||
</ButtonGroup>
|
||||
|
||||
</Box>
|
||||
</div>
|
||||
);
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ import { Manage as i18n } from '../../../../global/i18n';
|
|||
import store from '../../../../redux/store';
|
||||
import FileUpload from '../FileUpload';
|
||||
import { getAuthHeaders, uploadImage } from '../../../../global/api';
|
||||
import { setToast } from '../../../../global/toast';
|
||||
|
||||
const InputGroupStyle = {
|
||||
marginTop: '1rem',
|
||||
|
|
@ -46,13 +47,13 @@ export default ({ closeModal }) => {
|
|||
|
||||
const data = await resp.json();
|
||||
if (resp.ok) {
|
||||
store.dispatch({ type: 'SET_ALERT', data: { header: 'Added New Product!', content: 'Your New Product has Been Saved and Will Be Reflected on the Management Page' } });
|
||||
setToast('Added New Product Successfully!', '', 'success');
|
||||
setLoading(false);
|
||||
return true;
|
||||
}
|
||||
store.dispatch({ type: 'SET_ALERT', data: { header: 'Failed to Add Product', content: JSON.stringify(data) } });
|
||||
setToast('Failed to Add Product', data?.error || '', 'error');
|
||||
} catch (ex) {
|
||||
store.dispatch({ type: 'SET_ALERT', data: { header: 'Failed to Add Product', content: ex } });
|
||||
setToast('Failed to Add Product', ex || '', 'error');
|
||||
}
|
||||
setLoading(false);
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
import React, { useState, useEffect } from 'react';
|
||||
import {
|
||||
Table, Thead, Tbody, Tr, Th, Td, TableContainer, Box, Button, Flex,
|
||||
Table, Thead, Tbody, Tr, Th, Td, TableContainer, Box, Button, Flex, Heading,
|
||||
} from '@chakra-ui/react';
|
||||
import { BiSearchAlt2 } from 'react-icons/bi';
|
||||
import { BiSearchAlt2, BiPlus } from 'react-icons/bi';
|
||||
import { Manage as i18n } from '../../global/i18n';
|
||||
import Loading from '../../global/components/Loading';
|
||||
import store from '../../redux/store';
|
||||
|
|
@ -11,6 +11,7 @@ import DynamicModal from './components/DynamicModal';
|
|||
import New from './components/modal/New';
|
||||
import Edit from './components/modal/Edit';
|
||||
import search from '../../global/search';
|
||||
import IconTextDuo from '../../global/components/IconTextDuo';
|
||||
|
||||
const init = async (setProductsPt, setLoadedPt, setAllProductsPt) => {
|
||||
const resp = await fetch('/api/v1/products');
|
||||
|
|
@ -45,8 +46,15 @@ export default () => {
|
|||
|
||||
return (
|
||||
<div>
|
||||
<Heading my={3} textAlign="center">
|
||||
OpenCommerce Store
|
||||
</Heading>
|
||||
<Heading size="md" my={3} textAlign="center">
|
||||
Product Management
|
||||
</Heading>
|
||||
|
||||
<Flex justifyContent="center" alignItems="center">
|
||||
<Box maxW="400px" m="auto">
|
||||
<Box>
|
||||
<InlineLabelInput
|
||||
propChangeEvt={(evt) => setProducts(search(evt.target.value, allProducts))}
|
||||
propKeyPressEvt={() => {}}
|
||||
|
|
@ -61,7 +69,7 @@ export default () => {
|
|||
</Box>
|
||||
|
||||
<Button backgroundColor="green.400" onClick={() => setNewModal(true)}>
|
||||
Create
|
||||
<IconTextDuo text="Create" icon={(<BiPlus />)} />
|
||||
</Button>
|
||||
</Flex>
|
||||
|
||||
|
|
|
|||
27
frontend/src/pages/Product/components/Code.jsx
Normal file
27
frontend/src/pages/Product/components/Code.jsx
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
import { Code, useColorMode } from '@chakra-ui/react';
|
||||
import React from 'react';
|
||||
import SyntaxHighlighter from 'react-syntax-highlighter';
|
||||
import atomOneDark from 'react-syntax-highlighter/dist/cjs/styles/hljs/atom-one-dark';
|
||||
import atomOneLight from 'react-syntax-highlighter/dist/cjs/styles/hljs/atom-one-light';
|
||||
|
||||
export default ({
|
||||
inline, className, children, props,
|
||||
}) => {
|
||||
const { colorMode } = useColorMode();
|
||||
const match = /language-(\w+)/.exec(className || '');
|
||||
|
||||
return !inline && match && match.length ? (
|
||||
<SyntaxHighlighter
|
||||
language={match[1]}
|
||||
PreTag="div"
|
||||
style={colorMode === 'dark' ? atomOneDark : atomOneLight}
|
||||
{...props}
|
||||
>
|
||||
{children}
|
||||
</SyntaxHighlighter>
|
||||
) : (
|
||||
<Code {...props}>
|
||||
{children}
|
||||
</Code>
|
||||
);
|
||||
};
|
||||
|
|
@ -1,42 +1,41 @@
|
|||
import React, { useEffect, useState } from 'react';
|
||||
|
||||
import {
|
||||
Box, Button, Code, Heading,
|
||||
} from '@chakra-ui/react';
|
||||
import { Box, Button, Heading } from '@chakra-ui/react';
|
||||
import ReactMarkdown from 'react-markdown';
|
||||
import { MdOutlineArrowBackIosNew } from 'react-icons/md';
|
||||
import { useNavigate, useParams } from 'react-router-dom';
|
||||
import Loading from '../../global/components/Loading';
|
||||
import { Product as i18n } from '../../global/i18n';
|
||||
import store from '../../redux/store';
|
||||
import Carousel from './components/Carousel';
|
||||
import Code from './components/Code';
|
||||
|
||||
export default () => {
|
||||
const [product, setProduct] = useState(null);
|
||||
const [loaded, setLoaded] = useState(false);
|
||||
const [errored, setErrored] = useState(false);
|
||||
|
||||
const navigate = useNavigate();
|
||||
const params = useParams();
|
||||
|
||||
useEffect(() => {
|
||||
if (loaded) return () => {};
|
||||
|
||||
const _ = async (setProductPt, setLoadedPt) => {
|
||||
const params = new URLSearchParams(window.location.search);
|
||||
if (!params.has('productId')) {
|
||||
store.dispatch({ type: 'SET_ALERT', data: { header: i18n.downloadFailedAlert.header, content: 'URL is invalid as it\'s missing the Product ID' } });
|
||||
setErrored(true);
|
||||
return;
|
||||
}
|
||||
|
||||
const productId = params.get('productId');
|
||||
const _ = async (setProductPt, setLoadedPt, setErroredPt) => {
|
||||
// const productId = params.get('productId');
|
||||
const productId = params.id;
|
||||
const resp = await fetch(`/api/v1/products/${productId}`);
|
||||
const data = await resp.json();
|
||||
if (resp.ok) {
|
||||
setProductPt(data);
|
||||
} else {
|
||||
store.dispatch({ type: 'SET_ALERT', data: { header: i18n.downloadFailedAlert.header, content: JSON.stringify(data.error) } });
|
||||
setErroredPt(true);
|
||||
}
|
||||
setLoadedPt(true);
|
||||
};
|
||||
|
||||
_(setProduct, setLoaded);
|
||||
_(setProduct, setLoaded, setErrored);
|
||||
return () => {};
|
||||
}, [setProduct, loaded, setLoaded]);
|
||||
|
||||
|
|
@ -50,6 +49,9 @@ export default () => {
|
|||
|
||||
return (
|
||||
<div style={{ maxWidth: '768px', margin: 'auto' }}>
|
||||
<Button colorScheme="purple" onClick={() => navigate('/', { replace: true })}>
|
||||
<MdOutlineArrowBackIosNew />
|
||||
</Button>
|
||||
<Heading textAlign="center" mb={4}>{product.name}</Heading>
|
||||
{(product.images && product.images.length) ? (
|
||||
<Carousel photos={product.images} />
|
||||
|
|
@ -78,14 +80,13 @@ export default () => {
|
|||
<div>
|
||||
<Heading my={3}>Description</Heading>
|
||||
<Heading my={3} size="md">{product.name}</Heading>
|
||||
<ReactMarkdown>{product.description || ''}</ReactMarkdown>
|
||||
<ReactMarkdown
|
||||
components={{ code: Code }}
|
||||
skipHtml
|
||||
>
|
||||
{product.description || ''}
|
||||
</ReactMarkdown>
|
||||
</div>
|
||||
|
||||
<hr style={{ margin: '2rem auto' }} />
|
||||
|
||||
<Code colorScheme="cyan">
|
||||
{JSON.stringify(product, null, 2)}
|
||||
</Code>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ import store from '../../redux/store';
|
|||
import StandardInput from '../../global/components/FormControl/StandardInput';
|
||||
import IconTextDuo from '../../global/components/IconTextDuo';
|
||||
import { Login as i18n } from '../../global/i18n';
|
||||
import { setToast } from '../../global/toast';
|
||||
|
||||
export default () => {
|
||||
const [state, setState] = useState({ email: '', password: '' });
|
||||
|
|
@ -28,7 +29,7 @@ export default () => {
|
|||
|
||||
if (resp.ok) {
|
||||
store.dispatch({ type: 'SET_USER_TOKEN', token: data.token });
|
||||
store.dispatch({ type: 'SET_ALERT', data: { header: 'Logged In!', content: '' } });
|
||||
setToast(`Welcome ${data.first}!`, '', 'info');
|
||||
setTimeout(() => store.dispatch({ type: 'SET_ALERT', data: null }), 1000);
|
||||
navigate('/', { replace: true });
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
import { setToast } from '../global/toast';
|
||||
import store from './store';
|
||||
|
||||
const decodeAndDispatch = async (token) => {
|
||||
|
|
@ -9,6 +10,7 @@ const decodeAndDispatch = async (token) => {
|
|||
|
||||
if (resp.ok) {
|
||||
store.dispatch({ type: 'SET_USER', data: { ...data, token } });
|
||||
setToast(`Welcome ${data.email}!`, '', 'info');
|
||||
} else {
|
||||
if (resp.status === 410 && window.localStorage.getItem('auth-token')) {
|
||||
window.localStorage.removeItem('auth-token');
|
||||
|
|
@ -21,9 +23,9 @@ const decodeAndDispatch = async (token) => {
|
|||
};
|
||||
|
||||
export const decodeFromToken = async (token) => {
|
||||
decodeAndDispatch(token);
|
||||
await decodeAndDispatch(token);
|
||||
};
|
||||
|
||||
export const decodeFromLocalStorage = async () => {
|
||||
decodeAndDispatch(window.localStorage.getItem('auth-token'));
|
||||
await decodeAndDispatch(window.localStorage.getItem('auth-token'));
|
||||
};
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ const defaultState = {
|
|||
i18n: null,
|
||||
langs: null,
|
||||
alert: null,
|
||||
toast: null,
|
||||
};
|
||||
|
||||
// eslint-disable-next-line default-param-last
|
||||
|
|
@ -43,6 +44,11 @@ export default (state = defaultState, action) => {
|
|||
...state,
|
||||
alert: action.data || null,
|
||||
};
|
||||
case 'SET_TOAST':
|
||||
return {
|
||||
...state,
|
||||
toast: action.data || null,
|
||||
};
|
||||
default:
|
||||
return state;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue