Fix create profile
This commit is contained in:
@@ -54,7 +54,7 @@ function TableStatus({ listPublish }: { listPublish: any }) {
|
||||
|
||||
useShallowEffect(() => {
|
||||
if (typeof window !== "undefined") {
|
||||
console.log(window.location.origin);
|
||||
// console.log(window.location.origin);
|
||||
setOrigin(window.location.origin);
|
||||
}
|
||||
}, [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) {
|
||||
return (
|
||||
<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() {
|
||||
|
||||
@@ -7,6 +7,7 @@ import {
|
||||
Center,
|
||||
Grid,
|
||||
Group,
|
||||
Loader,
|
||||
Skeleton,
|
||||
Stack,
|
||||
Text,
|
||||
@@ -31,6 +32,8 @@ import moment from "moment";
|
||||
import { useShallowEffect } from "@mantine/hooks";
|
||||
import { API_RouteEvent } from "@/app/lib/api_user_router/route_api_event";
|
||||
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({
|
||||
total,
|
||||
@@ -43,6 +46,7 @@ export default function ComponentEvent_ListPeserta({
|
||||
}) {
|
||||
const router = useRouter();
|
||||
const [data, setData] = useState<MODEL_EVENT_PESERTA[] | null>(null);
|
||||
const [activePage, setActivePage] = useState<number>(1);
|
||||
|
||||
useShallowEffect(() => {
|
||||
onLoadPeserta();
|
||||
@@ -80,22 +84,53 @@ export default function ComponentEvent_ListPeserta({
|
||||
</Text>
|
||||
</Center>
|
||||
) : (
|
||||
<Stack>
|
||||
{data.map((e, i) => (
|
||||
<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}
|
||||
/>
|
||||
// <Stack>
|
||||
// {data.map((e, i) => (
|
||||
// <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>
|
||||
// {/* <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
|
||||
profile={item?.User?.Profile as any}
|
||||
sizeAvatar={30}
|
||||
fontSize={"sm"}
|
||||
tanggalMulai={item?.Event?.tanggal}
|
||||
tanggalSelesai={item?.Event?.tanggalSelesai}
|
||||
isPresent={item?.isPresent}
|
||||
/>
|
||||
)}
|
||||
</ScrollOnly>
|
||||
)}
|
||||
</Stack>
|
||||
</ComponentGlobal_CardStyles>
|
||||
@@ -139,7 +174,6 @@ function ComponentEvent_AvatarAndUsername({
|
||||
|
||||
const tglMulai = moment(tanggalMulai).diff(moment(), "minutes") < 0;
|
||||
|
||||
|
||||
return (
|
||||
<>
|
||||
<Grid align="flex-start" justify="space-around">
|
||||
@@ -180,7 +214,11 @@ function ComponentEvent_AvatarAndUsername({
|
||||
<Group position="right">
|
||||
<Stack justify="center" h={30}>
|
||||
<Text fw={"bold"} fz={fontSize ? fontSize : "sm"}>
|
||||
{isPresent ? <Badge color="green" >Hadir</Badge> : <Badge>-</Badge>}
|
||||
{isPresent ? (
|
||||
<Badge color="green">Hadir</Badge>
|
||||
) : (
|
||||
<Badge>-</Badge>
|
||||
)}
|
||||
</Text>
|
||||
</Stack>
|
||||
</Group>
|
||||
|
||||
@@ -54,6 +54,7 @@ export function Profile_ComponentCreateNewProfile({
|
||||
file: filePP,
|
||||
dirId: DIRECTORY_ID.profile_foto,
|
||||
});
|
||||
// console.log("ini foto", uploadPhoto);
|
||||
if (!uploadPhoto.success) {
|
||||
setLoading(false);
|
||||
return ComponentGlobal_NotifikasiPeringatan(
|
||||
@@ -61,29 +62,36 @@ export function Profile_ComponentCreateNewProfile({
|
||||
);
|
||||
}
|
||||
|
||||
const uploadBackground = await funGlobal_UploadToStorage({
|
||||
file: fileBG,
|
||||
dirId: DIRECTORY_ID.profile_background,
|
||||
});
|
||||
if (!uploadBackground.success) {
|
||||
setLoading(false);
|
||||
return ComponentGlobal_NotifikasiPeringatan(
|
||||
"Gagal upload background profile"
|
||||
);
|
||||
}
|
||||
if (uploadPhoto.success) {
|
||||
const uploadBackground = await funGlobal_UploadToStorage({
|
||||
file: fileBG,
|
||||
dirId: DIRECTORY_ID.profile_background,
|
||||
});
|
||||
// console.log("ini background", uploadBackground);
|
||||
if (!uploadBackground.success) {
|
||||
setLoading(false);
|
||||
return ComponentGlobal_NotifikasiPeringatan(
|
||||
"Gagal upload background profile"
|
||||
);
|
||||
}
|
||||
|
||||
const create = await funCreateNewProfile({
|
||||
data: newData as any,
|
||||
imageId: uploadPhoto.data.id,
|
||||
imageBackgroundId: uploadBackground.data.id,
|
||||
});
|
||||
|
||||
if (create.status === 201) {
|
||||
ComponentGlobal_NotifikasiBerhasil("Berhasil membuat profile", 3000);
|
||||
router.push(RouterHome.main_home, { scroll: false });
|
||||
} else {
|
||||
ComponentGlobal_NotifikasiGagal(create.message);
|
||||
setLoading(false);
|
||||
if (uploadBackground.success) {
|
||||
const create = await funCreateNewProfile({
|
||||
data: newData as any,
|
||||
imageId: uploadPhoto.data.id,
|
||||
imageBackgroundId: uploadBackground.data.id,
|
||||
});
|
||||
if (create.status === 201) {
|
||||
ComponentGlobal_NotifikasiBerhasil(
|
||||
"Berhasil membuat profile",
|
||||
3000
|
||||
);
|
||||
router.push(RouterHome.main_home, { scroll: false });
|
||||
} else {
|
||||
ComponentGlobal_NotifikasiGagal(create.message);
|
||||
setLoading(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
|
||||
Reference in New Issue
Block a user