validate logout
This commit is contained in:
@ -30,7 +30,7 @@ import {
|
|||||||
DialogDescription,
|
DialogDescription,
|
||||||
DialogHeader,
|
DialogHeader,
|
||||||
DialogTitle,
|
DialogTitle,
|
||||||
DialogTrigger,
|
DialogTrigger
|
||||||
} from './dialog';
|
} from './dialog';
|
||||||
|
|
||||||
interface DataTableProps<TData, TValue> {
|
interface DataTableProps<TData, TValue> {
|
||||||
@ -67,7 +67,7 @@ export function DataTable<TData, TValue>({
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<div className="flex items-center py-4 justify-between">
|
<div className="flex items-center py-4 justify-between w-full">
|
||||||
<Input
|
<Input
|
||||||
placeholder="Search"
|
placeholder="Search"
|
||||||
value={(table.getColumn('name')?.getFilterValue() as string) ?? ''}
|
value={(table.getColumn('name')?.getFilterValue() as string) ?? ''}
|
||||||
@ -107,18 +107,20 @@ export function DataTable<TData, TValue>({
|
|||||||
<div className="space-x-2">
|
<div className="space-x-2">
|
||||||
<button
|
<button
|
||||||
className="btn btn-sm btn-icon btn-clear btn-light"
|
className="btn btn-sm btn-icon btn-clear btn-light"
|
||||||
onClick={() => onUpdate(row.original)}>
|
onClick={() => onUpdate(row.original)}
|
||||||
|
>
|
||||||
<KeenIcon icon="notepad-edit" />
|
<KeenIcon icon="notepad-edit" />
|
||||||
</button>
|
</button>
|
||||||
{
|
{onDelete ? (
|
||||||
onDelete ? (
|
|
||||||
<button
|
<button
|
||||||
className="btn btn-sm btn-icon btn-clear btn-light"
|
className="btn btn-sm btn-icon btn-clear btn-light"
|
||||||
onClick={() => onDelete(row.original)}>
|
onClick={() => onDelete(row.original)}
|
||||||
|
>
|
||||||
<KeenIcon icon="trash" />
|
<KeenIcon icon="trash" />
|
||||||
</button>
|
</button>
|
||||||
) : ('')
|
) : (
|
||||||
}
|
''
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
</TableCell>
|
</TableCell>
|
||||||
</TableRow>
|
</TableRow>
|
||||||
|
|||||||
@ -1,11 +1,11 @@
|
|||||||
import { apiConfig } from '@/config/api.config';
|
import { apiConfig } from '@/config/api.config';
|
||||||
import { Account, columns } from './Columns';
|
|
||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
import { useEffect, useState } from 'react';
|
import { useEffect, useState } from 'react';
|
||||||
import { getData } from '@/utils';
|
import { getData } from '@/utils';
|
||||||
import { useCallApi } from '@/hooks';
|
import { useCallApi } from '@/hooks';
|
||||||
import { DataTable } from '@/components/ui/DataTable';
|
import { DataTable } from '@/components/ui/DataTable';
|
||||||
import { Breadcrumbs, Link } from '@mui/material';
|
import { Breadcrumbs, Link } from '@mui/material';
|
||||||
|
import { Account, columns } from './Columns';
|
||||||
|
|
||||||
const API_URL = apiConfig.service_dashboard;
|
const API_URL = apiConfig.service_dashboard;
|
||||||
|
|
||||||
@ -75,7 +75,7 @@ const ManageAccount = () => {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<div className="container mx-auto p-5">
|
<div className="container mx-auto w-full">
|
||||||
<h1 className="text-xl font-medium leading-none text-gray-900 mb-3">Manage Account</h1>
|
<h1 className="text-xl font-medium leading-none text-gray-900 mb-3">Manage Account</h1>
|
||||||
<Breadcrumbs>
|
<Breadcrumbs>
|
||||||
<Link underline="none" color="inherit" href="/">
|
<Link underline="none" color="inherit" href="/">
|
||||||
|
|||||||
@ -182,7 +182,7 @@ const ManageGroups = () => {
|
|||||||
onDelete={handleDelete}
|
onDelete={handleDelete}
|
||||||
/>
|
/>
|
||||||
<Dialog open={isDialogOpen} onClose={closeDialog}>
|
<Dialog open={isDialogOpen} onClose={closeDialog}>
|
||||||
<DialogContent className="w-[600px]">
|
<DialogContent className="w-full">
|
||||||
<div className="flex justify-between">
|
<div className="flex justify-between">
|
||||||
<DialogTitle>Create New Group</DialogTitle>
|
<DialogTitle>Create New Group</DialogTitle>
|
||||||
<Box display="flex" justifyContent="flex-end">
|
<Box display="flex" justifyContent="flex-end">
|
||||||
|
|||||||
@ -142,7 +142,7 @@ const Kyc = () => {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<div className="container mx-auto py-5">
|
<div className="container mx-auto w-full">
|
||||||
<ConfirmDialog
|
<ConfirmDialog
|
||||||
open={dialogOpen}
|
open={dialogOpen}
|
||||||
onClose={() => setDialogOpen(false)}
|
onClose={() => setDialogOpen(false)}
|
||||||
|
|||||||
@ -132,51 +132,51 @@ export const columns: ColumnDef<Members>[] = [
|
|||||||
];
|
];
|
||||||
|
|
||||||
export const initialMember = {
|
export const initialMember = {
|
||||||
id: "",
|
id: '',
|
||||||
fullname: "",
|
fullname: '',
|
||||||
email: "",
|
email: '',
|
||||||
username: "",
|
username: '',
|
||||||
msisdn: "",
|
msisdn: '',
|
||||||
password: "",
|
password: '',
|
||||||
pin: "",
|
pin: '',
|
||||||
try_pin: "",
|
try_pin: '',
|
||||||
mother_fullname: "",
|
mother_fullname: '',
|
||||||
agent_name: "",
|
agent_name: '',
|
||||||
bank_name: "",
|
bank_name: '',
|
||||||
bank_account: "",
|
bank_account: '',
|
||||||
ibank_number: "",
|
ibank_number: '',
|
||||||
address: "",
|
address: '',
|
||||||
longitude: "",
|
longitude: '',
|
||||||
latitude: "",
|
latitude: '',
|
||||||
nationality: "",
|
nationality: '',
|
||||||
photouser: "",
|
photouser: '',
|
||||||
photomerchant: "",
|
photomerchant: '',
|
||||||
file_selfie: "",
|
file_selfie: '',
|
||||||
file_document_id: "",
|
file_document_id: '',
|
||||||
file_document_id_selfie: "",
|
file_document_id_selfie: '',
|
||||||
file_commercial_license: "",
|
file_commercial_license: '',
|
||||||
identity_type: "",
|
identity_type: '',
|
||||||
identity_number: "",
|
identity_number: '',
|
||||||
license_number: "",
|
license_number: '',
|
||||||
date_birth: "",
|
date_birth: '',
|
||||||
gender: "",
|
gender: '',
|
||||||
status: "N",
|
status: 'N',
|
||||||
isneedapproval: "",
|
isneedapproval: '',
|
||||||
isapproved: "",
|
isapproved: '',
|
||||||
approveddate: "",
|
approveddate: '',
|
||||||
approvedby: "",
|
approvedby: '',
|
||||||
created_by: "",
|
created_by: '',
|
||||||
created_at: "",
|
created_at: '',
|
||||||
updated_by: "",
|
updated_by: '',
|
||||||
updated_at: "",
|
updated_at: '',
|
||||||
deleted_by: "",
|
deleted_by: '',
|
||||||
deleted_at: "",
|
deleted_at: '',
|
||||||
group: "",
|
group: '',
|
||||||
point_tier: "",
|
point_tier: '',
|
||||||
language: "",
|
language: '',
|
||||||
municipio: "",
|
municipio: '',
|
||||||
posto_adms: "",
|
posto_adms: '',
|
||||||
suco: "",
|
suco: '',
|
||||||
aldeia: "",
|
aldeia: '',
|
||||||
profession: "",
|
profession: ''
|
||||||
}
|
};
|
||||||
|
|||||||
@ -115,7 +115,7 @@ const ManageMembers = () => {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<div className="container mx-auto p-5">
|
<div className="container mx-auto w-full">
|
||||||
<ConfirmDialog
|
<ConfirmDialog
|
||||||
open={dialogOpen}
|
open={dialogOpen}
|
||||||
onClose={() => setDialogOpen(false)}
|
onClose={() => setDialogOpen(false)}
|
||||||
|
|||||||
@ -9,7 +9,7 @@ const ManageMenu = () => {
|
|||||||
return (
|
return (
|
||||||
<ManageMenusContextProvider>
|
<ManageMenusContextProvider>
|
||||||
<Container>
|
<Container>
|
||||||
<h1 className="text-xl font-medium leading-none text-gray-900 mb-5">Manage Menus</h1>
|
<h1 className="text-xl font-medium leading-none text-gray-900 mb-3">Manage Menu</h1>
|
||||||
<Breadcrumbs sx={{ mb: 2 }}>
|
<Breadcrumbs sx={{ mb: 2 }}>
|
||||||
<Link underline="none" color="inherit" href="/">
|
<Link underline="none" color="inherit" href="/">
|
||||||
<span className="text-sm hover:underline">Dashboard</span>
|
<span className="text-sm hover:underline">Dashboard</span>
|
||||||
@ -20,7 +20,7 @@ const ManageMenu = () => {
|
|||||||
</Link>
|
</Link>
|
||||||
|
|
||||||
<Link underline="none" color="inherit">
|
<Link underline="none" color="inherit">
|
||||||
<span className="text-sm">Manage Menus</span>
|
<span className="text-sm">Manage Menu</span>
|
||||||
</Link>
|
</Link>
|
||||||
</Breadcrumbs>
|
</Breadcrumbs>
|
||||||
<div className="grid gap-5 lg:gap-7.5">
|
<div className="grid gap-5 lg:gap-7.5">
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
import { Fragment } from 'react';
|
import { Fragment, useState } from 'react';
|
||||||
import { Link } from 'react-router-dom';
|
import { Link } from 'react-router-dom';
|
||||||
import { FormattedMessage } from 'react-intl';
|
import { FormattedMessage } from 'react-intl';
|
||||||
import { getAuth, useAuthContext } from '@/auth';
|
import { getAuth, useAuthContext } from '@/auth';
|
||||||
@ -15,6 +15,8 @@ import {
|
|||||||
MenuArrow,
|
MenuArrow,
|
||||||
MenuIcon
|
MenuIcon
|
||||||
} from '@/components/menu';
|
} from '@/components/menu';
|
||||||
|
import { Alert, Button, Dialog, DialogContent } from '@mui/material';
|
||||||
|
import { DialogFooter, DialogHeader } from '@/components/ui/dialog';
|
||||||
|
|
||||||
interface IDropdownUserProps {
|
interface IDropdownUserProps {
|
||||||
menuItemRef: any;
|
menuItemRef: any;
|
||||||
@ -26,6 +28,12 @@ interface IDropdownUserProps {
|
|||||||
|
|
||||||
const DropdownUser = ({ menuItemRef }: IDropdownUserProps) => {
|
const DropdownUser = ({ menuItemRef }: IDropdownUserProps) => {
|
||||||
const { logout, auth } = useAuthContext();
|
const { logout, auth } = useAuthContext();
|
||||||
|
const [showLogoutDialog, setShowLogoutDialog] = useState(false);
|
||||||
|
|
||||||
|
const handleLogout = () => {
|
||||||
|
setShowLogoutDialog(false); // Tutup dialog
|
||||||
|
logout(); // Panggil fungsi logout
|
||||||
|
};
|
||||||
|
|
||||||
const buildHeader = () => {
|
const buildHeader = () => {
|
||||||
return (
|
return (
|
||||||
@ -73,7 +81,10 @@ const DropdownUser = ({ menuItemRef }: IDropdownUserProps) => {
|
|||||||
return (
|
return (
|
||||||
<div className="flex flex-col">
|
<div className="flex flex-col">
|
||||||
<div className="menu-item px-4 py-1.5">
|
<div className="menu-item px-4 py-1.5">
|
||||||
<a onClick={logout} className="btn btn-sm btn-light justify-center">
|
<a
|
||||||
|
onClick={() => setShowLogoutDialog(true)}
|
||||||
|
className="btn btn-sm btn-light justify-center"
|
||||||
|
>
|
||||||
<FormattedMessage id="USER.MENU.LOGOUT" />
|
<FormattedMessage id="USER.MENU.LOGOUT" />
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
@ -89,6 +100,25 @@ const DropdownUser = ({ menuItemRef }: IDropdownUserProps) => {
|
|||||||
{buildHeader()}
|
{buildHeader()}
|
||||||
{buildMenu()}
|
{buildMenu()}
|
||||||
{buildFooter()}
|
{buildFooter()}
|
||||||
|
|
||||||
|
<Dialog open={showLogoutDialog} onClose={(open) => setShowLogoutDialog(false)}>
|
||||||
|
<DialogContent className="container-fixed max-w-md flex flex-col p-5 overflow-hidden [&>button]:hidden">
|
||||||
|
<DialogHeader className="p-0 border-0 block">
|
||||||
|
<Alert severity="warning" variant="filled">
|
||||||
|
<h3 className="text-lg">Are you sure?</h3>
|
||||||
|
<span className="text-sm">You are about to log out!</span>
|
||||||
|
</Alert>
|
||||||
|
</DialogHeader>
|
||||||
|
<DialogFooter className="flex justify-end items-center gap-4 mt-3">
|
||||||
|
<Button variant={'outlined'} onClick={() => setShowLogoutDialog(false)}>
|
||||||
|
Cancel
|
||||||
|
</Button>
|
||||||
|
<Button variant="outlined" color="error" onClick={handleLogout}>
|
||||||
|
Logout
|
||||||
|
</Button>
|
||||||
|
</DialogFooter>
|
||||||
|
</DialogContent>
|
||||||
|
</Dialog>
|
||||||
</MenuSub>
|
</MenuSub>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user