upd: upload foto user
This commit is contained in:
@@ -1,4 +1,12 @@
|
||||
import { hookstate } from "@hookstate/core"
|
||||
|
||||
export const pwd_key_config = "fchgvjknlmdfnbvghhujlaknsdvjbhknlkmsdbdyu567t8y9u30r4587638y9uipkoeghjvuyi89ipkoefmnrjbhtiu4or9ipkoemnjfbhjiuoijdklnjhbviufojkejnshbiuojijknehgruyu"
|
||||
export const globalRole = hookstate<string>('')
|
||||
export const globalRole = hookstate<string>('')
|
||||
export const DIR = {
|
||||
task: "cm0xhcqf0000dacbbixjb09yn",
|
||||
project: "cm0xhc9sv000bacbb7rfikw1k",
|
||||
document: "cm0xhbkf50009acbbtw03qo4l",
|
||||
village: "cm0xhb91o0007acbbkx8rk8hj",
|
||||
user: "cm0x8dbwn0005bp5tgmfcthzw",
|
||||
|
||||
}
|
||||
@@ -1,22 +1,21 @@
|
||||
export async function funDeleteFile({ name, dirId }: { name: String, dirId: string }) {
|
||||
export async function funDeleteFile({ fileId }: { fileId: string }) {
|
||||
try {
|
||||
const res = await fetch(`https://wibu-storage.wibudev.com/api/dir/${dirId}/${name}`, {
|
||||
method: "GET",
|
||||
const res = await fetch(`https://wibu-storage.wibudev.com/api/files/${fileId}/delete`, {
|
||||
method: "DELETE",
|
||||
headers: {
|
||||
Authorization: `Bearer eyJhbGciOiJIUzI1NiJ9.eyJ1c2VyIjp7ImlkIjoiY20wdnQ4bzFrMDAwMDEyenE1eXl1emd5YiIsIm5hbWUiOiJhbWFsaWEiLCJlbWFpbCI6ImFtYWxpYUBiaXAuY29tIiwiQXBpS2V5IjpbeyJpZCI6ImNtMHZ0OG8xcjAwMDIxMnpxZDVzejd3eTgiLCJuYW1lIjoiZGVmYXVsdCJ9XX0sImlhdCI6MTcyNTkzNTE5MiwiZXhwIjo0ODgxNjk1MTkyfQ.7U-HUnNBDmeq_6XXohiFZjFnh2rSzUPMHDdrUKOd7G4`
|
||||
Authorization: `Bearer ${process.env.WS_APIKEY}`
|
||||
}
|
||||
});
|
||||
|
||||
if (res.ok) {
|
||||
console.log("Berhasil dapat");
|
||||
const hasil = await res.json()
|
||||
console.log('berhasilAmalia', hasil)
|
||||
|
||||
return { success: true }
|
||||
} else {
|
||||
const errorText = await res.json();
|
||||
console.log('errorAmalia', errorText)
|
||||
return { success: false }
|
||||
}
|
||||
} catch (error) {
|
||||
return { success: false }
|
||||
console.error("Upload error:", error);
|
||||
}
|
||||
}
|
||||
@@ -13,12 +13,14 @@ export async function funUploadFile({ file, dirId }: { file: File, dirId: string
|
||||
});
|
||||
|
||||
if (res.ok) {
|
||||
console.log("File uploaded successfully");
|
||||
const hasil = await res.json()
|
||||
return { success: true, data: hasil.data }
|
||||
} else {
|
||||
const errorText = await res.text();
|
||||
console.log('errorAmalia', errorText)
|
||||
return { success: false, data: {} }
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("Upload error:", error);
|
||||
return { success: false, data: {} }
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
import prisma from "./bin/prisma";
|
||||
import { globalRole, pwd_key_config } from "./bin/val_global";
|
||||
import { DIR, globalRole, pwd_key_config } from "./bin/val_global";
|
||||
import SkeletonDetailDiscussionComment from "./components/skeleton_detail_discussion_comment";
|
||||
import SkeletonDetailDiscussionMember from "./components/skeleton_detail_discussion_member";
|
||||
import SkeletonDetailListTugasTask from "./components/skeleton_detail_list_tugas_task";
|
||||
@@ -40,3 +40,4 @@ export { WrapLayout }
|
||||
export { NoZoom }
|
||||
export { funUploadFile }
|
||||
export { funDeleteFile }
|
||||
export { DIR }
|
||||
|
||||
Reference in New Issue
Block a user