Merge pull request #385 from bipproduction/amalia/22-jan-25

Amalia/22 jan 25
This commit is contained in:
Amalia
2025-01-22 17:30:48 +08:00
committed by GitHub
6 changed files with 56 additions and 7 deletions

BIN
bun.lockb

Binary file not shown.

View File

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

View File

@@ -3,6 +3,7 @@ import { funGetUserByCookies } from "@/module/auth";
import { createLogUser } from "@/module/user";
import _ from "lodash";
import { NextResponse } from "next/server";
import sharp from "sharp";
// GET ONE MEMBER / USER
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") {
const fExt = file.name.split(".").pop()
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) })
const upload = await funUploadFile({ file: newFile, dirId: DIR.user })
const upload = await funUploadFile({ file: resizedFile, dirId: DIR.user })
await prisma.user.update({
where: {
id: id

View File

@@ -3,6 +3,7 @@ import { funGetUserByCookies } from "@/module/auth";
import { createLogUser } from "@/module/user";
import _ from "lodash";
import { NextResponse } from "next/server";
import sharp from "sharp";
// GET PROFILE BY COOKIES
@@ -119,9 +120,24 @@ export async function PUT(request: Request) {
if (String(file) != "undefined" && String(file) != "null") {
const fExt = file.name.split(".").pop()
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) })
const upload = await funUploadFile({ file: newFile, dirId: DIR.user })
const upload = await funUploadFile({ file: resizedFile, dirId: DIR.user })
if (upload.success) {
await prisma.user.update({
where: {

View File

@@ -3,6 +3,7 @@ import { funGetUserByCookies } from "@/module/auth";
import { createLogUser } from "@/module/user";
import _ from "lodash";
import { NextResponse } from "next/server";
import sharp from "sharp";
// GET ALL MEMBER / USER
export async function GET(request: Request) {
@@ -194,8 +195,23 @@ export async function POST(request: Request) {
const fExt = file.name.split(".").pop()
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) {
await prisma.user.update({
where: {

View File

@@ -2,7 +2,7 @@ import { NextResponse } from "next/server";
export async function GET(request: Request) {
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.3", tahap: "beta", update:"-resize profile image user (create anggota, edit anggota, edit profile)" }, { status: 200 });
} catch (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 });