Merge pull request #387 from bipproduction/join

Join
This commit is contained in:
Amalia
2025-01-24 10:43:31 +08:00
committed by GitHub
16 changed files with 91 additions and 42 deletions

BIN
bun.lockb

Binary file not shown.

View File

@@ -53,6 +53,7 @@
"readdirp": "^3.6.0", "readdirp": "^3.6.0",
"recharts": "2", "recharts": "2",
"rrule": "^2.8.1", "rrule": "^2.8.1",
"sharp": "^0.33.5",
"supabase": "^1.192.5", "supabase": "^1.192.5",
"web-push": "^3.6.7", "web-push": "^3.6.7",
"wibu-cli": "^1.0.91", "wibu-cli": "^1.0.91",

View File

@@ -3,6 +3,7 @@ import { funGetUserByCookies } from "@/module/auth";
import { createLogUser } from "@/module/user"; import { createLogUser } from "@/module/user";
import _ from "lodash"; import _ from "lodash";
import { NextResponse } from "next/server"; import { NextResponse } from "next/server";
import sharp from "sharp";
// GET ONE MEMBER / USER // GET ONE MEMBER / USER
export async function GET(request: Request, context: { params: { id: string } }) { export async function GET(request: Request, context: { params: { id: string } }) {
@@ -207,9 +208,24 @@ export async function PUT(request: Request, context: { params: { id: string } })
if (String(file) != "undefined" && String(file) != "null") { if (String(file) != "undefined" && String(file) != "null") {
const fExt = file.name.split(".").pop() const fExt = file.name.split(".").pop()
const fileName = id + '.' + fExt; const fileName = id + '.' + fExt;
const newFile = new File([file], fileName, { type: file.type });
// Resize ukuran
const imageBuffer = await file.arrayBuffer();
const resize = await sharp(imageBuffer).resize(300).toBuffer();
// Convert buffer ke Blob
const blob = new Blob([resize], { type: file.type });
// Convert Blob ke File
const resizedFile = new File([blob], fileName, {
type: file.type,
lastModified: new Date().getTime(),
});
// const newFile = new File([file], fileName, { type: file.type });
await funDeleteFile({ fileId: String(updates.img) }) await funDeleteFile({ fileId: String(updates.img) })
const upload = await funUploadFile({ file: newFile, dirId: DIR.user }) const upload = await funUploadFile({ file: resizedFile, dirId: DIR.user })
await prisma.user.update({ await prisma.user.update({
where: { where: {
id: id id: id

View File

@@ -3,6 +3,7 @@ import { funGetUserByCookies } from "@/module/auth";
import { createLogUser } from "@/module/user"; import { createLogUser } from "@/module/user";
import _ from "lodash"; import _ from "lodash";
import { NextResponse } from "next/server"; import { NextResponse } from "next/server";
import sharp from "sharp";
// GET PROFILE BY COOKIES // GET PROFILE BY COOKIES
@@ -119,9 +120,24 @@ export async function PUT(request: Request) {
if (String(file) != "undefined" && String(file) != "null") { if (String(file) != "undefined" && String(file) != "null") {
const fExt = file.name.split(".").pop() const fExt = file.name.split(".").pop()
const fileName = user.id + '.' + fExt; const fileName = user.id + '.' + fExt;
const newFile = new File([file], fileName, { type: file.type });
// Resize ukuran
const imageBuffer = await file.arrayBuffer();
const resize = await sharp(imageBuffer).resize(300).toBuffer();
// Convert buffer ke Blob
const blob = new Blob([resize], { type: file.type });
// Convert Blob ke File
const resizedFile = new File([blob], fileName, {
type: file.type,
lastModified: new Date().getTime(),
});
// const newFile = new File([file], fileName, { type: file.type });
await funDeleteFile({ fileId: String(update.img) }) await funDeleteFile({ fileId: String(update.img) })
const upload = await funUploadFile({ file: newFile, dirId: DIR.user }) const upload = await funUploadFile({ file: resizedFile, dirId: DIR.user })
if (upload.success) { if (upload.success) {
await prisma.user.update({ await prisma.user.update({
where: { where: {

View File

@@ -3,6 +3,7 @@ import { funGetUserByCookies } from "@/module/auth";
import { createLogUser } from "@/module/user"; import { createLogUser } from "@/module/user";
import _ from "lodash"; import _ from "lodash";
import { NextResponse } from "next/server"; import { NextResponse } from "next/server";
import sharp from "sharp";
// GET ALL MEMBER / USER // GET ALL MEMBER / USER
export async function GET(request: Request) { export async function GET(request: Request) {
@@ -194,8 +195,23 @@ export async function POST(request: Request) {
const fExt = file.name.split(".").pop() const fExt = file.name.split(".").pop()
const fileName = user.id + '.' + fExt; const fileName = user.id + '.' + fExt;
const newFile = new File([file], fileName, { type: file.type });
const upload = await funUploadFile({ file: newFile, dirId: DIR.user }) // Resize ukuran
const imageBuffer = await file.arrayBuffer();
const resize = await sharp(imageBuffer).resize(300).toBuffer();
// Convert buffer ke Blob
const blob = new Blob([resize], { type: file.type });
// Convert Blob ke File
const resizedFile = new File([blob], fileName, {
type: file.type,
lastModified: new Date().getTime(),
});
// const newFile = new File([file], fileName, { type: file.type });
const upload = await funUploadFile({ file: resizedFile, dirId: DIR.user })
if (upload.success) { if (upload.success) {
await prisma.user.update({ await prisma.user.update({
where: { where: {

View File

@@ -2,7 +2,7 @@ import { NextResponse } from "next/server";
export async function GET(request: Request) { export async function GET(request: Request) {
try { try {
return NextResponse.json({ success: true, version: "1.1.2", tahap: "beta", update:"-pdf viewer new -jumlah anggota pada grid list divisi" }, { status: 200 }); return NextResponse.json({ success: true, version: "1.1.4", tahap: "beta", update:"-resize profile image user (create anggota, edit anggota, edit profile) -menghilangkan image extensi heic" }, { status: 200 });
} catch (error) { } catch (error) {
console.error(error); console.error(error);
return NextResponse.json({ success: false, version: "Gagal mendapatkan version, coba lagi nanti (error: 500)", reason: (error as Error).message, }, { status: 500 }); return NextResponse.json({ success: false, version: "Gagal mendapatkan version, coba lagi nanti (error: 500)", reason: (error as Error).message, }, { status: 500 });

View File

@@ -120,9 +120,9 @@ function CreateBanner() {
}} }}
activateOnClick={false} activateOnClick={false}
maxSize={10 * 1024 ** 2} maxSize={10 * 1024 ** 2}
accept={['image/png', 'image/jpeg', 'image/heic']} accept={['image/png', 'image/jpeg']}
onReject={(files) => { onReject={(files) => {
return toast.error('File yang diizinkan: .png, .jpg, dan .heic dengan ukuran maksimal 10 MB') return toast.error('File yang diizinkan: .png dan .jpg dengan ukuran maksimal 10 MB')
}} }}
onClick={() => openRef.current?.()} onClick={() => openRef.current?.()}
> >
@@ -159,17 +159,17 @@ function CreateBanner() {
</Dropzone.Idle> </Dropzone.Idle>
<div > <div >
<Text size="xl" inline> <Text size="xl" inline>
Klik Untuk Upload Image Klik Untuk Upload Image
</Text> </Text>
<Text mb={2} size="sm" c="dimmed" inline mt={7}> <Text mb={2} size="sm" c="dimmed" inline mt={7}>
Mohon unggah gambar dalam resolusi Mohon unggah gambar dalam resolusi
</Text> </Text>
<Text mb={2} size='sm' c={"dimmed"} inline> <Text mb={2} size='sm' c={"dimmed"} inline>
1535 x 450 piksel untuk memastikan 1535 x 450 piksel untuk memastikan
</Text> </Text>
<Text size='sm' c={"dimmed"} inline> <Text size='sm' c={"dimmed"} inline>
tampilan sesuai dengan kebutuhan desain. tampilan sesuai dengan kebutuhan desain.
</Text> </Text>
</div> </div>
</Group> </Group>
@@ -177,15 +177,15 @@ function CreateBanner() {
</Dropzone> </Dropzone>
</Paper> </Paper>
<Box mt={10}> <Box mt={10}>
{touched.image && !imgForm && ( {touched.image && !imgForm && (
<Text size='sm' c={'red'}> <Text size='sm' c={'red'}>
Silahkan Pilih Gambar Silahkan Pilih Gambar
</Text> </Text>
)} )}
</Box> </Box>
<Box> <Box>
<TextInput <TextInput
mt={10} mt={10}
label="Judul Banner" label="Judul Banner"
placeholder='Judul Banner' placeholder='Judul Banner'

View File

@@ -56,8 +56,8 @@ export default function EditBanner() {
return false return false
setModal(true) setModal(true)
} }
async function getOneData() { async function getOneData() {
try { try {
const res = await funGetOneBanner(param.id) const res = await funGetOneBanner(param.id)
@@ -121,9 +121,9 @@ export default function EditBanner() {
}} }}
activateOnClick={false} activateOnClick={false}
maxSize={10 * 1024 ** 2} maxSize={10 * 1024 ** 2}
accept={['image/png', 'image/jpeg', 'image/heic']} accept={['image/png', 'image/jpeg']}
onReject={(files) => { onReject={(files) => {
return toast.error('File yang diizinkan: .png, .jpg, dan .heic dengan ukuran maksimal 10 MB') return toast.error('File yang diizinkan: .png dan .jpg dengan ukuran maksimal 10 MB')
}} }}
onClick={() => openRef.current?.()} onClick={() => openRef.current?.()}
> >

View File

@@ -149,12 +149,12 @@ export default function DrawerMenuDocumentDivision() {
}} }}
activateOnClick={false} activateOnClick={false}
maxSize={100 * 1024 ** 2} maxSize={100 * 1024 ** 2}
accept={['image/png', 'image/jpeg', 'image/heic', 'application/pdf', 'application/msword', 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', 'application/vnd.ms-excel', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet']} accept={['image/png', 'image/jpeg', 'application/pdf', 'application/msword', 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', 'application/vnd.ms-excel', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet']}
onReject={(files) => { onReject={(files) => {
refresh.set(true) refresh.set(true)
setOpenModal(false) setOpenModal(false)
setOpenDrawerDocument(false) setOpenDrawerDocument(false)
toast.error('File yang diizinkan: .csv, .png, .jpg, .heic, .pdf, .doc, .docx, .xls, .xlsx dengan ukuran maksimal 100 MB') toast.error('File yang diizinkan: .csv, .png, .jpg, .pdf, .doc, .docx, .xls, .xlsx dengan ukuran maksimal 100 MB')
}} }}
> >
<Flex justify={'center'} align={'center'} direction={'column'} mb={20} onClick={() => openRef.current?.()}> <Flex justify={'center'} align={'center'} direction={'column'} mb={20} onClick={() => openRef.current?.()}>

View File

@@ -106,9 +106,9 @@ export default function AddFileDetailProject() {
}} }}
activateOnClick={false} activateOnClick={false}
maxSize={100 * 1024 ** 2} maxSize={100 * 1024 ** 2}
accept={['image/png', 'image/jpeg', 'image/heic', 'application/pdf', 'application/msword', 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', 'application/vnd.ms-excel', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet']} accept={['image/png', 'image/jpeg', 'application/pdf', 'application/msword', 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', 'application/vnd.ms-excel', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet']}
onReject={(files) => { onReject={(files) => {
return toast.error('File yang diizinkan: .csv, .png, .jpg, .heic, .pdf, .doc, .docx, .xls, .xlsx dengan ukuran maksimal 100 MB') return toast.error('File yang diizinkan: .csv, .png, .jpg, .pdf, .doc, .docx, .xls, .xlsx dengan ukuran maksimal 100 MB')
}} }}
> >
</Dropzone> </Dropzone>

View File

@@ -200,7 +200,7 @@ export default function CreateProject() {
label="Grup" label="Grup"
size="md" size="md"
styles={{ styles={{
input: { input: {
border: `1px solid ${"#D6D8F6"}`, border: `1px solid ${"#D6D8F6"}`,
borderRadius: 10, borderRadius: 10,
}, },
@@ -413,9 +413,9 @@ export default function CreateProject() {
}} }}
activateOnClick={false} activateOnClick={false}
maxSize={100 * 1024 ** 2} maxSize={100 * 1024 ** 2}
accept={['image/png', 'image/jpeg', 'image/heic', 'application/pdf', 'application/msword', 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', 'application/vnd.ms-excel', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet']} accept={['image/png', 'image/jpeg', 'application/pdf', 'application/msword', 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', 'application/vnd.ms-excel', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet']}
onReject={(files) => { onReject={(files) => {
return toast.error('File yang diizinkan: .csv, .png, .jpg, .heic, .pdf, .doc, .docx, .xls, .xlsx dengan ukuran maksimal 100 MB') return toast.error('File yang diizinkan: .csv, .png, .jpg, .pdf, .doc, .docx, .xls, .xlsx dengan ukuran maksimal 100 MB')
}} }}
></Dropzone> ></Dropzone>

View File

@@ -107,9 +107,9 @@ export default function AddFileDetailTask() {
}} }}
activateOnClick={false} activateOnClick={false}
maxSize={100 * 1024 ** 2} maxSize={100 * 1024 ** 2}
accept={['image/png', 'image/jpeg', 'image/heic', 'application/pdf', 'application/msword', 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', 'application/vnd.ms-excel', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet']} accept={['image/png', 'image/jpeg', 'application/pdf', 'application/msword', 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', 'application/vnd.ms-excel', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet']}
onReject={(files) => { onReject={(files) => {
return toast.error('File yang diizinkan: .csv, .png, .jpg, .heic, .pdf, .doc, .docx, .xls, .xlsx dengan ukuran maksimal 100 MB') return toast.error('File yang diizinkan: .csv, .png, .jpg, .pdf, .doc, .docx, .xls, .xlsx dengan ukuran maksimal 100 MB')
}} }}
> >
</Dropzone> </Dropzone>

View File

@@ -336,9 +336,9 @@ export default function CreateTask() {
}} }}
activateOnClick={false} activateOnClick={false}
maxSize={100 * 1024 ** 2} maxSize={100 * 1024 ** 2}
accept={['image/png', 'image/jpeg', 'image/heic', 'application/pdf', 'application/msword', 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', 'application/vnd.ms-excel', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet']} accept={['image/png', 'image/jpeg', 'application/pdf', 'application/msword', 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', 'application/vnd.ms-excel', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet']}
onReject={(files) => { onReject={(files) => {
return toast.error('File yang diizinkan: .csv, .png, .jpg, .heic, .pdf, .doc, .docx, .xls, .xlsx dengan ukuran maksimal 100 MB') return toast.error('File yang diizinkan: .csv, .png, .jpg, .pdf, .doc, .docx, .xls, .xlsx dengan ukuran maksimal 100 MB')
}} }}
></Dropzone> ></Dropzone>

View File

@@ -284,9 +284,9 @@ export default function CreateMember() {
}} }}
activateOnClick={false} activateOnClick={false}
maxSize={10 * 1024 ** 2} maxSize={10 * 1024 ** 2}
accept={['image/png', 'image/jpeg', 'image/heic']} accept={['image/png', 'image/jpeg']}
onReject={(files) => { onReject={(files) => {
return toast.error('File yang diizinkan: .png, .jpg, dan .heic dengan ukuran maksimal 10 MB') return toast.error('File yang diizinkan: .png dan .jpg dengan ukuran maksimal 10 MB')
}} }}
> >
</Dropzone> </Dropzone>

View File

@@ -216,9 +216,9 @@ export default function EditMember({ id }: { id: string }) {
}} }}
activateOnClick={false} activateOnClick={false}
maxSize={10 * 1024 ** 2} maxSize={10 * 1024 ** 2}
accept={['image/png', 'image/jpeg', 'image/heic']} accept={['image/png', 'image/jpeg']}
onReject={(files) => { onReject={(files) => {
return toast.error('File yang diizinkan: .png, .jpg, dan .heic dengan ukuran maksimal 10 MB') return toast.error('File yang diizinkan: .png dan .jpg dengan ukuran maksimal 10 MB')
}} }}
> >
</Dropzone> </Dropzone>

View File

@@ -179,10 +179,10 @@ export default function EditProfile() {
}} }}
activateOnClick={false} activateOnClick={false}
maxSize={10 * 1024 ** 2} maxSize={10 * 1024 ** 2}
accept={["image/png", "image/jpeg", "image/heic"]} accept={["image/png", "image/jpeg"]}
onReject={(files) => { onReject={(files) => {
return toast.error( return toast.error(
"File yang diizinkan: .png, .jpg, dan .heic dengan ukuran maksimal 10 MB" "File yang diizinkan: .png dan .jpg dengan ukuran maksimal 10 MB"
); );
}} }}
></Dropzone> ></Dropzone>