diff --git a/app/(application)/announcement/index.tsx b/app/(application)/announcement/index.tsx index 90f4f42..df24a86 100644 --- a/app/(application)/announcement/index.tsx +++ b/app/(application)/announcement/index.tsx @@ -87,7 +87,7 @@ export default function Announcement() { - + { loading ? arrSkeleton.map((item, index) => { diff --git a/app/(application)/banner/index.tsx b/app/(application)/banner/index.tsx index 2e9513e..b980fdd 100644 --- a/app/(application)/banner/index.tsx +++ b/app/(application)/banner/index.tsx @@ -5,6 +5,7 @@ import ButtonBackHeader from "@/components/buttonBackHeader" import DrawerBottom from "@/components/drawerBottom" import MenuItemRow from "@/components/menuItemRow" import ModalLoading from "@/components/modalLoading" +import Text from "@/components/Text" import { ConstEnv } from "@/constants/ConstEnv" import Styles from "@/constants/Styles" import { apiDeleteBanner, apiGetBanner } from "@/lib/api" @@ -121,26 +122,36 @@ export default function BannerList() { } style={[Styles.h100]} > - - {entities.map((index: any, key: number) => ( - { - setDataId(index.id) - setSelectFile(index) - setModal(true) - }} - borderType="all" - icon={ - 0 + ? + + {entities.map((index: any, key: number) => ( + { + setDataId(index.id) + setSelectFile(index) + setModal(true) + }} + borderType="all" + icon={ + + } + title={index.title} /> - } - title={index.title} - /> - ))} - + ))} + + : + + Tidak ada data + + } + + setModal(false)} title="Menu"> diff --git a/app/(application)/discussion/index.tsx b/app/(application)/discussion/index.tsx index 7a8a09a..25336c7 100644 --- a/app/(application)/discussion/index.tsx +++ b/app/(application)/discussion/index.tsx @@ -122,7 +122,7 @@ export default function Discussion() { } - + { loading ? arrSkeleton.map((item: any, i: number) => { diff --git a/app/(application)/division/[id]/(fitur-division)/discussion/index.tsx b/app/(application)/division/[id]/(fitur-division)/discussion/index.tsx index c71d7c8..c6d494a 100644 --- a/app/(application)/division/[id]/(fitur-division)/discussion/index.tsx +++ b/app/(application)/division/[id]/(fitur-division)/discussion/index.tsx @@ -121,7 +121,7 @@ export default function DiscussionDivision() { - + { loading ? arrSkeleton.map((item: any, i: number) => { diff --git a/app/(application)/division/[id]/(fitur-division)/task/[detail]/index.tsx b/app/(application)/division/[id]/(fitur-division)/task/[detail]/index.tsx index b7edf09..8eb62fd 100644 --- a/app/(application)/division/[id]/(fitur-division)/task/[detail]/index.tsx +++ b/app/(application)/division/[id]/(fitur-division)/task/[detail]/index.tsx @@ -8,7 +8,7 @@ import SectionMemberTask from "@/components/task/sectionMemberTask"; import SectionReportTask from "@/components/task/sectionReportTask"; import SectionTanggalTugasTask from "@/components/task/sectionTanggalTugasTask"; import Styles from "@/constants/Styles"; -import { apiGetTaskOne } from "@/lib/api"; +import { apiGetDivisionOneFeature, apiGetTaskOne } from "@/lib/api"; import { useAuthSession } from "@/providers/AuthProvider"; import { router, Stack, useLocalSearchParams } from "expo-router"; import { useEffect, useState } from "react"; @@ -32,6 +32,35 @@ export default function DetailTaskDivision() { const [progress, setProgress] = useState(0) const update = useSelector((state: any) => state.taskUpdate) const [refreshing, setRefreshing] = useState(false) + const [isMemberDivision, setIsMemberDivision] = useState(false); + const [isAdminDivision, setIsAdminDivision] = useState(false); + const entityUser = useSelector((state: any) => state.user); + + async function handleCheckMember() { + try { + const hasil = await decryptToken(String(token?.current)); + const response = await apiGetDivisionOneFeature({ + id, + user: hasil, + cat: "check-member", + }); + + setIsMemberDivision(response.data); + + const response2 = await apiGetDivisionOneFeature({ + id, + user: hasil, + cat: "check-admin", + }); + setIsAdminDivision(response2.data); + } catch (error) { + console.error(error); + } + } + + useEffect(() => { + handleCheckMember() + }, []) async function handleLoad(cat: 'data' | 'progress') { @@ -74,7 +103,9 @@ export default function DetailTaskDivision() { headerLeft: () => { router.back() }} />, headerTitle: loading ? 'Loading... ' : data?.title, headerTitleAlign: 'center', - headerRight: () => , + headerRight: () => (entityUser.role == "user" || entityUser.role == "coadmin") && !isMemberDivision + ? <> + : , }} /> - - - - + + + + diff --git a/app/(application)/division/[id]/(fitur-division)/task/index.tsx b/app/(application)/division/[id]/(fitur-division)/task/index.tsx index eac1871..98ed95b 100644 --- a/app/(application)/division/[id]/(fitur-division)/task/index.tsx +++ b/app/(application)/division/[id]/(fitur-division)/task/index.tsx @@ -179,7 +179,7 @@ export default function ListTask() { - + { loading ? isList ? diff --git a/app/(application)/division/index.tsx b/app/(application)/division/index.tsx index 54bb756..20b2083 100644 --- a/app/(application)/division/index.tsx +++ b/app/(application)/division/index.tsx @@ -180,7 +180,7 @@ export default function ListDivision() { } - + { @@ -200,7 +200,7 @@ export default function ListDivision() { )} - + { loading ? isList ? diff --git a/app/(application)/group/index.tsx b/app/(application)/group/index.tsx index f7485ff..7e045a5 100644 --- a/app/(application)/group/index.tsx +++ b/app/(application)/group/index.tsx @@ -126,7 +126,7 @@ export default function Index() { return ( - + - + { loading ? arrSkeleton.map((item, index) => { diff --git a/app/(application)/member/index.tsx b/app/(application)/member/index.tsx index 93376c7..855576c 100644 --- a/app/(application)/member/index.tsx +++ b/app/(application)/member/index.tsx @@ -129,7 +129,7 @@ export default function Index() { } - + { loading ? arrSkeleton.map((item, index) => { diff --git a/app/(application)/position/index.tsx b/app/(application)/position/index.tsx index 21026d3..c180afd 100644 --- a/app/(application)/position/index.tsx +++ b/app/(application)/position/index.tsx @@ -165,7 +165,7 @@ export default function Index() { } - + { loading ? arrSkeleton.map((item, index) => { diff --git a/app/(application)/project/index.tsx b/app/(application)/project/index.tsx index f13bd65..e168c00 100644 --- a/app/(application)/project/index.tsx +++ b/app/(application)/project/index.tsx @@ -178,7 +178,7 @@ export default function ListProject() { n={4} /> - + { diff --git a/app/(application)/search.tsx b/app/(application)/search.tsx index f5d5b98..8490613 100644 --- a/app/(application)/search.tsx +++ b/app/(application)/search.tsx @@ -75,7 +75,6 @@ export default function Search() { headerTitleAlign: 'center' }} /> - {/* */} { @@ -163,13 +162,12 @@ export default function Search() { : - + Tidak ada data } - {/* */} ) diff --git a/components/home/carouselHome.tsx b/components/home/carouselHome.tsx index e03fcc6..2ce9e3a 100644 --- a/components/home/carouselHome.tsx +++ b/components/home/carouselHome.tsx @@ -9,6 +9,7 @@ import { Dimensions, Image, View } from "react-native"; import { useSharedValue } from "react-native-reanimated"; import Carousel, { ICarouselInstance } from "react-native-reanimated-carousel"; import { useDispatch, useSelector } from "react-redux"; +import Text from "../Text"; export default function CaraouselHome() { const { decryptToken, token } = useAuthSession() @@ -21,7 +22,13 @@ export default function CaraouselHome() { async function handleBannerView() { const hasil = await decryptToken(String(token?.current)) - apiGetBanner({ user: hasil }).then((data) => dispatch(setEntities(data.data))) + apiGetBanner({ user: hasil }).then((data) => { + if (data.data.length > 0) { + dispatch(setEntities(data.data)) + } else { + dispatch(setEntities([])) + } + }) } async function handleUser() { @@ -40,22 +47,30 @@ export default function CaraouselHome() { return ( - ( - 0 ? + ( + + )} /> - )} - /> + : + + BANNER + + } + ) } \ No newline at end of file diff --git a/components/inputForm.tsx b/components/inputForm.tsx index dded8b6..7ce6451 100644 --- a/components/inputForm.tsx +++ b/components/inputForm.tsx @@ -19,15 +19,16 @@ type Props = { value?: string disable?: boolean multiline?: boolean + mb?: boolean }; -export function InputForm({ label, value, placeholder, onChange, info, disable, error, errorText, required, itemLeft, itemRight, type, round, width, bg, multiline }: Props) { +export function InputForm({ label, value, placeholder, onChange, info, disable, error, errorText, required, itemLeft, itemRight, type, round, width, bg, multiline, mb = true }: Props) { const lebar = Dimensions.get("window").width; if (itemLeft != undefined || itemRight != undefined) { return ( - + { label != undefined && ( diff --git a/components/inputSearch.tsx b/components/inputSearch.tsx index b40100b..65d677d 100644 --- a/components/inputSearch.tsx +++ b/components/inputSearch.tsx @@ -12,6 +12,7 @@ export default function InputSearch({ onChange, width, value }: { onChange?: (va width={width} bg="white" value={value} + mb={false} /> ) } \ No newline at end of file diff --git a/components/task/headerTaskDetail.tsx b/components/task/headerTaskDetail.tsx index 392c6da..b5a08da 100644 --- a/components/task/headerTaskDetail.tsx +++ b/components/task/headerTaskDetail.tsx @@ -1,10 +1,10 @@ import Styles from "@/constants/Styles" -import { apiAddLinkTask, apiDeleteTask, apiGetDivisionOneFeature } from "@/lib/api" +import { apiAddLinkTask, apiDeleteTask } from "@/lib/api" import { setUpdateTask } from "@/lib/taskUpdate" import { useAuthSession } from "@/providers/AuthProvider" import { AntDesign, Feather, Ionicons, MaterialCommunityIcons, MaterialIcons } from "@expo/vector-icons" import { router } from "expo-router" -import { useEffect, useState } from "react" +import { useState } from "react" import { View } from "react-native" import Toast from "react-native-toast-message" import { useDispatch, useSelector } from "react-redux" @@ -18,46 +18,19 @@ import ModalFloat from "../modalFloat" type Props = { id: string | string[] division: string - status: number | undefined + status: number | undefined, + isAdminDivision: boolean } -export default function HeaderRightTaskDetail({ id, division, status }: Props) { +export default function HeaderRightTaskDetail({ id, division, status, isAdminDivision }: Props) { const { token, decryptToken } = useAuthSession() const [isVisible, setVisible] = useState(false) const entityUser = useSelector((state: any) => state.user); - const [isMemberDivision, setIsMemberDivision] = useState(false); - const [isAdminDivision, setIsAdminDivision] = useState(false); const dispatch = useDispatch() const update = useSelector((state: any) => state.taskUpdate) const [isAddLink, setAddLink] = useState(false) const [link, setLink] = useState("") - async function handleCheckMember() { - try { - const hasil = await decryptToken(String(token?.current)); - const response = await apiGetDivisionOneFeature({ - id: division, - user: hasil, - cat: "check-member", - }); - - setIsMemberDivision(response.data); - - const response2 = await apiGetDivisionOneFeature({ - id: division, - user: hasil, - cat: "check-admin", - }); - setIsAdminDivision(response2.data); - } catch (error) { - console.error(error); - } - } - - useEffect(() => { - handleCheckMember() - }, []) - async function handleDelete() { try { const hasil = await decryptToken(String(token?.current)) @@ -95,12 +68,7 @@ export default function HeaderRightTaskDetail({ id, division, status }: Props) { return ( <> - { - (entityUser.role == "user" || entityUser.role == "coadmin") && !isMemberDivision - ? <> - : - { setVisible(true) }} /> - } + { setVisible(true) }} /> () @@ -39,6 +39,7 @@ export default function SectionFileTask({ refreshing }: { refreshing: boolean }) const arrSkeleton = Array.from({ length: 5 }) const [selectFile, setSelectFile] = useState(null) const [loadingOpen, setLoadingOpen] = useState(false) + const entityUser = useSelector((state: any) => state.user); async function handleLoad(loading: boolean) { try { @@ -163,21 +164,28 @@ export default function SectionFileTask({ refreshing }: { refreshing: boolean }) openFile() }} /> - } - title="Hapus" - onPress={() => { - setModal(false) - AlertKonfirmasi({ - title: 'Konfirmasi', - desc: 'Apakah Anda yakin ingin menghapus file ini? File yang dihapus tidak dapat dikembalikan', - onPress: () => { - handleDelete() - } - }) + { + (entityUser.role != "user" && entityUser.role != "coadmin") || isMemberDivision + ? + } + title="Hapus" + onPress={() => { + setModal(false) + AlertKonfirmasi({ + title: 'Konfirmasi', + desc: 'Apakah Anda yakin ingin menghapus file ini? File yang dihapus tidak dapat dikembalikan', + onPress: () => { + handleDelete() + } + }) + + }} + /> + : + <> + } - }} - /> diff --git a/components/task/sectionLinkTask.tsx b/components/task/sectionLinkTask.tsx index b617ff5..17a3293 100644 --- a/components/task/sectionLinkTask.tsx +++ b/components/task/sectionLinkTask.tsx @@ -20,7 +20,7 @@ type Props = { link: string } -export default function SectionLinkTask({ refreshing }: { refreshing: boolean }) { +export default function SectionLinkTask({ refreshing, isMemberDivision }: { refreshing: boolean, isMemberDivision: boolean }) { const [isModal, setModal] = useState(false) const { token, decryptToken } = useAuthSession() const { detail } = useLocalSearchParams<{ detail: string }>() @@ -28,6 +28,7 @@ export default function SectionLinkTask({ refreshing }: { refreshing: boolean }) const update = useSelector((state: any) => state.taskUpdate) const dispatch = useDispatch() const [selectLink, setSelectLink] = useState(null) + const entityUser = useSelector((state: any) => state.user); async function handleLoad() { try { @@ -101,18 +102,25 @@ export default function SectionLinkTask({ refreshing }: { refreshing: boolean }) Linking.openURL(urlCompleted(String(selectLink?.link))) }} /> - } - title="Hapus" - onPress={() => { - setModal(false) - AlertKonfirmasi({ - title: 'Konfirmasi', - desc: 'Apakah Anda yakin ingin menghapus link ini? Link yang dihapus tidak dapat dikembalikan', - onPress: () => { handleDelete() } - }) - }} - /> + { + (entityUser.role != "user" && entityUser.role != "coadmin") || isMemberDivision + ? + } + title="Hapus" + onPress={() => { + setModal(false) + AlertKonfirmasi({ + title: 'Konfirmasi', + desc: 'Apakah Anda yakin ingin menghapus link ini? Link yang dihapus tidak dapat dikembalikan', + onPress: () => { handleDelete() } + }) + }} + /> + : + <> + } + diff --git a/components/task/sectionMemberTask.tsx b/components/task/sectionMemberTask.tsx index 4a66180..8bdb89b 100644 --- a/components/task/sectionMemberTask.tsx +++ b/components/task/sectionMemberTask.tsx @@ -26,8 +26,9 @@ type Props = { position: string; }; -export default function SectionMemberTask({ refreshing }: { refreshing: boolean }) { +export default function SectionMemberTask({ refreshing, isMemberDivision }: { refreshing: boolean, isMemberDivision: boolean }) { const [isModal, setModal] = useState(false); + const entityUser = useSelector((state: any) => state.user); const { token, decryptToken } = useAuthSession(); const { id, detail } = useLocalSearchParams<{ id: string; detail: string }>(); const [data, setData] = useState([]); @@ -165,24 +166,31 @@ export default function SectionMemberTask({ refreshing }: { refreshing: boolean }} /> - + } + title="Keluarkan" + onPress={() => { + setModal(false) + AlertKonfirmasi({ + title: "Konfirmasi", + desc: "Apakah Anda yakin ingin mengeluarkan anggota?", + onPress: () => { handleDeleteMember() }, + }); + }} /> - } - title="Keluarkan" - onPress={() => { - setModal(false) - AlertKonfirmasi({ - title: "Konfirmasi", - desc: "Apakah Anda yakin ingin mengeluarkan anggota?", - onPress: () => { handleDeleteMember() }, - }); - }} - /> + : + <> + } diff --git a/components/task/sectionTanggalTugasTask.tsx b/components/task/sectionTanggalTugasTask.tsx index 69977d2..5f19055 100644 --- a/components/task/sectionTanggalTugasTask.tsx +++ b/components/task/sectionTanggalTugasTask.tsx @@ -26,8 +26,9 @@ type Props = { dateEnd: string; } -export default function SectionTanggalTugasTask({ refreshing }: { refreshing: boolean }) { +export default function SectionTanggalTugasTask({ refreshing, isMemberDivision }: { refreshing: boolean, isMemberDivision: boolean }) { const dispatch = useDispatch() + const entityUser = useSelector((state: any) => state.user); const update = useSelector((state: any) => state.taskUpdate) const [isModal, setModal] = useState(false) const [isSelect, setSelect] = useState(false) @@ -155,24 +156,6 @@ export default function SectionTanggalTugasTask({ refreshing }: { refreshing: bo - } - title="Update Status" - onPress={() => { - setModal(false) - setTimeout(() => { - setSelect(true) - }, 600); - }} - /> - } - title="Edit Tugas" - onPress={() => { - setModal(false) - router.push(`./update/${tugas.id}`) - }} - /> - - - } - title="Hapus Tugas" - onPress={() => { - setModal(false) - AlertKonfirmasi({ - title: 'Konfirmasi', - desc: 'Apakah anda yakin ingin menghapus data ini?', - onPress: () => { - handleDelete() - } - }) + { + (entityUser.role != "user" && entityUser.role != "coadmin") || isMemberDivision + ? + <> + } + title="Update Status" + onPress={() => { + setModal(false) + setTimeout(() => { + setSelect(true) + }, 600); + }} + /> + } + title="Edit Tugas" + onPress={() => { + setModal(false) + router.push(`./update/${tugas.id}`) + }} + /> + + : + <> + } - }} - /> + { + (entityUser.role != "user" && entityUser.role != "coadmin") || isMemberDivision + ? + + } + title="Hapus Tugas" + onPress={() => { + setModal(false) + AlertKonfirmasi({ + title: 'Konfirmasi', + desc: 'Apakah anda yakin ingin menghapus data ini?', + onPress: () => { + handleDelete() + } + }) + + }} + /> + + : + <> + }