fix: admin app info
deskripsi: - penerapan filter jenis kelamin pada forum
This commit is contained in:
@@ -82,16 +82,7 @@ async function GET(request: Request) {
|
||||
const data = await prisma.sticker.findMany({
|
||||
skip: dataSkip,
|
||||
take: dataTake,
|
||||
where: {
|
||||
MasterEmotions: {
|
||||
some: {
|
||||
value: {
|
||||
contains: search ? search : "",
|
||||
mode: "insensitive",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
orderBy: {
|
||||
createdAt: "desc",
|
||||
},
|
||||
@@ -100,18 +91,7 @@ async function GET(request: Request) {
|
||||
},
|
||||
});
|
||||
|
||||
const nCount = await prisma.sticker.count({
|
||||
where: {
|
||||
MasterEmotions: {
|
||||
some: {
|
||||
value: {
|
||||
contains: search ? search : "",
|
||||
mode: "insensitive",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
const nCount = await prisma.sticker.count({});
|
||||
|
||||
fixData = {
|
||||
data: data,
|
||||
|
||||
@@ -15,7 +15,7 @@ async function GET(request: Request) {
|
||||
|
||||
let fixData;
|
||||
const { searchParams } = new URL(request.url);
|
||||
const emotion = searchParams.get("emotion");
|
||||
const gender = searchParams.get("gender");
|
||||
const page = searchParams.get("page");
|
||||
const dataTake = 10;
|
||||
const dataSkip = Number(page) * dataTake - dataTake;
|
||||
@@ -29,13 +29,9 @@ async function GET(request: Request) {
|
||||
},
|
||||
where: {
|
||||
isActive: true,
|
||||
MasterEmotions: {
|
||||
some: {
|
||||
value: {
|
||||
contains: emotion ? emotion : "",
|
||||
mode: "insensitive",
|
||||
},
|
||||
},
|
||||
jenisKelamin: {
|
||||
mode: "insensitive",
|
||||
contains: gender ?? "",
|
||||
},
|
||||
},
|
||||
include: {
|
||||
@@ -53,13 +49,9 @@ async function GET(request: Request) {
|
||||
take: dataTake,
|
||||
where: {
|
||||
isActive: true,
|
||||
MasterEmotions: {
|
||||
some: {
|
||||
value: {
|
||||
contains: emotion ? emotion : "",
|
||||
mode: "insensitive",
|
||||
},
|
||||
},
|
||||
jenisKelamin: {
|
||||
mode: "insensitive",
|
||||
contains: gender ?? "",
|
||||
},
|
||||
},
|
||||
orderBy: {
|
||||
@@ -73,13 +65,9 @@ async function GET(request: Request) {
|
||||
const nCount = await prisma.sticker.count({
|
||||
where: {
|
||||
isActive: true,
|
||||
MasterEmotions: {
|
||||
some: {
|
||||
value: {
|
||||
contains: emotion ? emotion : "",
|
||||
mode: "insensitive",
|
||||
},
|
||||
},
|
||||
jenisKelamin: {
|
||||
mode: "insensitive",
|
||||
contains: gender ?? "",
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
@@ -1,14 +1,16 @@
|
||||
import { funGetUserIdByToken } from "@/app_modules/_global/fun/get";
|
||||
import { Forum_Create } from "@/app_modules/forum";
|
||||
import Forum_NewCreate from "@/app_modules/forum/create/new_create";
|
||||
import { Forum_V3_Create } from "@/app_modules/forum/create/V3_create";
|
||||
|
||||
|
||||
export default async function Page() {
|
||||
const userLoginId = await funGetUserIdByToken();
|
||||
return (
|
||||
<>
|
||||
{/* <Forum_Create /> */}
|
||||
{/* <Forum_NewCreate/> */}
|
||||
<Forum_V3_Create/>
|
||||
<Forum_V3_Create userLoginId={userLoginId as string}/>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
import { funGetUserIdByToken } from "@/app_modules/_global/fun/get";
|
||||
import { Forum_EditPosting } from "@/app_modules/forum";
|
||||
import Forum_V3_EditPosting from "@/app_modules/forum/edit/posting/V3_edit_posting";
|
||||
|
||||
export default async function Page() {
|
||||
const userLoginId = await funGetUserIdByToken();
|
||||
return (
|
||||
<>
|
||||
{/* <Forum_EditPosting /> */}
|
||||
<Forum_V3_EditPosting/>
|
||||
<Forum_V3_EditPosting userLoginId={userLoginId as string}/>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
export const masterJenisKelamin = [
|
||||
{ value: "Laki-laki", label: "Laki-laki" },
|
||||
{ value: "Perempuan", label: "Perempuan" },
|
||||
{ value: "laki-laki", label: "Laki-laki" },
|
||||
{ value: "perempuan", label: "Perempuan" },
|
||||
];
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
export const apiGetStickerForUser = async ({ emotion }: { emotion?: string }) => {
|
||||
export const apiGetStickerForUser = async ({ gender }: { gender: string }) => {
|
||||
try {
|
||||
// Fetch token from cookie
|
||||
const { token } = await fetch("/api/get-cookie").then((res) => res.json());
|
||||
@@ -7,7 +7,7 @@ export const apiGetStickerForUser = async ({ emotion }: { emotion?: string })
|
||||
return null;
|
||||
}
|
||||
|
||||
const response = await fetch(`/api/sticker?emotion=${emotion || ""}`, {
|
||||
const response = await fetch(`/api/sticker?gender=${gender}`, {
|
||||
method: "GET",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
|
||||
@@ -104,15 +104,17 @@ export default function AdminAppInformation_ViewSticker() {
|
||||
cloneData[index].isActive = value;
|
||||
setDataSticker([...cloneData]);
|
||||
}
|
||||
|
||||
setOpened(false);
|
||||
setLoadingUpdate(false);
|
||||
ComponentAdminGlobal_NotifikasiBerhasil(updt.message);
|
||||
} else {
|
||||
setOpened(false);
|
||||
setLoadingUpdate(false);
|
||||
ComponentAdminGlobal_NotifikasiGagal(updt.message);
|
||||
}
|
||||
} catch (error) {
|
||||
console.log("Error update status sticker", error);
|
||||
} finally {
|
||||
setLoadingUpdate(false);
|
||||
console.log("Error update status sticker", error);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -197,13 +199,21 @@ export default function AdminAppInformation_ViewSticker() {
|
||||
)}
|
||||
</Stack>
|
||||
|
||||
<Admin_ComponentModal opened={opened} onClose={() => setOpened(false)}>
|
||||
<Admin_ComponentModal
|
||||
opened={opened}
|
||||
onClose={() => setOpened(false)}
|
||||
closeOnClickOutside={false}
|
||||
>
|
||||
<Stack>
|
||||
<Text fw={500} c={AdminColor.white}>
|
||||
Apakah anda yakin ingin mengubah status stiker ini ?
|
||||
</Text>
|
||||
<Group position="center">
|
||||
<Button
|
||||
style={{
|
||||
transition: "all 0.3s ease-in-out",
|
||||
}}
|
||||
disabled={loadingUpdate}
|
||||
radius={"xl"}
|
||||
onClick={() => {
|
||||
setOpened(false);
|
||||
@@ -213,6 +223,9 @@ export default function AdminAppInformation_ViewSticker() {
|
||||
Tidak
|
||||
</Button>
|
||||
<Button
|
||||
style={{
|
||||
transition: "all 0.3s ease-in-out",
|
||||
}}
|
||||
loading={loadingUpdate}
|
||||
loaderPosition="center"
|
||||
radius={"xl"}
|
||||
@@ -223,7 +236,6 @@ export default function AdminAppInformation_ViewSticker() {
|
||||
id: dataUpdate.id,
|
||||
value: dataUpdate.isActive,
|
||||
});
|
||||
setOpened(false);
|
||||
}}
|
||||
>
|
||||
Ya
|
||||
|
||||
@@ -2,78 +2,58 @@
|
||||
|
||||
import { ComponentGlobal_InputCountDown } from "@/app_modules/_global/component";
|
||||
import { funReplaceHtml } from "@/app_modules/_global/fun/fun_replace_html";
|
||||
import { apiGetUserById } from "@/app_modules/_global/lib/api_user";
|
||||
import { ISticker } from "@/app_modules/_global/lib/interface/stiker";
|
||||
import { maxInputLength } from "@/app_modules/_global/lib/maximal_setting";
|
||||
import { apiGetStickerForUser } from "@/app_modules/_global/lib/stiker/api_fecth_stiker_for_user";
|
||||
import { Component_V3_TextEditorWithSticker } from "@/app_modules/_global/lib/stiker/comp_V3_text_editor_stiker";
|
||||
import { Comp_ButtonSticker } from "@/app_modules/_global/lib/stiker/comp_button_sticker";
|
||||
import CustomSkeleton from "@/app_modules/components/CustomSkeleton";
|
||||
import { Group, Stack } from "@mantine/core";
|
||||
import { useDisclosure, useShallowEffect } from "@mantine/hooks";
|
||||
import { useRouter } from "next/navigation";
|
||||
import React, { useState } from "react";
|
||||
import Forum_ButtonCreatePosting from "../component/button/button_create_posting";
|
||||
import { apiGetStickerForUser } from "@/app_modules/_global/lib/stiker/api_fecth_stiker_for_user";
|
||||
import { apiGetMasterEmotions } from "@/app_modules/_global/lib/api_fetch_master";
|
||||
import pLimit from "p-limit";
|
||||
import global_limit from "@/lib/limit";
|
||||
import { ISticker } from "@/app_modules/_global/lib/interface/stiker";
|
||||
|
||||
export function Forum_V3_Create() {
|
||||
const router = useRouter();
|
||||
export function Forum_V3_Create({ userLoginId }: { userLoginId: string }) {
|
||||
const [editorContent, setEditorContent] = useState("");
|
||||
const [opened, { open, close }] = useDisclosure(false);
|
||||
const quillRef = React.useRef<any>(null);
|
||||
const [quillLoaded, setQuillLoaded] = useState<boolean>(false);
|
||||
const [isReady, setIsReady] = useState<boolean>(false);
|
||||
const [sticker, setSticker] = useState<ISticker[] | null>(null);
|
||||
const [emotion, setEmotion] = useState<any>([]);
|
||||
|
||||
// useShallowEffect(() => {
|
||||
// handleLoadData();
|
||||
// }, []);
|
||||
|
||||
// async function handleLoadData() {
|
||||
// const listLoadData = [
|
||||
// global_limit(onLoadEmotion),
|
||||
// global_limit(onLoadSticker),
|
||||
// ];
|
||||
// await Promise.all(listLoadData);
|
||||
// }
|
||||
|
||||
// useShallowEffect(() => {
|
||||
// onLoadEmotion();
|
||||
// }, []);
|
||||
|
||||
useShallowEffect(() => {
|
||||
onLoadSticker();
|
||||
onLoadData();
|
||||
}, []);
|
||||
|
||||
async function onLoadSticker() {
|
||||
async function onLoadData() {
|
||||
try {
|
||||
const response = await apiGetStickerForUser({ emotion });
|
||||
if (response.success) {
|
||||
setSticker(response.res.data);
|
||||
} else {
|
||||
console.error("Failed to get sticker", response.message);
|
||||
setSticker([]);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("Error get sticker", error);
|
||||
setSticker([]);
|
||||
}
|
||||
}
|
||||
const responseDataProfile = await apiGetUserById({
|
||||
id: userLoginId,
|
||||
});
|
||||
|
||||
async function onLoadEmotion() {
|
||||
try {
|
||||
const response = await apiGetMasterEmotions();
|
||||
if (response.success) {
|
||||
setEmotion(response.data);
|
||||
if (responseDataProfile.success) {
|
||||
try {
|
||||
const response = await apiGetStickerForUser({
|
||||
gender: responseDataProfile?.data?.Profile?.jenisKelamin,
|
||||
});
|
||||
if (response.success) {
|
||||
setSticker(response.res.data);
|
||||
} else {
|
||||
console.error("Failed to get sticker", response.message);
|
||||
setSticker([]);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("Error get sticker", error);
|
||||
setSticker([]);
|
||||
}
|
||||
} else {
|
||||
console.error("Failed to get emotion", response.message);
|
||||
setEmotion([]);
|
||||
console.error("Failed to get profile", responseDataProfile.message);
|
||||
setSticker(null);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("Error get emotion", error);
|
||||
setEmotion([]);
|
||||
console.error("Error get profile", error);
|
||||
setSticker(null);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
"use client";
|
||||
|
||||
import ComponentGlobal_IsEmptyData from "@/app_modules/_global/component/is_empty_data";
|
||||
import { apiGetUserById } from "@/app_modules/_global/lib/api_user";
|
||||
import { ISticker } from "@/app_modules/_global/lib/interface/stiker";
|
||||
import { apiGetStickerForUser } from "@/app_modules/_global/lib/stiker/api_fecth_stiker_for_user";
|
||||
import CustomSkeleton from "@/app_modules/components/CustomSkeleton";
|
||||
import { clientLogger } from "@/util/clientLogger";
|
||||
import mqtt_client from "@/util/mqtt_client";
|
||||
@@ -23,8 +26,6 @@ import {
|
||||
Forum_SkeletonListKomentar,
|
||||
} from "../component/skeleton_view";
|
||||
import { MODEL_FORUM_KOMENTAR, MODEL_FORUM_POSTING } from "../model/interface";
|
||||
import { ISticker } from "@/app_modules/_global/lib/interface/stiker";
|
||||
import { apiGetStickerForUser } from "@/app_modules/_global/lib/stiker/api_fecth_stiker_for_user";
|
||||
|
||||
export default function Forum_V3_MainDetail({
|
||||
userLoginId,
|
||||
@@ -41,26 +42,40 @@ export default function Forum_V3_MainDetail({
|
||||
>(null);
|
||||
const [activePage, setActivePage] = useState(1);
|
||||
const [isLoading, setIsLoading] = useState(false);
|
||||
|
||||
const [sticker, setSticker] = useState<ISticker[] | null>(null);
|
||||
const [emotion, setEmotion] = useState<any>([]);
|
||||
|
||||
useShallowEffect(() => {
|
||||
onLoadSticker();
|
||||
onLoadDataSticker();
|
||||
}, []);
|
||||
|
||||
async function onLoadSticker() {
|
||||
async function onLoadDataSticker() {
|
||||
try {
|
||||
const response = await apiGetStickerForUser({ emotion: "" });
|
||||
if (response.success) {
|
||||
setSticker(response.res.data);
|
||||
const responseDataProfile = await apiGetUserById({
|
||||
id: userLoginId,
|
||||
});
|
||||
|
||||
if (responseDataProfile.success) {
|
||||
try {
|
||||
const response = await apiGetStickerForUser({
|
||||
gender: responseDataProfile?.data?.Profile?.jenisKelamin,
|
||||
});
|
||||
if (response.success) {
|
||||
setSticker(response.res.data);
|
||||
} else {
|
||||
console.error("Failed to get sticker", response.message);
|
||||
setSticker([]);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("Error get sticker", error);
|
||||
setSticker([]);
|
||||
}
|
||||
} else {
|
||||
console.error("Failed to get sticker", response.message);
|
||||
setSticker([]);
|
||||
console.error("Failed to get profile", responseDataProfile.message);
|
||||
setSticker(null);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("Error get sticker", error);
|
||||
setSticker([]);
|
||||
console.error("Error get profile", error);
|
||||
setSticker(null);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -16,8 +16,13 @@ import Forum_ButtonUpdatePosting from "../../component/button/button_update_post
|
||||
import { MODEL_FORUM_POSTING } from "../../model/interface";
|
||||
import { ISticker } from "@/app_modules/_global/lib/interface/stiker";
|
||||
import { apiGetStickerForUser } from "@/app_modules/_global/lib/stiker/api_fecth_stiker_for_user";
|
||||
import { apiGetUserById } from "@/app_modules/_global/lib/api_user";
|
||||
|
||||
export default function Forum_V3_EditPosting() {
|
||||
export default function Forum_V3_EditPosting({
|
||||
userLoginId,
|
||||
}: {
|
||||
userLoginId: string;
|
||||
}) {
|
||||
const param = useParams<{ id: string }>();
|
||||
const [data, setData] = useState<MODEL_FORUM_POSTING | null>(null);
|
||||
|
||||
@@ -29,24 +34,40 @@ export default function Forum_V3_EditPosting() {
|
||||
const [sticker, setSticker] = useState<ISticker[] | null>(null);
|
||||
const [emotion, setEmotion] = useState<any>([]);
|
||||
|
||||
useShallowEffect(() => {
|
||||
onLoadSticker();
|
||||
}, []);
|
||||
|
||||
async function onLoadSticker() {
|
||||
try {
|
||||
const response = await apiGetStickerForUser({ emotion: "" });
|
||||
if (response.success) {
|
||||
setSticker(response.res.data);
|
||||
} else {
|
||||
console.error("Failed to get sticker", response.message);
|
||||
useShallowEffect(() => {
|
||||
onLoadData();
|
||||
}, []);
|
||||
|
||||
async function onLoadData() {
|
||||
try {
|
||||
const responseDataProfile = await apiGetUserById({
|
||||
id: userLoginId,
|
||||
});
|
||||
|
||||
if (responseDataProfile.success) {
|
||||
try {
|
||||
const response = await apiGetStickerForUser({
|
||||
gender: responseDataProfile?.data?.Profile?.jenisKelamin,
|
||||
});
|
||||
if (response.success) {
|
||||
setSticker(response.res.data);
|
||||
} else {
|
||||
console.error("Failed to get sticker", response.message);
|
||||
setSticker([]);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("Error get sticker", error);
|
||||
setSticker([]);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("Error get sticker", error);
|
||||
setSticker([]);
|
||||
} else {
|
||||
console.error("Failed to get profile", responseDataProfile.message);
|
||||
setSticker(null);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("Error get profile", error);
|
||||
setSticker(null);
|
||||
}
|
||||
}
|
||||
|
||||
useShallowEffect(() => {
|
||||
handleLoadData();
|
||||
|
||||
@@ -112,7 +112,10 @@ export default function CreateProfile() {
|
||||
withAsterisk
|
||||
label="Jenis Kelamin"
|
||||
placeholder="Pilih satu"
|
||||
data={masterJenisKelamin}
|
||||
data={[
|
||||
{ value: "Laki-laki", label: "Laki-laki" },
|
||||
{ value: "Perempuan", label: "Perempuan" },
|
||||
]}
|
||||
onChange={(val) => {
|
||||
setValue({
|
||||
...value,
|
||||
|
||||
@@ -212,7 +212,10 @@ export default function EditProfile() {
|
||||
withAsterisk
|
||||
label="Jenis Kelamin"
|
||||
value={data?.jenisKelamin}
|
||||
data={masterJenisKelamin}
|
||||
data={[
|
||||
{ value: "Laki-laki", label: "Laki-laki" },
|
||||
{ value: "Perempuan", label: "Perempuan" },
|
||||
]}
|
||||
onChange={(val: any) => {
|
||||
setData({
|
||||
...data,
|
||||
|
||||
Reference in New Issue
Block a user