Merge pull request #170 from bipproduction/amalia/30-agustus-24

Amalia/30 agustus 24
This commit is contained in:
Amalia
2024-08-30 11:40:16 +08:00
committed by GitHub
9 changed files with 28 additions and 19 deletions

View File

@@ -1,6 +1,9 @@
import { createLogUser } from "@/module/user";
import { cookies } from "next/headers"; import { cookies } from "next/headers";
export async function DELETE() { export async function DELETE() {
const log = await createLogUser({ act: 'LOGOUT', desc: 'User keluar dari program', table: 'user', data: '' })
cookies().delete('sessionCookieSDM') cookies().delete('sessionCookieSDM')
return Response.json({ success: true }) return Response.json({ success: true })

View File

@@ -36,7 +36,8 @@ export async function GET(request: Request, context: { params: { id: string } })
idUser: true, idUser: true,
User: { User: {
select: { select: {
name: true name: true,
img: true
} }
} }
}, },
@@ -47,7 +48,8 @@ export async function GET(request: Request, context: { params: { id: string } })
const fixMember = member.map((v: any) => ({ const fixMember = member.map((v: any) => ({
..._.omit(v, ["User"]), ..._.omit(v, ["User"]),
name: v.User.name name: v.User.name,
img: v.User.img
})) }))
const dataFix = { const dataFix = {

View File

@@ -150,7 +150,7 @@ export async function GET(request: Request) {
for (let index = 0; index < dataStatus.length; index++) { for (let index = 0; index < dataStatus.length; index++) {
const cek = data.some((i: any) => i.status == dataStatus[index].status) const cek = data.some((i: any) => i.status == dataStatus[index].status)
if (cek) { if (cek) {
const find = (Number(data.find((i: any) => i.status == dataStatus[index].status)?._count) * 100)/ data.reduce((n, {_count}) => n + _count, 0) const find = ((Number(data.find((i: any) => i.status == dataStatus[index].status)?._count) * 100)/ data.reduce((n, {_count}) => n + _count, 0)).toFixed(2)
input = { input = {
name: dataStatus[index].name, name: dataStatus[index].name,
value: find value: find

View File

@@ -4,6 +4,7 @@ import _ from "lodash";
import { NextResponse } from "next/server"; import { NextResponse } from "next/server";
import path from "path"; import path from "path";
import fs from "fs"; import fs from "fs";
import { createLogUser } from "@/module/user";
// GET PROFILE BY COOKIES // GET PROFILE BY COOKIES
@@ -139,6 +140,8 @@ export async function PUT(request: Request) {
}) })
} }
const log = await createLogUser({ act: 'UPDATE', desc: 'User mengupdate data profile', table: 'user', data: user.id })
return NextResponse.json({ success: true, message: "Berhasil ubah profile" }); return NextResponse.json({ success: true, message: "Berhasil ubah profile" });
} catch (error) { } catch (error) {
return NextResponse.json({ success: false, message: "Gagal ubah profile" }, { status: 500 }); return NextResponse.json({ success: false, message: "Gagal ubah profile" }, { status: 500 });

View File

@@ -2,6 +2,7 @@
import { sealData } from "iron-session"; import { sealData } from "iron-session";
import { cookies } from "next/headers"; import { cookies } from "next/headers";
import { prisma, pwd_key_config } from "@/module/_global"; import { prisma, pwd_key_config } from "@/module/_global";
import { createLogUser } from "@/module/user";
export default async function funSetCookies({ user }: { user: string }) { export default async function funSetCookies({ user }: { user: string }) {
try { try {
@@ -12,7 +13,7 @@ export default async function funSetCookies({ user }: { user: string }) {
where: { where: {
id: user id: user
}, },
select:{ select: {
isFirstLogin: true isFirstLogin: true
} }
}) })
@@ -34,7 +35,7 @@ export default async function funSetCookies({ user }: { user: string }) {
value: encryptedUserData, value: encryptedUserData,
}); });
const log = await createLogUser({ act: 'LOGIN', desc: 'User masuk ke program', table: 'user', data: '' })
return { success: true, message: "Login berhasil!", pertamaLogin: dataUser?.isFirstLogin }; return { success: true, message: "Login berhasil!", pertamaLogin: dataUser?.isFirstLogin };
} catch (error) { } catch (error) {

View File

@@ -55,5 +55,6 @@ export interface IDataMemberDivision {
idUser: string, idUser: string,
isAdmin: string, isAdmin: string,
isLeader: string, isLeader: string,
name: string name: string,
img: string
} }

View File

@@ -153,7 +153,7 @@ export default function CreateTask() {
borderRadius: 10, borderRadius: 10,
}} }}
> >
<Text c={WARNA.biruTua}>Tambah Anggota</Text> <Text>Tambah Anggota</Text>
<IoIosArrowDropright size={25} /> <IoIosArrowDropright size={25} />
</Group> </Group>
</Box> </Box>
@@ -205,7 +205,7 @@ export default function CreateTask() {
{ {
member.length > 0 && member.length > 0 &&
<Box pt={30} mb={60}> <Box pt={30} mb={100}>
<Group justify="space-between"> <Group justify="space-between">
<Text c={WARNA.biruTua}>Anggota Terpilih</Text> <Text c={WARNA.biruTua}>Anggota Terpilih</Text>
<Text c={WARNA.biruTua}>Total {member.length} Anggota</Text> <Text c={WARNA.biruTua}>Total {member.length} Anggota</Text>
@@ -229,7 +229,7 @@ export default function CreateTask() {
key={i} key={i}
> >
<Group> <Group>
<Avatar src={"v.image"} alt="it's me" size="lg" /> <Avatar src={`/api/file/img?cat=user&file=${v.img}`} alt="it's me" size="lg" />
<Box> <Box>
<Text c={WARNA.biruTua} fw={"bold"}> <Text c={WARNA.biruTua} fw={"bold"}>
{v.name} {v.name}

View File

@@ -4,18 +4,15 @@ import { funGetDivisionById, IDataMemberDivision } from "@/module/division_new";
import { useHookstate } from "@hookstate/core"; import { useHookstate } from "@hookstate/core";
import { import {
ActionIcon, ActionIcon,
Anchor,
Avatar, Avatar,
Box, Box,
Button, Button,
Checkbox,
Divider, Divider,
Flex, Flex,
Group, Group,
rem, rem,
Skeleton, Skeleton,
Text, Text,
TextInput,
} from "@mantine/core"; } from "@mantine/core";
import { useShallowEffect } from "@mantine/hooks"; import { useShallowEffect } from "@mantine/hooks";
import { useParams, useRouter } from "next/navigation"; import { useParams, useRouter } from "next/navigation";
@@ -23,6 +20,8 @@ import React, { useState } from "react";
import toast from "react-hot-toast"; import toast from "react-hot-toast";
import { globalMemberTask } from "../lib/val_task"; import { globalMemberTask } from "../lib/val_task";
import { FaCheck } from "react-icons/fa6"; import { FaCheck } from "react-icons/fa6";
import { RiListCheck } from "react-icons/ri";
import { BsListCheck } from "react-icons/bs";
export default function CreateUsersProject({ onClose }: { onClose: (val: any) => void }) { export default function CreateUsersProject({ onClose }: { onClose: (val: any) => void }) {
const router = useRouter() const router = useRouter()
@@ -64,7 +63,7 @@ export default function CreateUsersProject({ onClose }: { onClose: (val: any) =>
if (selectedFiles.some((i: any) => i.idUser == isData[index].idUser)) { if (selectedFiles.some((i: any) => i.idUser == isData[index].idUser)) {
setSelectedFiles(selectedFiles.filter((i: any) => i.idUser != isData[index].idUser)) setSelectedFiles(selectedFiles.filter((i: any) => i.idUser != isData[index].idUser))
} else { } else {
setSelectedFiles([...selectedFiles, { idUser: isData[index].idUser, name: isData[index].name }]) setSelectedFiles([...selectedFiles, { idUser: isData[index].idUser, name: isData[index].name, img: isData[index].img }])
} }
}; };
@@ -76,7 +75,7 @@ export default function CreateUsersProject({ onClose }: { onClose: (val: any) =>
for (let index = 0; index < isData.length; index++) { for (let index = 0; index < isData.length; index++) {
if (!selectedFiles.some((i: any) => i.idUser == isData[index].idUser)) { if (!selectedFiles.some((i: any) => i.idUser == isData[index].idUser)) {
const newArr = { const newArr = {
idUser: isData[index].idUser, name: isData[index].name idUser: isData[index].idUser, name: isData[index].name, img: isData[index].img
} }
setSelectedFiles((selectedFiles: any) => [...selectedFiles, newArr]) setSelectedFiles((selectedFiles: any) => [...selectedFiles, newArr])
} }
@@ -112,10 +111,10 @@ export default function CreateUsersProject({ onClose }: { onClose: (val: any) =>
<Text c={WARNA.biruTua} fw={"bold"}> <Text c={WARNA.biruTua} fw={"bold"}>
Pilih Semua Anggota Pilih Semua Anggota
</Text> </Text>
{selectAll ? <FaCheck style={{ marginRight: 10 }} /> : ""} <BsListCheck size={25} style={{ marginRight: 5 }} color={WARNA.biruTua}/>
</Group> </Group>
} }
<Box mt={15} mb={60}> <Box mt={15} mb={100}>
{loading ? {loading ?
Array(3) Array(3)
.fill(null) .fill(null)
@@ -146,7 +145,7 @@ export default function CreateUsersProject({ onClose }: { onClose: (val: any) =>
<Box mb={15} key={i} onClick={() => handleFileClick(i)}> <Box mb={15} key={i} onClick={() => handleFileClick(i)}>
<Flex justify={"space-between"} align={"center"}> <Flex justify={"space-between"} align={"center"}>
<Group> <Group>
<Avatar src={"v.image"} alt="it's me" size="lg" /> <Avatar src={`/api/file/img?cat=user&file=${v.img}`} alt="it's me" size="lg" />
<Text style={{ <Text style={{
cursor: 'pointer', cursor: 'pointer',
display: 'flex', display: 'flex',

View File

@@ -46,7 +46,7 @@ export default function Profile() {
await fetch('/api/auth/logout', { await fetch('/api/auth/logout', {
method: 'DELETE', method: 'DELETE',
}); });
toast.success('Logout Success') toast.success('Logout Sukses')
window.location.href = '/'; window.location.href = '/';
} }