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,29 +116,37 @@ export default function Index() {
|
|||||||
<InputSearch onChange={setSearch} />
|
<InputSearch onChange={setSearch} />
|
||||||
<View>
|
<View>
|
||||||
{
|
{
|
||||||
data.length > 0 ?
|
|
||||||
data.map((item, index) => {
|
loading ?
|
||||||
|
arrSkeleton.map((item, index) => {
|
||||||
return (
|
return (
|
||||||
<BorderBottomItem
|
<SkeletonTwoItem key={index} />
|
||||||
key={index}
|
|
||||||
onPress={() => {
|
|
||||||
setIdChoose(item.id)
|
|
||||||
setActiveChoose(item.isActive)
|
|
||||||
setTitleChoose(item.name)
|
|
||||||
setModal(true)
|
|
||||||
}}
|
|
||||||
borderType="all"
|
|
||||||
icon={
|
|
||||||
<View style={[Styles.iconContent, ColorsStatus.lightGreen]}>
|
|
||||||
<MaterialCommunityIcons name="office-building-outline" size={25} color={'#384288'} />
|
|
||||||
</View>
|
|
||||||
}
|
|
||||||
title={item.name}
|
|
||||||
/>
|
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
:
|
:
|
||||||
<Text style={[Styles.textDefault, Styles.cGray, { textAlign: 'center' }]}>Tidak ada data</Text>
|
data.length > 0 ?
|
||||||
|
data.map((item, index) => {
|
||||||
|
return (
|
||||||
|
<BorderBottomItem
|
||||||
|
key={index}
|
||||||
|
onPress={() => {
|
||||||
|
setIdChoose(item.id)
|
||||||
|
setActiveChoose(item.isActive)
|
||||||
|
setTitleChoose(item.name)
|
||||||
|
setModal(true)
|
||||||
|
}}
|
||||||
|
borderType="all"
|
||||||
|
icon={
|
||||||
|
<View style={[Styles.iconContent, ColorsStatus.lightGreen]}>
|
||||||
|
<MaterialCommunityIcons name="office-building-outline" size={25} color={'#384288'} />
|
||||||
|
</View>
|
||||||
|
}
|
||||||
|
title={item.name}
|
||||||
|
/>
|
||||||
|
)
|
||||||
|
})
|
||||||
|
:
|
||||||
|
<Text style={[Styles.textDefault, Styles.cGray, { textAlign: 'center' }]}>Tidak ada data</Text>
|
||||||
}
|
}
|
||||||
</View>
|
</View>
|
||||||
</View>
|
</View>
|
||||||
|
|||||||
@@ -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} />
|
||||||
<Text style={[Styles.textSubtitle, Styles.cWhite, Styles.mt10]}>{data?.name}</Text>
|
<Skeleton width={150} height={10} borderRadius={5} />
|
||||||
<Text style={[Styles.textMediumNormal, Styles.cWhite]}>{data?.role}</Text>
|
</>
|
||||||
|
:
|
||||||
|
<>
|
||||||
|
<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.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>
|
||||||
<ItemDetailMember category="nik" value={data?.nik} />
|
{
|
||||||
<ItemDetailMember category="group" value={data?.group} />
|
loading ?
|
||||||
<ItemDetailMember category="position" value={data?.position} />
|
arrSkeleton.map((item, index) => {
|
||||||
<ItemDetailMember category="phone" value={`+62${data?.phone}`} />
|
return (
|
||||||
<ItemDetailMember category="email" value={data?.email} />
|
<Skeleton key={index} width={100} widthType="percent" height={25} borderRadius={5} />
|
||||||
<ItemDetailMember category="gender" value={data?.gender == "F" ? "Perempuan" : "Laki-Laki"} />
|
)
|
||||||
|
})
|
||||||
|
:
|
||||||
|
<>
|
||||||
|
<ItemDetailMember category="nik" value={data?.nik} />
|
||||||
|
<ItemDetailMember category="group" value={data?.group} />
|
||||||
|
<ItemDetailMember category="position" value={data?.position} />
|
||||||
|
<ItemDetailMember category="phone" value={`+62${data?.phone}`} />
|
||||||
|
<ItemDetailMember category="email" value={data?.email} />
|
||||||
|
<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,25 +89,31 @@ export default function Index() {
|
|||||||
}
|
}
|
||||||
<View>
|
<View>
|
||||||
{
|
{
|
||||||
data.length > 0
|
loading ?
|
||||||
?
|
arrSkeleton.map((item, index) => {
|
||||||
data.map((item, index) => {
|
|
||||||
return (
|
return (
|
||||||
<BorderBottomItem
|
<SkeletonTwoItem key={index} />
|
||||||
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>
|
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>
|
||||||
}
|
}
|
||||||
</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,25 +146,32 @@ export default function Index() {
|
|||||||
}
|
}
|
||||||
<View>
|
<View>
|
||||||
{
|
{
|
||||||
data.length > 0 ?
|
loading ?
|
||||||
data.map((item, index) => {
|
arrSkeleton.map((item, index) => {
|
||||||
return (
|
return (
|
||||||
<BorderBottomItem
|
<SkeletonTwoItem key={index} />
|
||||||
key={index}
|
|
||||||
onPress={() => { handleChooseData(item.id, item.name, item.isActive, item.idGroup) }}
|
|
||||||
borderType="all"
|
|
||||||
icon={
|
|
||||||
<View style={[Styles.iconContent, ColorsStatus.lightGreen]}>
|
|
||||||
<MaterialCommunityIcons name="account-tie" size={25} color={'#384288'} />
|
|
||||||
</View>
|
|
||||||
}
|
|
||||||
title={item.name}
|
|
||||||
subtitle={item.group}
|
|
||||||
/>
|
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
:
|
:
|
||||||
<Text style={[Styles.textDefault, Styles.cGray, { textAlign: 'center' }]}>Tidak ada data</Text>
|
data.length > 0 ?
|
||||||
|
data.map((item, index) => {
|
||||||
|
return (
|
||||||
|
<BorderBottomItem
|
||||||
|
key={index}
|
||||||
|
onPress={() => { handleChooseData(item.id, item.name, item.isActive, item.idGroup) }}
|
||||||
|
borderType="all"
|
||||||
|
icon={
|
||||||
|
<View style={[Styles.iconContent, ColorsStatus.lightGreen]}>
|
||||||
|
<MaterialCommunityIcons name="account-tie" size={25} color={'#384288'} />
|
||||||
|
</View>
|
||||||
|
}
|
||||||
|
title={item.name}
|
||||||
|
subtitle={item.group}
|
||||||
|
/>
|
||||||
|
)
|
||||||
|
})
|
||||||
|
:
|
||||||
|
<Text style={[Styles.textDefault, Styles.cGray, { textAlign: 'center' }]}>Tidak ada data</Text>
|
||||||
}
|
}
|
||||||
</View>
|
</View>
|
||||||
</View>
|
</View>
|
||||||
|
|||||||
@@ -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,28 +52,33 @@ 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>
|
||||||
<BarChart
|
{
|
||||||
showFractionalValues={false}
|
loading ? <Skeleton width={100} height={200} borderRadius={10} widthType="percent" />
|
||||||
showYAxisIndices
|
:
|
||||||
noOfSections={4}
|
<BarChart
|
||||||
maxValue={maxValue}
|
showFractionalValues={false}
|
||||||
data={data}
|
showYAxisIndices
|
||||||
isAnimated
|
noOfSections={4}
|
||||||
width={width - 140}
|
maxValue={maxValue}
|
||||||
barWidth={width * 0.25}
|
data={data}
|
||||||
renderTooltip={(item: any, index: any) => {
|
isAnimated
|
||||||
return (
|
width={width - 140}
|
||||||
<View
|
barWidth={width * 0.25}
|
||||||
style={{
|
renderTooltip={(item: any, index: any) => {
|
||||||
alignItems: 'center',
|
return (
|
||||||
justifyContent: 'center',
|
<View
|
||||||
width: width * 0.25
|
style={{
|
||||||
}}>
|
alignItems: 'center',
|
||||||
<Text>{item.value}</Text>
|
justifyContent: 'center',
|
||||||
</View>
|
width: width * 0.25
|
||||||
);
|
}}>
|
||||||
}}
|
<Text>{item.value}</Text>
|
||||||
/>
|
</View>
|
||||||
|
);
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
}
|
||||||
|
|
||||||
</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,44 +42,50 @@ 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>
|
||||||
<PieChart
|
{
|
||||||
data={data}
|
loading ? <Skeleton width={100} height={200} borderRadius={10} widthType="percent" />
|
||||||
showText
|
:
|
||||||
showValuesAsTooltipText
|
<>
|
||||||
textColor="black"
|
<PieChart
|
||||||
radius={120}
|
data={data}
|
||||||
textSize={15}
|
showText
|
||||||
focusOnPress={false}
|
showValuesAsTooltipText
|
||||||
showValuesAsLabels
|
textColor="black"
|
||||||
showTextBackground={false}
|
radius={120}
|
||||||
textBackgroundRadius={0}
|
textSize={15}
|
||||||
isAnimated
|
focusOnPress={false}
|
||||||
/>
|
showValuesAsLabels
|
||||||
|
showTextBackground={false}
|
||||||
|
textBackgroundRadius={0}
|
||||||
|
isAnimated
|
||||||
|
/>
|
||||||
|
|
||||||
<View style={[Styles.mt15]}>
|
<View style={[Styles.mt15]}>
|
||||||
<View style={[Styles.rowSpaceBetween, Styles.w80]}>
|
<View style={[Styles.rowSpaceBetween, Styles.w80]}>
|
||||||
<View style={[Styles.rowItemsCenter, Styles.w60]}>
|
<View style={[Styles.rowItemsCenter, Styles.w60]}>
|
||||||
<View style={[Styles.iconContent, { backgroundColor: '#177AD5' }]}></View>
|
<View style={[Styles.iconContent, { backgroundColor: '#177AD5' }]}></View>
|
||||||
<Text style={[Styles.textInformation, Styles.ml10]}>Segera Dikerjakan</Text>
|
<Text style={[Styles.textInformation, Styles.ml10]}>Segera Dikerjakan</Text>
|
||||||
</View>
|
</View>
|
||||||
|
|
||||||
<View style={[Styles.rowItemsCenter, Styles.w50]}>
|
<View style={[Styles.rowItemsCenter, Styles.w50]}>
|
||||||
<View style={[Styles.iconContent, { backgroundColor: '#92cc76' }]}></View>
|
<View style={[Styles.iconContent, { backgroundColor: '#92cc76' }]}></View>
|
||||||
<Text style={[Styles.textInformation, Styles.ml10]}>Selesai</Text>
|
<Text style={[Styles.textInformation, Styles.ml10]}>Selesai</Text>
|
||||||
</View>
|
</View>
|
||||||
</View>
|
</View>
|
||||||
<View style={[Styles.rowSpaceBetween, Styles.w80, Styles.mt10]}>
|
<View style={[Styles.rowSpaceBetween, Styles.w80, Styles.mt10]}>
|
||||||
<View style={[Styles.rowItemsCenter, Styles.w60]}>
|
<View style={[Styles.rowItemsCenter, Styles.w60]}>
|
||||||
<View style={[Styles.iconContent, { backgroundColor: '#fac858' }]}></View>
|
<View style={[Styles.iconContent, { backgroundColor: '#fac858' }]}></View>
|
||||||
<Text style={[Styles.textInformation, Styles.ml10]}>Dikerjakan</Text>
|
<Text style={[Styles.textInformation, Styles.ml10]}>Dikerjakan</Text>
|
||||||
</View>
|
</View>
|
||||||
|
|
||||||
<View style={[Styles.rowItemsCenter, Styles.w50]}>
|
<View style={[Styles.rowItemsCenter, Styles.w50]}>
|
||||||
<View style={[Styles.iconContent, { backgroundColor: '#ED6665' }]}></View>
|
<View style={[Styles.iconContent, { backgroundColor: '#ED6665' }]}></View>
|
||||||
<Text style={[Styles.textInformation, Styles.ml10]}>Dibatalkan</Text>
|
<Text style={[Styles.textInformation, Styles.ml10]}>Dibatalkan</Text>
|
||||||
</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]}>
|
||||||
{
|
{
|
||||||
data.length > 0 ?
|
loading ?
|
||||||
data.map((item, index) => {
|
<>
|
||||||
return (
|
<Skeleton width={100} height={70} borderRadius={10} widthType="percent" />
|
||||||
<DiscussionItem key={index} title={item.desc} user={item.user} date={item.date} />
|
<Skeleton width={100} height={70} borderRadius={10} widthType="percent" />
|
||||||
)
|
</>
|
||||||
})
|
:
|
||||||
: <Text style={[Styles.textDefault, Styles.cGray, { textAlign: 'center' }]}>Tidak ada acara hari ini</Text>
|
data.length > 0 ?
|
||||||
|
data.map((item, index) => {
|
||||||
|
return (
|
||||||
|
<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 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,27 +43,32 @@ 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>
|
||||||
<Carousel
|
{
|
||||||
ref={ref}
|
loading ? <Skeleton width={100} height={150} borderRadius={10} widthType="percent" />
|
||||||
style={{ width: "100%" }}
|
:
|
||||||
width={width * 0.8}
|
<Carousel
|
||||||
height={235}
|
ref={ref}
|
||||||
data={data}
|
style={{ width: "100%" }}
|
||||||
loop={true}
|
width={width * 0.8}
|
||||||
autoPlay={false}
|
height={235}
|
||||||
autoPlayReverse={false}
|
data={data}
|
||||||
pagingEnabled={true}
|
loop={true}
|
||||||
snapEnabled={true}
|
autoPlay={false}
|
||||||
vertical={false}
|
autoPlayReverse={false}
|
||||||
renderItem={({ index }) => (
|
pagingEnabled={true}
|
||||||
<PaperGridContent onPress={() => { router.push(`/division/${data[index].id}`) }} content="carousel" title={data[index].name} headerColor="warning">
|
snapEnabled={true}
|
||||||
<View>
|
vertical={false}
|
||||||
<Text style={{ fontSize: 50, textAlign: "center", fontWeight: 'bold' }}>{data[index].jumlah}</Text>
|
renderItem={({ index }) => (
|
||||||
<Text style={[Styles.textSubtitle, { textAlign: "center" }]}>KEGIATAN</Text>
|
<PaperGridContent onPress={() => { router.push(`/division/${data[index].id}`) }} content="carousel" title={data[index].name} headerColor="warning">
|
||||||
</View>
|
<View>
|
||||||
</PaperGridContent>
|
<Text style={{ fontSize: 50, textAlign: "center", fontWeight: 'bold' }}>{data[index].jumlah}</Text>
|
||||||
)}
|
<Text style={[Styles.textSubtitle, { textAlign: "center" }]}>KEGIATAN</Text>
|
||||||
/>
|
</View>
|
||||||
|
</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,14 +47,21 @@ 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]}>
|
||||||
|
|
||||||
{
|
{
|
||||||
data.length > 0 ?
|
loading ?
|
||||||
data.map((item, index) => {
|
<>
|
||||||
return (
|
<Skeleton width={100} height={70} borderRadius={10} widthType="percent" />
|
||||||
<EventItem key={index} category={index % 2 == 0 ? 'purple' : 'orange'} onPress={() => {router.push(`/division/${item.idDivision}/calendar/${item.id}`)}} title={item.title} user={item.user_name} jamAwal={item.timeStart} jamAkhir={item.timeEnd} />
|
<Skeleton width={100} height={70} borderRadius={10} widthType="percent" />
|
||||||
)
|
</>
|
||||||
})
|
:
|
||||||
: <Text style={[Styles.textDefault, Styles.cGray, { textAlign: 'center' }]}>Tidak ada acara hari ini</Text>
|
data.length > 0 ?
|
||||||
|
data.map((item, index) => {
|
||||||
|
return (
|
||||||
|
<EventItem key={index} category={index % 2 == 0 ? 'purple' : 'orange'} onPress={() => { router.push(`/division/${item.idDivision}/calendar/${item.id}`) }} title={item.title} user={item.user_name} jamAwal={item.timeStart} jamAkhir={item.timeEnd} />
|
||||||
|
)
|
||||||
|
})
|
||||||
|
: <Text style={[Styles.textDefault, Styles.cGray, { textAlign: 'center' }]}>Tidak ada acara hari ini</Text>
|
||||||
}
|
}
|
||||||
</View>
|
</View>
|
||||||
</View>
|
</View>
|
||||||
|
|||||||
@@ -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,44 +46,49 @@ 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>
|
||||||
<Carousel
|
{
|
||||||
ref={ref}
|
loading ? (<Skeleton width={100} height={150} borderRadius={10} widthType="percent" />)
|
||||||
style={{ width: "100%" }}
|
:
|
||||||
width={width * 0.8}
|
<Carousel
|
||||||
height={235}
|
ref={ref}
|
||||||
data={data}
|
style={{ width: "100%" }}
|
||||||
loop={true}
|
width={width * 0.8}
|
||||||
autoPlay={false}
|
height={235}
|
||||||
autoPlayReverse={false}
|
data={data}
|
||||||
pagingEnabled={true}
|
loop={true}
|
||||||
snapEnabled={true}
|
autoPlay={false}
|
||||||
vertical={false}
|
autoPlayReverse={false}
|
||||||
renderItem={({ index }) => (
|
pagingEnabled={true}
|
||||||
<PaperGridContent content="carousel" onPress={() => { router.push(`/project/${data[index].id}`) }} title={data[index].title} headerColor="primary">
|
snapEnabled={true}
|
||||||
<ProgressBar value={data[index].progress} category="carousel" />
|
vertical={false}
|
||||||
<View style={[Styles.rowSpaceBetween]}>
|
renderItem={({ index }) => (
|
||||||
<Text style={[Styles.textDefault, Styles.cGray]}>{data[index].createdAt}</Text>
|
<PaperGridContent content="carousel" onPress={() => { router.push(`/project/${data[index].id}`) }} title={data[index].title} headerColor="primary">
|
||||||
<LabelStatus
|
<ProgressBar value={data[index].progress} category="carousel" />
|
||||||
size="default"
|
<View style={[Styles.rowSpaceBetween]}>
|
||||||
category={
|
<Text style={[Styles.textDefault, Styles.cGray]}>{data[index].createdAt}</Text>
|
||||||
data[index].status === 0 ? 'primary' :
|
<LabelStatus
|
||||||
data[index].status === 1 ? 'warning' :
|
size="default"
|
||||||
data[index].status === 2 ? 'success' :
|
category={
|
||||||
data[index].status === 3 ? 'error' :
|
data[index].status === 0 ? 'primary' :
|
||||||
'primary'
|
data[index].status === 1 ? 'warning' :
|
||||||
}
|
data[index].status === 2 ? 'success' :
|
||||||
text={
|
data[index].status === 3 ? 'error' :
|
||||||
data[index].status === 0 ? 'SEGERA' :
|
'primary'
|
||||||
data[index].status === 1 ? 'DIKERJAKAN' :
|
}
|
||||||
data[index].status === 2 ? 'SELESAI' :
|
text={
|
||||||
data[index].status === 3 ? 'DIBATALKAN' :
|
data[index].status === 0 ? 'SEGERA' :
|
||||||
'SEGERA'
|
data[index].status === 1 ? 'DIKERJAKAN' :
|
||||||
}
|
data[index].status === 2 ? 'SELESAI' :
|
||||||
/>
|
data[index].status === 3 ? 'DIBATALKAN' :
|
||||||
</View>
|
'SEGERA'
|
||||||
</PaperGridContent>
|
}
|
||||||
)}
|
/>
|
||||||
/>
|
</View>
|
||||||
|
</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