feaT:suspend user, kontenhumas->layananpemerintahri

This commit is contained in:
Rama Priyanto 2025-11-04 22:31:33 +07:00
parent edad636ba1
commit ed4f1c20e2
12 changed files with 86 additions and 14 deletions

View File

@ -74,6 +74,13 @@ export default function Login() {
const response: any = await emailValidation(data);
if (response?.error) {
console.log("error", response);
if (response?.message?.messages[0]?.includes("suspended")) {
error(
"Untuk sementara akun Polda/Polres Anda di tangguhkan, silahkan hubungi Admin Mabes untuk konfirmasi, Terima Kasih"
);
return false;
}
if (response?.message?.messages[0]?.includes("failed to send mail")) {
error("Gagal Mengirim OTP");
return false;

View File

@ -2732,3 +2732,23 @@ export const VideoIcon = ({
</g>
</svg>
);
export const SuspendIcon = ({
size,
height = 37,
width = 32,
fill = "currentColor",
...props
}: IconSvgProps) => (
<svg
xmlns="http://www.w3.org/2000/svg"
width={size || width}
height={size || height}
{...props}
viewBox="0 0 24 24"
>
<path
fill="currentColor"
d="M12 2c5.5 0 10 4.5 10 10s-4.5 10-10 10S2 17.5 2 12S6.5 2 12 2m0 2c-1.9 0-3.6.6-4.9 1.7l11.2 11.2c1-1.4 1.7-3.1 1.7-4.9c0-4.4-3.6-8-8-8m4.9 14.3L5.7 7.1C4.6 8.4 4 10.1 4 12c0 4.4 3.6 8 8 8c1.9 0 3.6-.6 4.9-1.7"
/>
</svg>
);

View File

@ -112,7 +112,7 @@ export default function Comment(props: { id: string | null }) {
}
const req: any = {
activityTypeId: 5,
url: "https://kontenhumas.com/" + pathname,
url: "https://layananpemerintahri.com/" + pathname,
articleId: Number(id),
};
@ -172,7 +172,7 @@ export default function Comment(props: { id: string | null }) {
}
const req: any = {
activityTypeId: 5,
url: "https://kontenhumas.com/" + pathname,
url: "https://layananpemerintahri.com/" + pathname,
articleId: Number(id),
userId: Number(userId),
};

View File

@ -36,7 +36,7 @@ export default function EMagazineDetail() {
const doDownload = async (fileName: string, title: string): Promise<void> => {
try {
const response = await fetch(
`https://kontenhumas.com/magazine-files/viewer/${fileName}`
`https://layananpemerintahri.com/magazine-files/viewer/${fileName}`
);
if (!response.ok) {

View File

@ -39,7 +39,7 @@ export default function NewsDetailPage(props: { datas: any }) {
const sendActivity = async () => {
let req: any = {
activityTypeId: 2,
url: "https://kontenhumas.com" + pathname,
url: "https://layananpemerintahri.com/" + pathname,
articleId: Number(id?.split("-")[0]),
};
if (uid) {

View File

@ -49,11 +49,11 @@ export default function DetailNews(props: { data: any; listArticle: any }) {
const handleShare = async (platform: string) => {
let shareLink = "";
const urls = "https://kontenhumas.com/" + pathname;
const urls = "https://layananpemerintahri.com/" + pathname;
let req: any = {
activityTypeId: 3,
url: "https://kontenhumas.com/" + pathname,
url: "https://layananpemerintahri.com/" + pathname,
articleId: Number(id?.split("-")[0]),
};
if (uid) {

View File

@ -5,6 +5,7 @@ import {
DotsYIcon,
EyeIconMdi,
SearchIcon,
SuspendIcon,
} from "@/components/icons";
import { error, success } from "@/config/swal";
import { deleteArticle, getListArticle } from "@/services/article";
@ -40,8 +41,10 @@ const columns = [
{ name: "Username", uid: "username" },
{ name: "Fullname", uid: "fullname" },
{ name: "Email", uid: "email" },
{ name: "Identity Type", uid: "identityType" },
{ name: "Identity Number", uid: "identityNumber" },
{ name: "Status", uid: "status" },
// { name: "Identity Type", uid: "identityType" },
// { name: "Identity Number", uid: "identityNumber" },
// { name: "Users", uid: "users" },
// { name: "Status", uid: "status" },
{ name: "Aksi", uid: "actions" },
@ -124,6 +127,35 @@ export default function MasterUserTable() {
});
}
const handleSuspend = (id: number, status: boolean) => {
MySwal.fire({
title: `${!status ? "Lepas " : ""}Suspend User?`,
icon: "warning",
showCancelButton: true,
cancelButtonColor: "#3085d6",
confirmButtonColor: "#d33",
confirmButtonText: "Yes",
}).then((result) => {
if (result.isConfirmed) {
doSuspend(id, status);
}
});
};
async function doSuspend(id: number, status: boolean) {
// loading();
console.log("do suspend", id, status);
// const resDelete = await deleteMasterUser(id);
// if (resDelete?.error) {
// error(resDelete.message);
// return false;
// }
// close();
successSubmit();
}
const renderCell = useCallback((user: MasterUser, columnKey: Key) => {
const cellValue = user[columnKey as keyof MasterUser];
const statusColorMap: Record<string, ChipProps["color"]> = {
@ -140,12 +172,12 @@ export default function MasterUserTable() {
return (
<Chip
className="capitalize "
// color={statusColorMap[user.status]}
color={user?.isSuspend ? "danger" : "success"}
size="lg"
variant="flat"
>
<div className="flex flex-row items-center gap-2 justify-center">
{cellValue}
{user?.isSuspend ? "Suspend" : "Active"}
</div>
</Chip>
);
@ -166,6 +198,18 @@ export default function MasterUserTable() {
Edit
</Link>
</DropdownItem>
<DropdownItem
key="Suspend"
onClick={() => handleSuspend(user.id, !user?.isSuspend)}
>
<SuspendIcon
color="red"
width={20}
height={16}
className="inline mr-2 mb-1"
/>
Suspend
</DropdownItem>
<DropdownItem
key="Delete"
onClick={() => handleDelete(user.id)}

View File

@ -125,5 +125,5 @@ self.addEventListener("push", function (event) {
self.addEventListener("notificationclick", function (event) {
console.log("Notification click received.");
event.notification.close();
event.waitUntil(clients.openWindow("<https://kontenhumas.com>"));
event.waitUntil(clients.openWindow("<https://layananpemerintahri.com>"));
});

View File

@ -1,6 +1,6 @@
import axios from "axios";
const baseURL = "https://kontenhumas.com/api";
const baseURL = "https://layananpemerintahri.com/api";
const axiosInterceptorInstance = axios.create({
baseURL,

View File

@ -2,7 +2,7 @@ import axios from "axios";
import { postSignIn } from "../master-user";
import Cookies from "js-cookie";
const baseURL = "https://kontenhumas.com/api";
const baseURL = "https://layananpemerintahri.com/api";
const refreshToken = Cookies.get("refresh_token");

View File

@ -1,6 +1,6 @@
import axios from "axios";
const baseURL = "https://kontenhumas.com/api";
const baseURL = "https://layananpemerintahri.com/api";
const axiosBaseInstance = axios.create({
baseURL,

View File

@ -40,6 +40,7 @@ export type MasterUser = {
userRoleId: number;
username: string;
workType: string;
isSuspend?: boolean;
};
export type MasterUserRole = {