♻️ refactor: create disconnect repository dialog component

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

View File

@ -0,0 +1,30 @@
import ConfirmDialog, {
ConfirmDialogProps,
} from 'components/shared/ConfirmDialog';
import React from 'react';
interface DisconnectRepositoryDialogProps extends ConfirmDialogProps {}
export const DisconnectRepositoryDialog = ({
open,
handleCancel,
handleConfirm,
...props
}: DisconnectRepositoryDialogProps) => {
return (
<ConfirmDialog
{...props}
dialogTitle="Disconnect repository?"
handleCancel={handleCancel}
open={open}
confirmButtonTitle="Yes, confirm disconnect"
handleConfirm={handleConfirm}
confirmButtonProps={{ variant: 'danger' }}
>
<p className="text-sm text-elements-high-em">
Any data tied to your Git project may become misconfigured. Are you sure
you want to continue?
</p>
</ConfirmDialog>
);
};

View File

@ -2,8 +2,8 @@ import React, { useState } from 'react';
import { Button, Typography } from '@material-tailwind/react';
import { GitRepositoryDetails } from '../../../../types';
import ConfirmDialog from '../../../shared/ConfirmDialog';
import { GitRepositoryDetails } from 'types';
import { DisconnectRepositoryDialog } from 'components/projects/Dialog/DisconnectRepositoryDialog';
const RepoConnectedSection = ({
linkedRepo,
@ -34,21 +34,13 @@ const RepoConnectedSection = ({
^ Disconnect
</Button>
</div>
<ConfirmDialog
dialogTitle="Disconnect repository?"
handleOpen={() => setDisconnectRepoDialogOpen((preVal) => !preVal)}
<DisconnectRepositoryDialog
handleCancel={() => setDisconnectRepoDialogOpen((preVal) => !preVal)}
open={disconnectRepoDialogOpen}
confirmButtonTitle="Yes, confirm disconnect"
handleConfirm={() => {
setDisconnectRepoDialogOpen((preVal) => !preVal);
}}
color="red"
>
<Typography variant="small" placeholder={''}>
Any data tied to your Git project may become misconfigured. Are you
sure you want to continue?
</Typography>
</ConfirmDialog>
/>
</div>
);
};