♻️ refactor: create transfer project dialog component

This commit is contained in:
Wahyu Kurniawan 2024-03-14 21:57:26 +07:00
parent e4fdae3329
commit 9b3ac4654f
No known key found for this signature in database
GPG Key ID: 040A1549143A8E33
2 changed files with 58 additions and 16 deletions

View File

@ -0,0 +1,47 @@
import ConfirmDialog, {
ConfirmDialogProps,
} from 'components/shared/ConfirmDialog';
import React from 'react';
interface TransferProjectDialogProps extends ConfirmDialogProps {
projectName: string;
from: string;
to: string;
}
export const TransferProjectDialog = ({
projectName,
from,
to,
open,
handleCancel,
handleConfirm,
...props
}: TransferProjectDialogProps) => {
return (
<ConfirmDialog
{...props}
dialogTitle="Transfer project?"
handleCancel={handleCancel}
open={open}
confirmButtonTitle="Yes, confirm transfer"
handleConfirm={handleConfirm}
>
<p className="text-sm text-elements-high-em">
Upon confirmation, your project{' '}
<span className="text-sm font-mono text-elements-on-secondary bg-controls-secondary rounded px-0.5">
{projectName}
</span>{' '}
will be transferred from{' '}
<span className="text-sm font-mono text-elements-on-secondary bg-controls-secondary rounded px-0.5">
{from}
</span>{' '}
to{' '}
<span className="text-sm font-mono text-elements-on-secondary bg-controls-secondary rounded px-0.5">
{to}
</span>
.
</p>
</ConfirmDialog>
);
};

View File

@ -6,11 +6,11 @@ import { Organization } from 'gql-client';
import { Button, Typography, Input, Option } from '@material-tailwind/react';
import DeleteProjectDialog from '../../../../../components/projects/project/settings/DeleteProjectDialog';
import ConfirmDialog from '../../../../../components/shared/ConfirmDialog';
import { useGQLClient } from '../../../../../context/GQLClientContext';
import AsyncSelect from '../../../../../components/shared/AsyncSelect';
import { OutletContextType } from '../../../../../types';
import DeleteProjectDialog from 'components/projects/project/settings/DeleteProjectDialog';
import { useGQLClient } from 'context/GQLClientContext';
import AsyncSelect from 'components/shared/AsyncSelect';
import { OutletContextType } from 'types';
import { TransferProjectDialog } from 'components/projects/Dialog/TransferProjectDialog';
const CopyIcon = ({ value }: { value: string }) => {
return (
@ -230,19 +230,14 @@ const GeneralTabPanel = () => {
Transfer
</Button>
</form>
<ConfirmDialog
dialogTitle="Transfer project"
handleOpen={() => setOpenTransferDialog(!openTransferDialog)}
<TransferProjectDialog
handleCancel={() => setOpenTransferDialog(!openTransferDialog)}
open={openTransferDialog}
confirmButtonTitle="Yes, Confirm transfer"
handleConfirm={handleTransferProject}
color="blue"
>
<Typography variant="small" placeholder={''}>
Upon confirmation, your project {project.name} will be transferred
from {project.organization.name} to {selectedUserOrgName}.
</Typography>
</ConfirmDialog>
projectName={project.name}
from={project.organization.name}
to={selectedUserOrgName}
/>
</div>
<div className="mb-1">
<Typography variant="h6" placeholder={''}>