diff --git a/bun.lockb b/bun.lockb index 9862c7b..8c40967 100755 Binary files a/bun.lockb and b/bun.lockb differ diff --git a/package.json b/package.json index 1d48414..d32500b 100644 --- a/package.json +++ b/package.json @@ -29,7 +29,12 @@ "@mantine/tiptap": "^7.11.0", "@prisma/client": "5.16.1", "@tabler/icons-react": "^3.7.0", + "@tiptap/extension-color": "^2.11.7", + "@tiptap/extension-highlight": "^2.11.7", "@tiptap/extension-link": "^2.4.0", + "@tiptap/extension-text-align": "^2.11.7", + "@tiptap/extension-underline": "^2.11.7", + "@tiptap/pm": "^2.11.7", "@tiptap/react": "^2.4.0", "@tiptap/starter-kit": "^2.4.0", "@types/lodash": "^4.17.6", diff --git a/src/app/(application)/layout.tsx b/src/app/(application)/layout.tsx index 2468927..631b909 100644 --- a/src/app/(application)/layout.tsx +++ b/src/app/(application)/layout.tsx @@ -3,6 +3,7 @@ import { WrapLayout } from "@/module/_global" import { funDetectCookies, funGetUserByCookies } from "@/module/auth" import _ from "lodash" import { redirect } from "next/navigation" +import '@mantine/tiptap/styles.css'; export default async function Layout({ children }: { children: React.ReactNode }) { const cookies = await funDetectCookies() diff --git a/src/module/_global/components/notification_custome_center.tsx b/src/module/_global/components/notification_custome_center.tsx index f40a956..cab0f68 100644 --- a/src/module/_global/components/notification_custome_center.tsx +++ b/src/module/_global/components/notification_custome_center.tsx @@ -7,7 +7,7 @@ import { IoCloseOutline } from 'react-icons/io5'; import { TEMA } from '../bin/val_global'; export default function NotificationCustomeCenter({ title, desc, onClick }: { title: string, desc: string, onClick: (val: string) => void, }) { - const [opened, setOpened] = useState(false); + const [opened, setOpened] = useState(false) const tema = useHookstate(TEMA) useShallowEffect(() => { @@ -72,7 +72,15 @@ export default function NotificationCustomeCenter({ title, desc, onClick }: { ti /> PENGUMUMAN {desc} - + + {/* { + isMobile + ? <> + : + <> */} + {/* + } */} diff --git a/src/module/announcement/ui/create_announcement.tsx b/src/module/announcement/ui/create_announcement.tsx index 25d72cf..8163b82 100644 --- a/src/module/announcement/ui/create_announcement.tsx +++ b/src/module/announcement/ui/create_announcement.tsx @@ -2,8 +2,16 @@ import { keyWibu, LayoutNavbarNew, TEMA } from "@/module/_global"; import LayoutModal from "@/module/_global/layout/layout_modal"; import { useHookstate } from "@hookstate/core"; -import { Box, Button, Flex, Group, rem, Stack, Text, Textarea, TextInput } from "@mantine/core"; +import { Box, Button, Flex, Group, rem, Stack, Text, TextInput } from "@mantine/core"; import { useShallowEffect } from "@mantine/hooks"; +import { Link, RichTextEditor } from "@mantine/tiptap"; +import { Color } from '@tiptap/extension-color'; +import Highlight from '@tiptap/extension-highlight'; +import TextAlign from '@tiptap/extension-text-align'; +import TextStyle from '@tiptap/extension-text-style'; +import Underline from '@tiptap/extension-underline'; +import { useEditor } from "@tiptap/react"; +import StarterKit from '@tiptap/starter-kit'; import { useRouter } from "next/navigation"; import { useState } from "react"; import toast from "react-hot-toast"; @@ -36,6 +44,19 @@ export default function CreateAnnouncement() { desc: false }); + const editor = useEditor({ + extensions: [ + StarterKit, + Underline, + Link, + Highlight, + TextStyle, + Color, + TextAlign.configure({ types: ['heading', 'paragraph'] }), + ], + content: "", + }); + async function onSubmit() { try { @@ -74,14 +95,17 @@ export default function CreateAnnouncement() { function onCheck() { - const cek = checkAll() - if (!cek) - return false + onValidation('desc', '') + setTimeout(() => { + const cek = checkAll() + if (!cek) + return false - if (memberValue.length == 0) - return toast.error("Error! silahkan pilih divisi") + if (memberValue.length == 0) + return toast.error("Error! silahkan pilih divisi") - setOpen(true) + setOpen(true) + }, 500) } function checkAll() { @@ -90,14 +114,16 @@ export default function CreateAnnouncement() { setTouched(touched => ({ ...touched, title: true })) nilai = false } - if (isData.desc === "") { + if (String(editor?.getHTML()) === "" || String(editor?.getHTML()) === "

" || String(editor?.getHTML()) === "undefined") { setTouched(touched => ({ ...touched, desc: true })) nilai = false + toast.error("Pengumuman Tidak Boleh Kosong!") } return nilai } + function onValidation(kategori: string, val: string) { if (kategori == 'title') { setisData({ ...isData, title: val }) @@ -107,15 +133,16 @@ export default function CreateAnnouncement() { setTouched({ ...touched, title: false }) } } else if (kategori == 'desc') { - setisData({ ...isData, desc: val }) - if (val === "") { - setTouched({ ...touched, desc: true }) - } else { - setTouched({ ...touched, desc: false }) - } + setisData({ ...isData, desc: String(editor?.getHTML()) }) + // if (val === "") { + // setTouched({ ...touched, desc: true }) + // } else { + // setTouched({ ...touched, desc: false }) + // } } } + if (isChooseMember) return { setIsChooseMember(false) }} /> return ( @@ -141,7 +168,7 @@ export default function CreateAnnouncement() { ) } /> -