rev : tampilkan user role

Deskripsi:
- menampilkan user role pada profile dan detail anggota

No Issues
This commit is contained in:
amel
2025-02-04 12:15:00 +08:00
parent 7bdca4de5d
commit bcd9e98518
6 changed files with 68 additions and 12 deletions

View File

@@ -55,8 +55,9 @@ export async function GET(request: Request, context: { params: { id: string } })
const position = users?.Position.name
const idUserRole = users?.UserRole.id
const phone = users?.phone.substr(2)
const role = users?.UserRole.name
const result = { ...userData, group, position, idUserRole, phone };
const result = { ...userData, group, position, idUserRole, phone, role };
const omitData = _.omit(result, ["Group", "Position", "UserRole"]);

View File

@@ -36,6 +36,11 @@ export async function GET(request: Request) {
select: {
name: true
}
},
UserRole:{
select:{
name: true
}
}
}
})
@@ -43,10 +48,11 @@ export async function GET(request: Request) {
const group = data?.Group.name
const position = data?.Position.name
const phone = data?.phone.substr(2)
const role = data?.UserRole.name
const omitData = _.omit(data, ["Group", "Position", "phone"])
const omitData = _.omit(data, ["Group", "Position", "phone", "UserRole"]);
const result = { ...userData, group, position, phone };
const result = { ...userData, group, position, phone, role };
return NextResponse.json({ success: true, data: result });
} catch (error) {

View File

@@ -8,7 +8,8 @@ export interface IListMember {
position: string,
group: string,
img: string,
isActive: boolean
isActive: boolean,
role: string
}
export interface IFormMember {

View File

@@ -5,7 +5,7 @@ import { ActionIcon, Avatar, Box, Center, Grid, Group, Skeleton, Stack, Text } f
import { useShallowEffect } from "@mantine/hooks";
import { useState } from "react";
import toast from "react-hot-toast";
import { FaSquarePhone } from "react-icons/fa6";
import { FaBuildingUser, FaSquarePhone } from "react-icons/fa6";
import { HiMenu } from "react-icons/hi";
import { IoMaleFemale } from "react-icons/io5";
import { MdEmail } from "react-icons/md";
@@ -14,6 +14,8 @@ import { valueRoleUser } from "../../lib/val_user";
import { funGetOneMember } from "../lib/api_member";
import { IListMember, IMember } from "../lib/type_member";
import DrawerDetailMember from "./drawer_detail_member";
import { BiSolidUserBadge } from "react-icons/bi";
import { PiGenderIntersexFill } from "react-icons/pi";
export default function NavbarDetailMember({ id }: IMember) {
@@ -47,7 +49,7 @@ export default function NavbarDetailMember({ id }: IMember) {
setLoading(false)
} catch (error) {
console.error(error)
toast.error("Gagal mendapatkan detail user, coba lagi nanti");
toast.error("Gagal mendapatkan detail anggota, coba lagi nanti");
} finally {
setLoading(false)
}
@@ -89,7 +91,7 @@ export default function NavbarDetailMember({ id }: IMember) {
:
<>
<Text c={'white'} fw={'bold'} fz={25} ta={"center"}>{dataOne?.name}</Text>
<Text c={'white'} fw={'lighter'} fz={15}>{dataOne?.group} - {dataOne?.position}</Text>
<Text c={'white'} fw={'lighter'} fz={15}>{dataOne?.role}</Text>
</>
}
</Stack>
@@ -113,6 +115,28 @@ export default function NavbarDetailMember({ id }: IMember) {
<Text fz={15} fw={'bold'} ta={"right"}>{dataOne?.nik}</Text>
</Grid.Col>
</Grid>
<Grid>
<Grid.Col span={5}>
<Group>
<FaBuildingUser size={25} />
<Text fz={15}>Lembaga Desa</Text>
</Group>
</Grid.Col>
<Grid.Col span={7}>
<Text fz={15} fw={'bold'} ta={"right"}>{dataOne?.group}</Text>
</Grid.Col>
</Grid>
<Grid>
<Grid.Col span={4}>
<Group>
<BiSolidUserBadge size={25} />
<Text fz={15}>Jabatan</Text>
</Group>
</Grid.Col>
<Grid.Col span={8}>
<Text fz={15} fw={'bold'} ta={"right"}>{dataOne?.position}</Text>
</Grid.Col>
</Grid>
<Grid>
<Grid.Col span={5}>
<Group>
@@ -138,7 +162,7 @@ export default function NavbarDetailMember({ id }: IMember) {
<Grid>
<Grid.Col span={6}>
<Group>
<IoMaleFemale size={25} />
<PiGenderIntersexFill size={25} />
<Text fz={15}>Jenis Kelamin</Text>
</Group>
</Grid.Col>

View File

@@ -9,6 +9,7 @@ export interface IProfileById {
idPosition: string
group: string
position: string
role:string
}
export interface IEditDataProfile {

View File

@@ -7,10 +7,11 @@ import { useShallowEffect } from "@mantine/hooks";
import { useRouter } from "next/navigation";
import { useState } from "react";
import toast from "react-hot-toast";
import { FaSquarePhone } from "react-icons/fa6";
import { IoMaleFemale } from "react-icons/io5";
import { BiSolidUserBadge } from "react-icons/bi";
import { FaBuildingUser, FaSquarePhone } from "react-icons/fa6";
import { LuLogOut } from "react-icons/lu";
import { MdEmail } from "react-icons/md";
import { PiGenderIntersexFill } from "react-icons/pi";
import { RiIdCardFill } from "react-icons/ri";
import { funGetProfileByCookies } from "../lib/api_profile";
import { IProfileById } from "../lib/type_profile";
@@ -88,7 +89,7 @@ export default function Profile() {
:
<>
<Text c={'white'} fw={'bold'} fz={25} ta={"center"}>{isData?.name}</Text>
<Text c={'white'} fw={'lighter'} fz={15}>{isData?.group} - {isData?.position}</Text>
<Text c={'white'} fw={'lighter'} fz={15}>{isData?.role}</Text>
</>
}
</Stack>
@@ -115,6 +116,28 @@ export default function Profile() {
<Text fz={15} fw={'bold'} ta={"right"}>{isData?.nik}</Text>
</Grid.Col>
</Grid>
<Grid>
<Grid.Col span={5}>
<Group>
<FaBuildingUser size={25} />
<Text fz={15}>Lembaga Desa</Text>
</Group>
</Grid.Col>
<Grid.Col span={7}>
<Text fz={15} fw={'bold'} ta={"right"}>{isData?.group}</Text>
</Grid.Col>
</Grid>
<Grid>
<Grid.Col span={4}>
<Group>
<BiSolidUserBadge size={25} />
<Text fz={15}>Jabatan</Text>
</Group>
</Grid.Col>
<Grid.Col span={8}>
<Text fz={15} fw={'bold'} ta={"right"}>{isData?.position}</Text>
</Grid.Col>
</Grid>
<Grid>
<Grid.Col span={5}>
<Group>
@@ -140,7 +163,7 @@ export default function Profile() {
<Grid>
<Grid.Col span={6}>
<Group>
<IoMaleFemale size={25} />
<PiGenderIntersexFill size={25} />
<Text fz={15}>Jenis Kelamin</Text>
</Group>
</Grid.Col>