upd: user role
Desrkipsi: - global state pada user role login - update fitur home No Issues
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user