diff --git a/src/api/crew.ts b/src/api/crew.ts index b45706e..44a7c19 100644 --- a/src/api/crew.ts +++ b/src/api/crew.ts @@ -70,6 +70,38 @@ export async function create( return { ok: true, value: res }; } +export async function update( + crew: string, + name: string, + tag: string +): Promise> { + const token = useAuthStore.getState().key; + if (token == null) { + return { + ok: false, + error: "You must be logged in to update a crew" + }; + } + + const req = await tryFetch( + `${import.meta.env.VITE_SLOP_CREW_SERVER}api/crew/${crew}`, + { + method: "PATCH", + headers: { + "Content-Type": "application/json", + Authorization: token + }, + body: JSON.stringify({ + name, + tag + }) + } + ); + + if (!req.ok) return req; + return { ok: true, value: null }; +} + export async function promote( crew: string, user: string diff --git a/src/routes/crews/CrewSettings.tsx b/src/routes/crews/CrewSettings.tsx index c6ff447..dd1c5ea 100644 --- a/src/routes/crews/CrewSettings.tsx +++ b/src/routes/crews/CrewSettings.tsx @@ -5,7 +5,72 @@ import { useNavigate, useRevalidator } from "react-router-dom"; import { CrewResponse, MeResponse } from "../../api/types"; import HiddenCode from "../../components/HiddenCode"; import { useRequiredAuth } from "../../util"; -import { createInvite, deleteInvite, nukeItFromOrbit } from "../../api/crew"; +import { + createInvite, + deleteInvite, + nukeItFromOrbit, + update +} from "../../api/crew"; +import TMPInput from "../../components/TMPInput.tsx"; +import Important from "../../components/Important.tsx"; + +function CrewUpdate({ crew }: { crew: CrewResponse }) { + const revalidator = useRevalidator(); + const name = React.createRef(); + const tag = React.createRef(); + + const [working, setWorking] = React.useState(false); + const [error, setError] = React.useState(null); + + return ( +
+

Name & tag

+ + {error != null && } + + + + + + +
+ ); +} function CrewSettingsInner({ crew, @@ -23,6 +88,8 @@ function CrewSettingsInner({ <>

Crew settings

+ +

Invites