auto push
This commit is contained in:
@@ -14,8 +14,9 @@ export default function LayoutValidasi({
|
||||
return (
|
||||
<>
|
||||
<AppShell
|
||||
bg={"red"}
|
||||
header={
|
||||
<Header height={50} sx={{borderStyle: "none"}} px={"md"}>
|
||||
<Header height={50} sx={{borderStyle: "none"}} px={"md"} bg={"yellow"}>
|
||||
<Group h={50} align="center">
|
||||
<ActionIcon variant="transparent" onClick={() => router.back()} >
|
||||
<IconChevronLeft />
|
||||
|
||||
@@ -151,7 +151,7 @@ export default function Validasi({ dataOtp }: { dataOtp: any }) {
|
||||
|
||||
{/* <pre>{JSON.stringify(code)}</pre> */}
|
||||
|
||||
<Center h={"80%"}>
|
||||
<Center h={"80%"} bg={"blue"} >
|
||||
<Stack px={"lg"} spacing={"xl"} w={{ base: 400 }} justify="center">
|
||||
<Center>
|
||||
<IconCloudLockOpen size={130} />
|
||||
|
||||
@@ -2,14 +2,14 @@
|
||||
|
||||
import prisma from "@/app/lib/prisma";
|
||||
import { MODEL_COLLABORATION } from "../../model/interface";
|
||||
import { User_getUserId } from "@/app_modules/fun_global/get_user_token";
|
||||
import { user_getOneUserId } from "@/app_modules/fun_global/get_user_token";
|
||||
import { revalidatePath } from "next/cache";
|
||||
import { RouterColab } from "@/app/lib/router_hipmi/router_colab";
|
||||
|
||||
export default async function colab_funCreateProyek(
|
||||
value: MODEL_COLLABORATION
|
||||
) {
|
||||
const AuthorId = await User_getUserId();
|
||||
const AuthorId = await user_getOneUserId();
|
||||
|
||||
const create = await prisma.projectCollaboration.create({
|
||||
data: {
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
"use server";
|
||||
|
||||
import prisma from "@/app/lib/prisma";
|
||||
import { User_getUserId } from "@/app_modules/fun_global/get_user_token";
|
||||
import { user_getOneUserId } from "@/app_modules/fun_global/get_user_token";
|
||||
|
||||
export default async function colab_funCekPartisipasiById(colabId: string) {
|
||||
const UserLoginId = await User_getUserId();
|
||||
const UserLoginId = await user_getOneUserId();
|
||||
|
||||
const cek = await prisma.projectCollaboration_Partisipasi.findFirst({
|
||||
where: {
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
"use server";
|
||||
|
||||
import prisma from "@/app/lib/prisma";
|
||||
import { User_getUserId } from "@/app_modules/fun_global/get_user_token";
|
||||
import { user_getOneUserId } from "@/app_modules/fun_global/get_user_token";
|
||||
|
||||
export default async function colab_getListByStatusId(statusId: number) {
|
||||
const AuthorId = await User_getUserId();
|
||||
const AuthorId = await user_getOneUserId();
|
||||
const data = await prisma.projectCollaboration.findMany({
|
||||
where: {
|
||||
userId: AuthorId,
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
"use server";
|
||||
|
||||
import prisma from "@/app/lib/prisma";
|
||||
import { User_getUserId } from "@/app_modules/fun_global/get_user_token";
|
||||
import { user_getOneUserId } from "@/app_modules/fun_global/get_user_token";
|
||||
|
||||
export default async function colab_getListPartisipasiByAuthorId() {
|
||||
const AuthorId = await User_getUserId();
|
||||
const AuthorId = await user_getOneUserId();
|
||||
|
||||
const get = await prisma.projectCollaboration_Partisipasi.findMany({
|
||||
where: {
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
"use server";
|
||||
|
||||
import prisma from "@/app/lib/prisma";
|
||||
import { User_getUserId } from "@/app_modules/fun_global/get_user_token";
|
||||
import { user_getOneUserId } from "@/app_modules/fun_global/get_user_token";
|
||||
|
||||
export default async function colab_getListAllProyekByAuthorId() {
|
||||
const AuthorId = await User_getUserId();
|
||||
const AuthorId = await user_getOneUserId();
|
||||
const get = await prisma.projectCollaboration.findMany({
|
||||
where: { userId: AuthorId, isActive: true },
|
||||
select: {
|
||||
|
||||
@@ -32,7 +32,7 @@ import ComponentGlobal_V2_LoadingPage from "@/app_modules/component_global/loadi
|
||||
import { useAtom } from "jotai";
|
||||
import { gs_forum_loading_edit_posting } from "../../global_state";
|
||||
import ComponentForum_LoadingDrawer from "../loading_drawer";
|
||||
import { User_getUserId } from "@/app_modules/fun_global/get_user_token";
|
||||
import { user_getOneUserId } from "@/app_modules/fun_global/get_user_token";
|
||||
import { forum_funDeletePostingById } from "../../fun/delete/fun_delete_posting_by_id";
|
||||
import { ComponentGlobal_NotifikasiGagal } from "@/app_modules/component_global/notif_global/notifikasi_gagal";
|
||||
import { IconSquareCheck } from "@tabler/icons-react";
|
||||
|
||||
@@ -26,7 +26,7 @@ import ComponentGlobal_V2_LoadingPage from "@/app_modules/component_global/loadi
|
||||
import { useAtom } from "jotai";
|
||||
import { gs_forum_loading_edit_posting } from "../../global_state";
|
||||
import ComponentForum_LoadingDrawer from "../loading_drawer";
|
||||
import { User_getUserId } from "@/app_modules/fun_global/get_user_token";
|
||||
import { user_getOneUserId } from "@/app_modules/fun_global/get_user_token";
|
||||
import { forum_funDeletePostingById } from "../../fun/delete/fun_delete_posting_by_id";
|
||||
import { ComponentGlobal_NotifikasiGagal } from "@/app_modules/component_global/notif_global/notifikasi_gagal";
|
||||
import { forum_funDeleteKomentarById } from "../../fun/delete/fun_delete_komentar_by_id";
|
||||
|
||||
@@ -33,7 +33,7 @@ import ComponentGlobal_V2_LoadingPage from "@/app_modules/component_global/loadi
|
||||
import { useAtom } from "jotai";
|
||||
import { gs_forum_loading_edit_posting } from "../../global_state";
|
||||
import ComponentForum_LoadingDrawer from "../loading_drawer";
|
||||
import { User_getUserId } from "@/app_modules/fun_global/get_user_token";
|
||||
import { user_getOneUserId } from "@/app_modules/fun_global/get_user_token";
|
||||
import { forum_funDeletePostingById } from "../../fun/delete/fun_delete_posting_by_id";
|
||||
import { ComponentGlobal_NotifikasiGagal } from "@/app_modules/component_global/notif_global/notifikasi_gagal";
|
||||
import { forum_funEditStatusPostingById } from "../../fun/edit/fun_edit_status_posting_by_id";
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
"use server";
|
||||
|
||||
import prisma from "@/app/lib/prisma";
|
||||
import { User_getUserId } from "@/app_modules/fun_global/get_user_token";
|
||||
import { user_getOneUserId } from "@/app_modules/fun_global/get_user_token";
|
||||
|
||||
export async function forum_countPostingByAuthorId(authorId: string) {
|
||||
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
"use server";
|
||||
|
||||
import prisma from "@/app/lib/prisma";
|
||||
import { User_getUserId } from "@/app_modules/fun_global/get_user_token";
|
||||
import { user_getOneUserId } from "@/app_modules/fun_global/get_user_token";
|
||||
import { revalidatePath } from "next/cache";
|
||||
|
||||
export async function forum_funCreate(value: string) {
|
||||
const AuthorId = await User_getUserId();
|
||||
const AuthorId = await user_getOneUserId();
|
||||
|
||||
const create = await prisma.forum_Posting.create({
|
||||
data: {
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
"use server";
|
||||
|
||||
import prisma from "@/app/lib/prisma";
|
||||
import { User_getUserId } from "@/app_modules/fun_global/get_user_token";
|
||||
import { user_getOneUserId } from "@/app_modules/fun_global/get_user_token";
|
||||
import { revalidatePath } from "next/cache";
|
||||
|
||||
export async function forum_funCreateKomentar(
|
||||
postingId: string,
|
||||
komentar: string
|
||||
) {
|
||||
const authorId = await User_getUserId();
|
||||
const authorId = await user_getOneUserId();
|
||||
|
||||
const create = await prisma.forum_Komentar.create({
|
||||
data: {
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
"use server";
|
||||
|
||||
import prisma from "@/app/lib/prisma";
|
||||
import { User_getUserId } from "@/app_modules/fun_global/get_user_token";
|
||||
import { user_getOneUserId } from "@/app_modules/fun_global/get_user_token";
|
||||
|
||||
export async function forum_funCreateReportKomentar(
|
||||
komentarId: string,
|
||||
value: string
|
||||
) {
|
||||
const authorId = await User_getUserId();
|
||||
const authorId = await user_getOneUserId();
|
||||
|
||||
const cekId = await prisma.forumMaster_KategoriReport.findFirst({
|
||||
where: {
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
"use server";
|
||||
|
||||
import prisma from "@/app/lib/prisma";
|
||||
import { User_getUserId } from "@/app_modules/fun_global/get_user_token";
|
||||
import { user_getOneUserId } from "@/app_modules/fun_global/get_user_token";
|
||||
|
||||
export async function forum_funCreateReportKomentarLainnya(
|
||||
komentarId: string,
|
||||
deskripsi: string
|
||||
) {
|
||||
const authorId = await User_getUserId();
|
||||
const authorId = await user_getOneUserId();
|
||||
const create = await prisma.forum_ReportKomentar.create({
|
||||
data: {
|
||||
forum_KomentarId: komentarId,
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
"use server";
|
||||
|
||||
import prisma from "@/app/lib/prisma";
|
||||
import { User_getUserId } from "@/app_modules/fun_global/get_user_token";
|
||||
import { user_getOneUserId } from "@/app_modules/fun_global/get_user_token";
|
||||
import { revalidatePath } from "next/cache";
|
||||
|
||||
export async function forum_funCreateReportPosting(
|
||||
postingId: string,
|
||||
value: string,
|
||||
) {
|
||||
const authorId = await User_getUserId();
|
||||
const authorId = await user_getOneUserId();
|
||||
const cekId = await prisma.forumMaster_KategoriReport.findFirst({
|
||||
where: {
|
||||
title: value,
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
"use server";
|
||||
|
||||
import prisma from "@/app/lib/prisma";
|
||||
import { User_getUserId } from "@/app_modules/fun_global/get_user_token";
|
||||
import { user_getOneUserId } from "@/app_modules/fun_global/get_user_token";
|
||||
|
||||
export async function forum_funCreateReportPostingLainnya(
|
||||
postingId: string,
|
||||
deskripsi: string
|
||||
) {
|
||||
const authorId = await User_getUserId();
|
||||
const authorId = await user_getOneUserId();
|
||||
const create = await prisma.forum_ReportPosting.create({
|
||||
data: {
|
||||
forum_PostingId: postingId,
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
"use server";
|
||||
|
||||
import prisma from "@/app/lib/prisma";
|
||||
import { User_getUserId } from "@/app_modules/fun_global/get_user_token";
|
||||
import { user_getOneUserId } from "@/app_modules/fun_global/get_user_token";
|
||||
import _ from "lodash";
|
||||
|
||||
export async function forum_getListPostingByAuhtorId(authorId: string) {
|
||||
|
||||
@@ -8,7 +8,7 @@ import { redirect } from "next/navigation";
|
||||
import { RouterAuth } from "@/app/lib/router_hipmi/router_auth";
|
||||
const config = yaml.parse(fs.readFileSync("config.yaml").toString());
|
||||
|
||||
export async function User_getUserId() {
|
||||
export async function user_getOneUserId() {
|
||||
const c = cookies().get("ssn");
|
||||
if (!c?.value || c.value === "") return redirect(RouterAuth.login);
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
"use server";
|
||||
|
||||
import prisma from "@/app/lib/prisma";
|
||||
import { User_getUserId } from "@/app_modules/fun_global/get_user_token";
|
||||
import { user_getOneUserId } from "@/app_modules/fun_global/get_user_token";
|
||||
import _ from "lodash";
|
||||
import { v4 } from "uuid";
|
||||
import fs from "fs";
|
||||
@@ -9,7 +9,7 @@ import { revalidatePath } from "next/cache";
|
||||
import { MODEL_JOB } from "../../model/interface";
|
||||
|
||||
export async function Job_funCreate(req: MODEL_JOB, file: FormData) {
|
||||
const authorId = await User_getUserId();
|
||||
const authorId = await user_getOneUserId();
|
||||
|
||||
const dataImage: any = file.get("file");
|
||||
if (dataImage !== "null") {
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
"use server";
|
||||
|
||||
import prisma from "@/app/lib/prisma";
|
||||
import { User_getUserId } from "@/app_modules/fun_global/get_user_token";
|
||||
import { user_getOneUserId } from "@/app_modules/fun_global/get_user_token";
|
||||
|
||||
export async function Job_getListAllArsipById() {
|
||||
const authorId = await User_getUserId();
|
||||
const authorId = await user_getOneUserId();
|
||||
|
||||
const get = await prisma.job.findMany({
|
||||
where: {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
"use server";
|
||||
|
||||
import prisma from "@/app/lib/prisma";
|
||||
import { User_getUserId } from "@/app_modules/fun_global/get_user_token";
|
||||
import { user_getOneUserId } from "@/app_modules/fun_global/get_user_token";
|
||||
|
||||
export async function Job_getAllListPublish() {
|
||||
const data = await prisma.job.findMany({
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
"use server";
|
||||
|
||||
import prisma from "@/app/lib/prisma";
|
||||
import { User_getUserId } from "@/app_modules/fun_global/get_user_token";
|
||||
import { user_getOneUserId } from "@/app_modules/fun_global/get_user_token";
|
||||
|
||||
export async function Job_getListStatusByStatusId(statusId: string) {
|
||||
const authorId = await User_getUserId();
|
||||
const authorId = await user_getOneUserId();
|
||||
if (statusId === "1") {
|
||||
const data = await prisma.job.findMany({
|
||||
orderBy: {
|
||||
|
||||
@@ -31,6 +31,7 @@ import { AppRouterInstance } from "next/dist/shared/lib/app-router-context.share
|
||||
import { NotifPeringatan } from "@/app_modules/donasi/component/notifikasi/notif_peringatan";
|
||||
import { ComponentGlobal_NotifikasiBerhasil } from "@/app_modules/component_global/notif_global/notifikasi_berhasil";
|
||||
import { ComponentGlobal_NotifikasiGagal } from "@/app_modules/component_global/notif_global/notifikasi_gagal";
|
||||
import { ComponentGlobal_NotifikasiPeringatan } from "@/app_modules/component_global/notif_global/notifikasi_peringatan";
|
||||
|
||||
export default function CreatePortofolio({
|
||||
bidangBisnis,
|
||||
@@ -40,6 +41,7 @@ export default function CreatePortofolio({
|
||||
profileId: any;
|
||||
}) {
|
||||
const router = useRouter();
|
||||
const [loading, setLoading] = useState(false);
|
||||
const [value, setValue] = useState({
|
||||
namaBisnis: "",
|
||||
masterBidangBisnisId: "",
|
||||
@@ -145,10 +147,15 @@ export default function CreatePortofolio({
|
||||
const buffer = URL.createObjectURL(
|
||||
new Blob([new Uint8Array(await files.arrayBuffer())])
|
||||
);
|
||||
// console.log(buffer, "ini buffer");
|
||||
// console.log(files, " ini file");
|
||||
setImg(buffer);
|
||||
setFile(files);
|
||||
if (files.size > 2000000) {
|
||||
ComponentGlobal_NotifikasiPeringatan(
|
||||
"Maaf, Ukuran file terlalu besar, maximum 2mb",
|
||||
3000
|
||||
);
|
||||
} else {
|
||||
setImg(buffer);
|
||||
setFile(files);
|
||||
}
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
@@ -230,8 +237,10 @@ export default function CreatePortofolio({
|
||||
radius={50}
|
||||
bg={Warna.hijau_muda}
|
||||
color="green"
|
||||
loading={loading ? true : false}
|
||||
loaderPosition="center"
|
||||
onClick={() => {
|
||||
onSubmit(router, profileId, value as any, file, medsos);
|
||||
onSubmit(router, profileId, value as any, file, medsos, setLoading);
|
||||
}}
|
||||
>
|
||||
Simpan
|
||||
@@ -248,7 +257,8 @@ async function onSubmit(
|
||||
profileId: string,
|
||||
dataPorto: MODEL_PORTOFOLIO_OLD,
|
||||
file: FormData,
|
||||
dataMedsos: any
|
||||
dataMedsos: any,
|
||||
setLoading: any
|
||||
) {
|
||||
const porto = {
|
||||
namaBisnis: dataPorto.namaBisnis,
|
||||
@@ -257,15 +267,18 @@ async function onSubmit(
|
||||
tlpn: dataPorto.tlpn,
|
||||
deskripsi: dataPorto.deskripsi,
|
||||
};
|
||||
if (_.values(porto).includes("")) return toast("Lengkapi Data");
|
||||
if (!file) return NotifPeringatan("Lengkapi logo binnis");
|
||||
if (_.values(porto).includes(""))
|
||||
return ComponentGlobal_NotifikasiPeringatan("Lengkapi Data");
|
||||
if (!file)
|
||||
return ComponentGlobal_NotifikasiPeringatan("Lengkapi logo binnis");
|
||||
|
||||
const gambar = new FormData
|
||||
gambar.append("file",file as any)
|
||||
const gambar = new FormData();
|
||||
gambar.append("file", file as any);
|
||||
|
||||
await funCreatePortofolio(profileId, porto as any, gambar, dataMedsos).then(
|
||||
(res) => {
|
||||
if (res.status === 201) {
|
||||
setLoading(true);
|
||||
ComponentGlobal_NotifikasiBerhasil("Berhasil disimpan");
|
||||
router.back();
|
||||
} else {
|
||||
|
||||
@@ -22,6 +22,7 @@ export default function Portofolio_EditDataBisnis({
|
||||
}) {
|
||||
const router = useRouter();
|
||||
const [porto, setPorto] = useState(dataPorto);
|
||||
const [loading, setLoading] = useState(false);
|
||||
// const [value, setPorto] = useState({
|
||||
// namaBisnis: "",
|
||||
// masterBidangBisnisId: "",
|
||||
@@ -107,8 +108,10 @@ export default function Portofolio_EditDataBisnis({
|
||||
</Stack>
|
||||
<Button
|
||||
radius={"xl"}
|
||||
loading={loading ? true : false}
|
||||
loaderPosition="center"
|
||||
onClick={() => {
|
||||
onUpdate(router, porto as any);
|
||||
onUpdate(router, porto as any, setLoading);
|
||||
}}
|
||||
>
|
||||
Update
|
||||
@@ -118,9 +121,14 @@ export default function Portofolio_EditDataBisnis({
|
||||
);
|
||||
}
|
||||
|
||||
async function onUpdate(router: AppRouterInstance, data: MODEL_PORTOFOLIO) {
|
||||
async function onUpdate(
|
||||
router: AppRouterInstance,
|
||||
data: MODEL_PORTOFOLIO,
|
||||
setLoading: any
|
||||
) {
|
||||
await Portofolio_funEditDataBisnis(data).then((res) => {
|
||||
if (res.status === 200) {
|
||||
setLoading(true);
|
||||
ComponentGlobal_NotifikasiBerhasil(res.message);
|
||||
router.back();
|
||||
} else {
|
||||
|
||||
@@ -34,6 +34,7 @@ export default function Portofolio_EditLogoBisnis({
|
||||
const router = useRouter();
|
||||
const [file, setFile] = useState<File | null>(null);
|
||||
const [image, setImage] = useState<any | null>(null);
|
||||
const [loading, setLoading] = useState(false);
|
||||
return (
|
||||
<>
|
||||
<Stack spacing={"xl"} px={"sm"}>
|
||||
@@ -83,12 +84,28 @@ export default function Portofolio_EditLogoBisnis({
|
||||
</Stack>
|
||||
</Paper>
|
||||
|
||||
<Button
|
||||
radius={"xl"}
|
||||
onClick={() => onUpdate(router, dataPorto.id, file as any)}
|
||||
>
|
||||
Simpan
|
||||
</Button>
|
||||
{file ? (
|
||||
<Button
|
||||
radius={"xl"}
|
||||
onClick={() =>
|
||||
onUpdate(router, dataPorto.id, file as any, setLoading)
|
||||
}
|
||||
>
|
||||
Simpan
|
||||
</Button>
|
||||
) : (
|
||||
<Button
|
||||
disabled
|
||||
radius={"xl"}
|
||||
loading={loading ? true : false}
|
||||
loaderPosition="center"
|
||||
onClick={() =>
|
||||
onUpdate(router, dataPorto.id, file as any, setLoading)
|
||||
}
|
||||
>
|
||||
Simpan
|
||||
</Button>
|
||||
)}
|
||||
</Stack>
|
||||
</>
|
||||
);
|
||||
@@ -97,13 +114,15 @@ export default function Portofolio_EditLogoBisnis({
|
||||
async function onUpdate(
|
||||
router: AppRouterInstance,
|
||||
portoId: string,
|
||||
file: FormData
|
||||
file: FormData,
|
||||
setLoading: any
|
||||
) {
|
||||
const gambar = new FormData();
|
||||
gambar.append("file", file as any);
|
||||
|
||||
await Portofolio_funEditLogoBisnisById(portoId, gambar).then((res) => {
|
||||
if (res.status === 200) {
|
||||
setLoading(true);
|
||||
ComponentGlobal_NotifikasiBerhasil(res.message);
|
||||
router.back();
|
||||
} else {
|
||||
|
||||
@@ -18,9 +18,11 @@ export default function Portofolio_EditMedsosBisnis({
|
||||
}) {
|
||||
const router = useRouter();
|
||||
const [medsos, setMedsos] = useState(dataMedsos);
|
||||
const [loading, setLoading] = useState(false);
|
||||
|
||||
return (
|
||||
<>
|
||||
<pre>{JSON.stringify(dataMedsos, null, 2)}</pre>
|
||||
{/* <pre>{JSON.stringify(dataMedsos, null, 2)}</pre> */}
|
||||
<Paper shadow="lg" p={"sm"}>
|
||||
<Stack px={"sm"}>
|
||||
<TextInput
|
||||
@@ -82,7 +84,9 @@ export default function Portofolio_EditMedsosBisnis({
|
||||
<Button
|
||||
mt={"xl"}
|
||||
radius={"xl"}
|
||||
onClick={() => onUpdate(router, medsos)}
|
||||
loading={loading ? true : false}
|
||||
loaderPosition="center"
|
||||
onClick={() => onUpdate(router, medsos, setLoading)}
|
||||
>
|
||||
Update
|
||||
</Button>
|
||||
@@ -94,10 +98,12 @@ export default function Portofolio_EditMedsosBisnis({
|
||||
|
||||
async function onUpdate(
|
||||
router: AppRouterInstance,
|
||||
medsos: MODEL_PORTOFOLIO_MEDSOS
|
||||
medsos: MODEL_PORTOFOLIO_MEDSOS,
|
||||
setLoading: any
|
||||
) {
|
||||
await Portofolio_funEditMedsosById(medsos).then((res) => {
|
||||
if (res.status === 200) {
|
||||
setLoading(true);
|
||||
ComponentGlobal_NotifikasiBerhasil(res.message);
|
||||
router.back();
|
||||
} else {
|
||||
|
||||
@@ -4,8 +4,12 @@ import prisma from "@/app/lib/prisma";
|
||||
|
||||
export async function funGetListPortofolio(profileId: any) {
|
||||
const data = await prisma.portofolio.findMany({
|
||||
orderBy: {
|
||||
createdAt: "desc"
|
||||
},
|
||||
where: {
|
||||
profileId: profileId,
|
||||
active: true
|
||||
},
|
||||
select: {
|
||||
id: true,
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
|
||||
import prisma from "@/app/lib/prisma";
|
||||
|
||||
export async function Portofolio_getOneById(portoId: string) {
|
||||
// console.log(id)
|
||||
export async function portofolio_getOneById(portoId: string) {
|
||||
// console.log(id)
|
||||
const data = await prisma.portofolio.findUnique({
|
||||
where: {
|
||||
id: portoId,
|
||||
@@ -27,12 +27,17 @@ export async function Portofolio_getOneById(portoId: string) {
|
||||
},
|
||||
},
|
||||
Portofolio_MediaSosial: true,
|
||||
|
||||
|
||||
|
||||
|
||||
Profile: {
|
||||
select: {
|
||||
User: {
|
||||
select: {
|
||||
id: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
return data
|
||||
return data;
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ import {
|
||||
Center,
|
||||
Grid,
|
||||
Group,
|
||||
Loader,
|
||||
Paper,
|
||||
SimpleGrid,
|
||||
Stack,
|
||||
@@ -40,6 +41,10 @@ export default function ListPortofolioView({
|
||||
}) {
|
||||
const router = useRouter();
|
||||
const [porto, setPorto] = useState(listPorto);
|
||||
const [loading, setLoading] = useState(false);
|
||||
const [loadingPorto, setLoadingPorto] = useState(false);
|
||||
const [idPorto, setIdPorto] = useState("")
|
||||
|
||||
return (
|
||||
<>
|
||||
{/* <pre>{JSON.stringify(porto, null, 2)}</pre> */}
|
||||
@@ -50,10 +55,12 @@ export default function ListPortofolioView({
|
||||
<Title order={4}>Portofolio</Title>
|
||||
{profile?.User.id === userLoginId ? (
|
||||
<ActionIcon
|
||||
loading={loading ? true : false}
|
||||
variant="transparent"
|
||||
onClick={() =>
|
||||
router.push(RouterPortofolio.create + `${profile.id}`)
|
||||
}
|
||||
onClick={() => {
|
||||
router.push(RouterPortofolio.create + `${profile.id}`);
|
||||
setLoading(true);
|
||||
}}
|
||||
>
|
||||
<IconPencilPlus color={Warna.biru} />
|
||||
</ActionIcon>
|
||||
@@ -70,42 +77,49 @@ export default function ListPortofolioView({
|
||||
</Center>
|
||||
) : (
|
||||
<SimpleGrid
|
||||
cols={4}
|
||||
spacing="md"
|
||||
breakpoints={[
|
||||
{ maxWidth: "md", cols: 3, spacing: "md" },
|
||||
{ maxWidth: "sm", cols: 2, spacing: "sm" },
|
||||
{ maxWidth: "xs", cols: 1, spacing: "sm" },
|
||||
]}
|
||||
>
|
||||
{porto.map((e: any) => (
|
||||
<Paper
|
||||
key={e.id}
|
||||
bg={"gray.5"}
|
||||
radius={"md"}
|
||||
onClick={() => router.push(`/dev/portofolio/main/${e.id}/`)}
|
||||
>
|
||||
<Grid align="center" p={"sm"}>
|
||||
<Grid.Col span={"auto"}>
|
||||
<Text fw={"bold"} truncate>
|
||||
{e.namaBisnis}
|
||||
</Text>
|
||||
</Grid.Col>
|
||||
<Grid.Col span={2}>
|
||||
<Stack>
|
||||
<IconCaretRight color="black" size={35} />
|
||||
</Stack>
|
||||
</Grid.Col>
|
||||
</Grid>
|
||||
</Paper>
|
||||
))}
|
||||
</SimpleGrid>
|
||||
cols={4}
|
||||
spacing="md"
|
||||
breakpoints={[
|
||||
{ maxWidth: "md", cols: 3, spacing: "md" },
|
||||
{ maxWidth: "sm", cols: 2, spacing: "sm" },
|
||||
{ maxWidth: "xs", cols: 1, spacing: "sm" },
|
||||
]}
|
||||
>
|
||||
{porto.map((e) => (
|
||||
<Paper
|
||||
shadow="md"
|
||||
key={e.id}
|
||||
bg={"gray.5"}
|
||||
radius={"md"}
|
||||
onClick={() => {
|
||||
setIdPorto(e.id)
|
||||
setLoadingPorto(true);
|
||||
router.push(`/dev/portofolio/main/${e.id}/`);
|
||||
}}
|
||||
>
|
||||
<Grid align="center" p={"sm"}>
|
||||
<Grid.Col span={"auto"}>
|
||||
<Text fw={"bold"} lineClamp={1}>
|
||||
{e.namaBisnis}
|
||||
</Text>
|
||||
</Grid.Col>
|
||||
<Grid.Col span={"content"}>
|
||||
<Stack>
|
||||
{idPorto === e.id && loadingPorto ? (
|
||||
<Loader color="gray" size={25}/>
|
||||
) : (
|
||||
<IconCaretRight color="black" size={25} />
|
||||
)}
|
||||
</Stack>
|
||||
</Grid.Col>
|
||||
</Grid>
|
||||
</Paper>
|
||||
))}
|
||||
</SimpleGrid>
|
||||
)}
|
||||
</Box>
|
||||
</Stack>
|
||||
</Paper>
|
||||
|
||||
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -18,16 +18,25 @@ import ComponentKatalog_HeaderTamplate from "../../component/header_tamplate";
|
||||
import { title } from "process";
|
||||
import { useDisclosure } from "@mantine/hooks";
|
||||
import { RouterPortofolio } from "@/app/lib/router_hipmi/router_katalog";
|
||||
import { useState } from "react";
|
||||
|
||||
export default function PortofolioLayout({
|
||||
children,
|
||||
portoId,
|
||||
userLoginId,
|
||||
authorId,
|
||||
}: {
|
||||
children: any;
|
||||
portoId: any;
|
||||
userLoginId: string;
|
||||
authorId: string;
|
||||
}) {
|
||||
const router = useRouter();
|
||||
const [opened, { open, close }] = useDisclosure(false);
|
||||
const [loadingData, setLoadingData] = useState(false);
|
||||
const [loadingLogo, setLoadingLogo] = useState(false);
|
||||
const [loadingMedia, setLoadingMedia] = useState(false);
|
||||
|
||||
return (
|
||||
<>
|
||||
<AppShell
|
||||
@@ -43,9 +52,13 @@ export default function PortofolioLayout({
|
||||
<IconChevronLeft />
|
||||
</ActionIcon>
|
||||
<Title order={5}>Detail Portofolio</Title>
|
||||
<ActionIcon variant="transparent" onClick={() => open()}>
|
||||
<IconEdit />
|
||||
</ActionIcon>
|
||||
{userLoginId === authorId ? (
|
||||
<ActionIcon variant="transparent" onClick={() => open()}>
|
||||
<IconEdit />
|
||||
</ActionIcon>
|
||||
) : (
|
||||
<ActionIcon disabled variant="transparent"></ActionIcon>
|
||||
)}
|
||||
</Group>
|
||||
</Header>
|
||||
}
|
||||
@@ -56,7 +69,10 @@ export default function PortofolioLayout({
|
||||
<Button
|
||||
radius={"xl"}
|
||||
variant="outline"
|
||||
loaderPosition="center"
|
||||
loading={loadingData ? true : false}
|
||||
onClick={() => {
|
||||
setLoadingData(true);
|
||||
router.push(RouterPortofolio.edit_data_bisnis + `${portoId}`);
|
||||
}}
|
||||
>
|
||||
@@ -66,7 +82,10 @@ export default function PortofolioLayout({
|
||||
radius={"xl"}
|
||||
variant="outline"
|
||||
color="green"
|
||||
loaderPosition="center"
|
||||
loading={loadingLogo ? true : false}
|
||||
onClick={() => {
|
||||
setLoadingLogo(true);
|
||||
router.push(RouterPortofolio.edit_logo_bisnis + `${portoId}`);
|
||||
}}
|
||||
>
|
||||
@@ -76,7 +95,10 @@ export default function PortofolioLayout({
|
||||
radius={"xl"}
|
||||
variant="outline"
|
||||
color="orange"
|
||||
loaderPosition="center"
|
||||
loading={loadingMedia ? true : false}
|
||||
onClick={() => {
|
||||
setLoadingMedia(true);
|
||||
router.push(RouterPortofolio.edit_medsos_bisnis + `${portoId}`);
|
||||
}}
|
||||
>
|
||||
|
||||
@@ -39,7 +39,7 @@ import { redirect, useRouter } from "next/navigation";
|
||||
import { useState } from "react";
|
||||
import { MODEL_PORTOFOLIO } from "../model/interface";
|
||||
import { useDisclosure, useShallowEffect } from "@mantine/hooks";
|
||||
import { Portofolio_getOneById } from "../fun/get/get_one_portofolio";
|
||||
import { portofolio_getOneById } from "../fun/get/get_one_portofolio";
|
||||
import _ from "lodash";
|
||||
import { Portofolio_funDeletePortofolioById } from "../fun/delete/fun_delete_by_id";
|
||||
import { ComponentGlobal_NotifikasiBerhasil } from "@/app_modules/component_global/notif_global/notifikasi_berhasil";
|
||||
@@ -48,12 +48,15 @@ import { ComponentGlobal_NotifikasiGagal } from "@/app_modules/component_global/
|
||||
|
||||
export default function ViewPortofolio({
|
||||
dataPorto,
|
||||
userLoginId,
|
||||
}: {
|
||||
dataPorto: MODEL_PORTOFOLIO;
|
||||
userLoginId: string;
|
||||
}) {
|
||||
const router = useRouter();
|
||||
const [porto, setPorto] = useState(dataPorto);
|
||||
const [opened, { open, close }] = useDisclosure(false);
|
||||
const [loadingDel, setLoadingDel] = useState(false);
|
||||
|
||||
return (
|
||||
<>
|
||||
@@ -67,7 +70,7 @@ export default function ViewPortofolio({
|
||||
<IconBuildingSkyscraper />
|
||||
</Grid.Col>
|
||||
<Grid.Col span={"auto"}>
|
||||
<Text truncate>{dataPorto.namaBisnis}</Text>
|
||||
<Text>{dataPorto?.namaBisnis}</Text>
|
||||
</Grid.Col>
|
||||
</Grid>
|
||||
<Grid>
|
||||
@@ -75,7 +78,7 @@ export default function ViewPortofolio({
|
||||
<IconPhoneCall />
|
||||
</Grid.Col>
|
||||
<Grid.Col span={"auto"}>
|
||||
<Text>+{dataPorto.tlpn}</Text>
|
||||
<Text>+{dataPorto?.tlpn}</Text>
|
||||
</Grid.Col>
|
||||
</Grid>
|
||||
<Grid>
|
||||
@@ -83,7 +86,7 @@ export default function ViewPortofolio({
|
||||
<IconMapPin />
|
||||
</Grid.Col>
|
||||
<Grid.Col span={"auto"}>
|
||||
<Text>{dataPorto.alamatKantor}</Text>
|
||||
<Text>{dataPorto?.alamatKantor}</Text>
|
||||
</Grid.Col>
|
||||
</Grid>
|
||||
<Grid>
|
||||
@@ -91,7 +94,7 @@ export default function ViewPortofolio({
|
||||
<IconListDetails />
|
||||
</Grid.Col>
|
||||
<Grid.Col span={"auto"}>
|
||||
<Text>{dataPorto.MasterBidangBisnis.name}</Text>
|
||||
<Text>{dataPorto?.MasterBidangBisnis.name}</Text>
|
||||
</Grid.Col>
|
||||
</Grid>
|
||||
<Grid>
|
||||
@@ -99,7 +102,7 @@ export default function ViewPortofolio({
|
||||
<IconPinned />
|
||||
</Grid.Col>
|
||||
<Grid.Col span={"auto"}>
|
||||
<Text>{dataPorto.deskripsi}</Text>
|
||||
<Text>{dataPorto?.deskripsi}</Text>
|
||||
</Grid.Col>
|
||||
</Grid>
|
||||
</Stack>
|
||||
@@ -111,7 +114,7 @@ export default function ViewPortofolio({
|
||||
<Paper>
|
||||
<Image
|
||||
alt="Foto"
|
||||
src={RouterPortofolio.api_logo_porto + `${dataPorto.logoId}`}
|
||||
src={RouterPortofolio.api_logo_porto + `${dataPorto?.logoId}`}
|
||||
/>
|
||||
</Paper>
|
||||
</AspectRatio>
|
||||
@@ -125,8 +128,8 @@ export default function ViewPortofolio({
|
||||
<IconBrandFacebook />
|
||||
</Grid.Col>
|
||||
<Grid.Col span={"auto"}>
|
||||
{dataPorto.Portofolio_MediaSosial.facebook ? (
|
||||
<Text>{dataPorto.Portofolio_MediaSosial.facebook}</Text>
|
||||
{dataPorto?.Portofolio_MediaSosial.facebook ? (
|
||||
<Text>{dataPorto?.Portofolio_MediaSosial.facebook}</Text>
|
||||
) : (
|
||||
"-"
|
||||
)}
|
||||
@@ -137,8 +140,8 @@ export default function ViewPortofolio({
|
||||
<IconBrandInstagram />
|
||||
</Grid.Col>
|
||||
<Grid.Col span={"auto"}>
|
||||
{dataPorto.Portofolio_MediaSosial.instagram ? (
|
||||
<Text>{dataPorto.Portofolio_MediaSosial.instagram}</Text>
|
||||
{dataPorto?.Portofolio_MediaSosial.instagram ? (
|
||||
<Text>{dataPorto?.Portofolio_MediaSosial.instagram}</Text>
|
||||
) : (
|
||||
"-"
|
||||
)}
|
||||
@@ -149,8 +152,8 @@ export default function ViewPortofolio({
|
||||
<IconBrandTiktok />
|
||||
</Grid.Col>
|
||||
<Grid.Col span={"auto"}>
|
||||
{dataPorto.Portofolio_MediaSosial.tiktok ? (
|
||||
<Text>{dataPorto.Portofolio_MediaSosial.tiktok}</Text>
|
||||
{dataPorto?.Portofolio_MediaSosial.tiktok ? (
|
||||
<Text>{dataPorto?.Portofolio_MediaSosial.tiktok}</Text>
|
||||
) : (
|
||||
"-"
|
||||
)}
|
||||
@@ -161,8 +164,8 @@ export default function ViewPortofolio({
|
||||
<IconBrandTwitter />
|
||||
</Grid.Col>
|
||||
<Grid.Col span={"auto"}>
|
||||
{dataPorto.Portofolio_MediaSosial.twitter ? (
|
||||
<Text>{dataPorto.Portofolio_MediaSosial.twitter}</Text>
|
||||
{dataPorto?.Portofolio_MediaSosial.twitter ? (
|
||||
<Text>{dataPorto?.Portofolio_MediaSosial.twitter}</Text>
|
||||
) : (
|
||||
"-"
|
||||
)}
|
||||
@@ -173,8 +176,8 @@ export default function ViewPortofolio({
|
||||
<IconBrandYoutube />
|
||||
</Grid.Col>
|
||||
<Grid.Col span={"auto"}>
|
||||
{dataPorto.Portofolio_MediaSosial.youtube ? (
|
||||
<Text>{dataPorto.Portofolio_MediaSosial.youtube}</Text>
|
||||
{dataPorto?.Portofolio_MediaSosial.youtube ? (
|
||||
<Text>{dataPorto?.Portofolio_MediaSosial.youtube}</Text>
|
||||
) : (
|
||||
"-"
|
||||
)}
|
||||
@@ -204,7 +207,9 @@ export default function ViewPortofolio({
|
||||
<Button
|
||||
radius={"xl"}
|
||||
color="red"
|
||||
onClick={() => onDelete(router, dataPorto as any)}
|
||||
loaderPosition="center"
|
||||
loading={loadingDel ? true : false}
|
||||
onClick={() => onDelete(router, dataPorto as any, setLoadingDel)}
|
||||
>
|
||||
Hapus
|
||||
</Button>
|
||||
@@ -217,10 +222,12 @@ export default function ViewPortofolio({
|
||||
|
||||
async function onDelete(
|
||||
router: AppRouterInstance,
|
||||
dataPorto: MODEL_PORTOFOLIO
|
||||
dataPorto: MODEL_PORTOFOLIO,
|
||||
setLoadingDel: any
|
||||
) {
|
||||
await Portofolio_funDeletePortofolioById(dataPorto).then((res) => {
|
||||
if (res.status === 200) {
|
||||
setLoadingDel(true)
|
||||
ComponentGlobal_NotifikasiBerhasil(res.message);
|
||||
router.push(RouterProfile.katalog + `${dataPorto.profileId}`);
|
||||
} else {
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
"use server";
|
||||
|
||||
import prisma from "@/app/lib/prisma";
|
||||
import { User_getUserId } from "@/app_modules/fun_global/get_user_token";
|
||||
import { user_getOneUserId } from "@/app_modules/fun_global/get_user_token";
|
||||
import { revalidatePath } from "next/cache";
|
||||
|
||||
export async function Vote_funCreateHasil(
|
||||
pilihanVotingId: string,
|
||||
votingId: string
|
||||
) {
|
||||
const authorId = await User_getUserId();
|
||||
const authorId = await user_getOneUserId();
|
||||
|
||||
const get = await prisma.voting_DaftarNamaVote.findFirst({
|
||||
where: {
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
"use server";
|
||||
|
||||
import prisma from "@/app/lib/prisma";
|
||||
import { User_getUserId } from "@/app_modules/fun_global/get_user_token";
|
||||
import { user_getOneUserId } from "@/app_modules/fun_global/get_user_token";
|
||||
import { revalidatePath } from "next/cache";
|
||||
|
||||
export async function Vote_funCreatePilihanVotingById(
|
||||
namaVotingId: string,
|
||||
votingId: string
|
||||
) {
|
||||
const authorId = await User_getUserId();
|
||||
const authorId = await user_getOneUserId();
|
||||
|
||||
const create = await prisma.voting_Kontributor.create({
|
||||
data: {
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
"use server";
|
||||
|
||||
import { User_getUserId } from "@/app_modules/fun_global/get_user_token";
|
||||
import { user_getOneUserId } from "@/app_modules/fun_global/get_user_token";
|
||||
import { MODEL_VOTING } from "../../model/interface";
|
||||
import prisma from "@/app/lib/prisma";
|
||||
import { revalidatePath } from "next/cache";
|
||||
|
||||
export async function Vote_funCreate(req: MODEL_VOTING, listVote: any[]) {
|
||||
const authorId = await User_getUserId();
|
||||
const authorId = await user_getOneUserId();
|
||||
|
||||
const create = await prisma.voting.create({
|
||||
data: {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
"use server";
|
||||
|
||||
import prisma from "@/app/lib/prisma";
|
||||
import { User_getUserId } from "@/app_modules/fun_global/get_user_token";
|
||||
import { user_getOneUserId } from "@/app_modules/fun_global/get_user_token";
|
||||
import { revalidatePath } from "next/cache";
|
||||
|
||||
export async function Vote_funEditStatusByStatusId(
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
"use server";
|
||||
|
||||
import prisma from "@/app/lib/prisma";
|
||||
import { User_getUserId } from "@/app_modules/fun_global/get_user_token";
|
||||
import { user_getOneUserId } from "@/app_modules/fun_global/get_user_token";
|
||||
|
||||
export async function Vote_cekKontributorById(votingId: string) {
|
||||
const UserId = await User_getUserId()
|
||||
const UserId = await user_getOneUserId()
|
||||
|
||||
const cek = await prisma.voting_Kontributor.count({
|
||||
where: {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
"use server";
|
||||
|
||||
import prisma from "@/app/lib/prisma";
|
||||
import { User_getUserId } from "@/app_modules/fun_global/get_user_token";
|
||||
import { user_getOneUserId } from "@/app_modules/fun_global/get_user_token";
|
||||
|
||||
export async function Vote_getAllListPublish() {
|
||||
const data = await prisma.voting.findMany({
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
"use server";
|
||||
|
||||
import { User_getUserId } from "@/app_modules/fun_global/get_user_token";
|
||||
import { user_getOneUserId } from "@/app_modules/fun_global/get_user_token";
|
||||
import prisma from "@/app/lib/prisma";
|
||||
|
||||
export async function Vote_getAllListRiwayatSaya() {
|
||||
const authorId = await User_getUserId();
|
||||
const authorId = await user_getOneUserId();
|
||||
const data = await prisma.voting.findMany({
|
||||
orderBy: {
|
||||
createdAt: "asc",
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
"use server";
|
||||
|
||||
import prisma from "@/app/lib/prisma";
|
||||
import { User_getUserId } from "@/app_modules/fun_global/get_user_token";
|
||||
import { user_getOneUserId } from "@/app_modules/fun_global/get_user_token";
|
||||
|
||||
export async function Vote_getAllListKontribusiByAuthorId() {
|
||||
const authorId = await User_getUserId();
|
||||
const authorId = await user_getOneUserId();
|
||||
const data = await prisma.voting_Kontributor.findMany({
|
||||
orderBy: {
|
||||
createdAt: "asc",
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
"use server";
|
||||
|
||||
import prisma from "@/app/lib/prisma";
|
||||
import { User_getUserId } from "@/app_modules/fun_global/get_user_token";
|
||||
import { user_getOneUserId } from "@/app_modules/fun_global/get_user_token";
|
||||
|
||||
export async function Vote_getListByStatusId(statusId: string) {
|
||||
const authorId = await User_getUserId();
|
||||
const authorId = await user_getOneUserId();
|
||||
|
||||
if (statusId === "1") {
|
||||
const data = await prisma.voting.findMany({
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
"use server";
|
||||
|
||||
import prisma from "@/app/lib/prisma";
|
||||
import { User_getUserId } from "@/app_modules/fun_global/get_user_token";
|
||||
import { user_getOneUserId } from "@/app_modules/fun_global/get_user_token";
|
||||
|
||||
export async function Vote_getOnePilihanVotingByUserId(votingId: string) {
|
||||
const userId = await User_getUserId();
|
||||
const userId = await user_getOneUserId();
|
||||
const get = await prisma.voting_Kontributor.findFirst({
|
||||
where: {
|
||||
authorId: userId,
|
||||
|
||||
Reference in New Issue
Block a user