Commit 998b966b authored by Lê Bảo Hồng Đức's avatar Lê Bảo Hồng Đức

fixnews

parent 0a8e85f9
......@@ -22,11 +22,8 @@ import { Button } from "@/components/ui/button";
import { Checkbox } from "@/components/ui/checkbox";
import { Input } from "@/components/ui/input";
import { Label } from "@/components/ui/label";
import logo from "@/assets/VCCI-HCM-logo-VN-2025.png";
import links, { resolveUploadUrl } from "@/links";
import { loginAdmin } from "@/lib/auth/admin-auth";
import useAuthStore from "@/store/useAuthStore";
import { fetchCmsFileById, resolveCmsFileUrl } from "@/lib/api/files";
type AuthMode = "login" | "forgot";
......@@ -121,18 +118,9 @@ function AuthShell({
}
);
// Resolve logo URL: prefer logo_url, otherwise fetch file by file_id.
const { data: logoFile } = useQuery({
queryKey: ["cms-file", logoData?.file_id],
queryFn: () => fetchCmsFileById(logoData!.file_id),
enabled: !!logoData?.file_id && !logoData?.logo_url,
});
const logoSrc = logoData?.logo_url
? resolveUploadUrl(logoData.logo_url)
: logoFile
? resolveCmsFileUrl(logoFile.path)
: logo;
// Always use the static /logo.png from public/ for the login screen so the
// logo renders reliably regardless of backend logo/upload state.
const logoSrc = "/logo.png";
const title =
mode === "login"
......
......@@ -385,8 +385,14 @@ export function AdminRichTextEditor({
"";
// Resolve to a full URL so the image preview renders inside the editor.
const resolvedUrl = rawUrl ? resolveUploadUrl(rawUrl) : "";
// isImages tells Jodit's defaultHandlerSuccess to insert an <img>
// tag instead of an <a> link. Without it, uploaded images render as
// plain text links inside the editor and on the client.
const mime = typeof responseData?.mime === "string" ? responseData.mime : "";
const isImage = mime.startsWith("image/") || /\.(png|jpe?g|gif|webp|svg|bmp|avif)$/i.test(resolvedUrl);
return {
files: resolvedUrl ? [resolvedUrl] : [],
isImages: resolvedUrl ? [isImage] : [],
baseurl: "",
error: resolvedUrl ? undefined : (r.message as string) || "Upload failed",
msg: (r.message as string) || "",
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment