Fix create profile
This commit is contained in:
@@ -54,7 +54,7 @@ function TableStatus({ listPublish }: { listPublish: any }) {
|
|||||||
|
|
||||||
useShallowEffect(() => {
|
useShallowEffect(() => {
|
||||||
if (typeof window !== "undefined") {
|
if (typeof window !== "undefined") {
|
||||||
console.log(window.location.origin);
|
// console.log(window.location.origin);
|
||||||
setOrigin(window.location.origin);
|
setOrigin(window.location.origin);
|
||||||
}
|
}
|
||||||
}, [setOrigin]);
|
}, [setOrigin]);
|
||||||
|
|||||||
@@ -135,16 +135,6 @@ export default function Ui_Konfirmasi({
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Jika sudah join, sudah konfirmasi dan tanggal mulai acara sudah lewat
|
|
||||||
// if (isPresent && moment(data?.tanggal).diff(moment(), "minute") < 0)
|
|
||||||
if (
|
|
||||||
isPresent &&
|
|
||||||
isJoin &&
|
|
||||||
moment(data?.tanggal).diff(moment(), "minute") < 0
|
|
||||||
) {
|
|
||||||
return <UserAlreadyConfirm title={data.title} />;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isPresent == false && data) {
|
if (isPresent == false && data) {
|
||||||
return (
|
return (
|
||||||
<UserNotConfirm
|
<UserNotConfirm
|
||||||
@@ -154,6 +144,16 @@ export default function Ui_Konfirmasi({
|
|||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Jika sudah join, sudah konfirmasi dan tanggal mulai acara sudah lewat
|
||||||
|
// if (isPresent && moment(data?.tanggal).diff(moment(), "minute") < 0)
|
||||||
|
if (
|
||||||
|
isPresent &&
|
||||||
|
isJoin &&
|
||||||
|
moment(data?.tanggal).diff(moment(), "minute") < 0
|
||||||
|
) {
|
||||||
|
return <UserAlreadyConfirm title={data.title} />;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function DataNotFound() {
|
function DataNotFound() {
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import {
|
|||||||
Center,
|
Center,
|
||||||
Grid,
|
Grid,
|
||||||
Group,
|
Group,
|
||||||
|
Loader,
|
||||||
Skeleton,
|
Skeleton,
|
||||||
Stack,
|
Stack,
|
||||||
Text,
|
Text,
|
||||||
@@ -31,6 +32,8 @@ import moment from "moment";
|
|||||||
import { useShallowEffect } from "@mantine/hooks";
|
import { useShallowEffect } from "@mantine/hooks";
|
||||||
import { API_RouteEvent } from "@/app/lib/api_user_router/route_api_event";
|
import { API_RouteEvent } from "@/app/lib/api_user_router/route_api_event";
|
||||||
import Event_ComponentSkeletonListPeserta from "../skeleton/comp_skeleton_list_peserta";
|
import Event_ComponentSkeletonListPeserta from "../skeleton/comp_skeleton_list_peserta";
|
||||||
|
import { ScrollOnly } from "next-scroll-loader";
|
||||||
|
import { event_newGetListPesertaById } from "../../fun";
|
||||||
|
|
||||||
export default function ComponentEvent_ListPeserta({
|
export default function ComponentEvent_ListPeserta({
|
||||||
total,
|
total,
|
||||||
@@ -43,6 +46,7 @@ export default function ComponentEvent_ListPeserta({
|
|||||||
}) {
|
}) {
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const [data, setData] = useState<MODEL_EVENT_PESERTA[] | null>(null);
|
const [data, setData] = useState<MODEL_EVENT_PESERTA[] | null>(null);
|
||||||
|
const [activePage, setActivePage] = useState<number>(1);
|
||||||
|
|
||||||
useShallowEffect(() => {
|
useShallowEffect(() => {
|
||||||
onLoadPeserta();
|
onLoadPeserta();
|
||||||
@@ -80,22 +84,53 @@ export default function ComponentEvent_ListPeserta({
|
|||||||
</Text>
|
</Text>
|
||||||
</Center>
|
</Center>
|
||||||
) : (
|
) : (
|
||||||
<Stack>
|
// <Stack>
|
||||||
{data.map((e, i) => (
|
// {data.map((e, i) => (
|
||||||
<Stack key={i} spacing={"sm"}>
|
// <Stack key={i} spacing={"sm"}>
|
||||||
<ComponentEvent_AvatarAndUsername
|
// <ComponentEvent_AvatarAndUsername
|
||||||
profile={e?.User?.Profile as any}
|
// profile={e?.User?.Profile as any}
|
||||||
sizeAvatar={30}
|
// sizeAvatar={30}
|
||||||
fontSize={"sm"}
|
// fontSize={"sm"}
|
||||||
tanggalMulai={e?.Event?.tanggal}
|
// tanggalMulai={e?.Event?.tanggal}
|
||||||
tanggalSelesai={e?.Event?.tanggalSelesai}
|
// tanggalSelesai={e?.Event?.tanggalSelesai}
|
||||||
isPresent={e?.isPresent}
|
// isPresent={e?.isPresent}
|
||||||
/>
|
// />
|
||||||
|
|
||||||
{/* <Divider /> */}
|
// {/* <Divider /> */}
|
||||||
</Stack>
|
// </Stack>
|
||||||
))}
|
// ))}
|
||||||
</Stack>
|
// </Stack>
|
||||||
|
<ScrollOnly
|
||||||
|
height="90vh"
|
||||||
|
renderLoading={() => (
|
||||||
|
<Center mt={"lg"}>
|
||||||
|
<Loader color={"yellow"} />
|
||||||
|
</Center>
|
||||||
|
)}
|
||||||
|
data={data}
|
||||||
|
setData={setData as any}
|
||||||
|
moreData={async () => {
|
||||||
|
const loadData = await event_newGetListPesertaById({
|
||||||
|
eventId: eventId as string,
|
||||||
|
page: activePage + 1,
|
||||||
|
});
|
||||||
|
|
||||||
|
setActivePage((val) => val + 1);
|
||||||
|
|
||||||
|
return loadData;
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{(item) => (
|
||||||
|
<ComponentEvent_AvatarAndUsername
|
||||||
|
profile={item?.User?.Profile as any}
|
||||||
|
sizeAvatar={30}
|
||||||
|
fontSize={"sm"}
|
||||||
|
tanggalMulai={item?.Event?.tanggal}
|
||||||
|
tanggalSelesai={item?.Event?.tanggalSelesai}
|
||||||
|
isPresent={item?.isPresent}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
</ScrollOnly>
|
||||||
)}
|
)}
|
||||||
</Stack>
|
</Stack>
|
||||||
</ComponentGlobal_CardStyles>
|
</ComponentGlobal_CardStyles>
|
||||||
@@ -139,7 +174,6 @@ function ComponentEvent_AvatarAndUsername({
|
|||||||
|
|
||||||
const tglMulai = moment(tanggalMulai).diff(moment(), "minutes") < 0;
|
const tglMulai = moment(tanggalMulai).diff(moment(), "minutes") < 0;
|
||||||
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Grid align="flex-start" justify="space-around">
|
<Grid align="flex-start" justify="space-around">
|
||||||
@@ -180,7 +214,11 @@ function ComponentEvent_AvatarAndUsername({
|
|||||||
<Group position="right">
|
<Group position="right">
|
||||||
<Stack justify="center" h={30}>
|
<Stack justify="center" h={30}>
|
||||||
<Text fw={"bold"} fz={fontSize ? fontSize : "sm"}>
|
<Text fw={"bold"} fz={fontSize ? fontSize : "sm"}>
|
||||||
{isPresent ? <Badge color="green" >Hadir</Badge> : <Badge>-</Badge>}
|
{isPresent ? (
|
||||||
|
<Badge color="green">Hadir</Badge>
|
||||||
|
) : (
|
||||||
|
<Badge>-</Badge>
|
||||||
|
)}
|
||||||
</Text>
|
</Text>
|
||||||
</Stack>
|
</Stack>
|
||||||
</Group>
|
</Group>
|
||||||
|
|||||||
@@ -54,6 +54,7 @@ export function Profile_ComponentCreateNewProfile({
|
|||||||
file: filePP,
|
file: filePP,
|
||||||
dirId: DIRECTORY_ID.profile_foto,
|
dirId: DIRECTORY_ID.profile_foto,
|
||||||
});
|
});
|
||||||
|
// console.log("ini foto", uploadPhoto);
|
||||||
if (!uploadPhoto.success) {
|
if (!uploadPhoto.success) {
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
return ComponentGlobal_NotifikasiPeringatan(
|
return ComponentGlobal_NotifikasiPeringatan(
|
||||||
@@ -61,29 +62,36 @@ export function Profile_ComponentCreateNewProfile({
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const uploadBackground = await funGlobal_UploadToStorage({
|
if (uploadPhoto.success) {
|
||||||
file: fileBG,
|
const uploadBackground = await funGlobal_UploadToStorage({
|
||||||
dirId: DIRECTORY_ID.profile_background,
|
file: fileBG,
|
||||||
});
|
dirId: DIRECTORY_ID.profile_background,
|
||||||
if (!uploadBackground.success) {
|
});
|
||||||
setLoading(false);
|
// console.log("ini background", uploadBackground);
|
||||||
return ComponentGlobal_NotifikasiPeringatan(
|
if (!uploadBackground.success) {
|
||||||
"Gagal upload background profile"
|
setLoading(false);
|
||||||
);
|
return ComponentGlobal_NotifikasiPeringatan(
|
||||||
}
|
"Gagal upload background profile"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
const create = await funCreateNewProfile({
|
if (uploadBackground.success) {
|
||||||
data: newData as any,
|
const create = await funCreateNewProfile({
|
||||||
imageId: uploadPhoto.data.id,
|
data: newData as any,
|
||||||
imageBackgroundId: uploadBackground.data.id,
|
imageId: uploadPhoto.data.id,
|
||||||
});
|
imageBackgroundId: uploadBackground.data.id,
|
||||||
|
});
|
||||||
if (create.status === 201) {
|
if (create.status === 201) {
|
||||||
ComponentGlobal_NotifikasiBerhasil("Berhasil membuat profile", 3000);
|
ComponentGlobal_NotifikasiBerhasil(
|
||||||
router.push(RouterHome.main_home, { scroll: false });
|
"Berhasil membuat profile",
|
||||||
} else {
|
3000
|
||||||
ComponentGlobal_NotifikasiGagal(create.message);
|
);
|
||||||
setLoading(false);
|
router.push(RouterHome.main_home, { scroll: false });
|
||||||
|
} else {
|
||||||
|
ComponentGlobal_NotifikasiGagal(create.message);
|
||||||
|
setLoading(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log(error);
|
console.log(error);
|
||||||
|
|||||||
Reference in New Issue
Block a user