Merge pull request #280 from bipproduction/amalia/02-okt-24
Amalia/02 okt 24
This commit is contained in:
3
src/app/(application)/banner/create/page.tsx
Normal file
3
src/app/(application)/banner/create/page.tsx
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
export default function Page() {
|
||||||
|
return <div>Tambah Banner</div>;
|
||||||
|
}
|
||||||
3
src/app/(application)/banner/edit/[id]/page.tsx
Normal file
3
src/app/(application)/banner/edit/[id]/page.tsx
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
export default function Page({ params }: { params: { id: string } }) {
|
||||||
|
return <div>Edit Banner</div>;
|
||||||
|
}
|
||||||
3
src/app/(application)/banner/page.tsx
Normal file
3
src/app/(application)/banner/page.tsx
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
export default function Page() {
|
||||||
|
return <div>List Banner</div>;
|
||||||
|
}
|
||||||
@@ -100,6 +100,9 @@ export async function POST(request: Request) {
|
|||||||
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 userRoleLogin = user.idUserRole
|
||||||
|
const userId = user.id
|
||||||
|
|
||||||
const { idDivision, desc } = (await request.json());
|
const { idDivision, desc } = (await request.json());
|
||||||
|
|
||||||
const cekDivision = await prisma.division.count({
|
const cekDivision = await prisma.division.count({
|
||||||
@@ -148,6 +151,25 @@ export async function POST(request: Request) {
|
|||||||
desc: 'Terdapat diskusi baru. Silahkan periksa detailnya.'
|
desc: 'Terdapat diskusi baru. Silahkan periksa detailnya.'
|
||||||
}))
|
}))
|
||||||
|
|
||||||
|
if (userRoleLogin != "supadmin") {
|
||||||
|
const perbekel = await prisma.user.findFirst({
|
||||||
|
where: {
|
||||||
|
isActive: true,
|
||||||
|
idUserRole: "supadmin",
|
||||||
|
idVillage: user.idVillage
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
dataNotif.push({
|
||||||
|
idUserTo: perbekel?.id,
|
||||||
|
idUserFrom: userId,
|
||||||
|
category: 'division/' + idDivision + '/discussion',
|
||||||
|
idContent: data.id,
|
||||||
|
title: 'Diskusi Baru',
|
||||||
|
desc: 'Terdapat diskusi baru. Silahkan periksa detailnya.'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
const insertNotif = await prisma.notifications.createMany({
|
const insertNotif = await prisma.notifications.createMany({
|
||||||
data: dataNotif
|
data: dataNotif
|
||||||
})
|
})
|
||||||
@@ -155,7 +177,7 @@ export async function POST(request: Request) {
|
|||||||
// create log user
|
// create log user
|
||||||
const log = await createLogUser({ act: 'CREATE', desc: 'User membuat data diskusi', table: 'divisionDisscussion', data: data.id })
|
const log = await createLogUser({ act: 'CREATE', desc: 'User membuat data diskusi', table: 'divisionDisscussion', data: data.id })
|
||||||
|
|
||||||
return NextResponse.json({ success: true, message: "Berhasil menambahkan diskusi", data, }, { status: 200 });
|
return NextResponse.json({ success: true, message: "Berhasil menambahkan diskusi", notif: dataNotif }, { status: 200 });
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(error);
|
console.error(error);
|
||||||
return NextResponse.json({ success: false, message: "Gagal menambahkan diskusi, coba lagi nanti", reason: (error as Error).message, }, { status: 500 });
|
return NextResponse.json({ success: false, message: "Gagal menambahkan diskusi, coba lagi nanti", reason: (error as Error).message, }, { status: 500 });
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ export default function WrapLayout({ children, role, theme, user }: { children:
|
|||||||
}, [role, theme])
|
}, [role, theme])
|
||||||
|
|
||||||
useShallowEffect(() => {
|
useShallowEffect(() => {
|
||||||
|
console.log(data)
|
||||||
if (data && data.some((i: any) => i.idUserTo == user)) {
|
if (data && data.some((i: any) => i.idUserTo == user)) {
|
||||||
setTampilNotif(true)
|
setTampilNotif(true)
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
|
|||||||
1
src/module/banner/index.ts
Normal file
1
src/module/banner/index.ts
Normal file
@@ -0,0 +1 @@
|
|||||||
|
//cobaa
|
||||||
0
src/module/banner/lib/git.keep
Normal file
0
src/module/banner/lib/git.keep
Normal file
0
src/module/banner/ui/git.keep
Normal file
0
src/module/banner/ui/git.keep
Normal file
@@ -1,14 +1,15 @@
|
|||||||
'use client'
|
'use client'
|
||||||
import { TEMA } from "@/module/_global";
|
import { keyWibu, TEMA } from "@/module/_global";
|
||||||
import LayoutModal from "@/module/_global/layout/layout_modal";
|
import LayoutModal from "@/module/_global/layout/layout_modal";
|
||||||
import { Avatar, Box, Button, Center, Grid, Group, rem, Text, Textarea } from "@mantine/core";
|
|
||||||
import { useState } from "react";
|
|
||||||
import toast from "react-hot-toast";
|
|
||||||
import { funCreateDiscussion, funGetDiscussionById } from "../lib/api_discussion";
|
|
||||||
import { useParams, useRouter } from "next/navigation";
|
|
||||||
import { useShallowEffect } from "@mantine/hooks";
|
|
||||||
import { funGetProfileByCookies } from "@/module/user/profile/lib/api_profile";
|
import { funGetProfileByCookies } from "@/module/user/profile/lib/api_profile";
|
||||||
import { useHookstate } from "@hookstate/core";
|
import { useHookstate } from "@hookstate/core";
|
||||||
|
import { Avatar, Box, Button, Grid, rem, Textarea } from "@mantine/core";
|
||||||
|
import { useShallowEffect } from "@mantine/hooks";
|
||||||
|
import { useParams, useRouter } from "next/navigation";
|
||||||
|
import { useState } from "react";
|
||||||
|
import toast from "react-hot-toast";
|
||||||
|
import { useWibuRealtime } from "wibu-realtime";
|
||||||
|
import { funCreateDiscussion } from "../lib/api_discussion";
|
||||||
|
|
||||||
export default function FormCreateDiscussion({ id }: { id: string }) {
|
export default function FormCreateDiscussion({ id }: { id: string }) {
|
||||||
const [isValModal, setValModal] = useState(false)
|
const [isValModal, setValModal] = useState(false)
|
||||||
@@ -25,22 +26,27 @@ export default function FormCreateDiscussion({ id }: { id: string }) {
|
|||||||
desc: "",
|
desc: "",
|
||||||
idDivision: id
|
idDivision: id
|
||||||
})
|
})
|
||||||
|
const [data, setDataRealtime] = useWibuRealtime({
|
||||||
|
WIBU_REALTIME_TOKEN: keyWibu,
|
||||||
|
project: "sdm"
|
||||||
|
})
|
||||||
|
|
||||||
async function getData() {
|
async function getData() {
|
||||||
try {
|
try {
|
||||||
setLoading(true)
|
setLoading(true)
|
||||||
const res = await funGetProfileByCookies()
|
const res = await funGetProfileByCookies()
|
||||||
setIMG(`https://wibu-storage.wibudev.com/api/files/${res.data.img}`)
|
setIMG(`https://wibu-storage.wibudev.com/api/files/${res.data.img}`)
|
||||||
setLoading(false)
|
setLoading(false)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(error);
|
console.error(error);
|
||||||
} finally {
|
} finally {
|
||||||
setLoading(false)
|
setLoading(false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
useShallowEffect(() => {
|
useShallowEffect(() => {
|
||||||
getData()
|
getData()
|
||||||
}, [])
|
}, [])
|
||||||
|
|
||||||
async function createDiscussion(val: boolean) {
|
async function createDiscussion(val: boolean) {
|
||||||
try {
|
try {
|
||||||
@@ -51,6 +57,7 @@ export default function FormCreateDiscussion({ id }: { id: string }) {
|
|||||||
})
|
})
|
||||||
|
|
||||||
if (response.success) {
|
if (response.success) {
|
||||||
|
setDataRealtime(response.notif)
|
||||||
toast.success(response.message)
|
toast.success(response.message)
|
||||||
router.push(`/division/${param.id}/discussion/`)
|
router.push(`/division/${param.id}/discussion/`)
|
||||||
setValModal(false)
|
setValModal(false)
|
||||||
@@ -70,7 +77,7 @@ export default function FormCreateDiscussion({ id }: { id: string }) {
|
|||||||
return (
|
return (
|
||||||
<Box >
|
<Box >
|
||||||
<Box p={20} >
|
<Box p={20} >
|
||||||
<Grid pt={10}>
|
<Grid pt={10}>
|
||||||
<Grid.Col span={2}>
|
<Grid.Col span={2}>
|
||||||
<Avatar src={img} alt="it's me" size="lg" />
|
<Avatar src={img} alt="it's me" size="lg" />
|
||||||
</Grid.Col>
|
</Grid.Col>
|
||||||
|
|||||||
Reference in New Issue
Block a user