Compare commits

...

6 Commits

Author SHA1 Message Date
1e1b18f860 Integrasi API: Donation & Admin Donation
Fix:
- app/(application)/(user)/donation/[id]/(transaction-flow)/[invoiceId]/invoice.tsx
- app/(application)/(user)/donation/[id]/index.tsx
- app/(application)/admin/donation/[id]/[status]/index.tsx
- app/(application)/admin/donation/[id]/[status]/transaction-detail.tsx
- app/(application)/admin/donation/[id]/list-of-donatur.tsx
- components/Select/SelectCustom.tsx
- context/AuthContext.tsx
- screens/Donation/BoxPublish.tsx
- screens/Donation/ProgressSection.tsx
- service/api-admin/api-admin-donation.ts

### NO Issue
2025-10-28 17:45:13 +08:00
5d4328a139 Integrasi API: Donation Admin
Add:
-  screens/Admin/Donation/funDonationUpdateStatus.ts
-  utils/countDownAndCondition.ts

Fix:
- app/(application)/(user)/donation/[id]/index.tsx
- app/(application)/admin/donation/[id]/[status]/index.tsx
- app/(application)/admin/donation/[id]/list-of-donatur.tsx
- app/(application)/admin/donation/[id]/reject-input.tsx
- app/(application)/admin/donation/index.tsx
- app/(application)/admin/event/[id]/[status]/index.tsx
- app/(application)/admin/voting/[id]/[status]/index.tsx
- screens/Admin/Donation/BoxOfDonationStory.tsx
- screens/Donation/BoxPublish.tsx
- screens/Donation/ComponentBoxDetailData.tsx
- service/api-admin/api-admin-donation.ts
- service/api-client/api-master.ts
- utils/colorBadge.ts
git add . && git commit -m
2025-10-28 10:19:47 +08:00
125bf16605 Update new github 2025-10-27 10:51:57 +08:00
73a803f2e8 Update new github 2025-10-27 10:49:31 +08:00
1bcd1a044f Integrasi API: Event Type
Add:
- utils/colorActivationForBadge.ts

Fix:
- app/(application)/admin/event/type-create.tsx
- app/(application)/admin/event/type-of-event.tsx
- app/(application)/admin/event/type-update.tsx
- service/api-admin/api-admin-event.ts
- service/api-admin/api-master-admin.ts
- service/api-client/api-event.ts

### No Issue
2025-10-24 16:22:45 +08:00
1e0b72de22 Integrasi API: Event Qr Code
Fix:
- app/(application)/(user)/event/[id]/confirmation.tsx
- app/(application)/(user)/event/[id]/list-of-participants.tsx
- app/(application)/admin/event/[id]/[status]/index.tsx
- app/(application)/admin/event/[id]/list-of-participants.tsx
- components/DateInput/DataTimeAndroid.tsx
- components/DateInput/DateTimeIOS.tsx
- service/api-admin/api-admin-event.ts

### No Issue
2025-10-24 11:57:05 +08:00
33 changed files with 1547 additions and 476 deletions

View File

@@ -122,7 +122,7 @@ export default function DonationInvoice() {
}}
>
<TextCustom size="xlarge" bold color="yellow">
{data?.DonasiMaster_Bank?.norek}
{data?.MasterBank?.norek}
</TextCustom>
</Grid.Col>
<Grid.Col
@@ -131,7 +131,7 @@ export default function DonationInvoice() {
alignItems: "flex-end",
}}
>
<CopyButton textToCopy={data?.DonasiMaster_Bank?.norek} />
<CopyButton textToCopy={data?.MasterBank?.norek} />
</Grid.Col>
</Grid>
</BaseBox>

View File

@@ -16,20 +16,19 @@ import Donation_ComponentInfoFundrising from "@/screens/Donation/ComponentInfoFu
import Donation_ComponentStoryFunrising from "@/screens/Donation/ComponentStoryFunrising";
import Donation_ProgressSection from "@/screens/Donation/ProgressSection";
import { apiDonationGetOne } from "@/service/api-client/api-donation";
import { countDownAndCondition } from "@/utils/countDownAndCondition";
import {
router,
Stack,
useFocusEffect,
useLocalSearchParams,
} from "expo-router";
import { useCallback, useState } from "react";
import { useCallback, useEffect, useState } from "react";
export default function DonasiDetailBeranda() {
const { user } = useAuth();
const { id } = useLocalSearchParams();
console.log("ID ", id);
const [openDrawer, setOpenDrawer] = useState(false);
const [data, setData] = useState<any>();
useFocusEffect(
@@ -45,21 +44,41 @@ export default function DonasiDetailBeranda() {
category: "permanent",
});
console.log("[RES GET ONE]", JSON.stringify(response.data, null, 2));
setData(response.data);
} catch (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 = (
<>
<BoxButtonOnFooter>
<ButtonCustom
disabled={value?.reminder}
onPress={() => router.navigate(`/donation/${id}/(transaction-flow)`)}
>
Donasi
{value?.reminder ? "Waktu berakhir" : "Donasi"}
</ButtonCustom>
</BoxButtonOnFooter>
</>
@@ -80,8 +99,10 @@ export default function DonasiDetailBeranda() {
<ViewWrapper footerComponent={buttonSection}>
<StackCustom>
<Donation_ComponentBoxDetailData
sisaHari={value.sisa}
reminder={value.reminder}
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_ComponentStoryFunrising

View File

@@ -74,8 +74,6 @@ export default function UserEventConfirmation() {
userId: user?.id as string,
});
console.log("[RES CONFIRMATION]", JSON.stringify(response, null, 2));
if (response.success) {
setData(response.data?.dataEvent);
setPeserta(response.data?.peserta);
@@ -142,11 +140,11 @@ export default function UserEventConfirmation() {
return (
<TamplateBox data={data}>
<TamplateText
text={`Event telah selesai, anda terdaftar sebagai peserta dan${
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.`}
} Terima kasih atas perhatian dan minat Anda. Kami berharap dapat bertemu di acara kami berikutnya.`}
/>
<BackToOtherPath
path="event"
@@ -173,14 +171,16 @@ export default function UserEventConfirmation() {
if (isWithinConfirmationWindow && peserta === true) {
if (konfirmasi === false) {
return (
<TamplateBox data={data}>
<TamplateText text="Konfirmasi Kehadiran" />
</TamplateBox>
<UserParticipan_And_DuringEvent
id={data.id}
userId={user?.id as string}
data={data}
/>
);
}
return (
<TamplateBox data={data}>
<TamplateText text="Anda telah mengonfirmasi kehadiran." />
<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}
@@ -192,7 +192,7 @@ export default function UserEventConfirmation() {
return (
<TamplateBox data={data}>
<TamplateText text="Anda terdaftar sebagai peserta. Konfirmasi kehadiran dibuka 1 jam sebelum acara dimulai." />
<TamplateText text="Anda telah terdaftar sebagai peserta pada Event ini. Konfirmasi kehadiran dibuka 1 jam sebelum acara dimulai." />
<BackToOtherPath
path="event"
id={data.id}
@@ -326,7 +326,7 @@ const TamplateBox = ({
);
};
const TamplateText = ({ text }: { text: string }) => {
const TamplateText = ({ text }: { text: React.ReactNode }) => {
return (
<>
<TextCustom align="center">{text}</TextCustom>
@@ -442,7 +442,7 @@ const NotStarted_And_UserNotParticipan = ({
};
// 🟡 ZONA ACARA BERLANGSUNG
// Acara sedang berlangsung & belum terdaftar
// Acara sedang berlangsung & belum terdaftar & user harus join dan konfirmasi
const UserNotParticipan_And_DuringEvent = ({
id,
userId,
@@ -464,8 +464,6 @@ const UserNotParticipan_And_DuringEvent = ({
category: "join_and_confirm",
});
// console.log("[RES JOIN & CONFIRMATION EVENT]", response);
if (!response.success) {
Toast.show({
type: "error",
@@ -498,3 +496,59 @@ const UserNotParticipan_And_DuringEvent = ({
</>
);
};
// 🟡 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>
</>
);
};

View File

@@ -11,29 +11,30 @@ import {
apiEventGetOne,
apiEventListOfParticipants,
} from "@/service/api-client/api-event";
import { useLocalSearchParams } from "expo-router";
import { useEffect, useState } from "react";
import dayjs, { Dayjs } from "dayjs";
import { useFocusEffect, useLocalSearchParams } from "expo-router";
import _ from "lodash";
import { useCallback, useState } from "react";
import { View } from "react-native";
export default function EventListOfParticipants() {
const { id } = useLocalSearchParams();
const [startDate, setStartDate] = useState();
const [listData, setListData] = useState([]);
const [isLoadData, setIsLoadData] = useState(false);
const [startDate, setStartDate] = useState<Dayjs | undefined>();
const [listData, setListData] = useState<any[] | null>(null);
const [loadtData, setLoadData] = useState(false);
useEffect(() => {
handlerLoadData();
}, [id]);
useFocusEffect(
useCallback(() => {
handlerLoadData();
}, [id])
);
const handlerLoadData = () => {
try {
setIsLoadData(true);
onLoadData();
onLoadList();
} catch (error) {
console.log("[ERROR]", error);
} finally {
setIsLoadData(false);
}
};
@@ -41,7 +42,8 @@ export default function EventListOfParticipants() {
try {
const response = await apiEventGetOne({ id: id as string });
if (response.success) {
setStartDate(response.data.tanggal);
const date = dayjs(response.data.tanggal);
setStartDate(date);
}
} catch (error) {
console.log("[ERROR]", error);
@@ -50,30 +52,36 @@ export default function EventListOfParticipants() {
const onLoadList = async () => {
try {
setLoadData(true);
const response = await apiEventListOfParticipants({ id: id as string });
if (response.success) {
setListData(response.data);
}
} catch (error) {
console.log("[ERROR]", error);
} finally {
setLoadData(false);
}
};
return (
<ViewWrapper>
{isLoadData ? (
{loadtData && !listData ? (
<LoaderCustom />
) : listData.length === 0 ? (
<TextCustom align="center">Belum ada peserta</TextCustom>
) : _.isEmpty(listData) ? (
<TextCustom align="center" color="gray">
Belum ada peserta
</TextCustom>
) : (
listData.map((item: any, index: number) => (
listData?.map((item: any, index: number) => (
<BaseBox key={index}>
<AvatarUsernameAndOtherComponent
avatar={item?.User?.Profile?.imageId}
name={item?.User?.username}
avatarHref={`/profile/${item?.User?.Profile?.id}`}
rightComponent={
new Date().getTime() > new Date(startDate as any).getTime() ? (
startDate && startDate.subtract(1, "hour").diff(dayjs()) < 0 ? (
<View
style={{
justifyContent: "flex-end",

View File

@@ -1,3 +1,4 @@
/* eslint-disable react-hooks/exhaustive-deps */
import {
ActionIcon,
AlertDefaultSystem,
@@ -18,97 +19,153 @@ import AdminBackButtonAntTitle from "@/components/_ShareComponent/Admin/BackButt
import AdminButtonReject from "@/components/_ShareComponent/Admin/ButtonReject";
import AdminButtonReview from "@/components/_ShareComponent/Admin/ButtonReview";
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 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 { router, useLocalSearchParams } from "expo-router";
import { router, useFocusEffect, useLocalSearchParams } from "expo-router";
import _ from "lodash";
import React from "react";
import { View } from "react-native";
import Toast from "react-native-toast-message";
export default function AdminDonationDetail() {
const { id, status } = useLocalSearchParams();
const [openDrawer, setOpenDrawer] = React.useState(false);
const colorBadge = () => {
if (status === "publish") {
return MainColor.green;
} else if (status === "review") {
return MainColor.orange;
} else if (status === "reject") {
return MainColor.red;
} else {
return MainColor.placeholder;
const [data, setData] = React.useState<any | null>(null);
const [countDonatur, setCountDonatur] = React.useState(0);
const [isLoading, setIsLoading] = React.useState(false);
useFocusEffect(
React.useCallback(() => {
onLoadData();
}, [id])
);
const onLoadData = async () => {
try {
const response = await apiAdminDonationDetailById({
id: id as string,
});
console.log("[RES GET BY ID]", JSON.stringify(response, null, 2));
if (response.success) {
setData(response.data.donasi);
setCountDonatur(response.data.donatur);
}
} catch (error) {
console.log("[ERROR]", error);
setData(null);
}
};
const listData = [
{
label: "Penggalang Dana",
value: `Bagas Banuna ${id}`,
value: (data && data?.Author?.username) || "-",
},
{
label: "Judul",
value: `Donasi Lorem ipsum dolor sit amet, consectetur adipisicing elit.`,
value: (data && data?.title) || "-",
},
{
label: "Status",
value: (
<BadgeCustom color={colorBadge()}>
{_.startCase(status as string)}
</BadgeCustom>
),
value:
data && data?.DonasiMaster_Status?.name ? (
<BadgeCustom
color={colorBadgeStatus({ status: data?.DonasiMaster_Status?.name })}
>
{_.startCase(data?.DonasiMaster_Status?.name)}
</BadgeCustom>
) : (
"-"
),
},
{
label: "Durasi",
value: "30 Hari",
value: (data && data?.DonasiMaster_Durasi?.name) + " hari" || "-",
},
{
label: "Target Dana",
value: "Rp 10.000.000",
value:
data && data?.target
? `Rp. ${formatCurrencyDisplay(data?.target)}`
: "-",
},
{
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 = [
{
label: "Total Dana Dicairkan",
value: "Rp 0",
value: `Rp ${(data && data?.totalPencairan) || 0}`,
},
{
label: "Sisa Dana",
value: "Rp 0",
label: "Sisa Dana Masuk",
value: `Rp ${
(data &&
formatCurrencyDisplay(data?.terkumpul - data?.totalPencairan)) ||
0
}`,
},
{
label: "Akumulasi Pencairan",
value: "0 kali",
value: `${(data && data?.akumulasiPencairan) || 0} kali`,
},
{
label: "Bank Tujuan",
value: "BNI",
value: (data && data?.namaBank) || "-",
},
{
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 = (
<ActionIcon
icon={<IconDot size={ICON_SIZE_BUTTON} />}
@@ -118,8 +175,6 @@ export default function AdminDonationDetail() {
/>
);
return (
<>
<ViewWrapper
@@ -147,6 +202,7 @@ export default function AdminDonationDetail() {
/>
))}
</StackCustom>
<ButtonCustom
iconLeft={
<Ionicons name="cash-outline" size={ICON_SIZE_BUTTON} />
@@ -161,16 +217,33 @@ export default function AdminDonationDetail() {
</BaseBox>
<BaseBox>
<ProgressCustom size="lg" />
<ProgressCustom
size="lg"
value={Number(data?.progres) || 0}
showLabel={true}
label={data?.progres + "%"}
animated
color="primary"
/>
<Spacing />
<StackCustom gap={"xs"}>
<GridDetail_4_8
label={<TextCustom bold>Jumlah Donatur</TextCustom>}
value={<TextCustom>0 orang</TextCustom>}
value={
<TextCustom>
{countDonatur ? countDonatur : 0} orang
</TextCustom>
}
/>
<GridDetail_4_8
label={<TextCustom bold>Dana Terkumpul</TextCustom>}
value={<TextCustom>Rp 0</TextCustom>}
value={
<TextCustom>
Rp {formatCurrencyDisplay(data?.terkumpul || 0)}
</TextCustom>
}
/>
</StackCustom>
</BaseBox>
@@ -179,7 +252,7 @@ export default function AdminDonationDetail() {
<BaseBox>
<StackCustom>
<DummyLandscapeImage />
<DummyLandscapeImage imageId={data?.imageId || ""} />
{listData.map((item, i) => (
<GridDetail_4_8
key={i}
@@ -190,27 +263,33 @@ export default function AdminDonationDetail() {
</StackCustom>
</BaseBox>
<AdminDonation_BoxOfDonationStory data={data?.CeritaDonasi as any} />
{data &&
data?.catatan &&
(status === "review" || status === "reject") && (
<ReportBox text={data?.catatan} />
)}
{status === "review" && (
<StackCustom>
<AdminDonation_BoxOfDonationStory />
<AdminButtonReview
isLoading={isLoading}
onPublish={() => {
AlertDefaultSystem({
title: "Publish",
message: "Apakah anda yakin ingin mempublikasikan data ini?",
textLeft: "Batal",
textRight: "Ya",
onPressLeft: () => {
router.back();
},
onPressRight: () => {
router.back();
handleReport({ changeStatus: "publish" });
},
});
}}
onReject={() => {
router.push(`/admin/donation/${id}/reject-input`);
router.push(
`/admin/donation/${id}/reject-input?status=${status}`
);
}}
/>
</StackCustom>
@@ -218,12 +297,12 @@ export default function AdminDonationDetail() {
{status === "reject" && (
<StackCustom>
<AdminDonation_BoxOfDonationStory />
<AdminButtonReject
title="Tambah Catatan"
onReject={() => {
router.push(`/admin/donation/${id}/reject-input`);
router.push(
`/admin/donation/${id}/reject-input?status=${status}`
);
}}
/>
</StackCustom>

View File

@@ -9,51 +9,162 @@ import {
} from "@/components";
import AdminBackButtonAntTitle from "@/components/_ShareComponent/Admin/BackButtonAntTitle";
import { GridDetail_4_8 } from "@/components/_ShareComponent/GridDetail_4_8";
import { MainColor } from "@/constants/color-palet";
import dayjs from "dayjs";
import { router, useLocalSearchParams } from "expo-router";
import {
apiAdminDonationInvoiceDetailById,
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() {
const { id } = useLocalSearchParams();
const { id, status } = useLocalSearchParams();
console.log("[STATUS]", id, status);
const buttonAction = (
<BoxButtonOnFooter>
<ButtonCustom onPress={() => router.back()}>Terima</ButtonCustom>
</BoxButtonOnFooter>
const [data, setData] = useState<any | null>(null);
const [isLoading, setLoading] = useState(false);
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 = [
{
label: "Donatur",
value: "Bagas Banuna",
value: (data && data?.Author?.username) || "-",
},
{
label: "Bank",
value: "BCA",
value: (data && data?.MasterBank?.namaBank) || "-",
},
{
label: "Jumlah Donasi",
value: "Rp. 1.000.000",
value: `Rp. ${
(data && data?.nominal && formatCurrencyDisplay(data?.nominal)) || "-"
}`,
},
{
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",
value: dayjs().format("DD-MM-YYYY HH:mm:ss"),
value: (data && dateTimeView({ date: data?.createdAt })) || "-",
},
{
label: "Bukti Transfer",
value: (
<ButtonCustom
onPress={() =>
router.push(`/(application)/(image)/preview-image/${id}`)
}
>
Cek
</ButtonCustom>
),
value:
(data && data?.imageId && (
<ButtonCustom
onPress={() =>
router.push(
`/(application)/(image)/preview-image/${data?.imageId}`
)
}
>
Cek
</ButtonCustom>
)) ||
"-",
},
];
@@ -61,7 +172,7 @@ export default function AdminDonasiTransactionDetail() {
<>
<ViewWrapper
headerComponent={<AdminBackButtonAntTitle title="Detail Transaksi" />}
footerComponent={buttonAction}
footerComponent={buttonAction()}
>
<BaseBox>
<StackCustom>

View File

@@ -1,7 +1,9 @@
/* eslint-disable react-hooks/exhaustive-deps */
import {
ActionIcon,
BadgeCustom,
CenterCustom,
LoaderCustom,
SelectCustom,
StackCustom,
TextCustom,
@@ -10,23 +12,91 @@ import {
import { IconView } from "@/components/_Icon/IconComponent";
import AdminBackButtonAntTitle from "@/components/_ShareComponent/Admin/BackButtonAntTitle";
import { GridViewCustomSpan } from "@/components/_ShareComponent/GridViewCustomSpan";
import { MainColor } from "@/constants/color-palet";
import { ICON_SIZE_BUTTON } from "@/constants/constans-value";
import { dummyMasterStatusTransaction } from "@/lib/dummy-data/_master/status-transaction";
import { router, useLocalSearchParams } from "expo-router";
import React from "react";
import { apiAdminDonationListOfDonatur } from "@/service/api-admin/api-admin-donation";
import { apiMasterTransaction } from "@/service/api-client/api-master";
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 { Divider } from "react-native-paper";
export default function AdminDonasiListOfDonatur() {
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 = (
<View style={{ flexDirection: "row", gap: 5 }}>
<SelectCustom
placeholder="Pilih status transaksi"
data={dummyMasterStatusTransaction}
onChange={(value) => console.log(value)}
data={
_.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 }}
allowClear
/>
</View>
);
@@ -37,63 +107,78 @@ export default function AdminDonasiListOfDonatur() {
<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>
{Array.from({ length: 10 }).map((_, index) => (
<View key={index}>
<GridViewCustomSpan
span1={3}
span2={5}
span3={4}
component1={
<CenterCustom>
<ActionIcon
icon={<IconView size={ICON_SIZE_BUTTON} color="black" />}
onPress={() => {
router.push(
`/admin/donation/${id}/berhasil/transaction-detail`
);
}}
/>
</CenterCustom>
}
component2={
<TextCustom bold align="center" truncate>
Bagas Banuna
</TextCustom>
}
component3={
<BadgeCustom
style={{ alignSelf: "center" }}
color={MainColor.green}
>
Berhasil
</BadgeCustom>
}
/>
<Divider />
</View>
))}
<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>
{loadData ? (
<LoaderCustom />
) : _.isEmpty(listData) ? (
<TextCustom align="center" color="gray">
Belum ada data
</TextCustom>
) : (
listData?.map((item: any, index: number) => (
<View key={index}>
<GridViewCustomSpan
span1={3}
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>
</ViewWrapper>
</>

View File

@@ -1,3 +1,4 @@
/* eslint-disable react-hooks/exhaustive-deps */
import {
AlertDefaultSystem,
BoxButtonOnFooter,
@@ -6,15 +7,84 @@ import {
} 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";
import { funUpdateStatusDonation } from "@/screens/Admin/Donation/funDonationUpdateStatus";
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() {
const { id } = useLocalSearchParams();
const [value, setValue] = useState(id as string);
const { id, status } = useLocalSearchParams();
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 = (
<BoxButtonOnFooter>
<AdminButtonReject
isLoading={isLoading}
title="Reject"
onReject={() =>
AlertDefaultSystem({
@@ -22,12 +92,9 @@ export default function AdminDonationRejectInput() {
message: "Apakah anda yakin ingin menolak data ini?",
textLeft: "Batal",
textRight: "Ya",
onPressLeft: () => {
router.back();
},
onPressRight: () => {
console.log("value:", value);
router.replace(`/admin/donation/reject/status`);
handleReport({ changeStatus: "reject" });
},
})
}
@@ -42,8 +109,8 @@ export default function AdminDonationRejectInput() {
headerComponent={<AdminBackButtonAntTitle title="Penolakan Donasi" />}
>
<TextAreaCustom
value={value}
onChangeText={setValue}
value={data}
onChangeText={setData}
placeholder="Masukan alasan"
required
showCount

View File

@@ -1,69 +1,116 @@
/* eslint-disable react-hooks/exhaustive-deps */
import {
ActionIcon,
SearchInput,
Spacing,
TextCustom,
ViewWrapper
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 { apiAdminDonation } from "@/service/api-admin/api-admin-donation";
import { Octicons } from "@expo/vector-icons";
import { router, useLocalSearchParams } from "expo-router";
import { router, useFocusEffect, useLocalSearchParams } from "expo-router";
import _ from "lodash";
import { useCallback, useState } from "react";
import { Divider } from "react-native-paper";
export default function AdminDonationStatus() {
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 = (
<SearchInput
containerStyle={{ width: "100%", marginBottom: 0 }}
placeholder="Cari"
value={search}
onChangeText={(value) => setSearch(value)}
/>
);
return (
<>
<ViewWrapper
headerComponent={
<ViewWrapper headerComponent={<AdminTitlePage title="Donasi" />}>
<StackCustom gap={"sm"}>
<AdminComp_BoxTitle
title={`Donasi ${_.startCase(status as string)}`}
title={`${_.startCase(status as string)}`}
rightComponent={rightComponent}
/>
}
>
<AdminTitleTable
title1="Aksi"
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>
}
<AdminTitleTable
title1="Aksi"
title2="Username"
title3="Judul Donasi"
/>
))}
<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>
</>
);

View File

@@ -1,15 +1,67 @@
import { Spacing, StackCustom, ViewWrapper } from "@/components";
import {
IconList,
IconPublish,
IconReject,
IconReview,
IconList,
IconPublish,
IconReject,
IconReview,
} from "@/components/_Icon/IconComponent";
import AdminComp_BoxDashboard from "@/components/_ShareComponent/Admin/BoxDashboard";
import AdminTitlePage from "@/components/_ShareComponent/Admin/TitlePage";
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() {
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 (
<>
<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} />,
},
];

View File

@@ -1,15 +1,16 @@
/* eslint-disable react-hooks/exhaustive-deps */
import {
ActionIcon,
AlertDefaultSystem,
BadgeCustom,
BaseBox,
DrawerCustom,
MenuDrawerDynamicGrid,
Spacing,
StackCustom,
TextCustom,
ViewWrapper,
ActionIcon,
AlertDefaultSystem,
BadgeCustom,
BaseBox,
DrawerCustom,
LoaderCustom,
MenuDrawerDynamicGrid,
Spacing,
StackCustom,
TextCustom,
ViewWrapper,
} from "@/components";
import { IconDot, IconList } from "@/components/_Icon/IconComponent";
import AdminBackButtonAntTitle from "@/components/_ShareComponent/Admin/BackButtonAntTitle";
@@ -22,24 +23,21 @@ import { useAuth } from "@/hooks/use-auth";
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 { colorBadge } from "@/utils/colorBadge";
import { colorBadgeStatus } from "@/utils/colorBadge";
import { dateTimeView } from "@/utils/dateTimeView";
import { router, useFocusEffect, useLocalSearchParams } from "expo-router";
import _ from "lodash";
import React, { useCallback } from "react";
import QRCode from "react-native-qrcode-svg";
import Toast from "react-native-toast-message";
export default function AdminEventDetail() {
const { user } = useAuth();
const { id, status } = useLocalSearchParams();
console.log("[ID QRCODE]", id);
console.log("[STATUS Detail]", status);
const [openDrawer, setOpenDrawer] = React.useState(false);
const newURL = DEEP_LINK_URL
console.log("[DEEP LINK URL]", newURL);
const [data, setData] = React.useState<any | null>(null);
const [loadData, setLoadData] = React.useState(false);
const deepLinkURL = `${DEEP_LINK_URL}/--/event/${id}/confirmation?userId=${user?.id}`;
useFocusEffect(
useCallback(() => {
@@ -48,17 +46,18 @@ export default function AdminEventDetail() {
);
const onLoadData = async () => {
try {
setLoadData(true);
const response = await apiAdminEventById({
id: id as string,
});
// console.log(`[RES DATA BY ID: ${id}]`, JSON.stringify(response, null, 2));
if (response.success) {
setData(response.data);
}
} catch (error) {
console.log("[ERROR]", error);
} finally {
setLoadData(false);
}
};
@@ -75,7 +74,7 @@ export default function AdminEventDetail() {
label: "Status",
value:
(data && (
<BadgeCustom color={colorBadge({ status: status as string })}>
<BadgeCustom color={colorBadgeStatus({ status: status as string })}>
{_.startCase(status as string)}
</BadgeCustom>
)) ||
@@ -124,11 +123,19 @@ export default function AdminEventDetail() {
changeStatus: "publish",
});
console.log("[RES PUBLISH]", JSON.stringify(response, null, 2));
if (response.success) {
router.back();
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);
}
@@ -170,15 +177,19 @@ export default function AdminEventDetail() {
<BaseBox>
<StackCustom style={{ alignItems: "center" }}>
<TextCustom bold>QR Code Event</TextCustom>
<QRCode
value={deepLinkURL}
size={200}
// logo={require("@/assets/images/logo-hipmi.png")}
// logoSize={70}
// logoBackgroundColor="transparent"
// logoBorderRadius={50}
// color="black"
/>
{loadData ? (
<LoaderCustom />
) : (
<QRCode
value={deepLinkURL}
size={200}
// logo={require("@/assets/images/logo-hipmi.png")}
// logoSize={70}
// logoBackgroundColor="transparent"
// logoBorderRadius={50}
// color="black"
/>
)}
</StackCustom>
</BaseBox>
)}

View File

@@ -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 { 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() {
const { id } = useLocalSearchParams();
const [listData, setListData] = useState<any[] | null>(null);
const [loadData, setLoadData] = useState(false);
const isPresent = ({id}: {id: number}) => {
const check = id % 3 * 3;
if (check === 0) {
return true;
} else {
return false;
}
useFocusEffect(
useCallback(() => {
onLoadData();
}, [id])
);
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 (
<>
<ViewWrapper
headerComponent={<AdminBackButtonAntTitle title="Daftar Peserta" />}
>
{Array.from({ length: 10 }).map((item, index) => (
<BaseBox key={index}>
<Grid>
<Grid.Col span={6}>
<TextCustom bold>Username {index + 1}</TextCustom>
<TextCustom>+6282123456789</TextCustom>
</Grid.Col>
<Grid.Col span={6} style={{ justifyContent: "center" }}>
<BadgeCustom
style={{ alignSelf: "flex-end" }}
color={isPresent({id: index}) ? MainColor.green : MainColor.red}
>
{isPresent({id: index}) ? "Hadir" : "Tidak Hadir"}
</BadgeCustom>
</Grid.Col>
</Grid>
</BaseBox>
))}
{loadData ? (
<LoaderCustom />
) : _.isEmpty(listData) ? (
<TextCustom align="center" color="gray">
Belum ada peserta
</TextCustom>
) : (
listData?.map((item: any, index: number) => (
<BaseBox key={index}>
<Grid>
<Grid.Col span={6}>
<StackCustom gap={"sm"}>
<TextCustom bold truncate>{item?.User?.username}</TextCustom>
<TextCustom>+{item?.User?.nomor}</TextCustom>
</StackCustom>
</Grid.Col>
<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>
</>
);

View File

@@ -5,13 +5,48 @@ import {
ViewWrapper,
} from "@/components";
import AdminBackButtonAntTitle from "@/components/_ShareComponent/Admin/BackButtonAntTitle";
import { apiEventCreateTypeOfEvent } from "@/service/api-admin/api-master-admin";
import { useRouter } from "expo-router";
import { useState } from "react";
import Toast from "react-native-toast-message";
export default function AdminEventTypeOfEventCreate() {
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 = (
<BoxButtonOnFooter>
<ButtonCustom onPress={() => router.back()}>Simpan</ButtonCustom>
<ButtonCustom isLoading={isLoading} onPress={() => handlerSubmit()}>
Simpan
</ButtonCustom>
</BoxButtonOnFooter>
);
return (
@@ -20,7 +55,11 @@ export default function AdminEventTypeOfEventCreate() {
headerComponent={<AdminBackButtonAntTitle title="Tambah Tipe Acara" />}
footerComponent={buttonSubmit}
>
<TextInputCustom placeholder="Masukkan Tipe Acara" />
<TextInputCustom
placeholder="Masukkan Tipe Acara"
value={value}
onChangeText={setValue}
/>
</ViewWrapper>
</>
);

View File

@@ -1,23 +1,53 @@
import {
ActionIcon,
BaseBox,
BadgeCustom,
CenterCustom,
LoaderCustom,
Spacing,
StackCustom,
TextCustom,
ViewWrapper,
ViewWrapper
} from "@/components";
import { IconEdit } from "@/components/_Icon";
import AdminActionIconPlus from "@/components/_ShareComponent/Admin/ActionIconPlus";
import AdminComp_BoxTitle from "@/components/_ShareComponent/Admin/BoxTitlePage";
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 { 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 { Divider } from "react-native-paper";
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 (
<>
<ViewWrapper headerComponent={<AdminTitlePage title="Event" />}>
@@ -32,73 +62,68 @@ export default function AdminEventTypeOfEvent() {
}
/>
<BaseBox>
<GridDetail_4_8
label={
<>
<GridViewCustomSpan
span1={2}
span2={5}
span3={5}
component1={
<TextCustom bold align="center">
Aksi
</TextCustom>
}
value={<TextCustom bold>Tipe Acara</TextCustom>}
component2={<TextCustom bold align="center">Status</TextCustom>}
component3={<TextCustom bold>Tipe Acara</TextCustom>}
/>
<Divider />
<Spacing />
<StackCustom>
{listData.map((item, index) => (
<View key={index}>
<GridDetail_4_8
label={
<CenterCustom>
<ActionIcon
icon={
<IconEdit size={ICON_SIZE_BUTTON} color="black" />
}
onPress={() => {
router.push(`/admin/event/type-update?id=${index}`);
}}
/>
</CenterCustom>
}
value={<TextCustom bold>{item.label}</TextCustom>}
/>
<Divider />
</View>
))}
{loadData ? (
<LoaderCustom />
) : _.isEmpty(listData) ? (
<TextCustom align="center" color="gray">
Belum ada data
</TextCustom>
) : (
listData?.map((item, index) => (
<View key={index}>
<GridViewCustomSpan
span1={2}
span2={5}
span3={5}
component1={
<CenterCustom>
<ActionIcon
icon={
<IconEdit size={ICON_SIZE_BUTTON} color="black" />
}
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>
</BaseBox>
</>
</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",
},
];

View File

@@ -1,20 +1,91 @@
/* eslint-disable react-hooks/exhaustive-deps */
import {
BoxButtonOnFooter,
ButtonCustom,
Spacing,
TextCustom,
TextInputCustom,
ViewWrapper,
} from "@/components";
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() {
const { id } = useLocalSearchParams();
console.log("id >", id);
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 = (
<BoxButtonOnFooter>
<ButtonCustom onPress={() => router.back()}>Update</ButtonCustom>
<ButtonCustom isLoading={isLoading} onPress={() => handlerSubmit()}>
Update
</ButtonCustom>
</BoxButtonOnFooter>
);
return (
@@ -23,7 +94,19 @@ export default function AdminEventTypeOfEventUpdate() {
headerComponent={<AdminBackButtonAntTitle title="Ubah Tipe Acara" />}
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>
</>
);

View File

@@ -1,14 +1,14 @@
/* eslint-disable react-hooks/exhaustive-deps */
import {
AlertDefaultSystem,
BadgeCustom,
BaseBox,
CircleContainer,
Grid,
Spacing,
StackCustom,
TextCustom,
ViewWrapper,
AlertDefaultSystem,
BadgeCustom,
BaseBox,
CircleContainer,
Grid,
Spacing,
StackCustom,
TextCustom,
ViewWrapper,
} from "@/components";
import AdminBackButtonAntTitle from "@/components/_ShareComponent/Admin/BackButtonAntTitle";
import AdminButtonReject from "@/components/_ShareComponent/Admin/ButtonReject";
@@ -18,7 +18,7 @@ import ReportBox from "@/components/Box/ReportBox";
import { MainColor } from "@/constants/color-palet";
import funUpdateStatusVoting from "@/screens/Admin/Voting/funUpdateStatus";
import { apiAdminVotingById } from "@/service/api-admin/api-admin-voting";
import { colorBadge } from "@/utils/colorBadge";
import { colorBadgeStatus } from "@/utils/colorBadge";
import { dateTimeView } from "@/utils/dateTimeView";
import { Entypo } from "@expo/vector-icons";
import dayjs from "dayjs";
@@ -68,7 +68,7 @@ export default function AdminVotingDetail() {
label: "Status",
value:
data && data?.Voting_Status?.name ? (
<BadgeCustom color={colorBadge({ status: status as string })}>
<BadgeCustom color={colorBadgeStatus({ status: status as string })}>
{status === "history" ? "Riwayat" : _.startCase(status as string)}
</BadgeCustom>
) : (

View File

@@ -196,6 +196,7 @@ const DateTimeInput_Android: React.FC<DateTimeInputProps> = ({
onChange={handleConfirmTime}
minimumDate={minimumDate}
maximumDate={maximumDate}
themeVariant="light"
/>
)}
</>

View File

@@ -145,6 +145,7 @@ const DateTimeInput_IOS: React.FC<DateTimeInputProps> = ({
onChange={handleConfirm}
minimumDate={minimumDate}
maximumDate={maximumDate}
themeVariant="light"
/>
</View>
</>

View File

@@ -27,6 +27,8 @@ type SelectProps = {
onChange: (value: string | number) => void;
borderRadius?: number;
styleContainer?: StyleProp<ViewStyle>;
allowClear?: boolean; // <-- new prop
clearLabel?: string; // default: "Kosongkan"
};
const SelectCustom: React.FC<SelectProps> = ({
@@ -39,13 +41,21 @@ const SelectCustom: React.FC<SelectProps> = ({
onChange,
borderRadius = 8,
styleContainer,
allowClear = true, // bisa dimatikan jika tidak perlu
clearLabel = "Hapus Pilihan",
}) => {
const [modalVisible, setModalVisible] = useState(false);
const selectedItem = data.find((item) => item.value === value);
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 (
<View style={[GStyles.inputContainerArea, styleContainer]}>
{label && (
@@ -54,29 +64,64 @@ const SelectCustom: React.FC<SelectProps> = ({
{required && <Text style={GStyles.inputRequired}> *</Text>}
</Text>
)}
<Pressable
{/* Input Container */}
<View
style={[
{ borderRadius, },
hasError ? GStyles.inputErrorBorder : null,
{
flexDirection: "row",
alignItems: "center",
// backgroundColor: "red",
// flex: 1,
borderRadius,
},
GStyles.inputContainerInput,
hasError ? GStyles.inputErrorBorder : null,
disabled && GStyles.disabledBox,
]} // <-- add error style
onPress={() => !disabled && setModalVisible(true)}
]}
>
<Text
style={
selectedItem
? disabled
? GStyles.inputTextDisabled
: GStyles.inputText
: disabled
? GStyles.inputPlaceholderDisabled
: GStyles.inputPlaceholder
}
<Pressable
style={[
{
flex: 1,
borderRadius,
flexDirection: "row",
alignItems: "center",
paddingHorizontal: 10,
height: 50,
},
// GStyles.inputContainerInput,
// hasError ? GStyles.inputErrorBorder : null,
// disabled && GStyles.disabledBox,
]}
onPress={() => !disabled && setModalVisible(true)}
>
{selectedItem?.label || placeholder}
</Text>
</Pressable>
<Text
style={
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">
<TouchableOpacity
@@ -86,19 +131,38 @@ const SelectCustom: React.FC<SelectProps> = ({
>
<View style={GStyles.selectModalContent}>
<FlatList
data={data}
data={renderData}
keyExtractor={(item) => String(item.value)}
renderItem={({ item }) => (
<TouchableOpacity
style={GStyles.selectOption}
onPress={() => {
onChange(item.value);
setModalVisible(false);
}}
>
<Text>{item.label}</Text>
</TouchableOpacity>
)}
renderItem={({ item }) => {
if (item.value === "__clear__") {
return (
<TouchableOpacity
style={[
GStyles.selectOption,
{ backgroundColor: "#fdd" },
]}
onPress={() => {
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>
</TouchableOpacity>

View File

@@ -91,14 +91,11 @@ export const AuthProvider = ({ children }: { children: React.ReactNode }) => {
setToken(token);
await AsyncStorage.setItem("authToken", token);
const responseUser = await apiConfig.get(
`/mobile?token=${token}`,
{
headers: {
Authorization: `Bearer ${token}`,
},
}
);
const responseUser = await apiConfig.get(`/mobile?token=${token}`, {
headers: {
Authorization: `Bearer ${token}`,
},
});
const dataUser = responseUser.data.data;
setUser(dataUser);
@@ -147,9 +144,7 @@ export const AuthProvider = ({ children }: { children: React.ReactNode }) => {
await AsyncStorage.setItem("userData", JSON.stringify(dataUser));
return dataUser;
} catch (error: any) {
throw new Error(
error.response?.data?.message || "Gagal mengambil data user"
);
console.log(error.response?.data?.message + "user" || "Gagal mengambil data user");
} finally {
setIsLoading(false);
}

View File

@@ -6,7 +6,11 @@ import {
DummyLandscapeImage,
} from "@/components";
export default function AdminDonation_BoxOfDonationStory() {
export default function AdminDonation_BoxOfDonationStory({
data,
}: {
data: any;
}) {
return (
<>
<BaseBox>
@@ -14,19 +18,9 @@ export default function AdminDonation_BoxOfDonationStory() {
<Spacing />
<StackCustom>
<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>
<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>
<TextCustom>{(data && data?.pembukaan) || "-"}</TextCustom>
<DummyLandscapeImage imageId={data?.imageId || "-"} />
<TextCustom>{(data && data?.cerita) || "-"}</TextCustom>
</StackCustom>
</BaseBox>
</>

View 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;
}
};

View File

@@ -1,11 +1,14 @@
/* eslint-disable react-hooks/exhaustive-deps */
import {
BaseBox,
Grid,
DummyLandscapeImage,
Grid,
ProgressCustom,
StackCustom,
TextCustom,
ProgressCustom,
} from "@/components";
import { countDownAndCondition } from "@/utils/countDownAndCondition";
import { useEffect, useState } from "react";
import { View } from "react-native";
export default function Donation_BoxPublish({
@@ -15,6 +18,27 @@ export default function Donation_BoxPublish({
id: string;
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 (
<>
<BaseBox paddingTop={7} paddingBottom={7} href={`/donation/${id}`}>
@@ -36,13 +60,22 @@ export default function Donation_BoxPublish({
{data?.title || "-"}
</TextCustom>
<TextCustom size="small">
Sisa hari: {data?.durasiDonasi || 0}
{value.reminder ? (
<TextCustom bold color="red">
Waktu berakhir
</TextCustom>
) : (
<TextCustom>Sisa hari: {value.sisa}</TextCustom>
)}
</TextCustom>
</View>
<ProgressCustom
label={data?.progres + "%" || "0%"}
value={data?.progres || 0}
size="lg"
value={Number(data?.progres) || 0}
showLabel={true}
label={data?.progres + "%"}
animated
color="primary"
/>
{/* <TextCustom>
Terkumpul : Rp 300.000

View File

@@ -1,9 +1,9 @@
import {
BaseBox,
StackCustom,
DummyLandscapeImage,
TextCustom,
Grid,
StackCustom,
TextCustom,
} from "@/components";
import { formatCurrencyDisplay } from "@/utils/formatCurrencyDisplay";
import React from "react";
@@ -12,10 +12,15 @@ import { View } from "react-native";
export default function Donation_ComponentBoxDetailData({
bottomSection,
data,
sisaHari,
reminder,
}: {
bottomSection?: React.ReactNode;
data: any;
sisaHari: number;
reminder: boolean;
}) {
return (
<>
<BaseBox>
@@ -25,9 +30,13 @@ export default function Donation_ComponentBoxDetailData({
<TextCustom bold size="large">
{data?.title || "-"}
</TextCustom>
<TextCustom size="small">
Durasi: {data?.DonasiMaster_Durasi?.name || "-"}
</TextCustom>
{reminder ? (
<TextCustom bold color="red">
Waktu berakhir
</TextCustom>
) : (
<TextCustom>Sisa hari: {sisaHari}</TextCustom>
)}
</View>
<Grid>

View File

@@ -11,11 +11,23 @@ import { Ionicons, MaterialIcons } from "@expo/vector-icons";
import { router } from "expo-router";
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 (
<>
<View>
<ProgressCustom size="lg" />
<ProgressCustom
size="lg"
value={progres}
label={progres + "%"}
animated
color="primary"
/>
<Spacing />
<Grid>
<Grid.Col span={4}>

View File

@@ -0,0 +1,105 @@
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;
}
}

View File

@@ -48,3 +48,15 @@ export async function apiAdminEventUpdateStatus({
}
}
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;
}
}

View File

@@ -62,7 +62,9 @@ export async function apiAdminMasterBusinessField() {
export async function apiAdminMasterBusinessFieldById({ id }: { id: string }) {
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;
} catch (error) {
throw error;
@@ -77,26 +79,91 @@ export async function apiAdminMasterBusinessFieldUpdate({
data: any;
}) {
try {
const response = await apiConfig.put(`/mobile/admin/master/business-field/${id}`, {
data: data,
});
const response = await apiConfig.put(
`/mobile/admin/master/business-field/${id}`,
{
data: data,
}
);
return response.data;
} catch (error) {
throw error;
}
}
export async function apiAdminMasterBusinessFieldCreate({ data }: { data: any }) {
export async function apiAdminMasterBusinessFieldCreate({
data,
}: {
data: any;
}) {
try {
const response = await apiConfig.post(`/mobile/admin/master/business-field`, {
data: data,
});
const response = await apiConfig.post(
`/mobile/admin/master/business-field`,
{
data: data,
}
);
return response.data;
} catch (error) {
throw error;
}
}
// ================== 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 ================== //

View File

@@ -177,3 +177,5 @@ export async function apiEventConfirmationAction({
throw error;
}
}

View File

@@ -157,3 +157,14 @@ export async function apiMasterDonation({
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;
}
}

View 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;
}
};

View File

@@ -1,6 +1,6 @@
import { MainColor } from "@/constants/color-palet";
import { AccentColor, MainColor } from "@/constants/color-palet";
export const colorBadge = ({ status }: { status: string }) => {
export const colorBadgeStatus = ({ status }: { status: string }) => {
const statusLowerCase = status.toLowerCase();
if (statusLowerCase === "publish") {
return MainColor.green;
@@ -12,3 +12,16 @@ export const colorBadge = ({ status }: { status: string }) => {
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;
}
};

View 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,
};
}