mirror of
https://github.com/trafficlunar/tomodachi-share.git
synced 2026-06-28 06:34:15 +00:00
feat: allow admins to disable submissions
This commit is contained in:
parent
769dd0b863
commit
c5437ed3e7
5 changed files with 104 additions and 0 deletions
44
src/components/admin/control-center.tsx
Normal file
44
src/components/admin/control-center.tsx
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
"use client";
|
||||
|
||||
import { useEffect, useState } from "react";
|
||||
|
||||
export default function ControlCenter() {
|
||||
const [canSubmit, setCanSubmit] = useState(true);
|
||||
|
||||
const onClickSet = async () => {
|
||||
await fetch("/api/admin/can-submit", { method: "PATCH", body: JSON.stringify(canSubmit) });
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
const check = async () => {
|
||||
const response = await fetch("/api/admin/can-submit");
|
||||
const { value } = await response.json();
|
||||
|
||||
setCanSubmit(value);
|
||||
};
|
||||
|
||||
check();
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<div className="bg-orange-100 rounded-xl border-2 border-orange-400 p-2 flex flex-col gap-2">
|
||||
<div className="flex items-center gap-4">
|
||||
<label htmlFor="submit">Submissions</label>
|
||||
<input
|
||||
name="submit"
|
||||
type="checkbox"
|
||||
className="checkbox !size-6"
|
||||
placeholder="Enter banner text"
|
||||
checked={canSubmit}
|
||||
onChange={(e) => setCanSubmit(e.target.checked)}
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div className="flex gap-2 self-end">
|
||||
<button type="submit" className="pill button" onClick={onClickSet}>
|
||||
Set
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue