rev : tampilkan user role
Deskripsi: - menampilkan user role pada profile dan detail anggota No Issues
This commit is contained in:
@@ -55,8 +55,9 @@ export async function GET(request: Request, context: { params: { id: string } })
|
|||||||
const position = users?.Position.name
|
const position = users?.Position.name
|
||||||
const idUserRole = users?.UserRole.id
|
const idUserRole = users?.UserRole.id
|
||||||
const phone = users?.phone.substr(2)
|
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"]);
|
const omitData = _.omit(result, ["Group", "Position", "UserRole"]);
|
||||||
|
|
||||||
|
|||||||
@@ -36,6 +36,11 @@ export async function GET(request: Request) {
|
|||||||
select: {
|
select: {
|
||||||
name: true
|
name: true
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
UserRole:{
|
||||||
|
select:{
|
||||||
|
name: true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@@ -43,10 +48,11 @@ export async function GET(request: Request) {
|
|||||||
const group = data?.Group.name
|
const group = data?.Group.name
|
||||||
const position = data?.Position.name
|
const position = data?.Position.name
|
||||||
const phone = data?.phone.substr(2)
|
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 });
|
return NextResponse.json({ success: true, data: result });
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|||||||
@@ -8,7 +8,8 @@ export interface IListMember {
|
|||||||
position: string,
|
position: string,
|
||||||
group: string,
|
group: string,
|
||||||
img: string,
|
img: string,
|
||||||
isActive: boolean
|
isActive: boolean,
|
||||||
|
role: string
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface IFormMember {
|
export interface IFormMember {
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import { ActionIcon, Avatar, Box, Center, Grid, Group, Skeleton, Stack, Text } f
|
|||||||
import { useShallowEffect } from "@mantine/hooks";
|
import { useShallowEffect } from "@mantine/hooks";
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
import toast from "react-hot-toast";
|
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 { HiMenu } from "react-icons/hi";
|
||||||
import { IoMaleFemale } from "react-icons/io5";
|
import { IoMaleFemale } from "react-icons/io5";
|
||||||
import { MdEmail } from "react-icons/md";
|
import { MdEmail } from "react-icons/md";
|
||||||
@@ -14,6 +14,8 @@ import { valueRoleUser } from "../../lib/val_user";
|
|||||||
import { funGetOneMember } from "../lib/api_member";
|
import { funGetOneMember } from "../lib/api_member";
|
||||||
import { IListMember, IMember } from "../lib/type_member";
|
import { IListMember, IMember } from "../lib/type_member";
|
||||||
import DrawerDetailMember from "./drawer_detail_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) {
|
export default function NavbarDetailMember({ id }: IMember) {
|
||||||
@@ -47,7 +49,7 @@ export default function NavbarDetailMember({ id }: IMember) {
|
|||||||
setLoading(false)
|
setLoading(false)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(error)
|
console.error(error)
|
||||||
toast.error("Gagal mendapatkan detail user, coba lagi nanti");
|
toast.error("Gagal mendapatkan detail anggota, coba lagi nanti");
|
||||||
} finally {
|
} finally {
|
||||||
setLoading(false)
|
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={'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>
|
</Stack>
|
||||||
@@ -113,6 +115,28 @@ export default function NavbarDetailMember({ id }: IMember) {
|
|||||||
<Text fz={15} fw={'bold'} ta={"right"}>{dataOne?.nik}</Text>
|
<Text fz={15} fw={'bold'} ta={"right"}>{dataOne?.nik}</Text>
|
||||||
</Grid.Col>
|
</Grid.Col>
|
||||||
</Grid>
|
</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>
|
||||||
<Grid.Col span={5}>
|
<Grid.Col span={5}>
|
||||||
<Group>
|
<Group>
|
||||||
@@ -138,7 +162,7 @@ export default function NavbarDetailMember({ id }: IMember) {
|
|||||||
<Grid>
|
<Grid>
|
||||||
<Grid.Col span={6}>
|
<Grid.Col span={6}>
|
||||||
<Group>
|
<Group>
|
||||||
<IoMaleFemale size={25} />
|
<PiGenderIntersexFill size={25} />
|
||||||
<Text fz={15}>Jenis Kelamin</Text>
|
<Text fz={15}>Jenis Kelamin</Text>
|
||||||
</Group>
|
</Group>
|
||||||
</Grid.Col>
|
</Grid.Col>
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ export interface IProfileById {
|
|||||||
idPosition: string
|
idPosition: string
|
||||||
group: string
|
group: string
|
||||||
position: string
|
position: string
|
||||||
|
role:string
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface IEditDataProfile {
|
export interface IEditDataProfile {
|
||||||
|
|||||||
@@ -7,10 +7,11 @@ import { useShallowEffect } from "@mantine/hooks";
|
|||||||
import { useRouter } from "next/navigation";
|
import { useRouter } from "next/navigation";
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
import toast from "react-hot-toast";
|
import toast from "react-hot-toast";
|
||||||
import { FaSquarePhone } from "react-icons/fa6";
|
import { BiSolidUserBadge } from "react-icons/bi";
|
||||||
import { IoMaleFemale } from "react-icons/io5";
|
import { FaBuildingUser, FaSquarePhone } from "react-icons/fa6";
|
||||||
import { LuLogOut } from "react-icons/lu";
|
import { LuLogOut } from "react-icons/lu";
|
||||||
import { MdEmail } from "react-icons/md";
|
import { MdEmail } from "react-icons/md";
|
||||||
|
import { PiGenderIntersexFill } from "react-icons/pi";
|
||||||
import { RiIdCardFill } from "react-icons/ri";
|
import { RiIdCardFill } from "react-icons/ri";
|
||||||
import { funGetProfileByCookies } from "../lib/api_profile";
|
import { funGetProfileByCookies } from "../lib/api_profile";
|
||||||
import { IProfileById } from "../lib/type_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={'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>
|
</Stack>
|
||||||
@@ -115,6 +116,28 @@ export default function Profile() {
|
|||||||
<Text fz={15} fw={'bold'} ta={"right"}>{isData?.nik}</Text>
|
<Text fz={15} fw={'bold'} ta={"right"}>{isData?.nik}</Text>
|
||||||
</Grid.Col>
|
</Grid.Col>
|
||||||
</Grid>
|
</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>
|
||||||
<Grid.Col span={5}>
|
<Grid.Col span={5}>
|
||||||
<Group>
|
<Group>
|
||||||
@@ -140,7 +163,7 @@ export default function Profile() {
|
|||||||
<Grid>
|
<Grid>
|
||||||
<Grid.Col span={6}>
|
<Grid.Col span={6}>
|
||||||
<Group>
|
<Group>
|
||||||
<IoMaleFemale size={25} />
|
<PiGenderIntersexFill size={25} />
|
||||||
<Text fz={15}>Jenis Kelamin</Text>
|
<Text fz={15}>Jenis Kelamin</Text>
|
||||||
</Group>
|
</Group>
|
||||||
</Grid.Col>
|
</Grid.Col>
|
||||||
|
|||||||
Reference in New Issue
Block a user