Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: Animate the Submit button, for consistency with animations for Approve and Pay #55515

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions src/components/ReportActionItem/ReportPreview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@

const [isPaidAnimationRunning, setIsPaidAnimationRunning] = useState(false);
const [isApprovedAnimationRunning, setIsApprovedAnimationRunning] = useState(false);
const [isSubmitAnimationRunning, setIsSubmitAnimationRunning] = useState(false);
const [isHoldMenuVisible, setIsHoldMenuVisible] = useState(false);
const [requestType, setRequestType] = useState<ActionHandledType>();
const [paymentType, setPaymentType] = useState<PaymentMethodType>();
Expand Down Expand Up @@ -249,8 +250,9 @@

const isArchived = isArchivedReportWithID(iouReport?.reportID);
const isAdmin = policy?.role === CONST.POLICY.ROLE.ADMIN;

const shouldShowSubmitButton = canSubmitReport(iouReport, policy, transactionIDList, transactionViolations) || isSubmitAnimationRunning;

Check failure on line 254 in src/components/ReportActionItem/ReportPreview.tsx

View workflow job for this annotation

GitHub Actions / typecheck

Argument of type 'string[]' is not assignable to parameter of type '({ amount: number; attendees?: Attendee[] | undefined; taxAmount?: number | undefined; taxCode?: string | undefined; billable?: boolean | undefined; category?: string | undefined; ... 44 more ...; inserted?: string | undefined; } & OfflineFeedback<...>)[] | SearchTransaction[]'.
const filteredTransactions = transactions?.filter((transaction) => transaction) ?? [];

Check failure on line 255 in src/components/ReportActionItem/ReportPreview.tsx

View workflow job for this annotation

GitHub Actions / ESLint check

'filteredTransactions' is assigned a value but never used

Check failure on line 255 in src/components/ReportActionItem/ReportPreview.tsx

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

'filteredTransactions' is assigned a value but never used
const shouldShowSubmitButton = canSubmitReport(iouReport, policy, filteredTransactions, transactionViolations);

const shouldDisableSubmitButton = shouldShowSubmitButton && !isAllowedToSubmitDraftExpenseReport(iouReport);

Expand All @@ -266,6 +268,7 @@
const stopAnimation = useCallback(() => {
setIsPaidAnimationRunning(false);
setIsApprovedAnimationRunning(false);
setIsSubmitAnimationRunning(false);
}, []);
const startAnimation = useCallback(() => {
setIsPaidAnimationRunning(true);
Expand All @@ -275,6 +278,10 @@
setIsApprovedAnimationRunning(true);
HapticFeedback.longPress();
}, []);
const startSubmitAnimation = useCallback(() => {

Check failure on line 281 in src/components/ReportActionItem/ReportPreview.tsx

View workflow job for this annotation

GitHub Actions / ESLint check

'startSubmitAnimation' is assigned a value but never used

Check failure on line 281 in src/components/ReportActionItem/ReportPreview.tsx

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

'startSubmitAnimation' is assigned a value but never used
setIsSubmitAnimationRunning(true);
HapticFeedback.longPress();
}, []);

const confirmPayment = useCallback(
(type: PaymentMethodType | undefined, payAsBusiness?: boolean) => {
Expand Down Expand Up @@ -409,7 +416,8 @@

const bankAccountRoute = getBankAccountRoute(chatReport);

const shouldShowSettlementButton = !shouldShowSubmitButton && (shouldShowPayButton || shouldShowApproveButton) && !showRTERViolationMessage && !shouldShowBrokenConnectionViolation;
const shouldShowSettlementButton = !shouldShowSubmitButton && (shouldShowPayButton || shouldShowApproveButton) && !showRTERViolationMessage && !shouldShowBrokenConnectionViolation && !isSubmitAnimationRunning;

Check failure on line 419 in src/components/ReportActionItem/ReportPreview.tsx

View workflow job for this annotation

GitHub Actions / ESLint check

Replace `·!shouldShowSubmitButton·&&·(shouldShowPayButton·||·shouldShowApproveButton)·&&·!showRTERViolationMessage·&&·!shouldShowBrokenConnectionViolation·&&·!isSubmitAnimationRunning;⏎` with `⏎········!shouldShowSubmitButton·&&·(shouldShowPayButton·||·shouldShowApproveButton)·&&·!showRTERViolationMessage·&&·!shouldShowBrokenConnectionViolation·&&·!isSubmitAnimationRunning;`

Check failure on line 419 in src/components/ReportActionItem/ReportPreview.tsx

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Replace `·!shouldShowSubmitButton·&&·(shouldShowPayButton·||·shouldShowApproveButton)·&&·!showRTERViolationMessage·&&·!shouldShowBrokenConnectionViolation·&&·!isSubmitAnimationRunning;⏎` with `⏎········!shouldShowSubmitButton·&&·(shouldShowPayButton·||·shouldShowApproveButton)·&&·!showRTERViolationMessage·&&·!shouldShowBrokenConnectionViolation·&&·!isSubmitAnimationRunning;`


const shouldPromptUserToAddBankAccount = (hasMissingPaymentMethod(userWallet, iouReportID) || hasMissingInvoiceBankAccount(iouReportID)) && !isSettled(iouReportID);
const shouldShowRBR = hasErrors && !iouSettled;
Expand Down Expand Up @@ -626,6 +634,7 @@
onlyShowPayElsewhere={onlyShowPayElsewhere}
isPaidAnimationRunning={isPaidAnimationRunning}
isApprovedAnimationRunning={isApprovedAnimationRunning}
isSubmitAnimationRunning={isSubmitAnimationRunning}
canIOUBePaid={canIOUBePaidAndApproved || isPaidAnimationRunning}
onAnimationFinish={stopAnimation}
formattedAmount={getSettlementAmount() ?? ''}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ type AnimatedSettlementButtonProps = SettlementButtonProps & {
isPaidAnimationRunning: boolean;
onAnimationFinish: () => void;
isApprovedAnimationRunning: boolean;
isSubmitAnimationRunning: boolean;
canIOUBePaid: boolean;
};

Expand All @@ -21,6 +22,7 @@ function AnimatedSettlementButton({
isApprovedAnimationRunning,
isDisabled,
canIOUBePaid,
isSubmitAnimationRunning,
...settlementButtonProps
}: AnimatedSettlementButtonProps) {
const styles = useThemeStyles();
Expand Down Expand Up @@ -48,7 +50,7 @@ function AnimatedSettlementButton({
marginTop: buttonMarginTop.get(),
}));
const buttonDisabledStyle =
isPaidAnimationRunning || isApprovedAnimationRunning
isPaidAnimationRunning || isApprovedAnimationRunning || isSubmitAnimationRunning
? {
opacity: 1,
...styles.cursorDefault,
Expand All @@ -65,7 +67,7 @@ function AnimatedSettlementButton({
}, [buttonScale, buttonOpacity, paymentCompleteTextScale, paymentCompleteTextOpacity, height, buttonMarginTop, styles.expenseAndReportPreviewTextButtonContainer.gap]);

useEffect(() => {
if (!isApprovedAnimationRunning && !isPaidAnimationRunning) {
if (!isApprovedAnimationRunning && !isPaidAnimationRunning && !isSubmitAnimationRunning) {
resetAnimation();
return;
}
Expand All @@ -88,6 +90,7 @@ function AnimatedSettlementButton({
}, [
isPaidAnimationRunning,
isApprovedAnimationRunning,
isSubmitAnimationRunning,
onAnimationFinish,
buttonOpacity,
buttonScale,
Expand Down
Loading