Merge pull request #375 from bipproduction/amalia/14-jan-25
Amalia/14 jan 25
This commit is contained in:
@@ -1,11 +1,14 @@
|
|||||||
import { ListDiscussionGeneral, NavbarDiscussionGeneral } from '@/module/discussion_general';
|
import { ViewFilter } from '@/module/_global';
|
||||||
import React from 'react';
|
import { NavbarDiscussionGeneral, TabListDiscussionGeneral } from '@/module/discussion_general';
|
||||||
|
|
||||||
|
function Page({ searchParams }: { searchParams: { page: string } }) {
|
||||||
|
if (searchParams.page == "filter")
|
||||||
|
return <ViewFilter linkFilter='discussion' />
|
||||||
|
|
||||||
function Page() {
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<NavbarDiscussionGeneral />
|
<NavbarDiscussionGeneral />
|
||||||
<ListDiscussionGeneral />
|
<TabListDiscussionGeneral />
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import { createLogUser } from "@/module/user";
|
|||||||
import _ from "lodash";
|
import _ from "lodash";
|
||||||
import moment from "moment";
|
import moment from "moment";
|
||||||
import { NextResponse } from "next/server";
|
import { NextResponse } from "next/server";
|
||||||
|
import "moment/locale/id";
|
||||||
|
|
||||||
|
|
||||||
// GET ONE DETAIL DISKUSI UMUM
|
// GET ONE DETAIL DISKUSI UMUM
|
||||||
@@ -22,7 +23,7 @@ export async function GET(request: Request, context: { params: { id: string } })
|
|||||||
const cek = await prisma.discussion.count({
|
const cek = await prisma.discussion.count({
|
||||||
where: {
|
where: {
|
||||||
id,
|
id,
|
||||||
isActive: true
|
// isActive: true
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -34,9 +35,10 @@ export async function GET(request: Request, context: { params: { id: string } })
|
|||||||
const data = await prisma.discussion.findUnique({
|
const data = await prisma.discussion.findUnique({
|
||||||
where: {
|
where: {
|
||||||
id,
|
id,
|
||||||
isActive: true
|
// isActive: true
|
||||||
},
|
},
|
||||||
select: {
|
select: {
|
||||||
|
isActive: true,
|
||||||
id: true,
|
id: true,
|
||||||
title: true,
|
title: true,
|
||||||
idGroup: true,
|
idGroup: true,
|
||||||
@@ -77,7 +79,7 @@ export async function GET(request: Request, context: { params: { id: string } })
|
|||||||
|
|
||||||
dataFix = data.map((v: any) => ({
|
dataFix = data.map((v: any) => ({
|
||||||
..._.omit(v, ["createdAt", "User",]),
|
..._.omit(v, ["createdAt", "User",]),
|
||||||
createdAt: moment(v.createdAt).format("lll"),
|
createdAt: moment(v.createdAt).format("lll").replace('pukul', ''),
|
||||||
username: v.User.name,
|
username: v.User.name,
|
||||||
img: v.User.img
|
img: v.User.img
|
||||||
}))
|
}))
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ export async function GET(request: Request) {
|
|||||||
const idGroup = searchParams.get("group");
|
const idGroup = searchParams.get("group");
|
||||||
const search = searchParams.get('search');
|
const search = searchParams.get('search');
|
||||||
const page = searchParams.get('page');
|
const page = searchParams.get('page');
|
||||||
|
const status = searchParams.get('active');
|
||||||
const dataSkip = Number(page) * 10 - 10;
|
const dataSkip = Number(page) * 10 - 10;
|
||||||
|
|
||||||
if (idGroup == "null" || idGroup == undefined || idGroup == "") {
|
if (idGroup == "null" || idGroup == undefined || idGroup == "") {
|
||||||
@@ -43,39 +44,11 @@ export async function GET(request: Request) {
|
|||||||
return NextResponse.json({ success: false, message: "Gagal mendapatkan data kegiatan, data tidak ditemukan", }, { status: 404 });
|
return NextResponse.json({ success: false, message: "Gagal mendapatkan data kegiatan, data tidak ditemukan", }, { status: 404 });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
let kondisi: any = {
|
|
||||||
isActive: true,
|
|
||||||
idVillage: String(villageId),
|
|
||||||
idGroup: grup,
|
|
||||||
title: {
|
|
||||||
contains: (search == undefined || search == "null") ? "" : search,
|
|
||||||
mode: "insensitive"
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
if (roleUser != "supadmin" && roleUser != "cosupadmin" && roleUser != "admin") {
|
|
||||||
kondisi = {
|
|
||||||
isActive: true,
|
|
||||||
idVillage: String(villageId),
|
|
||||||
idGroup: grup,
|
|
||||||
title: {
|
|
||||||
contains: (search == undefined || search == "null") ? "" : search,
|
|
||||||
mode: "insensitive"
|
|
||||||
},
|
|
||||||
DiscussionMember: {
|
|
||||||
some: {
|
|
||||||
idUser: String(userId)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const data = await prisma.discussion.findMany({
|
const data = await prisma.discussion.findMany({
|
||||||
skip: dataSkip,
|
skip: dataSkip,
|
||||||
take: 10,
|
take: 10,
|
||||||
where: {
|
where: {
|
||||||
isActive: true,
|
isActive: status == "false" ? false : true,
|
||||||
idVillage: String(villageId),
|
idVillage: String(villageId),
|
||||||
idGroup: grup,
|
idGroup: grup,
|
||||||
title: {
|
title: {
|
||||||
@@ -112,7 +85,17 @@ export async function GET(request: Request) {
|
|||||||
createdAt: moment(v.createdAt).format("ll")
|
createdAt: moment(v.createdAt).format("ll")
|
||||||
}))
|
}))
|
||||||
|
|
||||||
return NextResponse.json({ success: true, message: "Berhasil mendapatkan diskusi", data: fixData, }, { status: 200 });
|
const filter = await prisma.group.findUnique({
|
||||||
|
where: {
|
||||||
|
id: grup
|
||||||
|
},
|
||||||
|
select: {
|
||||||
|
id: true,
|
||||||
|
name: true
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
return NextResponse.json({ success: true, message: "Berhasil mendapatkan diskusi", data: fixData, filter }, { status: 200 });
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(error);
|
console.error(error);
|
||||||
|
|||||||
@@ -36,6 +36,7 @@ export async function GET(request: Request, context: { params: { id: string } })
|
|||||||
id: id
|
id: id
|
||||||
},
|
},
|
||||||
select: {
|
select: {
|
||||||
|
isActive: true,
|
||||||
id: true,
|
id: true,
|
||||||
title: true,
|
title: true,
|
||||||
desc: true,
|
desc: true,
|
||||||
@@ -152,7 +153,7 @@ export async function PUT(request: Request, context: { params: { id: string } })
|
|||||||
return NextResponse.json({ success: false, message: "Anda harus login untuk mengakses ini" }, { status: 401 });
|
return NextResponse.json({ success: false, message: "Anda harus login untuk mengakses ini" }, { status: 401 });
|
||||||
}
|
}
|
||||||
const { id } = context.params
|
const { id } = context.params
|
||||||
|
const { active } = (await request.json());
|
||||||
const cek = await prisma.divisionDisscussion.count({
|
const cek = await prisma.divisionDisscussion.count({
|
||||||
where: {
|
where: {
|
||||||
id: id
|
id: id
|
||||||
@@ -169,16 +170,22 @@ export async function PUT(request: Request, context: { params: { id: string } })
|
|||||||
id: id
|
id: id
|
||||||
},
|
},
|
||||||
data: {
|
data: {
|
||||||
isActive: false
|
isActive: active
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
// create log user
|
|
||||||
const log = await createLogUser({ act: 'DELETE', desc: 'User mengarsipkan data diskusi', table: 'divisionDisscussion', data: id })
|
|
||||||
|
|
||||||
return NextResponse.json({ success: true, message: "Berhasil mengarsipkan diskusi", user: user.id }, { status: 200 });
|
// create log user
|
||||||
|
if (active) {
|
||||||
|
const log = await createLogUser({ act: 'DELETE', desc: 'User mengaktifkan data diskusi', table: 'divisionDisscussion', data: id })
|
||||||
|
return NextResponse.json({ success: true, message: "Berhasil mengaktifkan diskusi", user: user.id }, { status: 200 });
|
||||||
|
} else {
|
||||||
|
const log = await createLogUser({ act: 'DELETE', desc: 'User mengarsipkan data diskusi', table: 'divisionDisscussion', data: id })
|
||||||
|
return NextResponse.json({ success: true, message: "Berhasil mengarsipkan diskusi", user: user.id }, { status: 200 });
|
||||||
|
}
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(error);
|
console.error(error);
|
||||||
return NextResponse.json({ success: false, message: "Gagal mengarsipkan diskusi, coba lagi nanti (error: 500)", reason: (error as Error).message, }, { status: 500 });
|
return NextResponse.json({ success: false, message: "Gagal mengubah diskusi, coba lagi nanti (error: 500)", reason: (error as Error).message, }, { status: 500 });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ import SkeletonList from "./components/skeleton_list";
|
|||||||
import { funViewDir } from "./fun/view_dir";
|
import { funViewDir } from "./fun/view_dir";
|
||||||
import { funSendWebPush } from "./fun/send_web_push";
|
import { funSendWebPush } from "./fun/send_web_push";
|
||||||
import ViewFilterData from "./view/view_filter_kategori_data";
|
import ViewFilterData from "./view/view_filter_kategori_data";
|
||||||
|
import LayoutModalNew from "./layout/layout_modal_new";
|
||||||
|
|
||||||
export { WARNA };
|
export { WARNA };
|
||||||
export { LayoutLogin };
|
export { LayoutLogin };
|
||||||
@@ -65,3 +66,4 @@ export { keyWibu }
|
|||||||
export { funViewDir }
|
export { funViewDir }
|
||||||
export { funSendWebPush }
|
export { funSendWebPush }
|
||||||
export { ViewFilterData }
|
export { ViewFilterData }
|
||||||
|
export { LayoutModalNew }
|
||||||
|
|||||||
43
src/module/_global/layout/layout_modal_new.tsx
Normal file
43
src/module/_global/layout/layout_modal_new.tsx
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
import { Button, Flex, Modal, SimpleGrid, Text } from '@mantine/core';
|
||||||
|
import { useMediaQuery } from '@mantine/hooks';
|
||||||
|
import { BsQuestionCircleFill } from 'react-icons/bs';
|
||||||
|
|
||||||
|
export default function LayoutModalNew({ opened, onClose, description, onYes, loading, onCheck }: { opened: boolean, onClose: () => void, loading?: boolean, description: string, onYes: (val: boolean) => void, onCheck: (val: boolean) => void }) {
|
||||||
|
const isMobile = useMediaQuery('(max-width: 768px)');
|
||||||
|
return (
|
||||||
|
<Modal styles={{
|
||||||
|
body: {
|
||||||
|
margin: 10,
|
||||||
|
},
|
||||||
|
content: {
|
||||||
|
border: `2px solid ${'#828AFC'}`,
|
||||||
|
borderRadius: 10
|
||||||
|
}
|
||||||
|
}} opened={opened} onClose={onClose} withCloseButton={false} centered closeOnClickOutside={false}>
|
||||||
|
<Flex justify={"center"} align={"center"} direction={"column"}>
|
||||||
|
<BsQuestionCircleFill size={100} color="red" />
|
||||||
|
<Text mt={30} ta={"center"} fw={"bold"} fz={18}>{description}</Text>
|
||||||
|
</Flex>
|
||||||
|
<Button mt={30} fullWidth size="lg" radius={'xl'} bg={'blue'} onClick={() => onCheck(true)}>Lihat Data</Button>
|
||||||
|
<SimpleGrid mt={10} cols={{ base: 1, sm: 2, lg: 2 }}>
|
||||||
|
{isMobile ?
|
||||||
|
<>
|
||||||
|
<Button loading={loading} fullWidth size="lg" radius={'xl'} bg={'green'} onClick={() => {
|
||||||
|
onYes(true)
|
||||||
|
}}>YA</Button>
|
||||||
|
<Button fullWidth size="lg" radius={'xl'} bg={'#F1C1CF'} c={'#D30B30'} onClick={() => onYes(false)}>TIDAK</Button>
|
||||||
|
</>
|
||||||
|
:
|
||||||
|
<>
|
||||||
|
<Button fullWidth size="lg" radius={'xl'} bg={'#F1C1CF'} c={'#D30B30'} onClick={() => onYes(false)}>TIDAK</Button>
|
||||||
|
<Button loading={loading} fullWidth size="lg" radius={'xl'} bg={'green'} onClick={() => {
|
||||||
|
onYes(true)
|
||||||
|
}}>YA</Button>
|
||||||
|
</>
|
||||||
|
|
||||||
|
}
|
||||||
|
</SimpleGrid>
|
||||||
|
</Modal>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
'use client'
|
'use client'
|
||||||
import { keyWibu, LayoutNavbarNew, TEMA } from '@/module/_global';
|
import { keyWibu, LayoutModalNew, LayoutNavbarNew, TEMA } from '@/module/_global';
|
||||||
import LayoutModal from '@/module/_global/layout/layout_modal';
|
import LayoutModal from '@/module/_global/layout/layout_modal';
|
||||||
import { useHookstate } from '@hookstate/core';
|
import { useHookstate } from '@hookstate/core';
|
||||||
import { Avatar, Box, Button, Divider, Grid, Group, rem, Select, SimpleGrid, Stack, Text, Textarea, TextInput } from '@mantine/core';
|
import { Avatar, Box, Button, Divider, Flex, Grid, Group, Modal, rem, Select, SimpleGrid, Stack, Table, Text, Textarea, TextInput } from '@mantine/core';
|
||||||
import { DateInput, TimeInput } from '@mantine/dates';
|
import { DateInput, TimeInput } from '@mantine/dates';
|
||||||
import { useMediaQuery } from '@mantine/hooks';
|
import { useMediaQuery } from '@mantine/hooks';
|
||||||
import moment from 'moment';
|
import moment from 'moment';
|
||||||
@@ -15,16 +15,19 @@ import { funCheckCalender, funCreateCalender } from '../lib/api_calender';
|
|||||||
import { IFormMemberCalender } from '../lib/type_calender';
|
import { IFormMemberCalender } from '../lib/type_calender';
|
||||||
import { globalCalender } from '../lib/val_calender';
|
import { globalCalender } from '../lib/val_calender';
|
||||||
import CreateUserCalender from './create_user_calender';
|
import CreateUserCalender from './create_user_calender';
|
||||||
|
import ViewDataConflict from './create_view_event_conflict';
|
||||||
|
|
||||||
export default function CreateCalenderDivisionCaleder() {
|
export default function CreateCalenderDivisionCaleder() {
|
||||||
const [value, setValue] = useState<Date | null>(null);
|
const [value, setValue] = useState<Date | null>(null);
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
const [isModal, setModal] = useState(false)
|
const [isModal, setModal] = useState(false)
|
||||||
const [isModalKonfirmasiTglSama, setModalKonfirmasiTglSama] = useState(false)
|
const [isModalKonfirmasiTglSama, setModalKonfirmasiTglSama] = useState(false)
|
||||||
|
const [isModalViewData, setModalViewData] = useState(false)
|
||||||
const [loadingModal, setLoadingModal] = useState(false)
|
const [loadingModal, setLoadingModal] = useState(false)
|
||||||
const [loadingModalKonfirmasiTglSama, setLoadingModalKonfirmasiTglSama] = useState(false)
|
const [loadingModalKonfirmasiTglSama, setLoadingModalKonfirmasiTglSama] = useState(false)
|
||||||
const member = useHookstate(globalCalender)
|
const member = useHookstate(globalCalender)
|
||||||
const memberValue = member.get() as IFormMemberCalender[]
|
const memberValue = member.get() as IFormMemberCalender[]
|
||||||
|
const [dataAcaraKonflik, setDataAcaraKonflik] = useState<any[]>([])
|
||||||
const [openMember, setOpenMember] = useState(false)
|
const [openMember, setOpenMember] = useState(false)
|
||||||
const param = useParams<{ id: string, detail: string }>()
|
const param = useParams<{ id: string, detail: string }>()
|
||||||
const tema = useHookstate(TEMA)
|
const tema = useHookstate(TEMA)
|
||||||
@@ -75,6 +78,7 @@ export default function CreateCalenderDivisionCaleder() {
|
|||||||
onSubmit()
|
onSubmit()
|
||||||
} else {
|
} else {
|
||||||
setModalKonfirmasiTglSama(true)
|
setModalKonfirmasiTglSama(true)
|
||||||
|
setDataAcaraKonflik(response.data)
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(error)
|
console.error(error)
|
||||||
@@ -217,6 +221,7 @@ export default function CreateCalenderDivisionCaleder() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (openMember) return <CreateUserCalender onClose={() => setOpenMember(false)} />
|
if (openMember) return <CreateUserCalender onClose={() => setOpenMember(false)} />
|
||||||
|
if (isModalViewData) return <ViewDataConflict onClose={() => setModalViewData(false)} data={dataAcaraKonflik} />
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Box>
|
<Box>
|
||||||
@@ -468,7 +473,7 @@ export default function CreateCalenderDivisionCaleder() {
|
|||||||
}} />
|
}} />
|
||||||
|
|
||||||
|
|
||||||
<LayoutModal loading={loadingModalKonfirmasiTglSama} opened={isModalKonfirmasiTglSama}
|
<LayoutModalNew loading={loadingModalKonfirmasiTglSama} opened={isModalKonfirmasiTglSama} onCheck={(val) => { val ? setModalViewData(true) : setModalViewData(false) }}
|
||||||
onClose={() => {
|
onClose={() => {
|
||||||
setModalKonfirmasiTglSama(false)
|
setModalKonfirmasiTglSama(false)
|
||||||
setModal(false)
|
setModal(false)
|
||||||
|
|||||||
101
src/module/calender/ui/create_view_event_conflict.tsx
Normal file
101
src/module/calender/ui/create_view_event_conflict.tsx
Normal file
@@ -0,0 +1,101 @@
|
|||||||
|
import { LayoutNavbarNew, TEMA } from '@/module/_global';
|
||||||
|
import { useHookstate } from '@hookstate/core';
|
||||||
|
import { ActionIcon, Avatar, Box, Button, Divider, Flex, Grid, rem, Stack, Table, Text } from '@mantine/core';
|
||||||
|
import moment from 'moment';
|
||||||
|
import { HiChevronLeft } from 'react-icons/hi2';
|
||||||
|
import "moment/locale/id";
|
||||||
|
import { FaCheck } from 'react-icons/fa6';
|
||||||
|
import { useMediaQuery } from '@mantine/hooks';
|
||||||
|
import { MdOutlineEventNote } from 'react-icons/md';
|
||||||
|
|
||||||
|
export default function ViewDataConflict({ onClose, data }: { onClose: (val: any) => void, data: any[] }) {
|
||||||
|
const tema = useHookstate(TEMA)
|
||||||
|
const isMobile2 = useMediaQuery("(max-width: 438px)");
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Box>
|
||||||
|
<LayoutNavbarNew
|
||||||
|
// back=""
|
||||||
|
title="Data Acara"
|
||||||
|
state={
|
||||||
|
<Box>
|
||||||
|
<ActionIcon variant="light" onClick={() => { onClose(true) }} bg={tema.get().bgIcon} size="lg" radius="lg" aria-label="Settings">
|
||||||
|
<HiChevronLeft size={20} color='white' />
|
||||||
|
</ActionIcon>
|
||||||
|
</Box>
|
||||||
|
}
|
||||||
|
menu={<></>}
|
||||||
|
/>
|
||||||
|
<Box p={20}>
|
||||||
|
{
|
||||||
|
(data.length === 0) ?
|
||||||
|
<Stack align="stretch" justify="center" w={"100%"} h={"60vh"}>
|
||||||
|
<Text c="dimmed" ta={"center"} fs={"italic"}>Tidak ada data</Text>
|
||||||
|
</Stack>
|
||||||
|
:
|
||||||
|
<Box mt={20} mb={100}>
|
||||||
|
{data.map((v, i) => {
|
||||||
|
return (
|
||||||
|
<Box my={10} key={i}>
|
||||||
|
<Grid align='center' >
|
||||||
|
<Grid.Col
|
||||||
|
span={{
|
||||||
|
base: 1,
|
||||||
|
xs: 1,
|
||||||
|
sm: 1,
|
||||||
|
md: 1,
|
||||||
|
lg: 1,
|
||||||
|
xl: 1,
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<ActionIcon variant="light" bg={tema.get().utama} size={50} radius={100} aria-label="icon" >
|
||||||
|
<MdOutlineEventNote color={"white"} size={25} />
|
||||||
|
</ActionIcon>
|
||||||
|
</Grid.Col>
|
||||||
|
<Grid.Col
|
||||||
|
span={{
|
||||||
|
base: 11,
|
||||||
|
xs: 11,
|
||||||
|
sm: 11,
|
||||||
|
md: 11,
|
||||||
|
lg: 11,
|
||||||
|
xl: 11,
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Flex justify='space-between' align={"center"}>
|
||||||
|
<Flex direction={'column'} align="flex-start" justify="flex-start">
|
||||||
|
<Text pl={isMobile2 ? 40 : 30} lineClamp={1}>{v.title}</Text>
|
||||||
|
<Text pl={isMobile2 ? 40 : 30} c={"dimmed"} lineClamp={1}>{moment.utc(v.timeStart).format("HH:mm")} - {moment.utc(v.timeEnd).format("HH:mm")}</Text>
|
||||||
|
</Flex>
|
||||||
|
{/* {isSelected ? <FaCheck /> : null} */}
|
||||||
|
</Flex>
|
||||||
|
</Grid.Col>
|
||||||
|
</Grid>
|
||||||
|
<Box mt={10}>
|
||||||
|
<Divider size={"xs"} />
|
||||||
|
</Box>
|
||||||
|
</Box>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
</Box>
|
||||||
|
}
|
||||||
|
</Box>
|
||||||
|
<Box pos={'fixed'} bottom={0} p={rem(20)} w={"100%"} style={{
|
||||||
|
maxWidth: rem(550),
|
||||||
|
zIndex: 999,
|
||||||
|
backgroundColor: `${tema.get().bgUtama}`,
|
||||||
|
}}>
|
||||||
|
<Button
|
||||||
|
c={"white"}
|
||||||
|
bg={tema.get().utama}
|
||||||
|
size="lg"
|
||||||
|
radius={30}
|
||||||
|
fullWidth
|
||||||
|
onClick={() => { onClose(true) }}
|
||||||
|
>
|
||||||
|
Tutup
|
||||||
|
</Button>
|
||||||
|
</Box>
|
||||||
|
</Box>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -36,9 +36,13 @@ export const funEditStatusDiscussion = async (path: string, data: IStatusDiscuss
|
|||||||
return await response.json().catch(() => null);
|
return await response.json().catch(() => null);
|
||||||
}
|
}
|
||||||
|
|
||||||
export const funDeleteDiscussion = async (path: string) => {
|
export const funDeleteDiscussion = async (path: string, data: { active: boolean }) => {
|
||||||
const response = await fetch(`/api/discussion/${path}`, {
|
const response = await fetch(`/api/discussion/${path}`, {
|
||||||
method: "PUT",
|
method: "PUT",
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
},
|
||||||
|
body: JSON.stringify(data),
|
||||||
});
|
});
|
||||||
return await response.json().catch(() => null);
|
return await response.json().catch(() => null);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ export interface IDetailDiscussion {
|
|||||||
user_img: string
|
user_img: string
|
||||||
totalComments: number
|
totalComments: number
|
||||||
createdBy: string
|
createdBy: string
|
||||||
|
isActive: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface IAllComents {
|
export interface IAllComents {
|
||||||
|
|||||||
@@ -118,7 +118,7 @@ export default function DetailDiscussion({ id, idDivision }: { id: string, idDiv
|
|||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
<LayoutDrawer opened={openDrawer} title={'Menu'} onClose={() => setOpenDrawer(false)}>
|
<LayoutDrawer opened={openDrawer} title={'Menu'} onClose={() => setOpenDrawer(false)}>
|
||||||
<DrawerDetailDiscussion onSuccess={(val) => setOpenDrawer(false)} id={id} status={Number(isData?.status)} idDivision={idDivision} />
|
<DrawerDetailDiscussion onSuccess={(val) => setOpenDrawer(false)} id={id} status={Number(isData?.status)} idDivision={idDivision} active={isData?.isActive == false ? false : true} />
|
||||||
</LayoutDrawer>
|
</LayoutDrawer>
|
||||||
|
|
||||||
|
|
||||||
@@ -324,7 +324,7 @@ export default function DetailDiscussion({ id, idDivision }: { id: string, idDiv
|
|||||||
}}
|
}}
|
||||||
size="md"
|
size="md"
|
||||||
placeholder="Kirim Komentar"
|
placeholder="Kirim Komentar"
|
||||||
disabled={(isData?.status === 2 || (!memberDivision.get() && (roleLogin.get() == "user" || roleLogin.get() == "coadmin")))}
|
disabled={(isData?.status === 2 || !isData?.isActive || (!memberDivision.get() && (roleLogin.get() == "user" || roleLogin.get() == "coadmin")))}
|
||||||
onChange={(e) => setIsComent(e.target.value)}
|
onChange={(e) => setIsComent(e.target.value)}
|
||||||
value={isComent}
|
value={isComent}
|
||||||
maxLength={300}
|
maxLength={300}
|
||||||
@@ -335,7 +335,7 @@ export default function DetailDiscussion({ id, idDivision }: { id: string, idDiv
|
|||||||
<Center>
|
<Center>
|
||||||
<ActionIcon
|
<ActionIcon
|
||||||
onClick={sendComent}
|
onClick={sendComent}
|
||||||
variant="subtle" aria-label="submit" disabled={(isData?.status === 2 || (!memberDivision.get() && (roleLogin.get() == "user" || roleLogin.get() == "coadmin")))}>
|
variant="subtle" aria-label="submit" disabled={(isData?.status === 2 || !isData?.isActive || (!memberDivision.get() && (roleLogin.get() == "user" || roleLogin.get() == "coadmin")))}>
|
||||||
<VscSend size={30} />
|
<VscSend size={30} />
|
||||||
</ActionIcon>
|
</ActionIcon>
|
||||||
</Center>
|
</Center>
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ import { useWibuRealtime } from "wibu-realtime";
|
|||||||
import { funDeleteDiscussion, funEditStatusDiscussion } from "../lib/api_discussion";
|
import { funDeleteDiscussion, funEditStatusDiscussion } from "../lib/api_discussion";
|
||||||
import { globalRefreshDiscussion } from "../lib/val_discussion";
|
import { globalRefreshDiscussion } from "../lib/val_discussion";
|
||||||
|
|
||||||
export default function DrawerDetailDiscussion({ onSuccess, id, status, idDivision }: { onSuccess: (val: boolean) => void, id: string, status: number, idDivision: string }) {
|
export default function DrawerDetailDiscussion({ onSuccess, id, status, idDivision, active }: { onSuccess: (val: boolean) => void, id: string, status: number, idDivision: string, active: boolean }) {
|
||||||
const [isValModal, setValModal] = useState(false)
|
const [isValModal, setValModal] = useState(false)
|
||||||
const [isValModalStatus, setValModalStatus] = useState(false)
|
const [isValModalStatus, setValModalStatus] = useState(false)
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
@@ -57,7 +57,7 @@ export default function DrawerDetailDiscussion({ onSuccess, id, status, idDivisi
|
|||||||
try {
|
try {
|
||||||
if (val) {
|
if (val) {
|
||||||
setLoadingDelete(true)
|
setLoadingDelete(true)
|
||||||
const response = await funDeleteDiscussion(id)
|
const response = await funDeleteDiscussion(id, { active: !active })
|
||||||
if (response.success) {
|
if (response.success) {
|
||||||
setDataRealtime([
|
setDataRealtime([
|
||||||
{
|
{
|
||||||
@@ -71,14 +71,26 @@ export default function DrawerDetailDiscussion({ onSuccess, id, status, idDivisi
|
|||||||
])
|
])
|
||||||
toast.success(response.message)
|
toast.success(response.message)
|
||||||
onSuccess(false)
|
onSuccess(false)
|
||||||
router.push(`/division/${param.id}/discussion`)
|
if (active) {
|
||||||
|
router.push(`/division/${param.id}/discussion`)
|
||||||
|
} else {
|
||||||
|
refresh.set(!refresh.get())
|
||||||
|
setDataRealtime([{
|
||||||
|
category: "discussion-detail",
|
||||||
|
id: id,
|
||||||
|
}])
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
toast.error(response.message)
|
toast.error(response.message)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(error);
|
console.error(error);
|
||||||
toast.error("Gagal mengarsipkan diskusi, coba lagi nanti");
|
if (!active) {
|
||||||
|
toast.error("Gagal mengarsipkan diskusi, coba lagi nanti");
|
||||||
|
} else {
|
||||||
|
toast.error("Gagal mengaktifkan diskusi, coba lagi nanti");
|
||||||
|
}
|
||||||
} finally {
|
} finally {
|
||||||
setLoadingDelete(false)
|
setLoadingDelete(false)
|
||||||
setValModal(false)
|
setValModal(false)
|
||||||
@@ -94,52 +106,73 @@ export default function DrawerDetailDiscussion({ onSuccess, id, status, idDivisi
|
|||||||
spacing={{ base: 'xl', sm: 'xl' }}
|
spacing={{ base: 'xl', sm: 'xl' }}
|
||||||
verticalSpacing={{ base: 'xl', sm: 'xl' }}
|
verticalSpacing={{ base: 'xl', sm: 'xl' }}
|
||||||
>
|
>
|
||||||
<Flex onClick={() => window.location.href = `/division/${param.id}/discussion/update/${param.detail}`} justify={'center'} align={'center'} direction={'column'} >
|
{
|
||||||
<Box>
|
active &&
|
||||||
<FaPencil size={30} color={tema.get().utama} />
|
<>
|
||||||
</Box>
|
<Flex onClick={() => window.location.href = `/division/${param.id}/discussion/update/${param.detail}`} justify={'center'} align={'center'} direction={'column'} >
|
||||||
<Box>
|
<Box>
|
||||||
<Text c={tema.get().utama}>Edit</Text>
|
<FaPencil size={30} color={tema.get().utama} />
|
||||||
</Box>
|
</Box>
|
||||||
</Flex>
|
<Box>
|
||||||
|
<Text c={tema.get().utama}>Edit</Text>
|
||||||
|
</Box>
|
||||||
|
</Flex>
|
||||||
|
|
||||||
<Flex justify={'center'} align={'center'} direction={'column'} onClick={() => setValModalStatus(true)} >
|
<Flex justify={'center'} align={'center'} direction={'column'} onClick={() => setValModalStatus(true)} >
|
||||||
{status === 1 ? (
|
{status === 1 ? (
|
||||||
<>
|
<>
|
||||||
<Flex justify={'center'} align={'center'} direction={'column'}>
|
<Flex justify={'center'} align={'center'} direction={'column'}>
|
||||||
<Box>
|
<Box>
|
||||||
<MdClose size={30} color={tema.get().utama} />
|
<MdClose size={30} color={tema.get().utama} />
|
||||||
</Box>
|
</Box>
|
||||||
<Text style={{ color: tema.get().utama }}>Tutup Diskusi</Text>
|
<Text style={{ color: tema.get().utama }}>Tutup Diskusi</Text>
|
||||||
</Flex>
|
</Flex>
|
||||||
</>
|
</>
|
||||||
) : (
|
) : (
|
||||||
<>
|
<>
|
||||||
<Flex justify={'center'} align={'center'} direction={'column'}>
|
<Flex justify={'center'} align={'center'} direction={'column'}>
|
||||||
|
|
||||||
<Box>
|
<Box>
|
||||||
<FaCheck size={30} color={tema.get().utama} />
|
<FaCheck size={30} color={tema.get().utama} />
|
||||||
</Box>
|
</Box>
|
||||||
<Text style={{ color: tema.get().utama }}>Buka Diskusi</Text>
|
<Text style={{ color: tema.get().utama }}>Buka Diskusi</Text>
|
||||||
</Flex>
|
</Flex>
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
</Flex>
|
</Flex>
|
||||||
|
</>
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
{
|
||||||
|
active ?
|
||||||
|
<Flex onClick={() => setValModal(true)} justify={'center'} align={'center'} direction={'column'} >
|
||||||
|
<Box>
|
||||||
|
<BiArchive size={30} color={tema.get().utama} />
|
||||||
|
</Box>
|
||||||
|
<Box>
|
||||||
|
<Text c={tema.get().utama}>Arsipkan</Text>
|
||||||
|
</Box>
|
||||||
|
</Flex>
|
||||||
|
:
|
||||||
|
<Flex onClick={() => setValModal(true)} justify={'center'} align={'center'} direction={'column'} >
|
||||||
|
<Box>
|
||||||
|
<BiArchive size={30} color={tema.get().utama} />
|
||||||
|
</Box>
|
||||||
|
<Box>
|
||||||
|
<Text c={tema.get().utama}>Aktifkan Diskusi</Text>
|
||||||
|
</Box>
|
||||||
|
</Flex>
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
<Flex onClick={() => setValModal(true)} justify={'center'} align={'center'} direction={'column'} >
|
|
||||||
<Box>
|
|
||||||
<BiArchive size={30} color={tema.get().utama} />
|
|
||||||
</Box>
|
|
||||||
<Box>
|
|
||||||
<Text c={tema.get().utama}>Arsipkan</Text>
|
|
||||||
</Box>
|
|
||||||
</Flex>
|
|
||||||
|
|
||||||
</SimpleGrid>
|
</SimpleGrid>
|
||||||
</Stack>
|
</Stack>
|
||||||
|
|
||||||
<LayoutModal loading={loadingDelete} opened={isValModal} onClose={() => setValModal(false)}
|
<LayoutModal loading={loadingDelete} opened={isValModal} onClose={() => setValModal(false)}
|
||||||
description="Apakah Anda yakin ingin mengarsipkan diskusi ini?"
|
description={`Apakah Anda yakin ingin ${active ? "mengarsipkan" : "mengaktifkan"} diskusi ini?`}
|
||||||
onYes={(val) => { fetchDeleteDiscussion(val) }} />
|
onYes={(val) => { fetchDeleteDiscussion(val) }} />
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ export default function NavbarDetailDiscussion({id, status, idDivision}: {id: st
|
|||||||
</ActionIcon>}
|
</ActionIcon>}
|
||||||
/>
|
/>
|
||||||
<LayoutDrawer opened={openDrawer} title={'Menu'} onClose={() => setOpenDrawer(false)}>
|
<LayoutDrawer opened={openDrawer} title={'Menu'} onClose={() => setOpenDrawer(false)}>
|
||||||
<DrawerDetailDiscussion onSuccess={(val) => setOpenDrawer(false)} id={id} status={status} idDivision={idDivision} />
|
<DrawerDetailDiscussion onSuccess={(val) => setOpenDrawer(false)} id={id} status={status} idDivision={idDivision} active={false}/>
|
||||||
</LayoutDrawer>
|
</LayoutDrawer>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import FormEditDiscussionGeneral from "./ui/edit_discussion_general";
|
|||||||
import ListDiscussionGeneral from "./ui/list_discussion";
|
import ListDiscussionGeneral from "./ui/list_discussion";
|
||||||
import MemberDiscussionGeneral from "./ui/member_discussion_general";
|
import MemberDiscussionGeneral from "./ui/member_discussion_general";
|
||||||
import NavbarDiscussionGeneral from "./ui/navbar_discussion";
|
import NavbarDiscussionGeneral from "./ui/navbar_discussion";
|
||||||
|
import TabListDiscussionGeneral from "./ui/tab_list_discussion_general";
|
||||||
|
|
||||||
export { ListDiscussionGeneral }
|
export { ListDiscussionGeneral }
|
||||||
export { NavbarDiscussionGeneral }
|
export { NavbarDiscussionGeneral }
|
||||||
@@ -12,4 +13,5 @@ export { FormCreateDiscussionGeneral }
|
|||||||
export { DetailDiscussionGeneral }
|
export { DetailDiscussionGeneral }
|
||||||
export { MemberDiscussionGeneral }
|
export { MemberDiscussionGeneral }
|
||||||
export { FormEditDiscussionGeneral }
|
export { FormEditDiscussionGeneral }
|
||||||
export { AddMemberDiscussionGeneral }
|
export { AddMemberDiscussionGeneral }
|
||||||
|
export { TabListDiscussionGeneral }
|
||||||
@@ -81,7 +81,7 @@ export default function DetailDiscussionGeneral() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (dataRealTime && dataRealTime.some((i: any) => i.category == 'discussion-general-delete' && i.id == param.id && i.user != isUser)) {
|
if (dataRealTime && dataRealTime.some((i: any) => i.category == 'discussion-general-delete' && i.id == param.id && i.user != isUser)) {
|
||||||
toast.error("Data telah di hapus, anda akan beralih ke halaman list diskusi umum")
|
toast.error("Data telah diarsipkan, anda akan beralih ke halaman list diskusi umum")
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
router.push(`/discussion`)
|
router.push(`/discussion`)
|
||||||
}, 1000)
|
}, 1000)
|
||||||
@@ -313,7 +313,7 @@ export default function DetailDiscussionGeneral() {
|
|||||||
</Box>
|
</Box>
|
||||||
</Grid.Col>
|
</Grid.Col>
|
||||||
<Grid.Col span={3}>
|
<Grid.Col span={3}>
|
||||||
<Text c={"grey"} ta={"end"} fz={13}>{moment(v.createdAt).format('lll').replace('pukul', '')}</Text>
|
<Text c={"grey"} ta={"end"} fz={13}>{v.createdAt}</Text>
|
||||||
</Grid.Col>
|
</Grid.Col>
|
||||||
</Grid>
|
</Grid>
|
||||||
<Box mt={10}>
|
<Box mt={10}>
|
||||||
|
|||||||
@@ -79,7 +79,7 @@ export default function DrawerDetailDiscussionGeneral({ onSuccess, id, status }:
|
|||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(error);
|
console.error(error);
|
||||||
toast.error("Gagal hapus diskusi umum, coba lagi nanti");
|
toast.error("Gagal mengarsipkan diskusi umum, coba lagi nanti");
|
||||||
} finally {
|
} finally {
|
||||||
setLoadingDelete(false)
|
setLoadingDelete(false)
|
||||||
setValModal(false)
|
setValModal(false)
|
||||||
@@ -145,7 +145,7 @@ export default function DrawerDetailDiscussionGeneral({ onSuccess, id, status }:
|
|||||||
<BsTrash3 size={30} color={tema.get().utama} />
|
<BsTrash3 size={30} color={tema.get().utama} />
|
||||||
</Box>
|
</Box>
|
||||||
<Box>
|
<Box>
|
||||||
<Text c={tema.get().utama}>Hapus</Text>
|
<Text c={tema.get().utama}>Arsipkan</Text>
|
||||||
</Box>
|
</Box>
|
||||||
</Flex>
|
</Flex>
|
||||||
</>
|
</>
|
||||||
@@ -157,7 +157,7 @@ export default function DrawerDetailDiscussionGeneral({ onSuccess, id, status }:
|
|||||||
</Stack>
|
</Stack>
|
||||||
|
|
||||||
<LayoutModal loading={loadingDelete} opened={isValModal} onClose={() => setValModal(false)}
|
<LayoutModal loading={loadingDelete} opened={isValModal} onClose={() => setValModal(false)}
|
||||||
description="Apakah Anda yakin ingin menghapus diskusi ini?"
|
description="Apakah Anda yakin ingin mengarsipkan diskusi ini?"
|
||||||
onYes={(val) => {
|
onYes={(val) => {
|
||||||
fetchDeleteDiscussion(val)
|
fetchDeleteDiscussion(val)
|
||||||
}} />
|
}} />
|
||||||
|
|||||||
@@ -1,16 +1,22 @@
|
|||||||
import { TEMA } from "@/module/_global";
|
import { globalRole, TEMA } from "@/module/_global";
|
||||||
import { useHookstate } from "@hookstate/core";
|
import { useHookstate } from "@hookstate/core";
|
||||||
import { Box, Flex, SimpleGrid, Stack, Text } from "@mantine/core";
|
import { Box, Flex, SimpleGrid, Stack, Text } from "@mantine/core";
|
||||||
|
import { useRouter, useSearchParams } from "next/navigation";
|
||||||
|
import { HiOutlineFilter } from "react-icons/hi";
|
||||||
import { IoAddCircle } from "react-icons/io5";
|
import { IoAddCircle } from "react-icons/io5";
|
||||||
|
|
||||||
export default function DrawerDiscussionGeneral() {
|
export default function DrawerDiscussionGeneral() {
|
||||||
const tema = useHookstate(TEMA)
|
const tema = useHookstate(TEMA)
|
||||||
|
const roleLogin = useHookstate(globalRole)
|
||||||
|
const router = useRouter()
|
||||||
|
const searchParams = useSearchParams()
|
||||||
|
const group = searchParams.get('group')
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Box>
|
<Box>
|
||||||
<Stack pt={10}>
|
<Stack pt={10}>
|
||||||
<SimpleGrid cols={{ base: 2, sm: 2, lg: 3 }} >
|
<SimpleGrid cols={{ base: 2, sm: 2, lg: 3 }} >
|
||||||
<Flex onClick={() => window.location.href = "/discussion/create"} justify={'center'} align={'center'} direction={'column'} >
|
<Flex onClick={() => router.push("/discussion/create")} justify={'center'} align={'center'} direction={'column'} >
|
||||||
<Box>
|
<Box>
|
||||||
<IoAddCircle size={30} color={tema.get().utama} />
|
<IoAddCircle size={30} color={tema.get().utama} />
|
||||||
</Box>
|
</Box>
|
||||||
@@ -18,6 +24,19 @@ export default function DrawerDiscussionGeneral() {
|
|||||||
<Text c={tema.get().utama}>Tambah Diskusi</Text>
|
<Text c={tema.get().utama}>Tambah Diskusi</Text>
|
||||||
</Box>
|
</Box>
|
||||||
</Flex>
|
</Flex>
|
||||||
|
{
|
||||||
|
roleLogin.get() == "supadmin" &&
|
||||||
|
<Flex onClick={() => {
|
||||||
|
router.push('/discussion?page=filter&group=' + group)
|
||||||
|
}} justify={'center'} align={'center'} direction={'column'} >
|
||||||
|
<Box>
|
||||||
|
<HiOutlineFilter size={30} color={tema.get().utama} />
|
||||||
|
</Box>
|
||||||
|
<Box>
|
||||||
|
<Text c={tema.get().utama}>Filter</Text>
|
||||||
|
</Box>
|
||||||
|
</Flex>
|
||||||
|
}
|
||||||
</SimpleGrid>
|
</SimpleGrid>
|
||||||
</Stack>
|
</Stack>
|
||||||
</Box>
|
</Box>
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
'use client'
|
'use client'
|
||||||
import { currentScroll, globalNotifPage, keyWibu, ReloadButtonTop, TEMA } from "@/module/_global";
|
import { currentScroll, globalNotifPage, globalRole, keyWibu, ReloadButtonTop, TEMA } from "@/module/_global";
|
||||||
import { useHookstate } from "@hookstate/core";
|
import { useHookstate } from "@hookstate/core";
|
||||||
import { ActionIcon, Badge, Box, Divider, Flex, Grid, Group, Skeleton, Spoiler, Text, TextInput } from "@mantine/core";
|
import { ActionIcon, Badge, Box, Divider, Flex, Grid, Group, Skeleton, Spoiler, Text, TextInput } from "@mantine/core";
|
||||||
import { useShallowEffect } from "@mantine/hooks";
|
import { useShallowEffect } from "@mantine/hooks";
|
||||||
import _ from "lodash";
|
import _ from "lodash";
|
||||||
import { useRouter } from "next/navigation";
|
import { useRouter, useSearchParams } from "next/navigation";
|
||||||
import { useEffect, useState } from "react";
|
import { useEffect, useState } from "react";
|
||||||
import toast from "react-hot-toast";
|
import toast from "react-hot-toast";
|
||||||
import { BiSolidCommentDetail } from "react-icons/bi";
|
import { BiSolidCommentDetail } from "react-icons/bi";
|
||||||
@@ -20,7 +20,12 @@ export default function ListDiscussionGeneral() {
|
|||||||
const [loading, setLoading] = useState(true)
|
const [loading, setLoading] = useState(true)
|
||||||
const tema = useHookstate(TEMA)
|
const tema = useHookstate(TEMA)
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
const { value: containerRef } = useHookstate(currentScroll);
|
const { value: containerRef } = useHookstate(currentScroll)
|
||||||
|
const searchParams = useSearchParams()
|
||||||
|
const status = searchParams.get('active')
|
||||||
|
const group = searchParams.get('group')
|
||||||
|
const roleLogin = useHookstate(globalRole)
|
||||||
|
const [nameGroup, setNameGroup] = useState('')
|
||||||
const [isPage, setPage] = useState(1)
|
const [isPage, setPage] = useState(1)
|
||||||
const notifLoadPage = useHookstate(globalNotifPage)
|
const notifLoadPage = useHookstate(globalNotifPage)
|
||||||
const [isRefresh, setRefresh] = useState(false)
|
const [isRefresh, setRefresh] = useState(false)
|
||||||
@@ -32,8 +37,9 @@ export default function ListDiscussionGeneral() {
|
|||||||
const getData = async (loading: boolean) => {
|
const getData = async (loading: boolean) => {
|
||||||
try {
|
try {
|
||||||
setLoading(loading)
|
setLoading(loading)
|
||||||
const response = await funGetAllDiscussionGeneral('?search=' + searchQuery + '&page=' + isPage)
|
const response = await funGetAllDiscussionGeneral('?active=' + status + '&group=' + group + '&search=' + searchQuery + '&page=' + isPage)
|
||||||
if (response.success) {
|
if (response.success) {
|
||||||
|
setNameGroup(response.filter.name)
|
||||||
if (isPage == 1) {
|
if (isPage == 1) {
|
||||||
setData(response.data)
|
setData(response.data)
|
||||||
} else {
|
} else {
|
||||||
@@ -56,7 +62,7 @@ export default function ListDiscussionGeneral() {
|
|||||||
useShallowEffect(() => {
|
useShallowEffect(() => {
|
||||||
setPage(1)
|
setPage(1)
|
||||||
getData(true)
|
getData(true)
|
||||||
}, [searchQuery])
|
}, [searchQuery, status])
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const handleScroll = async () => {
|
const handleScroll = async () => {
|
||||||
@@ -107,7 +113,7 @@ export default function ListDiscussionGeneral() {
|
|||||||
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Box p={20}>
|
<Box py={20}>
|
||||||
{
|
{
|
||||||
isRefresh &&
|
isRefresh &&
|
||||||
<ReloadButtonTop
|
<ReloadButtonTop
|
||||||
@@ -131,6 +137,7 @@ export default function ListDiscussionGeneral() {
|
|||||||
value={searchQuery}
|
value={searchQuery}
|
||||||
onChange={(e) => setSearchQuery(e.target.value)}
|
onChange={(e) => setSearchQuery(e.target.value)}
|
||||||
/>
|
/>
|
||||||
|
{roleLogin.get() == 'supadmin' && <Text>Filter : {nameGroup}</Text>}
|
||||||
{loading ?
|
{loading ?
|
||||||
Array(3)
|
Array(3)
|
||||||
.fill(null)
|
.fill(null)
|
||||||
@@ -214,7 +221,9 @@ export default function ListDiscussionGeneral() {
|
|||||||
<Text c={tema.get().utama} fw={"bold"} lineClamp={1}>
|
<Text c={tema.get().utama} fw={"bold"} lineClamp={1}>
|
||||||
{v.title}
|
{v.title}
|
||||||
</Text>
|
</Text>
|
||||||
<Badge color={v.status === 1 ? "green" : "red"} size="sm">{v.status === 1 ? "BUKA" : "TUTUP"}</Badge>
|
{
|
||||||
|
status != "false" && <Badge color={v.status === 1 ? "green" : "red"} size="sm">{v.status === 1 ? "BUKA" : "TUTUP"}</Badge>
|
||||||
|
}
|
||||||
</Box>
|
</Box>
|
||||||
</Grid.Col>
|
</Grid.Col>
|
||||||
<Grid.Col span={4}>
|
<Grid.Col span={4}>
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
'use client'
|
'use client'
|
||||||
import { LayoutDrawer, LayoutNavbarNew, TEMA } from "@/module/_global";
|
import { globalRole, LayoutDrawer, LayoutNavbarNew, TEMA } from "@/module/_global";
|
||||||
import { useHookstate } from "@hookstate/core";
|
import { useHookstate } from "@hookstate/core";
|
||||||
import { ActionIcon } from "@mantine/core";
|
import { ActionIcon } from "@mantine/core";
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
@@ -9,10 +9,13 @@ import DrawerDiscussionGeneral from "./drawer_discussion";
|
|||||||
export default function NavbarDiscussionGeneral() {
|
export default function NavbarDiscussionGeneral() {
|
||||||
const [openDrawer, setOpenDrawer] = useState(false)
|
const [openDrawer, setOpenDrawer] = useState(false)
|
||||||
const tema = useHookstate(TEMA)
|
const tema = useHookstate(TEMA)
|
||||||
|
const roleLogin = useHookstate(globalRole)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<LayoutNavbarNew back={`/home`} title="Diskusi Umum"
|
<LayoutNavbarNew back={`/home`} title="Diskusi Umum"
|
||||||
menu={
|
menu={
|
||||||
|
roleLogin.get() != 'user' && roleLogin.get() != 'coadmin' &&
|
||||||
<ActionIcon variant="light" onClick={() => setOpenDrawer(true)} bg={tema.get().bgIcon} size="lg" radius="lg" aria-label="Settings">
|
<ActionIcon variant="light" onClick={() => setOpenDrawer(true)} bg={tema.get().bgIcon} size="lg" radius="lg" aria-label="Settings">
|
||||||
<HiMenu size={20} color='white' />
|
<HiMenu size={20} color='white' />
|
||||||
</ActionIcon>
|
</ActionIcon>
|
||||||
|
|||||||
@@ -0,0 +1,68 @@
|
|||||||
|
"use client";
|
||||||
|
import { globalRole, TEMA } from "@/module/_global";
|
||||||
|
import { useHookstate } from "@hookstate/core";
|
||||||
|
import { Box, rem, Tabs } from "@mantine/core";
|
||||||
|
import { useRouter, useSearchParams } from "next/navigation";
|
||||||
|
import { IoMdCheckmarkCircleOutline } from "react-icons/io";
|
||||||
|
import { IoCloseCircleOutline } from "react-icons/io5";
|
||||||
|
import ListDiscussionGeneral from "./list_discussion";
|
||||||
|
|
||||||
|
export default function TabListDiscussionGeneral() {
|
||||||
|
const iconStyle = { width: rem(20), height: rem(20) };
|
||||||
|
const router = useRouter();
|
||||||
|
const searchParams = useSearchParams();
|
||||||
|
const status = searchParams.get("active");
|
||||||
|
const group = searchParams.get("group");
|
||||||
|
const tema = useHookstate(TEMA)
|
||||||
|
const roleLogin = useHookstate(globalRole)
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Box p={20}>
|
||||||
|
<Tabs
|
||||||
|
variant="pills"
|
||||||
|
color={tema.get().bgFiturHome}
|
||||||
|
radius="xl"
|
||||||
|
defaultValue={status == "false" ? "false" : "true"}
|
||||||
|
>
|
||||||
|
{
|
||||||
|
roleLogin.get() != ''
|
||||||
|
?
|
||||||
|
(roleLogin.get() != "user" && roleLogin.get() != "coadmin") ?
|
||||||
|
<Tabs.List
|
||||||
|
bg={"white"}
|
||||||
|
style={{
|
||||||
|
border: `1px solid ${"#EDEDED"}`,
|
||||||
|
padding: 5,
|
||||||
|
borderRadius: 100,
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Tabs.Tab
|
||||||
|
value="true"
|
||||||
|
w={"45%"}
|
||||||
|
leftSection={<IoMdCheckmarkCircleOutline style={iconStyle} />}
|
||||||
|
onClick={() => {
|
||||||
|
router.push("?active=true&group=" + group);
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
Aktif
|
||||||
|
</Tabs.Tab>
|
||||||
|
<Tabs.Tab
|
||||||
|
value="false"
|
||||||
|
w={"53%"}
|
||||||
|
leftSection={<IoCloseCircleOutline style={iconStyle} />}
|
||||||
|
onClick={() => {
|
||||||
|
router.push("?active=false&group=" + group);
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
Arsip
|
||||||
|
</Tabs.Tab>
|
||||||
|
</Tabs.List>
|
||||||
|
:
|
||||||
|
<></>
|
||||||
|
: <></>
|
||||||
|
}
|
||||||
|
<ListDiscussionGeneral />
|
||||||
|
</Tabs>
|
||||||
|
</Box>
|
||||||
|
);
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user