erp-platform/ui/src/views/shared/DialogContext/DialogShowComponent.tsx

95 lines
2.8 KiB
TypeScript
Raw Normal View History

2025-05-06 06:45:49 +00:00
import TenantsConnectionString from '@/views/admin/tenant-management/TenantsConnectionString'
import { useDialogContext } from './DialogProvider'
import CreateNotification from '@/views/admin/notification/CreateNotification'
2025-06-16 12:16:27 +00:00
import AuditLogDetail from '@/views/admin/auditLog/AuditLogDetail'
2025-06-28 21:34:28 +00:00
import RolesPermission from '@/views/admin/role-management/RolesPermission'
import UsersPermission from '@/views/admin/user-management/UsersPermission'
2025-10-09 19:53:36 +00:00
import BranchSeed from '@/views/branch/BranchSeed'
2025-10-16 12:47:32 +00:00
import QuestionDialog from '@/views/coordinator/QuestionDialog'
2025-05-06 06:45:49 +00:00
const DialogShowComponent = (): JSX.Element => {
const dialogContext: any = useDialogContext()
2025-10-16 22:15:34 +00:00
const handleDialogClose = () => {
if (dialogContext.config?.onClose) {
dialogContext.config.onClose()
}
dialogContext.setConfig({})
}
2025-05-06 06:45:49 +00:00
const getComponent = (param: string) => {
switch (param) {
case 'RolesPermission':
return (
<RolesPermission
open={true}
2025-10-16 22:15:34 +00:00
onDialogClose={handleDialogClose}
2025-05-06 06:45:49 +00:00
{...dialogContext.config?.props}
></RolesPermission>
)
case 'UsersPermission':
return (
<UsersPermission
open={true}
2025-10-16 22:15:34 +00:00
onDialogClose={handleDialogClose}
2025-05-06 06:45:49 +00:00
{...dialogContext.config?.props}
></UsersPermission>
)
case 'TenantsConnectionString':
return (
<TenantsConnectionString
open={true}
2025-10-16 22:15:34 +00:00
onDialogClose={handleDialogClose}
2025-05-06 06:45:49 +00:00
{...dialogContext.config?.props}
></TenantsConnectionString>
)
case 'CreateNotification':
2025-10-09 19:53:36 +00:00
return (
<CreateNotification
open={true}
2025-10-16 22:15:34 +00:00
onDialogClose={handleDialogClose}
2025-10-09 19:53:36 +00:00
{...dialogContext.config?.props}
></CreateNotification>
)
case 'AuditLogDetail':
return (
<AuditLogDetail
open={true}
2025-10-16 22:15:34 +00:00
onDialogClose={handleDialogClose}
2025-10-09 19:53:36 +00:00
{...dialogContext.config?.props}
></AuditLogDetail>
)
case 'BranchSeed':
return (
<BranchSeed
open={true}
2025-10-16 22:15:34 +00:00
onDialogClose={handleDialogClose}
2025-10-09 19:53:36 +00:00
{...dialogContext.config?.props}
></BranchSeed>
)
2025-10-16 12:47:32 +00:00
case 'QuestionAnswers':
return (
<QuestionDialog
open={true}
2025-10-16 22:15:34 +00:00
onDialogClose={handleDialogClose}
2025-10-16 12:47:32 +00:00
{...dialogContext.config?.props}
></QuestionDialog>
)
2025-10-22 12:16:34 +00:00
case 'CollectiveLeave':
return (
<QuestionDialog
open={true}
onDialogClose={handleDialogClose}
{...dialogContext.config?.props}
></QuestionDialog>
)
2025-05-06 06:45:49 +00:00
default:
return <></>
}
}
return getComponent(dialogContext.config?.component)
}
export default DialogShowComponent