Commit 8e5ee519 authored by Vũ Đình Nguyên's avatar Vũ Đình Nguyên

fix(layout-all-page

parent ac83cae9
allowBuilds:
esbuild: true
sharp: true
unrs-resolver: true
...@@ -39,8 +39,8 @@ const ABOUT_HIGHLIGHTS = [ ...@@ -39,8 +39,8 @@ const ABOUT_HIGHLIGHTS = [
const ACTIVITY_AREAS = [ const ACTIVITY_AREAS = [
"TP. Hồ Chí Minh", "TP. Hồ Chí Minh",
"Bình Dương", // "Bình Dương",
"Bình Phước", // "Bình Phước",
"Đồng Nai", "Đồng Nai",
"Lâm Đồng", "Lâm Đồng",
"Tây Ninh", "Tây Ninh",
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
import StructuredPostContent from "../StructuredPostContent"; import StructuredPostContent from "../StructuredPostContent";
import type { DynamicPostItem } from "../types"; import type { DynamicPostItem } from "../types";
import parse from "html-react-parser";
type DefaultInformationPageProps = { type DefaultInformationPageProps = {
post: DynamicPostItem; post: DynamicPostItem;
}; };
...@@ -20,7 +20,7 @@ export default function DefaultInformationPage({ ...@@ -20,7 +20,7 @@ export default function DefaultInformationPage({
{post.summary ? ( {post.summary ? (
<p className="mt-5 max-w-6xl text-base font-semibold leading-7 text-[#374151] md:text-lg md:leading-8"> <p className="mt-5 max-w-6xl text-base font-semibold leading-7 text-[#374151] md:text-lg md:leading-8">
{post.summary} {parse(post.summary)}
</p> </p>
) : null} ) : null}
......
...@@ -47,7 +47,7 @@ const SERVICE_SUPPORT_ITEMS = [ ...@@ -47,7 +47,7 @@ const SERVICE_SUPPORT_ITEMS = [
}, },
{ {
key: "certificate", key: "certificate",
title: "Cấp C/O và xác nhận các chứng từ thương mại", title: "Xác nhận các chứng từ thương mại (Bỏ cấp C/O)",
icon: FileBadge2, icon: FileBadge2,
}, },
{ {
......
...@@ -3,6 +3,8 @@ ...@@ -3,6 +3,8 @@
import dynamic from "next/dynamic"; import dynamic from "next/dynamic";
import { useMemo, useRef } from "react"; import { useMemo, useRef } from "react";
import type { JoditEditorProps } from "jodit-react"; import type { JoditEditorProps } from "jodit-react";
import useAuthStore from "@/store/useAuthStore";
import links from "@/links";
const JoditEditor = dynamic(() => import("jodit-react").then((mod) => mod.default), { const JoditEditor = dynamic(() => import("jodit-react").then((mod) => mod.default), {
ssr: false, ssr: false,
...@@ -104,6 +106,7 @@ export function AdminRichTextEditor({ ...@@ -104,6 +106,7 @@ export function AdminRichTextEditor({
readOnly = false, readOnly = false,
}: AdminRichTextEditorProps) { }: AdminRichTextEditorProps) {
const editor = useRef(null); const editor = useRef(null);
const accessToken = useAuthStore((state) => state.appAccessToken);
const config: JoditEditorProps["config"] = useMemo( const config: JoditEditorProps["config"] = useMemo(
() => ({ () => ({
...@@ -113,7 +116,52 @@ export function AdminRichTextEditor({ ...@@ -113,7 +116,52 @@ export function AdminRichTextEditor({
language: "vi", language: "vi",
toolbarButtonSize: "middle", toolbarButtonSize: "middle",
uploader: { uploader: {
insertImageAsBase64URI: true, url: `${links.apiEndpoint}/files`,
method: "POST",
headers: {
...(accessToken ? { Authorization: `Bearer ${accessToken}` } : {}),
},
format: "json",
buildData: (data: FormData) => {
const next = new FormData();
data.forEach((value, key) => {
if (key === "files[]" && value instanceof File) {
next.append("file", value);
} else {
next.append(key, value);
}
});
return next;
},
isSuccess: (resp: unknown) => {
if (typeof resp !== "object" || resp === null) return false;
const r = resp as Record<string, unknown>;
return (
r.status === "success" ||
r.status === "200" ||
(!r.violation && !!r.responseData)
);
},
process: (resp: unknown) => {
if (typeof resp !== "object" || resp === null) {
return { files: [], error: "Invalid response" };
}
const r = resp as Record<string, unknown>;
const responseData = r.responseData as Record<string, unknown> | undefined;
const url =
(typeof responseData?.url === "string" && responseData.url) ||
(typeof responseData?.fileUrl === "string" && responseData.fileUrl) ||
(typeof responseData?.path === "string" && responseData.path) ||
(typeof responseData?.link === "string" && responseData.link) ||
(typeof responseData?.src === "string" && responseData.src) ||
"";
return {
files: url ? [url] : [],
baseurl: "",
error: url ? undefined : (r.message as string) || "Upload failed",
msg: (r.message as string) || "",
};
},
}, },
buttons: [ buttons: [
"bold", "bold",
...@@ -182,7 +230,7 @@ export function AdminRichTextEditor({ ...@@ -182,7 +230,7 @@ export function AdminRichTextEditor({
}, },
}, },
}), }),
[minHeight, placeholder, readOnly], [minHeight, placeholder, readOnly, accessToken],
); );
return ( return (
......
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