diff --git a/components/form/login.tsx b/components/form/login.tsx index af7a3c8..bd1735d 100644 --- a/components/form/login.tsx +++ b/components/form/login.tsx @@ -68,6 +68,7 @@ export default function Login() { if (!username || !password) { error("Username & Password Wajib Diisi !"); } else { + // login dengan otp const response = await emailValidation(data); if (response?.error) { error("Username / Password Tidak Sesuai"); @@ -80,6 +81,7 @@ export default function Login() { setNeedOtp(true); } + // login tanpa otp // loading(); // const response = await postSignIn(data); // if (response?.error) { @@ -152,7 +154,6 @@ export default function Login() { // close(); // } } - // } }; const checkUsername = async () => { diff --git a/components/table/master-user-table.tsx b/components/table/master-user-table.tsx index 9616ec1..797bc18 100644 --- a/components/table/master-user-table.tsx +++ b/components/table/master-user-table.tsx @@ -4,12 +4,14 @@ import { DeleteIcon, DotsYIcon, EyeIconMdi, + SearchIcon, } from "@/components/icons"; import { error, success } from "@/config/swal"; import { deleteArticle, getListArticle } from "@/services/article"; import { deleteMasterUser, listMasterUsers } from "@/services/master-user"; import { Article, MasterUser } from "@/types/globals"; import { Button } from "@heroui/button"; +import { Input } from "@heroui/input"; import { Chip, ChipProps, @@ -18,6 +20,8 @@ import { DropdownMenu, DropdownTrigger, Pagination, + Select, + SelectItem, Spinner, Table, TableBody, @@ -48,13 +52,22 @@ export default function MasterUserTable() { const [user, setUser] = useState([]); const [page, setPage] = useState(1); const [totalPage, setTotalPage] = useState(1); + const [showData, setShowData] = useState("10"); + const [search, setSearch] = useState(""); + const [searchType, setSearchType] = useState("username"); useEffect(() => { initState(); - }, [page]); + }, [page, showData]); async function initState() { - const res = await listMasterUsers({ page: page, limit: 10 }); + const res = await listMasterUsers({ + page: page, + limit: Number(showData), + fullname: searchType === "fullname" ? search : "", + username: searchType === "username" ? search : "", + email: searchType === "email" ? search : "", + }); getTableNumber(10, res?.data?.data); setTotalPage(res?.data?.meta?.totalPage); } @@ -175,10 +188,85 @@ export default function MasterUserTable() { } }, []); + let typingTimer: NodeJS.Timeout; + const doneTypingInterval = 1500; + + const handleKeyUp = () => { + clearTimeout(typingTimer); + typingTimer = setTimeout(doneTyping, doneTypingInterval); + }; + + const handleKeyDown = () => { + clearTimeout(typingTimer); + }; + + async function doneTyping() { + initState(); + } + return ( <>
+
+
+

Pencarian

+ + } + type="text" + onChange={(e) => setSearch(e.target.value)} + onKeyUp={handleKeyUp} + onKeyDown={handleKeyDown} + endContent={ + + } + /> +
+
+

Data

+ +
+