Add: components/Button/BackButtonFromNotification.tsx types/type-collect-other.ts Fix: - android/app/build.gradle - app/(application)/(user)/_layout.tsx - app/(application)/(user)/event/(tabs)/_layout.tsx - app/(application)/(user)/event/(tabs)/status.tsx - app/(application)/(user)/event/create.tsx - app/(application)/(user)/job/(tabs)/_layout.tsx - app/(application)/(user)/notifications/index.tsx - app/(application)/admin/event/[id]/[status]/index.tsx - app/(application)/admin/event/[id]/reject-input.tsx - app/(application)/admin/notification/index.tsx - components/Notification/NotificationInitializer.tsx - hipmi-note.md - hooks/use-notification-store.tsx - screens/Admin/Event/funUpdateStatus.ts - service/api-notifications.ts - utils/formatChatTime.ts ### No Issue
127 lines
3.0 KiB
TypeScript
127 lines
3.0 KiB
TypeScript
/* 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 { useAuth } from "@/hooks/use-auth";
|
|
import { funUpdateStatusEvent } from "@/screens/Admin/Event/funUpdateStatus";
|
|
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() {
|
|
const { user } = useAuth();
|
|
const { id, status } = useLocalSearchParams();
|
|
|
|
const [data, setData] = useState<any>({
|
|
catatan: "",
|
|
senderId: "",
|
|
});
|
|
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 newData = {
|
|
catatan: data,
|
|
senderId: user?.id as string,
|
|
};
|
|
|
|
const response = await funUpdateStatusEvent({
|
|
id: id as string,
|
|
changeStatus,
|
|
data: newData,
|
|
});
|
|
|
|
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 = (
|
|
<BoxButtonOnFooter>
|
|
<AdminButtonReject
|
|
isLoading={isLoading}
|
|
title="Reject"
|
|
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 Event" />}
|
|
>
|
|
<TextAreaCustom
|
|
value={data}
|
|
onChangeText={setData}
|
|
placeholder="Masukan alasan"
|
|
required
|
|
showCount
|
|
maxLength={1000}
|
|
/>
|
|
</ViewWrapper>
|
|
</>
|
|
);
|
|
}
|