2023-11-27 11:45:48 +00:00
|
|
|
import { Control, Controller } from "react-hook-form";
|
|
|
|
import { IWebhook } from "types/webhook";
|
|
|
|
|
2023-11-29 08:32:13 +00:00
|
|
|
export const INDIVIDUAL_WEBHOOK_OPTIONS: {
|
2023-11-27 11:45:48 +00:00
|
|
|
key: keyof IWebhook;
|
|
|
|
label: string;
|
|
|
|
description: string;
|
|
|
|
}[] = [
|
|
|
|
{
|
|
|
|
key: "project",
|
|
|
|
label: "Projects",
|
2023-11-29 08:32:13 +00:00
|
|
|
description: "Project created, updated, or deleted",
|
2023-11-27 11:45:48 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
key: "cycle",
|
|
|
|
label: "Cycles",
|
2023-11-29 08:32:13 +00:00
|
|
|
description: "Cycle created, updated, or deleted",
|
2023-11-27 11:45:48 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
key: "issue",
|
|
|
|
label: "Issues",
|
2023-11-29 08:32:13 +00:00
|
|
|
description: "Issue created, updated, deleted, added to a cycle or module",
|
2023-11-27 11:45:48 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
key: "module",
|
|
|
|
label: "Modules",
|
2023-11-29 08:32:13 +00:00
|
|
|
description: "Module created, updated, or deleted",
|
2023-11-27 11:45:48 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
key: "issue_comment",
|
|
|
|
label: "Issue comments",
|
2023-11-29 08:32:13 +00:00
|
|
|
description: "Comment posted, updated, or deleted",
|
2023-11-27 11:45:48 +00:00
|
|
|
},
|
|
|
|
];
|
|
|
|
|
|
|
|
type Props = {
|
|
|
|
control: Control<IWebhook, any>;
|
|
|
|
};
|
|
|
|
|
|
|
|
export const WebhookIndividualEventOptions = ({ control }: Props) => (
|
2023-12-10 10:18:10 +00:00
|
|
|
<div className="grid grid-cols-1 gap-x-4 gap-y-8 px-6 lg:grid-cols-2">
|
2023-11-29 08:32:13 +00:00
|
|
|
{INDIVIDUAL_WEBHOOK_OPTIONS.map((option) => (
|
|
|
|
<Controller
|
|
|
|
key={option.key}
|
|
|
|
control={control}
|
|
|
|
name={option.key}
|
|
|
|
render={({ field: { onChange, value } }) => (
|
|
|
|
<div>
|
|
|
|
<div className="flex items-center gap-2">
|
|
|
|
<input
|
|
|
|
id={option.key}
|
|
|
|
onChange={() => onChange(!value)}
|
|
|
|
type="checkbox"
|
|
|
|
name="selectIndividualEvents"
|
|
|
|
checked={value === true}
|
|
|
|
/>
|
|
|
|
<label className="text-sm" htmlFor={option.key}>
|
|
|
|
{option.label}
|
|
|
|
</label>
|
2023-11-27 11:45:48 +00:00
|
|
|
</div>
|
2023-12-10 10:18:10 +00:00
|
|
|
<p className="ml-6 mt-0.5 text-xs text-custom-text-300">{option.description}</p>
|
2023-11-29 08:32:13 +00:00
|
|
|
</div>
|
|
|
|
)}
|
|
|
|
/>
|
|
|
|
))}
|
|
|
|
</div>
|
2023-11-27 11:45:48 +00:00
|
|
|
);
|