Event – User - app/(application)/(user)/event/(tabs)/contribution.tsx - app/(application)/(user)/event/(tabs)/index.tsx - app/(application)/(user)/event/[id]/list-of-participants.tsx Voting – User - app/(application)/(user)/voting/(tabs)/history.tsx Components - components/Notification/NotificationInitializer.tsx - components/_ShareComponent/NewWrapper.tsx Screens – Event - screens/Event/BoxPublishSection.tsx - screens/Event/ButtonStatusSection.tsx - screens/Event/ScreenHistory.tsx - screens/Event/ScreenStatus.tsx Screens – Forum - screens/Forum/ViewBeranda3.tsx API Client - service/api-client/api-event.ts Styles - styles/global-styles.ts Docs - docs/prompt-for-qwen-code.md Untracked (New Files) - screens/Event/ScreenBeranda.tsx - screens/Event/ScreenContribution.tsx - screens/Event/ScreenListOfParticipants.tsx #### No Issue
209 lines
5.0 KiB
TypeScript
209 lines
5.0 KiB
TypeScript
import { AlertDefaultSystem, ButtonCustom, Grid } from "@/components";
|
|
import {
|
|
apiEventDelete,
|
|
apiEventUpdateStatus,
|
|
} from "@/service/api-client/api-event";
|
|
import { router } from "expo-router";
|
|
import Toast from "react-native-toast-message";
|
|
|
|
export default function Event_ButtonStatusSection({
|
|
id,
|
|
status,
|
|
}: {
|
|
id: string;
|
|
status: string;
|
|
}) {
|
|
const handleBatalkanReview = () => {
|
|
AlertDefaultSystem({
|
|
title: "Batalkan Review",
|
|
message: "Apakah Anda yakin ingin batalkan review ini?",
|
|
textLeft: "Batal",
|
|
textRight: "Ya",
|
|
onPressRight: async () => {
|
|
try {
|
|
const response = await apiEventUpdateStatus({
|
|
id: id,
|
|
status: "draft",
|
|
});
|
|
|
|
if (response.success) {
|
|
Toast.show({
|
|
type: "success",
|
|
text1: response.message,
|
|
});
|
|
router.replace(`/event/(tabs)/status?status=draft`);
|
|
} else {
|
|
Toast.show({
|
|
type: "info",
|
|
text1: "Info",
|
|
text2: response.message,
|
|
});
|
|
router.back();
|
|
}
|
|
} catch (error) {
|
|
console.log("[ERROR]", error);
|
|
}
|
|
},
|
|
});
|
|
};
|
|
|
|
const handleAjukanReview = () => {
|
|
AlertDefaultSystem({
|
|
title: "Ajukan Review",
|
|
message: "Apakah Anda yakin ingin ajukan review ini?",
|
|
textLeft: "Batal",
|
|
textRight: "Ya",
|
|
onPressRight: async () => {
|
|
try {
|
|
const response = await apiEventUpdateStatus({
|
|
id: id,
|
|
status: "review",
|
|
});
|
|
|
|
if (response.success) {
|
|
Toast.show({
|
|
type: "success",
|
|
text1: response.message,
|
|
});
|
|
router.replace(`/event/(tabs)/status?status=review`);
|
|
} else {
|
|
Toast.show({
|
|
type: "info",
|
|
text1: "Info",
|
|
text2: response.message,
|
|
});
|
|
router.back();
|
|
}
|
|
} catch (error) {
|
|
console.log("[ERROR]", error);
|
|
}
|
|
},
|
|
});
|
|
};
|
|
|
|
const handleEditKembali = () => {
|
|
AlertDefaultSystem({
|
|
title: "Edit Kembali",
|
|
message: "Apakah Anda yakin ingin edit kembali ini?",
|
|
textLeft: "Batal",
|
|
textRight: "Ya",
|
|
onPressRight: async () => {
|
|
try {
|
|
const response = await apiEventUpdateStatus({
|
|
id: id,
|
|
status: "draft",
|
|
});
|
|
|
|
if (response.success) {
|
|
Toast.show({
|
|
type: "success",
|
|
text1: response.message,
|
|
});
|
|
router.replace(`/event/(tabs)/status?status=draft`);
|
|
} else {
|
|
Toast.show({
|
|
type: "info",
|
|
text1: "Info",
|
|
text2: response.message,
|
|
});
|
|
router.back();
|
|
}
|
|
} catch (error) {
|
|
console.log("[ERROR]", error);
|
|
}
|
|
},
|
|
});
|
|
};
|
|
|
|
const handleOpenDeleteAlert = () => {
|
|
AlertDefaultSystem({
|
|
title: "Hapus",
|
|
message: "Apakah Anda yakin ingin menghapus data ini?",
|
|
textLeft: "Batal",
|
|
textRight: "Hapus",
|
|
onPressRight: async () => {
|
|
try {
|
|
const response = await apiEventDelete({ id: id });
|
|
if (response.success) {
|
|
Toast.show({
|
|
type: "success",
|
|
text1: "Data dihapus",
|
|
});
|
|
router.back();
|
|
} else {
|
|
Toast.show({
|
|
type: "info",
|
|
text1: "Info",
|
|
text2: response.message,
|
|
});
|
|
router.back();
|
|
}
|
|
} catch (error) {
|
|
console.log("[ERROR]", error);
|
|
}
|
|
},
|
|
});
|
|
};
|
|
|
|
const DeleteButton = () => {
|
|
return (
|
|
<>
|
|
<ButtonCustom
|
|
backgroundColor="red"
|
|
textColor="white"
|
|
onPress={handleOpenDeleteAlert}
|
|
>
|
|
Hapus
|
|
</ButtonCustom>
|
|
</>
|
|
);
|
|
};
|
|
|
|
switch (status) {
|
|
case "publish":
|
|
return <></>;
|
|
|
|
case "review":
|
|
return (
|
|
<ButtonCustom onPress={handleBatalkanReview}>
|
|
Batalkan Review
|
|
</ButtonCustom>
|
|
);
|
|
|
|
case "draft":
|
|
return (
|
|
<>
|
|
<Grid>
|
|
<Grid.Col span={6} style={{ paddingRight: 10 }}>
|
|
<ButtonCustom onPress={handleAjukanReview}>
|
|
Ajukan Review
|
|
</ButtonCustom>
|
|
</Grid.Col>
|
|
<Grid.Col span={6} style={{ paddingLeft: 10 }}>
|
|
{DeleteButton()}
|
|
</Grid.Col>
|
|
</Grid>
|
|
</>
|
|
);
|
|
|
|
case "reject":
|
|
return (
|
|
<>
|
|
<Grid>
|
|
<Grid.Col span={6} style={{ paddingRight: 10 }}>
|
|
<ButtonCustom onPress={handleEditKembali}>
|
|
Edit Kembali
|
|
</ButtonCustom>
|
|
</Grid.Col>
|
|
<Grid.Col span={6} style={{ paddingLeft: 10 }}>
|
|
{DeleteButton()}
|
|
</Grid.Col>
|
|
</Grid>
|
|
</>
|
|
);
|
|
|
|
default:
|
|
return <ButtonCustom disabled>Status Undifined</ButtonCustom>;
|
|
}
|
|
}
|