fix:suspend account
This commit is contained in:
parent
ed4f1c20e2
commit
87baa5e2a1
|
|
@ -72,14 +72,15 @@ export default function Login() {
|
||||||
// login dengan otp
|
// login dengan otp
|
||||||
loading();
|
loading();
|
||||||
const response: any = await emailValidation(data);
|
const response: any = await emailValidation(data);
|
||||||
if (response?.error) {
|
if (response?.data?.messages[0]?.includes("Suspended")) {
|
||||||
console.log("error", response);
|
close();
|
||||||
if (response?.message?.messages[0]?.includes("suspended")) {
|
|
||||||
error(
|
error(
|
||||||
"Untuk sementara akun Polda/Polres Anda di tangguhkan, silahkan hubungi Admin Mabes untuk konfirmasi, Terima Kasih"
|
"Untuk sementara akun Polda/Polres Anda di tangguhkan, silahkan hubungi Admin Mabes untuk konfirmasi, Terima Kasih"
|
||||||
);
|
);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
if (response?.error) {
|
||||||
|
console.log("error", response);
|
||||||
|
|
||||||
if (response?.message?.messages[0]?.includes("failed to send mail")) {
|
if (response?.message?.messages[0]?.includes("failed to send mail")) {
|
||||||
error("Gagal Mengirim OTP");
|
error("Gagal Mengirim OTP");
|
||||||
|
|
|
||||||
|
|
@ -1421,14 +1421,16 @@ export const Checklist = ({
|
||||||
size = 24,
|
size = 24,
|
||||||
width,
|
width,
|
||||||
height,
|
height,
|
||||||
|
fill = "currentColor",
|
||||||
|
|
||||||
...props
|
...props
|
||||||
}: IconSvgProps) => (
|
}: IconSvgProps) => (
|
||||||
<svg
|
<svg
|
||||||
width="25"
|
|
||||||
height="24"
|
|
||||||
viewBox="0 0 25 24"
|
|
||||||
fill="none"
|
|
||||||
xmlns="http://www.w3.org/2000/svg"
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
width={size || width}
|
||||||
|
height={size || height}
|
||||||
|
{...props}
|
||||||
|
viewBox="0 0 25 24"
|
||||||
>
|
>
|
||||||
<g clipPath="url(#clip0_681_10672)">
|
<g clipPath="url(#clip0_681_10672)">
|
||||||
<path
|
<path
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
"use client";
|
"use client";
|
||||||
import {
|
import {
|
||||||
|
Checklist,
|
||||||
CreateIconIon,
|
CreateIconIon,
|
||||||
DeleteIcon,
|
DeleteIcon,
|
||||||
DotsYIcon,
|
DotsYIcon,
|
||||||
|
|
@ -7,9 +8,13 @@ import {
|
||||||
SearchIcon,
|
SearchIcon,
|
||||||
SuspendIcon,
|
SuspendIcon,
|
||||||
} from "@/components/icons";
|
} from "@/components/icons";
|
||||||
import { error, success } from "@/config/swal";
|
import { error, loading, success } from "@/config/swal";
|
||||||
import { deleteArticle, getListArticle } from "@/services/article";
|
import { deleteArticle, getListArticle } from "@/services/article";
|
||||||
import { deleteMasterUser, listMasterUsers } from "@/services/master-user";
|
import {
|
||||||
|
changeSuspendStatus,
|
||||||
|
deleteMasterUser,
|
||||||
|
listMasterUsers,
|
||||||
|
} from "@/services/master-user";
|
||||||
import { Article, MasterUser } from "@/types/globals";
|
import { Article, MasterUser } from "@/types/globals";
|
||||||
import { Button } from "@heroui/button";
|
import { Button } from "@heroui/button";
|
||||||
import { Input } from "@heroui/input";
|
import { Input } from "@heroui/input";
|
||||||
|
|
@ -143,16 +148,19 @@ export default function MasterUserTable() {
|
||||||
};
|
};
|
||||||
|
|
||||||
async function doSuspend(id: number, status: boolean) {
|
async function doSuspend(id: number, status: boolean) {
|
||||||
// loading();
|
loading();
|
||||||
|
|
||||||
console.log("do suspend", id, status);
|
console.log("do suspend", id, status);
|
||||||
// const resDelete = await deleteMasterUser(id);
|
const res = await changeSuspendStatus({
|
||||||
|
user_id: id,
|
||||||
|
is_suspended: status,
|
||||||
|
});
|
||||||
|
|
||||||
// if (resDelete?.error) {
|
if (res?.error) {
|
||||||
// error(resDelete.message);
|
error(res.message);
|
||||||
// return false;
|
return false;
|
||||||
// }
|
}
|
||||||
// close();
|
close();
|
||||||
successSubmit();
|
successSubmit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -172,12 +180,12 @@ export default function MasterUserTable() {
|
||||||
return (
|
return (
|
||||||
<Chip
|
<Chip
|
||||||
className="capitalize "
|
className="capitalize "
|
||||||
color={user?.isSuspend ? "danger" : "success"}
|
color={user?.isSuspended ? "danger" : "success"}
|
||||||
size="lg"
|
size="lg"
|
||||||
variant="flat"
|
variant="flat"
|
||||||
>
|
>
|
||||||
<div className="flex flex-row items-center gap-2 justify-center">
|
<div className="flex flex-row items-center gap-2 justify-center">
|
||||||
{user?.isSuspend ? "Suspend" : "Active"}
|
{user?.isSuspended ? "Suspend" : "Active"}
|
||||||
</div>
|
</div>
|
||||||
</Chip>
|
</Chip>
|
||||||
);
|
);
|
||||||
|
|
@ -200,15 +208,25 @@ export default function MasterUserTable() {
|
||||||
</DropdownItem>
|
</DropdownItem>
|
||||||
<DropdownItem
|
<DropdownItem
|
||||||
key="Suspend"
|
key="Suspend"
|
||||||
onClick={() => handleSuspend(user.id, !user?.isSuspend)}
|
onClick={() => handleSuspend(user.id, !user?.isSuspended)}
|
||||||
>
|
>
|
||||||
|
{user?.isSuspended ? (
|
||||||
|
<Checklist
|
||||||
|
color="green"
|
||||||
|
width={20}
|
||||||
|
height={16}
|
||||||
|
className="inline mr-2 mb-1"
|
||||||
|
/>
|
||||||
|
) : (
|
||||||
<SuspendIcon
|
<SuspendIcon
|
||||||
color="red"
|
color="red"
|
||||||
width={20}
|
width={20}
|
||||||
height={16}
|
height={16}
|
||||||
className="inline mr-2 mb-1"
|
className="inline mr-2 mb-1"
|
||||||
/>
|
/>
|
||||||
Suspend
|
)}
|
||||||
|
|
||||||
|
{user?.isSuspended ? "Unsuspend" : "Suspend"}
|
||||||
</DropdownItem>
|
</DropdownItem>
|
||||||
<DropdownItem
|
<DropdownItem
|
||||||
key="Delete"
|
key="Delete"
|
||||||
|
|
|
||||||
|
|
@ -138,6 +138,14 @@ export async function otpValidationLogin(data: any) {
|
||||||
return await httpPost(`/users/otp-validation`, headers, data);
|
return await httpPost(`/users/otp-validation`, headers, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function changeSuspendStatus(data: any) {
|
||||||
|
const headers = {
|
||||||
|
"content-type": "application/json",
|
||||||
|
Authorization: `Bearer ${token}`,
|
||||||
|
};
|
||||||
|
return await httpPost(`/users/suspend`, headers, data);
|
||||||
|
}
|
||||||
|
|
||||||
export async function postArticleComment(data: any) {
|
export async function postArticleComment(data: any) {
|
||||||
const headers = token
|
const headers = token
|
||||||
? {
|
? {
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,7 @@ export type MasterUser = {
|
||||||
userRoleId: number;
|
userRoleId: number;
|
||||||
username: string;
|
username: string;
|
||||||
workType: string;
|
workType: string;
|
||||||
isSuspend?: boolean;
|
isSuspended?: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type MasterUserRole = {
|
export type MasterUserRole = {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue