Skip to content

Commit

Permalink
fix: Added some missing null checks (#14146)
Browse files Browse the repository at this point in the history
Co-authored-by: Lars <[email protected]>
  • Loading branch information
mlqn and lassopicasso authored Nov 28, 2024
1 parent c94ca60 commit c71f649
Showing 1 changed file with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export const AttachmentListComponent = ({

const isTaskCustomReceipt = layoutSets?.sets
.find((layoutSet) => layoutSet.id === selectedFormLayoutSetName)
?.tasks.includes('CustomReceipt');
?.tasks?.includes('CustomReceipt');

const { dataTypeIds = [] } = component || {};
const internalDataFormat = convertExternalToInternalFormat(availableAttachments, dataTypeIds);
Expand Down Expand Up @@ -100,19 +100,21 @@ const filterAttachments = (
return availableDataTypes.filter((dataType) => {
const noReservedType = !Object.values(reservedDataTypes).includes(dataType.id);
const noAppLogic = !dataType.appLogic;
const hasMatchingTask = tasks.some((task) => dataType.taskId === task);
const hasMatchingTask = tasks?.some((task) => dataType.taskId === task);

return noReservedType && noAppLogic && hasMatchingTask;
});
};

const currentTasks = (layoutSets: LayoutSets, selectedFormLayoutSetName: string): string[] =>
layoutSets.sets.find((layoutSet) => layoutSet.id === selectedFormLayoutSetName).tasks;
layoutSets.sets.find((layoutSet) => layoutSet.id === selectedFormLayoutSetName)?.tasks;

const sampleTasks = (layoutSets: LayoutSets, selectedFormLayoutSetName: string): string[] => {
const tasks = [];
for (const layoutSet of layoutSets.sets) {
tasks.push(...layoutSet.tasks);
if (layoutSet.tasks) {
tasks.push(...layoutSet.tasks);
}
if (layoutSet.id === selectedFormLayoutSetName) {
break;
}
Expand Down

0 comments on commit c71f649

Please sign in to comment.