update Typeahead.tsx, typeahead-opt.tsx, TableList.tsx and axios.ts
This commit is contained in:
parent
ca52720715
commit
3532415aba
|
|
@ -513,6 +513,7 @@ export const Typeahead: FC<{
|
||||||
resetSearch();
|
resetSearch();
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
|
loading={local.loading}
|
||||||
showEmpty={!allow_new}
|
showEmpty={!allow_new}
|
||||||
className={popupClassName}
|
className={popupClassName}
|
||||||
open={local.open}
|
open={local.open}
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@ import { ButtonBetter } from "../../ui/button";
|
||||||
export type OptionItem = { value: string; label: string };
|
export type OptionItem = { value: string; label: string };
|
||||||
export const TypeaheadOptions: FC<{
|
export const TypeaheadOptions: FC<{
|
||||||
popup?: boolean;
|
popup?: boolean;
|
||||||
|
loading?: boolean;
|
||||||
open?: boolean;
|
open?: boolean;
|
||||||
children: any;
|
children: any;
|
||||||
onOpenChange?: (open: boolean) => void;
|
onOpenChange?: (open: boolean) => void;
|
||||||
|
|
@ -25,6 +26,7 @@ export const TypeaheadOptions: FC<{
|
||||||
fitur?: "search-add";
|
fitur?: "search-add";
|
||||||
}> = ({
|
}> = ({
|
||||||
popup,
|
popup,
|
||||||
|
loading,
|
||||||
children,
|
children,
|
||||||
open,
|
open,
|
||||||
onOpenChange,
|
onOpenChange,
|
||||||
|
|
@ -61,6 +63,8 @@ export const TypeaheadOptions: FC<{
|
||||||
`
|
`
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
|
{!loading ? (
|
||||||
|
<>
|
||||||
{options.map((item, idx) => {
|
{options.map((item, idx) => {
|
||||||
const is_selected = selected?.({ item, options, idx });
|
const is_selected = selected?.({ item, options, idx });
|
||||||
|
|
||||||
|
|
@ -85,9 +89,15 @@ export const TypeaheadOptions: FC<{
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
|
</>
|
||||||
|
) : (
|
||||||
|
<></>
|
||||||
|
)}
|
||||||
|
|
||||||
{searching ? (
|
{loading || searching ? (
|
||||||
<div className="px-4 w-full text-slate-400">Loading...</div>
|
<div className="px-4 w-full text-slate-400 text-sm py-2">
|
||||||
|
Loading...
|
||||||
|
</div>
|
||||||
) : (
|
) : (
|
||||||
<>
|
<>
|
||||||
{options.length === 0 && (
|
{options.length === 0 && (
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,12 @@
|
||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
import Cookies from "js-cookie";
|
import Cookies from "js-cookie";
|
||||||
import dotenv from 'dotenv';
|
import dotenv from "dotenv";
|
||||||
|
|
||||||
dotenv.config();
|
dotenv.config();
|
||||||
// Buat instance Axios
|
// Buat instance Axios
|
||||||
const api = axios.create({
|
const api = axios.create({
|
||||||
baseURL: process.env.NEXT_PUBLIC_API_BASE_URL || "https://api.example.com", // Ganti dengan URL API Anda
|
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
|
withCredentials: true, // Kirim cookie otomatis dengan setiap permintaan
|
||||||
});
|
});
|
||||||
// Interceptor untuk menambahkan token dari cookie ke header Authorization (jika diperlukan)
|
// Interceptor untuk menambahkan token dari cookie ke header Authorization (jika diperlukan)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue