From b1068933c22851d808b629b3c919d19234712ca6 Mon Sep 17 00:00:00 2001 From: Bagasbanuna02 Date: Mon, 19 May 2025 14:30:14 +0800 Subject: [PATCH] fix sticker on user UI --- .../lib/stiker/comp_button_sticker.tsx | 118 +++++++++++++++--- .../comp_V3_create.comment.tsx | 4 + src/app_modules/forum/create/V3_create.tsx | 31 ++++- .../forum/detail/v3_main_detail.tsx | 25 ++++ .../forum/edit/posting/V3_edit_posting.tsx | 25 ++++ 5 files changed, 179 insertions(+), 24 deletions(-) diff --git a/src/app_modules/_global/lib/stiker/comp_button_sticker.tsx b/src/app_modules/_global/lib/stiker/comp_button_sticker.tsx index f896f45f..f79bf846 100644 --- a/src/app_modules/_global/lib/stiker/comp_button_sticker.tsx +++ b/src/app_modules/_global/lib/stiker/comp_button_sticker.tsx @@ -1,40 +1,80 @@ +import { APIs } from "@/lib"; import { ActionIcon, Box, + Button, + CloseButton, Image, + Loader, ScrollArea, SimpleGrid, Tooltip, - Loader, - Group, } from "@mantine/core"; import { IconMoodSmileFilled } from "@tabler/icons-react"; +import { useRef, useState } from "react"; import { MainColor } from "../../color"; import { UIGlobal_Modal } from "../../ui"; import { insertStickerReactQuill } from "./react_quill_format_for_stiker"; -import { APIs } from "@/lib"; +import { ISticker } from "../interface/stiker"; interface Props { open: () => void; close: () => void; opened: boolean; quillRef: any; - dataSticker: any; - listEmotions: any + dataSticker: ISticker[] | null; + // listEmotions: any[]; + // onEmotionSelect?: (val: string | null) => void; } + export const Comp_ButtonSticker = ({ open, close, opened, quillRef, dataSticker, - listEmotions, + // listEmotions, + // onEmotionSelect, }: Props) => { - + + const scrollRef = useRef(null); + + // Menyimpan id emosi yang dipilih + const [selectedEmotions, setSelectedEmotions] = useState([]); + + // Menyimpan urutan awal + // const [originalOrder] = useState(listEmotions); + + // const handleEmotionClick = (value: string) => { + // setSelectedEmotions( + // (prev) => + // prev.includes(value) + // ? prev.filter((v) => v !== value) // batal pilih + // : [...prev, value] // tambah pilih + // ); + // }; + + // Urutkan emosi: yang dipilih muncul di depan + // const orderedEmotions = [ + // ...selectedEmotions.map((val) => listEmotions.find((e: any) => e.value === val)), + // ...originalOrder.filter((e: any) => !selectedEmotions.includes(e.value)), + // ]; + return ( <> - - + + - {/* - {listEmotions.map((item: any) => ( - open()}> - - - ))} - */} - + {/* + + {orderedEmotions.map((item: any) => { + const isSelected = selectedEmotions.includes(item.value); + + return ( + + ); + })} + + */} + + - {dataSticker.map((item: any) => ( + {dataSticker?.map((item: any) => ( { @@ -52,11 +53,13 @@ export default function Forum_V3_CreateKomentar({ data, userLoginId, onSetLoadData, + dataSticker, }: { postingId: string; data: MODEL_FORUM_POSTING; userLoginId: string; onSetLoadData: (val: string) => void; + dataSticker: ISticker[] | null; }) { const [loading, setLoading] = useState(false); const [isComment, setIsComment] = useState(false); @@ -196,6 +199,7 @@ export default function Forum_V3_CreateKomentar({ close={close} opened={opened} quillRef={quillRef} + dataSticker={dataSticker} />