upd: home
Deskripsi: - integrasi api kegiatan terupdate - integrasi api divisi teraktif - integrasi api progres kegiatan - integrasi api jumlah dokumen - integrasi api event hari ini - integrasi api diskusi No Issues
This commit is contained in:
@@ -2,14 +2,22 @@ import ButtonBackHeader from "@/components/buttonBackHeader";
|
|||||||
import ButtonSaveHeader from "@/components/buttonSaveHeader";
|
import ButtonSaveHeader from "@/components/buttonSaveHeader";
|
||||||
import { InputForm } from "@/components/inputForm";
|
import { InputForm } from "@/components/inputForm";
|
||||||
import Styles from "@/constants/Styles";
|
import Styles from "@/constants/Styles";
|
||||||
|
import { apiCreateBanner } from "@/lib/api";
|
||||||
|
import { addEntity } from "@/lib/bannerSlice";
|
||||||
|
import { useAuthSession } from "@/providers/AuthProvider";
|
||||||
import { Entypo } from "@expo/vector-icons";
|
import { Entypo } from "@expo/vector-icons";
|
||||||
import * as ImagePicker from 'expo-image-picker';
|
import * as ImagePicker from 'expo-image-picker';
|
||||||
import { router, Stack } from "expo-router";
|
import { router, Stack } from "expo-router";
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
import { Image, Pressable, SafeAreaView, ScrollView, Text, View } from "react-native";
|
import { Image, Pressable, SafeAreaView, ScrollView, Text, View } from "react-native";
|
||||||
|
import { useDispatch } from "react-redux";
|
||||||
|
|
||||||
export default function CreateBanner() {
|
export default function CreateBanner() {
|
||||||
|
const { decryptToken, token } = useAuthSession()
|
||||||
|
const dispatch = useDispatch()
|
||||||
const [selectedImage, setSelectedImage] = useState<string | undefined>(undefined)
|
const [selectedImage, setSelectedImage] = useState<string | undefined>(undefined)
|
||||||
|
const [imgForm, setImgForm] = useState<any>()
|
||||||
|
const [title, setTitle] = useState('')
|
||||||
|
|
||||||
const pickImageAsync = async () => {
|
const pickImageAsync = async () => {
|
||||||
let result = await ImagePicker.launchImageLibraryAsync({
|
let result = await ImagePicker.launchImageLibraryAsync({
|
||||||
@@ -20,11 +28,31 @@ export default function CreateBanner() {
|
|||||||
|
|
||||||
if (!result.canceled) {
|
if (!result.canceled) {
|
||||||
setSelectedImage(result.assets[0].uri);
|
setSelectedImage(result.assets[0].uri);
|
||||||
|
setImgForm(result.assets[0])
|
||||||
} else {
|
} else {
|
||||||
alert('Tidak ada gambar yang dipilih');
|
alert('Tidak ada gambar yang dipilih');
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
const handleCreateEntity = async () => {
|
||||||
|
const hasil = await decryptToken(String(token?.current))
|
||||||
|
const fd = new FormData()
|
||||||
|
fd.append("file", JSON.stringify({
|
||||||
|
uri: imgForm.uri,
|
||||||
|
type: 'image/jpeg', // or response.assets[0].type
|
||||||
|
name: imgForm.fileName,
|
||||||
|
}))
|
||||||
|
fd.append("data", JSON.stringify(
|
||||||
|
{
|
||||||
|
title: title,
|
||||||
|
user: hasil
|
||||||
|
}
|
||||||
|
))
|
||||||
|
const createdEntity = await apiCreateBanner(fd);
|
||||||
|
dispatch(addEntity(createdEntity));
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<SafeAreaView>
|
<SafeAreaView>
|
||||||
<Stack.Screen
|
<Stack.Screen
|
||||||
@@ -32,7 +60,7 @@ export default function CreateBanner() {
|
|||||||
headerLeft: () => <ButtonBackHeader onPress={() => { router.back() }} />,
|
headerLeft: () => <ButtonBackHeader onPress={() => { router.back() }} />,
|
||||||
headerTitle: 'Tambah Banner',
|
headerTitle: 'Tambah Banner',
|
||||||
headerTitleAlign: 'center',
|
headerTitleAlign: 'center',
|
||||||
headerRight: () => <ButtonSaveHeader category="create" />
|
headerRight: () => <ButtonSaveHeader category="create" onPress={() => { handleCreateEntity() }} />
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
<ScrollView>
|
<ScrollView>
|
||||||
@@ -47,25 +75,13 @@ export default function CreateBanner() {
|
|||||||
<Pressable onPress={pickImageAsync} style={[Styles.wrapPaper, Styles.contentItemCenter]}>
|
<Pressable onPress={pickImageAsync} style={[Styles.wrapPaper, Styles.contentItemCenter]}>
|
||||||
<View style={{ justifyContent: 'center', alignItems: 'center' }}>
|
<View style={{ justifyContent: 'center', alignItems: 'center' }}>
|
||||||
<Entypo name="image" size={50} color={'#aeaeae'} />
|
<Entypo name="image" size={50} color={'#aeaeae'} />
|
||||||
<Text style={[Styles.textInformation, Styles.mt05]}>Mohon unggah gambar dalam resolusi 1535 x 450 piksel untuk memastikan</Text>
|
<Text style={[Styles.textInformation, Styles.mt05]}>Mohon unggah gambar dalam resolusi 1535 x 450 pixel untuk memastikan</Text>
|
||||||
</View>
|
</View>
|
||||||
</Pressable>
|
</Pressable>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
</View>
|
</View>
|
||||||
<InputForm label="Judul" type="numeric" placeholder="Judul" required bg="white" />
|
<InputForm label="Judul" type="default" placeholder="Judul" required bg="white" onChange={setTitle} />
|
||||||
{/* <ButtonForm
|
|
||||||
text="SIMPAN"
|
|
||||||
onPress={() => {
|
|
||||||
AlertKonfirmasi({
|
|
||||||
title: 'Konfirmasi',
|
|
||||||
desc: 'Apakah anda yakin ingin menambahkan data?',
|
|
||||||
onPress: () => {
|
|
||||||
ToastAndroid.show('Berhasil menambahkan data', ToastAndroid.SHORT)
|
|
||||||
router.push('/banner')
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}} /> */}
|
|
||||||
</View>
|
</View>
|
||||||
</ScrollView>
|
</ScrollView>
|
||||||
</SafeAreaView>
|
</SafeAreaView>
|
||||||
|
|||||||
@@ -9,9 +9,13 @@ import { Ionicons, MaterialCommunityIcons } from "@expo/vector-icons"
|
|||||||
import { router, Stack } from "expo-router"
|
import { router, Stack } from "expo-router"
|
||||||
import { useState } from "react"
|
import { useState } from "react"
|
||||||
import { Image, SafeAreaView, ScrollView, ToastAndroid, View } from "react-native"
|
import { Image, SafeAreaView, ScrollView, ToastAndroid, View } from "react-native"
|
||||||
|
import { useSelector } from "react-redux"
|
||||||
|
|
||||||
export default function BannerList() {
|
export default function BannerList() {
|
||||||
const [isModal, setModal] = useState(false)
|
const [isModal, setModal] = useState(false)
|
||||||
|
const entities = useSelector((state: any) => state.banner)
|
||||||
|
const [dataId, setDataId] = useState('')
|
||||||
|
const [dataStorage, setDataStorage] = useState('')
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<SafeAreaView>
|
<SafeAreaView>
|
||||||
@@ -26,39 +30,24 @@ export default function BannerList() {
|
|||||||
|
|
||||||
<ScrollView>
|
<ScrollView>
|
||||||
<View style={[Styles.p15, Styles.mb100]}>
|
<View style={[Styles.p15, Styles.mb100]}>
|
||||||
|
{entities.map((index: any, key: number) => (
|
||||||
<BorderBottomItem
|
<BorderBottomItem
|
||||||
onPress={() => { setModal(true) }}
|
key={key}
|
||||||
|
onPress={() => {
|
||||||
|
setDataId(index.id)
|
||||||
|
setDataStorage(index.image)
|
||||||
|
setModal(true)
|
||||||
|
}}
|
||||||
borderType="all"
|
borderType="all"
|
||||||
icon={
|
icon={
|
||||||
<Image
|
<Image
|
||||||
source={require("../../../assets/images/bg.png")}
|
source={{ uri: `https://wibu-storage.wibudev.com/api/files/${index.image}` }}
|
||||||
style={[Styles.imgListBanner]}
|
style={[Styles.imgListBanner]}
|
||||||
/>
|
/>
|
||||||
}
|
}
|
||||||
title="Banner 1"
|
title={index.title}
|
||||||
/>
|
|
||||||
<BorderBottomItem
|
|
||||||
onPress={() => { setModal(true) }}
|
|
||||||
borderType="all"
|
|
||||||
icon={
|
|
||||||
<Image
|
|
||||||
source={require("../../../assets/images/bg.png")}
|
|
||||||
style={[Styles.imgListBanner]}
|
|
||||||
/>
|
|
||||||
}
|
|
||||||
title="Banner 2"
|
|
||||||
/>
|
|
||||||
<BorderBottomItem
|
|
||||||
onPress={() => { setModal(true) }}
|
|
||||||
borderType="all"
|
|
||||||
icon={
|
|
||||||
<Image
|
|
||||||
source={require("../../../assets/images/bg.png")}
|
|
||||||
style={[Styles.imgListBanner]}
|
|
||||||
/>
|
|
||||||
}
|
|
||||||
title="Banner 3"
|
|
||||||
/>
|
/>
|
||||||
|
))}
|
||||||
</View>
|
</View>
|
||||||
</ScrollView>
|
</ScrollView>
|
||||||
|
|
||||||
@@ -69,7 +58,7 @@ export default function BannerList() {
|
|||||||
title="Edit"
|
title="Edit"
|
||||||
onPress={() => {
|
onPress={() => {
|
||||||
setModal(false)
|
setModal(false)
|
||||||
router.push('/banner/784')
|
router.push(`/banner/${dataId}`)
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
<MenuItemRow
|
<MenuItemRow
|
||||||
|
|||||||
@@ -1,14 +1,49 @@
|
|||||||
import Styles from "@/constants/Styles";
|
import Styles from "@/constants/Styles";
|
||||||
|
import { apiGetDataHome } from "@/lib/api";
|
||||||
|
import { useAuthSession } from "@/providers/AuthProvider";
|
||||||
|
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";
|
||||||
|
|
||||||
|
type Props = {
|
||||||
|
value: number;
|
||||||
|
label: string;
|
||||||
|
frontColor: string;
|
||||||
|
}[]
|
||||||
|
|
||||||
export default function ChartDokumenHome() {
|
export default function ChartDokumenHome() {
|
||||||
|
const { decryptToken, token } = useAuthSession()
|
||||||
|
const [data, setData] = useState<Props>([])
|
||||||
|
const [maxValue, setMaxValue] = useState(5)
|
||||||
const barData = [
|
const barData = [
|
||||||
{ value: 23, label: 'Gambar', frontColor: '#fac858' },
|
{ value: 23, label: 'Gambar', frontColor: '#fac858' },
|
||||||
{ value: 12, label: 'Dokumen', frontColor: '#92cc76' },
|
{ value: 12, label: 'Dokumen', frontColor: '#92cc76' },
|
||||||
];
|
];
|
||||||
const width = Dimensions.get("window").width;
|
const width = Dimensions.get("window").width;
|
||||||
|
|
||||||
|
|
||||||
|
async function handleData() {
|
||||||
|
try {
|
||||||
|
const hasil = await decryptToken(String(token?.current))
|
||||||
|
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 roundUp = Math.ceil(maxValue / 10) * 10
|
||||||
|
setMaxValue(roundUp)
|
||||||
|
const convertedArray = response.data.map((item: { color: any; label: any; value: any; }) => ({
|
||||||
|
frontColor: item.color,
|
||||||
|
label: item.label,
|
||||||
|
value: Number(item.value)
|
||||||
|
}));
|
||||||
|
setData(convertedArray)
|
||||||
|
} catch (error) {
|
||||||
|
console.error(error)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
handleData()
|
||||||
|
}, []);
|
||||||
|
|
||||||
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>
|
||||||
@@ -16,8 +51,8 @@ export default function ChartDokumenHome() {
|
|||||||
showFractionalValues={false}
|
showFractionalValues={false}
|
||||||
showYAxisIndices
|
showYAxisIndices
|
||||||
noOfSections={4}
|
noOfSections={4}
|
||||||
maxValue={25}
|
maxValue={maxValue}
|
||||||
data={barData}
|
data={data}
|
||||||
isAnimated
|
isAnimated
|
||||||
width={width - 140}
|
width={width - 140}
|
||||||
barWidth={width * 0.25}
|
barWidth={width * 0.25}
|
||||||
|
|||||||
@@ -1,20 +1,44 @@
|
|||||||
import Styles from "@/constants/Styles";
|
import Styles from "@/constants/Styles";
|
||||||
|
import { apiGetDataHome } from "@/lib/api";
|
||||||
|
import { useAuthSession } from "@/providers/AuthProvider";
|
||||||
|
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";
|
||||||
|
|
||||||
|
type Props = {
|
||||||
|
value: number;
|
||||||
|
text: string;
|
||||||
|
color: string;
|
||||||
|
}[]
|
||||||
|
|
||||||
export default function ChartProgresHome() {
|
export default function ChartProgresHome() {
|
||||||
const pieData = [
|
const { decryptToken, token } = useAuthSession()
|
||||||
{ value: 54, text: "54%", color: '#177AD5' },
|
const [data, setData] = useState<Props>([])
|
||||||
{ value: 40, text: "40%", color: '#92cc76' },
|
|
||||||
{ value: 20, text: "20%", color: '#ED6665' },
|
async function handleData() {
|
||||||
{ value: 0, text: "0%", color: '#fac858' },
|
try {
|
||||||
];
|
const hasil = await decryptToken(String(token?.current))
|
||||||
|
const response = await apiGetDataHome({ cat: "progress", user: hasil })
|
||||||
|
const convertedArray = response.data.map((item: { color: any; text: any; value: any; }) => ({
|
||||||
|
color: item.color,
|
||||||
|
text: item.text,
|
||||||
|
value: Number(item.value)
|
||||||
|
}));
|
||||||
|
setData(convertedArray)
|
||||||
|
} catch (error) {
|
||||||
|
console.error(error)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
handleData()
|
||||||
|
}, []);
|
||||||
|
|
||||||
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
|
<PieChart
|
||||||
data={pieData}
|
data={data}
|
||||||
showText
|
showText
|
||||||
showValuesAsTooltipText
|
showValuesAsTooltipText
|
||||||
textColor="black"
|
textColor="black"
|
||||||
@@ -26,6 +50,31 @@ export default function ChartProgresHome() {
|
|||||||
textBackgroundRadius={0}
|
textBackgroundRadius={0}
|
||||||
isAnimated
|
isAnimated
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
<View style={[Styles.mt15]}>
|
||||||
|
<View style={[Styles.rowSpaceBetween, Styles.w80]}>
|
||||||
|
<View style={[Styles.rowItemsCenter, Styles.w60]}>
|
||||||
|
<View style={[Styles.iconContent, { backgroundColor: '#177AD5' }]}></View>
|
||||||
|
<Text style={[Styles.textInformation, Styles.ml10]}>Segera Dikerjakan</Text>
|
||||||
|
</View>
|
||||||
|
|
||||||
|
<View style={[Styles.rowItemsCenter, Styles.w50]}>
|
||||||
|
<View style={[Styles.iconContent, { backgroundColor: '#92cc76' }]}></View>
|
||||||
|
<Text style={[Styles.textInformation, Styles.ml10]}>Selesai</Text>
|
||||||
|
</View>
|
||||||
|
</View>
|
||||||
|
<View style={[Styles.rowSpaceBetween, Styles.w80, Styles.mt10]}>
|
||||||
|
<View style={[Styles.rowItemsCenter, Styles.w60]}>
|
||||||
|
<View style={[Styles.iconContent, { backgroundColor: '#fac858' }]}></View>
|
||||||
|
<Text style={[Styles.textInformation, Styles.ml10]}>Dikerjakan</Text>
|
||||||
|
</View>
|
||||||
|
|
||||||
|
<View style={[Styles.rowItemsCenter, Styles.w50]}>
|
||||||
|
<View style={[Styles.iconContent, { backgroundColor: '#ED6665' }]}></View>
|
||||||
|
<Text style={[Styles.textInformation, Styles.ml10]}>Dibatalkan</Text>
|
||||||
|
</View>
|
||||||
|
</View>
|
||||||
|
</View>
|
||||||
</View>
|
</View>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -1,15 +1,51 @@
|
|||||||
import Styles from "@/constants/Styles";
|
import Styles from "@/constants/Styles";
|
||||||
|
import { apiGetDataHome } from "@/lib/api";
|
||||||
|
import { useAuthSession } from "@/providers/AuthProvider";
|
||||||
|
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";
|
||||||
|
|
||||||
|
type Props = {
|
||||||
|
id: string
|
||||||
|
idDivision: string
|
||||||
|
desc: string
|
||||||
|
title: string
|
||||||
|
date: string
|
||||||
|
user: string
|
||||||
|
}
|
||||||
|
|
||||||
export default function DisccussionHome() {
|
export default function DisccussionHome() {
|
||||||
|
const { decryptToken, token } = useAuthSession()
|
||||||
|
const [data, setData] = useState<Props[]>([])
|
||||||
|
|
||||||
|
|
||||||
|
async function handleData() {
|
||||||
|
try {
|
||||||
|
const hasil = await decryptToken(String(token?.current))
|
||||||
|
const response = await apiGetDataHome({ cat: "discussion", user: hasil })
|
||||||
|
setData(response.data)
|
||||||
|
} catch (error) {
|
||||||
|
console.error(error)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
handleData()
|
||||||
|
}, []);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<View style={[Styles.mb15]}>
|
<View style={[Styles.mb15]}>
|
||||||
<Text style={[Styles.textDefaultSemiBold, Styles.mv10]}>Diskusi</Text>
|
<Text style={[Styles.textDefaultSemiBold, Styles.mv10]}>Diskusi</Text>
|
||||||
<View style={[Styles.wrapPaper]}>
|
<View style={[Styles.wrapPaper]}>
|
||||||
<DiscussionItem title="Bagaimana cara mengatasi banjir?" user="Amalia" date="13 Februari 2025" />
|
{
|
||||||
<DiscussionItem title="Bagaimana cara mengatasi banjir?" user="Amalia" date="13 Februari 2025" />
|
data.length > 0 ?
|
||||||
<DiscussionItem title="Bagaimana cara mengatasi banjir?" user="Amalia" date="13 Februari 2025" />
|
data.map((item, index) => {
|
||||||
|
return (
|
||||||
|
<DiscussionItem key={index} title={item.desc} user={item.user} date={item.date} />
|
||||||
|
)
|
||||||
|
})
|
||||||
|
: <Text style={[Styles.textDefault, Styles.cGray, { textAlign: 'center' }]}>Tidak ada acara hari ini</Text>
|
||||||
|
}
|
||||||
</View>
|
</View>
|
||||||
</View>
|
</View>
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -1,13 +1,38 @@
|
|||||||
import Styles from "@/constants/Styles";
|
import Styles from "@/constants/Styles";
|
||||||
import React from "react";
|
import { apiGetDataHome } from "@/lib/api";
|
||||||
|
import { useAuthSession } from "@/providers/AuthProvider";
|
||||||
|
import { router } from "expo-router";
|
||||||
|
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";
|
||||||
|
|
||||||
|
type Props = {
|
||||||
|
id: string
|
||||||
|
name: string
|
||||||
|
jumlah: number
|
||||||
|
}
|
||||||
|
|
||||||
export default function DivisionHome() {
|
export default function DivisionHome() {
|
||||||
const data = [...new Array(6).keys()];
|
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[]>([])
|
||||||
|
|
||||||
|
async function handleData() {
|
||||||
|
try {
|
||||||
|
const hasil = await decryptToken(String(token?.current))
|
||||||
|
const response = await apiGetDataHome({ cat: "division", user: hasil })
|
||||||
|
setData(response.data)
|
||||||
|
} catch (error) {
|
||||||
|
console.error(error)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
handleData()
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -26,9 +51,9 @@ export default function DivisionHome() {
|
|||||||
snapEnabled={true}
|
snapEnabled={true}
|
||||||
vertical={false}
|
vertical={false}
|
||||||
renderItem={({ index }) => (
|
renderItem={({ index }) => (
|
||||||
<PaperGridContent content="carousel" title="Kesekretariatan" headerColor="warning">
|
<PaperGridContent 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' }}>12</Text>
|
<Text style={{ fontSize: 50, textAlign: "center", fontWeight: 'bold' }}>{data[index].jumlah}</Text>
|
||||||
<Text style={[Styles.textSubtitle, { textAlign: "center" }]}>KEGIATAN</Text>
|
<Text style={[Styles.textSubtitle, { textAlign: "center" }]}>KEGIATAN</Text>
|
||||||
</View>
|
</View>
|
||||||
</PaperGridContent>
|
</PaperGridContent>
|
||||||
|
|||||||
@@ -1,14 +1,56 @@
|
|||||||
import Styles from "@/constants/Styles";
|
import Styles from "@/constants/Styles";
|
||||||
|
import { apiGetDataHome } from "@/lib/api";
|
||||||
|
import { useAuthSession } from "@/providers/AuthProvider";
|
||||||
|
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";
|
||||||
|
|
||||||
|
type Props = {
|
||||||
|
id: string
|
||||||
|
idDivision: string
|
||||||
|
title: string
|
||||||
|
desc: string
|
||||||
|
status: number
|
||||||
|
timeStart: string
|
||||||
|
timeEnd: string
|
||||||
|
dateStart: string
|
||||||
|
dateEnd: string
|
||||||
|
createdAt: string
|
||||||
|
user_name: string
|
||||||
|
}
|
||||||
|
|
||||||
export default function EventHome() {
|
export default function EventHome() {
|
||||||
|
const { decryptToken, token } = useAuthSession()
|
||||||
|
const [data, setData] = useState<Props[]>([])
|
||||||
|
|
||||||
|
async function handleData() {
|
||||||
|
try {
|
||||||
|
const hasil = await decryptToken(String(token?.current))
|
||||||
|
const response = await apiGetDataHome({ cat: "event", user: hasil })
|
||||||
|
setData(response.data)
|
||||||
|
} catch (error) {
|
||||||
|
console.error(error)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
handleData()
|
||||||
|
}, []);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<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]}>
|
||||||
<EventItem category="purple" title="Meeting Pertama" user="Amalia" jamAwal="10.00" jamAkhir="11.00" />
|
{
|
||||||
<EventItem category="orange" title="Meeting Pertama" user="Amalia" jamAwal="10.00" jamAkhir="11.00" />
|
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>
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -1,15 +1,42 @@
|
|||||||
|
import { ColorsStatus } from "@/constants/ColorsStatus";
|
||||||
import Styles from "@/constants/Styles";
|
import Styles from "@/constants/Styles";
|
||||||
import React from "react";
|
import { apiGetDataHome } from "@/lib/api";
|
||||||
|
import { useAuthSession } from "@/providers/AuthProvider";
|
||||||
|
import { router } from "expo-router";
|
||||||
|
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 ProgressBar from "../progressBar";
|
|
||||||
import { ColorsStatus } from "@/constants/ColorsStatus";
|
|
||||||
import PaperGridContent from "../paperGridContent";
|
import PaperGridContent from "../paperGridContent";
|
||||||
|
import ProgressBar from "../progressBar";
|
||||||
|
|
||||||
|
type Props = {
|
||||||
|
id: string
|
||||||
|
title: string
|
||||||
|
desc: string
|
||||||
|
status: number
|
||||||
|
progress: number
|
||||||
|
createdAt: string
|
||||||
|
}
|
||||||
|
|
||||||
export default function ProjectHome() {
|
export default function ProjectHome() {
|
||||||
const data = [...new Array(6).keys()];
|
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[]>([])
|
||||||
|
|
||||||
|
async function handleData() {
|
||||||
|
try {
|
||||||
|
const hasil = await decryptToken(String(token?.current))
|
||||||
|
const response = await apiGetDataHome({ cat: "kegiatan", user: hasil })
|
||||||
|
setData(response.data)
|
||||||
|
} catch (error) {
|
||||||
|
console.error(error)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
handleData()
|
||||||
|
}, []);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<View style={[Styles.mb15]}>
|
<View style={[Styles.mb15]}>
|
||||||
@@ -27,12 +54,26 @@ export default function ProjectHome() {
|
|||||||
snapEnabled={true}
|
snapEnabled={true}
|
||||||
vertical={false}
|
vertical={false}
|
||||||
renderItem={({ index }) => (
|
renderItem={({ index }) => (
|
||||||
<PaperGridContent content="carousel" title="Pembangunan Jembatan" headerColor="primary">
|
<PaperGridContent content="carousel" onPress={() => { router.push(`/project/${data[index].id}`) }} title={data[index].title} headerColor="primary">
|
||||||
<ProgressBar />
|
<ProgressBar />
|
||||||
<View style={[Styles.rowSpaceBetween]}>
|
<View style={[Styles.rowSpaceBetween]}>
|
||||||
<Text style={[Styles.textDefault, Styles.cGray]}>13 Februari 2025</Text>
|
<Text style={[Styles.textDefault, Styles.cGray]}>{data[index].createdAt}</Text>
|
||||||
<View style={[Styles.labelStatus, ColorsStatus.warning]}>
|
<View style={[Styles.labelStatus,
|
||||||
<Text style={[Styles.textMediumSemiBold, Styles.cWhite]}>DIKERJAKAN</Text>
|
data[index].status === 0 ? ColorsStatus.primary :
|
||||||
|
data[index].status === 1 ? ColorsStatus.warning :
|
||||||
|
data[index].status === 2 ? ColorsStatus.success :
|
||||||
|
data[index].status === 3 ? ColorsStatus.error :
|
||||||
|
ColorsStatus.primary
|
||||||
|
]}>
|
||||||
|
<Text style={[Styles.textMediumSemiBold, Styles.cWhite]}>
|
||||||
|
{
|
||||||
|
data[index].status === 0 ? 'SEGERA' :
|
||||||
|
data[index].status === 1 ? 'DIKERJAKAN' :
|
||||||
|
data[index].status === 2 ? 'SELESAI' :
|
||||||
|
data[index].status === 3 ? 'DIBATALKAN' :
|
||||||
|
"SEGERA"
|
||||||
|
}
|
||||||
|
</Text>
|
||||||
</View>
|
</View>
|
||||||
</View>
|
</View>
|
||||||
</PaperGridContent>
|
</PaperGridContent>
|
||||||
|
|||||||
@@ -158,6 +158,18 @@ const Styles = StyleSheet.create({
|
|||||||
w100: {
|
w100: {
|
||||||
width: '100%'
|
width: '100%'
|
||||||
},
|
},
|
||||||
|
w90: {
|
||||||
|
width: '90%'
|
||||||
|
},
|
||||||
|
w80: {
|
||||||
|
width: '80%'
|
||||||
|
},
|
||||||
|
w70: {
|
||||||
|
width: '70%'
|
||||||
|
},
|
||||||
|
w60: {
|
||||||
|
width: '60%'
|
||||||
|
},
|
||||||
w50: {
|
w50: {
|
||||||
width: '50%'
|
width: '50%'
|
||||||
},
|
},
|
||||||
|
|||||||
21
lib/api.ts
21
lib/api.ts
@@ -31,10 +31,23 @@ export const apiGetBanner = async ({ user }: { user: string }) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
// export const createEntity = async (newEntity: any) => {
|
export const apiCreateBanner = async (data: FormData) => {
|
||||||
// const response = await api.post('/entities', newEntity);
|
await api.post('/banner', data, {
|
||||||
// return response.data;
|
headers: {
|
||||||
// };
|
'Content-Type': 'multipart/form-data',
|
||||||
|
},
|
||||||
|
}).then(response => {
|
||||||
|
return response.data;
|
||||||
|
})
|
||||||
|
.catch(error => {
|
||||||
|
console.error('Error:', error);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
export const apiGetDataHome = async ({ cat, user }: { cat: 'kegiatan' | 'division' | 'progress' | 'dokumen' | 'event' | 'discussion' | 'header' | 'check-late-project', user: string }) => {
|
||||||
|
const response = await api.get(`mobile/home?user=${user}&cat=${cat}`);
|
||||||
|
return response.data;
|
||||||
|
};
|
||||||
|
|
||||||
// export const updateEntityById = async (id: any, updatedEntity: any) => {
|
// export const updateEntityById = async (id: any, updatedEntity: any) => {
|
||||||
// const response = await api.put(`/entities/${id}`, updatedEntity);
|
// const response = await api.put(`/entities/${id}`, updatedEntity);
|
||||||
|
|||||||
Reference in New Issue
Block a user