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