contracts 1.18.0 + website: Get more storage
contracts: hub.storageRequestSchema and its reply, a sample and JSON Schemas. Website: an Owner or Admin asks for more 5 GB steps under Media library (signed to the Hub); the heartbeat reports the licence's storage limit, so the Hub emails the church at 80% and when full. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -82,7 +82,7 @@ export function ImagePicker({ value, onChange, label }: { value: string | null;
|
||||
</div>
|
||||
<div className="mt-6 border-t border-gray-200 pt-4">
|
||||
<h3 className="mb-2 font-semibold">Upload a new one</h3>
|
||||
{data?.storage.full && <Notice tone="warning">Your storage is full, so uploads have stopped. To get more (5 GB at a time), contact Cross Code.</Notice>}
|
||||
{data?.storage.full && <Notice tone="warning">Your storage is full, so uploads have stopped. An Owner or Admin can get more under Media library.</Notice>}
|
||||
<Uploader disabled={data?.storage.full} onUploaded={(m) => { reload(); onChange(m.id); setOpen(false); }} />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -3,14 +3,17 @@
|
||||
import { useState } from "react";
|
||||
import { api } from "@/admin/api";
|
||||
import { gb, StorageMeter, Uploader, type MediaItem, type Storage } from "@/admin/media";
|
||||
import { Btn, inputClass, Loading, Notice, Panel, Title, useAction, useAdmin } from "@/admin/ui";
|
||||
import { Btn, inputClass, Loading, Notice, Panel, Title, useAction, useAdmin, when } from "@/admin/ui";
|
||||
|
||||
/** The media library (§10): uploads, what each photo shows (alt text), and storage used. */
|
||||
export default function Media() {
|
||||
const { data, error, reload } = useAdmin<{ storage: Storage; items: MediaItem[] }>("/media");
|
||||
const { data, error, reload } = useAdmin<{ storage: Storage; request: { at: string; steps: number } | null; items: MediaItem[] }>("/media");
|
||||
const me = useAdmin<{ user: { role: string } }>("/me");
|
||||
const [alts, setAlts] = useState<Record<string, string>>({});
|
||||
const [steps, setSteps] = useState(1);
|
||||
const { busy, message, run } = useAction();
|
||||
if (!data) return <Loading error={error} />;
|
||||
const manager = ["owner", "admin"].includes(me.data?.user.role ?? "");
|
||||
const s = data.storage;
|
||||
return (
|
||||
<>
|
||||
@@ -38,7 +41,22 @@ export default function Media() {
|
||||
<div className="space-y-6">
|
||||
<Panel title="Storage">
|
||||
<StorageMeter s={s} />
|
||||
{s.percent >= 80 && <div className="mt-3"><Notice tone={s.full ? "error" : "warning"}>{s.full ? "Storage is full: uploads have stopped until more storage is added." : "Storage is nearly full."} More comes in 5 GB steps (R20 a month each): contact Cross Code.</Notice></div>}
|
||||
{s.percent >= 80 && <div className="mt-3"><Notice tone={s.full ? "error" : "warning"}>{s.full ? "Storage is full: uploads have stopped until more storage is added." : "Storage is nearly full."} Everything already uploaded keeps showing.</Notice></div>}
|
||||
<div className="mt-4 border-t border-gray-200 pt-4">
|
||||
<h3 className="font-semibold">Get more storage</h3>
|
||||
<p className="mt-1 text-sm text-gray-600">In steps of 5 GB, R20 a month each, added to your church's account.</p>
|
||||
{data.request ? (
|
||||
<div className="mt-3"><Notice tone="info">You asked for {data.request.steps * 5} GB more on {when(data.request.at)}. Cross Code adds it to your account; uploads work again within a minute of that.</Notice></div>
|
||||
) : manager ? (
|
||||
<div className="mt-3 flex flex-wrap items-center gap-2">
|
||||
<label className="text-sm" htmlFor="steps">Add</label>
|
||||
<select id="steps" className={`${inputClass} w-28`} value={steps} onChange={(e) => setSteps(Number(e.target.value))}>
|
||||
{[1, 2, 3, 4].map((n) => <option key={n} value={n}>{n * 5} GB</option>)}
|
||||
</select>
|
||||
<Btn kind="primary" busy={busy} onClick={() => run(async () => { await api("/storage-request", { body: { steps } }); await reload(); }, "Asked: Cross Code will add it.")}>Ask for it</Btn>
|
||||
</div>
|
||||
) : <p className="mt-2 text-sm text-gray-600">Your website's Owner or an Admin can ask for it.</p>}
|
||||
</div>
|
||||
</Panel>
|
||||
<Panel title="Upload a photo">
|
||||
{s.full ? <Notice tone="warning">Uploads have stopped: your storage is full.</Notice> : <Uploader onUploaded={() => reload()} />}
|
||||
|
||||
Reference in New Issue
Block a user