mirror of
https://github.com/Sendouc/sendou.ink.git
synced 2026-05-07 22:12:57 -05:00
* Clean away prisma migrations
* Way to migrate WIP
* SQLite3 seeding script initial
* Fetch tournament data in loader
* CheckinActions new loader data model
* Virtual banner text color columns
* Logged in user
* Count teams
* ownTeam
* Map pool tab fully working
* Teams tab
* Fix timestamp default
* Register page
* Manage team page
* Camel case checkedInTimestamp
* Clean slate
* Add .nvmrc
* Add favicon
* Package lock file version 2
* Update tsconfig
* Add Tailwind
* Add StrictMode
* Add background color
* Auth without DB
* Revert "Add Tailwind"
This reverts commit 204713c602.
* Auth with DB
* Switch back to tilde absolute import
* Import layout
* Camel case for database columns
* Move auth routes to folder
* User popover links working
* Import linters
* User page initial
* User edit page with country
* Script to delete db files before migration in dev
* Remove "youtubeName" column
* Correct avatar size on desktop
* Fix SubNav not spanning the whole page
* Remove duplicate files
* Update README
82 lines
1.9 KiB
TypeScript
82 lines
1.9 KiB
TypeScript
import clsx from "clsx";
|
|
import * as React from "react";
|
|
|
|
export function SearchInput() {
|
|
if (process.env.NODE_ENV !== "development") return <div />;
|
|
return <SearchInputDev />;
|
|
}
|
|
|
|
export function SearchInputDev() {
|
|
const [inputValue, setInputValue] = React.useState("");
|
|
|
|
const handleEnter = () => {
|
|
const [action, value] = inputValue.split(":");
|
|
if (!action) return;
|
|
|
|
let fetchUrl = "";
|
|
switch (action) {
|
|
case "liu": {
|
|
if (!value) return;
|
|
fetchUrl = `/mock-auth?username=${encodeURIComponent(value)}`;
|
|
break;
|
|
}
|
|
case "lit": {
|
|
if (!value) return;
|
|
fetchUrl = `/mock-auth?team=${encodeURIComponent(value)}`;
|
|
break;
|
|
}
|
|
case "seed": {
|
|
if (!value) fetchUrl = "/seed";
|
|
else fetchUrl = `/seed?variation=${encodeURIComponent(value)}`;
|
|
break;
|
|
}
|
|
default: {
|
|
console.error("invalid action");
|
|
return;
|
|
}
|
|
}
|
|
|
|
return fetch(fetchUrl, { method: "post" }).then((res) => {
|
|
if (res.status === 200) location.reload();
|
|
else {
|
|
console.error(`http error when trying an admin action: ${res.status}`);
|
|
}
|
|
});
|
|
};
|
|
|
|
return (
|
|
<DumbSearchInput
|
|
value={inputValue}
|
|
setValue={setInputValue}
|
|
handleEnter={handleEnter}
|
|
/>
|
|
);
|
|
}
|
|
|
|
export function DumbSearchInput({
|
|
value,
|
|
setValue,
|
|
handleEnter,
|
|
}: {
|
|
value: string;
|
|
setValue: (newValue: string) => void;
|
|
handleEnter: () => Promise<void> | undefined;
|
|
}) {
|
|
return (
|
|
<div className={"layout__search-input__container"}>
|
|
<input
|
|
className={clsx("plain", "layout__search-input")}
|
|
type="text"
|
|
placeholder="Admin command"
|
|
value={value}
|
|
onChange={(e) => setValue(e.target.value)}
|
|
onKeyDown={(event) => {
|
|
if (event.key === "Enter") {
|
|
void handleEnter();
|
|
}
|
|
}}
|
|
/>
|
|
</div>
|
|
);
|
|
}
|