feat(admin): media library + upload component (replace URL fields)

- /admin/files Media Library: drag-drop multi-upload, thumbnails, copy-URL, delete
- FileUploadField replaces raw URL inputs; new "image" field type in AdminResource;
  wired into category image
- upload proxy /api/admin/files/upload: browser → Next → presigned PUT (server-side,
  reaches minio:9000) → confirm → returns public URL
- user-uploads bucket is public-read; public base via NEXT_PUBLIC_MINIO_URL

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
soroush.asadi
2026-06-02 14:55:52 +03:30
parent cf5dd4f195
commit 163f0c9ec3
12 changed files with 368 additions and 4 deletions
+9 -1
View File
@@ -2,10 +2,12 @@
import { useCallback, useEffect, useState, type ReactNode } from "react";
import { FileUploadField } from "@/components/admin/FileUploadField";
export interface FieldDef {
key: string;
label: string;
type?: "text" | "textarea" | "number" | "checkbox" | "select";
type?: "text" | "textarea" | "number" | "checkbox" | "select" | "image" | "file";
options?: { value: string; label: string }[];
required?: boolean;
placeholder?: string;
@@ -215,6 +217,12 @@ export function AdminResource({ config }: { config: ResourceConfig }) {
<input type="checkbox" checked={!!form[f.key]} onChange={(e) => setForm({ ...form, [f.key]: e.target.checked })} />
{f.label}
</label>
) : f.type === "image" || f.type === "file" ? (
<FileUploadField
value={String(form[f.key] ?? "")}
onChange={(url) => setForm({ ...form, [f.key]: url })}
accept={f.type === "image" ? "image/*" : "*/*"}
/>
) : (
<input type={f.type === "number" ? "number" : "text"} className={inputCls} placeholder={f.placeholder}
value={String(form[f.key] ?? "")}