Skip to content

Commit

Permalink
Final touches
Browse files Browse the repository at this point in the history
  • Loading branch information
blazejkustra committed Nov 24, 2024
1 parent 9910fbc commit 04d94db
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 7 deletions.
34 changes: 30 additions & 4 deletions src/components/ApprovalWorkflowSection.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React, {useCallback, useMemo} from 'react';
/* eslint-disable react/function-component-definition */
import React, {useCallback, useMemo, useRef} from 'react';

Check failure on line 2 in src/components/ApprovalWorkflowSection.tsx

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

'useRef' is defined but never used

Check failure on line 2 in src/components/ApprovalWorkflowSection.tsx

View workflow job for this annotation

GitHub Actions / ESLint check

'useRef' is defined but never used
import {View} from 'react-native';
import useLocalize from '@hooks/useLocalize';
import useResponsiveLayout from '@hooks/useResponsiveLayout';
Expand All @@ -20,11 +21,36 @@ type ApprovalWorkflowSectionProps = {
onPress: () => void;
};

function ApprovalWorkflowSection({approvalWorkflow, onPress}: ApprovalWorkflowSectionProps) {
const Test = () => {

Check failure on line 24 in src/components/ApprovalWorkflowSection.tsx

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

'Test' is assigned a value but never used

Check failure on line 24 in src/components/ApprovalWorkflowSection.tsx

View workflow job for this annotation

GitHub Actions / ESLint check

'Test' is assigned a value but never used
const styles = useThemeStyles();

Check failure on line 25 in src/components/ApprovalWorkflowSection.tsx

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

'styles' is assigned a value but never used

Check failure on line 25 in src/components/ApprovalWorkflowSection.tsx

View workflow job for this annotation

GitHub Actions / ESLint check

'styles' is assigned a value but never used
const theme = useTheme();

Check failure on line 26 in src/components/ApprovalWorkflowSection.tsx

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

'theme' is assigned a value but never used

Check failure on line 26 in src/components/ApprovalWorkflowSection.tsx

View workflow job for this annotation

GitHub Actions / ESLint check

'theme' is assigned a value but never used
const {shouldUseNarrowLayout} = useResponsiveLayout();

Check failure on line 27 in src/components/ApprovalWorkflowSection.tsx

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

'shouldUseNarrowLayout' is assigned a value but never used

Check failure on line 27 in src/components/ApprovalWorkflowSection.tsx

View workflow job for this annotation

GitHub Actions / ESLint check

'shouldUseNarrowLayout' is assigned a value but never used
const {translate, toLocaleOrdinal} = useLocalize();

const approverTitle = useCallback(

Check failure on line 30 in src/components/ApprovalWorkflowSection.tsx

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

'approverTitle' is assigned a value but never used

Check failure on line 30 in src/components/ApprovalWorkflowSection.tsx

View workflow job for this annotation

GitHub Actions / ESLint check

'approverTitle' is assigned a value but never used
(index: number) =>
approvalWorkflow.approvers.length > 1 ? `${toLocaleOrdinal(index + 1, true)} ${translate('workflowsPage.approver').toLowerCase()}` : `${translate('workflowsPage.approver')}`,

Check failure on line 32 in src/components/ApprovalWorkflowSection.tsx

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Unsafe member access .approvers on an `error` typed value

Check failure on line 32 in src/components/ApprovalWorkflowSection.tsx

View workflow job for this annotation

GitHub Actions / ESLint check

Unsafe member access .approvers on an `error` typed value

Check failure on line 32 in src/components/ApprovalWorkflowSection.tsx

View workflow job for this annotation

GitHub Actions / typecheck

Cannot find name 'approvalWorkflow'.
[approvalWorkflow.approvers.length, toLocaleOrdinal, translate],

Check warning on line 33 in src/components/ApprovalWorkflowSection.tsx

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

React Hook useCallback has an unnecessary dependency: 'approvalWorkflow.approvers.length'. Either exclude it or remove the dependency array. Outer scope values like 'approvalWorkflow.approvers.length' aren't valid dependencies because mutating them doesn't re-render the component

Check failure on line 33 in src/components/ApprovalWorkflowSection.tsx

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Unsafe member access .approvers on an `error` typed value

Check warning on line 33 in src/components/ApprovalWorkflowSection.tsx

View workflow job for this annotation

GitHub Actions / ESLint check

React Hook useCallback has an unnecessary dependency: 'approvalWorkflow.approvers.length'. Either exclude it or remove the dependency array. Outer scope values like 'approvalWorkflow.approvers.length' aren't valid dependencies because mutating them doesn't re-render the component

Check failure on line 33 in src/components/ApprovalWorkflowSection.tsx

View workflow job for this annotation

GitHub Actions / ESLint check

Unsafe member access .approvers on an `error` typed value

Check failure on line 33 in src/components/ApprovalWorkflowSection.tsx

View workflow job for this annotation

GitHub Actions / typecheck

Cannot find name 'approvalWorkflow'.
);

const members = useMemo(() => {

Check failure on line 36 in src/components/ApprovalWorkflowSection.tsx

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

'members' is assigned a value but never used

Check failure on line 36 in src/components/ApprovalWorkflowSection.tsx

View workflow job for this annotation

GitHub Actions / ESLint check

'members' is assigned a value but never used
if (approvalWorkflow.isDefault) {

Check failure on line 37 in src/components/ApprovalWorkflowSection.tsx

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Unsafe member access .isDefault on an `error` typed value

Check failure on line 37 in src/components/ApprovalWorkflowSection.tsx

View workflow job for this annotation

GitHub Actions / ESLint check

Unsafe member access .isDefault on an `error` typed value

Check failure on line 37 in src/components/ApprovalWorkflowSection.tsx

View workflow job for this annotation

GitHub Actions / typecheck

Cannot find name 'approvalWorkflow'.
return translate('workspace.common.everyone');
}

return OptionsListUtils.sortAlphabetically(approvalWorkflow.members, 'displayName')

Check failure on line 41 in src/components/ApprovalWorkflowSection.tsx

View workflow job for this annotation

GitHub Actions / typecheck

Cannot find name 'approvalWorkflow'.

Check failure on line 41 in src/components/ApprovalWorkflowSection.tsx

View workflow job for this annotation

GitHub Actions / typecheck

Argument of type 'string' is not assignable to parameter of type 'never'.
.map((m) => m.displayName)

Check failure on line 42 in src/components/ApprovalWorkflowSection.tsx

View workflow job for this annotation

GitHub Actions / typecheck

Property 'displayName' does not exist on type 'Partial<Record<never, string | undefined>>'.
.join(', ');
}, [approvalWorkflow.isDefault, translate]);

Check warning on line 44 in src/components/ApprovalWorkflowSection.tsx

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

React Hook useMemo has an unnecessary dependency: 'approvalWorkflow.isDefault'. Either exclude it or remove the dependency array. Outer scope values like 'approvalWorkflow.isDefault' aren't valid dependencies because mutating them doesn't re-render the component

Check warning on line 44 in src/components/ApprovalWorkflowSection.tsx

View workflow job for this annotation

GitHub Actions / ESLint check

React Hook useMemo has an unnecessary dependency: 'approvalWorkflow.isDefault'. Either exclude it or remove the dependency array. Outer scope values like 'approvalWorkflow.isDefault' aren't valid dependencies because mutating them doesn't re-render the component

Check failure on line 44 in src/components/ApprovalWorkflowSection.tsx

View workflow job for this annotation

GitHub Actions / typecheck

Cannot find name 'approvalWorkflow'.

return <View />;
};

function ApprovalWorkflowSection({approvalWorkflow, onPress}: ApprovalWorkflowSectionProps) {
const styles = useThemeStyles();
const theme = useTheme();
const {shouldUseNarrowLayout} = useResponsiveLayout();
const {translate, toLocaleOrdinal} = useLocalize();

const approverTitle = useCallback(
(index: number) =>
Expand All @@ -40,7 +66,7 @@ function ApprovalWorkflowSection({approvalWorkflow, onPress}: ApprovalWorkflowSe
return OptionsListUtils.sortAlphabetically(approvalWorkflow.members, 'displayName')
.map((m) => m.displayName)
.join(', ');
}, [approvalWorkflow.isDefault, approvalWorkflow.members, translate]);
}, [approvalWorkflow]);

Check warning on line 69 in src/components/ApprovalWorkflowSection.tsx

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

React Hook useMemo has a missing dependency: 'translate'. Either include it or remove the dependency array

Check warning on line 69 in src/components/ApprovalWorkflowSection.tsx

View workflow job for this annotation

GitHub Actions / ESLint check

React Hook useMemo has a missing dependency: 'translate'. Either include it or remove the dependency array

return (
<PressableWithoutFeedback
Expand Down Expand Up @@ -110,4 +136,4 @@ function ApprovalWorkflowSection({approvalWorkflow, onPress}: ApprovalWorkflowSe
);
}

export default ApprovalWorkflowSection;
export {ApprovalWorkflowSection};
4 changes: 1 addition & 3 deletions src/components/AttachmentModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,6 @@ function AttachmentModal({
}

setIsModalOpen(false);
// eslint-disable-next-line react-compiler/react-compiler, react-hooks/exhaustive-deps
}, [isModalOpen, isConfirmButtonDisabled, onConfirm, file, sourceState]);

/**
Expand Down Expand Up @@ -458,8 +457,7 @@ function AttachmentModal({
});
}
return menuItems;
// eslint-disable-next-line react-compiler/react-compiler, react-hooks/exhaustive-deps
}, [isReceiptAttachment, transaction, file, sourceState, iouType]);
}, [isReceiptAttachment, canEditReceipt, isOffline, allowDownload, isLocalSource, transaction, translate, closeModal, iouType, report?.reportID, downloadAttachment]);

// There are a few things that shouldn't be set until we absolutely know if the file is a receipt or an attachment.
// props.isReceiptAttachment will be null until its certain what the file is, in which case it will then be true|false.
Expand Down

0 comments on commit 04d94db

Please sign in to comment.