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

feat: delete account screen #1562

Merged
merged 20 commits into from
Jun 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
97c8687
refactor: make settings screen consistent with design terminology of …
tm-ruxandra Jun 7, 2024
be30631
feat: add skeleton for delete account screen navigation
tm-ruxandra Jun 7, 2024
44132f2
refactor: make typography components consistent with names used in de…
tm-ruxandra Jun 10, 2024
69d5033
feat: add other typography elements to components directory
tm-ruxandra Jun 10, 2024
fb0569f
feat: add standard bullet list from translated typography
tm-ruxandra Jun 13, 2024
a263b3a
feat: base functionality and content for user deletion requests
tm-ruxandra Jun 14, 2024
09ab06d
refactor: move user deletion hook to hooks directory
tm-ruxandra Jun 14, 2024
6a10b88
feat: spacing styles for account deletion
tm-ruxandra Jun 14, 2024
ffeaa77
fix: replace old input with new TextInput
tm-ruxandra Jun 14, 2024
f8f5f19
feat: styling for deletion buttons
tm-ruxandra Jun 14, 2024
b1a6b88
refactor: clean up style declarations for deletion form
tm-ruxandra Jun 14, 2024
851ec69
refactor: clean up styling conventions for deletion screen
tm-ruxandra Jun 14, 2024
5e411f9
chore: copyright notice
tm-ruxandra Jun 14, 2024
42bab3e
fix: use email input properties for confirm form
tm-ruxandra Jun 14, 2024
8bcd3bc
feat: improve wording for deletion screen.
tm-ruxandra Jun 14, 2024
9402c44
chore: rerun formatter
tm-ruxandra Jun 17, 2024
d8650f8
fix: garbled github suggestion
tm-ruxandra Jun 17, 2024
c3b6dbe
fix: change paragraph spacing per design's request
tm-ruxandra Jun 17, 2024
e4eda43
fix: wrap screen in scrollview to keep text input in view
tm-ruxandra Jun 17, 2024
8b59414
feat: change spacing on confirm form buttons
tm-ruxandra Jun 17, 2024
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/*
* Copyright © 2024 Technology Matters
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see https://www.gnu.org/licenses/.
*/

import {BulletList} from 'terraso-mobile-client/components/BulletList';
import {TranslatedParagraph} from 'terraso-mobile-client/components/content/typography/TranslatedParagraph';

type TranslatedBulletListProps = {
variant?: 'body1' | 'body2';
i18nKeys: string[];
values?: {};
};

export function TranslatedBulletList({
variant = 'body1',
i18nKeys,
values,
}: TranslatedBulletListProps) {
return (
<BulletList
data={i18nKeys}
renderItem={i18nKey => (
<TranslatedParagraph
i18nKey={i18nKey}
values={values}
variant={variant}
/>
)}
/>
);
}
39 changes: 39 additions & 0 deletions dev-client/src/components/content/typography/TranslatedContent.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
* Copyright © 2024 Technology Matters
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see https://www.gnu.org/licenses/.
*/

import {Trans} from 'react-i18next';

import {Text} from 'terraso-mobile-client/components/NativeBaseAdapters';

export type TranslatedContentProps = {
i18nKey: string;
values?: {};
};

export function TranslatedContent({i18nKey, values}: TranslatedContentProps) {
return (
<Trans
i18nKey={i18nKey}
values={values}
components={{
bold: <Text bold />,
italic: <Text italic />,
underline: <Text underline />,
}}
/>
);
}
32 changes: 32 additions & 0 deletions dev-client/src/components/content/typography/TranslatedHeading.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
* Copyright © 2024 Technology Matters
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see https://www.gnu.org/licenses/.
*/

import {
TranslatedContent,
TranslatedContentProps,
} from 'terraso-mobile-client/components/content/typography/TranslatedContent';
import {Heading} from 'terraso-mobile-client/components/NativeBaseAdapters';

type TranslatedHeadingProps = TranslatedContentProps;

export function TranslatedHeading({i18nKey, values}: TranslatedHeadingProps) {
return (
<Heading variant="h1">
<TranslatedContent i18nKey={i18nKey} values={values} />
</Heading>
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,32 +15,24 @@
* along with this program. If not, see https://www.gnu.org/licenses/.
*/

import {Trans} from 'react-i18next';

import {
TranslatedContent,
TranslatedContentProps,
} from 'terraso-mobile-client/components/content/typography/TranslatedContent';
import {Text} from 'terraso-mobile-client/components/NativeBaseAdapters';

type TranslatedBodyProps = {
i18nKey: string;
type TranslatedParagraphProps = {
variant?: 'body1' | 'body2';
values?: {};
};
} & TranslatedContentProps;

export function TranslatedBody({
i18nKey,
export function TranslatedParagraph({
tm-ruxandra marked this conversation as resolved.
Show resolved Hide resolved
variant = 'body1',
i18nKey,
values,
}: TranslatedBodyProps) {
}: TranslatedParagraphProps) {
return (
<Text variant={variant}>
<Trans
i18nKey={i18nKey}
values={values}
components={{
bold: <Text bold />,
italic: <Text italic />,
underline: <Text underline />,
}}
/>
<TranslatedContent i18nKey={i18nKey} values={values} />
</Text>
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*
* Copyright © 2024 Technology Matters
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see https://www.gnu.org/licenses/.
*/

import {
TranslatedContent,
TranslatedContentProps,
} from 'terraso-mobile-client/components/content/typography/TranslatedContent';
import {Heading} from 'terraso-mobile-client/components/NativeBaseAdapters';

type TranslatedSubHeadingProps = TranslatedContentProps;

export function TranslatedSubHeading({
i18nKey,
values,
}: TranslatedSubHeadingProps) {
return (
<Heading variant="h2">
<TranslatedContent i18nKey={i18nKey} values={values} />
</Heading>
);
}
39 changes: 39 additions & 0 deletions dev-client/src/hooks/userDeletionRequest.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
* Copyright © 2024 Technology Matters
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see https://www.gnu.org/licenses/.
*/

import {useCallback, useState} from 'react';

import {savePreference} from 'terraso-client-shared/account/accountSlice';

import {useDispatch, useSelector} from 'terraso-mobile-client/store';

const PREFERENCES_KEY = 'account_deletion_request';
const PREFERENCES_VALUE = 'true';

export const useUserDeletionRequests = () => {
const dispatch = useDispatch();
const {data: user} = useSelector(state => state.account.currentUser);
const [isPending, setIsPending] = useState(
user!.preferences[PREFERENCES_KEY] === PREFERENCES_VALUE,
);
const requestDeletion = useCallback(() => {
setIsPending(true);
dispatch(savePreference({key: PREFERENCES_KEY, value: PREFERENCES_VALUE}));
}, [dispatch]);

return {user, isPending, requestDeletion};
};
6 changes: 4 additions & 2 deletions dev-client/src/navigation/screenDefinitions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import {BottomTabsScreen} from 'terraso-mobile-client/screens/BottomTabsScreen';
import {ColorAnalysisScreen} from 'terraso-mobile-client/screens/ColorAnalysisScreen/ColorAnalysisScreen';
import {CreateProjectScreen} from 'terraso-mobile-client/screens/CreateProjectScreen/CreateProjectScreen';
import {CreateSiteScreen} from 'terraso-mobile-client/screens/CreateSiteScreen/CreateSiteScreen';
import {DeleteAccountScreen} from 'terraso-mobile-client/screens/DeleteAccountScreen/DeleteAccountScreen';
import {EditProjectInstructionsScreen} from 'terraso-mobile-client/screens/EditProjectInstructionsScreen';
import {EditSiteNoteScreen} from 'terraso-mobile-client/screens/EditSiteNoteScreen';
import {HomeScreen} from 'terraso-mobile-client/screens/HomeScreen/HomeScreen';
Expand All @@ -36,7 +37,6 @@ import {ManageTeamMemberScreen} from 'terraso-mobile-client/screens/ManageTeamMe
import {ProjectListScreen} from 'terraso-mobile-client/screens/ProjectListScreen/ProjectListScreen';
import {ProjectViewScreen} from 'terraso-mobile-client/screens/ProjectViewScreen';
import {ReadNoteScreen} from 'terraso-mobile-client/screens/ReadNoteScreen';
import {SettingsScreen} from 'terraso-mobile-client/screens/SettingsScreen/SettingsScreen';
import {SiteSettingsScreen} from 'terraso-mobile-client/screens/SiteSettingsScreen/SiteSettingsScreen';
import {SiteTeamSettingsScreen} from 'terraso-mobile-client/screens/SiteTeamSettingsScreen';
import {SiteTransferProjectScreen} from 'terraso-mobile-client/screens/SiteTransferProjectScreen/SiteTransferProjectScreen';
Expand All @@ -54,11 +54,12 @@ import {SOCSOMScreen} from 'terraso-mobile-client/screens/SoilScreen/SOCSOMScree
import {StructureScreen} from 'terraso-mobile-client/screens/SoilScreen/StructureScreen';
import {TextureGuideScreen} from 'terraso-mobile-client/screens/SoilScreen/TextureGuideScreen';
import {TextureScreen} from 'terraso-mobile-client/screens/SoilScreen/TextureScreen';
import {UserSettingsScreen} from 'terraso-mobile-client/screens/UserSettingsScreen/UserSettingsScreen';

export const bottomTabScreensDefinitions = {
PROJECT_LIST: ProjectListScreen,
HOME: HomeScreen,
SETTINGS: SettingsScreen,
SETTINGS: UserSettingsScreen,
} satisfies ScreenDefinitions;

export const screenDefinitions = {
Expand Down Expand Up @@ -89,6 +90,7 @@ export const screenDefinitions = {
TEXTURE_GUIDE: TextureGuideScreen,
COLOR_GUIDE: ColorGuideScreen,
COLOR_ANALYSIS: ColorAnalysisScreen,
DELETE_ACCOUNT: DeleteAccountScreen,
} satisfies ScreenDefinitions;

export const modalScreenDefinitions = {
Expand Down
4 changes: 2 additions & 2 deletions dev-client/src/screens/BottomTabsScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import {
import {BottomTabsParamList} from 'terraso-mobile-client/navigation/types';
import {HomeScreen} from 'terraso-mobile-client/screens/HomeScreen/HomeScreen';
import {ProjectListScreen} from 'terraso-mobile-client/screens/ProjectListScreen/ProjectListScreen';
import {SettingsScreen} from 'terraso-mobile-client/screens/SettingsScreen/SettingsScreen';
import {UserSettingsScreen} from 'terraso-mobile-client/screens/UserSettingsScreen/UserSettingsScreen';

export const BottomTabsScreen = memo(() => {
return (
Expand All @@ -41,7 +41,7 @@ export const BottomTabsScreen = memo(() => {
screenOptions={{headerShown: false}}>
<BottomTabs.Screen name="HOME" component={HomeScreen} />
<BottomTabs.Screen name="PROJECT_LIST" component={ProjectListScreen} />
<BottomTabs.Screen name="SETTINGS" component={SettingsScreen} />
<BottomTabs.Screen name="SETTINGS" component={UserSettingsScreen} />
</BottomTabs.Navigator>
);
});
55 changes: 55 additions & 0 deletions dev-client/src/screens/DeleteAccountScreen/DeleteAccountScreen.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/*
* Copyright © 2024 Technology Matters
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see https://www.gnu.org/licenses/.
*/

import {useTranslation} from 'react-i18next';
import {ScrollView} from 'react-native-gesture-handler';

import {ScreenContentSection} from 'terraso-mobile-client/components/content/ScreenContentSection';
import {Column} from 'terraso-mobile-client/components/NativeBaseAdapters';
import {useUserDeletionRequests} from 'terraso-mobile-client/hooks/userDeletionRequest.ts';
import {AppBar} from 'terraso-mobile-client/navigation/components/AppBar';
import {ScreenBackButton} from 'terraso-mobile-client/navigation/components/ScreenBackButton';
import {DeleteAccountConfirmContent} from 'terraso-mobile-client/screens/DeleteAccountScreen/components/DeleteAccountConfirmContent';
import {DeleteAccountConfirmForm} from 'terraso-mobile-client/screens/DeleteAccountScreen/components/DeleteAccountConfirmForm';
import {DeleteAccountPendingContent} from 'terraso-mobile-client/screens/DeleteAccountScreen/components/DeleteAccountPendingContent';
import {ScreenScaffold} from 'terraso-mobile-client/screens/ScreenScaffold';

export function DeleteAccountScreen() {
tm-ruxandra marked this conversation as resolved.
Show resolved Hide resolved
const {t} = useTranslation();
const {user, isPending, requestDeletion} = useUserDeletionRequests();

return (
<ScreenScaffold AppBar={<AppBar LeftButton={<ScreenBackButton />} />}>
<ScrollView>
<ScreenContentSection title={t('delete_account.title')}>
{user &&
(isPending ? (
<DeleteAccountPendingContent user={user} />
) : (
<Column space="16px">
<DeleteAccountConfirmContent user={user} />
<DeleteAccountConfirmForm
user={user}
onConfirm={requestDeletion}
/>
</Column>
))}
</ScreenContentSection>
</ScrollView>
</ScreenScaffold>
);
}
Loading
Loading