Skip to content

Commit

Permalink
Disable complete task for anonymous user
Browse files Browse the repository at this point in the history
  • Loading branch information
VickyStash committed Dec 4, 2023
1 parent 3ef8266 commit f7bb551
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/components/TaskHeaderActionButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,20 @@ import {OnyxEntry, withOnyx} from 'react-native-onyx';
import useLocalize from '@hooks/useLocalize';
import * as ReportUtils from '@libs/ReportUtils';
import useThemeStyles from '@styles/useThemeStyles';
import * as Session from '@userActions/Session';
import * as Task from '@userActions/Task';
import ONYXKEYS from '@src/ONYXKEYS';
import type {Report, Session} from '@src/types/onyx';
import * as OnyxTypes from '@src/types/onyx';
import Button from './Button';

type TaskHeaderActionButtonOnyxProps = {
/** Current user session */
session: OnyxEntry<Session>;
session: OnyxEntry<OnyxTypes.Session>;
};

type TaskHeaderActionButtonProps = TaskHeaderActionButtonOnyxProps & {
/** The report currently being looked at */
report: Report;
report: OnyxTypes.Report;
};

function TaskHeaderActionButton({report, session}: TaskHeaderActionButtonProps) {
Expand All @@ -30,7 +31,7 @@ function TaskHeaderActionButton({report, session}: TaskHeaderActionButtonProps)
isDisabled={!Task.canModifyTask(report, session?.accountID ?? 0)}
medium
text={translate(ReportUtils.isCompletedTaskReport(report) ? 'task.markAsIncomplete' : 'task.markAsComplete')}
onPress={() => (ReportUtils.isCompletedTaskReport(report) ? Task.reopenTask(report) : Task.completeTask(report))}
onPress={Session.checkIfActionIsAllowed(() => (ReportUtils.isCompletedTaskReport(report) ? Task.reopenTask(report) : Task.completeTask(report)))}
style={styles.flex1}
/>
</View>
Expand Down

0 comments on commit f7bb551

Please sign in to comment.