diff --git a/packages/frontend/src/components/projects/project/settings/Domains.tsx b/packages/frontend/src/components/projects/project/settings/Domains.tsx index d706a09..9a5f442 100644 --- a/packages/frontend/src/components/projects/project/settings/Domains.tsx +++ b/packages/frontend/src/components/projects/project/settings/Domains.tsx @@ -1,5 +1,6 @@ import React from 'react'; import { useParams, Link } from 'react-router-dom'; + import { Button, Typography } from '@material-tailwind/react'; import DomainCard from './DomainCard'; diff --git a/packages/frontend/src/components/projects/project/settings/GitTabPanel.tsx b/packages/frontend/src/components/projects/project/settings/GitTabPanel.tsx index 80e2919..9f743bb 100644 --- a/packages/frontend/src/components/projects/project/settings/GitTabPanel.tsx +++ b/packages/frontend/src/components/projects/project/settings/GitTabPanel.tsx @@ -1,4 +1,6 @@ -import React, { useState } from 'react'; +import React, { useEffect, useState } from 'react'; +import { useForm } from 'react-hook-form'; +import toast from 'react-hot-toast'; import { Button, Input, Switch, Typography } from '@material-tailwind/react'; @@ -6,10 +8,12 @@ import RepositoryList from '../../create/RepositoryList'; import RepoConnectedSection from './RepoConnectedSection'; import GitSelectionSection from './GitSelectionSection'; import { GitSelect, RepositoryDetails } from '../../../../types/project'; +import WebhookCard from './WebhookCard'; const GitTabPanel = () => { const [gitSelect, setGitSelect] = useState('none'); const [linkedRepo, setLinkedRepo] = useState(); + const [webhooksArray, setWebhooksArray] = useState>([]); const gitSelectionHandler = (git: GitSelect) => { setGitSelect(git); @@ -19,6 +23,23 @@ const GitTabPanel = () => { setLinkedRepo(repoDetails); }; + const { + register, + handleSubmit, + reset, + formState: { isSubmitSuccessful }, + } = useForm(); + + useEffect(() => { + reset(); + }, [isSubmitSuccessful]); + + const handleDelete = (index: number) => { + const newArray = webhooksArray.filter((value, idx) => idx != index); + setWebhooksArray(newArray); + toast.success('Webhook deleted successfully'); + }; + return ( <>
@@ -85,25 +106,45 @@ const GitTabPanel = () => {
-
- - Deploy webhooks - - - Webhooks configured to trigger when there is a change in a - project's build or deployment status. - -
-
- Webhook URL - -
-
- +
{ + setWebhooksArray((prevArray) => [...prevArray, data.webhookUrl]); + + toast.success('Webhook added successfully.'); + })} + > +
+ + Deploy webhooks + + + Webhooks configured to trigger when there is a change in a + project's build or deployment status. + +
+
+ Webhook URL + +
+
+ +
+
+
+ {webhooksArray?.map((webhookUrl, index) => { + return ( + handleDelete(index)} + key={index} + /> + ); + })}
); diff --git a/packages/frontend/src/components/projects/project/settings/RepoConnectedSection.tsx b/packages/frontend/src/components/projects/project/settings/RepoConnectedSection.tsx index 9f06f60..c824f6e 100644 --- a/packages/frontend/src/components/projects/project/settings/RepoConnectedSection.tsx +++ b/packages/frontend/src/components/projects/project/settings/RepoConnectedSection.tsx @@ -1,6 +1,7 @@ import React from 'react'; import { Button, Typography } from '@material-tailwind/react'; + import { RepositoryDetails } from '../../../../types/project'; const RepoConnectedSection = ({ diff --git a/packages/frontend/src/components/projects/project/settings/SetupDomain.tsx b/packages/frontend/src/components/projects/project/settings/SetupDomain.tsx index 5f87780..d3facf0 100644 --- a/packages/frontend/src/components/projects/project/settings/SetupDomain.tsx +++ b/packages/frontend/src/components/projects/project/settings/SetupDomain.tsx @@ -1,6 +1,7 @@ import React, { useEffect, useState } from 'react'; import { useNavigate } from 'react-router-dom'; import { useForm } from 'react-hook-form'; + import { Radio, Typography, diff --git a/packages/frontend/src/components/projects/project/settings/WebhookCard.tsx b/packages/frontend/src/components/projects/project/settings/WebhookCard.tsx new file mode 100644 index 0000000..a85b566 --- /dev/null +++ b/packages/frontend/src/components/projects/project/settings/WebhookCard.tsx @@ -0,0 +1,62 @@ +import React, { useState } from 'react'; +import toast from 'react-hot-toast'; + +import { Button, Typography } from '@material-tailwind/react'; + +import ConfirmDialog from '../../../shared/ConfirmDialog'; + +const WebhookCard = (props: { + webhooksArray: string[]; + webhookUrl: string; + handleDelete: () => void; +}) => { + const [deleteDialogOpen, setDeleteDialogOpen] = useState(false); + return ( +
+ {props.webhookUrl} + +
+ + +
+ + setDeleteDialogOpen((preVal) => !preVal)} + open={deleteDialogOpen} + confirmButtonTitle="Yes, Confirm delete" + handleConfirm={() => { + setDeleteDialogOpen((preVal) => !preVal); + props.handleDelete(); + }} + color="red" + > + + Are you sure you want to delete the variable{' '} + + {props.webhookUrl} + + ? + + +
+ ); +}; + +export default WebhookCard;