From bc883640584fe80694aedbe153b864252d86e716 Mon Sep 17 00:00:00 2001 From: Wikzyy Date: Mon, 21 Apr 2025 11:38:57 +0700 Subject: [PATCH] update remove fetch roles to optimize performance --- .../dashboards/home/DashboardHomePage.tsx | 38 ++----------------- 1 file changed, 4 insertions(+), 34 deletions(-) diff --git a/src/pages/dashboards/home/DashboardHomePage.tsx b/src/pages/dashboards/home/DashboardHomePage.tsx index 856d7d1..22d69b9 100644 --- a/src/pages/dashboards/home/DashboardHomePage.tsx +++ b/src/pages/dashboards/home/DashboardHomePage.tsx @@ -26,16 +26,8 @@ type CountType = 'sum' | 'count'; type ChartType = 'line' | 'bar'; type ChartLegend = 'true' | 'false'; -type RoleType = { - id: string; - name: string; -}; - -const API_URL_DASHBOARD = apiConfig.service_dashboard; - const DashboardHomePage = () => { const selectYear = get5LastYear(); - const { GetData } = useCallApi(); const [initialYear, setInitialYear] = useState(''); const [selectedYear, setSelectedYear] = useState(''); const [count, setCount] = useState('sum'); @@ -45,31 +37,9 @@ const DashboardHomePage = () => { from: new Date(), to: new Date() }); - const [roles, setRoles] = useState([]); - const parsedUser = getAuth()?.user; - const idCustomer = parsedUser?.customer?.id; - const roleCustomer = parsedUser.idRole; - const currentRole = roles.find((role) => role.id === roleCustomer)?.name?.toLowerCase(); - console.log(currentRole); - - useEffect(() => { - async function fetchRoles(sorting: any) { - try { - const response = await GetData(`${API_URL_DASHBOARD}/user_role/list`, { - limit: 100, - page: 1, - with_deleted: false, - order_field: sorting[0].id, - order_direction: sorting[0].desc == false ? 'ASC' : 'DESC' - }); - setRoles(response?.data.list); - } catch (error) { - console.error('Error fetching roles', error); - } - } - - fetchRoles([{ id: 'name', desc: false }]); - }, []); + const currentRole = getAuth()?.role_name; + const idCustomer = getAuth()?.user.customer?.id; + // console.log(currentRole); // Menyusun tanggal awal dan akhir berdasarkan selectedYear useEffect(() => { @@ -182,7 +152,7 @@ const DashboardHomePage = () => { {/* Account Balance Cards */} - {currentRole === 'escrow' || currentRole === 'master agent' ? ( + {currentRole === 'Escrow' || currentRole === 'Master Agent' ? (