upd: user role

Desrkipsi:
- global state pada user role login
- update fitur home

No Issues
This commit is contained in:
amel
2025-04-29 11:01:36 +08:00
parent b4c560b88e
commit 9b471eb269
4 changed files with 36 additions and 26 deletions

View File

@@ -1,6 +1,7 @@
import Styles from "@/constants/Styles";
import { apiGetBanner } from "@/lib/api";
import { apiGetBanner, apiGetProfile } from "@/lib/api";
import { setEntities } from "@/lib/bannerSlice";
import { setEntityUser } from "@/lib/userSlice";
import { useAuthSession } from "@/providers/AuthProvider";
import React, { useEffect } from "react";
import { Dimensions, Image, View } from "react-native";
@@ -15,16 +16,27 @@ export default function CaraouselHome() {
const progress = useSharedValue<number>(0);
const dispatch = useDispatch()
const entities = useSelector((state: any) => state.banner)
const entityUser = useSelector((state: any) => state.user)
async function handleBannerView() {
const hasil = await decryptToken(String(token?.current))
apiGetBanner({ user: hasil }).then((data) => dispatch(setEntities(data.data)))
}
async function handleUser() {
const hasil = await decryptToken(String(token?.current))
const response = await apiGetProfile({ id: hasil })
dispatch(setEntityUser({ role: response.data.idUserRole, admin: false }))
}
useEffect(() => {
handleBannerView()
}, [dispatch]);
useEffect(() => {
handleUser()
}, []);
return (
<View style={[Styles.mv15]}>
<Carousel