Compare commits
13 Commits
api-admin/
...
api-admin/
| Author | SHA1 | Date | |
|---|---|---|---|
| b3209dc7ee | |||
| 1e1b18f860 | |||
| 5d4328a139 | |||
| 125bf16605 | |||
| 73a803f2e8 | |||
| 1bcd1a044f | |||
| 1e0b72de22 | |||
| 36dbfa3296 | |||
| 966e55597c | |||
| 4da55a5a8a | |||
| faf0f36e53 | |||
| 57285e5697 | |||
| 1fd9694ebf |
@@ -70,5 +70,6 @@ export default {
|
|||||||
// Tambahkan environment variables ke sini
|
// Tambahkan environment variables ke sini
|
||||||
API_BASE_URL: process.env.API_BASE_URL,
|
API_BASE_URL: process.env.API_BASE_URL,
|
||||||
BASE_URL: process.env.BASE_URL,
|
BASE_URL: process.env.BASE_URL,
|
||||||
|
DEEP_LINK_URL: process.env.DEEP_LINK_URL,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
@@ -122,7 +122,7 @@ export default function DonationInvoice() {
|
|||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<TextCustom size="xlarge" bold color="yellow">
|
<TextCustom size="xlarge" bold color="yellow">
|
||||||
{data?.DonasiMaster_Bank?.norek}
|
{data?.MasterBank?.norek}
|
||||||
</TextCustom>
|
</TextCustom>
|
||||||
</Grid.Col>
|
</Grid.Col>
|
||||||
<Grid.Col
|
<Grid.Col
|
||||||
@@ -131,7 +131,7 @@ export default function DonationInvoice() {
|
|||||||
alignItems: "flex-end",
|
alignItems: "flex-end",
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<CopyButton textToCopy={data?.DonasiMaster_Bank?.norek} />
|
<CopyButton textToCopy={data?.MasterBank?.norek} />
|
||||||
</Grid.Col>
|
</Grid.Col>
|
||||||
</Grid>
|
</Grid>
|
||||||
</BaseBox>
|
</BaseBox>
|
||||||
|
|||||||
@@ -1,17 +1,71 @@
|
|||||||
|
/* eslint-disable react-hooks/exhaustive-deps */
|
||||||
import {
|
import {
|
||||||
BaseBox,
|
BaseBox,
|
||||||
ButtonCenteredOnly,
|
ButtonCenteredOnly,
|
||||||
Grid,
|
Grid,
|
||||||
InformationBox,
|
InformationBox,
|
||||||
|
LoaderCustom,
|
||||||
StackCustom,
|
StackCustom,
|
||||||
TextCustom,
|
TextCustom,
|
||||||
ViewWrapper,
|
ViewWrapper,
|
||||||
} from "@/components";
|
} from "@/components";
|
||||||
|
import {
|
||||||
|
apiDonationDisbursementOfFundsListById,
|
||||||
|
apiDonationGetOne,
|
||||||
|
} from "@/service/api-client/api-donation";
|
||||||
|
import { formatCurrencyDisplay } from "@/utils/formatCurrencyDisplay";
|
||||||
import dayjs from "dayjs";
|
import dayjs from "dayjs";
|
||||||
import { router, useLocalSearchParams } from "expo-router";
|
import { router, useFocusEffect, useLocalSearchParams } from "expo-router";
|
||||||
|
import _ from "lodash";
|
||||||
|
import React, { useState } from "react";
|
||||||
|
|
||||||
export default function DonationFundDisbursement() {
|
export default function DonationFundDisbursement() {
|
||||||
const { id } = useLocalSearchParams();
|
const { id } = useLocalSearchParams();
|
||||||
|
|
||||||
|
const [data, setData] = useState({
|
||||||
|
totalPencairan: 0,
|
||||||
|
akumulasiPencairan: 0,
|
||||||
|
});
|
||||||
|
|
||||||
|
const [listData, setListData] = React.useState<any[] | null>(null);
|
||||||
|
const [loadData, setLoadData] = React.useState(false);
|
||||||
|
|
||||||
|
useFocusEffect(
|
||||||
|
React.useCallback(() => {
|
||||||
|
onLoadData();
|
||||||
|
}, [id])
|
||||||
|
);
|
||||||
|
|
||||||
|
const onLoadData = async () => {
|
||||||
|
try {
|
||||||
|
setLoadData(true);
|
||||||
|
|
||||||
|
const responseData = await apiDonationGetOne({
|
||||||
|
id: id as string,
|
||||||
|
category: "permanent",
|
||||||
|
});
|
||||||
|
|
||||||
|
if (responseData.success) {
|
||||||
|
setData({
|
||||||
|
totalPencairan: responseData.data.totalPencairan,
|
||||||
|
akumulasiPencairan: responseData.data.akumulasiPencairan,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
const responseList = await apiDonationDisbursementOfFundsListById({
|
||||||
|
id: id as string,
|
||||||
|
});
|
||||||
|
|
||||||
|
if (responseList.success) {
|
||||||
|
setListData(responseList.data);
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.log("[ERROR]", error);
|
||||||
|
} finally {
|
||||||
|
setLoadData(false);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<ViewWrapper>
|
<ViewWrapper>
|
||||||
@@ -20,47 +74,50 @@ export default function DonationFundDisbursement() {
|
|||||||
<Grid>
|
<Grid>
|
||||||
<Grid.Col span={6}>
|
<Grid.Col span={6}>
|
||||||
<TextCustom bold color="yellow">
|
<TextCustom bold color="yellow">
|
||||||
Rp. 0
|
Rp. {formatCurrencyDisplay(data?.totalPencairan)}
|
||||||
</TextCustom>
|
</TextCustom>
|
||||||
<TextCustom size="small">Total Pencairan Dana</TextCustom>
|
<TextCustom size="small">Total Pencairan Dana</TextCustom>
|
||||||
</Grid.Col>
|
</Grid.Col>
|
||||||
<Grid.Col span={6}>
|
<Grid.Col span={6}>
|
||||||
<TextCustom bold color="yellow">
|
<TextCustom bold color="yellow">
|
||||||
0 kali
|
{data?.akumulasiPencairan} kali
|
||||||
</TextCustom>
|
</TextCustom>
|
||||||
<TextCustom size="small">Akumulasi Pencairan</TextCustom>
|
<TextCustom size="small">Akumulasi Pencairan</TextCustom>
|
||||||
</Grid.Col>
|
</Grid.Col>
|
||||||
</Grid>
|
</Grid>
|
||||||
</BaseBox>
|
</BaseBox>
|
||||||
|
|
||||||
{Array.from({ length: 10 }).map((_, index) => (
|
{loadData ? (
|
||||||
<BaseBox key={index}>
|
<LoaderCustom />
|
||||||
<StackCustom>
|
) : _.isEmpty(listData) ? (
|
||||||
<Grid>
|
<TextCustom align="center" color="gray">
|
||||||
<Grid.Col span={8}>
|
Belum ada data
|
||||||
<TextCustom bold>Pencairan ke - {index + 1}</TextCustom>
|
</TextCustom>
|
||||||
</Grid.Col>
|
) : (
|
||||||
<Grid.Col span={4} style={{ alignItems: "flex-end" }}>
|
listData?.map((item, index) => (
|
||||||
<TextCustom>{dayjs().format("DD MMM YYYY")}</TextCustom>
|
<BaseBox key={index}>
|
||||||
</Grid.Col>
|
<StackCustom>
|
||||||
</Grid>
|
<Grid>
|
||||||
<TextCustom>
|
<Grid.Col span={8}>
|
||||||
Lorem ipsum dolor sit amet consectetur adipisicing elit.
|
<TextCustom bold>{item?.title}</TextCustom>
|
||||||
Nesciunt dolor ad sit? Eaque rem nihil natus, id, esse possimus
|
</Grid.Col>
|
||||||
perferendis provident velit illo consectetur distinctio ab
|
<Grid.Col span={4} style={{ alignItems: "flex-end" }}>
|
||||||
accusantium quis earum omnis!
|
<TextCustom>{dayjs(item?.createdAt).format("DD MMM YYYY")}</TextCustom>
|
||||||
</TextCustom>
|
</Grid.Col>
|
||||||
<ButtonCenteredOnly
|
</Grid>
|
||||||
onPress={() => {
|
<TextCustom>{item?.deskripsi}</TextCustom>
|
||||||
router.navigate(`/(application)/(file)/${id}`);
|
<ButtonCenteredOnly
|
||||||
}}
|
onPress={() => {
|
||||||
icon="file-text"
|
router.navigate(`/(application)/(image)/preview-image/${item?.imageId}`);
|
||||||
>
|
}}
|
||||||
Bukti Transaksi
|
icon="file-text"
|
||||||
</ButtonCenteredOnly>
|
>
|
||||||
</StackCustom>
|
Bukti Transaksi
|
||||||
</BaseBox>
|
</ButtonCenteredOnly>
|
||||||
))}
|
</StackCustom>
|
||||||
|
</BaseBox>
|
||||||
|
))
|
||||||
|
)}
|
||||||
</ViewWrapper>
|
</ViewWrapper>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -16,20 +16,19 @@ import Donation_ComponentInfoFundrising from "@/screens/Donation/ComponentInfoFu
|
|||||||
import Donation_ComponentStoryFunrising from "@/screens/Donation/ComponentStoryFunrising";
|
import Donation_ComponentStoryFunrising from "@/screens/Donation/ComponentStoryFunrising";
|
||||||
import Donation_ProgressSection from "@/screens/Donation/ProgressSection";
|
import Donation_ProgressSection from "@/screens/Donation/ProgressSection";
|
||||||
import { apiDonationGetOne } from "@/service/api-client/api-donation";
|
import { apiDonationGetOne } from "@/service/api-client/api-donation";
|
||||||
|
import { countDownAndCondition } from "@/utils/countDownAndCondition";
|
||||||
import {
|
import {
|
||||||
router,
|
router,
|
||||||
Stack,
|
Stack,
|
||||||
useFocusEffect,
|
useFocusEffect,
|
||||||
useLocalSearchParams,
|
useLocalSearchParams,
|
||||||
} from "expo-router";
|
} from "expo-router";
|
||||||
import { useCallback, useState } from "react";
|
import { useCallback, useEffect, useState } from "react";
|
||||||
|
|
||||||
export default function DonasiDetailBeranda() {
|
export default function DonasiDetailBeranda() {
|
||||||
const { user } = useAuth();
|
const { user } = useAuth();
|
||||||
const { id } = useLocalSearchParams();
|
const { id } = useLocalSearchParams();
|
||||||
console.log("ID ", id);
|
|
||||||
const [openDrawer, setOpenDrawer] = useState(false);
|
const [openDrawer, setOpenDrawer] = useState(false);
|
||||||
|
|
||||||
const [data, setData] = useState<any>();
|
const [data, setData] = useState<any>();
|
||||||
|
|
||||||
useFocusEffect(
|
useFocusEffect(
|
||||||
@@ -45,21 +44,41 @@ export default function DonasiDetailBeranda() {
|
|||||||
category: "permanent",
|
category: "permanent",
|
||||||
});
|
});
|
||||||
|
|
||||||
console.log("[RES GET ONE]", JSON.stringify(response.data, null, 2));
|
|
||||||
|
|
||||||
setData(response.data);
|
setData(response.data);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log("[ERROR]", error);
|
console.log("[ERROR]", error);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const [value, setValue] = useState({
|
||||||
|
sisa: 0,
|
||||||
|
reminder: false,
|
||||||
|
});
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
updateCountDown();
|
||||||
|
}, [data]);
|
||||||
|
|
||||||
|
const updateCountDown = () => {
|
||||||
|
const countDown = countDownAndCondition({
|
||||||
|
duration: data?.DonasiMaster_Durasi?.name,
|
||||||
|
publishTime: data?.publishTime,
|
||||||
|
});
|
||||||
|
|
||||||
|
setValue({
|
||||||
|
sisa: countDown.durationDay,
|
||||||
|
reminder: countDown.reminder,
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
const buttonSection = (
|
const buttonSection = (
|
||||||
<>
|
<>
|
||||||
<BoxButtonOnFooter>
|
<BoxButtonOnFooter>
|
||||||
<ButtonCustom
|
<ButtonCustom
|
||||||
|
disabled={value?.reminder}
|
||||||
onPress={() => router.navigate(`/donation/${id}/(transaction-flow)`)}
|
onPress={() => router.navigate(`/donation/${id}/(transaction-flow)`)}
|
||||||
>
|
>
|
||||||
Donasi
|
{value?.reminder ? "Waktu berakhir" : "Donasi"}
|
||||||
</ButtonCustom>
|
</ButtonCustom>
|
||||||
</BoxButtonOnFooter>
|
</BoxButtonOnFooter>
|
||||||
</>
|
</>
|
||||||
@@ -80,8 +99,10 @@ export default function DonasiDetailBeranda() {
|
|||||||
<ViewWrapper footerComponent={buttonSection}>
|
<ViewWrapper footerComponent={buttonSection}>
|
||||||
<StackCustom>
|
<StackCustom>
|
||||||
<Donation_ComponentBoxDetailData
|
<Donation_ComponentBoxDetailData
|
||||||
|
sisaHari={value.sisa}
|
||||||
|
reminder={value.reminder}
|
||||||
data={data}
|
data={data}
|
||||||
bottomSection={<Donation_ProgressSection id={id as string} />}
|
bottomSection={<Donation_ProgressSection id={id as string} progres={Number(data?.progres) || 0} />}
|
||||||
/>
|
/>
|
||||||
<Donation_ComponentInfoFundrising dataAuthor={data?.Author} />
|
<Donation_ComponentInfoFundrising dataAuthor={data?.Author} />
|
||||||
<Donation_ComponentStoryFunrising
|
<Donation_ComponentStoryFunrising
|
||||||
|
|||||||
@@ -1,46 +1,93 @@
|
|||||||
|
/* eslint-disable react-hooks/exhaustive-deps */
|
||||||
import {
|
import {
|
||||||
BaseBox,
|
BaseBox,
|
||||||
Grid,
|
Grid,
|
||||||
|
LoaderCustom,
|
||||||
|
Spacing,
|
||||||
StackCustom,
|
StackCustom,
|
||||||
TextCustom,
|
TextCustom,
|
||||||
ViewWrapper,
|
ViewWrapper,
|
||||||
} from "@/components";
|
} from "@/components";
|
||||||
import { MainColor } from "@/constants/color-palet";
|
import { MainColor } from "@/constants/color-palet";
|
||||||
|
import { apiAdminDonationListOfDonaturById } from "@/service/api-admin/api-admin-donation";
|
||||||
|
import { formatCurrencyDisplay } from "@/utils/formatCurrencyDisplay";
|
||||||
import { FontAwesome6 } from "@expo/vector-icons";
|
import { FontAwesome6 } from "@expo/vector-icons";
|
||||||
import dayjs from "dayjs";
|
import dayjs from "dayjs";
|
||||||
|
import { useFocusEffect, useLocalSearchParams } from "expo-router";
|
||||||
|
import _ from "lodash";
|
||||||
|
import { useCallback, useState } from "react";
|
||||||
|
|
||||||
export default function Donation_ListOfDonatur() {
|
export default function Donation_ListOfDonatur() {
|
||||||
|
const { id } = useLocalSearchParams();
|
||||||
|
const [listData, setListData] = useState<any[] | null>(null);
|
||||||
|
const [loadData, setLoadData] = useState(false);
|
||||||
|
|
||||||
|
useFocusEffect(
|
||||||
|
useCallback(() => {
|
||||||
|
onLoadData();
|
||||||
|
}, [id])
|
||||||
|
);
|
||||||
|
|
||||||
|
const onLoadData = async () => {
|
||||||
|
try {
|
||||||
|
setLoadData(true);
|
||||||
|
const response = await apiAdminDonationListOfDonaturById({
|
||||||
|
id: id as string,
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
if (response.success) {
|
||||||
|
setListData(response.data);
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.log("[ERROR]", error);
|
||||||
|
} finally {
|
||||||
|
setLoadData(false);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<ViewWrapper>
|
<ViewWrapper>
|
||||||
{Array.from({ length: 10 }).map((_, index) => (
|
{loadData ? (
|
||||||
<BaseBox key={index}>
|
<LoaderCustom />
|
||||||
<Grid>
|
) : _.isEmpty(listData) ? (
|
||||||
<Grid.Col
|
<TextCustom bold align="center">
|
||||||
span={3}
|
Belum ada donatur
|
||||||
style={{ alignItems: "center", justifyContent: "center" }}
|
</TextCustom>
|
||||||
>
|
) : (
|
||||||
<FontAwesome6
|
listData?.map((item: any, index: number) => (
|
||||||
name="face-smile-wink"
|
<BaseBox key={index}>
|
||||||
size={50}
|
<Grid>
|
||||||
style={{ color: MainColor.yellow }}
|
<Grid.Col
|
||||||
/>
|
span={3}
|
||||||
</Grid.Col>
|
style={{ alignItems: "center", justifyContent: "center" }}
|
||||||
<Grid.Col span={9}>
|
>
|
||||||
<StackCustom gap={"xs"}>
|
<FontAwesome6
|
||||||
|
name="face-smile-wink"
|
||||||
|
size={50}
|
||||||
|
style={{ color: MainColor.yellow }}
|
||||||
|
/>
|
||||||
|
</Grid.Col>
|
||||||
|
<Grid.Col span={9}>
|
||||||
<TextCustom bold size="large">
|
<TextCustom bold size="large">
|
||||||
Username
|
{item?.Author?.username || "-"}
|
||||||
</TextCustom>
|
</TextCustom>
|
||||||
<TextCustom>Berdonas sebesar </TextCustom>
|
<Spacing/>
|
||||||
<TextCustom bold size="large" color="yellow">
|
<StackCustom gap={"xs"}>
|
||||||
Rp. 100.000
|
<TextCustom size={"small"}>Berdonas sebesar </TextCustom>
|
||||||
</TextCustom>
|
<TextCustom bold size="large" color="yellow">
|
||||||
<TextCustom>{dayjs().format("DD MMM YYYY")}</TextCustom>
|
Rp. {formatCurrencyDisplay(item?.nominal)}
|
||||||
</StackCustom>
|
</TextCustom>
|
||||||
</Grid.Col>
|
<TextCustom>
|
||||||
</Grid>
|
{dayjs(item?.createdAt).format("DD MMM YYYY, HH:mm")}
|
||||||
</BaseBox>
|
</TextCustom>
|
||||||
))}
|
</StackCustom>
|
||||||
|
</Grid.Col>
|
||||||
|
</Grid>
|
||||||
|
</BaseBox>
|
||||||
|
))
|
||||||
|
)}
|
||||||
</ViewWrapper>
|
</ViewWrapper>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -44,6 +44,8 @@ export default function EventBeranda() {
|
|||||||
<TextCustom align="center">Belum ada event</TextCustom>
|
<TextCustom align="center">Belum ada event</TextCustom>
|
||||||
) : (
|
) : (
|
||||||
listData.map((item: any, index) => (
|
listData.map((item: any, index) => (
|
||||||
|
|
||||||
|
|
||||||
<Event_BoxPublishSection
|
<Event_BoxPublishSection
|
||||||
key={index}
|
key={index}
|
||||||
href={`/event/${item.id}/publish`}
|
href={`/event/${item.id}/publish`}
|
||||||
|
|||||||
554
app/(application)/(user)/event/[id]/confirmation.tsx
Normal file
554
app/(application)/(user)/event/[id]/confirmation.tsx
Normal file
@@ -0,0 +1,554 @@
|
|||||||
|
/* eslint-disable @typescript-eslint/no-unused-vars */
|
||||||
|
/* eslint-disable react-hooks/exhaustive-deps */
|
||||||
|
import {
|
||||||
|
BaseBox,
|
||||||
|
ButtonCustom,
|
||||||
|
CenterCustom,
|
||||||
|
LoaderCustom,
|
||||||
|
StackCustom,
|
||||||
|
TextCustom,
|
||||||
|
ViewWrapper,
|
||||||
|
} from "@/components";
|
||||||
|
import { AccentColor, MainColor } from "@/constants/color-palet";
|
||||||
|
import { useAuth } from "@/hooks/use-auth";
|
||||||
|
import {
|
||||||
|
apiEventConfirmationAction,
|
||||||
|
apiEventGetConfirmation,
|
||||||
|
apiEventJoin,
|
||||||
|
} from "@/service/api-client/api-event";
|
||||||
|
import { Ionicons } from "@expo/vector-icons";
|
||||||
|
import dayjs from "dayjs";
|
||||||
|
import isBetween from "dayjs/plugin/isBetween";
|
||||||
|
import {
|
||||||
|
Redirect,
|
||||||
|
router,
|
||||||
|
Stack,
|
||||||
|
useFocusEffect,
|
||||||
|
useLocalSearchParams,
|
||||||
|
} from "expo-router";
|
||||||
|
import React, { useCallback, useState } from "react";
|
||||||
|
import { View } from "react-native";
|
||||||
|
import Toast from "react-native-toast-message";
|
||||||
|
|
||||||
|
// Extend Day.js dengan plugin isBetween
|
||||||
|
dayjs.extend(isBetween);
|
||||||
|
|
||||||
|
interface DataEvent {
|
||||||
|
id: string;
|
||||||
|
title: string;
|
||||||
|
tanggal: Date;
|
||||||
|
tanggalSelesai: Date;
|
||||||
|
lokasi: string;
|
||||||
|
Author: {
|
||||||
|
id: string;
|
||||||
|
username: string;
|
||||||
|
Profile: {
|
||||||
|
id: string;
|
||||||
|
name: string;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
export default function UserEventConfirmation() {
|
||||||
|
const { token } = useAuth();
|
||||||
|
const { id, userId: authorId } = useLocalSearchParams();
|
||||||
|
const { user } = useAuth();
|
||||||
|
const [data, setData] = useState<DataEvent | null>(null);
|
||||||
|
const [peserta, setPeserta] = useState<boolean | null>(null);
|
||||||
|
const [konfirmasi, setKonfirmasi] = useState<boolean | null>(null);
|
||||||
|
|
||||||
|
useFocusEffect(
|
||||||
|
useCallback(() => {
|
||||||
|
checkTokenAndDataParticipants() || console.log("Token is null");
|
||||||
|
}, [token, id, user?.id])
|
||||||
|
);
|
||||||
|
|
||||||
|
const checkTokenAndDataParticipants = async () => {
|
||||||
|
if (!token) {
|
||||||
|
return <Redirect href={`/`} />;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
const response = await apiEventGetConfirmation({
|
||||||
|
id: id as string,
|
||||||
|
userId: user?.id as string,
|
||||||
|
});
|
||||||
|
|
||||||
|
if (response.success) {
|
||||||
|
setData(response.data?.dataEvent);
|
||||||
|
setPeserta(response.data?.peserta);
|
||||||
|
setKonfirmasi(response.data?.kehadiran);
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.log("[ERROR CONFIRMATION]", error);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const handlerReturn = () => {
|
||||||
|
const now = dayjs(); // asumsi: UTC, sesuai dengan API
|
||||||
|
|
||||||
|
// --- [1] Loading & Data tidak ditemukan ---
|
||||||
|
if (data === undefined || data === null) {
|
||||||
|
if (peserta === null && konfirmasi === null) {
|
||||||
|
return <LoaderCustom />;
|
||||||
|
}
|
||||||
|
return (
|
||||||
|
<BaseBox>
|
||||||
|
<TextCustom bold align="center" size={"large"}>
|
||||||
|
Data Tidak Ditemukan
|
||||||
|
</TextCustom>
|
||||||
|
<BackToOtherPath path="home" />
|
||||||
|
</BaseBox>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// --- [2] Ambil waktu event dari `data` ---
|
||||||
|
const eventStart = dayjs(data.tanggal);
|
||||||
|
const eventEnd = dayjs(data.tanggalSelesai);
|
||||||
|
|
||||||
|
// --- [3] Definisikan jendela konfirmasi: 1 jam sebelum mulai → 1 jam setelah selesai ---
|
||||||
|
const confirmationStart = eventStart.subtract(1, "hour");
|
||||||
|
const confirmationEnd = eventEnd.add(1, "hour");
|
||||||
|
const isWithinConfirmationWindow = now.isBetween(
|
||||||
|
confirmationStart,
|
||||||
|
confirmationEnd,
|
||||||
|
null,
|
||||||
|
"[]"
|
||||||
|
);
|
||||||
|
|
||||||
|
// --- [4] Status waktu event (untuk pesan UI) ---
|
||||||
|
const isBeforeEvent = now.isBefore(eventStart);
|
||||||
|
const isAfterEvent = now.isAfter(eventEnd);
|
||||||
|
const isDuringEvent = !isBeforeEvent && !isAfterEvent;
|
||||||
|
|
||||||
|
// --- [5] Handle berdasarkan waktu dan status peserta/konfirmasi ---
|
||||||
|
|
||||||
|
// 🟢 Acara sudah selesai
|
||||||
|
if (isAfterEvent) {
|
||||||
|
if (peserta === false) {
|
||||||
|
return (
|
||||||
|
<TamplateBox data={data}>
|
||||||
|
<TamplateText text="Event telah selesai, sehingga konfirmasi kehadiran sudah tidak dapat dilakukan. Terima kasih atas perhatian dan minat Anda. Kami berharap dapat bertemu di acara kami berikutnya." />
|
||||||
|
<BackToOtherPath
|
||||||
|
path="event"
|
||||||
|
id={data.id}
|
||||||
|
isAfterEvent={isAfterEvent}
|
||||||
|
/>
|
||||||
|
</TamplateBox>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return (
|
||||||
|
<TamplateBox data={data}>
|
||||||
|
<TamplateText
|
||||||
|
text={`Event telah selesai, anda terdaftar sebagai peserta dan ${
|
||||||
|
konfirmasi
|
||||||
|
? "Anda telah mengonfirmasi kehadiran."
|
||||||
|
: "Anda tidak mengonfirmasi kehadiran."
|
||||||
|
} Terima kasih atas perhatian dan minat Anda. Kami berharap dapat bertemu di acara kami berikutnya.`}
|
||||||
|
/>
|
||||||
|
<BackToOtherPath
|
||||||
|
path="event"
|
||||||
|
id={data.id}
|
||||||
|
isAfterEvent={isAfterEvent}
|
||||||
|
/>
|
||||||
|
</TamplateBox>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 🔵 Acara belum mulai & belum terdaftar
|
||||||
|
if (isBeforeEvent) {
|
||||||
|
if (peserta === false) {
|
||||||
|
return (
|
||||||
|
<NotStarted_And_UserNotParticipan
|
||||||
|
id={data.id}
|
||||||
|
userId={user?.id as string}
|
||||||
|
data={data}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Peserta sudah daftar → cek apakah sudah boleh konfirmasi
|
||||||
|
if (isWithinConfirmationWindow && peserta === true) {
|
||||||
|
if (konfirmasi === false) {
|
||||||
|
return (
|
||||||
|
<UserParticipan_And_DuringEvent
|
||||||
|
id={data.id}
|
||||||
|
userId={user?.id as string}
|
||||||
|
data={data}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return (
|
||||||
|
<TamplateBox data={data}>
|
||||||
|
<TamplateText text="Terimakasih telah mengonfirmasi kehadiran. Silahkan lihat peserta lain pada halaman event atau kembali ke halaman home. Selamat menikmati acara dan selamat berpartisipasi." />
|
||||||
|
<BackToOtherPath
|
||||||
|
path="event"
|
||||||
|
id={data.id}
|
||||||
|
isAfterEvent={isAfterEvent}
|
||||||
|
/>
|
||||||
|
</TamplateBox>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<TamplateBox data={data}>
|
||||||
|
<TamplateText text="Anda telah terdaftar sebagai peserta pada Event ini. Konfirmasi kehadiran dibuka 1 jam sebelum acara dimulai." />
|
||||||
|
<BackToOtherPath
|
||||||
|
path="event"
|
||||||
|
id={data.id}
|
||||||
|
isAfterEvent={isAfterEvent}
|
||||||
|
/>
|
||||||
|
</TamplateBox>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 🟡 Acara sedang berlangsung & belum terdaftar
|
||||||
|
if (isDuringEvent) {
|
||||||
|
if (peserta === false) {
|
||||||
|
return (
|
||||||
|
<UserNotParticipan_And_DuringEvent
|
||||||
|
id={data.id}
|
||||||
|
userId={user?.id as string}
|
||||||
|
data={data}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (peserta === true) {
|
||||||
|
if (isWithinConfirmationWindow) {
|
||||||
|
if (konfirmasi === false) {
|
||||||
|
return (
|
||||||
|
<TamplateBox data={data}>
|
||||||
|
<TamplateText text="Konfirmasi Kehadiran" />
|
||||||
|
</TamplateBox>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return (
|
||||||
|
<TamplateBox data={data}>
|
||||||
|
<TamplateText text="Anda telah mengonfirmasi kehadiran dalam event ini. Terima kasih dan selamat menikmati acara. Have fun!" />
|
||||||
|
<BackToOtherPath
|
||||||
|
path="event"
|
||||||
|
id={data.id}
|
||||||
|
isAfterEvent={isAfterEvent}
|
||||||
|
/>
|
||||||
|
</TamplateBox>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ini sangat jarang terjadi selama event berlangsung, tapi aman
|
||||||
|
return (
|
||||||
|
<TamplateBox data={data}>
|
||||||
|
<TamplateText text="Konfirmasi kehadiran tidak tersedia saat ini." />
|
||||||
|
<BackToOtherPath path="home" />
|
||||||
|
</TamplateBox>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 🛑 Fallback aman
|
||||||
|
return (
|
||||||
|
<BaseBox>
|
||||||
|
<StackCustom>
|
||||||
|
<TamplateText text="Terjadi kesalahan tak terduga pada logika waktu." />
|
||||||
|
<BackToOtherPath path="home" />
|
||||||
|
</StackCustom>
|
||||||
|
</BaseBox>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<Stack.Screen
|
||||||
|
options={{
|
||||||
|
title: "Konfirmasi Event",
|
||||||
|
headerLeft: () => (
|
||||||
|
<Ionicons
|
||||||
|
name="arrow-back"
|
||||||
|
size={20}
|
||||||
|
color={MainColor.yellow}
|
||||||
|
onPress={() =>
|
||||||
|
router.navigate("/(application)/(user)/event/create")
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
),
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
<ViewWrapper>{handlerReturn()}</ViewWrapper>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const TamplateBox = ({
|
||||||
|
data,
|
||||||
|
children,
|
||||||
|
}: {
|
||||||
|
data: DataEvent;
|
||||||
|
children: React.ReactNode;
|
||||||
|
}) => {
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<CenterCustom>
|
||||||
|
<BaseBox>
|
||||||
|
<StackCustom gap={"lg"}>
|
||||||
|
<StackCustom gap={"sm"}>
|
||||||
|
<TextCustom bold align="center" size={"large"}>
|
||||||
|
{data?.title}
|
||||||
|
</TextCustom>
|
||||||
|
<View
|
||||||
|
style={{
|
||||||
|
flexDirection: "row",
|
||||||
|
justifyContent: "center",
|
||||||
|
// backgroundColor: AccentColor.blue,
|
||||||
|
// borderColor: AccentColor.blue,
|
||||||
|
// borderWidth: 1,
|
||||||
|
// borderRadius: 4,
|
||||||
|
// padding: 3
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<TextCustom align="center" size="small" bold>
|
||||||
|
{dayjs(data?.tanggal).format("DD MMM YYYY: HH:mm")}
|
||||||
|
</TextCustom>
|
||||||
|
<TextCustom align="center" size="small" bold>
|
||||||
|
{" "}
|
||||||
|
-{" "}
|
||||||
|
</TextCustom>
|
||||||
|
<TextCustom align="center" size="small" bold>
|
||||||
|
{dayjs(data?.tanggalSelesai).format("DD MMM YYYY: HH:mm")}
|
||||||
|
</TextCustom>
|
||||||
|
</View>
|
||||||
|
</StackCustom>
|
||||||
|
|
||||||
|
{children}
|
||||||
|
</StackCustom>
|
||||||
|
</BaseBox>
|
||||||
|
</CenterCustom>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
const TamplateText = ({ text }: { text: React.ReactNode }) => {
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<TextCustom align="center">{text}</TextCustom>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
type BackToOtherPathProps =
|
||||||
|
| { path: "home" | "beranda-event"; id?: never; isAfterEvent?: never }
|
||||||
|
| { path: "event"; id: string; isAfterEvent: boolean };
|
||||||
|
|
||||||
|
const BackToOtherPath = ({ path, id, isAfterEvent }: BackToOtherPathProps) => {
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
{path === "home" ? (
|
||||||
|
<ButtonCustom
|
||||||
|
onPress={() => {
|
||||||
|
router.replace("/(application)/home");
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
Home
|
||||||
|
</ButtonCustom>
|
||||||
|
) : (
|
||||||
|
<View
|
||||||
|
style={{
|
||||||
|
flexDirection: "row",
|
||||||
|
gap: 10,
|
||||||
|
|
||||||
|
justifyContent: "center",
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<ButtonCustom
|
||||||
|
onPress={() => {
|
||||||
|
router.replace("/(application)/home");
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
Home
|
||||||
|
</ButtonCustom>
|
||||||
|
<ButtonCustom
|
||||||
|
onPress={() => {
|
||||||
|
if (path === "event") {
|
||||||
|
if (isAfterEvent) {
|
||||||
|
router.push(`/(application)/(user)/event/${id}/history`);
|
||||||
|
} else {
|
||||||
|
router.push(`/(application)/(user)/event/${id}/publish`);
|
||||||
|
}
|
||||||
|
} else if (path === "beranda-event") {
|
||||||
|
router.push(`/(application)/(user)/event`);
|
||||||
|
} else {
|
||||||
|
console.log("[PATH]", path);
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
Lihat {path === "event" ? "Event" : "Beranda Event"}
|
||||||
|
</ButtonCustom>
|
||||||
|
</View>
|
||||||
|
)}
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
// 🔵 Acara belum mulai & belum terdaftar
|
||||||
|
const NotStarted_And_UserNotParticipan = ({
|
||||||
|
id,
|
||||||
|
userId,
|
||||||
|
data,
|
||||||
|
}: {
|
||||||
|
id: string;
|
||||||
|
userId: string;
|
||||||
|
data: DataEvent;
|
||||||
|
}) => {
|
||||||
|
const [isLoading, setIsLoading] = useState<boolean>(false);
|
||||||
|
|
||||||
|
const handlerJoinEvent = async () => {
|
||||||
|
try {
|
||||||
|
setIsLoading(true);
|
||||||
|
|
||||||
|
const response = await apiEventJoin({
|
||||||
|
id: id as string,
|
||||||
|
userId: userId as string,
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!response.success) {
|
||||||
|
Toast.show({
|
||||||
|
type: "error",
|
||||||
|
text1: "Anda gagal join",
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Toast.show({
|
||||||
|
type: "success",
|
||||||
|
text1: "Anda berhasil join",
|
||||||
|
});
|
||||||
|
router.navigate(`/(application)/(user)/event/${id}/publish`);
|
||||||
|
} catch (error) {
|
||||||
|
console.log("[ERROR JOIN EVENT]", error);
|
||||||
|
} finally {
|
||||||
|
setIsLoading(false);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<TamplateBox data={data}>
|
||||||
|
<TamplateText text="Anda belum terdaftar sebagai peserta & Event belum dimulai. Silahkan daftarkan diri anda terlebih dahulu" />
|
||||||
|
<ButtonCustom onPress={handlerJoinEvent} isLoading={isLoading}>
|
||||||
|
Join
|
||||||
|
</ButtonCustom>
|
||||||
|
</TamplateBox>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
// 🟡 ZONA ACARA BERLANGSUNG
|
||||||
|
// Acara sedang berlangsung & belum terdaftar & user harus join dan konfirmasi
|
||||||
|
const UserNotParticipan_And_DuringEvent = ({
|
||||||
|
id,
|
||||||
|
userId,
|
||||||
|
data,
|
||||||
|
}: {
|
||||||
|
id: string;
|
||||||
|
userId: string;
|
||||||
|
data: DataEvent;
|
||||||
|
}) => {
|
||||||
|
const [isLoading, setIsLoading] = useState<boolean>(false);
|
||||||
|
|
||||||
|
const handlerSubmit = async () => {
|
||||||
|
try {
|
||||||
|
setIsLoading(true);
|
||||||
|
|
||||||
|
const response = await apiEventConfirmationAction({
|
||||||
|
id: id as string,
|
||||||
|
userId: userId as string,
|
||||||
|
category: "join_and_confirm",
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!response.success) {
|
||||||
|
Toast.show({
|
||||||
|
type: "error",
|
||||||
|
text1: "Anda gagal join & konfirmasi",
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Toast.show({
|
||||||
|
type: "success",
|
||||||
|
text1: "Anda berhasil join & konfirmasi",
|
||||||
|
});
|
||||||
|
router.navigate(`/(application)/(user)/event/${id}/publish`);
|
||||||
|
} catch (error) {
|
||||||
|
console.log("[ERROR JOIN & CONFIRMATION EVENT]", error);
|
||||||
|
} finally {
|
||||||
|
setIsLoading(false);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<TamplateBox data={data}>
|
||||||
|
<TamplateText text="Anda belum terdaftar sebagai peserta & Event sedang berlangsung. Silahkan daftarkan diri anda & Konfirmasi kehadiran" />
|
||||||
|
|
||||||
|
<ButtonCustom onPress={() => handlerSubmit()} isLoading={isLoading}>
|
||||||
|
Join & Konfirmasi
|
||||||
|
</ButtonCustom>
|
||||||
|
</TamplateBox>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// 🟡 ZONA ACARA BERLANGSUN
|
||||||
|
// User sudah terdaftar & Event sedang berlangsung & user harus konfirmasi
|
||||||
|
const UserParticipan_And_DuringEvent = ({
|
||||||
|
id,
|
||||||
|
userId,
|
||||||
|
data,
|
||||||
|
}: {
|
||||||
|
id: string;
|
||||||
|
userId: string;
|
||||||
|
data: DataEvent;
|
||||||
|
}) => {
|
||||||
|
const [isLoading, setIsLoading] = useState<boolean>(false);
|
||||||
|
|
||||||
|
const handlerSubmit = async () => {
|
||||||
|
try {
|
||||||
|
setIsLoading(true);
|
||||||
|
|
||||||
|
const response = await apiEventConfirmationAction({
|
||||||
|
id: id as string,
|
||||||
|
userId: userId as string,
|
||||||
|
category: "confirmation",
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!response.success) {
|
||||||
|
Toast.show({
|
||||||
|
type: "error",
|
||||||
|
text1: "Anda gagal konfirmasi",
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Toast.show({
|
||||||
|
type: "success",
|
||||||
|
text1: "Anda berhasil konfirmasi",
|
||||||
|
});
|
||||||
|
router.navigate(`/(application)/(user)/event/${id}/publish`);
|
||||||
|
} catch (error) {
|
||||||
|
console.log("[ERROR JOIN & CONFIRMATION EVENT]", error);
|
||||||
|
} finally {
|
||||||
|
setIsLoading(false);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<TamplateBox data={data}>
|
||||||
|
<TamplateText text="Anda sudah terdaftar sebagai peserta & Event sedang berlangsung. Silahkan konfirmasi kehadiran" />
|
||||||
|
|
||||||
|
<ButtonCustom onPress={() => handlerSubmit()} isLoading={isLoading}>
|
||||||
|
Konfirmasi
|
||||||
|
</ButtonCustom>
|
||||||
|
</TamplateBox>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
};
|
||||||
@@ -11,29 +11,30 @@ import {
|
|||||||
apiEventGetOne,
|
apiEventGetOne,
|
||||||
apiEventListOfParticipants,
|
apiEventListOfParticipants,
|
||||||
} from "@/service/api-client/api-event";
|
} from "@/service/api-client/api-event";
|
||||||
import { useLocalSearchParams } from "expo-router";
|
import dayjs, { Dayjs } from "dayjs";
|
||||||
import { useEffect, useState } from "react";
|
import { useFocusEffect, useLocalSearchParams } from "expo-router";
|
||||||
|
import _ from "lodash";
|
||||||
|
import { useCallback, useState } from "react";
|
||||||
import { View } from "react-native";
|
import { View } from "react-native";
|
||||||
|
|
||||||
export default function EventListOfParticipants() {
|
export default function EventListOfParticipants() {
|
||||||
const { id } = useLocalSearchParams();
|
const { id } = useLocalSearchParams();
|
||||||
const [startDate, setStartDate] = useState();
|
const [startDate, setStartDate] = useState<Dayjs | undefined>();
|
||||||
const [listData, setListData] = useState([]);
|
const [listData, setListData] = useState<any[] | null>(null);
|
||||||
const [isLoadData, setIsLoadData] = useState(false);
|
const [loadtData, setLoadData] = useState(false);
|
||||||
|
|
||||||
useEffect(() => {
|
useFocusEffect(
|
||||||
handlerLoadData();
|
useCallback(() => {
|
||||||
}, [id]);
|
handlerLoadData();
|
||||||
|
}, [id])
|
||||||
|
);
|
||||||
|
|
||||||
const handlerLoadData = () => {
|
const handlerLoadData = () => {
|
||||||
try {
|
try {
|
||||||
setIsLoadData(true);
|
|
||||||
onLoadData();
|
onLoadData();
|
||||||
onLoadList();
|
onLoadList();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log("[ERROR]", error);
|
console.log("[ERROR]", error);
|
||||||
} finally {
|
|
||||||
setIsLoadData(false);
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -41,7 +42,8 @@ export default function EventListOfParticipants() {
|
|||||||
try {
|
try {
|
||||||
const response = await apiEventGetOne({ id: id as string });
|
const response = await apiEventGetOne({ id: id as string });
|
||||||
if (response.success) {
|
if (response.success) {
|
||||||
setStartDate(response.data.tanggal);
|
const date = dayjs(response.data.tanggal);
|
||||||
|
setStartDate(date);
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log("[ERROR]", error);
|
console.log("[ERROR]", error);
|
||||||
@@ -50,30 +52,36 @@ export default function EventListOfParticipants() {
|
|||||||
|
|
||||||
const onLoadList = async () => {
|
const onLoadList = async () => {
|
||||||
try {
|
try {
|
||||||
|
setLoadData(true);
|
||||||
const response = await apiEventListOfParticipants({ id: id as string });
|
const response = await apiEventListOfParticipants({ id: id as string });
|
||||||
|
|
||||||
if (response.success) {
|
if (response.success) {
|
||||||
setListData(response.data);
|
setListData(response.data);
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log("[ERROR]", error);
|
console.log("[ERROR]", error);
|
||||||
|
} finally {
|
||||||
|
setLoadData(false);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ViewWrapper>
|
<ViewWrapper>
|
||||||
{isLoadData ? (
|
{loadtData && !listData ? (
|
||||||
<LoaderCustom />
|
<LoaderCustom />
|
||||||
) : listData.length === 0 ? (
|
) : _.isEmpty(listData) ? (
|
||||||
<TextCustom align="center">Belum ada peserta</TextCustom>
|
<TextCustom align="center" color="gray">
|
||||||
|
Belum ada peserta
|
||||||
|
</TextCustom>
|
||||||
) : (
|
) : (
|
||||||
listData.map((item: any, index: number) => (
|
listData?.map((item: any, index: number) => (
|
||||||
<BaseBox key={index}>
|
<BaseBox key={index}>
|
||||||
<AvatarUsernameAndOtherComponent
|
<AvatarUsernameAndOtherComponent
|
||||||
avatar={item?.User?.Profile?.imageId}
|
avatar={item?.User?.Profile?.imageId}
|
||||||
name={item?.User?.username}
|
name={item?.User?.username}
|
||||||
avatarHref={`/profile/${item?.User?.Profile?.id}`}
|
avatarHref={`/profile/${item?.User?.Profile?.id}`}
|
||||||
rightComponent={
|
rightComponent={
|
||||||
new Date().getTime() > new Date(startDate as any).getTime() ? (
|
startDate && startDate.subtract(1, "hour").diff(dayjs()) < 0 ? (
|
||||||
<View
|
<View
|
||||||
style={{
|
style={{
|
||||||
justifyContent: "flex-end",
|
justifyContent: "flex-end",
|
||||||
|
|||||||
@@ -55,6 +55,8 @@ export default function EventDetailPublish() {
|
|||||||
userId: user?.id as string,
|
userId: user?.id as string,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
console.log("[RES CHECK PARTICIPANTS]", responseCheckParticipants);
|
||||||
|
|
||||||
if (
|
if (
|
||||||
responseCheckParticipants.success &&
|
responseCheckParticipants.success &&
|
||||||
responseCheckParticipants.data
|
responseCheckParticipants.data
|
||||||
@@ -69,6 +71,8 @@ export default function EventDetailPublish() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
console.log("[participans]", isParticipant);
|
||||||
|
|
||||||
const handlePress = (item: IMenuDrawerItem) => {
|
const handlePress = (item: IMenuDrawerItem) => {
|
||||||
console.log("PATH ", item.path);
|
console.log("PATH ", item.path);
|
||||||
router.navigate(item.path as any);
|
router.navigate(item.path as any);
|
||||||
|
|||||||
@@ -191,7 +191,7 @@ export default function EventCreate() {
|
|||||||
placeholder="Masukkan deskripsi event"
|
placeholder="Masukkan deskripsi event"
|
||||||
required
|
required
|
||||||
showCount
|
showCount
|
||||||
maxLength={100}
|
maxLength={1000}
|
||||||
onChangeText={(value: any) =>
|
onChangeText={(value: any) =>
|
||||||
setData({ ...data, deskripsi: value })
|
setData({ ...data, deskripsi: value })
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import {
|
|||||||
} from "@/components";
|
} from "@/components";
|
||||||
import { IconEdit } from "@/components/_Icon";
|
import { IconEdit } from "@/components/_Icon";
|
||||||
import { IMenuDrawerItem } from "@/components/_Interface/types";
|
import { IMenuDrawerItem } from "@/components/_Interface/types";
|
||||||
|
import ReportBox from "@/components/Box/ReportBox";
|
||||||
import Job_BoxDetailSection from "@/screens/Job/BoxDetailSection";
|
import Job_BoxDetailSection from "@/screens/Job/BoxDetailSection";
|
||||||
import Job_ButtonStatusSection from "@/screens/Job/ButtonStatusSection";
|
import Job_ButtonStatusSection from "@/screens/Job/ButtonStatusSection";
|
||||||
import { apiJobGetOne } from "@/service/api-client/api-job";
|
import { apiJobGetOne } from "@/service/api-client/api-job";
|
||||||
@@ -70,7 +71,13 @@ export default function JobDetailStatus() {
|
|||||||
<LoaderCustom />
|
<LoaderCustom />
|
||||||
) : (
|
) : (
|
||||||
<>
|
<>
|
||||||
<StackCustom>
|
<StackCustom gap={"xs"}>
|
||||||
|
{data &&
|
||||||
|
data?.catatan &&
|
||||||
|
(status === "draft" || status === "rejected") && (
|
||||||
|
<ReportBox text={data?.catatan} />
|
||||||
|
)}
|
||||||
|
|
||||||
<Job_BoxDetailSection data={data} />
|
<Job_BoxDetailSection data={data} />
|
||||||
<Job_ButtonStatusSection
|
<Job_ButtonStatusSection
|
||||||
id={id as string}
|
id={id as string}
|
||||||
|
|||||||
@@ -8,11 +8,13 @@ import {
|
|||||||
LoaderCustom,
|
LoaderCustom,
|
||||||
MenuDrawerDynamicGrid,
|
MenuDrawerDynamicGrid,
|
||||||
Spacing,
|
Spacing,
|
||||||
|
StackCustom,
|
||||||
TextCustom,
|
TextCustom,
|
||||||
ViewWrapper,
|
ViewWrapper,
|
||||||
} from "@/components";
|
} from "@/components";
|
||||||
import { IconArchive, IconContribution, IconEdit } from "@/components/_Icon";
|
import { IconArchive, IconContribution, IconEdit } from "@/components/_Icon";
|
||||||
import { IMenuDrawerItem } from "@/components/_Interface/types";
|
import { IMenuDrawerItem } from "@/components/_Interface/types";
|
||||||
|
import ReportBox from "@/components/Box/ReportBox";
|
||||||
import Voting_BoxDetailHasilVotingSection from "@/screens/Voting/BoxDetailHasilVotingSection";
|
import Voting_BoxDetailHasilVotingSection from "@/screens/Voting/BoxDetailHasilVotingSection";
|
||||||
import { Voting_BoxDetailSection } from "@/screens/Voting/BoxDetailSection";
|
import { Voting_BoxDetailSection } from "@/screens/Voting/BoxDetailSection";
|
||||||
import Voting_ButtonStatusSection from "@/screens/Voting/ButtonStatusSection";
|
import Voting_ButtonStatusSection from "@/screens/Voting/ButtonStatusSection";
|
||||||
@@ -49,6 +51,8 @@ export default function VotingDetailStatus() {
|
|||||||
setLoadingGetData(true);
|
setLoadingGetData(true);
|
||||||
const response = await apiVotingGetOne({ id: id as string });
|
const response = await apiVotingGetOne({ id: id as string });
|
||||||
|
|
||||||
|
console.log("[DATA BY ID]", JSON.stringify(response, null, 2));
|
||||||
|
|
||||||
if (response.success) {
|
if (response.success) {
|
||||||
setData(response.data);
|
setData(response.data);
|
||||||
}
|
}
|
||||||
@@ -127,6 +131,13 @@ export default function VotingDetailStatus() {
|
|||||||
</BaseBox>
|
</BaseBox>
|
||||||
)}
|
)}
|
||||||
<Spacing height={0} />
|
<Spacing height={0} />
|
||||||
|
|
||||||
|
{data &&
|
||||||
|
data?.catatan &&
|
||||||
|
(status === "draft" || status === "rejected") && (
|
||||||
|
<ReportBox text={data?.catatan} />
|
||||||
|
)}
|
||||||
|
|
||||||
<Voting_BoxDetailSection data={data as any} />
|
<Voting_BoxDetailSection data={data as any} />
|
||||||
{status === "publish" ? (
|
{status === "publish" ? (
|
||||||
<Voting_BoxDetailHasilVotingSection
|
<Voting_BoxDetailHasilVotingSection
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
/* eslint-disable react-hooks/exhaustive-deps */
|
||||||
import {
|
import {
|
||||||
ActionIcon,
|
ActionIcon,
|
||||||
AlertDefaultSystem,
|
AlertDefaultSystem,
|
||||||
@@ -18,97 +19,153 @@ import AdminBackButtonAntTitle from "@/components/_ShareComponent/Admin/BackButt
|
|||||||
import AdminButtonReject from "@/components/_ShareComponent/Admin/ButtonReject";
|
import AdminButtonReject from "@/components/_ShareComponent/Admin/ButtonReject";
|
||||||
import AdminButtonReview from "@/components/_ShareComponent/Admin/ButtonReview";
|
import AdminButtonReview from "@/components/_ShareComponent/Admin/ButtonReview";
|
||||||
import { GridDetail_4_8 } from "@/components/_ShareComponent/GridDetail_4_8";
|
import { GridDetail_4_8 } from "@/components/_ShareComponent/GridDetail_4_8";
|
||||||
import { MainColor } from "@/constants/color-palet";
|
import ReportBox from "@/components/Box/ReportBox";
|
||||||
import { ICON_SIZE_BUTTON, TEXT_SIZE_LARGE } from "@/constants/constans-value";
|
import { ICON_SIZE_BUTTON, TEXT_SIZE_LARGE } from "@/constants/constans-value";
|
||||||
import AdminDonation_BoxOfDonationStory from "@/screens/Admin/Donation/BoxOfDonationStory";
|
import AdminDonation_BoxOfDonationStory from "@/screens/Admin/Donation/BoxOfDonationStory";
|
||||||
|
import { funUpdateStatusDonation } from "@/screens/Admin/Donation/funDonationUpdateStatus";
|
||||||
|
import { apiAdminDonationDetailById } from "@/service/api-admin/api-admin-donation";
|
||||||
|
import { colorBadgeStatus } from "@/utils/colorBadge";
|
||||||
|
import { formatCurrencyDisplay } from "@/utils/formatCurrencyDisplay";
|
||||||
import { Ionicons } from "@expo/vector-icons";
|
import { Ionicons } from "@expo/vector-icons";
|
||||||
import { router, useLocalSearchParams } from "expo-router";
|
import { router, useFocusEffect, useLocalSearchParams } from "expo-router";
|
||||||
import _ from "lodash";
|
import _ from "lodash";
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import { View } from "react-native";
|
import { View } from "react-native";
|
||||||
|
import Toast from "react-native-toast-message";
|
||||||
|
|
||||||
export default function AdminDonationDetail() {
|
export default function AdminDonationDetail() {
|
||||||
const { id, status } = useLocalSearchParams();
|
const { id, status } = useLocalSearchParams();
|
||||||
const [openDrawer, setOpenDrawer] = React.useState(false);
|
const [openDrawer, setOpenDrawer] = React.useState(false);
|
||||||
|
|
||||||
const colorBadge = () => {
|
const [data, setData] = React.useState<any | null>(null);
|
||||||
if (status === "publish") {
|
const [countDonatur, setCountDonatur] = React.useState(0);
|
||||||
return MainColor.green;
|
const [isLoading, setIsLoading] = React.useState(false);
|
||||||
} else if (status === "review") {
|
|
||||||
return MainColor.orange;
|
useFocusEffect(
|
||||||
} else if (status === "reject") {
|
React.useCallback(() => {
|
||||||
return MainColor.red;
|
onLoadData();
|
||||||
} else {
|
}, [id])
|
||||||
return MainColor.placeholder;
|
);
|
||||||
|
|
||||||
|
const onLoadData = async () => {
|
||||||
|
try {
|
||||||
|
const response = await apiAdminDonationDetailById({
|
||||||
|
id: id as string,
|
||||||
|
});
|
||||||
|
|
||||||
|
if (response.success) {
|
||||||
|
setData(response.data.donasi);
|
||||||
|
setCountDonatur(response.data.donatur);
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.log("[ERROR]", error);
|
||||||
|
setData(null);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const listData = [
|
const listData = [
|
||||||
{
|
{
|
||||||
label: "Penggalang Dana",
|
label: "Penggalang Dana",
|
||||||
value: `Bagas Banuna ${id}`,
|
value: (data && data?.Author?.username) || "-",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: "Judul",
|
label: "Judul",
|
||||||
value: `Donasi Lorem ipsum dolor sit amet, consectetur adipisicing elit.`,
|
value: (data && data?.title) || "-",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: "Status",
|
label: "Status",
|
||||||
value: (
|
value:
|
||||||
<BadgeCustom color={colorBadge()}>
|
data && data?.DonasiMaster_Status?.name ? (
|
||||||
{_.startCase(status as string)}
|
<BadgeCustom
|
||||||
</BadgeCustom>
|
color={colorBadgeStatus({
|
||||||
),
|
status: data?.DonasiMaster_Status?.name,
|
||||||
|
})}
|
||||||
|
>
|
||||||
|
{_.startCase(data?.DonasiMaster_Status?.name)}
|
||||||
|
</BadgeCustom>
|
||||||
|
) : (
|
||||||
|
"-"
|
||||||
|
),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: "Durasi",
|
label: "Durasi",
|
||||||
value: "30 Hari",
|
value: (data && data?.DonasiMaster_Durasi?.name) + " hari" || "-",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: "Target Dana",
|
label: "Target Dana",
|
||||||
value: "Rp 10.000.000",
|
value:
|
||||||
|
data && data?.target
|
||||||
|
? `Rp. ${formatCurrencyDisplay(data?.target)}`
|
||||||
|
: "-",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: "Kategori",
|
label: "Kategori",
|
||||||
value: "Kategori Donasi",
|
value: (data && data?.DonasiMaster_Ketegori?.name) || "-",
|
||||||
},
|
},
|
||||||
// {
|
|
||||||
// label: "Total Donatur",
|
|
||||||
// value: "-",
|
|
||||||
// },
|
|
||||||
// {
|
|
||||||
// label: "Progress",
|
|
||||||
// value: "0 %",
|
|
||||||
// },
|
|
||||||
// {
|
|
||||||
// label: "Dana Terkumpul",
|
|
||||||
// value: "Rp 0",
|
|
||||||
// },
|
|
||||||
];
|
];
|
||||||
|
|
||||||
const listPencarianDana = [
|
const listPencarianDana = [
|
||||||
{
|
{
|
||||||
label: "Total Dana Dicairkan",
|
label: "Total Dana Dicairkan",
|
||||||
value: "Rp 0",
|
value: `Rp ${(data && formatCurrencyDisplay(data?.totalPencairan)) || 0}`,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: "Sisa Dana",
|
label: "Sisa Dana Masuk",
|
||||||
value: "Rp 0",
|
value: `Rp ${
|
||||||
|
(data &&
|
||||||
|
formatCurrencyDisplay(data?.terkumpul - data?.totalPencairan)) ||
|
||||||
|
0
|
||||||
|
}`,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: "Akumulasi Pencairan",
|
label: "Akumulasi Pencairan",
|
||||||
value: "0 kali",
|
value: `${(data && data?.akumulasiPencairan) || 0} kali`,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: "Bank Tujuan",
|
label: "Bank Tujuan",
|
||||||
value: "BNI",
|
value: (data && data?.namaBank) || "-",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: "Nomor Rekening",
|
label: "Nomor Rekening",
|
||||||
value: "123456789",
|
value: (data && data?.rekening) || "-",
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
|
const handleReport = async ({
|
||||||
|
changeStatus,
|
||||||
|
}: {
|
||||||
|
changeStatus: "publish" | "review" | "reject";
|
||||||
|
}) => {
|
||||||
|
try {
|
||||||
|
setIsLoading(true);
|
||||||
|
const response = await funUpdateStatusDonation({
|
||||||
|
id: id as string,
|
||||||
|
changeStatus,
|
||||||
|
data: data,
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!response.success) {
|
||||||
|
Toast.show({
|
||||||
|
type: "error",
|
||||||
|
text1: "Update status gagal",
|
||||||
|
});
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Toast.show({
|
||||||
|
type: "success",
|
||||||
|
text1: "Update status berhasil",
|
||||||
|
});
|
||||||
|
|
||||||
|
router.back();
|
||||||
|
} catch (error) {
|
||||||
|
console.log("[ERROR]", error);
|
||||||
|
} finally {
|
||||||
|
setIsLoading(false);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
const rightComponent = (
|
const rightComponent = (
|
||||||
<ActionIcon
|
<ActionIcon
|
||||||
icon={<IconDot size={ICON_SIZE_BUTTON} />}
|
icon={<IconDot size={ICON_SIZE_BUTTON} />}
|
||||||
@@ -118,8 +175,6 @@ export default function AdminDonationDetail() {
|
|||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<ViewWrapper
|
<ViewWrapper
|
||||||
@@ -147,11 +202,20 @@ export default function AdminDonationDetail() {
|
|||||||
/>
|
/>
|
||||||
))}
|
))}
|
||||||
</StackCustom>
|
</StackCustom>
|
||||||
|
|
||||||
<ButtonCustom
|
<ButtonCustom
|
||||||
iconLeft={
|
iconLeft={
|
||||||
<Ionicons name="cash-outline" size={ICON_SIZE_BUTTON} />
|
<Ionicons name="cash-outline" size={ICON_SIZE_BUTTON} />
|
||||||
}
|
}
|
||||||
|
disabled={data?.terkumpul - data?.totalPencairan <= 0}
|
||||||
onPress={() => {
|
onPress={() => {
|
||||||
|
if (data?.terkumpul - data?.totalPencairan <= 0) {
|
||||||
|
Toast.show({
|
||||||
|
type: "error",
|
||||||
|
text1: "Tidak ada dana yang tersisa",
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
router.push(`/admin/donation/${id}/disbursement-of-funds`);
|
router.push(`/admin/donation/${id}/disbursement-of-funds`);
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
@@ -161,16 +225,32 @@ export default function AdminDonationDetail() {
|
|||||||
</BaseBox>
|
</BaseBox>
|
||||||
|
|
||||||
<BaseBox>
|
<BaseBox>
|
||||||
<ProgressCustom size="lg" />
|
<ProgressCustom
|
||||||
|
size="lg"
|
||||||
|
value={Number(data?.progres) || 0}
|
||||||
|
showLabel={true}
|
||||||
|
label={data?.progres + "%"}
|
||||||
|
animated
|
||||||
|
color="primary"
|
||||||
|
/>
|
||||||
<Spacing />
|
<Spacing />
|
||||||
|
|
||||||
<StackCustom gap={"xs"}>
|
<StackCustom gap={"xs"}>
|
||||||
<GridDetail_4_8
|
<GridDetail_4_8
|
||||||
label={<TextCustom bold>Jumlah Donatur</TextCustom>}
|
label={<TextCustom bold>Jumlah Donatur</TextCustom>}
|
||||||
value={<TextCustom>0 orang</TextCustom>}
|
value={
|
||||||
|
<TextCustom>
|
||||||
|
{countDonatur ? countDonatur : 0} orang
|
||||||
|
</TextCustom>
|
||||||
|
}
|
||||||
/>
|
/>
|
||||||
<GridDetail_4_8
|
<GridDetail_4_8
|
||||||
label={<TextCustom bold>Dana Terkumpul</TextCustom>}
|
label={<TextCustom bold>Dana Terkumpul</TextCustom>}
|
||||||
value={<TextCustom>Rp 0</TextCustom>}
|
value={
|
||||||
|
<TextCustom>
|
||||||
|
Rp {formatCurrencyDisplay(data?.terkumpul || 0)}
|
||||||
|
</TextCustom>
|
||||||
|
}
|
||||||
/>
|
/>
|
||||||
</StackCustom>
|
</StackCustom>
|
||||||
</BaseBox>
|
</BaseBox>
|
||||||
@@ -179,7 +259,7 @@ export default function AdminDonationDetail() {
|
|||||||
|
|
||||||
<BaseBox>
|
<BaseBox>
|
||||||
<StackCustom>
|
<StackCustom>
|
||||||
<DummyLandscapeImage />
|
<DummyLandscapeImage imageId={data?.imageId || ""} />
|
||||||
{listData.map((item, i) => (
|
{listData.map((item, i) => (
|
||||||
<GridDetail_4_8
|
<GridDetail_4_8
|
||||||
key={i}
|
key={i}
|
||||||
@@ -190,27 +270,33 @@ export default function AdminDonationDetail() {
|
|||||||
</StackCustom>
|
</StackCustom>
|
||||||
</BaseBox>
|
</BaseBox>
|
||||||
|
|
||||||
|
<AdminDonation_BoxOfDonationStory data={data?.CeritaDonasi as any} />
|
||||||
|
|
||||||
|
{data &&
|
||||||
|
data?.catatan &&
|
||||||
|
(status === "review" || status === "reject") && (
|
||||||
|
<ReportBox text={data?.catatan} />
|
||||||
|
)}
|
||||||
|
|
||||||
{status === "review" && (
|
{status === "review" && (
|
||||||
<StackCustom>
|
<StackCustom>
|
||||||
<AdminDonation_BoxOfDonationStory />
|
|
||||||
|
|
||||||
<AdminButtonReview
|
<AdminButtonReview
|
||||||
|
isLoading={isLoading}
|
||||||
onPublish={() => {
|
onPublish={() => {
|
||||||
AlertDefaultSystem({
|
AlertDefaultSystem({
|
||||||
title: "Publish",
|
title: "Publish",
|
||||||
message: "Apakah anda yakin ingin mempublikasikan data ini?",
|
message: "Apakah anda yakin ingin mempublikasikan data ini?",
|
||||||
textLeft: "Batal",
|
textLeft: "Batal",
|
||||||
textRight: "Ya",
|
textRight: "Ya",
|
||||||
onPressLeft: () => {
|
|
||||||
router.back();
|
|
||||||
},
|
|
||||||
onPressRight: () => {
|
onPressRight: () => {
|
||||||
router.back();
|
handleReport({ changeStatus: "publish" });
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
}}
|
}}
|
||||||
onReject={() => {
|
onReject={() => {
|
||||||
router.push(`/admin/donation/${id}/reject-input`);
|
router.push(
|
||||||
|
`/admin/donation/${id}/reject-input?status=${status}`
|
||||||
|
);
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
</StackCustom>
|
</StackCustom>
|
||||||
@@ -218,12 +304,12 @@ export default function AdminDonationDetail() {
|
|||||||
|
|
||||||
{status === "reject" && (
|
{status === "reject" && (
|
||||||
<StackCustom>
|
<StackCustom>
|
||||||
<AdminDonation_BoxOfDonationStory />
|
|
||||||
|
|
||||||
<AdminButtonReject
|
<AdminButtonReject
|
||||||
title="Tambah Catatan"
|
title="Tambah Catatan"
|
||||||
onReject={() => {
|
onReject={() => {
|
||||||
router.push(`/admin/donation/${id}/reject-input`);
|
router.push(
|
||||||
|
`/admin/donation/${id}/reject-input?status=${status}`
|
||||||
|
);
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
</StackCustom>
|
</StackCustom>
|
||||||
|
|||||||
@@ -9,51 +9,162 @@ import {
|
|||||||
} from "@/components";
|
} from "@/components";
|
||||||
import AdminBackButtonAntTitle from "@/components/_ShareComponent/Admin/BackButtonAntTitle";
|
import AdminBackButtonAntTitle from "@/components/_ShareComponent/Admin/BackButtonAntTitle";
|
||||||
import { GridDetail_4_8 } from "@/components/_ShareComponent/GridDetail_4_8";
|
import { GridDetail_4_8 } from "@/components/_ShareComponent/GridDetail_4_8";
|
||||||
import { MainColor } from "@/constants/color-palet";
|
import {
|
||||||
import dayjs from "dayjs";
|
apiAdminDonationInvoiceDetailById,
|
||||||
import { router, useLocalSearchParams } from "expo-router";
|
apiAdminDonationInvoiceUpdateById,
|
||||||
|
} from "@/service/api-admin/api-admin-donation";
|
||||||
|
import { colorBadgeTransaction } from "@/utils/colorBadge";
|
||||||
|
import { dateTimeView } from "@/utils/dateTimeView";
|
||||||
|
import { formatCurrencyDisplay } from "@/utils/formatCurrencyDisplay";
|
||||||
|
import { router, useFocusEffect, useLocalSearchParams } from "expo-router";
|
||||||
|
import _ from "lodash";
|
||||||
|
import { useCallback, useState } from "react";
|
||||||
|
import Toast from "react-native-toast-message";
|
||||||
|
|
||||||
export default function AdminDonasiTransactionDetail() {
|
export default function AdminDonasiTransactionDetail() {
|
||||||
const { id } = useLocalSearchParams();
|
const { id, status } = useLocalSearchParams();
|
||||||
|
console.log("[STATUS]", id, status);
|
||||||
|
|
||||||
const buttonAction = (
|
const [data, setData] = useState<any | null>(null);
|
||||||
<BoxButtonOnFooter>
|
const [isLoading, setLoading] = useState(false);
|
||||||
<ButtonCustom onPress={() => router.back()}>Terima</ButtonCustom>
|
|
||||||
</BoxButtonOnFooter>
|
useFocusEffect(
|
||||||
|
useCallback(() => {
|
||||||
|
onLoadData();
|
||||||
|
|
||||||
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
|
}, [id])
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const onLoadData = async () => {
|
||||||
|
try {
|
||||||
|
const response = await apiAdminDonationInvoiceDetailById({
|
||||||
|
id: id as string,
|
||||||
|
});
|
||||||
|
|
||||||
|
console.log("[GET INVOICE BY ID]", JSON.stringify(response, null, 2));
|
||||||
|
if (response.success) {
|
||||||
|
setData(response.data);
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.log("[ERROR]", error);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const handlerSubmit = async () => {
|
||||||
|
try {
|
||||||
|
setLoading(true);
|
||||||
|
const newData = {
|
||||||
|
donationId: data?.donasiId,
|
||||||
|
nominal: data?.nominal,
|
||||||
|
};
|
||||||
|
|
||||||
|
const response = await apiAdminDonationInvoiceUpdateById({
|
||||||
|
id: id as string,
|
||||||
|
data: newData,
|
||||||
|
status: "berhasil",
|
||||||
|
});
|
||||||
|
|
||||||
|
console.log("[UPDATE INVOICE]", JSON.stringify(response, null, 2));
|
||||||
|
|
||||||
|
if (!response.success) {
|
||||||
|
Toast.show({
|
||||||
|
type: "error",
|
||||||
|
text1: response.message,
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Toast.show({
|
||||||
|
type: "success",
|
||||||
|
text1: response.message,
|
||||||
|
});
|
||||||
|
router.back();
|
||||||
|
} catch (error) {
|
||||||
|
console.log("[ERROR]", error);
|
||||||
|
} finally {
|
||||||
|
setLoading(false);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const buttonAction = () => {
|
||||||
|
if (data && data?.DonasiMaster_StatusInvoice?.name === "Menunggu") {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (data && data?.DonasiMaster_StatusInvoice?.name === "Proses") {
|
||||||
|
return (
|
||||||
|
<BoxButtonOnFooter>
|
||||||
|
<ButtonCustom
|
||||||
|
isLoading={isLoading}
|
||||||
|
onPress={() => {
|
||||||
|
handlerSubmit();
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
Terima donasi
|
||||||
|
</ButtonCustom>
|
||||||
|
</BoxButtonOnFooter>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<BoxButtonOnFooter>
|
||||||
|
<ButtonCustom disabled>
|
||||||
|
{data?.DonasiMaster_StatusInvoice?.name}
|
||||||
|
</ButtonCustom>
|
||||||
|
</BoxButtonOnFooter>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
const listData = [
|
const listData = [
|
||||||
{
|
{
|
||||||
label: "Donatur",
|
label: "Donatur",
|
||||||
value: "Bagas Banuna",
|
value: (data && data?.Author?.username) || "-",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: "Bank",
|
label: "Bank",
|
||||||
value: "BCA",
|
value: (data && data?.MasterBank?.namaBank) || "-",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: "Jumlah Donasi",
|
label: "Jumlah Donasi",
|
||||||
value: "Rp. 1.000.000",
|
value: `Rp. ${
|
||||||
|
(data && data?.nominal && formatCurrencyDisplay(data?.nominal)) || "-"
|
||||||
|
}`,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: "Status",
|
label: "Status",
|
||||||
value: <BadgeCustom color={MainColor.green}>Berhasil</BadgeCustom>,
|
value:
|
||||||
|
(data && data?.DonasiMaster_StatusInvoice?.name && (
|
||||||
|
<BadgeCustom
|
||||||
|
color={colorBadgeTransaction({
|
||||||
|
status: data?.DonasiMaster_StatusInvoice?.name as any,
|
||||||
|
})}
|
||||||
|
>
|
||||||
|
{_.startCase(
|
||||||
|
(data?.DonasiMaster_StatusInvoice?.name as any) || "-"
|
||||||
|
)}
|
||||||
|
</BadgeCustom>
|
||||||
|
)) ||
|
||||||
|
"-",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: "Tanggal",
|
label: "Tanggal",
|
||||||
value: dayjs().format("DD-MM-YYYY HH:mm:ss"),
|
value: (data && dateTimeView({ date: data?.createdAt })) || "-",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: "Bukti Transfer",
|
label: "Bukti Transfer",
|
||||||
value: (
|
value:
|
||||||
<ButtonCustom
|
(data && data?.imageId && (
|
||||||
onPress={() =>
|
<ButtonCustom
|
||||||
router.push(`/(application)/(image)/preview-image/${id}`)
|
onPress={() =>
|
||||||
}
|
router.push(
|
||||||
>
|
`/(application)/(image)/preview-image/${data?.imageId}`
|
||||||
Cek
|
)
|
||||||
</ButtonCustom>
|
}
|
||||||
),
|
>
|
||||||
|
Cek
|
||||||
|
</ButtonCustom>
|
||||||
|
)) ||
|
||||||
|
"-",
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
@@ -61,7 +172,7 @@ export default function AdminDonasiTransactionDetail() {
|
|||||||
<>
|
<>
|
||||||
<ViewWrapper
|
<ViewWrapper
|
||||||
headerComponent={<AdminBackButtonAntTitle title="Detail Transaksi" />}
|
headerComponent={<AdminBackButtonAntTitle title="Detail Transaksi" />}
|
||||||
footerComponent={buttonAction}
|
footerComponent={buttonAction()}
|
||||||
>
|
>
|
||||||
<BaseBox>
|
<BaseBox>
|
||||||
<StackCustom>
|
<StackCustom>
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
/* eslint-disable react-hooks/exhaustive-deps */
|
||||||
import {
|
import {
|
||||||
BaseBox,
|
BaseBox,
|
||||||
ButtonCustom,
|
ButtonCustom,
|
||||||
@@ -7,27 +8,53 @@ import {
|
|||||||
} from "@/components";
|
} from "@/components";
|
||||||
import AdminBackButtonAntTitle from "@/components/_ShareComponent/Admin/BackButtonAntTitle";
|
import AdminBackButtonAntTitle from "@/components/_ShareComponent/Admin/BackButtonAntTitle";
|
||||||
import { GridDetail_4_8 } from "@/components/_ShareComponent/GridDetail_4_8";
|
import { GridDetail_4_8 } from "@/components/_ShareComponent/GridDetail_4_8";
|
||||||
import dayjs from "dayjs";
|
import { apiAdminDonationDisbursementOfFundsListById } from "@/service/api-admin/api-admin-donation";
|
||||||
import { router, useLocalSearchParams } from "expo-router";
|
import { dateTimeView } from "@/utils/dateTimeView";
|
||||||
|
import { formatCurrencyDisplay } from "@/utils/formatCurrencyDisplay";
|
||||||
|
import { router, useFocusEffect, useLocalSearchParams } from "expo-router";
|
||||||
|
import React, { useCallback } from "react";
|
||||||
|
|
||||||
export default function AdminDonationDetailDisbursementOfFunds() {
|
export default function AdminDonationDetailDisbursementOfFunds() {
|
||||||
const { id } = useLocalSearchParams();
|
const { id } = useLocalSearchParams();
|
||||||
|
const [data, setData] = React.useState<any | null>(null);
|
||||||
|
|
||||||
|
useFocusEffect(
|
||||||
|
useCallback(() => {
|
||||||
|
onLoadData();
|
||||||
|
}, [id])
|
||||||
|
);
|
||||||
|
|
||||||
|
const onLoadData = async () => {
|
||||||
|
try {
|
||||||
|
const response = await apiAdminDonationDisbursementOfFundsListById({
|
||||||
|
id: id as string,
|
||||||
|
category: "get-one",
|
||||||
|
});
|
||||||
|
|
||||||
|
if (response.success) {
|
||||||
|
setData(response.data);
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.log("[ERROR]", error);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
const listData = [
|
const listData = [
|
||||||
{
|
{
|
||||||
label: "Nominal",
|
label: "Nominal",
|
||||||
value: "Rp 1.000.000",
|
value: `Rp ${(data && formatCurrencyDisplay(data?.nominalCair)) || 0}`,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: "Tanggal",
|
label: "Tanggal",
|
||||||
value: dayjs().format("DD-MM-YYYY HH:mm"),
|
value: dateTimeView({ date: data?.createdAt }),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: "Judul",
|
label: "Judul",
|
||||||
value: `Judul Pencairan Dana ${id}`,
|
value: (data && data?.title) || "-",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: "Deskripsi",
|
label: "Deskripsi",
|
||||||
value: `Lorem ipsum dolor sit amet consectetur adipisicing elit. Itaque velit eos facere a dicta nemo repellendus harum laboriosam quos, earum reprehenderit. Nisi sapiente, quo earum quis alias ullam temporibus quidem.`,
|
value: (data && data?.deskripsi) || "-",
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
return (
|
return (
|
||||||
@@ -39,7 +66,7 @@ export default function AdminDonationDetailDisbursementOfFunds() {
|
|||||||
>
|
>
|
||||||
<BaseBox>
|
<BaseBox>
|
||||||
<StackCustom>
|
<StackCustom>
|
||||||
{listData.map((item, index) => (
|
{listData?.map((item, index) => (
|
||||||
<GridDetail_4_8
|
<GridDetail_4_8
|
||||||
key={index}
|
key={index}
|
||||||
label={<TextCustom bold>{item.label}</TextCustom>}
|
label={<TextCustom bold>{item.label}</TextCustom>}
|
||||||
@@ -51,7 +78,7 @@ export default function AdminDonationDetailDisbursementOfFunds() {
|
|||||||
|
|
||||||
<ButtonCustom
|
<ButtonCustom
|
||||||
onPress={() =>
|
onPress={() =>
|
||||||
router.push(`/(application)/(image)/preview-image/${id}`)
|
router.push(`/(application)/(image)/preview-image/${data?.imageId}`)
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
Cek Bukti Transaksi
|
Cek Bukti Transaksi
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
/* eslint-disable react-hooks/exhaustive-deps */
|
||||||
import {
|
import {
|
||||||
BaseBox,
|
BaseBox,
|
||||||
BoxButtonOnFooter,
|
BoxButtonOnFooter,
|
||||||
@@ -12,15 +13,122 @@ import {
|
|||||||
ViewWrapper,
|
ViewWrapper,
|
||||||
} from "@/components";
|
} from "@/components";
|
||||||
import AdminBackButtonAntTitle from "@/components/_ShareComponent/Admin/BackButtonAntTitle";
|
import AdminBackButtonAntTitle from "@/components/_ShareComponent/Admin/BackButtonAntTitle";
|
||||||
import { router, useLocalSearchParams } from "expo-router";
|
import DIRECTORY_ID from "@/constants/directory-id";
|
||||||
|
import { apiAdminDonationDetailById, apiAdminDonationDisbursementOfFundsCreated } from "@/service/api-admin/api-admin-donation";
|
||||||
|
import { uploadFileService } from "@/service/upload-service";
|
||||||
|
import { formatCurrencyDisplay } from "@/utils/formatCurrencyDisplay";
|
||||||
|
import pickFile from "@/utils/pickFile";
|
||||||
|
import { Image } from "expo-image";
|
||||||
|
import { router, useFocusEffect, useLocalSearchParams } from "expo-router";
|
||||||
|
import React from "react";
|
||||||
|
import Toast from "react-native-toast-message";
|
||||||
|
|
||||||
export default function AdminDonationDisbursementOfFunds() {
|
export default function AdminDonationDisbursementOfFunds() {
|
||||||
const { id } = useLocalSearchParams();
|
const { id } = useLocalSearchParams();
|
||||||
const handleSubmit = (
|
|
||||||
|
const [data, setData] = React.useState<any | null>(null);
|
||||||
|
const [isLoading, setIsLoading] = React.useState(false);
|
||||||
|
|
||||||
|
const [value, setValue] = React.useState({
|
||||||
|
nominalCair: "",
|
||||||
|
title: "",
|
||||||
|
deskripsi: "",
|
||||||
|
});
|
||||||
|
|
||||||
|
const [image, setImage] = React.useState<any | null>(null);
|
||||||
|
|
||||||
|
useFocusEffect(
|
||||||
|
React.useCallback(() => {
|
||||||
|
onLoadData();
|
||||||
|
}, [id])
|
||||||
|
);
|
||||||
|
|
||||||
|
const onLoadData = async () => {
|
||||||
|
try {
|
||||||
|
const response = await apiAdminDonationDetailById({
|
||||||
|
id: id as string,
|
||||||
|
});
|
||||||
|
|
||||||
|
if (response.success) {
|
||||||
|
setData(response.data.donasi);
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.log("[ERROR]", error);
|
||||||
|
setData(null);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleSubmit = async () => {
|
||||||
|
if (!image) {
|
||||||
|
Toast.show({
|
||||||
|
type: "error",
|
||||||
|
text1: "Harap upload bukti transfer",
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!value.nominalCair || !value.title || !value.deskripsi) {
|
||||||
|
Toast.show({
|
||||||
|
type: "error",
|
||||||
|
text1: "Harap isi semua data",
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
setIsLoading(true);
|
||||||
|
const uploadImage = await uploadFileService({
|
||||||
|
dirId: DIRECTORY_ID.donasi_bukti_trf_pencairan_dana,
|
||||||
|
imageUri: image.uri,
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!uploadFileService) {
|
||||||
|
Toast.show({
|
||||||
|
type: "error",
|
||||||
|
text1: "Gagal mengunggah gambar",
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const imageId = uploadImage.data.id;
|
||||||
|
|
||||||
|
const newData = {
|
||||||
|
...value,
|
||||||
|
imageId: imageId,
|
||||||
|
};
|
||||||
|
|
||||||
|
const response = await apiAdminDonationDisbursementOfFundsCreated({
|
||||||
|
id: id as string,
|
||||||
|
data: newData,
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!response.success) {
|
||||||
|
Toast.show({
|
||||||
|
type: "error",
|
||||||
|
text1: response.message,
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Toast.show({
|
||||||
|
type: "success",
|
||||||
|
text1: "Pencairan dana berhasil disimpan",
|
||||||
|
});
|
||||||
|
|
||||||
|
router.back();
|
||||||
|
} catch (error) {
|
||||||
|
console.log("[ERROR]", error);
|
||||||
|
} finally {
|
||||||
|
setIsLoading(false);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const buttonSubmit = (
|
||||||
<BoxButtonOnFooter>
|
<BoxButtonOnFooter>
|
||||||
<ButtonCustom
|
<ButtonCustom
|
||||||
|
isLoading={isLoading}
|
||||||
onPress={() => {
|
onPress={() => {
|
||||||
router.back();
|
handleSubmit();
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
Simpan
|
Simpan
|
||||||
@@ -31,7 +139,7 @@ export default function AdminDonationDisbursementOfFunds() {
|
|||||||
return (
|
return (
|
||||||
<ViewWrapper
|
<ViewWrapper
|
||||||
headerComponent={<AdminBackButtonAntTitle title="Pencairan Dana" />}
|
headerComponent={<AdminBackButtonAntTitle title="Pencairan Dana" />}
|
||||||
footerComponent={handleSubmit}
|
footerComponent={buttonSubmit}
|
||||||
>
|
>
|
||||||
<BaseBox>
|
<BaseBox>
|
||||||
<StackCustom gap="md">
|
<StackCustom gap="md">
|
||||||
@@ -39,7 +147,7 @@ export default function AdminDonationDisbursementOfFunds() {
|
|||||||
Dana Tersisa
|
Dana Tersisa
|
||||||
</TextCustom>
|
</TextCustom>
|
||||||
<TextCustom align="center" bold size="large">
|
<TextCustom align="center" bold size="large">
|
||||||
Rp 1.000.000
|
Rp {formatCurrencyDisplay(data?.terkumpul - data?.totalPencairan)}
|
||||||
</TextCustom>
|
</TextCustom>
|
||||||
</StackCustom>
|
</StackCustom>
|
||||||
</BaseBox>
|
</BaseBox>
|
||||||
@@ -56,9 +164,27 @@ export default function AdminDonationDisbursementOfFunds() {
|
|||||||
label="Nominal"
|
label="Nominal"
|
||||||
placeholder="0"
|
placeholder="0"
|
||||||
iconLeft={"Rp"}
|
iconLeft={"Rp"}
|
||||||
|
value={value.nominalCair}
|
||||||
|
onChangeText={(text) => {
|
||||||
|
setValue({
|
||||||
|
...value,
|
||||||
|
nominalCair: text,
|
||||||
|
});
|
||||||
|
}}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<TextInputCustom required label="Judul" placeholder="Masukan judul" />
|
<TextInputCustom
|
||||||
|
required
|
||||||
|
label="Judul"
|
||||||
|
placeholder="Masukan judul"
|
||||||
|
value={value.title}
|
||||||
|
onChangeText={(text) => {
|
||||||
|
setValue({
|
||||||
|
...value,
|
||||||
|
title: text,
|
||||||
|
});
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
|
||||||
<TextAreaCustom
|
<TextAreaCustom
|
||||||
required
|
required
|
||||||
@@ -66,20 +192,37 @@ export default function AdminDonationDisbursementOfFunds() {
|
|||||||
placeholder="Masukan deskripsi"
|
placeholder="Masukan deskripsi"
|
||||||
showCount
|
showCount
|
||||||
maxLength={500}
|
maxLength={500}
|
||||||
|
value={value.deskripsi}
|
||||||
|
onChangeText={(text) => {
|
||||||
|
setValue({
|
||||||
|
...value,
|
||||||
|
deskripsi: text,
|
||||||
|
});
|
||||||
|
}}
|
||||||
/>
|
/>
|
||||||
</StackCustom>
|
</StackCustom>
|
||||||
</BaseBox>
|
</BaseBox>
|
||||||
<InformationBox text="Wajib menyertakan bukti transfer" />
|
|
||||||
|
|
||||||
|
<Spacing />
|
||||||
|
|
||||||
|
<InformationBox text="Wajib menyertakan bukti transfer" />
|
||||||
<ButtonCenteredOnly
|
<ButtonCenteredOnly
|
||||||
onPress={() => {
|
onPress={() => {
|
||||||
router.push(`/(application)/(image)/take-picture/${id}`);
|
pickFile({
|
||||||
|
allowedType: "image",
|
||||||
|
aspectRatio: [9, 16],
|
||||||
|
setImageUri: (file) => {
|
||||||
|
setImage(file);
|
||||||
|
},
|
||||||
|
});
|
||||||
}}
|
}}
|
||||||
icon="upload"
|
icon="upload"
|
||||||
>
|
>
|
||||||
Upload
|
Upload
|
||||||
</ButtonCenteredOnly>
|
</ButtonCenteredOnly>
|
||||||
<Spacing />
|
<Spacing />
|
||||||
|
<Image source={image?.uri} style={{ width: "100%", height: 300 }} />
|
||||||
|
<Spacing />
|
||||||
</ViewWrapper>
|
</ViewWrapper>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,21 +1,54 @@
|
|||||||
|
/* eslint-disable react-hooks/exhaustive-deps */
|
||||||
import {
|
import {
|
||||||
ActionIcon,
|
ActionIcon,
|
||||||
CenterCustom,
|
CenterCustom,
|
||||||
Divider,
|
Divider,
|
||||||
StackCustom,
|
LoaderCustom,
|
||||||
TextCustom,
|
StackCustom,
|
||||||
ViewWrapper
|
TextCustom,
|
||||||
|
ViewWrapper,
|
||||||
} from "@/components";
|
} from "@/components";
|
||||||
import { IconView } from "@/components/_Icon/IconComponent";
|
import { IconView } from "@/components/_Icon/IconComponent";
|
||||||
import AdminBackButtonAntTitle from "@/components/_ShareComponent/Admin/BackButtonAntTitle";
|
import AdminBackButtonAntTitle from "@/components/_ShareComponent/Admin/BackButtonAntTitle";
|
||||||
import { GridViewCustomSpan } from "@/components/_ShareComponent/GridViewCustomSpan";
|
import { GridViewCustomSpan } from "@/components/_ShareComponent/GridViewCustomSpan";
|
||||||
import { ICON_SIZE_BUTTON } from "@/constants/constans-value";
|
import { ICON_SIZE_BUTTON } from "@/constants/constans-value";
|
||||||
|
import { apiAdminDonationDisbursementOfFundsListById } from "@/service/api-admin/api-admin-donation";
|
||||||
|
import { formatCurrencyDisplay } from "@/utils/formatCurrencyDisplay";
|
||||||
import dayjs from "dayjs";
|
import dayjs from "dayjs";
|
||||||
import { router, useLocalSearchParams } from "expo-router";
|
import { router, useFocusEffect, useLocalSearchParams } from "expo-router";
|
||||||
|
import _ from "lodash";
|
||||||
|
import React, { useCallback } from "react";
|
||||||
import { View } from "react-native";
|
import { View } from "react-native";
|
||||||
|
|
||||||
export default function AdminDonasiListOfDisbursementOfFunds() {
|
export default function AdminDonasiListOfDisbursementOfFunds() {
|
||||||
const { id } = useLocalSearchParams();
|
const { id } = useLocalSearchParams();
|
||||||
|
const [listData, setListData] = React.useState<any[] | null>(null);
|
||||||
|
const [loadData, setLoadData] = React.useState(false);
|
||||||
|
|
||||||
|
useFocusEffect(
|
||||||
|
useCallback(() => {
|
||||||
|
onLoadData();
|
||||||
|
}, [id])
|
||||||
|
);
|
||||||
|
|
||||||
|
const onLoadData = async () => {
|
||||||
|
try {
|
||||||
|
setLoadData(true);
|
||||||
|
const response = await apiAdminDonationDisbursementOfFundsListById({
|
||||||
|
id: id as string,
|
||||||
|
category: "get-all",
|
||||||
|
});
|
||||||
|
|
||||||
|
if (response.success) {
|
||||||
|
setListData(response.data);
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.log("[ERROR]", error);
|
||||||
|
} finally {
|
||||||
|
setLoadData(false);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<ViewWrapper
|
<ViewWrapper
|
||||||
@@ -45,36 +78,47 @@ export default function AdminDonasiListOfDisbursementOfFunds() {
|
|||||||
/>
|
/>
|
||||||
<Divider />
|
<Divider />
|
||||||
<StackCustom>
|
<StackCustom>
|
||||||
{Array.from({ length: 10 }).map((_, index) => (
|
{loadData ? (
|
||||||
<View key={index}>
|
<LoaderCustom />
|
||||||
<GridViewCustomSpan
|
) : _.isEmpty(listData) ? (
|
||||||
span1={3}
|
<TextCustom align="center" color="gray">
|
||||||
span2={5}
|
Belum ada data
|
||||||
span3={4}
|
</TextCustom>
|
||||||
component1={
|
) : (
|
||||||
<CenterCustom>
|
listData?.map((item, index) => (
|
||||||
<ActionIcon
|
<View key={index}>
|
||||||
icon={<IconView size={ICON_SIZE_BUTTON} color="black" />}
|
<GridViewCustomSpan
|
||||||
onPress={() => {
|
span1={3}
|
||||||
router.push(
|
span2={5}
|
||||||
`/admin/donation/${id}/detail-disbursement-of-funds`
|
span3={4}
|
||||||
);
|
component1={
|
||||||
}}
|
<CenterCustom>
|
||||||
/>
|
<ActionIcon
|
||||||
</CenterCustom>
|
icon={
|
||||||
}
|
<IconView size={ICON_SIZE_BUTTON} color="black" />
|
||||||
component2={
|
}
|
||||||
<TextCustom bold align="center" truncate>
|
onPress={() => {
|
||||||
{dayjs()
|
router.push(
|
||||||
.add(index + 1, "day")
|
`/admin/donation/${item?.id}/detail-disbursement-of-funds`
|
||||||
.format("DD-MM-YYYY HH:mm")}
|
);
|
||||||
</TextCustom>
|
}}
|
||||||
}
|
/>
|
||||||
component3={<TextCustom>Rp. 1.000.000</TextCustom>}
|
</CenterCustom>
|
||||||
/>
|
}
|
||||||
<Divider />
|
component2={
|
||||||
</View>
|
<TextCustom align="center" truncate>
|
||||||
))}
|
{dayjs(item?.createdAt).format("DD-MM-YYYY")}
|
||||||
|
</TextCustom>
|
||||||
|
}
|
||||||
|
component3={
|
||||||
|
<TextCustom align="center" truncate>
|
||||||
|
Rp. {formatCurrencyDisplay(item?.nominalCair)}
|
||||||
|
</TextCustom>
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
</View>
|
||||||
|
))
|
||||||
|
)}
|
||||||
</StackCustom>
|
</StackCustom>
|
||||||
</ViewWrapper>
|
</ViewWrapper>
|
||||||
</>
|
</>
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
|
/* eslint-disable react-hooks/exhaustive-deps */
|
||||||
import {
|
import {
|
||||||
ActionIcon,
|
ActionIcon,
|
||||||
BadgeCustom,
|
BadgeCustom,
|
||||||
CenterCustom,
|
CenterCustom,
|
||||||
|
LoaderCustom,
|
||||||
SelectCustom,
|
SelectCustom,
|
||||||
StackCustom,
|
StackCustom,
|
||||||
TextCustom,
|
TextCustom,
|
||||||
@@ -10,23 +12,91 @@ import {
|
|||||||
import { IconView } from "@/components/_Icon/IconComponent";
|
import { IconView } from "@/components/_Icon/IconComponent";
|
||||||
import AdminBackButtonAntTitle from "@/components/_ShareComponent/Admin/BackButtonAntTitle";
|
import AdminBackButtonAntTitle from "@/components/_ShareComponent/Admin/BackButtonAntTitle";
|
||||||
import { GridViewCustomSpan } from "@/components/_ShareComponent/GridViewCustomSpan";
|
import { GridViewCustomSpan } from "@/components/_ShareComponent/GridViewCustomSpan";
|
||||||
import { MainColor } from "@/constants/color-palet";
|
|
||||||
import { ICON_SIZE_BUTTON } from "@/constants/constans-value";
|
import { ICON_SIZE_BUTTON } from "@/constants/constans-value";
|
||||||
import { dummyMasterStatusTransaction } from "@/lib/dummy-data/_master/status-transaction";
|
import { apiAdminDonationListOfDonatur } from "@/service/api-admin/api-admin-donation";
|
||||||
import { router, useLocalSearchParams } from "expo-router";
|
import { apiMasterTransaction } from "@/service/api-client/api-master";
|
||||||
import React from "react";
|
import { colorBadgeTransaction } from "@/utils/colorBadge";
|
||||||
|
import { router, useFocusEffect, useLocalSearchParams } from "expo-router";
|
||||||
|
import _ from "lodash";
|
||||||
|
import React, { useEffect } from "react";
|
||||||
import { View } from "react-native";
|
import { View } from "react-native";
|
||||||
import { Divider } from "react-native-paper";
|
import { Divider } from "react-native-paper";
|
||||||
|
|
||||||
export default function AdminDonasiListOfDonatur() {
|
export default function AdminDonasiListOfDonatur() {
|
||||||
const { id } = useLocalSearchParams();
|
const { id } = useLocalSearchParams();
|
||||||
|
const [listData, setListData] = React.useState<any[] | null>(null);
|
||||||
|
const [loadData, setLoadData] = React.useState(false);
|
||||||
|
const [master, setMaster] = React.useState<any[]>([]);
|
||||||
|
|
||||||
|
const [selectValue, setSelectValue] = React.useState<string | null>(null);
|
||||||
|
const [selectedStatus, setSelectedStatus] = React.useState<string | null>(
|
||||||
|
null
|
||||||
|
);
|
||||||
|
|
||||||
|
useFocusEffect(
|
||||||
|
React.useCallback(() => {
|
||||||
|
onLoadData();
|
||||||
|
}, [id, selectValue])
|
||||||
|
);
|
||||||
|
|
||||||
|
const onLoadData = async () => {
|
||||||
|
try {
|
||||||
|
setLoadData(true);
|
||||||
|
const response = await apiAdminDonationListOfDonatur({
|
||||||
|
id: id as string,
|
||||||
|
status: selectedStatus as any,
|
||||||
|
});
|
||||||
|
// console.log("[LIST OF DONATUR]", JSON.stringify(response, null, 2));
|
||||||
|
|
||||||
|
if (response.success) {
|
||||||
|
setListData(response.data);
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.log("[ERROR]", error);
|
||||||
|
setListData([]);
|
||||||
|
} finally {
|
||||||
|
setLoadData(false);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
onLoadMaster();
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
const onLoadMaster = async () => {
|
||||||
|
try {
|
||||||
|
const response = await apiMasterTransaction();
|
||||||
|
|
||||||
|
if (response.success) {
|
||||||
|
setMaster(response.data);
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.log("[ERROR]", error);
|
||||||
|
setMaster([]);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
const searchComponent = (
|
const searchComponent = (
|
||||||
<View style={{ flexDirection: "row", gap: 5 }}>
|
<View style={{ flexDirection: "row", gap: 5 }}>
|
||||||
<SelectCustom
|
<SelectCustom
|
||||||
placeholder="Pilih status transaksi"
|
placeholder="Pilih status transaksi"
|
||||||
data={dummyMasterStatusTransaction}
|
data={
|
||||||
onChange={(value) => console.log(value)}
|
_.isEmpty(master)
|
||||||
|
? []
|
||||||
|
: master?.map((item: any) => ({
|
||||||
|
label: item.name,
|
||||||
|
value: item.id,
|
||||||
|
}))
|
||||||
|
}
|
||||||
|
value={selectValue}
|
||||||
|
onChange={(value: any) => {
|
||||||
|
setSelectValue(value);
|
||||||
|
const nameSelected = master.find((item: any) => item.id === value);
|
||||||
|
const statusChooses = _.lowerCase(nameSelected?.name);
|
||||||
|
setSelectedStatus(statusChooses);
|
||||||
|
}}
|
||||||
styleContainer={{ width: "100%", marginBottom: 0 }}
|
styleContainer={{ width: "100%", marginBottom: 0 }}
|
||||||
|
allowClear
|
||||||
/>
|
/>
|
||||||
</View>
|
</View>
|
||||||
);
|
);
|
||||||
@@ -37,63 +107,78 @@ export default function AdminDonasiListOfDonatur() {
|
|||||||
<AdminBackButtonAntTitle newComponent={searchComponent} />
|
<AdminBackButtonAntTitle newComponent={searchComponent} />
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
<GridViewCustomSpan
|
|
||||||
span1={3}
|
|
||||||
span2={5}
|
|
||||||
span3={4}
|
|
||||||
component1={
|
|
||||||
<TextCustom bold align="center">
|
|
||||||
Aksi
|
|
||||||
</TextCustom>
|
|
||||||
}
|
|
||||||
component2={
|
|
||||||
<TextCustom bold align="center">
|
|
||||||
Donatur
|
|
||||||
</TextCustom>
|
|
||||||
}
|
|
||||||
component3={
|
|
||||||
<TextCustom bold align="center">
|
|
||||||
Status
|
|
||||||
</TextCustom>
|
|
||||||
}
|
|
||||||
/>
|
|
||||||
<Divider />
|
|
||||||
<StackCustom>
|
<StackCustom>
|
||||||
{Array.from({ length: 10 }).map((_, index) => (
|
<GridViewCustomSpan
|
||||||
<View key={index}>
|
span1={3}
|
||||||
<GridViewCustomSpan
|
span2={5}
|
||||||
span1={3}
|
span3={4}
|
||||||
span2={5}
|
component1={
|
||||||
span3={4}
|
<TextCustom bold align="center">
|
||||||
component1={
|
Aksi
|
||||||
<CenterCustom>
|
</TextCustom>
|
||||||
<ActionIcon
|
}
|
||||||
icon={<IconView size={ICON_SIZE_BUTTON} color="black" />}
|
component2={
|
||||||
onPress={() => {
|
<TextCustom bold align="center">
|
||||||
router.push(
|
Donatur
|
||||||
`/admin/donation/${id}/berhasil/transaction-detail`
|
</TextCustom>
|
||||||
);
|
}
|
||||||
}}
|
component3={
|
||||||
/>
|
<TextCustom bold align="center">
|
||||||
</CenterCustom>
|
Status
|
||||||
}
|
</TextCustom>
|
||||||
component2={
|
}
|
||||||
<TextCustom bold align="center" truncate>
|
/>
|
||||||
Bagas Banuna
|
<Divider />
|
||||||
</TextCustom>
|
<StackCustom>
|
||||||
}
|
{loadData ? (
|
||||||
component3={
|
<LoaderCustom />
|
||||||
<BadgeCustom
|
) : _.isEmpty(listData) ? (
|
||||||
style={{ alignSelf: "center" }}
|
<TextCustom align="center" color="gray">
|
||||||
color={MainColor.green}
|
Belum ada data
|
||||||
>
|
</TextCustom>
|
||||||
Berhasil
|
) : (
|
||||||
</BadgeCustom>
|
listData?.map((item: any, index: number) => (
|
||||||
}
|
<View key={index}>
|
||||||
/>
|
<GridViewCustomSpan
|
||||||
<Divider />
|
span1={3}
|
||||||
</View>
|
span2={5}
|
||||||
))}
|
span3={4}
|
||||||
|
component1={
|
||||||
|
<CenterCustom>
|
||||||
|
<ActionIcon
|
||||||
|
icon={
|
||||||
|
<IconView size={ICON_SIZE_BUTTON} color="black" />
|
||||||
|
}
|
||||||
|
onPress={() => {
|
||||||
|
router.push(
|
||||||
|
`/admin/donation/${item?.id}/${_.lowerCase(
|
||||||
|
item?.DonasiMaster_StatusInvoice?.name
|
||||||
|
)}/transaction-detail`
|
||||||
|
);
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</CenterCustom>
|
||||||
|
}
|
||||||
|
component2={
|
||||||
|
<TextCustom bold align="center" truncate>
|
||||||
|
{item?.Author?.username || "-"}
|
||||||
|
</TextCustom>
|
||||||
|
}
|
||||||
|
component3={
|
||||||
|
<BadgeCustom
|
||||||
|
style={{ alignSelf: "center" }}
|
||||||
|
color={colorBadgeTransaction({
|
||||||
|
status: item?.DonasiMaster_StatusInvoice?.name,
|
||||||
|
})}
|
||||||
|
>
|
||||||
|
{item?.DonasiMaster_StatusInvoice?.name}
|
||||||
|
</BadgeCustom>
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
</View>
|
||||||
|
))
|
||||||
|
)}
|
||||||
|
</StackCustom>
|
||||||
</StackCustom>
|
</StackCustom>
|
||||||
</ViewWrapper>
|
</ViewWrapper>
|
||||||
</>
|
</>
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
/* eslint-disable react-hooks/exhaustive-deps */
|
||||||
import {
|
import {
|
||||||
AlertDefaultSystem,
|
AlertDefaultSystem,
|
||||||
BoxButtonOnFooter,
|
BoxButtonOnFooter,
|
||||||
@@ -6,15 +7,84 @@ import {
|
|||||||
} from "@/components";
|
} from "@/components";
|
||||||
import AdminBackButtonAntTitle from "@/components/_ShareComponent/Admin/BackButtonAntTitle";
|
import AdminBackButtonAntTitle from "@/components/_ShareComponent/Admin/BackButtonAntTitle";
|
||||||
import AdminButtonReject from "@/components/_ShareComponent/Admin/ButtonReject";
|
import AdminButtonReject from "@/components/_ShareComponent/Admin/ButtonReject";
|
||||||
import { router, useLocalSearchParams } from "expo-router";
|
import { funUpdateStatusDonation } from "@/screens/Admin/Donation/funDonationUpdateStatus";
|
||||||
import { useState } from "react";
|
import {
|
||||||
|
apiAdminDonationDetailById
|
||||||
|
} from "@/service/api-admin/api-admin-donation";
|
||||||
|
import { router, useFocusEffect, useLocalSearchParams } from "expo-router";
|
||||||
|
import React from "react";
|
||||||
|
import Toast from "react-native-toast-message";
|
||||||
|
|
||||||
export default function AdminDonationRejectInput() {
|
export default function AdminDonationRejectInput() {
|
||||||
const { id } = useLocalSearchParams();
|
const { id, status } = useLocalSearchParams();
|
||||||
const [value, setValue] = useState(id as string);
|
|
||||||
|
const [data, setData] = React.useState<any | null>(null);
|
||||||
|
const [isLoading, setIsLoading] = React.useState(false);
|
||||||
|
|
||||||
|
useFocusEffect(
|
||||||
|
React.useCallback(() => {
|
||||||
|
onLoadData();
|
||||||
|
}, [id])
|
||||||
|
);
|
||||||
|
|
||||||
|
const onLoadData = async () => {
|
||||||
|
try {
|
||||||
|
const response = await apiAdminDonationDetailById({
|
||||||
|
id: id as string,
|
||||||
|
});
|
||||||
|
|
||||||
|
if (response.success) {
|
||||||
|
setData(response.data.catatan);
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.log("[ERROR]", error);
|
||||||
|
setData(null);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleReport = async ({
|
||||||
|
changeStatus,
|
||||||
|
}: {
|
||||||
|
changeStatus: "publish" | "review" | "reject";
|
||||||
|
}) => {
|
||||||
|
try {
|
||||||
|
setIsLoading(true);
|
||||||
|
const response = await funUpdateStatusDonation({
|
||||||
|
id: id as string,
|
||||||
|
changeStatus,
|
||||||
|
data: data,
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!response.success) {
|
||||||
|
Toast.show({
|
||||||
|
type: "error",
|
||||||
|
text1: "Report gagal",
|
||||||
|
});
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
Toast.show({
|
||||||
|
type: "success",
|
||||||
|
text1: "Report berhasil",
|
||||||
|
});
|
||||||
|
|
||||||
|
if (status === "review") {
|
||||||
|
router.replace(`/admin/donation/reject/status`);
|
||||||
|
} else if (status === "reject") {
|
||||||
|
router.back();
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.log("[ERROR]", error);
|
||||||
|
} finally {
|
||||||
|
setIsLoading(false);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
const buttonSubmit = (
|
const buttonSubmit = (
|
||||||
<BoxButtonOnFooter>
|
<BoxButtonOnFooter>
|
||||||
<AdminButtonReject
|
<AdminButtonReject
|
||||||
|
isLoading={isLoading}
|
||||||
title="Reject"
|
title="Reject"
|
||||||
onReject={() =>
|
onReject={() =>
|
||||||
AlertDefaultSystem({
|
AlertDefaultSystem({
|
||||||
@@ -22,12 +92,9 @@ export default function AdminDonationRejectInput() {
|
|||||||
message: "Apakah anda yakin ingin menolak data ini?",
|
message: "Apakah anda yakin ingin menolak data ini?",
|
||||||
textLeft: "Batal",
|
textLeft: "Batal",
|
||||||
textRight: "Ya",
|
textRight: "Ya",
|
||||||
onPressLeft: () => {
|
|
||||||
router.back();
|
|
||||||
},
|
|
||||||
onPressRight: () => {
|
onPressRight: () => {
|
||||||
console.log("value:", value);
|
handleReport({ changeStatus: "reject" });
|
||||||
router.replace(`/admin/donation/reject/status`);
|
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -42,8 +109,8 @@ export default function AdminDonationRejectInput() {
|
|||||||
headerComponent={<AdminBackButtonAntTitle title="Penolakan Donasi" />}
|
headerComponent={<AdminBackButtonAntTitle title="Penolakan Donasi" />}
|
||||||
>
|
>
|
||||||
<TextAreaCustom
|
<TextAreaCustom
|
||||||
value={value}
|
value={data}
|
||||||
onChangeText={setValue}
|
onChangeText={setData}
|
||||||
placeholder="Masukan alasan"
|
placeholder="Masukan alasan"
|
||||||
required
|
required
|
||||||
showCount
|
showCount
|
||||||
|
|||||||
@@ -1,69 +1,116 @@
|
|||||||
|
/* eslint-disable react-hooks/exhaustive-deps */
|
||||||
import {
|
import {
|
||||||
ActionIcon,
|
ActionIcon,
|
||||||
SearchInput,
|
LoaderCustom,
|
||||||
Spacing,
|
SearchInput,
|
||||||
TextCustom,
|
StackCustom,
|
||||||
ViewWrapper
|
TextCustom,
|
||||||
|
ViewWrapper
|
||||||
} from "@/components";
|
} from "@/components";
|
||||||
import AdminComp_BoxTitle from "@/components/_ShareComponent/Admin/BoxTitlePage";
|
import AdminComp_BoxTitle from "@/components/_ShareComponent/Admin/BoxTitlePage";
|
||||||
import AdminTitleTable from "@/components/_ShareComponent/Admin/TableTitle";
|
import AdminTitleTable from "@/components/_ShareComponent/Admin/TableTitle";
|
||||||
import AdminTableValue from "@/components/_ShareComponent/Admin/TableValue";
|
import AdminTableValue from "@/components/_ShareComponent/Admin/TableValue";
|
||||||
|
import AdminTitlePage from "@/components/_ShareComponent/Admin/TitlePage";
|
||||||
import { ICON_SIZE_BUTTON } from "@/constants/constans-value";
|
import { ICON_SIZE_BUTTON } from "@/constants/constans-value";
|
||||||
|
import { apiAdminDonation } from "@/service/api-admin/api-admin-donation";
|
||||||
import { Octicons } from "@expo/vector-icons";
|
import { Octicons } from "@expo/vector-icons";
|
||||||
import { router, useLocalSearchParams } from "expo-router";
|
import { router, useFocusEffect, useLocalSearchParams } from "expo-router";
|
||||||
import _ from "lodash";
|
import _ from "lodash";
|
||||||
|
import { useCallback, useState } from "react";
|
||||||
import { Divider } from "react-native-paper";
|
import { Divider } from "react-native-paper";
|
||||||
|
|
||||||
export default function AdminDonationStatus() {
|
export default function AdminDonationStatus() {
|
||||||
const { status } = useLocalSearchParams();
|
const { status } = useLocalSearchParams();
|
||||||
|
console.log("[STATUS]", status);
|
||||||
|
|
||||||
|
const [data, setData] = useState<any | null>(null);
|
||||||
|
const [search, setSearch] = useState<string>("");
|
||||||
|
const [loadData, setLoadData] = useState<boolean>(false);
|
||||||
|
|
||||||
|
useFocusEffect(
|
||||||
|
useCallback(() => {
|
||||||
|
onLoadData();
|
||||||
|
}, [status, search])
|
||||||
|
);
|
||||||
|
|
||||||
|
const onLoadData = async () => {
|
||||||
|
try {
|
||||||
|
setLoadData(true);
|
||||||
|
const response = await apiAdminDonation({
|
||||||
|
category: status as "publish" | "review" | "reject",
|
||||||
|
search,
|
||||||
|
});
|
||||||
|
|
||||||
|
console.log("[RES]", JSON.stringify(response, null, 2));
|
||||||
|
|
||||||
|
if (response.success) {
|
||||||
|
setData(response.data);
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.log("[ERROR]", error);
|
||||||
|
setData([]);
|
||||||
|
} finally {
|
||||||
|
setLoadData(false);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
const rightComponent = (
|
const rightComponent = (
|
||||||
<SearchInput
|
<SearchInput
|
||||||
containerStyle={{ width: "100%", marginBottom: 0 }}
|
containerStyle={{ width: "100%", marginBottom: 0 }}
|
||||||
placeholder="Cari"
|
placeholder="Cari"
|
||||||
|
value={search}
|
||||||
|
onChangeText={(value) => setSearch(value)}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<ViewWrapper
|
<ViewWrapper headerComponent={<AdminTitlePage title="Donasi" />}>
|
||||||
headerComponent={
|
<StackCustom gap={"sm"}>
|
||||||
<AdminComp_BoxTitle
|
<AdminComp_BoxTitle
|
||||||
title={`Donasi ${_.startCase(status as string)}`}
|
title={`${_.startCase(status as string)}`}
|
||||||
rightComponent={rightComponent}
|
rightComponent={rightComponent}
|
||||||
/>
|
/>
|
||||||
}
|
<AdminTitleTable
|
||||||
>
|
title1="Aksi"
|
||||||
<AdminTitleTable
|
title2="Username"
|
||||||
title1="Aksi"
|
title3="Judul Donasi"
|
||||||
title2="Username"
|
|
||||||
title3="Judul Donasi"
|
|
||||||
/>
|
|
||||||
<Spacing />
|
|
||||||
<Divider />
|
|
||||||
|
|
||||||
{Array.from({ length: 10 }).map((_, index) => (
|
|
||||||
<AdminTableValue
|
|
||||||
key={index}
|
|
||||||
value1={
|
|
||||||
<ActionIcon
|
|
||||||
icon={
|
|
||||||
<Octicons name="eye" size={ICON_SIZE_BUTTON} color="black" />
|
|
||||||
}
|
|
||||||
onPress={() => {
|
|
||||||
router.push(`/admin/donation/${index}/${status}`);
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
}
|
|
||||||
value2={<TextCustom truncate={1}>Username username</TextCustom>}
|
|
||||||
value3={
|
|
||||||
<TextCustom truncate={2}>
|
|
||||||
Lorem ipsum dolor sit amet consectetur adipisicing elit.
|
|
||||||
Blanditiis asperiores quidem deleniti architecto eaque et
|
|
||||||
nostrum, ad consequuntur eveniet quisquam quae voluptatum
|
|
||||||
ducimus! Dolorem nobis modi officia debitis, beatae mollitia.
|
|
||||||
</TextCustom>
|
|
||||||
}
|
|
||||||
/>
|
/>
|
||||||
))}
|
<Divider />
|
||||||
|
|
||||||
|
{loadData ? (
|
||||||
|
<LoaderCustom />
|
||||||
|
) : _.isEmpty(data) ? (
|
||||||
|
<TextCustom align="center" size="small" color="gray">
|
||||||
|
Belum ada data
|
||||||
|
</TextCustom>
|
||||||
|
) : (
|
||||||
|
data?.map((item: any, index: number) => (
|
||||||
|
<AdminTableValue
|
||||||
|
key={index}
|
||||||
|
value1={
|
||||||
|
<ActionIcon
|
||||||
|
icon={
|
||||||
|
<Octicons
|
||||||
|
name="eye"
|
||||||
|
size={ICON_SIZE_BUTTON}
|
||||||
|
color="black"
|
||||||
|
/>
|
||||||
|
}
|
||||||
|
onPress={() => {
|
||||||
|
router.push(`/admin/donation/${item.id}/${status}`);
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
}
|
||||||
|
value2={<TextCustom truncate={1}>{item?.Author?.username || "-"}</TextCustom>}
|
||||||
|
value3={
|
||||||
|
<TextCustom truncate={2}>
|
||||||
|
{item?.title || "-"}
|
||||||
|
</TextCustom>
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
))
|
||||||
|
)}
|
||||||
|
</StackCustom>
|
||||||
</ViewWrapper>
|
</ViewWrapper>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,15 +1,67 @@
|
|||||||
import { Spacing, StackCustom, ViewWrapper } from "@/components";
|
import { Spacing, StackCustom, ViewWrapper } from "@/components";
|
||||||
import {
|
import {
|
||||||
IconList,
|
IconList,
|
||||||
IconPublish,
|
IconPublish,
|
||||||
IconReject,
|
IconReject,
|
||||||
IconReview,
|
IconReview,
|
||||||
} from "@/components/_Icon/IconComponent";
|
} from "@/components/_Icon/IconComponent";
|
||||||
import AdminComp_BoxDashboard from "@/components/_ShareComponent/Admin/BoxDashboard";
|
import AdminComp_BoxDashboard from "@/components/_ShareComponent/Admin/BoxDashboard";
|
||||||
import AdminTitlePage from "@/components/_ShareComponent/Admin/TitlePage";
|
import AdminTitlePage from "@/components/_ShareComponent/Admin/TitlePage";
|
||||||
import { MainColor } from "@/constants/color-palet";
|
import { MainColor } from "@/constants/color-palet";
|
||||||
|
import { apiAdminDonation } from "@/service/api-admin/api-admin-donation";
|
||||||
|
import { useFocusEffect } from "expo-router";
|
||||||
|
import { useState, useCallback } from "react";
|
||||||
|
|
||||||
export default function AdminDonation() {
|
export default function AdminDonation() {
|
||||||
|
const [data, setData] = useState<any | null>(null);
|
||||||
|
|
||||||
|
useFocusEffect(
|
||||||
|
useCallback(() => {
|
||||||
|
onLoadData();
|
||||||
|
}, [])
|
||||||
|
);
|
||||||
|
|
||||||
|
const onLoadData = async () => {
|
||||||
|
try {
|
||||||
|
|
||||||
|
const response = await apiAdminDonation({
|
||||||
|
category: "dashboard",
|
||||||
|
});
|
||||||
|
|
||||||
|
console.log("[RES]", JSON.stringify(response, null, 2));
|
||||||
|
|
||||||
|
if (response.success) {
|
||||||
|
setData(response.data);
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.log("[ERROR]", error);
|
||||||
|
setData([]);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const listData = [
|
||||||
|
{
|
||||||
|
label: "Publish",
|
||||||
|
value: (data && data.publish) || 0,
|
||||||
|
icon: <IconPublish size={25} color={MainColor.green} />,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: "Review",
|
||||||
|
value: (data && data.review) || 0,
|
||||||
|
icon: <IconReview size={25} color={MainColor.orange} />,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: "Reject",
|
||||||
|
value: (data && data.reject) || 0,
|
||||||
|
icon: <IconReject size={25} color={MainColor.red} />,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: "Kategori",
|
||||||
|
value: (data && data.categoryDonation) || 0,
|
||||||
|
icon: <IconList size={25} color={MainColor.white_gray} />,
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<ViewWrapper>
|
<ViewWrapper>
|
||||||
@@ -24,26 +76,3 @@ export default function AdminDonation() {
|
|||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const listData = [
|
|
||||||
{
|
|
||||||
label: "Publish",
|
|
||||||
value: 4,
|
|
||||||
icon: <IconPublish size={25} color={MainColor.green} />,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: "Review",
|
|
||||||
value: 7,
|
|
||||||
icon: <IconReview size={25} color={MainColor.orange} />,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: "Reject",
|
|
||||||
value: 5,
|
|
||||||
icon: <IconReject size={25} color={MainColor.red} />,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: "Kategori",
|
|
||||||
value: 4,
|
|
||||||
icon: <IconList size={25} color={MainColor.white_gray} />,
|
|
||||||
},
|
|
||||||
];
|
|
||||||
|
|||||||
@@ -1,112 +1,110 @@
|
|||||||
|
/* eslint-disable react-hooks/exhaustive-deps */
|
||||||
import {
|
import {
|
||||||
ActionIcon,
|
ActionIcon,
|
||||||
AlertDefaultSystem,
|
AlertDefaultSystem,
|
||||||
BadgeCustom,
|
BadgeCustom,
|
||||||
BaseBox,
|
BaseBox,
|
||||||
DrawerCustom,
|
DrawerCustom,
|
||||||
MenuDrawerDynamicGrid,
|
LoaderCustom,
|
||||||
Spacing,
|
MenuDrawerDynamicGrid,
|
||||||
StackCustom,
|
Spacing,
|
||||||
TextCustom,
|
StackCustom,
|
||||||
ViewWrapper,
|
TextCustom,
|
||||||
|
ViewWrapper,
|
||||||
} from "@/components";
|
} from "@/components";
|
||||||
import { IconDot, IconList } from "@/components/_Icon/IconComponent";
|
import { IconDot, IconList } from "@/components/_Icon/IconComponent";
|
||||||
import AdminBackButtonAntTitle from "@/components/_ShareComponent/Admin/BackButtonAntTitle";
|
import AdminBackButtonAntTitle from "@/components/_ShareComponent/Admin/BackButtonAntTitle";
|
||||||
import AdminButtonReject from "@/components/_ShareComponent/Admin/ButtonReject";
|
import AdminButtonReject from "@/components/_ShareComponent/Admin/ButtonReject";
|
||||||
import AdminButtonReview from "@/components/_ShareComponent/Admin/ButtonReview";
|
import AdminButtonReview from "@/components/_ShareComponent/Admin/ButtonReview";
|
||||||
import { GridDetail_4_8 } from "@/components/_ShareComponent/GridDetail_4_8";
|
import { GridDetail_4_8 } from "@/components/_ShareComponent/GridDetail_4_8";
|
||||||
import { MainColor } from "@/constants/color-palet";
|
import ReportBox from "@/components/Box/ReportBox";
|
||||||
import { ICON_SIZE_BUTTON } from "@/constants/constans-value";
|
import { ICON_SIZE_BUTTON } from "@/constants/constans-value";
|
||||||
import dayjs from "dayjs";
|
import { useAuth } from "@/hooks/use-auth";
|
||||||
import { router, useLocalSearchParams } from "expo-router";
|
import { funUpdateStatusEvent } from "@/screens/Admin/Event/funUpdateStatus";
|
||||||
|
import { apiAdminEventById } from "@/service/api-admin/api-admin-event";
|
||||||
|
import { DEEP_LINK_URL } from "@/service/api-config";
|
||||||
|
import { colorBadgeStatus } from "@/utils/colorBadge";
|
||||||
|
import { dateTimeView } from "@/utils/dateTimeView";
|
||||||
|
import { router, useFocusEffect, useLocalSearchParams } from "expo-router";
|
||||||
import _ from "lodash";
|
import _ from "lodash";
|
||||||
import React from "react";
|
import React, { useCallback } from "react";
|
||||||
import QRCode from "react-native-qrcode-svg";
|
import QRCode from "react-native-qrcode-svg";
|
||||||
|
import Toast from "react-native-toast-message";
|
||||||
|
|
||||||
export default function AdminEventDetail() {
|
export default function AdminEventDetail() {
|
||||||
|
const { user } = useAuth();
|
||||||
const { id, status } = useLocalSearchParams();
|
const { id, status } = useLocalSearchParams();
|
||||||
const [openDrawer, setOpenDrawer] = React.useState(false);
|
const [openDrawer, setOpenDrawer] = React.useState(false);
|
||||||
|
|
||||||
const colorBadge = () => {
|
const [data, setData] = React.useState<any | null>(null);
|
||||||
if (status === "publish") {
|
const [loadData, setLoadData] = React.useState(false);
|
||||||
return MainColor.green;
|
const deepLinkURL = `${DEEP_LINK_URL}/--/event/${id}/confirmation?userId=${user?.id}`;
|
||||||
} else if (status === "review") {
|
useFocusEffect(
|
||||||
return MainColor.orange;
|
useCallback(() => {
|
||||||
} else if (status === "reject") {
|
onLoadData();
|
||||||
return MainColor.red;
|
}, [id])
|
||||||
} else {
|
);
|
||||||
return MainColor.placeholder;
|
const onLoadData = async () => {
|
||||||
|
try {
|
||||||
|
setLoadData(true);
|
||||||
|
const response = await apiAdminEventById({
|
||||||
|
id: id as string,
|
||||||
|
});
|
||||||
|
|
||||||
|
if (response.success) {
|
||||||
|
setData(response.data);
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.log("[ERROR]", error);
|
||||||
|
} finally {
|
||||||
|
setLoadData(false);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const listData = [
|
const listData = [
|
||||||
{
|
{
|
||||||
label: "Pembuat Event",
|
label: "Pembuat Event",
|
||||||
value: `Bagas Banuna ${id}`,
|
value: (data && data?.Author?.username) || "-",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: "Judul Event",
|
label: "Judul Event",
|
||||||
value: `Event 123`,
|
value: (data && data?.title) || "-",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: "Status",
|
label: "Status",
|
||||||
value: (
|
value:
|
||||||
<BadgeCustom color={colorBadge()}>
|
(data && (
|
||||||
{_.startCase(status as string)}
|
<BadgeCustom color={colorBadgeStatus({ status: status as string })}>
|
||||||
</BadgeCustom>
|
{_.startCase(status as string)}
|
||||||
),
|
</BadgeCustom>
|
||||||
|
)) ||
|
||||||
|
"-",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: "Lokasi",
|
label: "Lokasi",
|
||||||
value: "Lokasi Event",
|
value: (data && data?.lokasi) || "-",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: "Tipe Acara",
|
label: "Tipe Acara",
|
||||||
value: "Tipe Acara",
|
value: (data && data?.EventMaster_TipeAcara?.name) || "-",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: "Mulai Event",
|
label: "Mulai Event",
|
||||||
value: dayjs().format("DD/MM/YYYY HH:mm:ss"),
|
value:
|
||||||
|
(data && data?.tanggal && dateTimeView({ date: data?.tanggal })) || "-",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: "Event Berakhir",
|
label: "Event Berakhir",
|
||||||
value: dayjs().add(3, "day").format("DD/MM/YYYY HH:mm:ss"),
|
value:
|
||||||
|
(data &&
|
||||||
|
data?.tanggalSelesai &&
|
||||||
|
dateTimeView({ date: data?.tanggalSelesai })) ||
|
||||||
|
"-",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: "Deskripsi",
|
label: "Deskripsi",
|
||||||
value: "Lorem ipsum dolor sit amet consectetur adipisicing elit.",
|
value: (data && data?.deskripsi) || "-",
|
||||||
},
|
},
|
||||||
// {
|
|
||||||
// label: "Daftar Tipe Acara",
|
|
||||||
// value: (
|
|
||||||
// <>
|
|
||||||
// <List.Item
|
|
||||||
// title={<TextCustom>Pilihan 1</TextCustom>}
|
|
||||||
// left={(props) => (
|
|
||||||
// <List.Icon {...props} icon="circle" color={MainColor.yellow} />
|
|
||||||
// )}
|
|
||||||
// />
|
|
||||||
// <List.Item
|
|
||||||
// title={<TextCustom>Pilihan 2</TextCustom>}
|
|
||||||
// left={(props) => (
|
|
||||||
// <List.Icon {...props} icon="circle" color={MainColor.yellow} />
|
|
||||||
// )}
|
|
||||||
// />
|
|
||||||
// <List.Item
|
|
||||||
// title={<TextCustom>Pilihan 3</TextCustom>}
|
|
||||||
// left={(props) => (
|
|
||||||
// <List.Icon {...props} icon="circle" color={MainColor.yellow} />
|
|
||||||
// )}
|
|
||||||
// />
|
|
||||||
// <List.Item
|
|
||||||
// title={<TextCustom>Pilihan 4</TextCustom>}
|
|
||||||
// left={(props) => (
|
|
||||||
// <List.Icon {...props} icon="circle" color={MainColor.yellow} />
|
|
||||||
// )}
|
|
||||||
// />
|
|
||||||
// </>
|
|
||||||
// ),
|
|
||||||
// },
|
|
||||||
];
|
];
|
||||||
|
|
||||||
const rightComponent = (
|
const rightComponent = (
|
||||||
@@ -118,6 +116,31 @@ export default function AdminEventDetail() {
|
|||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const handlerSubmit = async () => {
|
||||||
|
try {
|
||||||
|
const response = await funUpdateStatusEvent({
|
||||||
|
id: id as string,
|
||||||
|
changeStatus: "publish",
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!response.success) {
|
||||||
|
Toast.show({
|
||||||
|
type: "error",
|
||||||
|
text1: "Gagal mempublikasikan event",
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Toast.show({
|
||||||
|
type: "success",
|
||||||
|
text1: "Event berhasil dipublikasikan",
|
||||||
|
});
|
||||||
|
router.back();
|
||||||
|
} catch (error) {
|
||||||
|
console.log("[ERROR]", error);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<ViewWrapper
|
<ViewWrapper
|
||||||
@@ -125,7 +148,7 @@ export default function AdminEventDetail() {
|
|||||||
<AdminBackButtonAntTitle
|
<AdminBackButtonAntTitle
|
||||||
title={`Detail Data`}
|
title={`Detail Data`}
|
||||||
rightComponent={
|
rightComponent={
|
||||||
(status === "publish" || status === "riwayat") && rightComponent
|
(status === "publish" || status === "history") && rightComponent
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
}
|
}
|
||||||
@@ -143,19 +166,30 @@ export default function AdminEventDetail() {
|
|||||||
|
|
||||||
<Spacing />
|
<Spacing />
|
||||||
</BaseBox>
|
</BaseBox>
|
||||||
{(status === "publish" || status === "riwayat") && (
|
|
||||||
|
{data &&
|
||||||
|
data?.catatan &&
|
||||||
|
(status === "reject" || status === "review") && (
|
||||||
|
<ReportBox text={data?.catatan} />
|
||||||
|
)}
|
||||||
|
|
||||||
|
{(status === "publish" || status === "history") && (
|
||||||
<BaseBox>
|
<BaseBox>
|
||||||
<StackCustom style={{ alignItems: "center" }}>
|
<StackCustom style={{ alignItems: "center" }}>
|
||||||
<TextCustom bold>QR Code Event</TextCustom>
|
<TextCustom bold>QR Code Event</TextCustom>
|
||||||
<QRCode
|
{loadData ? (
|
||||||
value="https://google.com"
|
<LoaderCustom />
|
||||||
size={200}
|
) : (
|
||||||
// logo={require("@/assets/images/logo-hipmi.png")}
|
<QRCode
|
||||||
// logoSize={70}
|
value={deepLinkURL}
|
||||||
// logoBackgroundColor="transparent"
|
size={200}
|
||||||
// logoBorderRadius={50}
|
// logo={require("@/assets/images/logo-hipmi.png")}
|
||||||
// color="black"
|
// logoSize={70}
|
||||||
/>
|
// logoBackgroundColor="transparent"
|
||||||
|
// logoBorderRadius={50}
|
||||||
|
// color="black"
|
||||||
|
/>
|
||||||
|
)}
|
||||||
</StackCustom>
|
</StackCustom>
|
||||||
</BaseBox>
|
</BaseBox>
|
||||||
)}
|
)}
|
||||||
@@ -168,16 +202,11 @@ export default function AdminEventDetail() {
|
|||||||
message: "Apakah anda yakin ingin mempublikasikan data ini?",
|
message: "Apakah anda yakin ingin mempublikasikan data ini?",
|
||||||
textLeft: "Batal",
|
textLeft: "Batal",
|
||||||
textRight: "Ya",
|
textRight: "Ya",
|
||||||
onPressLeft: () => {
|
onPressRight: () => handlerSubmit(),
|
||||||
router.back();
|
|
||||||
},
|
|
||||||
onPressRight: () => {
|
|
||||||
router.back();
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
}}
|
}}
|
||||||
onReject={() => {
|
onReject={() => {
|
||||||
router.push(`/admin/event/${id}/reject-input`);
|
router.push(`/admin/event/${id}/reject-input?status=${status}`);
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
@@ -186,7 +215,7 @@ export default function AdminEventDetail() {
|
|||||||
<AdminButtonReject
|
<AdminButtonReject
|
||||||
title="Tambah Catatan"
|
title="Tambah Catatan"
|
||||||
onReject={() => {
|
onReject={() => {
|
||||||
router.push(`/admin/event/${id}/reject-input`);
|
router.push(`/admin/event/${id}/reject-input?status=${status}`);
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
|||||||
@@ -1,41 +1,81 @@
|
|||||||
import { BadgeCustom, BaseBox, Grid, TextCustom, ViewWrapper } from "@/components";
|
/* eslint-disable react-hooks/exhaustive-deps */
|
||||||
|
import {
|
||||||
|
BadgeCustom,
|
||||||
|
BaseBox,
|
||||||
|
Grid,
|
||||||
|
LoaderCustom,
|
||||||
|
StackCustom,
|
||||||
|
TextCustom,
|
||||||
|
ViewWrapper,
|
||||||
|
} from "@/components";
|
||||||
import AdminBackButtonAntTitle from "@/components/_ShareComponent/Admin/BackButtonAntTitle";
|
import AdminBackButtonAntTitle from "@/components/_ShareComponent/Admin/BackButtonAntTitle";
|
||||||
import { MainColor } from "@/constants/color-palet";
|
import { apiAdminEventListOfParticipants } from "@/service/api-admin/api-admin-event";
|
||||||
|
import { useFocusEffect, useLocalSearchParams } from "expo-router";
|
||||||
|
import _ from "lodash";
|
||||||
|
import { useCallback, useState } from "react";
|
||||||
|
|
||||||
export default function AdminEventListOfParticipants() {
|
export default function AdminEventListOfParticipants() {
|
||||||
|
const { id } = useLocalSearchParams();
|
||||||
|
const [listData, setListData] = useState<any[] | null>(null);
|
||||||
|
const [loadData, setLoadData] = useState(false);
|
||||||
|
|
||||||
const isPresent = ({id}: {id: number}) => {
|
useFocusEffect(
|
||||||
const check = id % 3 * 3;
|
useCallback(() => {
|
||||||
if (check === 0) {
|
onLoadData();
|
||||||
return true;
|
}, [id])
|
||||||
} else {
|
);
|
||||||
return false;
|
|
||||||
}
|
const onLoadData = async () => {
|
||||||
|
try {
|
||||||
|
setLoadData(true);
|
||||||
|
const response = await apiAdminEventListOfParticipants({
|
||||||
|
id: id as string,
|
||||||
|
});
|
||||||
|
|
||||||
|
if (response.success) {
|
||||||
|
setListData(response.data);
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.log("[ERROR]", error);
|
||||||
|
} finally {
|
||||||
|
setLoadData(false);
|
||||||
}
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<ViewWrapper
|
<ViewWrapper
|
||||||
headerComponent={<AdminBackButtonAntTitle title="Daftar Peserta" />}
|
headerComponent={<AdminBackButtonAntTitle title="Daftar Peserta" />}
|
||||||
>
|
>
|
||||||
{Array.from({ length: 10 }).map((item, index) => (
|
{loadData ? (
|
||||||
<BaseBox key={index}>
|
<LoaderCustom />
|
||||||
<Grid>
|
) : _.isEmpty(listData) ? (
|
||||||
<Grid.Col span={6}>
|
<TextCustom align="center" color="gray">
|
||||||
<TextCustom bold>Username {index + 1}</TextCustom>
|
Belum ada peserta
|
||||||
<TextCustom>+6282123456789</TextCustom>
|
</TextCustom>
|
||||||
</Grid.Col>
|
) : (
|
||||||
<Grid.Col span={6} style={{ justifyContent: "center" }}>
|
listData?.map((item: any, index: number) => (
|
||||||
<BadgeCustom
|
<BaseBox key={index}>
|
||||||
style={{ alignSelf: "flex-end" }}
|
<Grid>
|
||||||
color={isPresent({id: index}) ? MainColor.green : MainColor.red}
|
<Grid.Col span={6}>
|
||||||
>
|
<StackCustom gap={"sm"}>
|
||||||
{isPresent({id: index}) ? "Hadir" : "Tidak Hadir"}
|
<TextCustom bold truncate>{item?.User?.username}</TextCustom>
|
||||||
</BadgeCustom>
|
<TextCustom>+{item?.User?.nomor}</TextCustom>
|
||||||
</Grid.Col>
|
</StackCustom>
|
||||||
</Grid>
|
</Grid.Col>
|
||||||
</BaseBox>
|
<Grid.Col span={6} style={{ justifyContent: "center" }}>
|
||||||
))}
|
<BadgeCustom
|
||||||
|
style={{ alignSelf: "flex-end" }}
|
||||||
|
color={item?.isPresent ? "green" : "red"}
|
||||||
|
>
|
||||||
|
{item?.isPresent ? "Hadir" : "Tidak Hadir"}
|
||||||
|
</BadgeCustom>
|
||||||
|
</Grid.Col>
|
||||||
|
</Grid>
|
||||||
|
</BaseBox>
|
||||||
|
))
|
||||||
|
)}
|
||||||
</ViewWrapper>
|
</ViewWrapper>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
/* eslint-disable react-hooks/exhaustive-deps */
|
||||||
import {
|
import {
|
||||||
AlertDefaultSystem,
|
AlertDefaultSystem,
|
||||||
BoxButtonOnFooter,
|
BoxButtonOnFooter,
|
||||||
@@ -6,15 +7,78 @@ import {
|
|||||||
} from "@/components";
|
} from "@/components";
|
||||||
import AdminBackButtonAntTitle from "@/components/_ShareComponent/Admin/BackButtonAntTitle";
|
import AdminBackButtonAntTitle from "@/components/_ShareComponent/Admin/BackButtonAntTitle";
|
||||||
import AdminButtonReject from "@/components/_ShareComponent/Admin/ButtonReject";
|
import AdminButtonReject from "@/components/_ShareComponent/Admin/ButtonReject";
|
||||||
import { router, useLocalSearchParams } from "expo-router";
|
import { funUpdateStatusEvent } from "@/screens/Admin/Event/funUpdateStatus";
|
||||||
import { useState } from "react";
|
import { apiAdminEventById } from "@/service/api-admin/api-admin-event";
|
||||||
|
import { router, useFocusEffect, useLocalSearchParams } from "expo-router";
|
||||||
|
import { useCallback, useState } from "react";
|
||||||
|
import Toast from "react-native-toast-message";
|
||||||
|
|
||||||
export default function AdminEventRejectInput() {
|
export default function AdminEventRejectInput() {
|
||||||
const { id } = useLocalSearchParams();
|
const { id, status } = useLocalSearchParams();
|
||||||
const [value, setValue] = useState(id as string);
|
|
||||||
|
const [data, setData] = useState<any>("");
|
||||||
|
const [isLoading, setIsLoading] = useState(false);
|
||||||
|
|
||||||
|
useFocusEffect(
|
||||||
|
useCallback(() => {
|
||||||
|
onLoadData();
|
||||||
|
}, [id])
|
||||||
|
);
|
||||||
|
const onLoadData = async () => {
|
||||||
|
try {
|
||||||
|
const response = await apiAdminEventById({
|
||||||
|
id: id as string,
|
||||||
|
});
|
||||||
|
|
||||||
|
if (response.success) {
|
||||||
|
setData(response.data.catatan);
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.log("[ERROR]", error);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleUpdate = async ({
|
||||||
|
changeStatus,
|
||||||
|
}: {
|
||||||
|
changeStatus: "publish" | "review" | "reject";
|
||||||
|
}) => {
|
||||||
|
try {
|
||||||
|
setIsLoading(true);
|
||||||
|
const response = await funUpdateStatusEvent({
|
||||||
|
id: id as string,
|
||||||
|
changeStatus,
|
||||||
|
data: data,
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!response.success) {
|
||||||
|
Toast.show({
|
||||||
|
type: "error",
|
||||||
|
text1: "Report gagal",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
Toast.show({
|
||||||
|
type: "success",
|
||||||
|
text1: "Report berhasil",
|
||||||
|
});
|
||||||
|
|
||||||
|
if (status === "review") {
|
||||||
|
router.replace(`/admin/event/reject/status`);
|
||||||
|
} else if (status === "reject") {
|
||||||
|
router.back();
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.log("[ERROR]", error);
|
||||||
|
} finally {
|
||||||
|
setIsLoading(false);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
const buttonSubmit = (
|
const buttonSubmit = (
|
||||||
<BoxButtonOnFooter>
|
<BoxButtonOnFooter>
|
||||||
<AdminButtonReject
|
<AdminButtonReject
|
||||||
|
isLoading={isLoading}
|
||||||
title="Reject"
|
title="Reject"
|
||||||
onReject={() =>
|
onReject={() =>
|
||||||
AlertDefaultSystem({
|
AlertDefaultSystem({
|
||||||
@@ -22,12 +86,8 @@ export default function AdminEventRejectInput() {
|
|||||||
message: "Apakah anda yakin ingin menolak data ini?",
|
message: "Apakah anda yakin ingin menolak data ini?",
|
||||||
textLeft: "Batal",
|
textLeft: "Batal",
|
||||||
textRight: "Ya",
|
textRight: "Ya",
|
||||||
onPressLeft: () => {
|
|
||||||
router.back();
|
|
||||||
},
|
|
||||||
onPressRight: () => {
|
onPressRight: () => {
|
||||||
console.log("value:", value);
|
handleUpdate({ changeStatus: "reject" });
|
||||||
router.replace(`/admin/event/reject/status`);
|
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -42,8 +102,8 @@ export default function AdminEventRejectInput() {
|
|||||||
headerComponent={<AdminBackButtonAntTitle title="Penolakan Event" />}
|
headerComponent={<AdminBackButtonAntTitle title="Penolakan Event" />}
|
||||||
>
|
>
|
||||||
<TextAreaCustom
|
<TextAreaCustom
|
||||||
value={value}
|
value={data}
|
||||||
onChangeText={setValue}
|
onChangeText={setData}
|
||||||
placeholder="Masukan alasan"
|
placeholder="Masukan alasan"
|
||||||
required
|
required
|
||||||
showCount
|
showCount
|
||||||
|
|||||||
@@ -1,27 +1,67 @@
|
|||||||
|
/* eslint-disable react-hooks/exhaustive-deps */
|
||||||
import {
|
import {
|
||||||
ActionIcon,
|
ActionIcon,
|
||||||
BaseBox,
|
LoaderCustom,
|
||||||
SearchInput,
|
SearchInput,
|
||||||
Spacing,
|
StackCustom,
|
||||||
TextCustom,
|
TextCustom,
|
||||||
ViewWrapper,
|
ViewWrapper
|
||||||
} from "@/components";
|
} from "@/components";
|
||||||
import AdminComp_BoxTitle from "@/components/_ShareComponent/Admin/BoxTitlePage";
|
import AdminComp_BoxTitle from "@/components/_ShareComponent/Admin/BoxTitlePage";
|
||||||
import AdminTitleTable from "@/components/_ShareComponent/Admin/TableTitle";
|
import AdminTitleTable from "@/components/_ShareComponent/Admin/TableTitle";
|
||||||
import AdminTableValue from "@/components/_ShareComponent/Admin/TableValue";
|
import AdminTableValue from "@/components/_ShareComponent/Admin/TableValue";
|
||||||
import AdminTitlePage from "@/components/_ShareComponent/Admin/TitlePage";
|
import AdminTitlePage from "@/components/_ShareComponent/Admin/TitlePage";
|
||||||
import { ICON_SIZE_BUTTON } from "@/constants/constans-value";
|
import { ICON_SIZE_BUTTON } from "@/constants/constans-value";
|
||||||
|
import { apiAdminEvent } from "@/service/api-admin/api-admin-event";
|
||||||
import { Octicons } from "@expo/vector-icons";
|
import { Octicons } from "@expo/vector-icons";
|
||||||
import { router, useLocalSearchParams } from "expo-router";
|
import { router, useFocusEffect, useLocalSearchParams } from "expo-router";
|
||||||
import _ from "lodash";
|
import _ from "lodash";
|
||||||
|
import { useCallback, useState } from "react";
|
||||||
import { Divider } from "react-native-paper";
|
import { Divider } from "react-native-paper";
|
||||||
|
|
||||||
export default function AdminEventStatus() {
|
export default function AdminEventStatus() {
|
||||||
const { status } = useLocalSearchParams();
|
const { status } = useLocalSearchParams();
|
||||||
|
console.log("[STATUS EVENT]", status);
|
||||||
|
|
||||||
|
const [listData, setListData] = useState<any[] | null>(null);
|
||||||
|
const [loadData, setLoadData] = useState(false);
|
||||||
|
const [search, setSearch] = useState<string>("");
|
||||||
|
|
||||||
|
useFocusEffect(
|
||||||
|
useCallback(() => {
|
||||||
|
onLoadData();
|
||||||
|
}, [status, search])
|
||||||
|
);
|
||||||
|
|
||||||
|
const onLoadData = async () => {
|
||||||
|
try {
|
||||||
|
setLoadData(true);
|
||||||
|
const response = await apiAdminEvent({
|
||||||
|
category: status as "publish" | "review" | "reject" | "history" as any,
|
||||||
|
search,
|
||||||
|
});
|
||||||
|
|
||||||
|
console.log(
|
||||||
|
`[RES LIST BY STATUS: ${status}]`,
|
||||||
|
JSON.stringify(response, null, 2)
|
||||||
|
);
|
||||||
|
|
||||||
|
if (response.success) {
|
||||||
|
setListData(response.data);
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.log("[ERROR]", error);
|
||||||
|
} finally {
|
||||||
|
setLoadData(false);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
const rightComponent = (
|
const rightComponent = (
|
||||||
<SearchInput
|
<SearchInput
|
||||||
containerStyle={{ width: "100%", marginBottom: 0 }}
|
containerStyle={{ width: "100%", marginBottom: 0 }}
|
||||||
placeholder="Cari"
|
placeholder="Cari"
|
||||||
|
value={search}
|
||||||
|
onChangeText={(value) => setSearch(value)}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
return (
|
return (
|
||||||
@@ -32,44 +72,50 @@ export default function AdminEventStatus() {
|
|||||||
rightComponent={rightComponent}
|
rightComponent={rightComponent}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<BaseBox>
|
<StackCustom gap={"sm"}>
|
||||||
<AdminTitleTable
|
<AdminTitleTable
|
||||||
title1="Aksi"
|
title1="Aksi"
|
||||||
title2="Username"
|
title2="Username"
|
||||||
title3="Judul Event"
|
title3="Judul Event"
|
||||||
/>
|
/>
|
||||||
<Spacing />
|
|
||||||
<Divider />
|
<Divider />
|
||||||
|
|
||||||
{Array.from({ length: 10 }).map((_, index) => (
|
{loadData ? (
|
||||||
<AdminTableValue
|
<LoaderCustom />
|
||||||
key={index}
|
) : _.isEmpty(listData) ? (
|
||||||
value1={
|
<TextCustom align="center" size="small" color="gray">Belum ada data</TextCustom>
|
||||||
<ActionIcon
|
) : (
|
||||||
icon={
|
listData?.map((item, index) => (
|
||||||
<Octicons
|
<AdminTableValue
|
||||||
name="eye"
|
key={index}
|
||||||
size={ICON_SIZE_BUTTON}
|
value1={
|
||||||
color="black"
|
<ActionIcon
|
||||||
/>
|
icon={
|
||||||
}
|
<Octicons
|
||||||
onPress={() => {
|
name="eye"
|
||||||
router.push(`/admin/event/${index}/${status}`);
|
size={ICON_SIZE_BUTTON}
|
||||||
}}
|
color="black"
|
||||||
/>
|
/>
|
||||||
}
|
}
|
||||||
value2={<TextCustom truncate={1}>Username username</TextCustom>}
|
onPress={() => {
|
||||||
value3={
|
router.push(`/admin/event/${item.id}/${status}`);
|
||||||
<TextCustom truncate={2}>
|
}}
|
||||||
Lorem ipsum dolor sit amet consectetur adipisicing elit.
|
/>
|
||||||
Blanditiis asperiores quidem deleniti architecto eaque et
|
}
|
||||||
nostrum, ad consequuntur eveniet quisquam quae voluptatum
|
value2={
|
||||||
ducimus! Dolorem nobis modi officia debitis, beatae mollitia.
|
<TextCustom truncate={1}>
|
||||||
</TextCustom>
|
{item?.Author?.username || "-"}
|
||||||
}
|
</TextCustom>
|
||||||
/>
|
}
|
||||||
))}
|
value3={
|
||||||
</BaseBox>
|
<TextCustom align="center" truncate={2}>
|
||||||
|
{item?.title || "-"}
|
||||||
|
</TextCustom>
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
))
|
||||||
|
)}
|
||||||
|
</StackCustom>
|
||||||
</ViewWrapper>
|
</ViewWrapper>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -9,13 +9,67 @@ import {
|
|||||||
import AdminComp_BoxDashboard from "@/components/_ShareComponent/Admin/BoxDashboard";
|
import AdminComp_BoxDashboard from "@/components/_ShareComponent/Admin/BoxDashboard";
|
||||||
import AdminTitlePage from "@/components/_ShareComponent/Admin/TitlePage";
|
import AdminTitlePage from "@/components/_ShareComponent/Admin/TitlePage";
|
||||||
import { MainColor } from "@/constants/color-palet";
|
import { MainColor } from "@/constants/color-palet";
|
||||||
|
import { apiAdminEvent } from "@/service/api-admin/api-admin-event";
|
||||||
|
import { useFocusEffect } from "expo-router";
|
||||||
|
import { useCallback, useState } from "react";
|
||||||
|
|
||||||
export default function AdminVoting() {
|
export default function AdminVoting() {
|
||||||
|
const [data, setData] = useState<any | null>(null);
|
||||||
|
|
||||||
|
useFocusEffect(
|
||||||
|
useCallback(() => {
|
||||||
|
onLoadData();
|
||||||
|
}, [])
|
||||||
|
);
|
||||||
|
|
||||||
|
const onLoadData = async () => {
|
||||||
|
try {
|
||||||
|
const response = await apiAdminEvent({
|
||||||
|
category: "dashboard",
|
||||||
|
});
|
||||||
|
|
||||||
|
if (response.success) {
|
||||||
|
setData(response.data);
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.log("[ERROR]", error);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const listData = [
|
||||||
|
{
|
||||||
|
label: "Publish",
|
||||||
|
value: (data && data.publish) || 0,
|
||||||
|
icon: <IconPublish size={25} color={MainColor.green} />,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: "Review",
|
||||||
|
value: (data && data.review) || 0,
|
||||||
|
icon: <IconReview size={25} color={MainColor.orange} />,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: "Reject",
|
||||||
|
value: (data && data.reject) || 0,
|
||||||
|
icon: <IconReject size={25} color={MainColor.red} />,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: "Riwayat",
|
||||||
|
value: (data && data.history) || 0,
|
||||||
|
icon: <IconArchive size={25} color={MainColor.placeholder} />,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: "Tipe Acara",
|
||||||
|
value: (data && data.typeOfEvent) || 0,
|
||||||
|
icon: <IconList size={25} color={MainColor.placeholder} />,
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<ViewWrapper>
|
<ViewWrapper>
|
||||||
<AdminTitlePage title="Event" />
|
<AdminTitlePage title="Event" />
|
||||||
<Spacing />
|
<Spacing />
|
||||||
|
|
||||||
<StackCustom gap={"xs"}>
|
<StackCustom gap={"xs"}>
|
||||||
{listData.map((item, i) => (
|
{listData.map((item, i) => (
|
||||||
<AdminComp_BoxDashboard key={i} item={item} />
|
<AdminComp_BoxDashboard key={i} item={item} />
|
||||||
@@ -25,31 +79,3 @@ export default function AdminVoting() {
|
|||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const listData = [
|
|
||||||
{
|
|
||||||
label: "Publish",
|
|
||||||
value: 3,
|
|
||||||
icon: <IconPublish size={25} color={MainColor.green} />,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: "Review",
|
|
||||||
value: 8,
|
|
||||||
icon: <IconReview size={25} color={MainColor.orange} />,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: "Reject",
|
|
||||||
value: 4,
|
|
||||||
icon: <IconReject size={25} color={MainColor.red} />,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: "Riwayat",
|
|
||||||
value: 6,
|
|
||||||
icon: <IconArchive size={25} color={MainColor.placeholder} />,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: "Tipe Acara",
|
|
||||||
value: 7,
|
|
||||||
icon: <IconList size={25} color={MainColor.placeholder} />,
|
|
||||||
},
|
|
||||||
];
|
|
||||||
|
|||||||
@@ -5,13 +5,48 @@ import {
|
|||||||
ViewWrapper,
|
ViewWrapper,
|
||||||
} from "@/components";
|
} from "@/components";
|
||||||
import AdminBackButtonAntTitle from "@/components/_ShareComponent/Admin/BackButtonAntTitle";
|
import AdminBackButtonAntTitle from "@/components/_ShareComponent/Admin/BackButtonAntTitle";
|
||||||
|
import { apiEventCreateTypeOfEvent } from "@/service/api-admin/api-master-admin";
|
||||||
import { useRouter } from "expo-router";
|
import { useRouter } from "expo-router";
|
||||||
|
import { useState } from "react";
|
||||||
|
import Toast from "react-native-toast-message";
|
||||||
|
|
||||||
export default function AdminEventTypeOfEventCreate() {
|
export default function AdminEventTypeOfEventCreate() {
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
|
const [value, setValue] = useState("");
|
||||||
|
const [isLoading, setLoading] = useState<boolean>(false);
|
||||||
|
|
||||||
|
const handlerSubmit = async () => {
|
||||||
|
try {
|
||||||
|
setLoading(true);
|
||||||
|
const response = await apiEventCreateTypeOfEvent({
|
||||||
|
data: value,
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
if (!response.success) {
|
||||||
|
Toast.show({
|
||||||
|
type: "error",
|
||||||
|
text1: "Gagal menambahkan tipe acara",
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Toast.show({
|
||||||
|
type: "success",
|
||||||
|
text1: "Berhasil menambahkan tipe acara",
|
||||||
|
});
|
||||||
|
router.back();
|
||||||
|
} catch (error) {
|
||||||
|
console.log("[ERROR CREATE TYPE EVENT]", error);
|
||||||
|
} finally {
|
||||||
|
setLoading(false);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
const buttonSubmit = (
|
const buttonSubmit = (
|
||||||
<BoxButtonOnFooter>
|
<BoxButtonOnFooter>
|
||||||
<ButtonCustom onPress={() => router.back()}>Simpan</ButtonCustom>
|
<ButtonCustom isLoading={isLoading} onPress={() => handlerSubmit()}>
|
||||||
|
Simpan
|
||||||
|
</ButtonCustom>
|
||||||
</BoxButtonOnFooter>
|
</BoxButtonOnFooter>
|
||||||
);
|
);
|
||||||
return (
|
return (
|
||||||
@@ -20,7 +55,11 @@ export default function AdminEventTypeOfEventCreate() {
|
|||||||
headerComponent={<AdminBackButtonAntTitle title="Tambah Tipe Acara" />}
|
headerComponent={<AdminBackButtonAntTitle title="Tambah Tipe Acara" />}
|
||||||
footerComponent={buttonSubmit}
|
footerComponent={buttonSubmit}
|
||||||
>
|
>
|
||||||
<TextInputCustom placeholder="Masukkan Tipe Acara" />
|
<TextInputCustom
|
||||||
|
placeholder="Masukkan Tipe Acara"
|
||||||
|
value={value}
|
||||||
|
onChangeText={setValue}
|
||||||
|
/>
|
||||||
</ViewWrapper>
|
</ViewWrapper>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,23 +1,53 @@
|
|||||||
import {
|
import {
|
||||||
ActionIcon,
|
ActionIcon,
|
||||||
BaseBox,
|
BadgeCustom,
|
||||||
CenterCustom,
|
CenterCustom,
|
||||||
|
LoaderCustom,
|
||||||
Spacing,
|
Spacing,
|
||||||
StackCustom,
|
StackCustom,
|
||||||
TextCustom,
|
TextCustom,
|
||||||
ViewWrapper,
|
ViewWrapper
|
||||||
} from "@/components";
|
} from "@/components";
|
||||||
import { IconEdit } from "@/components/_Icon";
|
import { IconEdit } from "@/components/_Icon";
|
||||||
import AdminActionIconPlus from "@/components/_ShareComponent/Admin/ActionIconPlus";
|
import AdminActionIconPlus from "@/components/_ShareComponent/Admin/ActionIconPlus";
|
||||||
import AdminComp_BoxTitle from "@/components/_ShareComponent/Admin/BoxTitlePage";
|
import AdminComp_BoxTitle from "@/components/_ShareComponent/Admin/BoxTitlePage";
|
||||||
import AdminTitlePage from "@/components/_ShareComponent/Admin/TitlePage";
|
import AdminTitlePage from "@/components/_ShareComponent/Admin/TitlePage";
|
||||||
import { GridDetail_4_8 } from "@/components/_ShareComponent/GridDetail_4_8";
|
import { GridViewCustomSpan } from "@/components/_ShareComponent/GridViewCustomSpan";
|
||||||
import { ICON_SIZE_BUTTON } from "@/constants/constans-value";
|
import { ICON_SIZE_BUTTON } from "@/constants/constans-value";
|
||||||
import { router } from "expo-router";
|
import { apiAdminMasterTypeOfEvent } from "@/service/api-admin/api-master-admin";
|
||||||
|
import { colorActivationForBadge } from "@/utils/colorActivationForBadge";
|
||||||
|
import { router, useFocusEffect } from "expo-router";
|
||||||
|
import _ from "lodash";
|
||||||
|
import { useCallback, useState } from "react";
|
||||||
import { View } from "react-native";
|
import { View } from "react-native";
|
||||||
import { Divider } from "react-native-paper";
|
import { Divider } from "react-native-paper";
|
||||||
|
|
||||||
export default function AdminEventTypeOfEvent() {
|
export default function AdminEventTypeOfEvent() {
|
||||||
|
const [listData, setListData] = useState<any[] | null>(null);
|
||||||
|
const [loadData, setLoadData] = useState<boolean>(false);
|
||||||
|
|
||||||
|
useFocusEffect(
|
||||||
|
useCallback(() => {
|
||||||
|
onLoadData();
|
||||||
|
}, [])
|
||||||
|
);
|
||||||
|
|
||||||
|
const onLoadData = async () => {
|
||||||
|
try {
|
||||||
|
setLoadData(true);
|
||||||
|
const response = await apiAdminMasterTypeOfEvent();
|
||||||
|
|
||||||
|
if (response.success) {
|
||||||
|
setListData(response.data);
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.log("[ERROR]",error);
|
||||||
|
setListData([]);
|
||||||
|
} finally {
|
||||||
|
setLoadData(false);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<ViewWrapper headerComponent={<AdminTitlePage title="Event" />}>
|
<ViewWrapper headerComponent={<AdminTitlePage title="Event" />}>
|
||||||
@@ -32,73 +62,68 @@ export default function AdminEventTypeOfEvent() {
|
|||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<BaseBox>
|
<>
|
||||||
<GridDetail_4_8
|
<GridViewCustomSpan
|
||||||
label={
|
span1={2}
|
||||||
|
span2={5}
|
||||||
|
span3={5}
|
||||||
|
component1={
|
||||||
<TextCustom bold align="center">
|
<TextCustom bold align="center">
|
||||||
Aksi
|
Aksi
|
||||||
</TextCustom>
|
</TextCustom>
|
||||||
}
|
}
|
||||||
value={<TextCustom bold>Tipe Acara</TextCustom>}
|
component2={<TextCustom bold align="center">Status</TextCustom>}
|
||||||
|
component3={<TextCustom bold>Tipe Acara</TextCustom>}
|
||||||
/>
|
/>
|
||||||
<Divider />
|
<Divider />
|
||||||
<Spacing />
|
<Spacing />
|
||||||
|
|
||||||
<StackCustom>
|
<StackCustom>
|
||||||
{listData.map((item, index) => (
|
{loadData ? (
|
||||||
<View key={index}>
|
<LoaderCustom />
|
||||||
<GridDetail_4_8
|
) : _.isEmpty(listData) ? (
|
||||||
label={
|
<TextCustom align="center" color="gray">
|
||||||
<CenterCustom>
|
Belum ada data
|
||||||
<ActionIcon
|
</TextCustom>
|
||||||
icon={
|
) : (
|
||||||
<IconEdit size={ICON_SIZE_BUTTON} color="black" />
|
listData?.map((item, index) => (
|
||||||
}
|
<View key={index}>
|
||||||
onPress={() => {
|
<GridViewCustomSpan
|
||||||
router.push(`/admin/event/type-update?id=${index}`);
|
span1={2}
|
||||||
}}
|
span2={5}
|
||||||
/>
|
span3={5}
|
||||||
</CenterCustom>
|
component1={
|
||||||
}
|
<CenterCustom>
|
||||||
value={<TextCustom bold>{item.label}</TextCustom>}
|
<ActionIcon
|
||||||
/>
|
icon={
|
||||||
<Divider />
|
<IconEdit size={ICON_SIZE_BUTTON} color="black" />
|
||||||
</View>
|
}
|
||||||
))}
|
onPress={() => {
|
||||||
|
router.push(`/admin/event/type-update?id=${item.id}`);
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</CenterCustom>
|
||||||
|
}
|
||||||
|
style2={{ alignItems: "center" }}
|
||||||
|
component2={
|
||||||
|
<CenterCustom>
|
||||||
|
<BadgeCustom
|
||||||
|
color={colorActivationForBadge({
|
||||||
|
status: item?.active,
|
||||||
|
})}
|
||||||
|
>
|
||||||
|
{item?.active ? "Aktif" : "Tidak Aktif"}
|
||||||
|
</BadgeCustom>
|
||||||
|
</CenterCustom>
|
||||||
|
}
|
||||||
|
component3={<TextCustom >{item.name}</TextCustom>}
|
||||||
|
/>
|
||||||
|
</View>
|
||||||
|
))
|
||||||
|
)}
|
||||||
</StackCustom>
|
</StackCustom>
|
||||||
</BaseBox>
|
</>
|
||||||
</ViewWrapper>
|
</ViewWrapper>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const listData = [
|
|
||||||
{
|
|
||||||
label: "Seminar",
|
|
||||||
value: "seminar",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: "Workshop",
|
|
||||||
value: "workshop",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: "Konferensi",
|
|
||||||
value: "konferensi",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: "Lomba",
|
|
||||||
value: "lomba",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: "Pameran",
|
|
||||||
value: "pameran",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: "Pesta",
|
|
||||||
value: "pesta",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: "Pertandingan",
|
|
||||||
value: "pertandingan",
|
|
||||||
},
|
|
||||||
];
|
|
||||||
|
|||||||
@@ -1,20 +1,91 @@
|
|||||||
|
/* eslint-disable react-hooks/exhaustive-deps */
|
||||||
import {
|
import {
|
||||||
BoxButtonOnFooter,
|
BoxButtonOnFooter,
|
||||||
ButtonCustom,
|
ButtonCustom,
|
||||||
|
Spacing,
|
||||||
|
TextCustom,
|
||||||
TextInputCustom,
|
TextInputCustom,
|
||||||
ViewWrapper,
|
ViewWrapper,
|
||||||
} from "@/components";
|
} from "@/components";
|
||||||
import AdminBackButtonAntTitle from "@/components/_ShareComponent/Admin/BackButtonAntTitle";
|
import AdminBackButtonAntTitle from "@/components/_ShareComponent/Admin/BackButtonAntTitle";
|
||||||
import { useLocalSearchParams, useRouter } from "expo-router";
|
import { MainColor } from "@/constants/color-palet";
|
||||||
|
import {
|
||||||
|
apiAdminMasterTypeOfEventGetOne,
|
||||||
|
apiAdminMasterTypeOfEventUpdate,
|
||||||
|
} from "@/service/api-admin/api-master-admin";
|
||||||
|
|
||||||
|
import { useFocusEffect, useLocalSearchParams, useRouter } from "expo-router";
|
||||||
|
import { useCallback, useState } from "react";
|
||||||
|
import { Switch } from "react-native-paper";
|
||||||
|
import Toast from "react-native-toast-message";
|
||||||
|
|
||||||
export default function AdminEventTypeOfEventUpdate() {
|
export default function AdminEventTypeOfEventUpdate() {
|
||||||
const { id } = useLocalSearchParams();
|
const { id } = useLocalSearchParams();
|
||||||
console.log("id >", id);
|
|
||||||
|
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
|
|
||||||
|
const [data, setData] = useState<{ name: string; active: boolean }>({
|
||||||
|
name: "",
|
||||||
|
active: false,
|
||||||
|
});
|
||||||
|
const [isLoading, setLoading] = useState<boolean>(false);
|
||||||
|
|
||||||
|
useFocusEffect(
|
||||||
|
useCallback(() => {
|
||||||
|
onLoadData();
|
||||||
|
}, [id])
|
||||||
|
);
|
||||||
|
|
||||||
|
const onLoadData = async () => {
|
||||||
|
try {
|
||||||
|
const response = await apiAdminMasterTypeOfEventGetOne({
|
||||||
|
id: id as string,
|
||||||
|
});
|
||||||
|
|
||||||
|
if (response.success) {
|
||||||
|
setData({
|
||||||
|
name: response.data.name,
|
||||||
|
active: response.data.active,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.log("[ERROR UPDATE]", error);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const handlerSubmit = async () => {
|
||||||
|
try {
|
||||||
|
setLoading(true);
|
||||||
|
|
||||||
|
const response = await apiAdminMasterTypeOfEventUpdate({
|
||||||
|
id: id as string,
|
||||||
|
data: data,
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!response.success) {
|
||||||
|
Toast.show({
|
||||||
|
type: "error",
|
||||||
|
text1: "Gagal mengupdate tipe acara",
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Toast.show({
|
||||||
|
type: "success",
|
||||||
|
text1: "Berhasil mengupdate tipe acara",
|
||||||
|
});
|
||||||
|
router.back();
|
||||||
|
} catch (error) {
|
||||||
|
console.log("[ERROR UPDATE]", error);
|
||||||
|
} finally {
|
||||||
|
setLoading(false);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
const buttonSubmit = (
|
const buttonSubmit = (
|
||||||
<BoxButtonOnFooter>
|
<BoxButtonOnFooter>
|
||||||
<ButtonCustom onPress={() => router.back()}>Update</ButtonCustom>
|
<ButtonCustom isLoading={isLoading} onPress={() => handlerSubmit()}>
|
||||||
|
Update
|
||||||
|
</ButtonCustom>
|
||||||
</BoxButtonOnFooter>
|
</BoxButtonOnFooter>
|
||||||
);
|
);
|
||||||
return (
|
return (
|
||||||
@@ -23,7 +94,19 @@ export default function AdminEventTypeOfEventUpdate() {
|
|||||||
headerComponent={<AdminBackButtonAntTitle title="Ubah Tipe Acara" />}
|
headerComponent={<AdminBackButtonAntTitle title="Ubah Tipe Acara" />}
|
||||||
footerComponent={buttonSubmit}
|
footerComponent={buttonSubmit}
|
||||||
>
|
>
|
||||||
<TextInputCustom placeholder="Masukkan Tipe Acara" value="" />
|
<TextInputCustom
|
||||||
|
placeholder="Masukkan Tipe Acara"
|
||||||
|
value={data.name}
|
||||||
|
onChangeText={(text) => setData({ ...data, name: text })}
|
||||||
|
/>
|
||||||
|
|
||||||
|
<TextCustom>Aktivasi</TextCustom>
|
||||||
|
<Spacing height={10} />
|
||||||
|
<Switch
|
||||||
|
color={MainColor.yellow}
|
||||||
|
value={data.active}
|
||||||
|
onValueChange={(value) => setData({ ...data, active: value })}
|
||||||
|
/>
|
||||||
</ViewWrapper>
|
</ViewWrapper>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -22,11 +22,7 @@ import { useCallback, useState } from "react";
|
|||||||
export default function AdminForumDetailPosting() {
|
export default function AdminForumDetailPosting() {
|
||||||
const { id } = useLocalSearchParams();
|
const { id } = useLocalSearchParams();
|
||||||
const [openDrawerPage, setOpenDrawerPage] = useState(false);
|
const [openDrawerPage, setOpenDrawerPage] = useState(false);
|
||||||
const [selectedId, setSelectedId] = useState<any>();
|
|
||||||
|
|
||||||
const [data, setData] = useState<any | null>(null);
|
const [data, setData] = useState<any | null>(null);
|
||||||
const [listComment, setListComment] = useState<any[] | null>(null);
|
|
||||||
|
|
||||||
useFocusEffect(
|
useFocusEffect(
|
||||||
useCallback(() => {
|
useCallback(() => {
|
||||||
onLoadData();
|
onLoadData();
|
||||||
@@ -38,7 +34,6 @@ export default function AdminForumDetailPosting() {
|
|||||||
const response = await apiAdminForumPostingById({
|
const response = await apiAdminForumPostingById({
|
||||||
id: id as string,
|
id: id as string,
|
||||||
});
|
});
|
||||||
console.log("[RES DATA]", JSON.stringify(response, null, 2));
|
|
||||||
|
|
||||||
if (response.success) {
|
if (response.success) {
|
||||||
setData(response.data);
|
setData(response.data);
|
||||||
@@ -86,14 +81,25 @@ export default function AdminForumDetailPosting() {
|
|||||||
<AdminBackButtonAntTitle
|
<AdminBackButtonAntTitle
|
||||||
title="Detail Posting"
|
title="Detail Posting"
|
||||||
rightComponent={
|
rightComponent={
|
||||||
<ActionIcon
|
data &&
|
||||||
icon={<IconDot size={16} color={MainColor.darkblue} />}
|
data?.isActive && (
|
||||||
onPress={() => setOpenDrawerPage(true)}
|
<ActionIcon
|
||||||
/>
|
icon={<IconDot size={16} color={MainColor.darkblue} />}
|
||||||
|
onPress={() => setOpenDrawerPage(true)}
|
||||||
|
/>
|
||||||
|
)
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
|
{data && !data?.isActive && (
|
||||||
|
<BaseBox>
|
||||||
|
<TextCustom bold align="center" color="red">
|
||||||
|
Postingan ini telah di nonaktifkan
|
||||||
|
</TextCustom>
|
||||||
|
</BaseBox>
|
||||||
|
)}
|
||||||
|
|
||||||
<BaseBox>
|
<BaseBox>
|
||||||
<StackCustom gap={"sm"}>
|
<StackCustom gap={"sm"}>
|
||||||
{listDataAction.map((item, i) => (
|
{listDataAction.map((item, i) => (
|
||||||
@@ -112,47 +118,6 @@ export default function AdminForumDetailPosting() {
|
|||||||
<TextCustom>{(data && data?.diskusi) || "-"}</TextCustom>
|
<TextCustom>{(data && data?.diskusi) || "-"}</TextCustom>
|
||||||
</StackCustom>
|
</StackCustom>
|
||||||
</BaseBox>
|
</BaseBox>
|
||||||
|
|
||||||
{/* <AdminComp_BoxTitle title="Komentar" rightComponent={rightComponent} /> */}
|
|
||||||
{/* <StackCustom>
|
|
||||||
<AdminTitleTable title1="Aksi" title2="Username" title3="Komentar" />
|
|
||||||
<Divider />
|
|
||||||
{!listComment ? (
|
|
||||||
<LoaderCustom />
|
|
||||||
) : _.isEmpty(listComment) ? (
|
|
||||||
<TextCustom align="center" color="gray">
|
|
||||||
Tidak ada komentar
|
|
||||||
</TextCustom>
|
|
||||||
) : (
|
|
||||||
listComment?.map((item: any, index: number) => (
|
|
||||||
<AdminTableValue
|
|
||||||
key={index}
|
|
||||||
value1={
|
|
||||||
<ActionIcon
|
|
||||||
icon={
|
|
||||||
<Ionicons
|
|
||||||
name="ellipsis-vertical-outline"
|
|
||||||
size={ICON_SIZE_BUTTON}
|
|
||||||
color="black"
|
|
||||||
/>
|
|
||||||
}
|
|
||||||
onPress={() => {
|
|
||||||
setSelectedId(index + 1);
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
}
|
|
||||||
value2={
|
|
||||||
<TextCustom truncate={1}>
|
|
||||||
{item?.Author?.username || "-"}
|
|
||||||
</TextCustom>
|
|
||||||
}
|
|
||||||
value3={
|
|
||||||
<TextCustom truncate={2}>{item?.komentar || "-"}</TextCustom>
|
|
||||||
}
|
|
||||||
/>
|
|
||||||
))
|
|
||||||
)}
|
|
||||||
</StackCustom> */}
|
|
||||||
</ViewWrapper>
|
</ViewWrapper>
|
||||||
|
|
||||||
<DrawerCustom
|
<DrawerCustom
|
||||||
|
|||||||
@@ -1,41 +1,24 @@
|
|||||||
/* eslint-disable react-hooks/exhaustive-deps */
|
/* eslint-disable react-hooks/exhaustive-deps */
|
||||||
import {
|
import {
|
||||||
ActionIcon,
|
LoaderCustom,
|
||||||
AlertDefaultSystem,
|
StackCustom,
|
||||||
DrawerCustom,
|
TextCustom,
|
||||||
LoaderCustom,
|
ViewWrapper
|
||||||
MenuDrawerDynamicGrid,
|
|
||||||
StackCustom,
|
|
||||||
TextCustom,
|
|
||||||
ViewWrapper,
|
|
||||||
} from "@/components";
|
} from "@/components";
|
||||||
import { IconView } from "@/components/_Icon/IconComponent";
|
|
||||||
import { IconOpenTo } from "@/components/_Icon/IconOpenTo";
|
import { IconOpenTo } from "@/components/_Icon/IconOpenTo";
|
||||||
import { IconTrash } from "@/components/_Icon/IconTrash";
|
|
||||||
import AdminBackButtonAntTitle from "@/components/_ShareComponent/Admin/BackButtonAntTitle";
|
import AdminBackButtonAntTitle from "@/components/_ShareComponent/Admin/BackButtonAntTitle";
|
||||||
import AdminTitleTable from "@/components/_ShareComponent/Admin/TableTitle";
|
import AdminTitleTable from "@/components/_ShareComponent/Admin/TableTitle";
|
||||||
import AdminTableValue from "@/components/_ShareComponent/Admin/TableValue";
|
import AdminTableValue from "@/components/_ShareComponent/Admin/TableValue";
|
||||||
import { MainColor } from "@/constants/color-palet";
|
|
||||||
import {
|
|
||||||
ICON_SIZE_BUTTON,
|
|
||||||
ICON_SIZE_MEDIUM,
|
|
||||||
ICON_SIZE_XLARGE,
|
|
||||||
} from "@/constants/constans-value";
|
|
||||||
import { apiAdminForumCommentById } from "@/service/api-admin/api-admin-forum";
|
import { apiAdminForumCommentById } from "@/service/api-admin/api-admin-forum";
|
||||||
import { Ionicons } from "@expo/vector-icons";
|
|
||||||
import { router, useFocusEffect, useLocalSearchParams } from "expo-router";
|
import { router, useFocusEffect, useLocalSearchParams } from "expo-router";
|
||||||
import _ from "lodash";
|
import _ from "lodash";
|
||||||
import { useCallback, useState } from "react";
|
import { useCallback, useState } from "react";
|
||||||
import { Divider } from "react-native-paper";
|
import { Divider } from "react-native-paper";
|
||||||
import Toast from "react-native-toast-message";
|
|
||||||
|
|
||||||
export default function AdminForumListComment() {
|
export default function AdminForumListComment() {
|
||||||
const { id } = useLocalSearchParams();
|
const { id } = useLocalSearchParams();
|
||||||
const [openDrawerAction, setOpenDrawerAction] = useState(false);
|
|
||||||
|
|
||||||
console.log("[ID]", id);
|
|
||||||
|
|
||||||
const [listComment, setListComment] = useState<any[] | null>(null);
|
const [listComment, setListComment] = useState<any[] | null>(null);
|
||||||
|
const [loadList, setLoadList] = useState(false);
|
||||||
|
|
||||||
useFocusEffect(
|
useFocusEffect(
|
||||||
useCallback(() => {
|
useCallback(() => {
|
||||||
@@ -45,49 +28,32 @@ export default function AdminForumListComment() {
|
|||||||
|
|
||||||
const onLoadComment = async () => {
|
const onLoadComment = async () => {
|
||||||
try {
|
try {
|
||||||
|
setLoadList(true);
|
||||||
const response = await apiAdminForumCommentById({
|
const response = await apiAdminForumCommentById({
|
||||||
id: id as string,
|
id: id as string,
|
||||||
category: "get-all",
|
category: "get-all",
|
||||||
});
|
});
|
||||||
|
|
||||||
console.log("[RES COMMENT]", JSON.stringify(response, null, 2));
|
|
||||||
if (response.success) {
|
if (response.success) {
|
||||||
setListComment(response.data);
|
setListComment(response.data);
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log("[ERROR]", error);
|
console.log("[ERROR]", error);
|
||||||
setListComment([]);
|
setListComment([]);
|
||||||
|
} finally {
|
||||||
|
setLoadList(false);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const handlerAction = (item: { value: string; path: string }) => {
|
|
||||||
if (item.value === "delete") {
|
|
||||||
AlertDefaultSystem({
|
|
||||||
title: "Hapus Posting",
|
|
||||||
message: "Apakah Anda yakin ingin menghapus posting ini?",
|
|
||||||
textLeft: "Batal",
|
|
||||||
textRight: "Hapus",
|
|
||||||
onPressRight: () => {
|
|
||||||
Toast.show({
|
|
||||||
type: "success",
|
|
||||||
text1: "Posting berhasil dihapus",
|
|
||||||
});
|
|
||||||
},
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
router.navigate(item.path as any);
|
|
||||||
}
|
|
||||||
setOpenDrawerAction(false);
|
|
||||||
};
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<ViewWrapper
|
<ViewWrapper
|
||||||
headerComponent={<AdminBackButtonAntTitle title="Daftar Komentar" />}
|
headerComponent={<AdminBackButtonAntTitle title="Daftar Komentar" />}
|
||||||
>
|
>
|
||||||
<StackCustom>
|
<StackCustom>
|
||||||
<AdminTitleTable title1="Aksi" title2="Username" title3="Komentar" />
|
<AdminTitleTable title1="Aksi" title2="Report" title3="Komentar" />
|
||||||
<Divider />
|
<Divider />
|
||||||
{!listComment ? (
|
{loadList ? (
|
||||||
<LoaderCustom />
|
<LoaderCustom />
|
||||||
) : _.isEmpty(listComment) ? (
|
) : _.isEmpty(listComment) ? (
|
||||||
<TextCustom align="center" color="gray">
|
<TextCustom align="center" color="gray">
|
||||||
@@ -108,7 +74,7 @@ export default function AdminForumListComment() {
|
|||||||
}
|
}
|
||||||
value2={
|
value2={
|
||||||
<TextCustom truncate={1}>
|
<TextCustom truncate={1}>
|
||||||
{item?.Author?.username || "-"}
|
{item?.countReport || 0}
|
||||||
</TextCustom>
|
</TextCustom>
|
||||||
}
|
}
|
||||||
value3={
|
value3={
|
||||||
@@ -120,34 +86,6 @@ export default function AdminForumListComment() {
|
|||||||
</StackCustom>
|
</StackCustom>
|
||||||
</ViewWrapper>
|
</ViewWrapper>
|
||||||
|
|
||||||
<DrawerCustom
|
|
||||||
isVisible={openDrawerAction}
|
|
||||||
closeDrawer={() => setOpenDrawerAction(false)}
|
|
||||||
height={"auto"}
|
|
||||||
>
|
|
||||||
<MenuDrawerDynamicGrid
|
|
||||||
data={[
|
|
||||||
{
|
|
||||||
icon: <IconView />,
|
|
||||||
label: "Detail Komentar",
|
|
||||||
value: "detail",
|
|
||||||
path: `admin/forum/${id}/list-report-comment`,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
icon: (
|
|
||||||
<IconTrash size={ICON_SIZE_MEDIUM} color={MainColor.white} />
|
|
||||||
),
|
|
||||||
label: "Hapus Komentar",
|
|
||||||
value: "delete",
|
|
||||||
path: "",
|
|
||||||
color: MainColor.red,
|
|
||||||
},
|
|
||||||
]}
|
|
||||||
onPressItem={(item) => {
|
|
||||||
handlerAction(item as any);
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
</DrawerCustom>
|
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,8 +4,8 @@ import {
|
|||||||
AlertDefaultSystem,
|
AlertDefaultSystem,
|
||||||
BaseBox,
|
BaseBox,
|
||||||
DrawerCustom,
|
DrawerCustom,
|
||||||
|
LoaderCustom,
|
||||||
MenuDrawerDynamicGrid,
|
MenuDrawerDynamicGrid,
|
||||||
Spacing,
|
|
||||||
StackCustom,
|
StackCustom,
|
||||||
TextCustom,
|
TextCustom,
|
||||||
ViewWrapper,
|
ViewWrapper,
|
||||||
@@ -19,18 +19,31 @@ import AdminTableValue from "@/components/_ShareComponent/Admin/TableValue";
|
|||||||
import { GridDetail_4_8 } from "@/components/_ShareComponent/GridDetail_4_8";
|
import { GridDetail_4_8 } from "@/components/_ShareComponent/GridDetail_4_8";
|
||||||
import { MainColor } from "@/constants/color-palet";
|
import { MainColor } from "@/constants/color-palet";
|
||||||
import { ICON_SIZE_BUTTON } from "@/constants/constans-value";
|
import { ICON_SIZE_BUTTON } from "@/constants/constans-value";
|
||||||
import { apiAdminForumCommentById } from "@/service/api-admin/api-admin-forum";
|
import {
|
||||||
|
apiAdminForumCommentById,
|
||||||
|
apiAdminForumDeactivateComment,
|
||||||
|
apiAdminForumListReportCommentById,
|
||||||
|
} from "@/service/api-admin/api-admin-forum";
|
||||||
import { router, useFocusEffect, useLocalSearchParams } from "expo-router";
|
import { router, useFocusEffect, useLocalSearchParams } from "expo-router";
|
||||||
|
import _ from "lodash";
|
||||||
import { useCallback, useState } from "react";
|
import { useCallback, useState } from "react";
|
||||||
import { Divider } from "react-native-paper";
|
import { Divider } from "react-native-paper";
|
||||||
import Toast from "react-native-toast-message";
|
import Toast from "react-native-toast-message";
|
||||||
|
|
||||||
export default function AdminForumReportComment() {
|
export default function AdminForumReportComment() {
|
||||||
const { id } = useLocalSearchParams();
|
const { id } = useLocalSearchParams();
|
||||||
console.log("[ID]", id);
|
|
||||||
const [data, setData] = useState<any | null>(null);
|
const [data, setData] = useState<any | null>(null);
|
||||||
|
const [listReport, setListReport] = useState<any[] | null>(null);
|
||||||
|
const [loadList, setLoadList] = useState(false);
|
||||||
const [openDrawer, setOpenDrawer] = useState(false);
|
const [openDrawer, setOpenDrawer] = useState(false);
|
||||||
const [openDrawerAction, setOpenDrawerAction] = useState(false);
|
const [openDrawerAction, setOpenDrawerAction] = useState(false);
|
||||||
|
const [selectedReport, setSelectedReport] = useState({
|
||||||
|
id: "",
|
||||||
|
username: "",
|
||||||
|
kategori: "",
|
||||||
|
keterangan: "",
|
||||||
|
deskripsi: "",
|
||||||
|
});
|
||||||
|
|
||||||
useFocusEffect(
|
useFocusEffect(
|
||||||
useCallback(() => {
|
useCallback(() => {
|
||||||
@@ -40,18 +53,28 @@ export default function AdminForumReportComment() {
|
|||||||
|
|
||||||
const onLoadData = async () => {
|
const onLoadData = async () => {
|
||||||
try {
|
try {
|
||||||
|
setLoadList(true);
|
||||||
const response = await apiAdminForumCommentById({
|
const response = await apiAdminForumCommentById({
|
||||||
id: id as string,
|
id: id as string,
|
||||||
category: "get-one",
|
category: "get-one",
|
||||||
});
|
});
|
||||||
|
|
||||||
console.log("[RES GET ONE COMMENT]", JSON.stringify(response, null, 2));
|
const responseReport = await apiAdminForumListReportCommentById({
|
||||||
|
id: id as string,
|
||||||
|
});
|
||||||
|
|
||||||
if (response.success) {
|
if (response.success) {
|
||||||
setData(response.data);
|
setData(response.data);
|
||||||
}
|
}
|
||||||
|
if (responseReport.success) {
|
||||||
|
setListReport(responseReport.data);
|
||||||
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log("[ERROR]", error);
|
console.log("[ERROR]", error);
|
||||||
setData(null);
|
setData(null);
|
||||||
|
setListReport([]);
|
||||||
|
} finally {
|
||||||
|
setLoadList(false);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -85,34 +108,52 @@ export default function AdminForumReportComment() {
|
|||||||
|
|
||||||
<AdminComp_BoxTitle title="Daftar Report Komentar" />
|
<AdminComp_BoxTitle title="Daftar Report Komentar" />
|
||||||
|
|
||||||
<BaseBox>
|
<StackCustom>
|
||||||
<AdminTitleTable
|
<AdminTitleTable
|
||||||
title1="Aksi"
|
title1="Aksi"
|
||||||
title2="Username"
|
title2="Pelapor"
|
||||||
title3="Kategori Report"
|
title3="Kategori Report"
|
||||||
/>
|
/>
|
||||||
<Spacing />
|
|
||||||
<Divider />
|
<Divider />
|
||||||
{Array.from({ length: 5 }).map((_, index) => (
|
{loadList ? (
|
||||||
<AdminTableValue
|
<LoaderCustom />
|
||||||
key={index}
|
) : _.isEmpty(listReport) ? (
|
||||||
value1={
|
<TextCustom align="center" color="gray">
|
||||||
<ActionIcon
|
Tidak ada report
|
||||||
icon={<IconView size={ICON_SIZE_BUTTON} color="black" />}
|
</TextCustom>
|
||||||
onPress={() => {
|
) : (
|
||||||
setOpenDrawerAction(true);
|
listReport?.map((item: any, index: number) => (
|
||||||
}}
|
<AdminTableValue
|
||||||
/>
|
key={index}
|
||||||
}
|
value1={
|
||||||
value2={<TextCustom truncate={1}>Username username</TextCustom>}
|
<ActionIcon
|
||||||
value3={
|
icon={<IconView size={ICON_SIZE_BUTTON} color="black" />}
|
||||||
<TextCustom truncate={2} align="center">
|
onPress={() => {
|
||||||
SPAM
|
setOpenDrawerAction(true);
|
||||||
</TextCustom>
|
setSelectedReport({
|
||||||
}
|
id: item.id,
|
||||||
/>
|
username: item.User?.username,
|
||||||
))}
|
kategori: item.ForumMaster_KategoriReport?.title,
|
||||||
</BaseBox>
|
keterangan: item.ForumMaster_KategoriReport?.deskripsi,
|
||||||
|
deskripsi: item.deskripsi,
|
||||||
|
});
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
}
|
||||||
|
value2={
|
||||||
|
<TextCustom truncate={1}>
|
||||||
|
{item?.User?.username || "-"}
|
||||||
|
</TextCustom>
|
||||||
|
}
|
||||||
|
value3={
|
||||||
|
<TextCustom truncate={2} align="center">
|
||||||
|
{item?.ForumMaster_KategoriReport?.title || "-"}
|
||||||
|
</TextCustom>
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
))
|
||||||
|
)}
|
||||||
|
</StackCustom>
|
||||||
</ViewWrapper>
|
</ViewWrapper>
|
||||||
|
|
||||||
<DrawerCustom
|
<DrawerCustom
|
||||||
@@ -136,7 +177,19 @@ export default function AdminForumReportComment() {
|
|||||||
message: "Apakah Anda yakin ingin menghapus komentar ini?",
|
message: "Apakah Anda yakin ingin menghapus komentar ini?",
|
||||||
textLeft: "Batal",
|
textLeft: "Batal",
|
||||||
textRight: "Hapus",
|
textRight: "Hapus",
|
||||||
onPressRight: () => {
|
onPressRight: async () => {
|
||||||
|
const deleteComment = await apiAdminForumDeactivateComment({
|
||||||
|
id: id as string,
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!deleteComment.success) {
|
||||||
|
Toast.show({
|
||||||
|
type: "error",
|
||||||
|
text1: "Komentar gagal dihapus",
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
setOpenDrawer(false);
|
setOpenDrawer(false);
|
||||||
Toast.show({
|
Toast.show({
|
||||||
type: "success",
|
type: "success",
|
||||||
@@ -154,37 +207,39 @@ export default function AdminForumReportComment() {
|
|||||||
closeDrawer={() => setOpenDrawerAction(false)}
|
closeDrawer={() => setOpenDrawerAction(false)}
|
||||||
height={"auto"}
|
height={"auto"}
|
||||||
>
|
>
|
||||||
{listDataAction.map((item, i) => (
|
<StackCustom>
|
||||||
<GridDetail_4_8
|
<GridDetail_4_8
|
||||||
key={i}
|
label={<TextCustom bold>Pelapor</TextCustom>}
|
||||||
label={<TextCustom bold>{item.label}</TextCustom>}
|
value={<TextCustom>{selectedReport?.username || "-"}</TextCustom>}
|
||||||
value={<TextCustom>{item.value}</TextCustom>}
|
|
||||||
/>
|
/>
|
||||||
))}
|
|
||||||
|
{selectedReport?.kategori && (
|
||||||
|
<>
|
||||||
|
<GridDetail_4_8
|
||||||
|
label={<TextCustom bold>Kategori Report</TextCustom>}
|
||||||
|
value={
|
||||||
|
<TextCustom>{selectedReport?.kategori || "-"}</TextCustom>
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
<GridDetail_4_8
|
||||||
|
label={<TextCustom bold>Keterangan</TextCustom>}
|
||||||
|
value={
|
||||||
|
<TextCustom>{selectedReport?.keterangan || "-"}</TextCustom>
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
|
||||||
|
{selectedReport?.deskripsi && (
|
||||||
|
<GridDetail_4_8
|
||||||
|
label={<TextCustom bold>Deskripsi</TextCustom>}
|
||||||
|
value={
|
||||||
|
<TextCustom>{selectedReport?.deskripsi || "-"}</TextCustom>
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
</StackCustom>
|
||||||
</DrawerCustom>
|
</DrawerCustom>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const listData = [
|
|
||||||
{
|
|
||||||
label: "Username",
|
|
||||||
value: "Username",
|
|
||||||
},
|
|
||||||
];
|
|
||||||
|
|
||||||
const listDataAction = [
|
|
||||||
{
|
|
||||||
label: "Username",
|
|
||||||
value: "Riyusa",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: "Kategori Report",
|
|
||||||
value: "SPAM",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: "Deskripsi",
|
|
||||||
value:
|
|
||||||
"Lorem ipsum dolor sit amet consectetur adipisicing elit. Blanditiis asperiores quidem deleniti architecto eaque et nostrum, ad consequuntur eveniet quisquam quae voluptatum ducimus! Dolorem nobis modi officia debitis, beatae mollitia.",
|
|
||||||
},
|
|
||||||
];
|
|
||||||
|
|||||||
@@ -1,11 +1,12 @@
|
|||||||
|
/* eslint-disable react-hooks/exhaustive-deps */
|
||||||
import {
|
import {
|
||||||
ActionIcon,
|
ActionIcon,
|
||||||
AlertDefaultSystem,
|
AlertDefaultSystem,
|
||||||
BadgeCustom,
|
BadgeCustom,
|
||||||
BaseBox,
|
BaseBox,
|
||||||
DrawerCustom,
|
DrawerCustom,
|
||||||
|
LoaderCustom,
|
||||||
MenuDrawerDynamicGrid,
|
MenuDrawerDynamicGrid,
|
||||||
Spacing,
|
|
||||||
StackCustom,
|
StackCustom,
|
||||||
TextCustom,
|
TextCustom,
|
||||||
ViewWrapper,
|
ViewWrapper,
|
||||||
@@ -19,15 +20,64 @@ import AdminTableValue from "@/components/_ShareComponent/Admin/TableValue";
|
|||||||
import { GridDetail_4_8 } from "@/components/_ShareComponent/GridDetail_4_8";
|
import { GridDetail_4_8 } from "@/components/_ShareComponent/GridDetail_4_8";
|
||||||
import { MainColor } from "@/constants/color-palet";
|
import { MainColor } from "@/constants/color-palet";
|
||||||
import { ICON_SIZE_BUTTON } from "@/constants/constans-value";
|
import { ICON_SIZE_BUTTON } from "@/constants/constans-value";
|
||||||
import { router } from "expo-router";
|
import {
|
||||||
import { useState } from "react";
|
apiAdminForumDeactivatePosting,
|
||||||
|
apiAdminForumListReportPostingById,
|
||||||
|
apiAdminForumPostingById,
|
||||||
|
} from "@/service/api-admin/api-admin-forum";
|
||||||
|
import { router, useFocusEffect, useLocalSearchParams } from "expo-router";
|
||||||
|
import _ from "lodash";
|
||||||
|
import { useCallback, useState } from "react";
|
||||||
import { Divider } from "react-native-paper";
|
import { Divider } from "react-native-paper";
|
||||||
import Toast from "react-native-toast-message";
|
import Toast from "react-native-toast-message";
|
||||||
|
|
||||||
export default function AdminForumReportPosting() {
|
export default function AdminForumReportPosting() {
|
||||||
|
const { id } = useLocalSearchParams();
|
||||||
const [openDrawerPage, setOpenDrawerPage] = useState(false);
|
const [openDrawerPage, setOpenDrawerPage] = useState(false);
|
||||||
const [openDrawerAction, setOpenDrawerAction] = useState(false);
|
const [openDrawerAction, setOpenDrawerAction] = useState(false);
|
||||||
|
|
||||||
|
const [data, setData] = useState<any | null>(null);
|
||||||
|
const [listReport, setListReport] = useState<any[] | null>(null);
|
||||||
|
const [loadListReport, setLoadListReport] = useState(false);
|
||||||
|
const [selectedReport, setSelectedReport] = useState({
|
||||||
|
id: "",
|
||||||
|
username: "",
|
||||||
|
kategori: "",
|
||||||
|
keterangan: "",
|
||||||
|
deskripsi: "",
|
||||||
|
});
|
||||||
|
|
||||||
|
useFocusEffect(
|
||||||
|
useCallback(() => {
|
||||||
|
onLoadData();
|
||||||
|
}, [id])
|
||||||
|
);
|
||||||
|
|
||||||
|
const onLoadData = async () => {
|
||||||
|
try {
|
||||||
|
setLoadListReport(true);
|
||||||
|
const response = await apiAdminForumPostingById({
|
||||||
|
id: id as string,
|
||||||
|
});
|
||||||
|
|
||||||
|
const responseReport = await apiAdminForumListReportPostingById({
|
||||||
|
id: id as string,
|
||||||
|
});
|
||||||
|
|
||||||
|
if (response.success) {
|
||||||
|
setData(response.data);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (responseReport.success) {
|
||||||
|
setListReport(responseReport.data);
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.log("[ERROR]", error);
|
||||||
|
} finally {
|
||||||
|
setLoadListReport(false);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<ViewWrapper
|
<ViewWrapper
|
||||||
@@ -45,50 +95,86 @@ export default function AdminForumReportPosting() {
|
|||||||
>
|
>
|
||||||
<BaseBox>
|
<BaseBox>
|
||||||
<StackCustom gap={"sm"}>
|
<StackCustom gap={"sm"}>
|
||||||
{listData.map((item, i) => (
|
<GridDetail_4_8
|
||||||
<GridDetail_4_8
|
label={<TextCustom bold>Username</TextCustom>}
|
||||||
key={i}
|
value={<TextCustom>{data?.Author?.username || "-"}</TextCustom>}
|
||||||
label={<TextCustom bold>{item.label}</TextCustom>}
|
/>
|
||||||
value={<TextCustom>{item.value}</TextCustom>}
|
|
||||||
/>
|
<GridDetail_4_8
|
||||||
))}
|
label={<TextCustom bold>Status</TextCustom>}
|
||||||
<TextCustom bold>Posting</TextCustom>
|
value={
|
||||||
<TextCustom>
|
data && data?.ForumMaster_StatusPosting?.status ? (
|
||||||
Lorem ipsum dolor sit amet consectetur adipisicing elit.
|
<BadgeCustom
|
||||||
Asperiores cupiditate nobis dignissimos explicabo quo unde dolorum
|
color={
|
||||||
numquam eos ab laborum fugiat illo nam velit quibusdam, maxime
|
data?.ForumMaster_StatusPosting?.status === "Open"
|
||||||
assumenda aut vero provident!
|
? MainColor.green
|
||||||
</TextCustom>
|
: MainColor.red
|
||||||
|
}
|
||||||
|
>
|
||||||
|
{data?.ForumMaster_StatusPosting?.status === "Open"
|
||||||
|
? "Open"
|
||||||
|
: "Close"}
|
||||||
|
</BadgeCustom>
|
||||||
|
) : (
|
||||||
|
<TextCustom>{"-"}</TextCustom>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
|
||||||
|
<GridDetail_4_8
|
||||||
|
label={<TextCustom bold>Postingan</TextCustom>}
|
||||||
|
value={<TextCustom>{data?.diskusi || "-"}</TextCustom>}
|
||||||
|
/>
|
||||||
</StackCustom>
|
</StackCustom>
|
||||||
</BaseBox>
|
</BaseBox>
|
||||||
|
|
||||||
<AdminComp_BoxTitle title="Daftar Report Posting" />
|
<AdminComp_BoxTitle title="Daftar Report Posting" />
|
||||||
<BaseBox>
|
<StackCustom gap={"sm"}>
|
||||||
<AdminTitleTable
|
<AdminTitleTable
|
||||||
title1="Aksi"
|
title1="Aksi"
|
||||||
title2="Username"
|
title2="Pelapor"
|
||||||
title3="Kategori Report"
|
title3="Kategori Report"
|
||||||
/>
|
/>
|
||||||
<Spacing />
|
|
||||||
<Divider />
|
<Divider />
|
||||||
{Array.from({ length: 5 }).map((_, index) => (
|
{loadListReport ? (
|
||||||
<AdminTableValue
|
<LoaderCustom />
|
||||||
key={index}
|
) : _.isEmpty(listReport) ? (
|
||||||
value1={
|
<TextCustom align="center" color={"gray"}>
|
||||||
<ActionIcon
|
Belum ada report
|
||||||
icon={<IconView size={ICON_SIZE_BUTTON} color="black" />}
|
</TextCustom>
|
||||||
onPress={() => setOpenDrawerAction(true)}
|
) : (
|
||||||
/>
|
listReport?.map((item: any, index: number) => (
|
||||||
}
|
<AdminTableValue
|
||||||
value2={<TextCustom truncate={1}>Username username</TextCustom>}
|
key={index}
|
||||||
value3={
|
value1={
|
||||||
<TextCustom truncate={2} align="center">
|
<ActionIcon
|
||||||
SPAM
|
icon={<IconView size={ICON_SIZE_BUTTON} color="black" />}
|
||||||
</TextCustom>
|
onPress={() => {
|
||||||
}
|
setOpenDrawerAction(true);
|
||||||
/>
|
setSelectedReport({
|
||||||
))}
|
id: item?.id,
|
||||||
</BaseBox>
|
username: item?.User?.username,
|
||||||
|
kategori: item?.ForumMaster_KategoriReport?.title,
|
||||||
|
keterangan: item?.ForumMaster_KategoriReport?.deskripsi,
|
||||||
|
deskripsi: item?.deskripsi,
|
||||||
|
});
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
}
|
||||||
|
value2={
|
||||||
|
<TextCustom truncate={1}>
|
||||||
|
{item?.User?.username || "-"}
|
||||||
|
</TextCustom>
|
||||||
|
}
|
||||||
|
value3={
|
||||||
|
<TextCustom truncate={2} align="center">
|
||||||
|
{item?.ForumMaster_KategoriReport?.title || "-"}
|
||||||
|
</TextCustom>
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
))
|
||||||
|
)}
|
||||||
|
</StackCustom>
|
||||||
</ViewWrapper>
|
</ViewWrapper>
|
||||||
|
|
||||||
<DrawerCustom
|
<DrawerCustom
|
||||||
@@ -112,13 +198,25 @@ export default function AdminForumReportPosting() {
|
|||||||
message: "Apakah Anda yakin ingin menghapus posting ini?",
|
message: "Apakah Anda yakin ingin menghapus posting ini?",
|
||||||
textLeft: "Batal",
|
textLeft: "Batal",
|
||||||
textRight: "Hapus",
|
textRight: "Hapus",
|
||||||
onPressRight: () => {
|
onPressRight: async () => {
|
||||||
|
const response = await apiAdminForumDeactivatePosting({
|
||||||
|
id: id as string,
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!response.success) {
|
||||||
|
Toast.show({
|
||||||
|
type: "error",
|
||||||
|
text1: "Posting gagal dihapus",
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
setOpenDrawerPage(false);
|
setOpenDrawerPage(false);
|
||||||
Toast.show({
|
Toast.show({
|
||||||
type: "success",
|
type: "success",
|
||||||
text1: "Posting berhasil dihapus",
|
text1: "Posting berhasil dihapus",
|
||||||
});
|
});
|
||||||
router.back()
|
router.back();
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
}}
|
}}
|
||||||
@@ -130,41 +228,39 @@ export default function AdminForumReportPosting() {
|
|||||||
closeDrawer={() => setOpenDrawerAction(false)}
|
closeDrawer={() => setOpenDrawerAction(false)}
|
||||||
height={"auto"}
|
height={"auto"}
|
||||||
>
|
>
|
||||||
{listDataAction.map((item, i) => (
|
<StackCustom>
|
||||||
<GridDetail_4_8
|
<GridDetail_4_8
|
||||||
key={i}
|
label={<TextCustom bold>Pelapor</TextCustom>}
|
||||||
label={<TextCustom bold>{item.label}</TextCustom>}
|
value={<TextCustom>{selectedReport?.username || "-"}</TextCustom>}
|
||||||
value={<TextCustom>{item.value}</TextCustom>}
|
|
||||||
/>
|
/>
|
||||||
))}
|
|
||||||
|
{selectedReport?.kategori && (
|
||||||
|
<>
|
||||||
|
<GridDetail_4_8
|
||||||
|
label={<TextCustom bold>Kategori Report</TextCustom>}
|
||||||
|
value={
|
||||||
|
<TextCustom>{selectedReport?.kategori || "-"}</TextCustom>
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
<GridDetail_4_8
|
||||||
|
label={<TextCustom bold>Keterangan</TextCustom>}
|
||||||
|
value={
|
||||||
|
<TextCustom>{selectedReport?.keterangan || "-"}</TextCustom>
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
|
||||||
|
{selectedReport?.deskripsi && (
|
||||||
|
<GridDetail_4_8
|
||||||
|
label={<TextCustom bold>Deskripsi</TextCustom>}
|
||||||
|
value={
|
||||||
|
<TextCustom>{selectedReport?.deskripsi || "-"}</TextCustom>
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
</StackCustom>
|
||||||
</DrawerCustom>
|
</DrawerCustom>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const listData = [
|
|
||||||
{
|
|
||||||
label: "Username",
|
|
||||||
value: "Username",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: "Status",
|
|
||||||
value: <BadgeCustom color={MainColor.green}>Open</BadgeCustom>,
|
|
||||||
},
|
|
||||||
];
|
|
||||||
|
|
||||||
const listDataAction = [
|
|
||||||
{
|
|
||||||
label: "Username",
|
|
||||||
value: "Firman Nusantara",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: "Kategori Report",
|
|
||||||
value: "SPAM",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: "Deskripsi",
|
|
||||||
value:
|
|
||||||
"Lorem ipsum dolor sit amet consectetur adipisicing elit. Blanditiis asperiores quidem deleniti architecto eaque et nostrum, ad consequuntur eveniet quisquam quae voluptatum ducimus! Dolorem nobis modi officia debitis, beatae mollitia.",
|
|
||||||
},
|
|
||||||
];
|
|
||||||
|
|||||||
@@ -22,7 +22,6 @@ export default function AdminForum() {
|
|||||||
category: "dashboard",
|
category: "dashboard",
|
||||||
});
|
});
|
||||||
|
|
||||||
console.log("[RES DASHBOARD]", JSON.stringify(response, null, 2));
|
|
||||||
if (response.success) {
|
if (response.success) {
|
||||||
setData(response.data);
|
setData(response.data);
|
||||||
}
|
}
|
||||||
@@ -39,12 +38,12 @@ export default function AdminForum() {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: "Report Posting",
|
label: "Report Posting",
|
||||||
value: data?.report_posting || 0,
|
value: data?.reportPosting || 0,
|
||||||
icon: <IconReport size={25} color={MainColor.orange} />,
|
icon: <IconReport size={25} color={MainColor.orange} />,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: "Report Comment",
|
label: "Report Comment",
|
||||||
value: data?.report_comment || 0,
|
value: data?.reportComment || 0,
|
||||||
icon: <IconReport size={25} color={MainColor.red} />,
|
icon: <IconReport size={25} color={MainColor.red} />,
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|||||||
@@ -1,10 +1,8 @@
|
|||||||
/* eslint-disable react-hooks/exhaustive-deps */
|
/* eslint-disable react-hooks/exhaustive-deps */
|
||||||
import {
|
import {
|
||||||
ActionIcon,
|
ActionIcon,
|
||||||
BaseBox,
|
|
||||||
LoaderCustom,
|
LoaderCustom,
|
||||||
SearchInput,
|
SearchInput,
|
||||||
Spacing,
|
|
||||||
StackCustom,
|
StackCustom,
|
||||||
TextCustom,
|
TextCustom,
|
||||||
ViewWrapper,
|
ViewWrapper,
|
||||||
@@ -40,7 +38,6 @@ export default function AdminForumPosting() {
|
|||||||
search: search,
|
search: search,
|
||||||
});
|
});
|
||||||
|
|
||||||
// console.log("[RES LIST POSTING]", JSON.stringify(response, null, 2));
|
|
||||||
if (response.success) {
|
if (response.success) {
|
||||||
setList(response.data);
|
setList(response.data);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
|
/* eslint-disable react-hooks/exhaustive-deps */
|
||||||
import {
|
import {
|
||||||
ActionIcon,
|
ActionIcon,
|
||||||
BaseBox,
|
LoaderCustom,
|
||||||
Divider,
|
|
||||||
SearchInput,
|
SearchInput,
|
||||||
Spacing,
|
StackCustom,
|
||||||
TextCustom,
|
TextCustom,
|
||||||
ViewWrapper,
|
ViewWrapper,
|
||||||
} from "@/components";
|
} from "@/components";
|
||||||
@@ -14,14 +14,48 @@ import AdminTableValue from "@/components/_ShareComponent/Admin/TableValue";
|
|||||||
import AdminTitlePage from "@/components/_ShareComponent/Admin/TitlePage";
|
import AdminTitlePage from "@/components/_ShareComponent/Admin/TitlePage";
|
||||||
import { MainColor } from "@/constants/color-palet";
|
import { MainColor } from "@/constants/color-palet";
|
||||||
import { ICON_SIZE_BUTTON } from "@/constants/constans-value";
|
import { ICON_SIZE_BUTTON } from "@/constants/constans-value";
|
||||||
import { router } from "expo-router";
|
import { apiAdminForum } from "@/service/api-admin/api-admin-forum";
|
||||||
|
import { router, useFocusEffect } from "expo-router";
|
||||||
|
import _ from "lodash";
|
||||||
|
import { useCallback, useState } from "react";
|
||||||
|
import { Divider } from "react-native-paper";
|
||||||
|
|
||||||
export default function AdminForumReportComment() {
|
export default function AdminForumReportComment() {
|
||||||
|
const [listData, setListData] = useState<any[] | null>(null);
|
||||||
|
const [loadList, setLoadList] = useState<boolean>(false);
|
||||||
|
const [search, setSearch] = useState<string>("");
|
||||||
|
|
||||||
|
useFocusEffect(
|
||||||
|
useCallback(() => {
|
||||||
|
onLoadData();
|
||||||
|
}, [search])
|
||||||
|
);
|
||||||
|
|
||||||
|
const onLoadData = async () => {
|
||||||
|
try {
|
||||||
|
setLoadList(true);
|
||||||
|
|
||||||
|
const response = await apiAdminForum({
|
||||||
|
category: "report_comment",
|
||||||
|
search: search,
|
||||||
|
});
|
||||||
|
|
||||||
|
if (response.success) {
|
||||||
|
setListData(response.data);
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.log("[ERROR]", error);
|
||||||
|
} finally {
|
||||||
|
setLoadList(false);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
const rightComponent = (
|
const rightComponent = (
|
||||||
<SearchInput
|
<SearchInput
|
||||||
containerStyle={{ width: "100%", marginBottom: 0 }}
|
containerStyle={{ width: "100%", marginBottom: 0 }}
|
||||||
placeholder="Cari Komentar"
|
placeholder="Cari Komentar"
|
||||||
|
value={search}
|
||||||
|
onChangeText={setSearch}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -29,36 +63,56 @@ export default function AdminForumReportComment() {
|
|||||||
<>
|
<>
|
||||||
<ViewWrapper headerComponent={<AdminTitlePage title="Forum" />}>
|
<ViewWrapper headerComponent={<AdminTitlePage title="Forum" />}>
|
||||||
<AdminComp_BoxTitle
|
<AdminComp_BoxTitle
|
||||||
title="Report Comment"
|
title="Report Komentar"
|
||||||
rightComponent={rightComponent}
|
rightComponent={rightComponent}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<BaseBox>
|
<StackCustom gap={"sm"}>
|
||||||
<AdminTitleTable title1="Aksi" title2="Pelapor" title3="Jenis Laporan" />
|
<AdminTitleTable
|
||||||
<Spacing />
|
title1="Aksi"
|
||||||
|
title2="Pelapor"
|
||||||
|
title3="Jenis Laporan"
|
||||||
|
/>
|
||||||
<Divider />
|
<Divider />
|
||||||
{Array.from({ length: 10 }).map((_, index) => (
|
{loadList ? (
|
||||||
<AdminTableValue
|
<LoaderCustom />
|
||||||
key={index}
|
) : _.isEmpty(listData) ? (
|
||||||
value1={
|
<TextCustom align="center" color="gray">
|
||||||
<ActionIcon
|
Belum ada data
|
||||||
icon={
|
</TextCustom>
|
||||||
<IconView size={ICON_SIZE_BUTTON} color={MainColor.black} />
|
) : (
|
||||||
}
|
listData?.map((item: any, index: number) => (
|
||||||
onPress={() => {
|
<AdminTableValue
|
||||||
router.push(`/admin/forum/${index + 1}/list-report-comment`);
|
key={index}
|
||||||
}}
|
value1={
|
||||||
/>
|
<ActionIcon
|
||||||
}
|
icon={
|
||||||
value2={<TextCustom truncate={1}>Username username</TextCustom>}
|
<IconView
|
||||||
value3={
|
size={ICON_SIZE_BUTTON}
|
||||||
<TextCustom truncate={2} align="center">
|
color={MainColor.black}
|
||||||
SPAM
|
/>
|
||||||
</TextCustom>
|
}
|
||||||
}
|
onPress={() => {
|
||||||
/>
|
router.push(
|
||||||
))}
|
`/admin/forum/${item?.Forum_Komentar?.id}/list-report-comment`
|
||||||
</BaseBox>
|
);
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
}
|
||||||
|
value2={
|
||||||
|
<TextCustom truncate={1}>
|
||||||
|
{item?.User?.username || "-"}
|
||||||
|
</TextCustom>
|
||||||
|
}
|
||||||
|
value3={
|
||||||
|
<TextCustom truncate={2} align="center">
|
||||||
|
{item?.ForumMaster_KategoriReport?.title || "-"}
|
||||||
|
</TextCustom>
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
))
|
||||||
|
)}
|
||||||
|
</StackCustom>
|
||||||
</ViewWrapper>
|
</ViewWrapper>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
/* eslint-disable @typescript-eslint/no-unused-vars */
|
/* eslint-disable react-hooks/exhaustive-deps */
|
||||||
import {
|
import {
|
||||||
ActionIcon,
|
ActionIcon,
|
||||||
BaseBox,
|
|
||||||
Divider,
|
Divider,
|
||||||
|
LoaderCustom,
|
||||||
SearchInput,
|
SearchInput,
|
||||||
Spacing,
|
StackCustom,
|
||||||
TextCustom,
|
TextCustom,
|
||||||
ViewWrapper,
|
ViewWrapper
|
||||||
} from "@/components";
|
} from "@/components";
|
||||||
import { IconView } from "@/components/_Icon/IconComponent";
|
import { IconView } from "@/components/_Icon/IconComponent";
|
||||||
import AdminComp_BoxTitle from "@/components/_ShareComponent/Admin/BoxTitlePage";
|
import AdminComp_BoxTitle from "@/components/_ShareComponent/Admin/BoxTitlePage";
|
||||||
@@ -15,17 +15,47 @@ import AdminTableValue from "@/components/_ShareComponent/Admin/TableValue";
|
|||||||
import AdminTitlePage from "@/components/_ShareComponent/Admin/TitlePage";
|
import AdminTitlePage from "@/components/_ShareComponent/Admin/TitlePage";
|
||||||
import { MainColor } from "@/constants/color-palet";
|
import { MainColor } from "@/constants/color-palet";
|
||||||
import { ICON_SIZE_BUTTON } from "@/constants/constans-value";
|
import { ICON_SIZE_BUTTON } from "@/constants/constans-value";
|
||||||
import { router } from "expo-router";
|
import { apiAdminForum } from "@/service/api-admin/api-admin-forum";
|
||||||
import { useState } from "react";
|
import { router, useFocusEffect } from "expo-router";
|
||||||
|
import _ from "lodash";
|
||||||
|
import { useCallback, useState } from "react";
|
||||||
|
|
||||||
export default function AdminForumReportPosting() {
|
export default function AdminForumReportPosting() {
|
||||||
const [openDrawer, setOpenDrawer] = useState(false);
|
const [listData, setListData] = useState<any[] | null>(null);
|
||||||
const [id, setId] = useState<any>();
|
const [loadList, setLoadList] = useState<boolean>(false);
|
||||||
|
const [search, setSearch] = useState<string>("");
|
||||||
|
|
||||||
|
useFocusEffect(
|
||||||
|
useCallback(() => {
|
||||||
|
onLoadData();
|
||||||
|
}, [search])
|
||||||
|
);
|
||||||
|
|
||||||
|
const onLoadData = async () => {
|
||||||
|
try {
|
||||||
|
setLoadList(true);
|
||||||
|
|
||||||
|
const response = await apiAdminForum({
|
||||||
|
category: "report_posting",
|
||||||
|
search: search,
|
||||||
|
});
|
||||||
|
|
||||||
|
if (response.success) {
|
||||||
|
setListData(response.data);
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.log("[ERROR]", error);
|
||||||
|
} finally {
|
||||||
|
setLoadList(false);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
const rightComponent = (
|
const rightComponent = (
|
||||||
<SearchInput
|
<SearchInput
|
||||||
containerStyle={{ width: "100%", marginBottom: 0 }}
|
containerStyle={{ width: "100%", marginBottom: 0 }}
|
||||||
placeholder="Cari"
|
placeholder="Cari Postingan"
|
||||||
|
value={search}
|
||||||
|
onChangeText={setSearch}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -37,36 +67,49 @@ export default function AdminForumReportPosting() {
|
|||||||
rightComponent={rightComponent}
|
rightComponent={rightComponent}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<BaseBox>
|
<StackCustom gap={"sm"}>
|
||||||
<AdminTitleTable title1="Aksi" title2="Pelapor" title3="Postingan" />
|
<AdminTitleTable title1="Aksi" title2="Pelapor" title3="Postingan" />
|
||||||
<Spacing />
|
|
||||||
<Divider />
|
<Divider />
|
||||||
{Array.from({ length: 10 }).map((_, index) => (
|
{loadList ? (
|
||||||
<AdminTableValue
|
<LoaderCustom />
|
||||||
key={index}
|
) : _.isEmpty(listData) ? (
|
||||||
value1={
|
<TextCustom align="center" color="gray">
|
||||||
<ActionIcon
|
Belum ada data
|
||||||
icon={
|
</TextCustom>
|
||||||
<IconView size={ICON_SIZE_BUTTON} color={MainColor.black} />
|
) : (
|
||||||
}
|
listData?.map((item: any, index: number) => (
|
||||||
onPress={() => {
|
<AdminTableValue
|
||||||
router.push(`/admin/forum/${id}/list-report-posting`);
|
key={index}
|
||||||
}}
|
value1={
|
||||||
/>
|
<ActionIcon
|
||||||
}
|
icon={
|
||||||
value2={<TextCustom truncate={1}>Username username</TextCustom>}
|
<IconView
|
||||||
value3={
|
size={ICON_SIZE_BUTTON}
|
||||||
<TextCustom truncate={2} align="center">
|
color={MainColor.black}
|
||||||
Lorem, ipsum dolor sit amet consectetur adipisicing elit.
|
/>
|
||||||
Omnis laborum doloremque eius velit voluptate corrupti vel,
|
}
|
||||||
provident quaerat tempore animi sed accusamus amet.
|
onPress={() => {
|
||||||
Temporibus, praesentium? Rem voluptatum nesciunt voluptas
|
router.push(
|
||||||
repellat.
|
`/admin/forum/${item?.Forum_Posting?.id}/list-report-posting`
|
||||||
</TextCustom>
|
);
|
||||||
}
|
}}
|
||||||
/>
|
/>
|
||||||
))}
|
}
|
||||||
</BaseBox>
|
value2={
|
||||||
|
<TextCustom truncate={1}>
|
||||||
|
{item?.User?.username || "-"}
|
||||||
|
</TextCustom>
|
||||||
|
}
|
||||||
|
value3={
|
||||||
|
<TextCustom truncate={2} align="center">
|
||||||
|
{item?.Forum_Posting?.diskusi || "-"}
|
||||||
|
</TextCustom>
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
))
|
||||||
|
)}
|
||||||
|
</StackCustom>
|
||||||
</ViewWrapper>
|
</ViewWrapper>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -13,8 +13,9 @@ import {
|
|||||||
import AdminBackButtonAntTitle from "@/components/_ShareComponent/Admin/BackButtonAntTitle";
|
import AdminBackButtonAntTitle from "@/components/_ShareComponent/Admin/BackButtonAntTitle";
|
||||||
import AdminButtonReject from "@/components/_ShareComponent/Admin/ButtonReject";
|
import AdminButtonReject from "@/components/_ShareComponent/Admin/ButtonReject";
|
||||||
import AdminButtonReview from "@/components/_ShareComponent/Admin/ButtonReview";
|
import AdminButtonReview from "@/components/_ShareComponent/Admin/ButtonReview";
|
||||||
|
import ReportBox from "@/components/Box/ReportBox";
|
||||||
import { MainColor } from "@/constants/color-palet";
|
import { MainColor } from "@/constants/color-palet";
|
||||||
import funUpdateStatus from "@/screens/Admin/Job/funUpdateStatus";
|
import funUpdateStatusJob from "@/screens/Admin/Job/funUpdateStatus";
|
||||||
import { apiAdminJobGetById } from "@/service/api-admin/api-admin-job";
|
import { apiAdminJobGetById } from "@/service/api-admin/api-admin-job";
|
||||||
import { router, useFocusEffect, useLocalSearchParams } from "expo-router";
|
import { router, useFocusEffect, useLocalSearchParams } from "expo-router";
|
||||||
import _ from "lodash";
|
import _ from "lodash";
|
||||||
@@ -88,7 +89,7 @@ export default function AdminJobDetailStatus() {
|
|||||||
changeStatus: "publish" | "review" | "reject";
|
changeStatus: "publish" | "review" | "reject";
|
||||||
}) => {
|
}) => {
|
||||||
try {
|
try {
|
||||||
const response = await funUpdateStatus({
|
const response = await funUpdateStatusJob({
|
||||||
id: id as string,
|
id: id as string,
|
||||||
changeStatus,
|
changeStatus,
|
||||||
});
|
});
|
||||||
@@ -141,13 +142,8 @@ export default function AdminJobDetailStatus() {
|
|||||||
</StackCustom>
|
</StackCustom>
|
||||||
</BaseBox>
|
</BaseBox>
|
||||||
|
|
||||||
{data && data?.catatan && (
|
{data && data?.catatan && (status === "reject" || status === "review") && (
|
||||||
<BaseBox>
|
<ReportBox text={data?.catatan}/>
|
||||||
<StackCustom>
|
|
||||||
<TextCustom bold>Catatan report</TextCustom>
|
|
||||||
<TextCustom>{data?.catatan}</TextCustom>
|
|
||||||
</StackCustom>
|
|
||||||
</BaseBox>
|
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{status === "review" && (
|
{status === "review" && (
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import {
|
|||||||
} from "@/components";
|
} from "@/components";
|
||||||
import AdminBackButtonAntTitle from "@/components/_ShareComponent/Admin/BackButtonAntTitle";
|
import AdminBackButtonAntTitle from "@/components/_ShareComponent/Admin/BackButtonAntTitle";
|
||||||
import AdminButtonReject from "@/components/_ShareComponent/Admin/ButtonReject";
|
import AdminButtonReject from "@/components/_ShareComponent/Admin/ButtonReject";
|
||||||
import funUpdateStatus from "@/screens/Admin/Job/funUpdateStatus";
|
import funUpdateStatusJob from "@/screens/Admin/Job/funUpdateStatus";
|
||||||
import { apiAdminJobGetById } from "@/service/api-admin/api-admin-job";
|
import { apiAdminJobGetById } from "@/service/api-admin/api-admin-job";
|
||||||
import { router, useFocusEffect, useLocalSearchParams } from "expo-router";
|
import { router, useFocusEffect, useLocalSearchParams } from "expo-router";
|
||||||
import { useCallback, useState } from "react";
|
import { useCallback, useState } from "react";
|
||||||
@@ -45,7 +45,7 @@ export default function AdminJobRejectInput() {
|
|||||||
}) => {
|
}) => {
|
||||||
try {
|
try {
|
||||||
setIsLoading(true);
|
setIsLoading(true);
|
||||||
const response = await funUpdateStatus({
|
const response = await funUpdateStatusJob({
|
||||||
id: id as string,
|
id: id as string,
|
||||||
changeStatus,
|
changeStatus,
|
||||||
data: data,
|
data: data,
|
||||||
|
|||||||
@@ -1,102 +1,166 @@
|
|||||||
|
/* eslint-disable react-hooks/exhaustive-deps */
|
||||||
import {
|
import {
|
||||||
AlertDefaultSystem,
|
AlertDefaultSystem,
|
||||||
BadgeCustom,
|
BadgeCustom,
|
||||||
BaseBox,
|
BaseBox,
|
||||||
CircleContainer,
|
CircleContainer,
|
||||||
Grid,
|
Grid,
|
||||||
Spacing,
|
Spacing,
|
||||||
StackCustom,
|
StackCustom,
|
||||||
TextCustom,
|
TextCustom,
|
||||||
ViewWrapper,
|
ViewWrapper,
|
||||||
} from "@/components";
|
} from "@/components";
|
||||||
import AdminBackButtonAntTitle from "@/components/_ShareComponent/Admin/BackButtonAntTitle";
|
import AdminBackButtonAntTitle from "@/components/_ShareComponent/Admin/BackButtonAntTitle";
|
||||||
import AdminButtonReject from "@/components/_ShareComponent/Admin/ButtonReject";
|
import AdminButtonReject from "@/components/_ShareComponent/Admin/ButtonReject";
|
||||||
import AdminButtonReview from "@/components/_ShareComponent/Admin/ButtonReview";
|
import AdminButtonReview from "@/components/_ShareComponent/Admin/ButtonReview";
|
||||||
import { GridDetail_4_8 } from "@/components/_ShareComponent/GridDetail_4_8";
|
import { GridDetail_4_8 } from "@/components/_ShareComponent/GridDetail_4_8";
|
||||||
|
import ReportBox from "@/components/Box/ReportBox";
|
||||||
import { MainColor } from "@/constants/color-palet";
|
import { MainColor } from "@/constants/color-palet";
|
||||||
|
import funUpdateStatusVoting from "@/screens/Admin/Voting/funUpdateStatus";
|
||||||
|
import { apiAdminVotingById } from "@/service/api-admin/api-admin-voting";
|
||||||
|
import { colorBadgeStatus } from "@/utils/colorBadge";
|
||||||
|
import { dateTimeView } from "@/utils/dateTimeView";
|
||||||
|
import { Entypo } from "@expo/vector-icons";
|
||||||
import dayjs from "dayjs";
|
import dayjs from "dayjs";
|
||||||
import { router, useLocalSearchParams } from "expo-router";
|
import { router, useFocusEffect, useLocalSearchParams } from "expo-router";
|
||||||
import _ from "lodash";
|
import _ from "lodash";
|
||||||
|
import { useCallback, useState } from "react";
|
||||||
import { List } from "react-native-paper";
|
import { List } from "react-native-paper";
|
||||||
|
import Toast from "react-native-toast-message";
|
||||||
|
|
||||||
export default function AdminVotingDetail() {
|
export default function AdminVotingDetail() {
|
||||||
const { id, status } = useLocalSearchParams();
|
const { id, status } = useLocalSearchParams();
|
||||||
|
const [data, setData] = useState<any | null>(null);
|
||||||
|
const [isLoading, setIsLoading] = useState(false);
|
||||||
|
|
||||||
const colorBadge = () => {
|
console.log("[status]", status);
|
||||||
if (status === "publish") {
|
|
||||||
return MainColor.green;
|
useFocusEffect(
|
||||||
} else if (status === "review") {
|
useCallback(() => {
|
||||||
return MainColor.orange;
|
onLoadData();
|
||||||
} else if (status === "reject") {
|
}, [id])
|
||||||
return MainColor.red;
|
);
|
||||||
} else {
|
|
||||||
return MainColor.placeholder;
|
const onLoadData = async () => {
|
||||||
|
try {
|
||||||
|
const response = await apiAdminVotingById({
|
||||||
|
id: id as string,
|
||||||
|
});
|
||||||
|
|
||||||
|
if (response.success) {
|
||||||
|
setData(response.data);
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.log("[ERROR]", error);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const listData = [
|
const listData = [
|
||||||
{
|
{
|
||||||
label: "Username",
|
label: "Username",
|
||||||
value: "Bagas Banuna",
|
value: (data && data?.Author?.username) || "-",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: "Judul",
|
label: "Judul",
|
||||||
value: `Judul Proyek: ${id}Lorem ipsum dolor sit amet consectetur adipisicing elit.`,
|
value: (data && data?.title) || "-",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: "Status",
|
label: "Status",
|
||||||
value: (
|
value:
|
||||||
<BadgeCustom color={colorBadge()}>
|
data && data?.Voting_Status?.name ? (
|
||||||
{_.startCase(status as string)}
|
<BadgeCustom color={colorBadgeStatus({ status: status as string })}>
|
||||||
</BadgeCustom>
|
{status === "history" ? "Riwayat" : _.startCase(status as string)}
|
||||||
),
|
</BadgeCustom>
|
||||||
|
) : (
|
||||||
|
"-"
|
||||||
|
),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: "Mulai Voting",
|
label: "Mulai Voting",
|
||||||
value: dayjs().format("DD/MM/YYYY"),
|
value:
|
||||||
|
(data && data?.awalVote && dateTimeView({ date: data?.awalVote })) ||
|
||||||
|
"-",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: "Voting Berakhir",
|
label: "Voting Berakhir",
|
||||||
value: dayjs().format("DD/MM/YYYY"),
|
value:
|
||||||
|
(data && data?.akhirVote && dateTimeView({ date: data?.akhirVote })) ||
|
||||||
|
"-",
|
||||||
},
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
label: "Deskripsi",
|
label: "Deskripsi",
|
||||||
value: "Lorem ipsum dolor sit amet consectetur adipisicing elit.",
|
value: (data && data?.deskripsi) || "-",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: "Daftar Pilhan",
|
label: "Daftar Pilihan",
|
||||||
value: (
|
value:
|
||||||
<>
|
data && data?.Voting_DaftarNamaVote
|
||||||
<List.Item
|
? data?.Voting_DaftarNamaVote?.map((item: any, i: number) => (
|
||||||
title={<TextCustom>Pilihan 1</TextCustom>}
|
<List.Item
|
||||||
left={(props) => (
|
key={i}
|
||||||
<List.Icon {...props} icon="circle" color={MainColor.yellow} />
|
title={<TextCustom>{item?.value}</TextCustom>}
|
||||||
)}
|
left={(props) => (
|
||||||
/>
|
<Entypo name="chevron-right" color={MainColor.yellow} />
|
||||||
<List.Item
|
)}
|
||||||
title={<TextCustom>Pilihan 2</TextCustom>}
|
/>
|
||||||
left={(props) => (
|
))
|
||||||
<List.Icon {...props} icon="circle" color={MainColor.yellow} />
|
: "-",
|
||||||
)}
|
|
||||||
/>
|
|
||||||
<List.Item
|
|
||||||
title={<TextCustom>Pilihan 3</TextCustom>}
|
|
||||||
left={(props) => (
|
|
||||||
<List.Icon {...props} icon="circle" color={MainColor.yellow} />
|
|
||||||
)}
|
|
||||||
/>
|
|
||||||
<List.Item
|
|
||||||
title={<TextCustom>Pilihan 4</TextCustom>}
|
|
||||||
left={(props) => (
|
|
||||||
<List.Icon {...props} icon="circle" color={MainColor.yellow} />
|
|
||||||
)}
|
|
||||||
/>
|
|
||||||
</>
|
|
||||||
),
|
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
|
const handleUpdate = async ({
|
||||||
|
changeStatus,
|
||||||
|
}: {
|
||||||
|
changeStatus: "publish" | "review" | "reject";
|
||||||
|
}) => {
|
||||||
|
try {
|
||||||
|
const dateNow = new Date();
|
||||||
|
// const dateNowHour = dateNow.getHours();
|
||||||
|
// const awalVoteHour = dayjs(data?.awalVote).hour();
|
||||||
|
|
||||||
|
const isBefore = dayjs(dateNow).diff(dayjs(data?.awalVote), "hours") < 0;
|
||||||
|
console.log("[IS BEFORE]", isBefore);
|
||||||
|
|
||||||
|
if (!isBefore) {
|
||||||
|
Toast.show({
|
||||||
|
type: "error",
|
||||||
|
text1: "Tanggal & waktu telah lewat",
|
||||||
|
text2: "Silahkan report dan ubah tanggal & waktu voting",
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Toast.show({
|
||||||
|
type: "success",
|
||||||
|
text1: "Berhasil mempublikasikan data",
|
||||||
|
});
|
||||||
|
|
||||||
|
setIsLoading(true);
|
||||||
|
const response = await funUpdateStatusVoting({
|
||||||
|
id: id as string,
|
||||||
|
changeStatus,
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!response.success) {
|
||||||
|
Toast.show({
|
||||||
|
type: "error",
|
||||||
|
text1: "Gagal mempublikasikan data",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
Toast.show({
|
||||||
|
type: "success",
|
||||||
|
text1: "Berhasil mempublikasikan data",
|
||||||
|
});
|
||||||
|
|
||||||
|
router.back();
|
||||||
|
} catch (error) {
|
||||||
|
console.log("[ERROR]", error);
|
||||||
|
} finally {
|
||||||
|
setIsLoading(false);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<ViewWrapper
|
<ViewWrapper
|
||||||
@@ -114,46 +178,59 @@ export default function AdminVotingDetail() {
|
|||||||
</StackCustom>
|
</StackCustom>
|
||||||
</BaseBox>
|
</BaseBox>
|
||||||
|
|
||||||
{status === "publish" && (
|
{status === "publish" ||
|
||||||
<BaseBox>
|
(status === "history" && (
|
||||||
<TextCustom bold align="center">
|
<BaseBox>
|
||||||
Hasil Voting
|
<TextCustom bold align="center">
|
||||||
</TextCustom>
|
Hasil Voting
|
||||||
<Spacing />
|
</TextCustom>
|
||||||
<Grid>
|
<Spacing />
|
||||||
|
<Grid>
|
||||||
|
{data?.Voting_DaftarNamaVote?.map(
|
||||||
|
(item: any, index: number) => (
|
||||||
|
<Grid.Col
|
||||||
|
key={index}
|
||||||
|
span={12 / data?.Voting_DaftarNamaVote?.length}
|
||||||
|
style={{ paddingRight: 3, paddingLeft: 3 }}
|
||||||
|
>
|
||||||
|
<StackCustom gap={"sm"}>
|
||||||
|
<CircleContainer
|
||||||
|
value={item?.jumlah}
|
||||||
|
style={{ alignSelf: "center" }}
|
||||||
|
/>
|
||||||
|
<TextCustom size="small" align="center">
|
||||||
|
{item?.value}
|
||||||
|
</TextCustom>
|
||||||
|
</StackCustom>
|
||||||
|
</Grid.Col>
|
||||||
|
)
|
||||||
|
)}
|
||||||
|
</Grid>
|
||||||
|
</BaseBox>
|
||||||
|
))}
|
||||||
|
|
||||||
{Array.from({length: 4}).map((_, index) => (
|
{data &&
|
||||||
<Grid.Col key={index} span={3} style={{ paddingRight: 3, paddingLeft: 3 }}>
|
data?.catatan &&
|
||||||
<StackCustom gap={"sm"}>
|
(status === "review" || status === "reject") && (
|
||||||
<CircleContainer value={index % 3 * 3} style={{ alignSelf: "center" }} />
|
<ReportBox text={data?.catatan} />
|
||||||
<TextCustom size="small" align="center">
|
)}
|
||||||
Pilihan {index + 1}
|
|
||||||
</TextCustom>
|
|
||||||
</StackCustom>
|
|
||||||
</Grid.Col>
|
|
||||||
))}
|
|
||||||
</Grid>
|
|
||||||
</BaseBox>
|
|
||||||
)}
|
|
||||||
|
|
||||||
{status === "review" && (
|
{status === "review" && (
|
||||||
<AdminButtonReview
|
<AdminButtonReview
|
||||||
|
isLoading={isLoading}
|
||||||
onPublish={() => {
|
onPublish={() => {
|
||||||
AlertDefaultSystem({
|
AlertDefaultSystem({
|
||||||
title: "Publish",
|
title: "Publish",
|
||||||
message: "Apakah anda yakin ingin mempublikasikan data ini?",
|
message: "Apakah anda yakin ingin mempublikasikan data ini?",
|
||||||
textLeft: "Cancel",
|
textLeft: "Cancel",
|
||||||
textRight: "Publish",
|
textRight: "Publish",
|
||||||
onPressLeft: () => {
|
|
||||||
router.back();
|
|
||||||
},
|
|
||||||
onPressRight: () => {
|
onPressRight: () => {
|
||||||
router.back();
|
handleUpdate({ changeStatus: "publish" });
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
}}
|
}}
|
||||||
onReject={() => {
|
onReject={() => {
|
||||||
router.push(`/admin/voting/${id}/reject-input`);
|
router.push(`/admin/voting/${id}/${status}/reject-input`);
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
@@ -162,7 +239,7 @@ export default function AdminVotingDetail() {
|
|||||||
<AdminButtonReject
|
<AdminButtonReject
|
||||||
title="Tambah Catatan"
|
title="Tambah Catatan"
|
||||||
onReject={() => {
|
onReject={() => {
|
||||||
router.push(`/admin/voting/${id}/reject-input`);
|
router.push(`/admin/voting/${id}/${status}/reject-input`);
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
|||||||
113
app/(application)/admin/voting/[id]/[status]/reject-input.tsx
Normal file
113
app/(application)/admin/voting/[id]/[status]/reject-input.tsx
Normal file
@@ -0,0 +1,113 @@
|
|||||||
|
/* eslint-disable react-hooks/exhaustive-deps */
|
||||||
|
import {
|
||||||
|
AlertDefaultSystem,
|
||||||
|
BoxButtonOnFooter,
|
||||||
|
TextAreaCustom,
|
||||||
|
ViewWrapper,
|
||||||
|
} from "@/components";
|
||||||
|
import AdminBackButtonAntTitle from "@/components/_ShareComponent/Admin/BackButtonAntTitle";
|
||||||
|
import AdminButtonReject from "@/components/_ShareComponent/Admin/ButtonReject";
|
||||||
|
import funUpdateStatusVoting from "@/screens/Admin/Voting/funUpdateStatus";
|
||||||
|
import { apiAdminVotingById } from "@/service/api-admin/api-admin-voting";
|
||||||
|
import { router, useFocusEffect, useLocalSearchParams } from "expo-router";
|
||||||
|
import { useCallback, useState } from "react";
|
||||||
|
import Toast from "react-native-toast-message";
|
||||||
|
|
||||||
|
export default function AdminVotingRejectInput() {
|
||||||
|
const { id, status } = useLocalSearchParams();
|
||||||
|
const [data, setData] = useState("");
|
||||||
|
const [isLoading, setIsLoading] = useState(false);
|
||||||
|
|
||||||
|
useFocusEffect(
|
||||||
|
useCallback(() => {
|
||||||
|
onLoadData();
|
||||||
|
}, [id])
|
||||||
|
);
|
||||||
|
|
||||||
|
const onLoadData = async () => {
|
||||||
|
try {
|
||||||
|
const response = await apiAdminVotingById({
|
||||||
|
id: id as string,
|
||||||
|
});
|
||||||
|
|
||||||
|
if (response.success) {
|
||||||
|
setData(response.data.catatan);
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.log("[ERROR]", error);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleUpdate = async ({
|
||||||
|
changeStatus,
|
||||||
|
}: {
|
||||||
|
changeStatus: "publish" | "review" | "reject";
|
||||||
|
}) => {
|
||||||
|
try {
|
||||||
|
setIsLoading(true);
|
||||||
|
const response = await funUpdateStatusVoting({
|
||||||
|
id: id as string,
|
||||||
|
changeStatus,
|
||||||
|
data: data,
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!response.success) {
|
||||||
|
Toast.show({
|
||||||
|
type: "error",
|
||||||
|
text1: "Report gagal",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
Toast.show({
|
||||||
|
type: "success",
|
||||||
|
text1: "Report berhasil",
|
||||||
|
});
|
||||||
|
|
||||||
|
if (status === "review") {
|
||||||
|
router.replace(`/admin/voting/reject/status`);
|
||||||
|
} else if (status === "reject") {
|
||||||
|
router.back();
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.log("[ERROR]", error);
|
||||||
|
} finally {
|
||||||
|
setIsLoading(false);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const buttonSubmit = (
|
||||||
|
<BoxButtonOnFooter>
|
||||||
|
<AdminButtonReject
|
||||||
|
title="Reject"
|
||||||
|
isLoading={isLoading}
|
||||||
|
onReject={() =>
|
||||||
|
AlertDefaultSystem({
|
||||||
|
title: "Reject",
|
||||||
|
message: "Apakah anda yakin ingin menolak data ini?",
|
||||||
|
textLeft: "Batal",
|
||||||
|
textRight: "Ya",
|
||||||
|
onPressRight: () => handleUpdate({ changeStatus: "reject" }),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
</BoxButtonOnFooter>
|
||||||
|
);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<ViewWrapper
|
||||||
|
footerComponent={buttonSubmit}
|
||||||
|
headerComponent={<AdminBackButtonAntTitle title="Penolakan Voting" />}
|
||||||
|
>
|
||||||
|
<TextAreaCustom
|
||||||
|
value={data}
|
||||||
|
onChangeText={setData}
|
||||||
|
placeholder="Masukan alasan"
|
||||||
|
required
|
||||||
|
showCount
|
||||||
|
maxLength={1000}
|
||||||
|
/>
|
||||||
|
</ViewWrapper>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -1,55 +0,0 @@
|
|||||||
import {
|
|
||||||
AlertDefaultSystem,
|
|
||||||
BoxButtonOnFooter,
|
|
||||||
TextAreaCustom,
|
|
||||||
ViewWrapper,
|
|
||||||
} from "@/components";
|
|
||||||
import AdminBackButtonAntTitle from "@/components/_ShareComponent/Admin/BackButtonAntTitle";
|
|
||||||
import AdminButtonReject from "@/components/_ShareComponent/Admin/ButtonReject";
|
|
||||||
import { router, useLocalSearchParams } from "expo-router";
|
|
||||||
import { useState } from "react";
|
|
||||||
|
|
||||||
export default function AdminVotingRejectInput() {
|
|
||||||
const { id } = useLocalSearchParams();
|
|
||||||
const [value, setValue] = useState(id as string);
|
|
||||||
const buttonSubmit = (
|
|
||||||
<BoxButtonOnFooter>
|
|
||||||
<AdminButtonReject
|
|
||||||
title="Reject"
|
|
||||||
onReject={() =>
|
|
||||||
AlertDefaultSystem({
|
|
||||||
title: "Reject",
|
|
||||||
message: "Apakah anda yakin ingin menolak data ini?",
|
|
||||||
textLeft: "Batal",
|
|
||||||
textRight: "Ya",
|
|
||||||
onPressLeft: () => {
|
|
||||||
router.back();
|
|
||||||
},
|
|
||||||
onPressRight: () => {
|
|
||||||
console.log("value:", value);
|
|
||||||
router.replace(`/admin/voting/reject/status`);
|
|
||||||
},
|
|
||||||
})
|
|
||||||
}
|
|
||||||
/>
|
|
||||||
</BoxButtonOnFooter>
|
|
||||||
);
|
|
||||||
|
|
||||||
return (
|
|
||||||
<>
|
|
||||||
<ViewWrapper
|
|
||||||
footerComponent={buttonSubmit}
|
|
||||||
headerComponent={<AdminBackButtonAntTitle title="Penolakan Voting" />}
|
|
||||||
>
|
|
||||||
<TextAreaCustom
|
|
||||||
value={value}
|
|
||||||
onChangeText={setValue}
|
|
||||||
placeholder="Masukan alasan"
|
|
||||||
required
|
|
||||||
showCount
|
|
||||||
maxLength={1000}
|
|
||||||
/>
|
|
||||||
</ViewWrapper>
|
|
||||||
</>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
@@ -1,27 +1,60 @@
|
|||||||
|
/* eslint-disable react-hooks/exhaustive-deps */
|
||||||
import {
|
import {
|
||||||
ActionIcon,
|
ActionIcon,
|
||||||
BaseBox,
|
LoaderCustom,
|
||||||
SearchInput,
|
SearchInput,
|
||||||
Spacing,
|
StackCustom,
|
||||||
TextCustom,
|
TextCustom,
|
||||||
ViewWrapper,
|
ViewWrapper,
|
||||||
} from "@/components";
|
} from "@/components";
|
||||||
import AdminComp_BoxTitle from "@/components/_ShareComponent/Admin/BoxTitlePage";
|
import AdminComp_BoxTitle from "@/components/_ShareComponent/Admin/BoxTitlePage";
|
||||||
import AdminTitleTable from "@/components/_ShareComponent/Admin/TableTitle";
|
import AdminTitleTable from "@/components/_ShareComponent/Admin/TableTitle";
|
||||||
import AdminTableValue from "@/components/_ShareComponent/Admin/TableValue";
|
import AdminTableValue from "@/components/_ShareComponent/Admin/TableValue";
|
||||||
import AdminTitlePage from "@/components/_ShareComponent/Admin/TitlePage";
|
import AdminTitlePage from "@/components/_ShareComponent/Admin/TitlePage";
|
||||||
import { ICON_SIZE_BUTTON } from "@/constants/constans-value";
|
import { ICON_SIZE_BUTTON } from "@/constants/constans-value";
|
||||||
|
import { apiAdminVoting } from "@/service/api-admin/api-admin-voting";
|
||||||
import { Octicons } from "@expo/vector-icons";
|
import { Octicons } from "@expo/vector-icons";
|
||||||
import { router, useLocalSearchParams } from "expo-router";
|
import { router, useFocusEffect, useLocalSearchParams } from "expo-router";
|
||||||
import _ from "lodash";
|
import _ from "lodash";
|
||||||
|
import { useCallback, useState } from "react";
|
||||||
import { Divider } from "react-native-paper";
|
import { Divider } from "react-native-paper";
|
||||||
|
|
||||||
export default function AdminVotingStatus() {
|
export default function AdminVotingStatus() {
|
||||||
const { status } = useLocalSearchParams();
|
const { status } = useLocalSearchParams();
|
||||||
|
const [list, setList] = useState<any | null>(null);
|
||||||
|
const [loadList, setLoadList] = useState(false);
|
||||||
|
const [search, setSearch] = useState<string>("");
|
||||||
|
|
||||||
|
useFocusEffect(
|
||||||
|
useCallback(() => {
|
||||||
|
onLoadData();
|
||||||
|
}, [status, search])
|
||||||
|
);
|
||||||
|
|
||||||
|
const onLoadData = async () => {
|
||||||
|
try {
|
||||||
|
setLoadList(true);
|
||||||
|
const response = await apiAdminVoting({
|
||||||
|
category: status as "publish" | "review" | "reject" as any,
|
||||||
|
search,
|
||||||
|
});
|
||||||
|
|
||||||
|
if (response.success) {
|
||||||
|
setList(response.data);
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.log("[ERROR]", error);
|
||||||
|
} finally {
|
||||||
|
setLoadList(false);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
const rightComponent = (
|
const rightComponent = (
|
||||||
<SearchInput
|
<SearchInput
|
||||||
containerStyle={{ width: "100%", marginBottom: 0 }}
|
containerStyle={{ width: "100%", marginBottom: 0 }}
|
||||||
placeholder="Cari"
|
placeholder="Cari"
|
||||||
|
value={search}
|
||||||
|
onChangeText={setSearch}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
return (
|
return (
|
||||||
@@ -32,44 +65,52 @@ export default function AdminVotingStatus() {
|
|||||||
rightComponent={rightComponent}
|
rightComponent={rightComponent}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<BaseBox>
|
<StackCustom gap={"sm"}>
|
||||||
<AdminTitleTable
|
<AdminTitleTable
|
||||||
title1="Aksi"
|
title1="Aksi"
|
||||||
title2="Username"
|
title2="Username"
|
||||||
title3="Judul Voting"
|
title3="Judul Voting"
|
||||||
/>
|
/>
|
||||||
<Spacing />
|
|
||||||
<Divider />
|
<Divider />
|
||||||
|
|
||||||
{Array.from({ length: 10 }).map((_, index) => (
|
{loadList ? (
|
||||||
<AdminTableValue
|
<LoaderCustom />
|
||||||
key={index}
|
) : _.isEmpty(list) ? (
|
||||||
value1={
|
<TextCustom align="center" bold color="gray">
|
||||||
<ActionIcon
|
Belum ada data
|
||||||
icon={
|
</TextCustom>
|
||||||
<Octicons
|
) : (
|
||||||
name="eye"
|
list.map((item: any, i: number) => (
|
||||||
size={ICON_SIZE_BUTTON}
|
<AdminTableValue
|
||||||
color="black"
|
key={i}
|
||||||
/>
|
value1={
|
||||||
}
|
<ActionIcon
|
||||||
onPress={() => {
|
icon={
|
||||||
router.push(`/admin/voting/${index}/${status}`);
|
<Octicons
|
||||||
}}
|
name="eye"
|
||||||
/>
|
size={ICON_SIZE_BUTTON}
|
||||||
}
|
color="black"
|
||||||
value2={<TextCustom truncate={1}>Username username</TextCustom>}
|
/>
|
||||||
value3={
|
}
|
||||||
<TextCustom truncate={2}>
|
onPress={() => {
|
||||||
Lorem ipsum dolor sit amet consectetur adipisicing elit.
|
router.push(`/admin/voting/${item.id}/${status}`);
|
||||||
Blanditiis asperiores quidem deleniti architecto eaque et
|
}}
|
||||||
nostrum, ad consequuntur eveniet quisquam quae voluptatum
|
/>
|
||||||
ducimus! Dolorem nobis modi officia debitis, beatae mollitia.
|
}
|
||||||
</TextCustom>
|
value2={
|
||||||
}
|
<TextCustom truncate={1}>
|
||||||
/>
|
{item?.Author?.username || "-"}
|
||||||
))}
|
</TextCustom>
|
||||||
</BaseBox>
|
}
|
||||||
|
value3={
|
||||||
|
<TextCustom align="center" truncate={2}>
|
||||||
|
{item?.title || "-"}
|
||||||
|
</TextCustom>
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
))
|
||||||
|
)}
|
||||||
|
</StackCustom>
|
||||||
</ViewWrapper>
|
</ViewWrapper>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
|||||||
104
app/(application)/admin/voting/history.tsx
Normal file
104
app/(application)/admin/voting/history.tsx
Normal file
@@ -0,0 +1,104 @@
|
|||||||
|
/* eslint-disable react-hooks/exhaustive-deps */
|
||||||
|
import {
|
||||||
|
ActionIcon,
|
||||||
|
LoaderCustom,
|
||||||
|
SearchInput,
|
||||||
|
StackCustom,
|
||||||
|
TextCustom,
|
||||||
|
ViewWrapper
|
||||||
|
} from "@/components";
|
||||||
|
import AdminComp_BoxTitle from "@/components/_ShareComponent/Admin/BoxTitlePage";
|
||||||
|
import AdminTitleTable from "@/components/_ShareComponent/Admin/TableTitle";
|
||||||
|
import AdminTableValue from "@/components/_ShareComponent/Admin/TableValue";
|
||||||
|
import AdminTitlePage from "@/components/_ShareComponent/Admin/TitlePage";
|
||||||
|
import { ICON_SIZE_BUTTON } from "@/constants/constans-value";
|
||||||
|
import { apiAdminVoting } from "@/service/api-admin/api-admin-voting";
|
||||||
|
import { Octicons } from "@expo/vector-icons";
|
||||||
|
import { router, useFocusEffect } from "expo-router";
|
||||||
|
import _ from "lodash";
|
||||||
|
import { useCallback, useState } from "react";
|
||||||
|
import { Divider } from "react-native-paper";
|
||||||
|
|
||||||
|
export default function AdminVotingHistory() {
|
||||||
|
const [list, setList] = useState<any | null>(null);
|
||||||
|
const [loadList, setLoadList] = useState(false);
|
||||||
|
const [search, setSearch] = useState<string>("");
|
||||||
|
|
||||||
|
useFocusEffect(
|
||||||
|
useCallback(() => {
|
||||||
|
onLoadData();
|
||||||
|
}, [ search])
|
||||||
|
);
|
||||||
|
|
||||||
|
const onLoadData = async () => {
|
||||||
|
try {
|
||||||
|
setLoadList(true);
|
||||||
|
const response = await apiAdminVoting({
|
||||||
|
category: "history",
|
||||||
|
search,
|
||||||
|
});
|
||||||
|
|
||||||
|
if (response.success) {
|
||||||
|
setList(response.data);
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.log("[ERROR]", error);
|
||||||
|
} finally {
|
||||||
|
setLoadList(false);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const rightComponent = (
|
||||||
|
<SearchInput
|
||||||
|
containerStyle={{ width: "100%", marginBottom: 0 }}
|
||||||
|
placeholder="Cari"
|
||||||
|
value={search}
|
||||||
|
onChangeText={setSearch}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<ViewWrapper headerComponent={<AdminTitlePage title="Voting" />}>
|
||||||
|
<AdminComp_BoxTitle
|
||||||
|
title="Riwayat"
|
||||||
|
rightComponent={rightComponent}
|
||||||
|
/>
|
||||||
|
|
||||||
|
<StackCustom gap={"sm"}>
|
||||||
|
<AdminTitleTable
|
||||||
|
title1="Aksi"
|
||||||
|
title2="Username"
|
||||||
|
title3="Judul Voting"
|
||||||
|
/>
|
||||||
|
<Divider />
|
||||||
|
|
||||||
|
{loadList ? <LoaderCustom/> : _.isEmpty(list) ? <TextCustom align="center" bold color="gray">Belum ada data</TextCustom> : list.map((item: any, i: number) => (
|
||||||
|
<AdminTableValue
|
||||||
|
key={i}
|
||||||
|
value1={
|
||||||
|
<ActionIcon
|
||||||
|
icon={
|
||||||
|
<Octicons
|
||||||
|
name="eye"
|
||||||
|
size={ICON_SIZE_BUTTON}
|
||||||
|
color="black"
|
||||||
|
/>
|
||||||
|
}
|
||||||
|
onPress={() => {
|
||||||
|
router.push(`/admin/voting/${item.id}/history`);
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
}
|
||||||
|
value2={<TextCustom truncate={1}>{item?.Author?.username || "-"}</TextCustom>}
|
||||||
|
value3={
|
||||||
|
<TextCustom align="center" truncate={2}>
|
||||||
|
{item?.title || "-"}
|
||||||
|
</TextCustom>
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
))}
|
||||||
|
</StackCustom>
|
||||||
|
</ViewWrapper>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -8,8 +8,56 @@ import {
|
|||||||
import AdminComp_BoxDashboard from "@/components/_ShareComponent/Admin/BoxDashboard";
|
import AdminComp_BoxDashboard from "@/components/_ShareComponent/Admin/BoxDashboard";
|
||||||
import AdminTitlePage from "@/components/_ShareComponent/Admin/TitlePage";
|
import AdminTitlePage from "@/components/_ShareComponent/Admin/TitlePage";
|
||||||
import { MainColor } from "@/constants/color-palet";
|
import { MainColor } from "@/constants/color-palet";
|
||||||
|
import { apiAdminVoting } from "@/service/api-admin/api-admin-voting";
|
||||||
|
import { useFocusEffect } from "expo-router";
|
||||||
|
import { useCallback, useState } from "react";
|
||||||
|
|
||||||
export default function AdminVoting() {
|
export default function AdminVoting() {
|
||||||
|
const [data, setData] = useState<any | null>(null);
|
||||||
|
|
||||||
|
useFocusEffect(
|
||||||
|
useCallback(() => {
|
||||||
|
onLoadData();
|
||||||
|
}, [])
|
||||||
|
);
|
||||||
|
|
||||||
|
const onLoadData = async () => {
|
||||||
|
try {
|
||||||
|
const response = await apiAdminVoting({
|
||||||
|
category: "dashboard",
|
||||||
|
});
|
||||||
|
|
||||||
|
if (response.success) {
|
||||||
|
setData(response.data);
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.log("[ERROR]", error);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const listData = [
|
||||||
|
{
|
||||||
|
label: "Publish",
|
||||||
|
value: (data && data?.publish) || 0,
|
||||||
|
icon: <IconPublish size={25} color={MainColor.green} />,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: "Review",
|
||||||
|
value: (data && data?.review) || 0,
|
||||||
|
icon: <IconReview size={25} color={MainColor.orange} />,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: "Reject",
|
||||||
|
value: (data && data?.reject) || 0,
|
||||||
|
icon: <IconReject size={25} color={MainColor.red} />,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: "Riwayat",
|
||||||
|
value: (data && data?.history) || 0,
|
||||||
|
icon: <IconArchive size={25} color={MainColor.white_gray} />,
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<ViewWrapper>
|
<ViewWrapper>
|
||||||
@@ -24,26 +72,3 @@ export default function AdminVoting() {
|
|||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const listData = [
|
|
||||||
{
|
|
||||||
label: "Publish",
|
|
||||||
value: 4,
|
|
||||||
icon: <IconPublish size={25} color={MainColor.green} />,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: "Review",
|
|
||||||
value: 7,
|
|
||||||
icon: <IconReview size={25} color={MainColor.orange} />,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: "Reject",
|
|
||||||
value: 5,
|
|
||||||
icon: <IconReject size={25} color={MainColor.red} />,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: "Riwayat",
|
|
||||||
value: 5,
|
|
||||||
icon: <IconArchive size={25} color={MainColor.white_gray} />,
|
|
||||||
},
|
|
||||||
];
|
|
||||||
|
|||||||
3
bun.lock
3
bun.lock
@@ -17,7 +17,6 @@
|
|||||||
"axios": "^1.11.0",
|
"axios": "^1.11.0",
|
||||||
"dayjs": "^1.11.13",
|
"dayjs": "^1.11.13",
|
||||||
"expo": "^54.0.0",
|
"expo": "^54.0.0",
|
||||||
"expo-blur": "~15.0.7",
|
|
||||||
"expo-camera": "~17.0.7",
|
"expo-camera": "~17.0.7",
|
||||||
"expo-clipboard": "~8.0.7",
|
"expo-clipboard": "~8.0.7",
|
||||||
"expo-constants": "~18.0.8",
|
"expo-constants": "~18.0.8",
|
||||||
@@ -1153,8 +1152,6 @@
|
|||||||
|
|
||||||
"expo-asset": ["expo-asset@12.0.8", "", { "dependencies": { "@expo/image-utils": "^0.8.7", "expo-constants": "~18.0.8" }, "peerDependencies": { "expo": "*", "react": "*", "react-native": "*" } }, "sha512-jj2U8zw9+7orST2rlQGULYiqPoECOuUyffs2NguGrq84bYbkM041T7TOMXH2raPVJnM9lEAP54ezI6XL+GVYqw=="],
|
"expo-asset": ["expo-asset@12.0.8", "", { "dependencies": { "@expo/image-utils": "^0.8.7", "expo-constants": "~18.0.8" }, "peerDependencies": { "expo": "*", "react": "*", "react-native": "*" } }, "sha512-jj2U8zw9+7orST2rlQGULYiqPoECOuUyffs2NguGrq84bYbkM041T7TOMXH2raPVJnM9lEAP54ezI6XL+GVYqw=="],
|
||||||
|
|
||||||
"expo-blur": ["expo-blur@15.0.7", "", { "peerDependencies": { "expo": "*", "react": "*", "react-native": "*" } }, "sha512-SugQQbQd+zRPy8z2G5qDD4NqhcD7srBF7fN7O7yq6q7ZFK59VWvpDxtMoUkmSfdxgqONsrBN/rLdk00USADrMg=="],
|
|
||||||
|
|
||||||
"expo-camera": ["expo-camera@17.0.7", "", { "dependencies": { "invariant": "^2.2.4" }, "peerDependencies": { "expo": "*", "react": "*", "react-native": "*", "react-native-web": "*" }, "optionalPeers": ["react-native-web"] }, "sha512-jdZfijfFjlVAuuIkDheA41YKpigPjqsN0juRvgyr7Lcyz+fvwZ3/RP50/n/hvuozH657wHxPfiyVVFa00z8TcQ=="],
|
"expo-camera": ["expo-camera@17.0.7", "", { "dependencies": { "invariant": "^2.2.4" }, "peerDependencies": { "expo": "*", "react": "*", "react-native": "*", "react-native-web": "*" }, "optionalPeers": ["react-native-web"] }, "sha512-jdZfijfFjlVAuuIkDheA41YKpigPjqsN0juRvgyr7Lcyz+fvwZ3/RP50/n/hvuozH657wHxPfiyVVFa00z8TcQ=="],
|
||||||
|
|
||||||
"expo-clipboard": ["expo-clipboard@8.0.7", "", { "peerDependencies": { "expo": "*", "react": "*", "react-native": "*" } }, "sha512-zvlfFV+wB2QQrQnHWlo0EKHAkdi2tycLtE+EXFUWTPZYkgu1XcH+aiKfd4ul7Z0SDF+1IuwoiW9AA9eO35aj3Q=="],
|
"expo-clipboard": ["expo-clipboard@8.0.7", "", { "peerDependencies": { "expo": "*", "react": "*", "react-native": "*" } }, "sha512-zvlfFV+wB2QQrQnHWlo0EKHAkdi2tycLtE+EXFUWTPZYkgu1XcH+aiKfd4ul7Z0SDF+1IuwoiW9AA9eO35aj3Q=="],
|
||||||
|
|||||||
16
components/Box/ReportBox.tsx
Normal file
16
components/Box/ReportBox.tsx
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
import StackCustom from "../Stack/StackCustom";
|
||||||
|
import TextCustom from "../Text/TextCustom";
|
||||||
|
import BaseBox from "./BaseBox";
|
||||||
|
|
||||||
|
export default function ReportBox({ text }: { text: string }) {
|
||||||
|
return (
|
||||||
|
<BaseBox>
|
||||||
|
<StackCustom gap={"sm"}>
|
||||||
|
<TextCustom bold>
|
||||||
|
Catatan penolakan
|
||||||
|
</TextCustom>
|
||||||
|
<TextCustom>{text}</TextCustom>
|
||||||
|
</StackCustom>
|
||||||
|
</BaseBox>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -1,27 +1,39 @@
|
|||||||
import { MainColor } from "@/constants/color-palet";
|
import { MainColor } from "@/constants/color-palet";
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import { StyleProp, StyleSheet, TextInput, View, ViewStyle } from "react-native";
|
import {
|
||||||
|
StyleProp,
|
||||||
|
StyleSheet,
|
||||||
|
View,
|
||||||
|
ViewStyle
|
||||||
|
} from "react-native";
|
||||||
|
import TextCustom from "../Text/TextCustom";
|
||||||
|
|
||||||
interface CircularInputProps {
|
interface CircularInputProps {
|
||||||
value?: string | number
|
value?: string | number;
|
||||||
onChange?: (value: string | number) => void;
|
onChange?: (value: string | number) => void;
|
||||||
icon?: React.ReactNode;
|
icon?: React.ReactNode;
|
||||||
style?: StyleProp<ViewStyle>
|
style?: StyleProp<ViewStyle>;
|
||||||
}
|
}
|
||||||
|
|
||||||
const CircularInput: React.FC<CircularInputProps> = ({ value, onChange, icon, style }) => {
|
const CircularInput: React.FC<CircularInputProps> = ({
|
||||||
|
value,
|
||||||
|
onChange,
|
||||||
|
icon,
|
||||||
|
style,
|
||||||
|
}) => {
|
||||||
return (
|
return (
|
||||||
<View style={[styles.circleContainer, style]}>
|
<View style={[styles.circleContainer, style]}>
|
||||||
{icon ? (
|
{icon ? (
|
||||||
icon
|
icon
|
||||||
) : (
|
) : (
|
||||||
<TextInput
|
<TextCustom
|
||||||
value={String(value)}
|
// text={String(value)}
|
||||||
onChangeText={onChange}
|
|
||||||
style={styles.input}
|
style={styles.input}
|
||||||
keyboardType="numeric"
|
// keyboardType="numeric"
|
||||||
maxLength={2} // Batasan maksimal karakter
|
// maxLength={2} // Batasan maksimal karakter
|
||||||
/>
|
>
|
||||||
|
{value}
|
||||||
|
</TextCustom>
|
||||||
)}
|
)}
|
||||||
</View>
|
</View>
|
||||||
);
|
);
|
||||||
@@ -39,7 +51,7 @@ const styles = StyleSheet.create({
|
|||||||
},
|
},
|
||||||
input: {
|
input: {
|
||||||
color: MainColor.yellow, // Warna kuning
|
color: MainColor.yellow, // Warna kuning
|
||||||
fontSize: 24,
|
fontSize: 18,
|
||||||
fontWeight: "bold",
|
fontWeight: "bold",
|
||||||
textAlign: "center",
|
textAlign: "center",
|
||||||
padding: 0,
|
padding: 0,
|
||||||
|
|||||||
@@ -196,6 +196,7 @@ const DateTimeInput_Android: React.FC<DateTimeInputProps> = ({
|
|||||||
onChange={handleConfirmTime}
|
onChange={handleConfirmTime}
|
||||||
minimumDate={minimumDate}
|
minimumDate={minimumDate}
|
||||||
maximumDate={maximumDate}
|
maximumDate={maximumDate}
|
||||||
|
themeVariant="light"
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
</>
|
</>
|
||||||
|
|||||||
@@ -145,6 +145,7 @@ const DateTimeInput_IOS: React.FC<DateTimeInputProps> = ({
|
|||||||
onChange={handleConfirm}
|
onChange={handleConfirm}
|
||||||
minimumDate={minimumDate}
|
minimumDate={minimumDate}
|
||||||
maximumDate={maximumDate}
|
maximumDate={maximumDate}
|
||||||
|
themeVariant="light"
|
||||||
/>
|
/>
|
||||||
</View>
|
</View>
|
||||||
</>
|
</>
|
||||||
|
|||||||
@@ -27,6 +27,8 @@ type SelectProps = {
|
|||||||
onChange: (value: string | number) => void;
|
onChange: (value: string | number) => void;
|
||||||
borderRadius?: number;
|
borderRadius?: number;
|
||||||
styleContainer?: StyleProp<ViewStyle>;
|
styleContainer?: StyleProp<ViewStyle>;
|
||||||
|
allowClear?: boolean; // <-- new prop
|
||||||
|
clearLabel?: string; // default: "Kosongkan"
|
||||||
};
|
};
|
||||||
|
|
||||||
const SelectCustom: React.FC<SelectProps> = ({
|
const SelectCustom: React.FC<SelectProps> = ({
|
||||||
@@ -39,13 +41,21 @@ const SelectCustom: React.FC<SelectProps> = ({
|
|||||||
onChange,
|
onChange,
|
||||||
borderRadius = 8,
|
borderRadius = 8,
|
||||||
styleContainer,
|
styleContainer,
|
||||||
|
allowClear = true, // bisa dimatikan jika tidak perlu
|
||||||
|
clearLabel = "Hapus Pilihan",
|
||||||
}) => {
|
}) => {
|
||||||
const [modalVisible, setModalVisible] = useState(false);
|
const [modalVisible, setModalVisible] = useState(false);
|
||||||
|
|
||||||
const selectedItem = data.find((item) => item.value === value);
|
const selectedItem = data.find((item) => item.value === value);
|
||||||
|
|
||||||
const hasError = required && value === null; // <-- check if empty and required
|
const hasError = required && value === null; // <-- check if empty and required
|
||||||
|
|
||||||
|
// Gabungkan opsi clear di atas daftar
|
||||||
|
const renderData = allowClear
|
||||||
|
? [...data,
|
||||||
|
// { label: clearLabel, value: "__clear__" }
|
||||||
|
]
|
||||||
|
: data;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<View style={[GStyles.inputContainerArea, styleContainer]}>
|
<View style={[GStyles.inputContainerArea, styleContainer]}>
|
||||||
{label && (
|
{label && (
|
||||||
@@ -54,29 +64,64 @@ const SelectCustom: React.FC<SelectProps> = ({
|
|||||||
{required && <Text style={GStyles.inputRequired}> *</Text>}
|
{required && <Text style={GStyles.inputRequired}> *</Text>}
|
||||||
</Text>
|
</Text>
|
||||||
)}
|
)}
|
||||||
<Pressable
|
|
||||||
|
{/* Input Container */}
|
||||||
|
<View
|
||||||
style={[
|
style={[
|
||||||
{ borderRadius, },
|
{
|
||||||
hasError ? GStyles.inputErrorBorder : null,
|
flexDirection: "row",
|
||||||
|
alignItems: "center",
|
||||||
|
// backgroundColor: "red",
|
||||||
|
// flex: 1,
|
||||||
|
borderRadius,
|
||||||
|
},
|
||||||
GStyles.inputContainerInput,
|
GStyles.inputContainerInput,
|
||||||
|
hasError ? GStyles.inputErrorBorder : null,
|
||||||
disabled && GStyles.disabledBox,
|
disabled && GStyles.disabledBox,
|
||||||
]} // <-- add error style
|
]}
|
||||||
onPress={() => !disabled && setModalVisible(true)}
|
|
||||||
>
|
>
|
||||||
<Text
|
<Pressable
|
||||||
style={
|
style={[
|
||||||
selectedItem
|
{
|
||||||
? disabled
|
flex: 1,
|
||||||
? GStyles.inputTextDisabled
|
borderRadius,
|
||||||
: GStyles.inputText
|
flexDirection: "row",
|
||||||
: disabled
|
alignItems: "center",
|
||||||
? GStyles.inputPlaceholderDisabled
|
paddingHorizontal: 10,
|
||||||
: GStyles.inputPlaceholder
|
height: 50,
|
||||||
}
|
},
|
||||||
|
|
||||||
|
// GStyles.inputContainerInput,
|
||||||
|
// hasError ? GStyles.inputErrorBorder : null,
|
||||||
|
// disabled && GStyles.disabledBox,
|
||||||
|
]}
|
||||||
|
onPress={() => !disabled && setModalVisible(true)}
|
||||||
>
|
>
|
||||||
{selectedItem?.label || placeholder}
|
<Text
|
||||||
</Text>
|
style={
|
||||||
</Pressable>
|
selectedItem
|
||||||
|
? disabled
|
||||||
|
? GStyles.inputTextDisabled
|
||||||
|
: GStyles.inputText
|
||||||
|
: disabled
|
||||||
|
? GStyles.inputPlaceholderDisabled
|
||||||
|
: GStyles.inputPlaceholder
|
||||||
|
}
|
||||||
|
>
|
||||||
|
{selectedItem?.label || placeholder}
|
||||||
|
</Text>
|
||||||
|
</Pressable>
|
||||||
|
|
||||||
|
{/* Tombol Clear (Hanya muncul jika ada nilai terpilih & allowClear aktif) */}
|
||||||
|
{!disabled && allowClear && value !== null && value !== undefined && (
|
||||||
|
<TouchableOpacity
|
||||||
|
style={{ paddingHorizontal: 10 }}
|
||||||
|
onPress={() => onChange(null as any)} // null dikirim sebagai value
|
||||||
|
>
|
||||||
|
<Text style={{ fontSize: 18, color: "#999" }}>×</Text>
|
||||||
|
</TouchableOpacity>
|
||||||
|
)}
|
||||||
|
</View>
|
||||||
|
|
||||||
<Modal visible={modalVisible} transparent animationType="fade">
|
<Modal visible={modalVisible} transparent animationType="fade">
|
||||||
<TouchableOpacity
|
<TouchableOpacity
|
||||||
@@ -86,19 +131,38 @@ const SelectCustom: React.FC<SelectProps> = ({
|
|||||||
>
|
>
|
||||||
<View style={GStyles.selectModalContent}>
|
<View style={GStyles.selectModalContent}>
|
||||||
<FlatList
|
<FlatList
|
||||||
data={data}
|
data={renderData}
|
||||||
keyExtractor={(item) => String(item.value)}
|
keyExtractor={(item) => String(item.value)}
|
||||||
renderItem={({ item }) => (
|
renderItem={({ item }) => {
|
||||||
<TouchableOpacity
|
if (item.value === "__clear__") {
|
||||||
style={GStyles.selectOption}
|
return (
|
||||||
onPress={() => {
|
<TouchableOpacity
|
||||||
onChange(item.value);
|
style={[
|
||||||
setModalVisible(false);
|
GStyles.selectOption,
|
||||||
}}
|
{ backgroundColor: "#fdd" },
|
||||||
>
|
]}
|
||||||
<Text>{item.label}</Text>
|
onPress={() => {
|
||||||
</TouchableOpacity>
|
onChange(null as any); // kosongkan nilai
|
||||||
)}
|
setModalVisible(false);
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Text>{item.label}</Text>
|
||||||
|
</TouchableOpacity>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<TouchableOpacity
|
||||||
|
style={GStyles.selectOption}
|
||||||
|
onPress={() => {
|
||||||
|
onChange(item.value);
|
||||||
|
setModalVisible(false);
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Text>{item.label}</Text>
|
||||||
|
</TouchableOpacity>
|
||||||
|
);
|
||||||
|
}}
|
||||||
/>
|
/>
|
||||||
</View>
|
</View>
|
||||||
</TouchableOpacity>
|
</TouchableOpacity>
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ interface TextCustomProps {
|
|||||||
bold?: boolean;
|
bold?: boolean;
|
||||||
semiBold?: boolean;
|
semiBold?: boolean;
|
||||||
size?: "default" | "large" | "small" | "xlarge" | number
|
size?: "default" | "large" | "small" | "xlarge" | number
|
||||||
color?: "default" | "yellow" | "red" | "gray" | "green" | "black"
|
color?: "default" | "yellow" | "red" | "gray" | "green" | "black" | "orange"
|
||||||
align?: TextAlign; // Prop untuk alignment
|
align?: TextAlign; // Prop untuk alignment
|
||||||
truncate?: boolean | number;
|
truncate?: boolean | number;
|
||||||
onPress?: () => void;
|
onPress?: () => void;
|
||||||
@@ -62,6 +62,7 @@ const TextCustom: React.FC<TextCustomProps> = ({
|
|||||||
else if (color === "gray") selectedStyles.push(styles.gray);
|
else if (color === "gray") selectedStyles.push(styles.gray);
|
||||||
else if (color === "green") selectedStyles.push(styles.green);
|
else if (color === "green") selectedStyles.push(styles.green);
|
||||||
else if (color === "black") selectedStyles.push(styles.black);
|
else if (color === "black") selectedStyles.push(styles.black);
|
||||||
|
else if (color === "orange") selectedStyles.push(styles.orange);
|
||||||
|
|
||||||
// Alignment
|
// Alignment
|
||||||
if (align) {
|
if (align) {
|
||||||
@@ -140,4 +141,7 @@ export const styles = StyleSheet.create({
|
|||||||
black: {
|
black: {
|
||||||
color: MainColor.black,
|
color: MainColor.black,
|
||||||
},
|
},
|
||||||
|
orange: {
|
||||||
|
color: MainColor.orange,
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ export default function AdminButtonReject({
|
|||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<ButtonCustom
|
<ButtonCustom
|
||||||
iconLeft={<IconReject />}
|
iconLeft={<IconReject size={16} />}
|
||||||
backgroundColor={MainColor.red}
|
backgroundColor={MainColor.red}
|
||||||
textColor="white"
|
textColor="white"
|
||||||
onPress={onReject}
|
onPress={onReject}
|
||||||
|
|||||||
@@ -4,9 +4,11 @@ import Grid from "@/components/Grid/GridCustom";
|
|||||||
import { MainColor } from "@/constants/color-palet";
|
import { MainColor } from "@/constants/color-palet";
|
||||||
|
|
||||||
export default function AdminButtonReview({
|
export default function AdminButtonReview({
|
||||||
|
isLoading,
|
||||||
onPublish,
|
onPublish,
|
||||||
onReject,
|
onReject,
|
||||||
}: {
|
}: {
|
||||||
|
isLoading?: boolean;
|
||||||
onPublish: () => void;
|
onPublish: () => void;
|
||||||
onReject: () => void;
|
onReject: () => void;
|
||||||
}) {
|
}) {
|
||||||
@@ -15,6 +17,7 @@ export default function AdminButtonReview({
|
|||||||
<Grid>
|
<Grid>
|
||||||
<Grid.Col span={6} style={{ paddingRight: 10 }}>
|
<Grid.Col span={6} style={{ paddingRight: 10 }}>
|
||||||
<ButtonCustom
|
<ButtonCustom
|
||||||
|
isLoading={isLoading}
|
||||||
iconLeft={<IconPublish />}
|
iconLeft={<IconPublish />}
|
||||||
backgroundColor={MainColor.green}
|
backgroundColor={MainColor.green}
|
||||||
textColor="white"
|
textColor="white"
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ import {
|
|||||||
StyleProp,
|
StyleProp,
|
||||||
ViewStyle,
|
ViewStyle,
|
||||||
} from "react-native";
|
} from "react-native";
|
||||||
import { SafeAreaView } from "react-native-safe-area-context";
|
import { NativeSafeAreaViewProps, SafeAreaView } from "react-native-safe-area-context";
|
||||||
|
|
||||||
interface ViewWrapperProps {
|
interface ViewWrapperProps {
|
||||||
children: React.ReactNode;
|
children: React.ReactNode;
|
||||||
@@ -21,6 +21,7 @@ interface ViewWrapperProps {
|
|||||||
footerComponent?: React.ReactNode;
|
footerComponent?: React.ReactNode;
|
||||||
floatingButton?: React.ReactNode;
|
floatingButton?: React.ReactNode;
|
||||||
hideFooter?: boolean;
|
hideFooter?: boolean;
|
||||||
|
edgesFooter?: NativeSafeAreaViewProps["edges"];
|
||||||
style?: StyleProp<ViewStyle>;
|
style?: StyleProp<ViewStyle>;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -37,6 +38,7 @@ const ViewWrapper = ({
|
|||||||
footerComponent,
|
footerComponent,
|
||||||
floatingButton,
|
floatingButton,
|
||||||
hideFooter = false,
|
hideFooter = false,
|
||||||
|
edgesFooter =[],
|
||||||
style,
|
style,
|
||||||
}: ViewWrapperProps) => {
|
}: ViewWrapperProps) => {
|
||||||
const assetBackground = require("../../assets/images/main-background.png");
|
const assetBackground = require("../../assets/images/main-background.png");
|
||||||
@@ -77,7 +79,7 @@ const ViewWrapper = ({
|
|||||||
|
|
||||||
{footerComponent ? (
|
{footerComponent ? (
|
||||||
<SafeAreaView
|
<SafeAreaView
|
||||||
edges={["bottom"]}
|
edges={Platform.OS === "ios" ? edgesFooter : ["bottom"]}
|
||||||
style={{
|
style={{
|
||||||
backgroundColor: MainColor.darkblue,
|
backgroundColor: MainColor.darkblue,
|
||||||
height: OS_HEIGHT
|
height: OS_HEIGHT
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ export {
|
|||||||
|
|
||||||
// OS Height
|
// OS Height
|
||||||
const OS_ANDROID_HEIGHT = 115
|
const OS_ANDROID_HEIGHT = 115
|
||||||
const OS_IOS_HEIGHT = 65
|
const OS_IOS_HEIGHT = 70
|
||||||
const OS_HEIGHT = Platform.OS === "ios" ? OS_IOS_HEIGHT : OS_ANDROID_HEIGHT
|
const OS_HEIGHT = Platform.OS === "ios" ? OS_IOS_HEIGHT : OS_ANDROID_HEIGHT
|
||||||
|
|
||||||
// Text Size
|
// Text Size
|
||||||
|
|||||||
@@ -91,14 +91,11 @@ export const AuthProvider = ({ children }: { children: React.ReactNode }) => {
|
|||||||
setToken(token);
|
setToken(token);
|
||||||
await AsyncStorage.setItem("authToken", token);
|
await AsyncStorage.setItem("authToken", token);
|
||||||
|
|
||||||
const responseUser = await apiConfig.get(
|
const responseUser = await apiConfig.get(`/mobile?token=${token}`, {
|
||||||
`/mobile?token=${token}`,
|
headers: {
|
||||||
{
|
Authorization: `Bearer ${token}`,
|
||||||
headers: {
|
},
|
||||||
Authorization: `Bearer ${token}`,
|
});
|
||||||
},
|
|
||||||
}
|
|
||||||
);
|
|
||||||
const dataUser = responseUser.data.data;
|
const dataUser = responseUser.data.data;
|
||||||
|
|
||||||
setUser(dataUser);
|
setUser(dataUser);
|
||||||
@@ -147,9 +144,7 @@ export const AuthProvider = ({ children }: { children: React.ReactNode }) => {
|
|||||||
await AsyncStorage.setItem("userData", JSON.stringify(dataUser));
|
await AsyncStorage.setItem("userData", JSON.stringify(dataUser));
|
||||||
return dataUser;
|
return dataUser;
|
||||||
} catch (error: any) {
|
} catch (error: any) {
|
||||||
throw new Error(
|
console.log(error.response?.data?.message + "user" || "Gagal mengambil data user");
|
||||||
error.response?.data?.message || "Gagal mengambil data user"
|
|
||||||
);
|
|
||||||
} finally {
|
} finally {
|
||||||
setIsLoading(false);
|
setIsLoading(false);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,7 +24,6 @@
|
|||||||
"axios": "^1.11.0",
|
"axios": "^1.11.0",
|
||||||
"dayjs": "^1.11.13",
|
"dayjs": "^1.11.13",
|
||||||
"expo": "^54.0.0",
|
"expo": "^54.0.0",
|
||||||
"expo-blur": "~15.0.7",
|
|
||||||
"expo-camera": "~17.0.7",
|
"expo-camera": "~17.0.7",
|
||||||
"expo-clipboard": "~8.0.7",
|
"expo-clipboard": "~8.0.7",
|
||||||
"expo-constants": "~18.0.8",
|
"expo-constants": "~18.0.8",
|
||||||
|
|||||||
@@ -6,7 +6,11 @@ import {
|
|||||||
DummyLandscapeImage,
|
DummyLandscapeImage,
|
||||||
} from "@/components";
|
} from "@/components";
|
||||||
|
|
||||||
export default function AdminDonation_BoxOfDonationStory() {
|
export default function AdminDonation_BoxOfDonationStory({
|
||||||
|
data,
|
||||||
|
}: {
|
||||||
|
data: any;
|
||||||
|
}) {
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<BaseBox>
|
<BaseBox>
|
||||||
@@ -14,19 +18,9 @@ export default function AdminDonation_BoxOfDonationStory() {
|
|||||||
<Spacing />
|
<Spacing />
|
||||||
|
|
||||||
<StackCustom>
|
<StackCustom>
|
||||||
<TextCustom>
|
<TextCustom>{(data && data?.pembukaan) || "-"}</TextCustom>
|
||||||
Lorem ipsum dolor sit, amet consectetur adipisicing elit. Rem magni
|
<DummyLandscapeImage imageId={data?.imageId || "-"} />
|
||||||
perspiciatis eius ipsam provident, impedit, fugiat aliquid nobis
|
<TextCustom>{(data && data?.cerita) || "-"}</TextCustom>
|
||||||
pariatur asperiores fuga quidem temporibus labore, molestias
|
|
||||||
perferendis optio ipsum. Praesentium, tempore?
|
|
||||||
</TextCustom>
|
|
||||||
<DummyLandscapeImage />
|
|
||||||
<TextCustom>
|
|
||||||
Lorem ipsum dolor sit, amet consectetur adipisicing elit. Rem magni
|
|
||||||
perspiciatis eius ipsam provident, impedit, fugiat aliquid nobis
|
|
||||||
pariatur asperiores fuga quidem temporibus labore, molestias
|
|
||||||
perferendis optio ipsum. Praesentium, tempore?
|
|
||||||
</TextCustom>
|
|
||||||
</StackCustom>
|
</StackCustom>
|
||||||
</BaseBox>
|
</BaseBox>
|
||||||
</>
|
</>
|
||||||
|
|||||||
23
screens/Admin/Donation/funDonationUpdateStatus.ts
Normal file
23
screens/Admin/Donation/funDonationUpdateStatus.ts
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
import { apiAdminDonationUpdateStatus } from "@/service/api-admin/api-admin-donation";
|
||||||
|
|
||||||
|
export const funUpdateStatusDonation = async ({
|
||||||
|
id,
|
||||||
|
changeStatus,
|
||||||
|
data,
|
||||||
|
}: {
|
||||||
|
id: string;
|
||||||
|
changeStatus: "publish" | "review" | "reject";
|
||||||
|
data?: string;
|
||||||
|
}) => {
|
||||||
|
try {
|
||||||
|
const response = await apiAdminDonationUpdateStatus({
|
||||||
|
id: id,
|
||||||
|
changeStatus: changeStatus as any,
|
||||||
|
data: data,
|
||||||
|
});
|
||||||
|
return response;
|
||||||
|
} catch (error) {
|
||||||
|
console.log("[ERROR]", error);
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
};
|
||||||
23
screens/Admin/Event/funUpdateStatus.ts
Normal file
23
screens/Admin/Event/funUpdateStatus.ts
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
import { apiAdminEventUpdateStatus } from "@/service/api-admin/api-admin-event";
|
||||||
|
|
||||||
|
export const funUpdateStatusEvent = async ({
|
||||||
|
id,
|
||||||
|
changeStatus,
|
||||||
|
data,
|
||||||
|
}: {
|
||||||
|
id: string;
|
||||||
|
changeStatus: "publish" | "review" | "reject";
|
||||||
|
data?: string;
|
||||||
|
}) => {
|
||||||
|
try {
|
||||||
|
const response = await apiAdminEventUpdateStatus({
|
||||||
|
id: id,
|
||||||
|
changeStatus: changeStatus as any,
|
||||||
|
data: data,
|
||||||
|
});
|
||||||
|
return response;
|
||||||
|
} catch (error) {
|
||||||
|
console.log("[ERROR]", error);
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
import { apiAdminJobUpdate } from "@/service/api-admin/api-admin-job";
|
import { apiAdminJobUpdate } from "@/service/api-admin/api-admin-job";
|
||||||
|
|
||||||
const funUpdateStatus = async ({
|
const funUpdateStatusJob = async ({
|
||||||
id,
|
id,
|
||||||
changeStatus,
|
changeStatus,
|
||||||
data,
|
data,
|
||||||
@@ -23,4 +23,4 @@ const funUpdateStatus = async ({
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
export default funUpdateStatus;
|
export default funUpdateStatusJob;
|
||||||
|
|||||||
26
screens/Admin/Voting/funUpdateStatus.ts
Normal file
26
screens/Admin/Voting/funUpdateStatus.ts
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
import { apiAdminVotingUpdateStatus } from "@/service/api-admin/api-admin-voting";
|
||||||
|
|
||||||
|
const funUpdateStatusVoting = async ({
|
||||||
|
id,
|
||||||
|
changeStatus,
|
||||||
|
data,
|
||||||
|
}: {
|
||||||
|
id: string;
|
||||||
|
changeStatus: "publish" | "review" | "reject";
|
||||||
|
data?: string;
|
||||||
|
}) => {
|
||||||
|
try {
|
||||||
|
const response = await apiAdminVotingUpdateStatus({
|
||||||
|
id: id,
|
||||||
|
status: changeStatus as any,
|
||||||
|
data: data,
|
||||||
|
});
|
||||||
|
|
||||||
|
return response;
|
||||||
|
} catch (error) {
|
||||||
|
console.log("[ERROR]", error);
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
export default funUpdateStatusVoting;
|
||||||
@@ -38,7 +38,7 @@ const adminListMenu: NavbarItem[] = [
|
|||||||
{ label: "Review", link: "/admin/event/review/status" },
|
{ label: "Review", link: "/admin/event/review/status" },
|
||||||
{ label: "Reject", link: "/admin/event/reject/status" },
|
{ label: "Reject", link: "/admin/event/reject/status" },
|
||||||
{ label: "Tipe Acara", link: "/admin/event/type-of-event" },
|
{ label: "Tipe Acara", link: "/admin/event/type-of-event" },
|
||||||
{ label: "Riwayat", link: "/admin/event/riwayat/status" },
|
{ label: "Riwayat", link: "/admin/event/history/status" },
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -49,7 +49,7 @@ const adminListMenu: NavbarItem[] = [
|
|||||||
{ label: "Publish", link: "/admin/voting/publish/status" },
|
{ label: "Publish", link: "/admin/voting/publish/status" },
|
||||||
{ label: "Review", link: "/admin/voting/review/status" },
|
{ label: "Review", link: "/admin/voting/review/status" },
|
||||||
{ label: "Reject", link: "/admin/voting/reject/status" },
|
{ label: "Reject", link: "/admin/voting/reject/status" },
|
||||||
{ label: "Riwayat", link: "/admin/voting/riwayat/status" },
|
{ label: "Riwayat", link: "/admin/voting/history" },
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -69,7 +69,7 @@ const adminListMenu: NavbarItem[] = [
|
|||||||
{ label: "Dashboard", link: "/admin/forum" },
|
{ label: "Dashboard", link: "/admin/forum" },
|
||||||
{ label: "Posting", link: "/admin/forum/posting" },
|
{ label: "Posting", link: "/admin/forum/posting" },
|
||||||
{ label: "Report Posting", link: "/admin/forum/report-posting" },
|
{ label: "Report Posting", link: "/admin/forum/report-posting" },
|
||||||
{ label: "Report Comment", link: "/admin/forum/report-comment" },
|
{ label: "Report Komentar", link: "/admin/forum/report-comment" },
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -131,7 +131,7 @@ const superAdminListMenu: NavbarItem[] = [
|
|||||||
{ label: "Review", link: "/admin/event/review/status" },
|
{ label: "Review", link: "/admin/event/review/status" },
|
||||||
{ label: "Reject", link: "/admin/event/reject/status" },
|
{ label: "Reject", link: "/admin/event/reject/status" },
|
||||||
{ label: "Tipe Acara", link: "/admin/event/type-of-event" },
|
{ label: "Tipe Acara", link: "/admin/event/type-of-event" },
|
||||||
{ label: "Riwayat", link: "/admin/event/riwayat/status" },
|
{ label: "Riwayat", link: "/admin/event/history/status" },
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -142,7 +142,7 @@ const superAdminListMenu: NavbarItem[] = [
|
|||||||
{ label: "Publish", link: "/admin/voting/publish/status" },
|
{ label: "Publish", link: "/admin/voting/publish/status" },
|
||||||
{ label: "Review", link: "/admin/voting/review/status" },
|
{ label: "Review", link: "/admin/voting/review/status" },
|
||||||
{ label: "Reject", link: "/admin/voting/reject/status" },
|
{ label: "Reject", link: "/admin/voting/reject/status" },
|
||||||
{ label: "Riwayat", link: "/admin/voting/riwayat/status" },
|
{ label: "Riwayat", link: "/admin/voting/history" },
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -162,7 +162,7 @@ const superAdminListMenu: NavbarItem[] = [
|
|||||||
{ label: "Dashboard", link: "/admin/forum" },
|
{ label: "Dashboard", link: "/admin/forum" },
|
||||||
{ label: "Posting", link: "/admin/forum/posting" },
|
{ label: "Posting", link: "/admin/forum/posting" },
|
||||||
{ label: "Report Posting", link: "/admin/forum/report-posting" },
|
{ label: "Report Posting", link: "/admin/forum/report-posting" },
|
||||||
{ label: "Report Comment", link: "/admin/forum/report-comment" },
|
{ label: "Report Komentar", link: "/admin/forum/report-comment" },
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,11 +1,14 @@
|
|||||||
|
/* eslint-disable react-hooks/exhaustive-deps */
|
||||||
import {
|
import {
|
||||||
BaseBox,
|
BaseBox,
|
||||||
Grid,
|
|
||||||
DummyLandscapeImage,
|
DummyLandscapeImage,
|
||||||
|
Grid,
|
||||||
|
ProgressCustom,
|
||||||
StackCustom,
|
StackCustom,
|
||||||
TextCustom,
|
TextCustom,
|
||||||
ProgressCustom,
|
|
||||||
} from "@/components";
|
} from "@/components";
|
||||||
|
import { countDownAndCondition } from "@/utils/countDownAndCondition";
|
||||||
|
import { useEffect, useState } from "react";
|
||||||
import { View } from "react-native";
|
import { View } from "react-native";
|
||||||
|
|
||||||
export default function Donation_BoxPublish({
|
export default function Donation_BoxPublish({
|
||||||
@@ -15,6 +18,27 @@ export default function Donation_BoxPublish({
|
|||||||
id: string;
|
id: string;
|
||||||
data: any;
|
data: any;
|
||||||
}) {
|
}) {
|
||||||
|
const [value, setValue] = useState({
|
||||||
|
sisa: 0,
|
||||||
|
reminder: false,
|
||||||
|
});
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
updateCountDown();
|
||||||
|
}, [data]);
|
||||||
|
|
||||||
|
const updateCountDown = () => {
|
||||||
|
const countDown = countDownAndCondition({
|
||||||
|
duration: data?.durasiDonasi,
|
||||||
|
publishTime: data?.publishTime,
|
||||||
|
});
|
||||||
|
|
||||||
|
setValue({
|
||||||
|
sisa: countDown.durationDay,
|
||||||
|
reminder: countDown.reminder,
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<BaseBox paddingTop={7} paddingBottom={7} href={`/donation/${id}`}>
|
<BaseBox paddingTop={7} paddingBottom={7} href={`/donation/${id}`}>
|
||||||
@@ -36,13 +60,22 @@ export default function Donation_BoxPublish({
|
|||||||
{data?.title || "-"}
|
{data?.title || "-"}
|
||||||
</TextCustom>
|
</TextCustom>
|
||||||
<TextCustom size="small">
|
<TextCustom size="small">
|
||||||
Sisa hari: {data?.durasiDonasi || 0}
|
{value.reminder ? (
|
||||||
|
<TextCustom bold color="red">
|
||||||
|
Waktu berakhir
|
||||||
|
</TextCustom>
|
||||||
|
) : (
|
||||||
|
<TextCustom>Sisa hari: {value.sisa}</TextCustom>
|
||||||
|
)}
|
||||||
</TextCustom>
|
</TextCustom>
|
||||||
</View>
|
</View>
|
||||||
<ProgressCustom
|
<ProgressCustom
|
||||||
label={data?.progres + "%" || "0%"}
|
|
||||||
value={data?.progres || 0}
|
|
||||||
size="lg"
|
size="lg"
|
||||||
|
value={Number(data?.progres) || 0}
|
||||||
|
showLabel={true}
|
||||||
|
label={data?.progres + "%"}
|
||||||
|
animated
|
||||||
|
color="primary"
|
||||||
/>
|
/>
|
||||||
{/* <TextCustom>
|
{/* <TextCustom>
|
||||||
Terkumpul : Rp 300.000
|
Terkumpul : Rp 300.000
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
import {
|
import {
|
||||||
BaseBox,
|
BaseBox,
|
||||||
StackCustom,
|
|
||||||
DummyLandscapeImage,
|
DummyLandscapeImage,
|
||||||
TextCustom,
|
|
||||||
Grid,
|
Grid,
|
||||||
|
StackCustom,
|
||||||
|
TextCustom,
|
||||||
} from "@/components";
|
} from "@/components";
|
||||||
import { formatCurrencyDisplay } from "@/utils/formatCurrencyDisplay";
|
import { formatCurrencyDisplay } from "@/utils/formatCurrencyDisplay";
|
||||||
import React from "react";
|
import React from "react";
|
||||||
@@ -12,10 +12,15 @@ import { View } from "react-native";
|
|||||||
export default function Donation_ComponentBoxDetailData({
|
export default function Donation_ComponentBoxDetailData({
|
||||||
bottomSection,
|
bottomSection,
|
||||||
data,
|
data,
|
||||||
|
sisaHari,
|
||||||
|
reminder,
|
||||||
}: {
|
}: {
|
||||||
bottomSection?: React.ReactNode;
|
bottomSection?: React.ReactNode;
|
||||||
data: any;
|
data: any;
|
||||||
|
sisaHari: number;
|
||||||
|
reminder: boolean;
|
||||||
}) {
|
}) {
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<BaseBox>
|
<BaseBox>
|
||||||
@@ -25,9 +30,13 @@ export default function Donation_ComponentBoxDetailData({
|
|||||||
<TextCustom bold size="large">
|
<TextCustom bold size="large">
|
||||||
{data?.title || "-"}
|
{data?.title || "-"}
|
||||||
</TextCustom>
|
</TextCustom>
|
||||||
<TextCustom size="small">
|
{reminder ? (
|
||||||
Durasi: {data?.DonasiMaster_Durasi?.name || "-"}
|
<TextCustom bold color="red">
|
||||||
</TextCustom>
|
Waktu berakhir
|
||||||
|
</TextCustom>
|
||||||
|
) : (
|
||||||
|
<TextCustom>Sisa hari: {sisaHari}</TextCustom>
|
||||||
|
)}
|
||||||
</View>
|
</View>
|
||||||
|
|
||||||
<Grid>
|
<Grid>
|
||||||
|
|||||||
@@ -11,11 +11,23 @@ import { Ionicons, MaterialIcons } from "@expo/vector-icons";
|
|||||||
import { router } from "expo-router";
|
import { router } from "expo-router";
|
||||||
import { View } from "react-native";
|
import { View } from "react-native";
|
||||||
|
|
||||||
export default function Donation_ProgressSection({ id }: { id: string }) {
|
export default function Donation_ProgressSection({
|
||||||
|
id,
|
||||||
|
progres,
|
||||||
|
}: {
|
||||||
|
id: string;
|
||||||
|
progres: number;
|
||||||
|
}) {
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<View>
|
<View>
|
||||||
<ProgressCustom size="lg" />
|
<ProgressCustom
|
||||||
|
size="lg"
|
||||||
|
value={progres}
|
||||||
|
label={progres + "%"}
|
||||||
|
animated
|
||||||
|
color="primary"
|
||||||
|
/>
|
||||||
<Spacing />
|
<Spacing />
|
||||||
<Grid>
|
<Grid>
|
||||||
<Grid.Col span={4}>
|
<Grid.Col span={4}>
|
||||||
|
|||||||
154
service/api-admin/api-admin-donation.ts
Normal file
154
service/api-admin/api-admin-donation.ts
Normal file
@@ -0,0 +1,154 @@
|
|||||||
|
import { apiConfig } from "../api-config";
|
||||||
|
|
||||||
|
export async function apiAdminDonation({
|
||||||
|
category,
|
||||||
|
search,
|
||||||
|
}: {
|
||||||
|
category: "dashboard" | "publish" | "review" | "reject";
|
||||||
|
search?: string;
|
||||||
|
}) {
|
||||||
|
try {
|
||||||
|
const response = await apiConfig.get(
|
||||||
|
`/mobile/admin/donation?category=${category}&search=${search}`
|
||||||
|
);
|
||||||
|
return response.data;
|
||||||
|
} catch (error) {
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function apiAdminDonationDetailById({ id }: { id: string }) {
|
||||||
|
try {
|
||||||
|
const response = await apiConfig.get(`/mobile/admin/donation/${id}`);
|
||||||
|
return response.data;
|
||||||
|
} catch (error) {
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function apiAdminDonationUpdateStatus({
|
||||||
|
id,
|
||||||
|
changeStatus,
|
||||||
|
data,
|
||||||
|
}: {
|
||||||
|
id: string;
|
||||||
|
changeStatus: "publish" | "review" | "reject";
|
||||||
|
data?: string;
|
||||||
|
}) {
|
||||||
|
try {
|
||||||
|
const response = await apiConfig.put(
|
||||||
|
`/mobile/admin/donation/${id}?status=${changeStatus}`,
|
||||||
|
{
|
||||||
|
data: data,
|
||||||
|
}
|
||||||
|
);
|
||||||
|
return response.data;
|
||||||
|
} catch (error) {
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function apiAdminDonationListOfDonatur({
|
||||||
|
id,
|
||||||
|
status,
|
||||||
|
}: {
|
||||||
|
id: string;
|
||||||
|
status: "berhasil" | "gagal" | "proses" | "menunggu" | null;
|
||||||
|
}) {
|
||||||
|
const query = status && status !== null ? `?status=${status}` : "";
|
||||||
|
|
||||||
|
try {
|
||||||
|
const response = await apiConfig.get(
|
||||||
|
`/mobile/admin/donation/${id}/donatur${query}`
|
||||||
|
);
|
||||||
|
return response.data;
|
||||||
|
} catch (error) {
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function apiAdminDonationInvoiceDetailById({
|
||||||
|
id,
|
||||||
|
}: {
|
||||||
|
id: string;
|
||||||
|
}) {
|
||||||
|
try {
|
||||||
|
const response = await apiConfig.get(
|
||||||
|
`/mobile/admin/donation/${id}/invoice`
|
||||||
|
);
|
||||||
|
return response.data;
|
||||||
|
} catch (error) {
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function apiAdminDonationInvoiceUpdateById({
|
||||||
|
id,
|
||||||
|
data,
|
||||||
|
status,
|
||||||
|
}: {
|
||||||
|
id: string;
|
||||||
|
data: any;
|
||||||
|
status: "berhasil" | "gagal" | "proses" | "menunggu";
|
||||||
|
}) {
|
||||||
|
try {
|
||||||
|
const response = await apiConfig.put(
|
||||||
|
`/mobile/admin/donation/${id}/invoice?status=${status}`,
|
||||||
|
{
|
||||||
|
data: data,
|
||||||
|
}
|
||||||
|
);
|
||||||
|
return response.data;
|
||||||
|
} catch (error) {
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function apiAdminDonationListOfDonaturById({
|
||||||
|
id,
|
||||||
|
}: {
|
||||||
|
id: string;
|
||||||
|
}) {
|
||||||
|
try {
|
||||||
|
const response = await apiConfig.get(`/mobile/donation/${id}/donatur`);
|
||||||
|
return response.data;
|
||||||
|
} catch (error) {
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function apiAdminDonationDisbursementOfFundsCreated({
|
||||||
|
id,
|
||||||
|
data,
|
||||||
|
}: {
|
||||||
|
id: string;
|
||||||
|
data: any;
|
||||||
|
}) {
|
||||||
|
try {
|
||||||
|
const response = await apiConfig.post(
|
||||||
|
`/mobile/admin/donation/${id}/disbursement`,
|
||||||
|
{
|
||||||
|
data: data,
|
||||||
|
}
|
||||||
|
);
|
||||||
|
return response.data;
|
||||||
|
} catch (error) {
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function apiAdminDonationDisbursementOfFundsListById({
|
||||||
|
id,
|
||||||
|
category,
|
||||||
|
}: {
|
||||||
|
id: string;
|
||||||
|
category: "get-all" | "get-one"
|
||||||
|
}) {
|
||||||
|
try {
|
||||||
|
const response = await apiConfig.get(`/mobile/admin/donation/${id}/disbursement?category=${category}`);
|
||||||
|
return response.data;
|
||||||
|
} catch (error) {
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
62
service/api-admin/api-admin-event.ts
Normal file
62
service/api-admin/api-admin-event.ts
Normal file
@@ -0,0 +1,62 @@
|
|||||||
|
import { apiConfig } from "../api-config";
|
||||||
|
|
||||||
|
export async function apiAdminEvent({
|
||||||
|
category,
|
||||||
|
search,
|
||||||
|
}: {
|
||||||
|
category: "dashboard" | "history" | "publish" | "review" | "type-of-event";
|
||||||
|
search?: string;
|
||||||
|
}) {
|
||||||
|
try {
|
||||||
|
const response = await apiConfig.get(
|
||||||
|
`/mobile/admin/event?category=${category}&search=${search}`
|
||||||
|
);
|
||||||
|
return response.data;
|
||||||
|
} catch (error) {
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function apiAdminEventById({ id }: { id: string }) {
|
||||||
|
try {
|
||||||
|
const response = await apiConfig.get(`/mobile/admin/event/${id}`);
|
||||||
|
return response.data;
|
||||||
|
} catch (error) {
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function apiAdminEventUpdateStatus({
|
||||||
|
id,
|
||||||
|
changeStatus,
|
||||||
|
data,
|
||||||
|
}: {
|
||||||
|
id: string;
|
||||||
|
changeStatus: "publish" | "review" | "reject";
|
||||||
|
data?: string;
|
||||||
|
}) {
|
||||||
|
try {
|
||||||
|
const response = await apiConfig.put(
|
||||||
|
`/mobile/admin/event/${id}?status=${changeStatus}`,
|
||||||
|
{
|
||||||
|
data: data,
|
||||||
|
}
|
||||||
|
);
|
||||||
|
return response.data;
|
||||||
|
} catch (error) {
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function apiAdminEventListOfParticipants({ id }: { id: string }) {
|
||||||
|
try {
|
||||||
|
const response = await apiConfig.get(
|
||||||
|
`/mobile/admin/event/${id}/participants`
|
||||||
|
);
|
||||||
|
return response.data;
|
||||||
|
} catch (error) {
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -41,3 +41,51 @@ export async function apiAdminForumCommentById({
|
|||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function apiAdminForumListReportCommentById({
|
||||||
|
id,
|
||||||
|
}: {
|
||||||
|
id: string;
|
||||||
|
}) {
|
||||||
|
try {
|
||||||
|
const response = await apiConfig.get(
|
||||||
|
`/mobile/admin/forum/${id}/report-comment`
|
||||||
|
);
|
||||||
|
return response.data;
|
||||||
|
} catch (error) {
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function apiAdminForumDeactivateComment({ id }: { id: string }) {
|
||||||
|
try {
|
||||||
|
const response = await apiConfig.put(`/mobile/admin/forum/${id}/comment`);
|
||||||
|
return response.data;
|
||||||
|
} catch (error) {
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function apiAdminForumListReportPostingById({
|
||||||
|
id,
|
||||||
|
}: {
|
||||||
|
id: string;
|
||||||
|
}) {
|
||||||
|
try {
|
||||||
|
const response = await apiConfig.get(
|
||||||
|
`/mobile/admin/forum/${id}/report-posting`
|
||||||
|
);
|
||||||
|
return response.data;
|
||||||
|
} catch (error) {
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function apiAdminForumDeactivatePosting({ id }: { id: string }) {
|
||||||
|
try {
|
||||||
|
const response = await apiConfig.put(`/mobile/admin/forum/${id}`);
|
||||||
|
return response.data;
|
||||||
|
} catch (error) {
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
49
service/api-admin/api-admin-voting.ts
Normal file
49
service/api-admin/api-admin-voting.ts
Normal file
@@ -0,0 +1,49 @@
|
|||||||
|
import { apiConfig } from "../api-config";
|
||||||
|
|
||||||
|
export async function apiAdminVoting({
|
||||||
|
category,
|
||||||
|
search,
|
||||||
|
}: {
|
||||||
|
category: "dashboard" | "history" | "publish" | "review" | "report";
|
||||||
|
search?: string;
|
||||||
|
}) {
|
||||||
|
try {
|
||||||
|
const response = await apiConfig.get(
|
||||||
|
`/mobile/admin/voting?category=${category}&search=${search}`
|
||||||
|
);
|
||||||
|
return response.data;
|
||||||
|
} catch (error) {
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function apiAdminVotingById({ id }: { id: string }) {
|
||||||
|
try {
|
||||||
|
const response = await apiConfig.get(`/mobile/admin/voting/${id}`);
|
||||||
|
return response.data;
|
||||||
|
} catch (error) {
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function apiAdminVotingUpdateStatus({
|
||||||
|
id,
|
||||||
|
data,
|
||||||
|
status,
|
||||||
|
}: {
|
||||||
|
id: string;
|
||||||
|
data?: string;
|
||||||
|
status: "publish" | "review" | "reject";
|
||||||
|
}) {
|
||||||
|
try {
|
||||||
|
const response = await apiConfig.put(
|
||||||
|
`/mobile/admin/voting/${id}?status=${status}`,
|
||||||
|
{
|
||||||
|
data: data,
|
||||||
|
}
|
||||||
|
);
|
||||||
|
return response.data;
|
||||||
|
} catch (error) {
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -62,7 +62,9 @@ export async function apiAdminMasterBusinessField() {
|
|||||||
|
|
||||||
export async function apiAdminMasterBusinessFieldById({ id }: { id: string }) {
|
export async function apiAdminMasterBusinessFieldById({ id }: { id: string }) {
|
||||||
try {
|
try {
|
||||||
const response = await apiConfig.get(`/mobile/admin/master/business-field/${id}`);
|
const response = await apiConfig.get(
|
||||||
|
`/mobile/admin/master/business-field/${id}`
|
||||||
|
);
|
||||||
return response.data;
|
return response.data;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
throw error;
|
throw error;
|
||||||
@@ -77,26 +79,91 @@ export async function apiAdminMasterBusinessFieldUpdate({
|
|||||||
data: any;
|
data: any;
|
||||||
}) {
|
}) {
|
||||||
try {
|
try {
|
||||||
const response = await apiConfig.put(`/mobile/admin/master/business-field/${id}`, {
|
const response = await apiConfig.put(
|
||||||
data: data,
|
`/mobile/admin/master/business-field/${id}`,
|
||||||
});
|
{
|
||||||
|
data: data,
|
||||||
|
}
|
||||||
|
);
|
||||||
return response.data;
|
return response.data;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function apiAdminMasterBusinessFieldCreate({ data }: { data: any }) {
|
export async function apiAdminMasterBusinessFieldCreate({
|
||||||
|
data,
|
||||||
|
}: {
|
||||||
|
data: any;
|
||||||
|
}) {
|
||||||
try {
|
try {
|
||||||
const response = await apiConfig.post(`/mobile/admin/master/business-field`, {
|
const response = await apiConfig.post(
|
||||||
data: data,
|
`/mobile/admin/master/business-field`,
|
||||||
});
|
{
|
||||||
|
data: data,
|
||||||
|
}
|
||||||
|
);
|
||||||
return response.data;
|
return response.data;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// ================== END BUSINNES FIELD ================== //
|
// ================== END BUSINNES FIELD ================== //
|
||||||
|
|
||||||
|
// ================== START EVENT ================== //
|
||||||
|
export async function apiAdminMasterTypeOfEvent() {
|
||||||
|
try {
|
||||||
|
const response = await apiConfig.get(`/mobile/admin/master/type-of-event`);
|
||||||
|
return response.data;
|
||||||
|
} catch (error) {
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function apiEventCreateTypeOfEvent({ data }: { data: string }) {
|
||||||
|
try {
|
||||||
|
const response = await apiConfig.post(
|
||||||
|
`/mobile/admin/master/type-of-event`,
|
||||||
|
{
|
||||||
|
data: data,
|
||||||
|
}
|
||||||
|
);
|
||||||
|
return response.data;
|
||||||
|
} catch (error) {
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function apiAdminMasterTypeOfEventGetOne({ id }: { id: string }) {
|
||||||
|
try {
|
||||||
|
const response = await apiConfig.get(
|
||||||
|
`/mobile/admin/master/type-of-event/${id}`
|
||||||
|
);
|
||||||
|
return response.data;
|
||||||
|
} catch (error) {
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function apiAdminMasterTypeOfEventUpdate({
|
||||||
|
id,
|
||||||
|
data,
|
||||||
|
}: {
|
||||||
|
id: string;
|
||||||
|
data: any;
|
||||||
|
}) {
|
||||||
|
try {
|
||||||
|
const response = await apiConfig.put(
|
||||||
|
`/mobile/admin/master/type-of-event/${id}`,
|
||||||
|
{
|
||||||
|
data: data,
|
||||||
|
}
|
||||||
|
);
|
||||||
|
return response.data;
|
||||||
|
} catch (error) {
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ================== END EVENT ================== //
|
||||||
|
|||||||
@@ -255,3 +255,16 @@ export async function apiDonationDeleteNews({ id }: { id: string }) {
|
|||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function apiDonationDisbursementOfFundsListById({
|
||||||
|
id,
|
||||||
|
}: {
|
||||||
|
id: string;
|
||||||
|
}) {
|
||||||
|
try {
|
||||||
|
const response = await apiConfig.get(`/mobile/donation/${id}/disbursement`);
|
||||||
|
return response.data;
|
||||||
|
} catch (error) {
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -138,3 +138,44 @@ export async function apiEventCheckParticipants({
|
|||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function apiEventGetConfirmation({
|
||||||
|
id,
|
||||||
|
userId,
|
||||||
|
}: {
|
||||||
|
id: string;
|
||||||
|
userId?: string;
|
||||||
|
}) {
|
||||||
|
try {
|
||||||
|
const response = await apiConfig.get(`/mobile/event/${id}/confirmation?userId=${userId}`);
|
||||||
|
return response.data;
|
||||||
|
} catch (error) {
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function apiEventConfirmationAction({
|
||||||
|
id,
|
||||||
|
userId,
|
||||||
|
category,
|
||||||
|
}: {
|
||||||
|
id: string;
|
||||||
|
userId?: string;
|
||||||
|
category?: "join_and_confirm" | "confirmation";
|
||||||
|
}) {
|
||||||
|
try {
|
||||||
|
const response = await apiConfig.post(
|
||||||
|
`/mobile/event/${id}/confirmation?category=${category}`,
|
||||||
|
{
|
||||||
|
data: {
|
||||||
|
userId: userId,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
);
|
||||||
|
return response.data;
|
||||||
|
} catch (error) {
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -157,3 +157,14 @@ export async function apiMasterDonation({
|
|||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ================== END MASTER DONATION ================== //
|
||||||
|
|
||||||
|
export async function apiMasterTransaction() {
|
||||||
|
try {
|
||||||
|
const response = await apiConfig.get(`/mobile/master/transaction-status`);
|
||||||
|
return response.data;
|
||||||
|
} catch (error) {
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -3,6 +3,7 @@ import axios, { AxiosInstance } from "axios";
|
|||||||
import Constants from "expo-constants";
|
import Constants from "expo-constants";
|
||||||
export const BASE_URL = Constants.expoConfig?.extra?.BASE_URL;
|
export const BASE_URL = Constants.expoConfig?.extra?.BASE_URL;
|
||||||
export const API_BASE_URL = Constants.expoConfig?.extra?.API_BASE_URL;
|
export const API_BASE_URL = Constants.expoConfig?.extra?.API_BASE_URL;
|
||||||
|
export const DEEP_LINK_URL = Constants.expoConfig?.extra?.DEEP_LINK_URL;
|
||||||
|
|
||||||
export const apiConfig: AxiosInstance = axios.create({
|
export const apiConfig: AxiosInstance = axios.create({
|
||||||
baseURL: API_BASE_URL,
|
baseURL: API_BASE_URL,
|
||||||
|
|||||||
@@ -195,7 +195,14 @@ export const GStyles = StyleSheet.create({
|
|||||||
bottomBar: {
|
bottomBar: {
|
||||||
backgroundColor: MainColor.darkblue,
|
backgroundColor: MainColor.darkblue,
|
||||||
borderTopColor: AccentColor.blue,
|
borderTopColor: AccentColor.blue,
|
||||||
borderTopWidth: 1,
|
// borderTopWidth: 0.5,
|
||||||
|
height: "100%",
|
||||||
|
justifyContent: "center",
|
||||||
|
shadowColor: AccentColor.blue,
|
||||||
|
shadowOffset: { width: 0, height: -5},
|
||||||
|
shadowOpacity: 0.4,
|
||||||
|
shadowRadius: 40,
|
||||||
|
elevation: 8, // untuk Android
|
||||||
},
|
},
|
||||||
bottomBarContainer: {
|
bottomBarContainer: {
|
||||||
paddingHorizontal: 15,
|
paddingHorizontal: 15,
|
||||||
|
|||||||
9
utils/colorActivationForBadge.ts
Normal file
9
utils/colorActivationForBadge.ts
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
import { AccentColor } from "@/constants/color-palet";
|
||||||
|
|
||||||
|
export const colorActivationForBadge = ({ status }: { status: boolean }) => {
|
||||||
|
if (status) {
|
||||||
|
return AccentColor.blue;
|
||||||
|
} else {
|
||||||
|
return AccentColor.blackgray;
|
||||||
|
}
|
||||||
|
};
|
||||||
27
utils/colorBadge.ts
Normal file
27
utils/colorBadge.ts
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
import { AccentColor, MainColor } from "@/constants/color-palet";
|
||||||
|
|
||||||
|
export const colorBadgeStatus = ({ status }: { status: string }) => {
|
||||||
|
const statusLowerCase = status.toLowerCase();
|
||||||
|
if (statusLowerCase === "publish") {
|
||||||
|
return MainColor.green;
|
||||||
|
} else if (statusLowerCase === "review") {
|
||||||
|
return MainColor.orange;
|
||||||
|
} else if (statusLowerCase === "reject") {
|
||||||
|
return MainColor.red;
|
||||||
|
} else {
|
||||||
|
return MainColor.placeholder;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
export const colorBadgeTransaction = ({ status }: { status: string }) => {
|
||||||
|
const statusLowerCase = status.toLowerCase();
|
||||||
|
if (statusLowerCase === "berhasil") {
|
||||||
|
return MainColor.green;
|
||||||
|
} else if (statusLowerCase === "menunggu") {
|
||||||
|
return MainColor.orange;
|
||||||
|
} else if (statusLowerCase === "gagal") {
|
||||||
|
return MainColor.red;
|
||||||
|
} else {
|
||||||
|
return AccentColor.blue;
|
||||||
|
}
|
||||||
|
};
|
||||||
21
utils/countDownAndCondition.ts
Normal file
21
utils/countDownAndCondition.ts
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
import dayjs from "dayjs";
|
||||||
|
|
||||||
|
export function countDownAndCondition({
|
||||||
|
publishTime,
|
||||||
|
duration,
|
||||||
|
}: {
|
||||||
|
publishTime: Date;
|
||||||
|
duration: number | string;
|
||||||
|
}) {
|
||||||
|
const now = dayjs();
|
||||||
|
const publish = dayjs(publishTime);
|
||||||
|
const diffTime = publish.diff(now, "day");
|
||||||
|
|
||||||
|
const durasi = Number(duration);
|
||||||
|
const sisaHari = durasi + diffTime;
|
||||||
|
|
||||||
|
return {
|
||||||
|
durationDay: sisaHari,
|
||||||
|
reminder: sisaHari <= 0,
|
||||||
|
};
|
||||||
|
}
|
||||||
@@ -13,19 +13,28 @@ export interface IFileData {
|
|||||||
|
|
||||||
export type AllowedFileType = "image" | "pdf" | undefined;
|
export type AllowedFileType = "image" | "pdf" | undefined;
|
||||||
|
|
||||||
|
export type AspectRatio = [number, number];
|
||||||
|
|
||||||
export interface PickFileOptions {
|
export interface PickFileOptions {
|
||||||
setImageUri?: (file: IFileData) => void;
|
setImageUri?: (file: IFileData) => void;
|
||||||
setPdfUri?: (file: IFileData) => void;
|
setPdfUri?: (file: IFileData) => void;
|
||||||
allowedType?: AllowedFileType; // <-- Tambahkan prop ini
|
allowedType?: AllowedFileType; // <-- Tambahkan prop ini
|
||||||
|
aspectRatio?: AspectRatio;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default async function pickFile({
|
export default async function pickFile({
|
||||||
setImageUri,
|
setImageUri,
|
||||||
setPdfUri,
|
setPdfUri,
|
||||||
allowedType,
|
allowedType,
|
||||||
|
aspectRatio,
|
||||||
}: PickFileOptions): Promise<void> {
|
}: PickFileOptions): Promise<void> {
|
||||||
if (allowedType === "image") {
|
if (allowedType === "image") {
|
||||||
await pickImage(setImageUri);
|
if (aspectRatio) {
|
||||||
|
await pickImage(setImageUri, aspectRatio);
|
||||||
|
} else {
|
||||||
|
// Jika tidak, tawarkan pilihan rasio (default [4,3])
|
||||||
|
showAspectRatioChoice(setImageUri);
|
||||||
|
}
|
||||||
} else if (allowedType === "pdf") {
|
} else if (allowedType === "pdf") {
|
||||||
await pickPdf(setPdfUri);
|
await pickPdf(setPdfUri);
|
||||||
} else {
|
} else {
|
||||||
@@ -36,15 +45,45 @@ export default async function pickFile({
|
|||||||
[
|
[
|
||||||
{ text: "Batal", style: "cancel" },
|
{ text: "Batal", style: "cancel" },
|
||||||
{ text: "Dokumen (PDF)", onPress: () => pickPdf(setPdfUri) },
|
{ text: "Dokumen (PDF)", onPress: () => pickPdf(setPdfUri) },
|
||||||
{ text: "Gambar", onPress: () => pickImage(setImageUri) },
|
{ text: "Gambar", onPress: () => pickImage(setImageUri, aspectRatio) },
|
||||||
],
|
],
|
||||||
{ cancelable: true }
|
{ cancelable: true }
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function showAspectRatioChoice(setImageUri?: (file: IFileData) => void) {
|
||||||
|
Alert.alert(
|
||||||
|
"Pilih Rasio Gambar",
|
||||||
|
"Pilih rasio crop yang diinginkan:",
|
||||||
|
[
|
||||||
|
{ text: "Batal", style: "cancel" },
|
||||||
|
{
|
||||||
|
text: "1:1 (Kotak)",
|
||||||
|
onPress: () => pickImage(setImageUri, [1, 1]),
|
||||||
|
},
|
||||||
|
// {
|
||||||
|
// text: "4:3 (Default)",
|
||||||
|
// onPress: () => pickImage(setImageUri, [4, 3]),
|
||||||
|
// },
|
||||||
|
// {
|
||||||
|
// text: "9:16 (Landscape)",
|
||||||
|
// onPress: () => pickImage(setImageUri, [9, 16]),
|
||||||
|
// },
|
||||||
|
{
|
||||||
|
text: "3:4 (Potret)",
|
||||||
|
onPress: () => pickImage(setImageUri, [3, 4]),
|
||||||
|
},
|
||||||
|
],
|
||||||
|
{ cancelable: true }
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
// --- Fungsi internal: pickImage ---
|
// --- Fungsi internal: pickImage ---
|
||||||
async function pickImage(setImageUri?: (file: IFileData) => void) {
|
async function pickImage(
|
||||||
|
setImageUri?: (file: IFileData) => void,
|
||||||
|
aspectRatio: AspectRatio = [4, 3] // Default [4, 3]
|
||||||
|
) {
|
||||||
const { status } = await ImagePicker.requestMediaLibraryPermissionsAsync();
|
const { status } = await ImagePicker.requestMediaLibraryPermissionsAsync();
|
||||||
if (status !== "granted") {
|
if (status !== "granted") {
|
||||||
Alert.alert(
|
Alert.alert(
|
||||||
@@ -57,7 +96,7 @@ async function pickImage(setImageUri?: (file: IFileData) => void) {
|
|||||||
const result = await ImagePicker.launchImageLibraryAsync({
|
const result = await ImagePicker.launchImageLibraryAsync({
|
||||||
mediaTypes: ImagePicker.MediaTypeOptions.Images,
|
mediaTypes: ImagePicker.MediaTypeOptions.Images,
|
||||||
allowsEditing: true,
|
allowsEditing: true,
|
||||||
aspect: [4, 3],
|
aspect: aspectRatio, // 🎯 Gunakan rasio dinamis
|
||||||
quality: 1,
|
quality: 1,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user