Fix create profile

This commit is contained in:
2024-12-10 11:11:45 +08:00
parent 8f5acae10d
commit b2e48ba06c
4 changed files with 96 additions and 50 deletions

View File

@@ -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]);

View File

@@ -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() {

View File

@@ -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
// profile={e?.User?.Profile as any}
// sizeAvatar={30}
// fontSize={"sm"}
// tanggalMulai={e?.Event?.tanggal}
// tanggalSelesai={e?.Event?.tanggalSelesai}
// isPresent={e?.isPresent}
// />
// {/* <Divider /> */}
// </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 <ComponentEvent_AvatarAndUsername
profile={e?.User?.Profile as any} profile={item?.User?.Profile as any}
sizeAvatar={30} sizeAvatar={30}
fontSize={"sm"} fontSize={"sm"}
tanggalMulai={e?.Event?.tanggal} tanggalMulai={item?.Event?.tanggal}
tanggalSelesai={e?.Event?.tanggalSelesai} tanggalSelesai={item?.Event?.tanggalSelesai}
isPresent={e?.isPresent} isPresent={item?.isPresent}
/> />
)}
{/* <Divider /> */} </ScrollOnly>
</Stack>
))}
</Stack>
)} )}
</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>

View File

@@ -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,10 +62,12 @@ export function Profile_ComponentCreateNewProfile({
); );
} }
if (uploadPhoto.success) {
const uploadBackground = await funGlobal_UploadToStorage({ const uploadBackground = await funGlobal_UploadToStorage({
file: fileBG, file: fileBG,
dirId: DIRECTORY_ID.profile_background, dirId: DIRECTORY_ID.profile_background,
}); });
// console.log("ini background", uploadBackground);
if (!uploadBackground.success) { if (!uploadBackground.success) {
setLoading(false); setLoading(false);
return ComponentGlobal_NotifikasiPeringatan( return ComponentGlobal_NotifikasiPeringatan(
@@ -72,19 +75,24 @@ export function Profile_ComponentCreateNewProfile({
); );
} }
if (uploadBackground.success) {
const create = await funCreateNewProfile({ const create = await funCreateNewProfile({
data: newData as any, data: newData as any,
imageId: uploadPhoto.data.id, imageId: uploadPhoto.data.id,
imageBackgroundId: uploadBackground.data.id, imageBackgroundId: uploadBackground.data.id,
}); });
if (create.status === 201) { if (create.status === 201) {
ComponentGlobal_NotifikasiBerhasil("Berhasil membuat profile", 3000); ComponentGlobal_NotifikasiBerhasil(
"Berhasil membuat profile",
3000
);
router.push(RouterHome.main_home, { scroll: false }); router.push(RouterHome.main_home, { scroll: false });
} else { } else {
ComponentGlobal_NotifikasiGagal(create.message); ComponentGlobal_NotifikasiGagal(create.message);
setLoading(false); setLoading(false);
} }
}
}
} catch (error) { } catch (error) {
console.log(error); console.log(error);
} }