upd: member
Deskripsi: - detail member - aktivasi member - edit member No Issues
This commit is contained in:
@@ -4,7 +4,7 @@ import { Text, View } from "react-native";
|
||||
|
||||
type Props = {
|
||||
category: 'nik' | 'group' | 'position' | 'phone' | 'email' | 'gender' | 'dokumen' | 'type' | 'location' | 'owner' | 'calendar' | 'share'
|
||||
value: string
|
||||
value: string | undefined
|
||||
border?: boolean
|
||||
}
|
||||
|
||||
|
||||
@@ -1,20 +1,38 @@
|
||||
import Styles from "@/constants/Styles"
|
||||
import { apiDeleteUser } from "@/lib/api"
|
||||
import { useAuthSession } from "@/providers/AuthProvider"
|
||||
import { MaterialCommunityIcons } from "@expo/vector-icons"
|
||||
import { router } from "expo-router"
|
||||
import { useState } from "react"
|
||||
import { ToastAndroid, View } from "react-native"
|
||||
import AlertKonfirmasi from "../alertKonfirmasi"
|
||||
import ButtonMenuHeader from "../buttonMenuHeader"
|
||||
import DrawerBottom from "../drawerBottom"
|
||||
import MenuItemRow from "../menuItemRow"
|
||||
import { router } from "expo-router"
|
||||
|
||||
type Props = {
|
||||
id: string | string[]
|
||||
active: any,
|
||||
id: string
|
||||
}
|
||||
|
||||
export default function HeaderRightMemberDetail({ id }: Props) {
|
||||
export default function HeaderRightMemberDetail({ active, id }: Props) {
|
||||
const { token, decryptToken } = useAuthSession()
|
||||
const [isVisible, setVisible] = useState(false)
|
||||
|
||||
async function handleActive() {
|
||||
try {
|
||||
const hasil = await decryptToken(String(token?.current))
|
||||
const response = await apiDeleteUser({ user: hasil, isActive: active }, id)
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
} finally {
|
||||
setVisible(false)
|
||||
ToastAndroid.show('Berhasil mengupdate data', ToastAndroid.SHORT)
|
||||
router.replace(`/member/${id}`);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
<ButtonMenuHeader onPress={() => { setVisible(true) }} />
|
||||
@@ -22,14 +40,13 @@ export default function HeaderRightMemberDetail({ id }: Props) {
|
||||
<View style={Styles.rowItemsCenter}>
|
||||
<MenuItemRow
|
||||
icon={<MaterialCommunityIcons name="toggle-switch-off-outline" color="black" size={25} />}
|
||||
title="Non Aktifkan"
|
||||
title={active ? "Non Aktifkan" : "Aktifkan"}
|
||||
onPress={() => {
|
||||
AlertKonfirmasi({
|
||||
title: 'Konfirmasi',
|
||||
desc: 'Apakah anda yakin ingin menonaktifkan data?',
|
||||
desc: active ? 'Apakah anda yakin ingin menonaktifkan user?' : 'Apakah anda yakin ingin mengaktifkan user?',
|
||||
onPress: () => {
|
||||
setVisible(false)
|
||||
ToastAndroid.show('Berhasil mengubah data', ToastAndroid.SHORT)
|
||||
handleActive()
|
||||
}
|
||||
})
|
||||
}}
|
||||
|
||||
@@ -17,14 +17,15 @@ type Props = {
|
||||
category: 'group' | 'status-task' | 'position' | 'role' | 'gender'
|
||||
idParent?: string
|
||||
onSelect: (value: { val: string, label: string }) => void
|
||||
valChoose?: string
|
||||
}
|
||||
|
||||
export default function ModalSelect({ open, close, title, category, idParent, onSelect }: Props) {
|
||||
export default function ModalSelect({ open, close, title, category, idParent, onSelect, valChoose }: Props) {
|
||||
const { token, decryptToken } = useAuthSession()
|
||||
const entityUser = useSelector((state: any) => state.user)
|
||||
const dispatch = useDispatch()
|
||||
const entitiesGroup = useSelector((state: any) => state.filterGroup)
|
||||
const [chooseValue, setChooseValue] = useState({ val: '', label: '' })
|
||||
const [chooseValue, setChooseValue] = useState({ val: valChoose, label: '' })
|
||||
const [data, setData] = useState<any>([])
|
||||
|
||||
async function handleLoadGroup() {
|
||||
@@ -65,6 +66,7 @@ export default function ModalSelect({ open, close, title, category, idParent, on
|
||||
} else if (category == "gender") {
|
||||
handleLoadGender()
|
||||
}
|
||||
setChooseValue({ ...chooseValue, val: valChoose })
|
||||
}, [dispatch, open]);
|
||||
|
||||
function onChoose(val: string, label: string) {
|
||||
|
||||
Reference in New Issue
Block a user