Merge pull request #176 from bipproduction/event/konfirmasi

Fix create profile
This commit is contained in:
Bagasbanuna02
2024-12-10 11:12:24 +08:00
committed by GitHub
6 changed files with 100 additions and 52 deletions

View File

@@ -2,6 +2,8 @@
All notable changes to this project will be documented in this file. See [commit-and-tag-version](https://github.com/absolute-version/commit-and-tag-version) for commit guidelines.
## [1.2.22](https://github.com/bipproduction/hipmi/compare/v1.2.21...v1.2.22) (2024-12-10)
## [1.2.21](https://github.com/bipproduction/hipmi/compare/v1.2.20...v1.2.21) (2024-12-09)
## [1.2.20](https://github.com/bipproduction/hipmi/compare/v1.2.19...v1.2.20) (2024-12-09)

View File

@@ -1,10 +1,10 @@
{
"name": "hipmi",
"version": "1.2.21",
"version": "1.2.22",
"private": true,
"prisma": {
"seed": "npx tsx prisma/seed.ts --yes"
},
},
"scripts": {
"dev": "bun --bun run next dev --experimental-https",
"build": "NODE_OPTIONS='--max-old-space-size=2048' bun --bun run next build",

View File

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

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

View File

@@ -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>

View File

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