upd: skeleton loading
Deskripsi: - home - list lembaga desa - list jabatan - list member - detail member No Issues
This commit is contained in:
@@ -6,6 +6,7 @@ import DrawerBottom from "@/components/drawerBottom";
|
|||||||
import { InputForm } from "@/components/inputForm";
|
import { InputForm } from "@/components/inputForm";
|
||||||
import InputSearch from "@/components/inputSearch";
|
import InputSearch from "@/components/inputSearch";
|
||||||
import MenuItemRow from "@/components/menuItemRow";
|
import MenuItemRow from "@/components/menuItemRow";
|
||||||
|
import SkeletonTwoItem from "@/components/skeletonTwoItem";
|
||||||
import { ColorsStatus } from "@/constants/ColorsStatus";
|
import { ColorsStatus } from "@/constants/ColorsStatus";
|
||||||
import Styles from "@/constants/Styles";
|
import Styles from "@/constants/Styles";
|
||||||
import { apiDeleteGroup, apiEditGroup, apiGetGroup } from "@/lib/api";
|
import { apiDeleteGroup, apiEditGroup, apiGetGroup } from "@/lib/api";
|
||||||
@@ -30,6 +31,8 @@ export default function Index() {
|
|||||||
const [isVisibleEdit, setVisibleEdit] = useState(false)
|
const [isVisibleEdit, setVisibleEdit] = useState(false)
|
||||||
const [data, setData] = useState<Props[]>([])
|
const [data, setData] = useState<Props[]>([])
|
||||||
const [search, setSearch] = useState('')
|
const [search, setSearch] = useState('')
|
||||||
|
const arrSkeleton = Array.from({ length: 5 }, (_, index) => index)
|
||||||
|
const [loading, setLoading] = useState(true)
|
||||||
|
|
||||||
const [idChoose, setIdChoose] = useState('')
|
const [idChoose, setIdChoose] = useState('')
|
||||||
const [activeChoose, setActiveChoose] = useState(true)
|
const [activeChoose, setActiveChoose] = useState(true)
|
||||||
@@ -67,19 +70,28 @@ export default function Index() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function handleLoad() {
|
async function handleLoad(loading: boolean) {
|
||||||
try {
|
try {
|
||||||
|
setLoading(loading)
|
||||||
const hasil = await decryptToken(String(token?.current))
|
const hasil = await decryptToken(String(token?.current))
|
||||||
const response = await apiGetGroup({ user: hasil, active: String(active), search: search })
|
const response = await apiGetGroup({ user: hasil, active: String(active), search: search })
|
||||||
setData(response.data)
|
setData(response.data)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(error)
|
console.error(error)
|
||||||
|
} finally {
|
||||||
|
setLoading(false)
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
handleLoad()
|
handleLoad(true)
|
||||||
}, [active, search, update])
|
}, [active, search])
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
handleLoad(false)
|
||||||
|
}, [update])
|
||||||
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<SafeAreaView>
|
<SafeAreaView>
|
||||||
@@ -89,14 +101,14 @@ export default function Index() {
|
|||||||
<ButtonTab
|
<ButtonTab
|
||||||
active={active == "false" ? "false" : "true"}
|
active={active == "false" ? "false" : "true"}
|
||||||
value="true"
|
value="true"
|
||||||
onPress={() => { router.push('/group?active=true') }}
|
onPress={() => { router.replace('/group?active=true') }}
|
||||||
label="Aktif"
|
label="Aktif"
|
||||||
icon={<Feather name="check-circle" color={active == "true" ? 'white' : 'black'} size={20} />}
|
icon={<Feather name="check-circle" color={active == "true" ? 'white' : 'black'} size={20} />}
|
||||||
n={2} />
|
n={2} />
|
||||||
<ButtonTab
|
<ButtonTab
|
||||||
active={active == "false" ? "false" : "true"}
|
active={active == "false" ? "false" : "true"}
|
||||||
value="false"
|
value="false"
|
||||||
onPress={() => { router.push('/group?active=false') }}
|
onPress={() => { router.replace('/group?active=false') }}
|
||||||
label="Tidak Aktif"
|
label="Tidak Aktif"
|
||||||
icon={<AntDesign name="closecircleo" color={active == "false" ? 'white' : 'black'} size={20} />}
|
icon={<AntDesign name="closecircleo" color={active == "false" ? 'white' : 'black'} size={20} />}
|
||||||
n={2} />
|
n={2} />
|
||||||
@@ -104,6 +116,14 @@ export default function Index() {
|
|||||||
<InputSearch onChange={setSearch} />
|
<InputSearch onChange={setSearch} />
|
||||||
<View>
|
<View>
|
||||||
{
|
{
|
||||||
|
|
||||||
|
loading ?
|
||||||
|
arrSkeleton.map((item, index) => {
|
||||||
|
return (
|
||||||
|
<SkeletonTwoItem key={index} />
|
||||||
|
)
|
||||||
|
})
|
||||||
|
:
|
||||||
data.length > 0 ?
|
data.length > 0 ?
|
||||||
data.map((item, index) => {
|
data.map((item, index) => {
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -1,12 +1,14 @@
|
|||||||
import ButtonBackHeader from "@/components/buttonBackHeader";
|
import ButtonBackHeader from "@/components/buttonBackHeader";
|
||||||
|
import ImageUser from "@/components/imageNew";
|
||||||
import ItemDetailMember from "@/components/itemDetailMember";
|
import ItemDetailMember from "@/components/itemDetailMember";
|
||||||
import HeaderRightMemberDetail from "@/components/member/headerMemberDetail";
|
import HeaderRightMemberDetail from "@/components/member/headerMemberDetail";
|
||||||
|
import Skeleton from "@/components/skeleton";
|
||||||
import { valueRoleUser } from "@/constants/RoleUser";
|
import { valueRoleUser } from "@/constants/RoleUser";
|
||||||
import Styles from "@/constants/Styles";
|
import Styles from "@/constants/Styles";
|
||||||
import { apiGetProfile } from "@/lib/api";
|
import { apiGetProfile } from "@/lib/api";
|
||||||
import { router, Stack, useLocalSearchParams } from "expo-router";
|
import { router, Stack, useLocalSearchParams } from "expo-router";
|
||||||
import { useEffect, useState } from "react";
|
import { useEffect, useState } from "react";
|
||||||
import { Image, SafeAreaView, ScrollView, Text, View } from "react-native";
|
import { SafeAreaView, ScrollView, Text, View } from "react-native";
|
||||||
import { useSelector } from "react-redux";
|
import { useSelector } from "react-redux";
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
@@ -29,14 +31,19 @@ export default function MemberDetail() {
|
|||||||
const [error, setError] = useState(false)
|
const [error, setError] = useState(false)
|
||||||
const entityUser = useSelector((state: any) => state.user)
|
const entityUser = useSelector((state: any) => state.user)
|
||||||
const [isEdit, setEdit] = useState(true)
|
const [isEdit, setEdit] = useState(true)
|
||||||
|
const arrSkeleton = Array.from({ length: 5 }, (_, index) => index)
|
||||||
|
const [loading, setLoading] = useState(true)
|
||||||
|
|
||||||
async function handleLoad() {
|
async function handleLoad() {
|
||||||
try {
|
try {
|
||||||
|
setLoading(true)
|
||||||
const response = await apiGetProfile({ id: id })
|
const response = await apiGetProfile({ id: id })
|
||||||
setData(response.data)
|
setData(response.data)
|
||||||
setEdit(valueRoleUser.filter((v) => v.login == entityUser.role)[0]?.data.some((i: any) => i.id == response.data.idUserRole))
|
setEdit(valueRoleUser.filter((v) => v.login == entityUser.role)[0]?.data.some((i: any) => i.id == response.data.idUserRole))
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(error)
|
console.error(error)
|
||||||
|
} finally {
|
||||||
|
setLoading(false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -59,24 +66,44 @@ export default function MemberDetail() {
|
|||||||
<ScrollView>
|
<ScrollView>
|
||||||
<View style={{ flexDirection: 'column' }}>
|
<View style={{ flexDirection: 'column' }}>
|
||||||
<View style={[Styles.wrapHeadViewMember]}>
|
<View style={[Styles.wrapHeadViewMember]}>
|
||||||
<Image
|
{
|
||||||
source={error ? require("../../../assets/images/user.jpg") : { uri: `https://wibu-storage.wibudev.com/api/files/${data?.img}` }}
|
loading ?
|
||||||
onError={() => { setError(true) }}
|
<>
|
||||||
style={[Styles.userProfileBig]}
|
<Skeleton width={100} height={100} borderRadius={100} />
|
||||||
/>
|
<Skeleton width={200} height={10} borderRadius={5} />
|
||||||
|
<Skeleton width={150} height={10} borderRadius={5} />
|
||||||
|
</>
|
||||||
|
:
|
||||||
|
<>
|
||||||
|
<ImageUser src={`https://wibu-storage.wibudev.com/api/files/${data?.img}`} size="lg" />
|
||||||
<Text style={[Styles.textSubtitle, Styles.cWhite, Styles.mt10]}>{data?.name}</Text>
|
<Text style={[Styles.textSubtitle, Styles.cWhite, Styles.mt10]}>{data?.name}</Text>
|
||||||
<Text style={[Styles.textMediumNormal, Styles.cWhite]}>{data?.role}</Text>
|
<Text style={[Styles.textMediumNormal, Styles.cWhite]}>{data?.role}</Text>
|
||||||
|
</>
|
||||||
|
|
||||||
|
}
|
||||||
</View>
|
</View>
|
||||||
<View style={[Styles.p15]}>
|
<View style={[Styles.p15]}>
|
||||||
<View style={[Styles.rowSpaceBetween]}>
|
<View style={[Styles.rowSpaceBetween]}>
|
||||||
<Text style={[Styles.textDefaultSemiBold]}>Informasi</Text>
|
<Text style={[Styles.textDefaultSemiBold]}>Informasi</Text>
|
||||||
</View>
|
</View>
|
||||||
|
{
|
||||||
|
loading ?
|
||||||
|
arrSkeleton.map((item, index) => {
|
||||||
|
return (
|
||||||
|
<Skeleton key={index} width={100} widthType="percent" height={25} borderRadius={5} />
|
||||||
|
)
|
||||||
|
})
|
||||||
|
:
|
||||||
|
<>
|
||||||
<ItemDetailMember category="nik" value={data?.nik} />
|
<ItemDetailMember category="nik" value={data?.nik} />
|
||||||
<ItemDetailMember category="group" value={data?.group} />
|
<ItemDetailMember category="group" value={data?.group} />
|
||||||
<ItemDetailMember category="position" value={data?.position} />
|
<ItemDetailMember category="position" value={data?.position} />
|
||||||
<ItemDetailMember category="phone" value={`+62${data?.phone}`} />
|
<ItemDetailMember category="phone" value={`+62${data?.phone}`} />
|
||||||
<ItemDetailMember category="email" value={data?.email} />
|
<ItemDetailMember category="email" value={data?.email} />
|
||||||
<ItemDetailMember category="gender" value={data?.gender == "F" ? "Perempuan" : "Laki-Laki"} />
|
<ItemDetailMember category="gender" value={data?.gender == "F" ? "Perempuan" : "Laki-Laki"} />
|
||||||
|
</>
|
||||||
|
}
|
||||||
|
|
||||||
</View>
|
</View>
|
||||||
</View>
|
</View>
|
||||||
</ScrollView>
|
</ScrollView>
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import BorderBottomItem from "@/components/borderBottomItem";
|
|||||||
import ButtonTab from "@/components/buttonTab";
|
import ButtonTab from "@/components/buttonTab";
|
||||||
import ImageUser from "@/components/imageNew";
|
import ImageUser from "@/components/imageNew";
|
||||||
import InputSearch from "@/components/inputSearch";
|
import InputSearch from "@/components/inputSearch";
|
||||||
|
import SkeletonTwoItem from "@/components/skeletonTwoItem";
|
||||||
import Styles from "@/constants/Styles";
|
import Styles from "@/constants/Styles";
|
||||||
import { apiGetUser } from "@/lib/api";
|
import { apiGetUser } from "@/lib/api";
|
||||||
import { useAuthSession } from "@/providers/AuthProvider";
|
import { useAuthSession } from "@/providers/AuthProvider";
|
||||||
@@ -9,7 +10,7 @@ import { AntDesign, Feather } from "@expo/vector-icons";
|
|||||||
import { router, useLocalSearchParams } from "expo-router";
|
import { router, useLocalSearchParams } from "expo-router";
|
||||||
import { useEffect, useState } from "react";
|
import { useEffect, useState } from "react";
|
||||||
import { SafeAreaView, ScrollView, Text, View } from "react-native";
|
import { SafeAreaView, ScrollView, Text, View } from "react-native";
|
||||||
import { useDispatch, useSelector } from "react-redux";
|
import { useSelector } from "react-redux";
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
id: string,
|
id: string,
|
||||||
@@ -32,25 +33,31 @@ export default function Index() {
|
|||||||
const [search, setSearch] = useState('')
|
const [search, setSearch] = useState('')
|
||||||
const [nameGroup, setNameGroup] = useState('')
|
const [nameGroup, setNameGroup] = useState('')
|
||||||
const [data, setData] = useState<Props[]>([])
|
const [data, setData] = useState<Props[]>([])
|
||||||
const dispatch = useDispatch()
|
|
||||||
const update = useSelector((state: any) => state.memberUpdate)
|
const update = useSelector((state: any) => state.memberUpdate)
|
||||||
|
const arrSkeleton = Array.from({ length: 5 }, (_, index) => index)
|
||||||
|
const [loading, setLoading] = useState(true)
|
||||||
|
|
||||||
async function handleLoad() {
|
async function handleLoad(loading: boolean) {
|
||||||
try {
|
try {
|
||||||
|
setLoading(loading)
|
||||||
const hasil = await decryptToken(String(token?.current))
|
const hasil = await decryptToken(String(token?.current))
|
||||||
const response = await apiGetUser({ user: hasil, active: String(active), search: search, group: String(group) })
|
const response = await apiGetUser({ user: hasil, active: String(active), search: search, group: String(group) })
|
||||||
setData(response.data)
|
setData(response.data)
|
||||||
setNameGroup(response.filter.name)
|
setNameGroup(response.filter.name)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(error)
|
console.error(error)
|
||||||
|
} finally {
|
||||||
|
setLoading(false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
handleLoad()
|
handleLoad(true)
|
||||||
}, [active, search, group, update])
|
}, [active, search, group])
|
||||||
|
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
handleLoad(false)
|
||||||
|
}, [update])
|
||||||
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -61,14 +68,14 @@ export default function Index() {
|
|||||||
<ButtonTab
|
<ButtonTab
|
||||||
active={active == "false" ? "false" : "true"}
|
active={active == "false" ? "false" : "true"}
|
||||||
value="true"
|
value="true"
|
||||||
onPress={() => { router.push(`/member?active=true&group=${group}&search=${search}`) }}
|
onPress={() => { router.replace(`/member?active=true&group=${group}&search=${search}`) }}
|
||||||
label="Aktif"
|
label="Aktif"
|
||||||
icon={<Feather name="check-circle" color={active == "false" ? 'black' : 'white'} size={20} />}
|
icon={<Feather name="check-circle" color={active == "false" ? 'black' : 'white'} size={20} />}
|
||||||
n={2} />
|
n={2} />
|
||||||
<ButtonTab
|
<ButtonTab
|
||||||
active={active == "false" ? "false" : "true"}
|
active={active == "false" ? "false" : "true"}
|
||||||
value="false"
|
value="false"
|
||||||
onPress={() => { router.push(`/member?active=false&group=${group}&search=${search}`) }}
|
onPress={() => { router.replace(`/member?active=false&group=${group}&search=${search}`) }}
|
||||||
label="Tidak Aktif"
|
label="Tidak Aktif"
|
||||||
icon={<AntDesign name="closecircleo" color={active == "false" ? 'white' : 'black'} size={20} />}
|
icon={<AntDesign name="closecircleo" color={active == "false" ? 'white' : 'black'} size={20} />}
|
||||||
n={2} />
|
n={2} />
|
||||||
@@ -82,6 +89,13 @@ export default function Index() {
|
|||||||
}
|
}
|
||||||
<View>
|
<View>
|
||||||
{
|
{
|
||||||
|
loading ?
|
||||||
|
arrSkeleton.map((item, index) => {
|
||||||
|
return (
|
||||||
|
<SkeletonTwoItem key={index} />
|
||||||
|
)
|
||||||
|
})
|
||||||
|
:
|
||||||
data.length > 0
|
data.length > 0
|
||||||
?
|
?
|
||||||
data.map((item, index) => {
|
data.map((item, index) => {
|
||||||
@@ -100,7 +114,6 @@ export default function Index() {
|
|||||||
})
|
})
|
||||||
:
|
:
|
||||||
<Text style={[Styles.textDefault, Styles.cGray, { textAlign: 'center' }]}>Tidak ada data</Text>
|
<Text style={[Styles.textDefault, Styles.cGray, { textAlign: 'center' }]}>Tidak ada data</Text>
|
||||||
|
|
||||||
}
|
}
|
||||||
</View>
|
</View>
|
||||||
</View>
|
</View>
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import DrawerBottom from "@/components/drawerBottom";
|
|||||||
import { InputForm } from "@/components/inputForm";
|
import { InputForm } from "@/components/inputForm";
|
||||||
import InputSearch from "@/components/inputSearch";
|
import InputSearch from "@/components/inputSearch";
|
||||||
import MenuItemRow from "@/components/menuItemRow";
|
import MenuItemRow from "@/components/menuItemRow";
|
||||||
|
import SkeletonTwoItem from "@/components/skeletonTwoItem";
|
||||||
import { ColorsStatus } from "@/constants/ColorsStatus";
|
import { ColorsStatus } from "@/constants/ColorsStatus";
|
||||||
import Styles from "@/constants/Styles";
|
import Styles from "@/constants/Styles";
|
||||||
import { apiDeletePosition, apiEditPosition, apiGetPosition } from "@/lib/api";
|
import { apiDeletePosition, apiEditPosition, apiGetPosition } from "@/lib/api";
|
||||||
@@ -26,6 +27,8 @@ type Props = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export default function Index() {
|
export default function Index() {
|
||||||
|
const arrSkeleton = Array.from({ length: 5 }, (_, index) => index)
|
||||||
|
const [loading, setLoading] = useState(true)
|
||||||
const { token, decryptToken } = useAuthSession()
|
const { token, decryptToken } = useAuthSession()
|
||||||
const entityUser = useSelector((state: any) => state.user)
|
const entityUser = useSelector((state: any) => state.user)
|
||||||
const { active, group } = useLocalSearchParams<{ active?: string, group?: string }>()
|
const { active, group } = useLocalSearchParams<{ active?: string, group?: string }>()
|
||||||
@@ -42,20 +45,27 @@ export default function Index() {
|
|||||||
const dispatch = useDispatch()
|
const dispatch = useDispatch()
|
||||||
const update = useSelector((state: any) => state.positionUpdate)
|
const update = useSelector((state: any) => state.positionUpdate)
|
||||||
|
|
||||||
async function handleLoad() {
|
async function handleLoad(loading: boolean) {
|
||||||
try {
|
try {
|
||||||
|
setLoading(loading)
|
||||||
const hasil = await decryptToken(String(token?.current))
|
const hasil = await decryptToken(String(token?.current))
|
||||||
const response = await apiGetPosition({ user: hasil, active: String(active), search: search, group: String(group) })
|
const response = await apiGetPosition({ user: hasil, active: String(active), search: search, group: String(group) })
|
||||||
setData(response.data)
|
setData(response.data)
|
||||||
setNameGroup(response.filter.name)
|
setNameGroup(response.filter.name)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(error)
|
console.error(error)
|
||||||
|
} finally {
|
||||||
|
setLoading(false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
handleLoad()
|
handleLoad(true)
|
||||||
}, [active, search, group, update])
|
}, [active, search, group])
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
handleLoad(false)
|
||||||
|
}, [update])
|
||||||
|
|
||||||
|
|
||||||
function handleChooseData(id: string, name: string, active: boolean, group: string) {
|
function handleChooseData(id: string, name: string, active: boolean, group: string) {
|
||||||
@@ -115,14 +125,14 @@ export default function Index() {
|
|||||||
<ButtonTab
|
<ButtonTab
|
||||||
active={active == "false" ? "false" : "true"}
|
active={active == "false" ? "false" : "true"}
|
||||||
value="true"
|
value="true"
|
||||||
onPress={() => { router.push(`/position?active=true&group=${group}&search=${search}`) }}
|
onPress={() => { router.replace(`/position?active=true&group=${group}&search=${search}`) }}
|
||||||
label="Aktif"
|
label="Aktif"
|
||||||
icon={<Feather name="check-circle" color={active == "true" ? 'white' : 'black'} size={20} />}
|
icon={<Feather name="check-circle" color={active == "true" ? 'white' : 'black'} size={20} />}
|
||||||
n={2} />
|
n={2} />
|
||||||
<ButtonTab
|
<ButtonTab
|
||||||
active={active == "false" ? "false" : "true"}
|
active={active == "false" ? "false" : "true"}
|
||||||
value="false"
|
value="false"
|
||||||
onPress={() => { router.push(`/position?active=false&group=${group}&search=${search}`) }}
|
onPress={() => { router.replace(`/position?active=false&group=${group}&search=${search}`) }}
|
||||||
label="Tidak Aktif"
|
label="Tidak Aktif"
|
||||||
icon={<AntDesign name="closecircleo" color={active == "false" ? 'white' : 'black'} size={20} />}
|
icon={<AntDesign name="closecircleo" color={active == "false" ? 'white' : 'black'} size={20} />}
|
||||||
n={2} />
|
n={2} />
|
||||||
@@ -136,6 +146,13 @@ export default function Index() {
|
|||||||
}
|
}
|
||||||
<View>
|
<View>
|
||||||
{
|
{
|
||||||
|
loading ?
|
||||||
|
arrSkeleton.map((item, index) => {
|
||||||
|
return (
|
||||||
|
<SkeletonTwoItem key={index} />
|
||||||
|
)
|
||||||
|
})
|
||||||
|
:
|
||||||
data.length > 0 ?
|
data.length > 0 ?
|
||||||
data.map((item, index) => {
|
data.map((item, index) => {
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import { useAuthSession } from "@/providers/AuthProvider";
|
|||||||
import { useEffect, useState } from "react";
|
import { useEffect, useState } from "react";
|
||||||
import { Dimensions, Text, View } from "react-native";
|
import { Dimensions, Text, View } from "react-native";
|
||||||
import { BarChart } from "react-native-gifted-charts";
|
import { BarChart } from "react-native-gifted-charts";
|
||||||
|
import Skeleton from "../skeleton";
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
value: number;
|
value: number;
|
||||||
@@ -12,6 +13,7 @@ type Props = {
|
|||||||
}[]
|
}[]
|
||||||
|
|
||||||
export default function ChartDokumenHome() {
|
export default function ChartDokumenHome() {
|
||||||
|
const [loading, setLoading] = useState(true)
|
||||||
const { decryptToken, token } = useAuthSession()
|
const { decryptToken, token } = useAuthSession()
|
||||||
const [data, setData] = useState<Props>([])
|
const [data, setData] = useState<Props>([])
|
||||||
const [maxValue, setMaxValue] = useState(5)
|
const [maxValue, setMaxValue] = useState(5)
|
||||||
@@ -24,6 +26,7 @@ export default function ChartDokumenHome() {
|
|||||||
|
|
||||||
async function handleData() {
|
async function handleData() {
|
||||||
try {
|
try {
|
||||||
|
setLoading(true)
|
||||||
const hasil = await decryptToken(String(token?.current))
|
const hasil = await decryptToken(String(token?.current))
|
||||||
const response = await apiGetDataHome({ cat: "dokumen", user: hasil })
|
const response = await apiGetDataHome({ cat: "dokumen", user: hasil })
|
||||||
const maxValue = response.data.reduce((max: number, obj: { value: number; }) => Math.max(max, obj.value), -Infinity);
|
const maxValue = response.data.reduce((max: number, obj: { value: number; }) => Math.max(max, obj.value), -Infinity);
|
||||||
@@ -37,6 +40,8 @@ export default function ChartDokumenHome() {
|
|||||||
setData(convertedArray)
|
setData(convertedArray)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(error)
|
console.error(error)
|
||||||
|
} finally {
|
||||||
|
setLoading(false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -47,6 +52,9 @@ export default function ChartDokumenHome() {
|
|||||||
return (
|
return (
|
||||||
<View style={[Styles.wrapPaper, Styles.contentItemCenter, Styles.mb15]}>
|
<View style={[Styles.wrapPaper, Styles.contentItemCenter, Styles.mb15]}>
|
||||||
<Text style={[Styles.textSubtitle, Styles.mv15]}>JUMLAH DOKUMEN</Text>
|
<Text style={[Styles.textSubtitle, Styles.mv15]}>JUMLAH DOKUMEN</Text>
|
||||||
|
{
|
||||||
|
loading ? <Skeleton width={100} height={200} borderRadius={10} widthType="percent" />
|
||||||
|
:
|
||||||
<BarChart
|
<BarChart
|
||||||
showFractionalValues={false}
|
showFractionalValues={false}
|
||||||
showYAxisIndices
|
showYAxisIndices
|
||||||
@@ -69,6 +77,8 @@ export default function ChartDokumenHome() {
|
|||||||
);
|
);
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
|
}
|
||||||
|
|
||||||
</View>
|
</View>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -4,6 +4,7 @@ import { useAuthSession } from "@/providers/AuthProvider";
|
|||||||
import { useEffect, useState } from "react";
|
import { useEffect, useState } from "react";
|
||||||
import { Text, View } from "react-native";
|
import { Text, View } from "react-native";
|
||||||
import { PieChart } from "react-native-gifted-charts";
|
import { PieChart } from "react-native-gifted-charts";
|
||||||
|
import Skeleton from "../skeleton";
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
value: number;
|
value: number;
|
||||||
@@ -14,9 +15,11 @@ type Props = {
|
|||||||
export default function ChartProgresHome() {
|
export default function ChartProgresHome() {
|
||||||
const { decryptToken, token } = useAuthSession()
|
const { decryptToken, token } = useAuthSession()
|
||||||
const [data, setData] = useState<Props>([])
|
const [data, setData] = useState<Props>([])
|
||||||
|
const [loading, setLoading] = useState(true)
|
||||||
|
|
||||||
async function handleData() {
|
async function handleData() {
|
||||||
try {
|
try {
|
||||||
|
setLoading(true)
|
||||||
const hasil = await decryptToken(String(token?.current))
|
const hasil = await decryptToken(String(token?.current))
|
||||||
const response = await apiGetDataHome({ cat: "progress", user: hasil })
|
const response = await apiGetDataHome({ cat: "progress", user: hasil })
|
||||||
const convertedArray = response.data.map((item: { color: any; text: any; value: any; }) => ({
|
const convertedArray = response.data.map((item: { color: any; text: any; value: any; }) => ({
|
||||||
@@ -27,6 +30,8 @@ export default function ChartProgresHome() {
|
|||||||
setData(convertedArray)
|
setData(convertedArray)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(error)
|
console.error(error)
|
||||||
|
} finally {
|
||||||
|
setLoading(false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -37,6 +42,10 @@ export default function ChartProgresHome() {
|
|||||||
return (
|
return (
|
||||||
<View style={[Styles.wrapPaper, Styles.contentItemCenter, Styles.mb15]}>
|
<View style={[Styles.wrapPaper, Styles.contentItemCenter, Styles.mb15]}>
|
||||||
<Text style={[Styles.textSubtitle, Styles.mv15]}>PROGRES KEGIATAN</Text>
|
<Text style={[Styles.textSubtitle, Styles.mv15]}>PROGRES KEGIATAN</Text>
|
||||||
|
{
|
||||||
|
loading ? <Skeleton width={100} height={200} borderRadius={10} widthType="percent" />
|
||||||
|
:
|
||||||
|
<>
|
||||||
<PieChart
|
<PieChart
|
||||||
data={data}
|
data={data}
|
||||||
showText
|
showText
|
||||||
@@ -75,6 +84,8 @@ export default function ChartProgresHome() {
|
|||||||
</View>
|
</View>
|
||||||
</View>
|
</View>
|
||||||
</View>
|
</View>
|
||||||
|
</>
|
||||||
|
}
|
||||||
</View>
|
</View>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -1,9 +1,11 @@
|
|||||||
import Styles from "@/constants/Styles";
|
import Styles from "@/constants/Styles";
|
||||||
import { apiGetDataHome } from "@/lib/api";
|
import { apiGetDataHome } from "@/lib/api";
|
||||||
import { useAuthSession } from "@/providers/AuthProvider";
|
import { useAuthSession } from "@/providers/AuthProvider";
|
||||||
|
import { router } from "expo-router";
|
||||||
import { useEffect, useState } from "react";
|
import { useEffect, useState } from "react";
|
||||||
import { Text, View } from "react-native";
|
import { Text, View } from "react-native";
|
||||||
import DiscussionItem from "../discussionItem";
|
import DiscussionItem from "../discussionItem";
|
||||||
|
import Skeleton from "../skeleton";
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
id: string
|
id: string
|
||||||
@@ -17,15 +19,19 @@ type Props = {
|
|||||||
export default function DisccussionHome() {
|
export default function DisccussionHome() {
|
||||||
const { decryptToken, token } = useAuthSession()
|
const { decryptToken, token } = useAuthSession()
|
||||||
const [data, setData] = useState<Props[]>([])
|
const [data, setData] = useState<Props[]>([])
|
||||||
|
const [loading, setLoading] = useState(true)
|
||||||
|
|
||||||
|
|
||||||
async function handleData() {
|
async function handleData() {
|
||||||
try {
|
try {
|
||||||
|
setLoading(true)
|
||||||
const hasil = await decryptToken(String(token?.current))
|
const hasil = await decryptToken(String(token?.current))
|
||||||
const response = await apiGetDataHome({ cat: "discussion", user: hasil })
|
const response = await apiGetDataHome({ cat: "discussion", user: hasil })
|
||||||
setData(response.data)
|
setData(response.data)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(error)
|
console.error(error)
|
||||||
|
} finally {
|
||||||
|
setLoading(false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -38,13 +44,19 @@ export default function DisccussionHome() {
|
|||||||
<Text style={[Styles.textDefaultSemiBold, Styles.mv10]}>Diskusi</Text>
|
<Text style={[Styles.textDefaultSemiBold, Styles.mv10]}>Diskusi</Text>
|
||||||
<View style={[Styles.wrapPaper]}>
|
<View style={[Styles.wrapPaper]}>
|
||||||
{
|
{
|
||||||
|
loading ?
|
||||||
|
<>
|
||||||
|
<Skeleton width={100} height={70} borderRadius={10} widthType="percent" />
|
||||||
|
<Skeleton width={100} height={70} borderRadius={10} widthType="percent" />
|
||||||
|
</>
|
||||||
|
:
|
||||||
data.length > 0 ?
|
data.length > 0 ?
|
||||||
data.map((item, index) => {
|
data.map((item, index) => {
|
||||||
return (
|
return (
|
||||||
<DiscussionItem key={index} title={item.desc} user={item.user} date={item.date} />
|
<DiscussionItem key={index} title={item.desc} user={item.user} date={item.date} onPress={() => { router.push(`/division/${item.idDivision}/discussion/${item.id}`) }} />
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
: <Text style={[Styles.textDefault, Styles.cGray, { textAlign: 'center' }]}>Tidak ada acara hari ini</Text>
|
: <Text style={[Styles.textDefault, Styles.cGray, { textAlign: 'center' }]}>Tidak ada diskusi</Text>
|
||||||
}
|
}
|
||||||
</View>
|
</View>
|
||||||
</View>
|
</View>
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import React, { useEffect, useState } from "react";
|
|||||||
import { Dimensions, Text, View } from "react-native";
|
import { Dimensions, Text, View } from "react-native";
|
||||||
import Carousel, { ICarouselInstance } from "react-native-reanimated-carousel";
|
import Carousel, { ICarouselInstance } from "react-native-reanimated-carousel";
|
||||||
import PaperGridContent from "../paperGridContent";
|
import PaperGridContent from "../paperGridContent";
|
||||||
|
import Skeleton from "../skeleton";
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
id: string
|
id: string
|
||||||
@@ -18,14 +19,18 @@ export default function DivisionHome() {
|
|||||||
const ref = React.useRef<ICarouselInstance>(null);
|
const ref = React.useRef<ICarouselInstance>(null);
|
||||||
const width = Dimensions.get("window").width;
|
const width = Dimensions.get("window").width;
|
||||||
const [data, setData] = useState<Props[]>([])
|
const [data, setData] = useState<Props[]>([])
|
||||||
|
const [loading, setLoading] = useState(true)
|
||||||
|
|
||||||
async function handleData() {
|
async function handleData() {
|
||||||
try {
|
try {
|
||||||
|
setLoading(true)
|
||||||
const hasil = await decryptToken(String(token?.current))
|
const hasil = await decryptToken(String(token?.current))
|
||||||
const response = await apiGetDataHome({ cat: "division", user: hasil })
|
const response = await apiGetDataHome({ cat: "division", user: hasil })
|
||||||
setData(response.data)
|
setData(response.data)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(error)
|
console.error(error)
|
||||||
|
} finally {
|
||||||
|
setLoading(false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -38,6 +43,9 @@ export default function DivisionHome() {
|
|||||||
return (
|
return (
|
||||||
<View style={[Styles.mb15]}>
|
<View style={[Styles.mb15]}>
|
||||||
<Text style={[Styles.textDefaultSemiBold, Styles.mv10]}>Divisi Teraktif</Text>
|
<Text style={[Styles.textDefaultSemiBold, Styles.mv10]}>Divisi Teraktif</Text>
|
||||||
|
{
|
||||||
|
loading ? <Skeleton width={100} height={150} borderRadius={10} widthType="percent" />
|
||||||
|
:
|
||||||
<Carousel
|
<Carousel
|
||||||
ref={ref}
|
ref={ref}
|
||||||
style={{ width: "100%" }}
|
style={{ width: "100%" }}
|
||||||
@@ -59,6 +67,8 @@ export default function DivisionHome() {
|
|||||||
</PaperGridContent>
|
</PaperGridContent>
|
||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
|
}
|
||||||
|
|
||||||
</View>
|
</View>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -1,10 +1,11 @@
|
|||||||
import Styles from "@/constants/Styles";
|
import Styles from "@/constants/Styles";
|
||||||
import { apiGetDataHome } from "@/lib/api";
|
import { apiGetDataHome } from "@/lib/api";
|
||||||
import { useAuthSession } from "@/providers/AuthProvider";
|
import { useAuthSession } from "@/providers/AuthProvider";
|
||||||
|
import { router } from "expo-router";
|
||||||
import { useEffect, useState } from "react";
|
import { useEffect, useState } from "react";
|
||||||
import { Text, View } from "react-native";
|
import { Text, View } from "react-native";
|
||||||
import EventItem from "../eventItem";
|
import EventItem from "../eventItem";
|
||||||
import { router } from "expo-router";
|
import Skeleton from "../skeleton";
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
id: string
|
id: string
|
||||||
@@ -23,14 +24,18 @@ type Props = {
|
|||||||
export default function EventHome() {
|
export default function EventHome() {
|
||||||
const { decryptToken, token } = useAuthSession()
|
const { decryptToken, token } = useAuthSession()
|
||||||
const [data, setData] = useState<Props[]>([])
|
const [data, setData] = useState<Props[]>([])
|
||||||
|
const [loading, setLoading] = useState(true)
|
||||||
|
|
||||||
async function handleData() {
|
async function handleData() {
|
||||||
try {
|
try {
|
||||||
|
setLoading(true)
|
||||||
const hasil = await decryptToken(String(token?.current))
|
const hasil = await decryptToken(String(token?.current))
|
||||||
const response = await apiGetDataHome({ cat: "event", user: hasil })
|
const response = await apiGetDataHome({ cat: "event", user: hasil })
|
||||||
setData(response.data)
|
setData(response.data)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(error)
|
console.error(error)
|
||||||
|
} finally {
|
||||||
|
setLoading(false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -42,7 +47,14 @@ export default function EventHome() {
|
|||||||
<View style={[Styles.mb15]}>
|
<View style={[Styles.mb15]}>
|
||||||
<Text style={[Styles.textDefaultSemiBold, Styles.mv10]}>Acara Hari Ini</Text>
|
<Text style={[Styles.textDefaultSemiBold, Styles.mv10]}>Acara Hari Ini</Text>
|
||||||
<View style={[Styles.wrapPaper]}>
|
<View style={[Styles.wrapPaper]}>
|
||||||
|
|
||||||
{
|
{
|
||||||
|
loading ?
|
||||||
|
<>
|
||||||
|
<Skeleton width={100} height={70} borderRadius={10} widthType="percent" />
|
||||||
|
<Skeleton width={100} height={70} borderRadius={10} widthType="percent" />
|
||||||
|
</>
|
||||||
|
:
|
||||||
data.length > 0 ?
|
data.length > 0 ?
|
||||||
data.map((item, index) => {
|
data.map((item, index) => {
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import Carousel, { ICarouselInstance } from "react-native-reanimated-carousel";
|
|||||||
import LabelStatus from "../labelStatus";
|
import LabelStatus from "../labelStatus";
|
||||||
import PaperGridContent from "../paperGridContent";
|
import PaperGridContent from "../paperGridContent";
|
||||||
import ProgressBar from "../progressBar";
|
import ProgressBar from "../progressBar";
|
||||||
|
import Skeleton from "../skeleton";
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
id: string
|
id: string
|
||||||
@@ -23,14 +24,18 @@ export default function ProjectHome() {
|
|||||||
const ref = React.useRef<ICarouselInstance>(null);
|
const ref = React.useRef<ICarouselInstance>(null);
|
||||||
const width = Dimensions.get("window").width;
|
const width = Dimensions.get("window").width;
|
||||||
const [data, setData] = useState<Props[]>([])
|
const [data, setData] = useState<Props[]>([])
|
||||||
|
const [loading, setLoading] = useState(true)
|
||||||
|
|
||||||
async function handleData() {
|
async function handleData() {
|
||||||
try {
|
try {
|
||||||
|
setLoading(true)
|
||||||
const hasil = await decryptToken(String(token?.current))
|
const hasil = await decryptToken(String(token?.current))
|
||||||
const response = await apiGetDataHome({ cat: "kegiatan", user: hasil })
|
const response = await apiGetDataHome({ cat: "kegiatan", user: hasil })
|
||||||
setData(response.data)
|
setData(response.data)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(error)
|
console.error(error)
|
||||||
|
} finally {
|
||||||
|
setLoading(false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -41,6 +46,9 @@ export default function ProjectHome() {
|
|||||||
return (
|
return (
|
||||||
<View style={[Styles.mb15]}>
|
<View style={[Styles.mb15]}>
|
||||||
<Text style={[Styles.textDefaultSemiBold, Styles.mv10]}>Kegiatan Terupdate</Text>
|
<Text style={[Styles.textDefaultSemiBold, Styles.mv10]}>Kegiatan Terupdate</Text>
|
||||||
|
{
|
||||||
|
loading ? (<Skeleton width={100} height={150} borderRadius={10} widthType="percent" />)
|
||||||
|
:
|
||||||
<Carousel
|
<Carousel
|
||||||
ref={ref}
|
ref={ref}
|
||||||
style={{ width: "100%" }}
|
style={{ width: "100%" }}
|
||||||
@@ -79,6 +87,8 @@ export default function ProjectHome() {
|
|||||||
</PaperGridContent>
|
</PaperGridContent>
|
||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
|
}
|
||||||
|
|
||||||
</View>
|
</View>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -4,7 +4,7 @@ import { Image } from "react-native";
|
|||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
src: string,
|
src: string,
|
||||||
size?: 'sm' | 'xs'
|
size?: 'sm' | 'xs' | 'lg'
|
||||||
border?: boolean
|
border?: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -13,7 +13,7 @@ export default function ImageUser({ src, size }: Props) {
|
|||||||
return (
|
return (
|
||||||
<Image
|
<Image
|
||||||
source={error ? require('../assets/images/user.jpg') : { uri: src }}
|
source={error ? require('../assets/images/user.jpg') : { uri: src }}
|
||||||
style={[size == 'xs' ? Styles.userProfileExtraSmall : Styles.userProfileSmall, Styles.borderAll]}
|
style={[size == 'xs' ? Styles.userProfileExtraSmall : size == 'lg' ? Styles.userProfileBig : Styles.userProfileSmall, Styles.borderAll]}
|
||||||
onError={() =>
|
onError={() =>
|
||||||
setError(true)
|
setError(true)
|
||||||
}
|
}
|
||||||
|
|||||||
40
components/skeleton.tsx
Normal file
40
components/skeleton.tsx
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
import Styles from '@/constants/Styles';
|
||||||
|
import React, { useEffect } from 'react';
|
||||||
|
import { StyleSheet } from 'react-native';
|
||||||
|
import Animated, { Easing, useAnimatedStyle, useSharedValue, withRepeat, withTiming } from 'react-native-reanimated';
|
||||||
|
|
||||||
|
const Skeleton = ({ width, height, borderRadius = 0, widthType = 'number' }: { width: number, widthType?: 'number' | 'percent', height: number, borderRadius?: number }) => {
|
||||||
|
const opacity = useSharedValue(0.3);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
opacity.value = withRepeat(
|
||||||
|
withTiming(1, { duration: 500, easing: Easing.linear }),
|
||||||
|
-1,
|
||||||
|
true
|
||||||
|
);
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
const animatedStyle = useAnimatedStyle(() => {
|
||||||
|
return {
|
||||||
|
opacity: opacity.value,
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Animated.View
|
||||||
|
style={[
|
||||||
|
styles.skeleton,
|
||||||
|
{ width: widthType === 'percent' ? `${width}%` : width, height: height, borderRadius: borderRadius },
|
||||||
|
animatedStyle, Styles.mv05
|
||||||
|
]}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
const styles = StyleSheet.create({
|
||||||
|
skeleton: {
|
||||||
|
backgroundColor: '#e0e0e0',
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
export default Skeleton;
|
||||||
14
components/skeletonTwoItem.tsx
Normal file
14
components/skeletonTwoItem.tsx
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
import Styles from "@/constants/Styles";
|
||||||
|
import { View } from "react-native";
|
||||||
|
import Skeleton from "./skeleton";
|
||||||
|
|
||||||
|
export default function SkeletonTwoItem() {
|
||||||
|
return (
|
||||||
|
<View style={[Styles.rowOnly]}>
|
||||||
|
<Skeleton width={50} height={50} borderRadius={10} />
|
||||||
|
<View style={[{ flex: 1 }, Styles.ph05]}>
|
||||||
|
<Skeleton width={100} widthType="percent" height={50} borderRadius={10} />
|
||||||
|
</View>
|
||||||
|
</View>
|
||||||
|
)
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user