Skip to content

Commit 624c399

Browse files
committed
Add delete directive confirmation dialog
1 parent 62fa68a commit 624c399

File tree

2 files changed

+43
-8
lines changed

2 files changed

+43
-8
lines changed

src/components/Agentic/IncidentDirectives/index.tsx

Lines changed: 38 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import type {
1414
Directive,
1515
IncidentAgentEvent
1616
} from "../../../redux/services/types";
17+
import { CancelConfirmation } from "../../common/CancelConfirmation";
1718
import { SortIcon } from "../../common/icons/16px/SortIcon";
1819
import { TrashBinIcon } from "../../common/icons/16px/TrashBinIcon";
1920
import { Direction } from "../../common/icons/types";
@@ -52,6 +53,7 @@ const mockData: Directive[] = [
5253
];
5354

5455
// TODO: remove
56+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
5557
const mockEventsData: IncidentAgentEvent[] = [
5658
{
5759
agent_name: "incident_entry",
@@ -105,15 +107,23 @@ const mockEventsData: IncidentAgentEvent[] = [
105107
}
106108
];
107109

110+
const REFRESH_INTERVAL = 10 * 1000; // in milliseconds
111+
108112
const columnHelper = createColumnHelper<ExtendedDirective>();
109113

110114
export const IncidentDirectives = () => {
111115
const [searchInputValue, setSearchInputValue] = useState("");
112116
const [selectedConditions, setSelectedConditions] = useState<string[]>([]);
117+
const [directiveToDelete, setDirectiveToDelete] = useState<string>();
113118

114-
const { data } = useGetIncidentAgentDirectivesQuery({
115-
search_term: searchInputValue
116-
});
119+
const { data } = useGetIncidentAgentDirectivesQuery(
120+
{
121+
search_term: searchInputValue || undefined
122+
},
123+
{
124+
pollingInterval: REFRESH_INTERVAL
125+
}
126+
);
117127

118128
const [deleteIncidentAgentDirective] =
119129
useDeleteIncidentAgentDirectiveMutation();
@@ -128,6 +138,19 @@ export const IncidentDirectives = () => {
128138
);
129139
};
130140

141+
const handleDeleteDirectiveDialogConfirm = () => {
142+
if (directiveToDelete) {
143+
void deleteIncidentAgentDirective({
144+
id: directiveToDelete
145+
});
146+
}
147+
setDirectiveToDelete(undefined);
148+
};
149+
150+
const handleDeleteDirectiveDialogClose = () => {
151+
setDirectiveToDelete(undefined);
152+
};
153+
131154
const handleMessageSend = () => {
132155
// TODO: implement
133156
};
@@ -254,9 +277,7 @@ export const IncidentDirectives = () => {
254277
const value = info.getValue();
255278

256279
const handleDeleteMenuItemClick = () => {
257-
void deleteIncidentAgentDirective({
258-
id: value.id
259-
});
280+
setDirectiveToDelete(value.id);
260281
};
261282

262283
const items: MenuItem[] = [
@@ -376,8 +397,7 @@ export const IncidentDirectives = () => {
376397
</s.Table>
377398
</s.TableContainer>
378399
<s.StyledAgentChat
379-
// TODO: remove mock data
380-
data={mockEventsData}
400+
data={[]}
381401
isDataLoading={false}
382402
onMessageSend={handleMessageSend}
383403
isMessageSending={false}
@@ -396,6 +416,16 @@ export const IncidentDirectives = () => {
396416
)
397417
}
398418
/>
419+
{directiveToDelete && (
420+
<s.StyledOverlay>
421+
<CancelConfirmation
422+
header={"Delete directive"}
423+
description={"Are you sure you want to delete this directive?"}
424+
onClose={handleDeleteDirectiveDialogClose}
425+
onConfirm={handleDeleteDirectiveDialogConfirm}
426+
/>
427+
</s.StyledOverlay>
428+
)}
399429
</s.Container>
400430
);
401431
};

src/components/Agentic/IncidentDirectives/styles.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import {
66
subheading1RegularTypography,
77
subscriptRegularTypography
88
} from "../../common/App/typographies";
9+
import { Overlay } from "../../common/Overlay";
910
import { AgentChat } from "../common/AgentChat";
1011
import { Form, TextArea } from "../common/PromptInput/styles";
1112
import { SearchInput } from "../common/SearchInput";
@@ -172,3 +173,7 @@ export const StyledAgentChat = styled(AgentChat)`
172173
}
173174
}
174175
`;
176+
177+
export const StyledOverlay = styled(Overlay)`
178+
align-items: center;
179+
`;

0 commit comments

Comments
 (0)