update Typeahead.tsx, typeahead-opt.tsx, TableList.tsx and axios.ts

This commit is contained in:
faisolavolut 2025-02-04 10:33:13 +07:00
parent ca52720715
commit 3532415aba
3 changed files with 37 additions and 26 deletions

View File

@ -513,6 +513,7 @@ export const Typeahead: FC<{
resetSearch();
}
}}
loading={local.loading}
showEmpty={!allow_new}
className={popupClassName}
open={local.open}

View File

@ -6,6 +6,7 @@ import { ButtonBetter } from "../../ui/button";
export type OptionItem = { value: string; label: string };
export const TypeaheadOptions: FC<{
popup?: boolean;
loading?: boolean;
open?: boolean;
children: any;
onOpenChange?: (open: boolean) => void;
@ -25,6 +26,7 @@ export const TypeaheadOptions: FC<{
fitur?: "search-add";
}> = ({
popup,
loading,
children,
open,
onOpenChange,
@ -61,6 +63,8 @@ export const TypeaheadOptions: FC<{
`
)}
>
{!loading ? (
<>
{options.map((item, idx) => {
const is_selected = selected?.({ item, options, idx });
@ -85,9 +89,15 @@ export const TypeaheadOptions: FC<{
</div>
);
})}
</>
) : (
<></>
)}
{searching ? (
<div className="px-4 w-full text-slate-400">Loading...</div>
{loading || searching ? (
<div className="px-4 w-full text-slate-400 text-sm py-2">
Loading...
</div>
) : (
<>
{options.length === 0 && (

View File

@ -1,12 +1,12 @@
import axios from "axios";
import Cookies from "js-cookie";
import dotenv from 'dotenv';
import dotenv from "dotenv";
dotenv.config();
// Buat instance Axios
const api = axios.create({
baseURL: process.env.NEXT_PUBLIC_API_BASE_URL || "https://api.example.com", // Ganti dengan URL API Anda
timeout: 10000, // Timeout dalam milidetik
timeout: 60000, // Timeout dalam milidetik
withCredentials: true, // Kirim cookie otomatis dengan setiap permintaan
});
// Interceptor untuk menambahkan token dari cookie ke header Authorization (jika diperlukan)