upd: member
Deskripsi: - load member - search member - filter member - active member - tambah member nb: blm bisa upload gambar No Issues
This commit is contained in:
@@ -1,13 +1,57 @@
|
||||
import BorderBottomItem from "@/components/borderBottomItem";
|
||||
import ButtonTab from "@/components/buttonTab";
|
||||
import ImageUser from "@/components/imageNew";
|
||||
import InputSearch from "@/components/inputSearch";
|
||||
import Styles from "@/constants/Styles";
|
||||
import { apiGetUser } from "@/lib/api";
|
||||
import { useAuthSession } from "@/providers/AuthProvider";
|
||||
import { AntDesign, Feather } from "@expo/vector-icons";
|
||||
import { router, useLocalSearchParams } from "expo-router";
|
||||
import { Image, SafeAreaView, ScrollView, Text, View } from "react-native";
|
||||
import { useEffect, useState } from "react";
|
||||
import { SafeAreaView, ScrollView, Text, View } from "react-native";
|
||||
import { useDispatch, useSelector } from "react-redux";
|
||||
|
||||
type Props = {
|
||||
id: string,
|
||||
name: string,
|
||||
nik: string,
|
||||
email: string,
|
||||
phone: string,
|
||||
gender: string,
|
||||
position: string,
|
||||
group: string,
|
||||
img: string,
|
||||
isActive: boolean,
|
||||
role: string
|
||||
}
|
||||
|
||||
export default function Index() {
|
||||
const { active } = useLocalSearchParams<{ active?: string }>()
|
||||
const { active, group } = useLocalSearchParams<{ active?: string, group?: string }>()
|
||||
const { token, decryptToken } = useAuthSession()
|
||||
const entityUser = useSelector((state: any) => state.user)
|
||||
const [search, setSearch] = useState('')
|
||||
const [nameGroup, setNameGroup] = useState('')
|
||||
const [data, setData] = useState<Props[]>([])
|
||||
const dispatch = useDispatch()
|
||||
const update = useSelector((state: any) => state.memberUpdate)
|
||||
|
||||
async function handleLoad() {
|
||||
try {
|
||||
const hasil = await decryptToken(String(token?.current))
|
||||
const response = await apiGetUser({ user: hasil, active: String(active), search: search, group: String(group) })
|
||||
setData(response.data)
|
||||
setNameGroup(response.filter.name)
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
}
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
handleLoad()
|
||||
}, [active, search, group, update])
|
||||
|
||||
|
||||
|
||||
|
||||
return (
|
||||
<SafeAreaView>
|
||||
@@ -17,100 +61,47 @@ export default function Index() {
|
||||
<ButtonTab
|
||||
active={active == "false" ? "false" : "true"}
|
||||
value="true"
|
||||
onPress={() => { router.push('/member?active=true') }}
|
||||
onPress={() => { router.push(`/member?active=true&group=${group}&search=${search}`) }}
|
||||
label="Aktif"
|
||||
icon={<Feather name="check-circle" color={active == "false" ? 'black' : 'white'} size={20} />}
|
||||
n={2} />
|
||||
<ButtonTab
|
||||
active={active == "false" ? "false" : "true"}
|
||||
value="false"
|
||||
onPress={() => { router.push('/member?active=false') }}
|
||||
onPress={() => { router.push(`/member?active=false&group=${group}&search=${search}`) }}
|
||||
label="Tidak Aktif"
|
||||
icon={<AntDesign name="closecircleo" color={active == "false" ? 'white' : 'black'} size={20} />}
|
||||
n={2} />
|
||||
</View>
|
||||
<InputSearch />
|
||||
<View style={[Styles.mv05]}>
|
||||
<Text>Filter : Dinas</Text>
|
||||
</View>
|
||||
<InputSearch onChange={setSearch} />
|
||||
{
|
||||
(entityUser.role == "supadmin" || entityUser.role == "developer") &&
|
||||
<View style={[Styles.mv05]}>
|
||||
<Text>Filter : {nameGroup}</Text>
|
||||
</View>
|
||||
}
|
||||
<View>
|
||||
<BorderBottomItem
|
||||
onPress={() => {router.push('/member/1')}}
|
||||
borderType="all"
|
||||
icon={
|
||||
<Image
|
||||
source={require("../../../assets/images/user.jpeg")}
|
||||
style={[Styles.userProfileSmall]}
|
||||
/>
|
||||
}
|
||||
title="Amalia Dwi"
|
||||
subtitle="Dinas - Sekretaris"
|
||||
/>
|
||||
{
|
||||
data.length > 0
|
||||
?
|
||||
data.map((item, index) => {
|
||||
return (
|
||||
<BorderBottomItem
|
||||
key={index}
|
||||
onPress={() => { router.push(`/member/${item.id}`) }}
|
||||
borderType="all"
|
||||
icon={
|
||||
<ImageUser src={`https://wibu-storage.wibudev.com/api/files/${item.img}`} />
|
||||
}
|
||||
title={item.name}
|
||||
subtitle={`${item.group} - ${item.position}`}
|
||||
/>
|
||||
)
|
||||
})
|
||||
:
|
||||
<Text style={[Styles.textDefault, Styles.cGray, { textAlign: 'center' }]}>Tidak ada data</Text>
|
||||
|
||||
<BorderBottomItem
|
||||
onPress={() => {router.push('/member/1')}}
|
||||
borderType="all"
|
||||
icon={
|
||||
<Image
|
||||
source={require("../../../assets/images/user.jpeg")}
|
||||
style={[Styles.userProfileSmall]}
|
||||
/>
|
||||
}
|
||||
title="Amalia Dwi"
|
||||
subtitle="Dinas - Sekretaris"
|
||||
/>
|
||||
|
||||
<BorderBottomItem
|
||||
onPress={() => {router.push('/member/1')}}
|
||||
borderType="all"
|
||||
icon={
|
||||
<Image
|
||||
source={require("../../../assets/images/user.jpeg")}
|
||||
style={[Styles.userProfileSmall]}
|
||||
/>
|
||||
}
|
||||
title="Amalia Dwi"
|
||||
subtitle="Dinas - Sekretaris"
|
||||
/>
|
||||
|
||||
<BorderBottomItem
|
||||
onPress={() => {router.push('/member/1')}}
|
||||
borderType="all"
|
||||
icon={
|
||||
<Image
|
||||
source={require("../../../assets/images/user.jpeg")}
|
||||
style={[Styles.userProfileSmall]}
|
||||
/>
|
||||
}
|
||||
title="Amalia Dwi"
|
||||
subtitle="Dinas - Sekretaris"
|
||||
/>
|
||||
|
||||
<BorderBottomItem
|
||||
onPress={() => {router.push('/member/1')}}
|
||||
borderType="all"
|
||||
icon={
|
||||
<Image
|
||||
source={require("../../../assets/images/user.jpeg")}
|
||||
style={[Styles.userProfileSmall]}
|
||||
/>
|
||||
}
|
||||
title="Amalia Dwi"
|
||||
subtitle="Dinas - Sekretaris"
|
||||
/>
|
||||
|
||||
<BorderBottomItem
|
||||
onPress={() => {router.push('/member/1')}}
|
||||
borderType="all"
|
||||
icon={
|
||||
<Image
|
||||
source={require("../../../assets/images/user.jpeg")}
|
||||
style={[Styles.userProfileSmall]}
|
||||
/>
|
||||
}
|
||||
title="Amalia Dwi"
|
||||
subtitle="Dinas - Sekretaris"
|
||||
/>
|
||||
}
|
||||
</View>
|
||||
</View>
|
||||
</ScrollView>
|
||||
|
||||
Reference in New Issue
Block a user