♻️ 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 { Button, Typography } from '@material-tailwind/react';
import { GitRepositoryDetails } from '../../../../types'; import { GitRepositoryDetails } from 'types';
import ConfirmDialog from '../../../shared/ConfirmDialog'; import { DisconnectRepositoryDialog } from 'components/projects/Dialog/DisconnectRepositoryDialog';
const RepoConnectedSection = ({ const RepoConnectedSection = ({
linkedRepo, linkedRepo,
@ -34,21 +34,13 @@ const RepoConnectedSection = ({
^ Disconnect ^ Disconnect
</Button> </Button>
</div> </div>
<ConfirmDialog <DisconnectRepositoryDialog
dialogTitle="Disconnect repository?" handleCancel={() => setDisconnectRepoDialogOpen((preVal) => !preVal)}
handleOpen={() => setDisconnectRepoDialogOpen((preVal) => !preVal)}
open={disconnectRepoDialogOpen} open={disconnectRepoDialogOpen}
confirmButtonTitle="Yes, confirm disconnect"
handleConfirm={() => { handleConfirm={() => {
setDisconnectRepoDialogOpen((preVal) => !preVal); 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> </div>
); );
}; };