-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #35321 from shahinyan11/issues/25215
[TS migration] Migrate 'SettingsProfileReport' page to TypeScript
- Loading branch information
Showing
16 changed files
with
212 additions
and
245 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import type {StackScreenProps} from '@react-navigation/stack'; | ||
import React from 'react'; | ||
import FullPageNotFoundView from '@components/BlockingViews/FullPageNotFoundView'; | ||
import HeaderWithBackButton from '@components/HeaderWithBackButton'; | ||
import ScreenWrapper from '@components/ScreenWrapper'; | ||
import SelectionList from '@components/SelectionList'; | ||
import useLocalize from '@hooks/useLocalize'; | ||
import * as ReportUtils from '@libs/ReportUtils'; | ||
import type {ReportSettingsNavigatorParamList} from '@navigation/types'; | ||
import withReportOrNotFound from '@pages/home/report/withReportOrNotFound'; | ||
import type {WithReportOrNotFoundProps} from '@pages/home/report/withReportOrNotFound'; | ||
import * as ReportActions from '@userActions/Report'; | ||
import CONST from '@src/CONST'; | ||
import type SCREENS from '@src/SCREENS'; | ||
|
||
type NotificationPreferencePageProps = WithReportOrNotFoundProps & StackScreenProps<ReportSettingsNavigatorParamList, typeof SCREENS.REPORT_SETTINGS.NOTIFICATION_PREFERENCES>; | ||
|
||
function NotificationPreferencePage({report}: NotificationPreferencePageProps) { | ||
const {translate} = useLocalize(); | ||
const shouldDisableNotificationPreferences = ReportUtils.isArchivedRoom(report); | ||
const notificationPreferenceOptions = Object.values(CONST.REPORT.NOTIFICATION_PREFERENCE) | ||
.filter((pref) => pref !== CONST.REPORT.NOTIFICATION_PREFERENCE.HIDDEN) | ||
.map((preference) => ({ | ||
value: preference, | ||
text: translate(`notificationPreferencesPage.notificationPreferences.${preference}`), | ||
keyForList: preference, | ||
isSelected: preference === report?.notificationPreference, | ||
})); | ||
|
||
return ( | ||
<ScreenWrapper | ||
includeSafeAreaPaddingBottom={false} | ||
testID={NotificationPreferencePage.displayName} | ||
> | ||
<FullPageNotFoundView shouldShow={shouldDisableNotificationPreferences}> | ||
<HeaderWithBackButton | ||
title={translate('notificationPreferencesPage.header')} | ||
onBackButtonPress={() => ReportUtils.goBackToDetailsPage(report)} | ||
/> | ||
<SelectionList | ||
sections={[{data: notificationPreferenceOptions}]} | ||
onSelectRow={(option) => | ||
report && ReportActions.updateNotificationPreference(report.reportID, report.notificationPreference, option.value, true, undefined, undefined, report) | ||
} | ||
initiallyFocusedOptionKey={notificationPreferenceOptions.find((locale) => locale.isSelected)?.keyForList} | ||
/> | ||
</FullPageNotFoundView> | ||
</ScreenWrapper> | ||
); | ||
} | ||
|
||
NotificationPreferencePage.displayName = 'NotificationPreferencePage'; | ||
|
||
export default withReportOrNotFound()(NotificationPreferencePage); |
Oops, something went wrong.