upd: profile dan pencarian
No Issues
This commit is contained in:
@@ -17,7 +17,7 @@ export default function Profile() {
|
|||||||
const dispatch = useDispatch()
|
const dispatch = useDispatch()
|
||||||
const entities = useSelector((state: any) => state.entities)
|
const entities = useSelector((state: any) => state.entities)
|
||||||
const [error, setError] = useState(false)
|
const [error, setError] = useState(false)
|
||||||
const [role, setRole] = useState('')
|
const [role, setRole] = useState('developer')
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
handleUserLogin()
|
handleUserLogin()
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import { useAuthSession } from "@/providers/AuthProvider";
|
|||||||
import { AntDesign, MaterialIcons } from "@expo/vector-icons";
|
import { AntDesign, MaterialIcons } from "@expo/vector-icons";
|
||||||
import { router, Stack } from "expo-router";
|
import { router, Stack } from "expo-router";
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
import { FlatList, Image, SafeAreaView, Text, View } from "react-native";
|
import { FlatList, Image, SafeAreaView, Text, ToastAndroid, View } from "react-native";
|
||||||
|
|
||||||
type PropsUser = {
|
type PropsUser = {
|
||||||
id: string
|
id: string
|
||||||
@@ -43,9 +43,13 @@ export default function Search() {
|
|||||||
if (cari.length > 3) {
|
if (cari.length > 3) {
|
||||||
const user = await decryptToken(String(token?.current))
|
const user = await decryptToken(String(token?.current))
|
||||||
const hasil = await apiGetSearch({ text: cari, user: user })
|
const hasil = await apiGetSearch({ text: cari, user: user })
|
||||||
setDataUser(hasil.user)
|
if (hasil.success) {
|
||||||
setDataDivisi(hasil.division)
|
setDataUser(hasil.data.user)
|
||||||
setDataProject(hasil.project)
|
setDataDivisi(hasil.data.division)
|
||||||
|
setDataProject(hasil.data.project)
|
||||||
|
} else {
|
||||||
|
return ToastAndroid.show(hasil.message, ToastAndroid.SHORT)
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
setDataUser([])
|
setDataUser([])
|
||||||
setDataDivisi([])
|
setDataDivisi([])
|
||||||
@@ -53,6 +57,7 @@ export default function Search() {
|
|||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(error)
|
console.error(error)
|
||||||
|
return ToastAndroid.show('Gagal melakukan pencarian', ToastAndroid.SHORT)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -16,13 +16,13 @@ export const apiSendOtp = async (body: { phone: string, otp: number }) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const apiGetProfile = async ({ id }: { id: string }) => {
|
export const apiGetProfile = async ({ id }: { id: string }) => {
|
||||||
const response = await api.get(`/user/${id}`);
|
const response = await api.get(`mobile/user/${id}`);
|
||||||
return response.data;
|
return response.data;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const apiGetSearch = async ({ text, user }: { text: string, user:string }) => {
|
export const apiGetSearch = async ({ text, user }: { text: string, user:string }) => {
|
||||||
const response = await api.get(`/home/search?search=${text}&user=${user}`);
|
const response = await api.get(`mobile/home/search?search=${text}&user=${user}`);
|
||||||
return response.data.data;
|
return response.data;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user