upd
This commit is contained in:
@@ -1,11 +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 { Feather } from "@expo/vector-icons";
|
||||||
import { router } from "expo-router";
|
import { router } from "expo-router";
|
||||||
import React, { useEffect, useState } from "react";
|
import React, { useEffect, useState } from "react";
|
||||||
import { Dimensions, Text, View } from "react-native";
|
import { Dimensions, Pressable, Text, View } from "react-native";
|
||||||
import Carousel, { ICarouselInstance } from "react-native-reanimated-carousel";
|
import { ICarouselInstance } from "react-native-reanimated-carousel";
|
||||||
import PaperGridContent from "../paperGridContent";
|
|
||||||
import Skeleton from "../skeleton";
|
import Skeleton from "../skeleton";
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
@@ -16,10 +16,11 @@ type Props = {
|
|||||||
|
|
||||||
export default function DivisionHome() {
|
export default function DivisionHome() {
|
||||||
const { decryptToken, token } = useAuthSession()
|
const { decryptToken, token } = useAuthSession()
|
||||||
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)
|
const [loading, setLoading] = useState(true)
|
||||||
|
const arrSkeleton = Array.from({ length: 2 }, (_, index) => index)
|
||||||
|
|
||||||
async function handleData() {
|
async function handleData() {
|
||||||
try {
|
try {
|
||||||
@@ -44,34 +45,47 @@ export default function DivisionHome() {
|
|||||||
<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" />
|
loading ?
|
||||||
|
arrSkeleton.map((item, index) => (
|
||||||
|
<Skeleton key={index} width={100} height={80} borderRadius={10} widthType="percent" />
|
||||||
|
))
|
||||||
:
|
:
|
||||||
data.length > 0 ?
|
data.length > 0 ?
|
||||||
<Carousel
|
data.map((item, index) => (
|
||||||
ref={ref}
|
<Pressable style={[Styles.wrapPaper, Styles.mb05,]} key={index} onPress={() => { router.push(`/division/${item.id}`) }}>
|
||||||
style={{ width: "100%" }}
|
<View style={[Styles.rowSpaceBetween, { alignItems: 'center' }]}>
|
||||||
width={width * 0.8}
|
|
||||||
height={235}
|
|
||||||
data={data}
|
|
||||||
loop={true}
|
|
||||||
autoPlay={false}
|
|
||||||
autoPlayReverse={false}
|
|
||||||
pagingEnabled={true}
|
|
||||||
snapEnabled={true}
|
|
||||||
vertical={false}
|
|
||||||
renderItem={({ index }) => (
|
|
||||||
<PaperGridContent titleTail={1} onPress={() => { router.push(`/division/${data[index].id}`) }} content="carousel" title={data[index].name} headerColor="warning">
|
|
||||||
<View>
|
<View>
|
||||||
<Text style={{ fontSize: 50, textAlign: "center", fontWeight: 'bold' }}>{data[index].jumlah}</Text>
|
<Text style={[Styles.textDefaultSemiBold]}>{item.name}</Text>
|
||||||
<Text style={[Styles.textSubtitle, { textAlign: "center" }]}>KEGIATAN</Text>
|
<Text style={[Styles.textDefault]}>{item.jumlah} Kegiatan</Text>
|
||||||
</View>
|
</View>
|
||||||
</PaperGridContent>
|
<Feather name="chevron-right" size={20} color="black" />
|
||||||
)}
|
</View>
|
||||||
/>
|
</Pressable>
|
||||||
|
))
|
||||||
|
// <Carousel
|
||||||
|
// ref={ref}
|
||||||
|
// style={{ width: "100%" }}
|
||||||
|
// width={width * 0.8}
|
||||||
|
// height={235}
|
||||||
|
// data={data}
|
||||||
|
// loop={true}
|
||||||
|
// autoPlay={false}
|
||||||
|
// autoPlayReverse={false}
|
||||||
|
// pagingEnabled={true}
|
||||||
|
// snapEnabled={true}
|
||||||
|
// vertical={false}
|
||||||
|
// renderItem={({ index }) => (
|
||||||
|
// <PaperGridContent titleTail={1} onPress={() => { router.push(`/division/${data[index].id}`) }} content="carousel" title={data[index].name} headerColor="warning">
|
||||||
|
// <View>
|
||||||
|
// <Text style={{ fontSize: 50, textAlign: "center", fontWeight: 'bold' }}>{data[index].jumlah}</Text>
|
||||||
|
// <Text style={[Styles.textSubtitle, { textAlign: "center" }]}>KEGIATAN</Text>
|
||||||
|
// </View>
|
||||||
|
// </PaperGridContent>
|
||||||
|
// )}
|
||||||
|
// />
|
||||||
:
|
:
|
||||||
<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>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -2,8 +2,8 @@ import axios from 'axios';
|
|||||||
|
|
||||||
const api = axios.create({
|
const api = axios.create({
|
||||||
// baseURL: 'http://10.0.2.2:3000/api',
|
// baseURL: 'http://10.0.2.2:3000/api',
|
||||||
baseURL: 'https://stg-darmasaba.wibudev.com/api',
|
// baseURL: 'https://stg-darmasaba.wibudev.com/api',
|
||||||
// baseURL: 'http://192.168.1.126:3000/api',
|
baseURL: 'http://192.168.1.135:3000/api',
|
||||||
});
|
});
|
||||||
|
|
||||||
export const apiCheckPhoneLogin = async (body: { phone: string }) => {
|
export const apiCheckPhoneLogin = async (body: { phone: string }) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user