"use client"; import { RouterProfile } from "@/app/lib/router_hipmi/router_katalog"; import ComponentGlobal_IsEmptyData from "@/app_modules/component_global/is_empty_data"; import { MODEL_USER } from "@/app_modules/home/model/interface"; import { ActionIcon, Avatar, Box, Center, Grid, Group, Loader, Stack, Text, TextInput, } from "@mantine/core"; import { IconChevronRight, IconSearch } from "@tabler/icons-react"; import _ from "lodash"; import { ScrollOnly } from "next-scroll-loader"; import { useRouter } from "next/navigation"; import { useState } from "react"; import { userSearch_getAllUser } from "../fun/get/get_all_user"; import { MainColor } from "@/app_modules/component_global/color/color_pallet"; import ComponentGlobal_UI_Loader from "@/app_modules/component_global/ui/ui_loader"; export function UserSearch_UiView({ listUser }: { listUser: MODEL_USER[] }) { const [data, setData] = useState(listUser); const [activePage, setActivePage] = useState(1); const [isSearch, setIsSearch] = useState(""); async function onSearch(name: string) { setIsSearch(name); const loadData = await userSearch_getAllUser({ page: activePage, search: name, }); setData(loadData as any); setActivePage(1); } return ( <> } placeholder="Masukan username " onChange={(val) => onSearch(val.target.value)} /> {_.isEmpty(data) ? ( ) : ( (
)} data={data} setData={setData} moreData={async () => { const loadData = await userSearch_getAllUser({ page: activePage + 1, search: isSearch, }); setActivePage((val) => val + 1); return loadData; }} > {(item) => }
)}
{/*
{JSON.stringify(data, null, 2)}
*/} ); } function CardView({ data }: { data: MODEL_USER }) { const router = useRouter(); const [loading, setLoading] = useState(false); return ( <> { setLoading(true); router.push(RouterProfile.katalog + `${data?.Profile?.id}`); }} > {data?.username} +{data?.nomor}
{loading ? ( ) : ( )}
); } let dataDummy = [ { id: "clx8pl7r90005su4mldioo0v1", username: "amalia 1", nomor: "628980185458", active: true, masterUserRoleId: "1", Profile: { id: "clx8ptp7w000esu4ma275qnc8", name: "Amalia Dwi", imagesId: "clx8ptp7m000bsu4mwzbfvd9w", }, }, { id: "clx8pl7r90005su4mldioo0v1", username: "amalia 2", nomor: "628980185458", active: true, masterUserRoleId: "1", Profile: { id: "clx8ptp7w000esu4ma275qnc8", name: "Amalia Dwi", imagesId: "clx8ptp7m000bsu4mwzbfvd9w", }, }, { id: "clx8pl7r90005su4mldioo0v1", username: "amalia 1", nomor: "628980185458", active: true, masterUserRoleId: "1", Profile: { id: "clx8ptp7w000esu4ma275qnc8", name: "Amalia Dwi", imagesId: "clx8ptp7m000bsu4mwzbfvd9w", }, }, { id: "clx8pl7r90005su4mldioo0v1", username: "amalia 2", nomor: "628980185458", active: true, masterUserRoleId: "1", Profile: { id: "clx8ptp7w000esu4ma275qnc8", name: "Amalia Dwi", imagesId: "clx8ptp7m000bsu4mwzbfvd9w", }, }, { id: "clx8pl7r90005su4mldioo0v1", username: "amalia 1", nomor: "628980185458", active: true, masterUserRoleId: "1", Profile: { id: "clx8ptp7w000esu4ma275qnc8", name: "Amalia Dwi", imagesId: "clx8ptp7m000bsu4mwzbfvd9w", }, }, { id: "clx8pl7r90005su4mldioo0v1", username: "amalia 2", nomor: "628980185458", active: true, masterUserRoleId: "1", Profile: { id: "clx8ptp7w000esu4ma275qnc8", name: "Amalia Dwi", imagesId: "clx8ptp7m000bsu4mwzbfvd9w", }, }, { id: "clx8pl7r90005su4mldioo0v1", username: "amalia 1", nomor: "628980185458", active: true, masterUserRoleId: "1", Profile: { id: "clx8ptp7w000esu4ma275qnc8", name: "Amalia Dwi", imagesId: "clx8ptp7m000bsu4mwzbfvd9w", }, }, { id: "clx8pl7r90005su4mldioo0v1", username: "amalia 2", nomor: "628980185458", active: true, masterUserRoleId: "1", Profile: { id: "clx8ptp7w000esu4ma275qnc8", name: "Amalia Dwi", imagesId: "clx8ptp7m000bsu4mwzbfvd9w", }, }, { id: "clx8pl7r90005su4mldioo0v1", username: "amalia 1", nomor: "628980185458", active: true, masterUserRoleId: "1", Profile: { id: "clx8ptp7w000esu4ma275qnc8", name: "Amalia Dwi", imagesId: "clx8ptp7m000bsu4mwzbfvd9w", }, }, { id: "clx8pl7r90005su4mldioo0v1", username: "amalia 2", nomor: "628980185458", active: true, masterUserRoleId: "1", Profile: { id: "clx8ptp7w000esu4ma275qnc8", name: "Amalia Dwi", imagesId: "clx8ptp7m000bsu4mwzbfvd9w", }, }, { id: "clx8pl7r90005su4mldioo0v1", username: "amalia 1", nomor: "628980185458", active: true, masterUserRoleId: "1", Profile: { id: "clx8ptp7w000esu4ma275qnc8", name: "Amalia Dwi", imagesId: "clx8ptp7m000bsu4mwzbfvd9w", }, }, { id: "clx8pl7r90005su4mldioo0v1", username: "amalia 2", nomor: "628980185458", active: true, masterUserRoleId: "1", Profile: { id: "clx8ptp7w000esu4ma275qnc8", name: "Amalia Dwi", imagesId: "clx8ptp7m000bsu4mwzbfvd9w", }, }, { id: "clx8pl7r90005su4mldioo0v1", username: "amalia 1", nomor: "628980185458", active: true, masterUserRoleId: "1", Profile: { id: "clx8ptp7w000esu4ma275qnc8", name: "Amalia Dwi", imagesId: "clx8ptp7m000bsu4mwzbfvd9w", }, }, { id: "clx8pl7r90005su4mldioo0v1", username: "amalia 2", nomor: "628980185458", active: true, masterUserRoleId: "1", Profile: { id: "clx8ptp7w000esu4ma275qnc8", name: "Amalia Dwi", imagesId: "clx8ptp7m000bsu4mwzbfvd9w", }, }, ];