diff --git a/Commands/pushDefaultValue.cjs b/Commands/pushDefaultValue.cjs new file mode 100644 index 0000000..cff2e96 --- /dev/null +++ b/Commands/pushDefaultValue.cjs @@ -0,0 +1,57 @@ +const { BaseCommand } = require('kurami'); +const { getFirestore, collection, addDoc } = require('firebase/firestore'); +const chartData = require('./../charts.json'); +const scoreData = require('../scores.cjs'); +const { initializeApp } = require("firebase/app"); + +class pushDefaultValue extends BaseCommand { + constructor() { + super({ + name: 'load:default:data', + description: 'Push some default charts and scores', + }); + } + + async run() { + const app = initializeApp({ + // firebase config here + }); + + console.log('Pushing default data...') + console.log('Pushing default charts...') + await this.pushDefaultCharts(); + console.log('Pushing default scores...') + await this.pushDefaultScores(); + console.log('Done!') + } + + async pushDefaultCharts() { + // push chartData content to firestore + const db = getFirestore(); + const chartsRef = collection(db, 'Chart'); + for (let i = 0; i < chartData.length; i++) { + const chart = chartData[i]; + await addDoc(chartsRef, chart).then((docRef) => { + console.log("Document written with ID: ", docRef.id); + }).catch((error) => { + console.error("Error adding document: ", error); + }); + } + } + + async pushDefaultScores() { + // push scoreData content to firestore + const db = getFirestore(); + const scoresRef = collection(db, 'Score'); + for (let i = 0; i < scoreData.length; i++) { + const score = scoreData[i]; + await addDoc(scoresRef, score).then((docRef) => { + console.log("Document written with ID: ", docRef.id); + }).catch((error) => { + console.error("Error adding document: ", error); + }); + } + } +} + +module.exports = pushDefaultValue; \ No newline at end of file diff --git a/src/charts.json b/charts.json similarity index 86% rename from src/charts.json rename to charts.json index 3e7b687..5443d3a 100644 --- a/src/charts.json +++ b/charts.json @@ -1,8 +1,9 @@ [ { + "id": "axe611acu8", "name" : "Axeria", "artist": "AcuticNotes", - "category": "Original", + "category": "original", "difficulty" : [ { "Easy": "4", @@ -15,9 +16,10 @@ "imageCover": "https://silentblue.remywiki.com/images/d/d8/Axeria.png" }, { + "id": "our1110t+p8", "name" : "Our Wrenaly", "artist": "t+pazolite", - "category": "Original", + "category": "original", "difficulty" : [ { "Easy": "4", @@ -30,9 +32,10 @@ "imageCover": "https://silentblue.remywiki.com/images/0/05/Our_Wrenally.png" }, { + "id": "mil57mil4", "name" : "Milk", "artist": "モリモリあつし", - "category": "GAME & VARIETY", + "category": "game", "difficulty" : [ { "Easy": "1", @@ -45,9 +48,10 @@ "imageCover": "https://silentblue.remywiki.com/images/e/eb/MilK.png" }, { + "id": "pandora_paradoxxx", "name" : "Pandora Paradoxxx", "artist": "Sakuzyo", - "category": "Original", + "category": "original", "difficulty" : [ { "Easy": "6", diff --git a/index.html b/index.html index 79c4701..04dd590 100644 --- a/index.html +++ b/index.html @@ -4,7 +4,7 @@ - Vite + React + MaiScore
diff --git a/kurami.json b/kurami.json new file mode 100644 index 0000000..4667b8a --- /dev/null +++ b/kurami.json @@ -0,0 +1,3 @@ +{ + "commandsPath": "./Commands" +} \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 1fbadc6..09d2fb0 100644 --- a/package-lock.json +++ b/package-lock.json @@ -12,6 +12,7 @@ "@heroicons/react": "^2.0.16", "@tailwindcss/forms": "^0.5.3", "firebase": "^9.18.0", + "kurami": "^1.0.1", "react": "^18.2.0", "react-dom": "^18.2.0", "react-router-dom": "^6.9.0" @@ -2016,6 +2017,11 @@ "url": "https://www.patreon.com/infusion" } }, + "node_modules/fs": { + "version": "0.0.1-security", + "resolved": "https://registry.npmjs.org/fs/-/fs-0.0.1-security.tgz", + "integrity": "sha512-3XY9e1pP0CVEUCdj5BmfIZxRBTSDycnbqhIOGec9QYtmVH2fbLpj86CFWkrNOkt/Fvty4KZG5lTglL9j/gJ87w==" + }, "node_modules/fsevents": { "version": "2.3.2", "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz", @@ -2101,6 +2107,11 @@ "resolved": "https://registry.npmjs.org/idb/-/idb-7.0.1.tgz", "integrity": "sha512-UUxlE7vGWK5RfB/fDwEGgRf84DY/ieqNha6msMV99UsEMQhJ1RwbCd8AYBj3QMgnE3VZnfQvm4oKVCJTYlqIgg==" }, + "node_modules/inherits": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", + "integrity": "sha512-x00IRNXNy63jwGkJmzPigoySHbaqpNuzKbBOmzK+g2OdZpQ9w+sxCN+VSB3ja7IAge2OP2qpfxTjeNcyjmW1uw==" + }, "node_modules/is-binary-path": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/is-binary-path/-/is-binary-path-2.1.0.tgz", @@ -2187,6 +2198,28 @@ "node": ">=6" } }, + "node_modules/kurami": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/kurami/-/kurami-1.0.1.tgz", + "integrity": "sha512-cgDIGJRrTzmOvYvfdOr4q14PGJdH12Ht+vlznnm2LB/RI4Qwi3dtgy7+130BuCWfdiuzpXbi0dXHMd0b9vcoVA==", + "funding": [ + { + "type": "individual", + "url": "https://www.buymeacoffee.com/nesmon" + }, + { + "type": "individual", + "url": "https://ko-fi.com/nesmon" + } + ], + "dependencies": { + "fs": "^0.0.1-security", + "path": "^0.12.7" + }, + "bin": { + "kurami": "bin/kurami.js" + } + }, "node_modules/lilconfig": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/lilconfig/-/lilconfig-2.1.0.tgz", @@ -2340,6 +2373,15 @@ "node": ">= 6" } }, + "node_modules/path": { + "version": "0.12.7", + "resolved": "https://registry.npmjs.org/path/-/path-0.12.7.tgz", + "integrity": "sha512-aXXC6s+1w7otVF9UletFkFcDsJeO7lSZBPUQhtb5O0xJe8LtYhj/GxldoL09bBj9+ZmE2hNoHqQSFMN5fikh4Q==", + "dependencies": { + "process": "^0.11.1", + "util": "^0.10.3" + } + }, "node_modules/path-parse": { "version": "1.0.7", "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.7.tgz", @@ -2489,6 +2531,14 @@ "resolved": "https://registry.npmjs.org/postcss-value-parser/-/postcss-value-parser-4.2.0.tgz", "integrity": "sha512-1NNCs6uurfkVbeXG4S8JFT9t19m45ICnif8zWLd5oPSZ50QnwMfK+H3jv408d4jw/7Bttv5axS5IiHoLaVNHeQ==" }, + "node_modules/process": { + "version": "0.11.10", + "resolved": "https://registry.npmjs.org/process/-/process-0.11.10.tgz", + "integrity": "sha512-cdGef/drWFoydD1JsMzuFf8100nZl+GT+yacc2bEced5f9Rjk4z+WtFUTBu9PhOi9j/jfmBPu0mMEY4wIdAF8A==", + "engines": { + "node": ">= 0.6.0" + } + }, "node_modules/protobufjs": { "version": "6.11.3", "resolved": "https://registry.npmjs.org/protobufjs/-/protobufjs-6.11.3.tgz", @@ -2888,6 +2938,14 @@ "browserslist": ">= 4.21.0" } }, + "node_modules/util": { + "version": "0.10.4", + "resolved": "https://registry.npmjs.org/util/-/util-0.10.4.tgz", + "integrity": "sha512-0Pm9hTQ3se5ll1XihRic3FDIku70C+iHUdT/W926rSgHV5QgXsYbKZN8MSC3tJtSkhuROzvsQjAaFENRXr+19A==", + "dependencies": { + "inherits": "2.0.3" + } + }, "node_modules/util-deprecate": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", @@ -4512,6 +4570,11 @@ "integrity": "sha512-MhLuK+2gUcnZe8ZHlaaINnQLl0xRIGRfcGk2yl8xoQAfHrSsL3rYu6FCmBdkdbhc9EPlwyGHewaRsvwRMJtAlA==", "dev": true }, + "fs": { + "version": "0.0.1-security", + "resolved": "https://registry.npmjs.org/fs/-/fs-0.0.1-security.tgz", + "integrity": "sha512-3XY9e1pP0CVEUCdj5BmfIZxRBTSDycnbqhIOGec9QYtmVH2fbLpj86CFWkrNOkt/Fvty4KZG5lTglL9j/gJ87w==" + }, "fsevents": { "version": "2.3.2", "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz", @@ -4572,6 +4635,11 @@ "resolved": "https://registry.npmjs.org/idb/-/idb-7.0.1.tgz", "integrity": "sha512-UUxlE7vGWK5RfB/fDwEGgRf84DY/ieqNha6msMV99UsEMQhJ1RwbCd8AYBj3QMgnE3VZnfQvm4oKVCJTYlqIgg==" }, + "inherits": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", + "integrity": "sha512-x00IRNXNy63jwGkJmzPigoySHbaqpNuzKbBOmzK+g2OdZpQ9w+sxCN+VSB3ja7IAge2OP2qpfxTjeNcyjmW1uw==" + }, "is-binary-path": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/is-binary-path/-/is-binary-path-2.1.0.tgz", @@ -4628,6 +4696,15 @@ "integrity": "sha512-XmOWe7eyHYH14cLdVPoyg+GOH3rYX++KpzrylJwSW98t3Nk+U8XOl8FWKOgwtzdb8lXGf6zYwDUzeHMWfxasyg==", "dev": true }, + "kurami": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/kurami/-/kurami-1.0.1.tgz", + "integrity": "sha512-cgDIGJRrTzmOvYvfdOr4q14PGJdH12Ht+vlznnm2LB/RI4Qwi3dtgy7+130BuCWfdiuzpXbi0dXHMd0b9vcoVA==", + "requires": { + "fs": "^0.0.1-security", + "path": "^0.12.7" + } + }, "lilconfig": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/lilconfig/-/lilconfig-2.1.0.tgz", @@ -4734,6 +4811,15 @@ "resolved": "https://registry.npmjs.org/object-hash/-/object-hash-3.0.0.tgz", "integrity": "sha512-RSn9F68PjH9HqtltsSnqYC1XXoWe9Bju5+213R98cNGttag9q9yAOTzdbsqvIa7aNm5WffBZFpWYr2aWrklWAw==" }, + "path": { + "version": "0.12.7", + "resolved": "https://registry.npmjs.org/path/-/path-0.12.7.tgz", + "integrity": "sha512-aXXC6s+1w7otVF9UletFkFcDsJeO7lSZBPUQhtb5O0xJe8LtYhj/GxldoL09bBj9+ZmE2hNoHqQSFMN5fikh4Q==", + "requires": { + "process": "^0.11.1", + "util": "^0.10.3" + } + }, "path-parse": { "version": "1.0.7", "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.7.tgz", @@ -4813,6 +4899,11 @@ "resolved": "https://registry.npmjs.org/postcss-value-parser/-/postcss-value-parser-4.2.0.tgz", "integrity": "sha512-1NNCs6uurfkVbeXG4S8JFT9t19m45ICnif8zWLd5oPSZ50QnwMfK+H3jv408d4jw/7Bttv5axS5IiHoLaVNHeQ==" }, + "process": { + "version": "0.11.10", + "resolved": "https://registry.npmjs.org/process/-/process-0.11.10.tgz", + "integrity": "sha512-cdGef/drWFoydD1JsMzuFf8100nZl+GT+yacc2bEced5f9Rjk4z+WtFUTBu9PhOi9j/jfmBPu0mMEY4wIdAF8A==" + }, "protobufjs": { "version": "6.11.3", "resolved": "https://registry.npmjs.org/protobufjs/-/protobufjs-6.11.3.tgz", @@ -5063,6 +5154,14 @@ "picocolors": "^1.0.0" } }, + "util": { + "version": "0.10.4", + "resolved": "https://registry.npmjs.org/util/-/util-0.10.4.tgz", + "integrity": "sha512-0Pm9hTQ3se5ll1XihRic3FDIku70C+iHUdT/W926rSgHV5QgXsYbKZN8MSC3tJtSkhuROzvsQjAaFENRXr+19A==", + "requires": { + "inherits": "2.0.3" + } + }, "util-deprecate": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", diff --git a/package.json b/package.json index 479881a..d9a44ed 100644 --- a/package.json +++ b/package.json @@ -6,13 +6,15 @@ "scripts": { "dev": "vite", "build": "vite build", - "preview": "vite preview" + "preview": "vite preview", + "kurami": "kurami" }, "dependencies": { "@headlessui/react": "^1.7.13", "@heroicons/react": "^2.0.16", "@tailwindcss/forms": "^0.5.3", "firebase": "^9.18.0", + "kurami": "^1.0.1", "react": "^18.2.0", "react-dom": "^18.2.0", "react-router-dom": "^6.9.0" diff --git a/scores.cjs b/scores.cjs new file mode 100644 index 0000000..5500936 --- /dev/null +++ b/scores.cjs @@ -0,0 +1,67 @@ +const scores = [ + { + "chartId": "axe611acu8", + "difficulty": "Master", + "rank": "A", + "pseudo": "Nenes", + "score": "21234", + "accuracy": "87.34", + "date": new Date(), + }, + { + "chartId": "axe611acu8", + "difficulty": "Master", + "rank": "A", + "pseudo": "Megumi", + "score": "21224", + "accuracy": "84.34", + "date": new Date(), + }, + { + "chartId": "our1110t+p8", + "difficulty": "Expert", + "rank": "A", + "pseudo": "MrDuck", + "score": "2123", + "accuracy": "80.34", + "date": new Date(), + }, + { + "chartId": "mil57mil4", + "difficulty": "Expert", + "rank": "A", + "pseudo": "Nenes", + "score": "21234", + "accuracy": "87.34", + "date": new Date(), + }, + { + "chartId": "axe611acu8", + "difficulty": "Advance", + "rank": "A", + "pseudo": "Megumi", + "score": "21224", + "accuracy": "84.34", + "date": new Date(), + }, + { + "chartId": "mil57mil4", + "difficulty": "Expert", + "rank": "A", + "pseudo": "MrDuck", + "score": "2123", + "accuracy": "80.34", + "date": new Date(), + }, + { + "chartId": "pandora_paradoxxx", + "difficulty": "Expert", + "rank": "S", + "pseudo": "Nenes", + "score": "21233", + "accuracy": "98,03", + "date": new Date(), + } +] + +module.exports = scores; \ No newline at end of file diff --git a/src/Route/ChartScore/ChartScore.jsx b/src/Route/ChartScore/ChartScore.jsx index db2f63f..3023252 100644 --- a/src/Route/ChartScore/ChartScore.jsx +++ b/src/Route/ChartScore/ChartScore.jsx @@ -8,6 +8,7 @@ function Score() { const [chart, setChart] = useState([]); const [scores, setScores] = useState([]); + const [selectedDifficulty, setSelectedDifficulty] = useState("Easy"); const getChart = async () => { const db = getFirestore(); @@ -25,6 +26,7 @@ function Score() { const scores = snapshot.docs.map(doc => doc.data()); const score = scores.filter(item => item.chartId === chartId && item.difficulty === difficulty); score.sort((a, b) => b.score - a.score); + setSelectedDifficulty(difficulty); setScores(score); } @@ -42,7 +44,9 @@ function Score() { fetchData(); }, []); - console.log(scores) + function classNames(...classes) { + return classes.filter(Boolean).join(' ') + } const getCategory = () => { switch (chart.category) { @@ -76,12 +80,30 @@ function Score() { {chart.difficulty && Array.isArray(chart.difficulty) && chart.difficulty.map((item, index) => { return ( ) })} @@ -100,7 +122,7 @@ function Score() {
-
+
diff --git a/src/Route/Charts/Charts.jsx b/src/Route/Charts/Charts.jsx index 7c1a478..c702d42 100644 --- a/src/Route/Charts/Charts.jsx +++ b/src/Route/Charts/Charts.jsx @@ -40,7 +40,7 @@ function Charts() { return (
-
+