diff --git a/public/assets/img/bg-login1.jpg b/public/assets/img/bg-login1.jpg new file mode 100644 index 0000000..bced4d6 Binary files /dev/null and b/public/assets/img/bg-login1.jpg differ diff --git a/public/assets/img/bg-login3.jpg b/public/assets/img/bg-login3.jpg new file mode 100644 index 0000000..46b196f Binary files /dev/null and b/public/assets/img/bg-login3.jpg differ diff --git a/src/app/api/log-user/route.ts b/src/app/api/log-user/route.ts new file mode 100644 index 0000000..fa00c54 --- /dev/null +++ b/src/app/api/log-user/route.ts @@ -0,0 +1,70 @@ +import { prisma } from "@/module/_global"; +import _ from "lodash"; +import moment from "moment"; +import "moment/locale/id"; +import { NextResponse } from "next/server"; + +export async function GET(request: Request) { + try { + const { searchParams } = new URL(request.url); + const idVillage = searchParams.get("village"); + const dStart = searchParams.get('dateStart'); + const dEnd = searchParams.get('dateEnd'); + + const awalDate = moment(dStart).format('YYYY-MM-DD') + ' 00:00:01' + const akhirDate = moment(dEnd).format('YYYY-MM-DD') + ' 23:59:59' + + + const data = await prisma.userLog.findMany({ + where: { + User: { + idVillage: String(idVillage) + }, + createdAt: { + gte: new Date(awalDate), + lte: new Date(akhirDate), + } + }, + select: { + User: { + select: { + name: true, + img: true, + UserRole: { + select: { + name: true + } + }, + Group: { + select: { + name: true + } + } + } + }, + id: true, + createdAt: true, + idUser: true, + action: true, + desc: true, + idContent: true, + tbContent: true, + } + }) + + const fixData = data.map((v: any) => ({ + ..._.omit(v, ["createdAt", "User"]), + createdAt: moment(v.createdAt).format("lll").replace("pukul", ""), + userName: v.User.name, + userImg: v.User.img, + userRole: v.User.UserRole.name, + userGroup: v.User.Group.name + })) + + return NextResponse.json({ success: true, message: "Berhasil mendapatkan data", data: fixData }, { status: 200 }); + + } catch (error) { + console.error(error); + return NextResponse.json({ success: false, message: "Gagal mendapatkan divisi, coba lagi nanti (error: 500)", reason: (error as Error).message, }, { status: 500 }); + } +} \ No newline at end of file diff --git a/src/app/api/version-app/route.ts b/src/app/api/version-app/route.ts index 52bbc69..d8e1f4f 100644 --- a/src/app/api/version-app/route.ts +++ b/src/app/api/version-app/route.ts @@ -2,7 +2,7 @@ import { NextResponse } from "next/server"; export async function GET(request: Request) { try { - return NextResponse.json({ success: true, version: "1.2.3", tahap: "beta", update:"-nama grup darmasaba jadi lembaga desa, -menampilkan user role pada profile pada detail anggota, -fitur hapus pada data yg telah dibatalkan pada fitur kegiatan dan tugas divisi, -zoom in out gesture pada view file pdf dan image" }, { status: 200 }); + return NextResponse.json({ success: true, version: "1.2.4", tahap: "beta", update: "-tampilan login dashboard, -tampilan log user pada dashboard developer" }, { status: 200 }); } catch (error) { console.error(error); return NextResponse.json({ success: false, version: "Gagal mendapatkan version, coba lagi nanti (error: 500)", reason: (error as Error).message, }, { status: 500 }); diff --git a/src/app/dashboard/page.tsx b/src/app/dashboard/page.tsx new file mode 100644 index 0000000..dff69b7 --- /dev/null +++ b/src/app/dashboard/page.tsx @@ -0,0 +1,9 @@ +import { AuthPage, LoginPageDashboard, LogUserPage } from "@/module/dashboard"; + +export default function Page() { + return ( + // + // + + ) +} \ No newline at end of file diff --git a/src/module/dashboard/index.ts b/src/module/dashboard/index.ts new file mode 100644 index 0000000..c769e85 --- /dev/null +++ b/src/module/dashboard/index.ts @@ -0,0 +1,7 @@ +import AuthPage from "./ui/auth_page"; +import LogUserPage from "./ui/log_user_page"; +import LoginPageDashboard from "./ui/login_das"; + +export { LoginPageDashboard } +export { LogUserPage } +export { AuthPage } \ No newline at end of file diff --git a/src/module/dashboard/lib/api_log_user.ts b/src/module/dashboard/lib/api_log_user.ts new file mode 100644 index 0000000..9ec03ec --- /dev/null +++ b/src/module/dashboard/lib/api_log_user.ts @@ -0,0 +1,4 @@ +export const funGetLogUserDashboard = async (path?: string) => { + const response = await fetch(`/api/log-user${(path) ? path : ''}`); + return await response.json().catch(() => null); +} \ No newline at end of file diff --git a/src/module/dashboard/lib/type_log_user.ts b/src/module/dashboard/lib/type_log_user.ts new file mode 100644 index 0000000..6bb9b7c --- /dev/null +++ b/src/module/dashboard/lib/type_log_user.ts @@ -0,0 +1,13 @@ +export interface IDataLogUserDashboard { + id: string + idUser: string + idContent: string + tbContent: string + action: string + desc: string + userName: string + userImg: string | null + userRole: string + userGroup: string + createdAt: string +}[] \ No newline at end of file diff --git a/src/module/dashboard/ui/auth_page.tsx b/src/module/dashboard/ui/auth_page.tsx new file mode 100644 index 0000000..fdec9b6 --- /dev/null +++ b/src/module/dashboard/ui/auth_page.tsx @@ -0,0 +1,26 @@ +'use client' + +import { useState } from "react"; +import LogUserPage from "./log_user_page"; +import LoginPageDashboard from "./login_das"; +import toast from "react-hot-toast"; + +export default function AuthPage() { + const [valid, setValid] = useState(false) + + function cekPassword(pass: string) { + if (pass == "wibuSekali") { + toast.success("Selamat datang di dashboard developer!") + setTimeout(() => { + setValid(true) + }, 2000); + } else { + setValid(false) + toast.error("Password salah") + } + } + + if (valid) return + + return { cekPassword(val) }} /> +} \ No newline at end of file diff --git a/src/module/dashboard/ui/log_user_page.tsx b/src/module/dashboard/ui/log_user_page.tsx new file mode 100644 index 0000000..60130f8 --- /dev/null +++ b/src/module/dashboard/ui/log_user_page.tsx @@ -0,0 +1,139 @@ +'use client' +import { Avatar, Box, Button, Center, Divider, Flex, Grid, Group, Text, Loader } from "@mantine/core"; +import { DateInput } from "@mantine/dates"; +import _ from "lodash"; +import { useState } from "react"; +import { IDataLogUserDashboard } from "../lib/type_log_user"; +import toast from "react-hot-toast"; +import { funGetLogUserDashboard } from "../lib/api_log_user"; +import moment from "moment"; +import { useShallowEffect } from "@mantine/hooks"; + +export default function LogUserPage() { + const [value, setValue] = useState(new Date()); + const [valueEnd, setValueEnd] = useState(new Date()); + const [data, setData] = useState([]); + const [loading, setLoading] = useState(true) + + async function onShow(awal: any, akhir: any) { + try { + setLoading(true) + const res = await funGetLogUserDashboard(`?village=desa1&dateStart=${moment(awal).format("YYYY-MM-DD")}&dateEnd=${moment(akhir).format("YYYY-MM-DD")}`) + if (res.success) { + setData(res.data) + } else { + toast.error(res.message) + } + } catch (error) { + console.error(error) + toast.error("Gagal mendapatkan data, coba lagi nanti"); + } finally { + setLoading(false) + } + } + + function onChangeDateStart(val: any, kat: string) { + if (kat == "start") { + val == null ? setValue(undefined) : setValue(val) + if (valueEnd != undefined && val != undefined && valueEnd < val) { + setValueEnd(val) + onShow(val, val) + } else { + onShow(val, valueEnd) + } + } else if (kat == "end") { + val == null ? setValueEnd(undefined) : setValueEnd(val) + onShow(value, val) + } + } + + useShallowEffect(() => { + onShow(value, valueEnd) + }, []) + + return ( + <> + + + { onChangeDateStart(val, 'start') }} + label="Tanggal Awal" + placeholder="Tanggal Awal" + mb={5} + /> + { onChangeDateStart(val, 'end') }} + label="Tanggal Akhir" + placeholder="Tanggal Akhir" + /> + + + { + !loading ? + data.length > 0 ? + data.map((item, i) => { + return ( + + + + + + + + + {item.userName} + + {item.createdAt} + + + + {item.userRole + ' - ' + item.userGroup} + + + + + {item.desc} + {item.tbContent + ' | ' + item.idContent} + + + + ) + }) + + : + ( + Data Kosong + ) + : + ( + + ) + } + + + + ) +} \ No newline at end of file diff --git a/src/module/dashboard/ui/login_das.tsx b/src/module/dashboard/ui/login_das.tsx new file mode 100644 index 0000000..e9c4043 --- /dev/null +++ b/src/module/dashboard/ui/login_das.tsx @@ -0,0 +1,53 @@ +'use client' +import { Box, Button, Image, PasswordInput, Stack, Text } from "@mantine/core"; +import { useViewportSize } from "@mantine/hooks"; +import { useState } from "react"; + + +export default function LoginPageDashboard({ onSubmit }: { onSubmit: (val: string) => void }) { + const { height, width } = useViewportSize(); + const [password, setPassword] = useState("") + + return ( + <> + + background login + + WELCOME! + + + + + Sign in + If you do not know the password, kindly contact the developer for assistance. + + setPassword(e.target.value)} + /> + + + + + + ) +} \ No newline at end of file