- PC: Loader chat
- QC: Auth , Profile, portofolio & user search
## No Issuue
git commit -m
This commit is contained in:
2024-05-16 10:03:34 +08:00
parent c57e495d68
commit 66b9902d97
74 changed files with 1336 additions and 622 deletions

View File

@@ -0,0 +1,13 @@
"use client";
import { Center } from "@mantine/core";
export default function ComponentUserSearch_IsEmptyData({ text }: { text: string }) {
return (
<>
<Center h={"50vh"} fz={"sm"} c="gray" fw={"bold"} style={{ zIndex: 1 }}>
{text}
</Center>
</>
);
}

View File

@@ -1,11 +1,49 @@
"use server";
import prisma from "@/app/lib/prisma";
import { user_getOneUserId } from "@/app_modules/fun_global/get_user_token";
export async function UserSearch_getListUser() {
const data = await prisma.user.findMany({
export async function UserSearch_getListUser({ name }: { name: string }) {
const userLoginId = await user_getOneUserId();
if (name === "") {
const data = await prisma.user.findMany({
where: {
masterUserRoleId: "1",
NOT: {
id: userLoginId,
},
},
select: {
id: true,
username: true,
nomor: true,
active: true,
masterUserRoleId: true,
Profile: {
select: {
id: true,
name: true,
imagesId: true,
},
},
},
});
return data;
}
const getDataCari = await prisma.user.findMany({
where: {
masterUserRoleId: "1"
masterUserRoleId: "1",
Profile: {
name: {
contains: name,
mode: "insensitive",
},
},
NOT: {
id: userLoginId,
},
},
select: {
id: true,
@@ -13,14 +51,9 @@ export async function UserSearch_getListUser() {
nomor: true,
active: true,
masterUserRoleId: true,
Profile: {
select: {
id: true,
name: true,
imagesId: true,
},
},
Profile: true,
},
});
return data;
return getDataCari;
}

View File

@@ -14,7 +14,6 @@ export async function UserSearch_searchByName(name: string) {
},
},
},
take: 10,
select: {
id: true,
username: true,

View File

@@ -21,6 +21,10 @@ import { UserSearch_searchByName } from "../fun/search/fun_search_by_name";
import { useRouter } from "next/navigation";
import ComponentGlobal_MaintenanceInformation from "@/app_modules/component_global/maintenance_information";
import ComponentGlobal_V2_LoadingPage from "@/app_modules/component_global/loading_page_v2";
import { data } from "autoprefixer";
import { UserSearch_getListUser } from "../fun/get/get_list_user";
import _ from "lodash";
import ComponentUserSearch_IsEmptyData from "../component/is_empty_data";
export default function UserSearch_MainView({
listUser,
@@ -28,11 +32,13 @@ export default function UserSearch_MainView({
listUser: MODEL_USER[];
}) {
const router = useRouter();
const [user, setUser] = useState(listUser);
const [data, setData] = useState(listUser);
const [loading, setLoading] = useState(false);
async function onSearch(name: string) {
await UserSearch_searchByName(name).then((res) => setUser(res as any));
await UserSearch_getListUser({ name: name }).then((res) =>
setData(res as any)
);
}
// return (
@@ -43,75 +49,83 @@ export default function UserSearch_MainView({
// </>
// );
if(loading) return <ComponentGlobal_V2_LoadingPage/>
if (loading) return <ComponentGlobal_V2_LoadingPage />;
return (
<>
<Box>
{/* <pre>{JSON.stringify(user, null,2)}</pre>r */}
<Stack spacing={"md"}>
<TextInput
style={{ zIndex: 99 }}
pos={"sticky"}
top={"6vh"}
icon={<IconSearch size={20} />}
placeholder="Masukan nama pegguna"
onChange={(val) => onSearch(val.target.value)}
/>
{!user ? (
""
) : (
<Box>
{user?.map((e) =>
e.Profile === null ? (
""
) : (
<Stack key={e.id} spacing={"xs"} mt={"xs"}>
<Grid>
<Grid.Col span={2}>
<Center h={"100%"}>
<Avatar
sx={{ borderStyle: "solid", borderWidth: "0.5px" }}
radius={"xl"}
size={"md"}
src={
RouterProfile.api_foto_profile +
`${e?.Profile?.imagesId}`
}
/>
</Center>
</Grid.Col>
<Grid.Col span={"auto"}>
<Stack spacing={0}>
<Text fw={"bold"} lineClamp={1}>
{e?.Profile?.name}
</Text>
<Text fz={"sm"} fs={"italic"}>
+{e?.nomor}
</Text>
</Stack>
</Grid.Col>
<Grid.Col span={2}>
<Center h={"100%"}>
<ActionIcon
variant="transparent"
onClick={() => {
setLoading(true);
router.push(
RouterProfile.katalog + `${e?.Profile?.id}`
);
}}
>
<IconChevronRight />
</ActionIcon>
</Center>
</Grid.Col>
</Grid>
<Divider />
</Stack>
)
)}
</Box>
)}
<Box>
{_.isEmpty(data) ? (
<ComponentUserSearch_IsEmptyData text="Tidak ada pengguna" />
) : (
<Box>
{data?.map((e, i) =>
e?.Profile === null ? (
""
) : (
<Stack key={i} spacing={"xs"} mt={"xs"}>
<Grid>
<Grid.Col span={2}>
<Center h={"100%"}>
<Avatar
sx={{
borderStyle: "solid",
borderWidth: "0.5px",
}}
radius={"xl"}
size={"md"}
src={
RouterProfile?.api_foto_profile +
`${e?.Profile?.imagesId}`
}
/>
</Center>
</Grid.Col>
<Grid.Col span={"auto"}>
<Stack spacing={0}>
<Text fw={"bold"} lineClamp={1}>
{e?.Profile?.name}
</Text>
<Text fz={"sm"} fs={"italic"}>
+{e?.nomor}
</Text>
</Stack>
</Grid.Col>
<Grid.Col span={2}>
<Center h={"100%"}>
<ActionIcon
variant="transparent"
onClick={() => {
setLoading(true);
router.push(
RouterProfile.katalog + `${e?.Profile?.id}`
);
}}
>
<IconChevronRight />
</ActionIcon>
</Center>
</Grid.Col>
</Grid>
<Divider />
</Stack>
)
)}
</Box>
)}
</Box>
</Stack>
</Box>
{/* <pre>{JSON.stringify(data, null, 2)}</pre> */}
</>
);
}