fix button sticker and API Sticket
This commit is contained in:
@@ -11,6 +11,8 @@ import { useDisclosure, useShallowEffect } from "@mantine/hooks";
|
||||
import { useRouter } from "next/navigation";
|
||||
import React, { useState } from "react";
|
||||
import Forum_ButtonCreatePosting from "../component/button/button_create_posting";
|
||||
import { apiGetStickerForUser } from "@/app_modules/_global/lib/stiker/api_fecth_stiker_for_user";
|
||||
import { apiGetMasterEmotions } from "@/app_modules/_global/lib/api_fetch_master";
|
||||
|
||||
export function Forum_V3_Create() {
|
||||
const router = useRouter();
|
||||
@@ -19,6 +21,45 @@ export function Forum_V3_Create() {
|
||||
const quillRef = React.useRef<any>(null);
|
||||
const [quillLoaded, setQuillLoaded] = useState<boolean>(false);
|
||||
const [isReady, setIsReady] = useState<boolean>(false);
|
||||
const [sticker, setSticker] = useState<any>([]);
|
||||
const [emotion, setEmotion] = useState<any>([]);
|
||||
|
||||
useShallowEffect(() => {
|
||||
onLoadSticker();
|
||||
onLoadEmotion();
|
||||
}, []);
|
||||
|
||||
async function onLoadSticker() {
|
||||
try {
|
||||
const response = await apiGetStickerForUser({ emotion });
|
||||
console.log("response >>", response);
|
||||
if (response.success) {
|
||||
setSticker(response.res.data);
|
||||
} else {
|
||||
console.error("Failed to get sticker", response.message);
|
||||
setSticker([]);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("Error get sticker", error);
|
||||
setSticker([]);
|
||||
}
|
||||
}
|
||||
|
||||
async function onLoadEmotion() {
|
||||
try {
|
||||
const response = await apiGetMasterEmotions();
|
||||
console.log("response >>", response);
|
||||
if (response.success) {
|
||||
setEmotion(response.data);
|
||||
} else {
|
||||
console.error("Failed to get emotion", response.message);
|
||||
setEmotion([]);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("Error get emotion", error);
|
||||
setEmotion([]);
|
||||
}
|
||||
}
|
||||
|
||||
useShallowEffect(() => {
|
||||
setIsReady(true); // Set ready on client-side mount
|
||||
@@ -82,6 +123,8 @@ export function Forum_V3_Create() {
|
||||
close={close}
|
||||
opened={opened}
|
||||
quillRef={quillRef}
|
||||
dataSticker={sticker}
|
||||
listEmotions={emotion}
|
||||
/>
|
||||
|
||||
<Forum_ButtonCreatePosting value={editorContent} />
|
||||
|
||||
Reference in New Issue
Block a user