();
const [isTimeStart, setIsTimeStart] = useState(false);
const [diffTimeStart, setDiffTimeStart] = useState(0);
const [isTimeEnd, setIsTimeEnd] = useState(false);
const [diffTimeEnd, setDiffTimeEnd] = useState(0);
-
const [value, setValue] = useState({
title: "",
lokasi: "",
@@ -42,24 +33,61 @@ export default function Event_Create({
tanggal: Date.toString(),
tanggalSelesai: Date.toString(),
eventMaster_TipeAcaraId: 0,
- authorId: authorId,
+ authorId: "",
});
+ useShallowEffect(() => {
+ handleGetUserLoginId();
+ }, []);
+
+ async function handleGetUserLoginId() {
+ try {
+ const response = await apiNewGetUserIdByToken();
+ if (response.success) {
+ setValue({
+ ...value,
+ authorId: response.userId,
+ });
+ }
+ } catch (error) {
+ setValue({
+ ...value,
+ authorId: "",
+ });
+ }
+ }
+
+ useShallowEffect(() => {
+ handleGetMasterTipeAcara();
+ }, []);
+
+ async function handleGetMasterTipeAcara() {
+ try {
+ const response = await apiGetMasterTipeAcara();
+ if (response.success) {
+ setListTipe(response.data);
+ } else {
+ setListTipe([]);
+ }
+ } catch (error) {
+ setListTipe([]);
+ }
+ }
+
+ if (!listTipe || !value.authorId) {
+ return ;
+ }
+
return (
<>
{/* {JSON.stringify(value, null, 2)} */}
-
+
- {/*
- */}
-
();
const eventId = params.id;
const [isLoading, setLoading] = useState(false);
const [isJoinSuccess, setIsJoinSuccess] = useState(null);
// const [isNewPeserta, setIsNewPeserta] = useState(null);
+ const [userLoginId, setUserLoginId] = useState(null);
+
useShallowEffect(() => {
- onCheckPeserta();
+ handleGetUserLoginId();
}, []);
- async function onCheckPeserta() {
+ async function handleGetUserLoginId() {
try {
- const respone = await apiGetEventCekPeserta({
- userId: userLoginId,
- eventId: eventId,
- });
+ const response = await apiNewGetUserIdByToken();
+ if (response.success) {
+ setUserLoginId(response.userId);
+ const responseData = await apiGetEventCekPeserta({
+ userId: response.userId,
+ eventId: eventId,
+ });
- if (respone) {
- setIsJoinSuccess(respone.data);
+ if (responseData) {
+ setIsJoinSuccess(responseData.data);
+ }
+ } else {
+ setUserLoginId(null);
}
} catch (error) {
- clientLogger.error("Error check peserta", error);
+ setUserLoginId(null);
}
}
+ // useShallowEffect(() => {
+ // onCheckPeserta();
+ // }, []);
+
+ // async function onCheckPeserta() {
+ // try {
+ // const respone = await apiGetEventCekPeserta({
+ // userId: userLoginId,
+ // eventId: eventId,
+ // });
+
+ // if (respone) {
+ // setIsJoinSuccess(respone.data);
+ // }
+ // } catch (error) {
+ // clientLogger.error("Error check peserta", error);
+ // }
+ // }
+
// [ON JOIN BUTTON]
async function onJoin() {
const body = {
@@ -97,7 +121,7 @@ export default function Event_DetailMain({
- {isJoinSuccess == null ? (
+ {isJoinSuccess == null || !userLoginId ? (
) : isJoinSuccess ? (
- {/*
-
- ) : (
- ""
- )
- }
- onChange={(val) => {
- setValue({
- ...value,
- deskripsi: val.target.value,
- });
- }}
- />
-
- */}
-