🚀 report error in demo
This commit is contained in:
@@ -16,6 +16,7 @@ export const getBestRoute = (grid0: Grid, snake0: Snake) => {
|
|||||||
const chunk = pruneLayer(grid, color, snakeN);
|
const chunk = pruneLayer(grid, color, snakeN);
|
||||||
const c = cleanLayer(gridN, chain[0], chunk);
|
const c = cleanLayer(gridN, chain[0], chunk);
|
||||||
if (c) chain.unshift(...c);
|
if (c) chain.unshift(...c);
|
||||||
|
else throw new Error("some cells are unreachable");
|
||||||
}
|
}
|
||||||
|
|
||||||
return chain.reverse().slice(1);
|
return chain.reverse().slice(1);
|
||||||
|
|||||||
@@ -12,7 +12,11 @@ import {
|
|||||||
import { userContributionToGrid } from "../action/userContributionToGrid";
|
import { userContributionToGrid } from "../action/userContributionToGrid";
|
||||||
import { snake3 } from "@snk/types/__fixtures__/snake";
|
import { snake3 } from "@snk/types/__fixtures__/snake";
|
||||||
|
|
||||||
const createForm = ({ onSubmit }: { onSubmit: (s: string) => void }) => {
|
const createForm = ({
|
||||||
|
onSubmit,
|
||||||
|
}: {
|
||||||
|
onSubmit: (s: string) => Promise<void>;
|
||||||
|
}) => {
|
||||||
const form = document.createElement("form");
|
const form = document.createElement("form");
|
||||||
form.style.position = "relative";
|
form.style.position = "relative";
|
||||||
form.style.display = "flex";
|
form.style.display = "flex";
|
||||||
@@ -26,7 +30,6 @@ const createForm = ({ onSubmit }: { onSubmit: (s: string) => void }) => {
|
|||||||
submit.innerText = "ok";
|
submit.innerText = "ok";
|
||||||
|
|
||||||
const label = document.createElement("label");
|
const label = document.createElement("label");
|
||||||
label.innerText = "loading ...";
|
|
||||||
label.style.position = "absolute";
|
label.style.position = "absolute";
|
||||||
label.style.textAlign = "center";
|
label.style.textAlign = "center";
|
||||||
label.style.top = "60px";
|
label.style.top = "60px";
|
||||||
@@ -61,11 +64,15 @@ const createForm = ({ onSubmit }: { onSubmit: (s: string) => void }) => {
|
|||||||
const u = new URLSearchParams(window.location.search).get("userName");
|
const u = new URLSearchParams(window.location.search).get("userName");
|
||||||
if (u) {
|
if (u) {
|
||||||
input.value = u;
|
input.value = u;
|
||||||
onSubmit(u);
|
onSubmit(u).catch((err) => {
|
||||||
|
label.innerText = "error :(";
|
||||||
|
throw err;
|
||||||
|
});
|
||||||
|
|
||||||
input.disabled = true;
|
input.disabled = true;
|
||||||
submit.disabled = true;
|
submit.disabled = true;
|
||||||
form.appendChild(label);
|
form.appendChild(label);
|
||||||
|
label.innerText = "loading ...";
|
||||||
}
|
}
|
||||||
|
|
||||||
return { dispose };
|
return { dispose };
|
||||||
|
|||||||
Reference in New Issue
Block a user