Portofolio
#feat - Create porto - Edit Porto - Upload gambar background profile - List user - Search user ## No issuue
This commit is contained in:
39
src/app_modules/fun_global/get_user_profile.ts
Normal file
39
src/app_modules/fun_global/get_user_profile.ts
Normal file
@@ -0,0 +1,39 @@
|
||||
"use server";
|
||||
import prisma from "@/app/lib/prisma";
|
||||
import { revalidatePath } from "next/cache";
|
||||
|
||||
export async function funGetUserProfile( userId: string ) {
|
||||
|
||||
const user = await prisma.user.findUnique({
|
||||
where: {
|
||||
id: userId,
|
||||
},
|
||||
select: {
|
||||
id: true,
|
||||
username: true,
|
||||
nomor: true,
|
||||
Profile: {
|
||||
select: {
|
||||
id: true,
|
||||
alamat: true,
|
||||
email: true,
|
||||
jenisKelamin: true,
|
||||
name: true,
|
||||
imagesId: true,
|
||||
ImageProfile: {
|
||||
select: {
|
||||
url: true,
|
||||
},
|
||||
},
|
||||
ImagesBackground: true,
|
||||
imagesBackgroundId: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
revalidatePath("/dev/home");
|
||||
revalidatePath("/dev/katalog/view");
|
||||
|
||||
return user;
|
||||
}
|
||||
21
src/app_modules/fun_global/get_user_token.ts
Normal file
21
src/app_modules/fun_global/get_user_token.ts
Normal file
@@ -0,0 +1,21 @@
|
||||
"use server";
|
||||
|
||||
import { cookies } from "next/headers";
|
||||
import yaml from "yaml";
|
||||
import fs from "fs";
|
||||
import { unsealData } from "iron-session";
|
||||
import { redirect } from "next/navigation";
|
||||
const config = yaml.parse(fs.readFileSync("config.yaml").toString());
|
||||
|
||||
export async function User_getUserId() {
|
||||
const c = cookies().get("ssn");
|
||||
if (!c?.value) return redirect("/dev/auth/login");
|
||||
|
||||
const token = JSON.parse(
|
||||
await unsealData(c?.value as string, {
|
||||
password: config.server.password,
|
||||
})
|
||||
);
|
||||
|
||||
return token.id
|
||||
}
|
||||
15
src/app_modules/fun_global/midtrans/fun_get_notif.ts
Normal file
15
src/app_modules/fun_global/midtrans/fun_get_notif.ts
Normal file
@@ -0,0 +1,15 @@
|
||||
"use server";
|
||||
|
||||
export default async function funGetNotif({
|
||||
params,
|
||||
}: {
|
||||
params: { data: any };
|
||||
}) {
|
||||
const body = params.data;
|
||||
console.log(body);
|
||||
|
||||
return {
|
||||
status: 200,
|
||||
message: "OK",
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user