feat: create MVP database table, adjust api
This commit is contained in:
@@ -52,8 +52,8 @@ export function Chemistry() {
|
||||
const [dialog, setDialog] = useState("dialog");
|
||||
|
||||
async function handleSubmit() {
|
||||
const dialog = document.querySelector("dialog");
|
||||
dialog?.showModal();
|
||||
const dialog = document.querySelector("dialog[id='ChemistryDialog']");
|
||||
(dialog as HTMLDialogElement).showModal();
|
||||
if (user.length < 1) {
|
||||
setDialog("who are you?");
|
||||
} else {
|
||||
@@ -148,6 +148,7 @@ export function Chemistry() {
|
||||
|
||||
<button onClick={() => handleSubmit()}>submit</button>
|
||||
<dialog
|
||||
id="ChemistryDialog"
|
||||
onClick={(event) => {
|
||||
event.currentTarget.close();
|
||||
}}
|
||||
@@ -167,16 +168,16 @@ export function MVP() {
|
||||
const [dialog, setDialog] = useState("dialog");
|
||||
|
||||
async function handleSubmit() {
|
||||
const dialog = document.querySelector("dialog");
|
||||
dialog?.showModal();
|
||||
const dialog = document.querySelector("dialog[id='MVPDialog']");
|
||||
(dialog as HTMLDialogElement).showModal();
|
||||
if (user.length < 1) {
|
||||
setDialog("who are you?");
|
||||
} else {
|
||||
setDialog("sending...");
|
||||
let _user = user.map(({ name }) => name)[0];
|
||||
let mvps = rankedPlayers.map(({ name }) => name);
|
||||
const data = { user: _user, rankedPlayers: mvps };
|
||||
const response = await api("mvp", data);
|
||||
const data = { user: _user, mvps: mvps };
|
||||
const response = await api("mvps", data);
|
||||
response.ok ? setDialog("success!") : setDialog("try sending again");
|
||||
}
|
||||
}
|
||||
@@ -258,6 +259,7 @@ export function MVP() {
|
||||
|
||||
<button onClick={() => handleSubmit()}>submit</button>
|
||||
<dialog
|
||||
id="MVPDialog"
|
||||
onClick={(event) => {
|
||||
event.currentTarget.close();
|
||||
}}
|
||||
|
Reference in New Issue
Block a user