Skip to content

Commit c2030ff

Browse files
refactor: simplify template callback checks using optional chaining
1 parent 00d8e6a commit c2030ff

1 file changed

Lines changed: 3 additions & 5 deletions

File tree

  • src/core_modules/capture-core/components/WorkingLists/EventWorkingLists/epics

src/core_modules/capture-core/components/WorkingLists/EventWorkingLists/epics/templates.epics.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,7 @@ export const updateTemplateEpic = (
9292
const isActiveTemplate =
9393
store.value.workingListsTemplates[storeId].selectedTemplateId === id;
9494

95-
// Call the onChangeTemplate callback if provided
96-
if (callBacks && callBacks.onChangeTemplate) {
95+
if (callBacks?.onChangeTemplate) {
9796
callBacks.onChangeTemplate(id);
9897
}
9998

@@ -170,8 +169,7 @@ export const addTemplateEpic = (
170169
store.value.workingListsTemplates[storeId].selectedTemplateId === clientId;
171170
const templateId = result.response.uid;
172171

173-
// Call the onChangeTemplate callback if provided
174-
if (callBacks && callBacks.onChangeTemplate) {
172+
if (callBacks?.onChangeTemplate) {
175173
callBacks.onChangeTemplate(templateId);
176174
}
177175

@@ -214,7 +212,7 @@ export const deleteTemplateEpic = (
214212
}).then(() => {
215213
const { programId } = getLocationQuery();
216214

217-
if (callBacks && callBacks.onChangeTemplate) {
215+
if (callBacks?.onChangeTemplate) {
218216
callBacks.onChangeTemplate(`${programId}-default`);
219217
}
220218

0 commit comments

Comments
 (0)