mirror of
https://github.com/trafficlunar/tomodachi-share.git
synced 2026-06-28 14:44:15 +00:00
feat: queue toggle in admin control center
This commit is contained in:
parent
12c0205bf5
commit
bf8e8a094d
6 changed files with 55 additions and 36 deletions
|
|
@ -1,25 +1,17 @@
|
|||
"use client";
|
||||
|
||||
import { useEffect, useState } from "react";
|
||||
import { settings } from "@/lib/settings";
|
||||
import { useState } from "react";
|
||||
|
||||
export default function ControlCenter() {
|
||||
const [canSubmit, setCanSubmit] = useState(true);
|
||||
const [canSubmit, setCanSubmit] = useState(settings.canSubmit);
|
||||
const [isQueueEnabled, setIsQeueueEnabled] = useState(settings.queueEnabled);
|
||||
|
||||
const onClickSet = async () => {
|
||||
await fetch("/api/admin/can-submit", { method: "PATCH", body: JSON.stringify(canSubmit) });
|
||||
await fetch("/api/admin/queue", { method: "PATCH", body: JSON.stringify(isQueueEnabled) });
|
||||
};
|
||||
|
||||
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-2">
|
||||
|
|
@ -33,6 +25,17 @@ export default function ControlCenter() {
|
|||
/>
|
||||
<label htmlFor="submit">Enable Submissions</label>
|
||||
</div>
|
||||
<div className="flex items-center gap-2">
|
||||
<input
|
||||
id="queue"
|
||||
type="checkbox"
|
||||
className="checkbox size-6!"
|
||||
placeholder="Enter banner text"
|
||||
checked={isQueueEnabled}
|
||||
onChange={(e) => setIsQeueueEnabled(e.target.checked)}
|
||||
/>
|
||||
<label htmlFor="queue">Enable Queue</label>
|
||||
</div>
|
||||
|
||||
<div className="flex gap-2 self-end">
|
||||
<button type="submit" className="pill button" onClick={onClickSet}>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue