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";
export async function DELETE() {
const log = await createLogUser({ act: 'LOGOUT', desc: 'User keluar dari program', table: 'user', data: '' })
cookies().delete('sessionCookieSDM')
return Response.json({ success: true })

View File

@@ -36,7 +36,8 @@ export async function GET(request: Request, context: { params: { id: string } })
idUser: true,
User: {
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) => ({
..._.omit(v, ["User"]),
name: v.User.name
name: v.User.name,
img: v.User.img
}))
const dataFix = {

View File

@@ -150,7 +150,7 @@ export async function GET(request: Request) {
for (let index = 0; index < dataStatus.length; index++) {
const cek = data.some((i: any) => i.status == dataStatus[index].status)
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 = {
name: dataStatus[index].name,
value: find

View File

@@ -4,6 +4,7 @@ import _ from "lodash";
import { NextResponse } from "next/server";
import path from "path";
import fs from "fs";
import { createLogUser } from "@/module/user";
// 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" });
} catch (error) {
return NextResponse.json({ success: false, message: "Gagal ubah profile" }, { status: 500 });

View File

@@ -2,6 +2,7 @@
import { sealData } from "iron-session";
import { cookies } from "next/headers";
import { prisma, pwd_key_config } from "@/module/_global";
import { createLogUser } from "@/module/user";
export default async function funSetCookies({ user }: { user: string }) {
try {
@@ -11,8 +12,8 @@ export default async function funSetCookies({ user }: { user: string }) {
const dataUser = await prisma.user.findUnique({
where: {
id: user
},
select:{
},
select: {
isFirstLogin: true
}
})
@@ -34,7 +35,7 @@ export default async function funSetCookies({ user }: { user: string }) {
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 };
} catch (error) {

View File

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

View File

@@ -153,7 +153,7 @@ export default function CreateTask() {
borderRadius: 10,
}}
>
<Text c={WARNA.biruTua}>Tambah Anggota</Text>
<Text>Tambah Anggota</Text>
<IoIosArrowDropright size={25} />
</Group>
</Box>
@@ -205,7 +205,7 @@ export default function CreateTask() {
{
member.length > 0 &&
<Box pt={30} mb={60}>
<Box pt={30} mb={100}>
<Group justify="space-between">
<Text c={WARNA.biruTua}>Anggota Terpilih</Text>
<Text c={WARNA.biruTua}>Total {member.length} Anggota</Text>
@@ -229,7 +229,7 @@ export default function CreateTask() {
key={i}
>
<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>
<Text c={WARNA.biruTua} fw={"bold"}>
{v.name}

View File

@@ -4,18 +4,15 @@ import { funGetDivisionById, IDataMemberDivision } from "@/module/division_new";
import { useHookstate } from "@hookstate/core";
import {
ActionIcon,
Anchor,
Avatar,
Box,
Button,
Checkbox,
Divider,
Flex,
Group,
rem,
Skeleton,
Text,
TextInput,
} from "@mantine/core";
import { useShallowEffect } from "@mantine/hooks";
import { useParams, useRouter } from "next/navigation";
@@ -23,6 +20,8 @@ import React, { useState } from "react";
import toast from "react-hot-toast";
import { globalMemberTask } from "../lib/val_task";
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 }) {
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)) {
setSelectedFiles(selectedFiles.filter((i: any) => i.idUser != isData[index].idUser))
} 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++) {
if (!selectedFiles.some((i: any) => i.idUser == isData[index].idUser)) {
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])
}
@@ -112,10 +111,10 @@ export default function CreateUsersProject({ onClose }: { onClose: (val: any) =>
<Text c={WARNA.biruTua} fw={"bold"}>
Pilih Semua Anggota
</Text>
{selectAll ? <FaCheck style={{ marginRight: 10 }} /> : ""}
<BsListCheck size={25} style={{ marginRight: 5 }} color={WARNA.biruTua}/>
</Group>
}
<Box mt={15} mb={60}>
<Box mt={15} mb={100}>
{loading ?
Array(3)
.fill(null)
@@ -146,7 +145,7 @@ export default function CreateUsersProject({ onClose }: { onClose: (val: any) =>
<Box mb={15} key={i} onClick={() => handleFileClick(i)}>
<Flex justify={"space-between"} align={"center"}>
<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={{
cursor: 'pointer',
display: 'flex',

View File

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