diff --git a/dev-client/package-lock.json b/dev-client/package-lock.json index 6291fcb8f..675538e3c 100644 --- a/dev-client/package-lock.json +++ b/dev-client/package-lock.json @@ -36,7 +36,7 @@ "react-native-svg": "^13.14.0", "react-native-tab-view": "^3.5.2", "react-native-vector-icons": "^10.0.1", - "terraso-client-shared": "github:techmatters/terraso-client-shared#babc75d", + "terraso-client-shared": "github:techmatters/terraso-client-shared#ed971c1", "uuid": "^9.0.1", "yup": "^1.3.2" }, @@ -14158,9 +14158,12 @@ } }, "node_modules/jwt-decode": { - "version": "3.1.2", - "resolved": "https://registry.npmjs.org/jwt-decode/-/jwt-decode-3.1.2.tgz", - "integrity": "sha512-UfpWE/VZn0iP50d8cz9NrZLM9lSWhcJ+0Gt/nm4by88UL+J1SiKN8/5dkjMmbEzwL2CAe+67GsegCbIKtbp75A==" + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/jwt-decode/-/jwt-decode-4.0.0.tgz", + "integrity": "sha512-+KJGIyHgkGuIq3IEBNftfhW/LfWhXUIY6OmyVWjliu5KH1y0fw7VQ8YndE2O4qZdMSd9SqbnC8GOcZEy0Om7sA==", + "engines": { + "node": ">=18" + } }, "node_modules/keyv": { "version": "4.5.3", @@ -18710,7 +18713,7 @@ "resolved": "git+ssh://git@github.com/techmatters/terraso-client-shared.git#babc75d89dfe9933682a8ae04036fd1c1fa87f69", "dependencies": { "@reduxjs/toolkit": "^1.9.7", - "jwt-decode": "^3.1.2", + "jwt-decode": "^4.0.0", "lodash": "^4.17.21", "react": "^18.2.0", "react-redux": "^8.1.3", diff --git a/dev-client/package.json b/dev-client/package.json index 30ff6e3e5..a464424ad 100644 --- a/dev-client/package.json +++ b/dev-client/package.json @@ -41,7 +41,7 @@ "react-native-svg": "^13.14.0", "react-native-tab-view": "^3.5.2", "react-native-vector-icons": "^10.0.1", - "terraso-client-shared": "github:techmatters/terraso-client-shared#babc75d", + "terraso-client-shared": "github:techmatters/terraso-client-shared#ed971c1", "uuid": "^9.0.1", "yup": "^1.3.2" }, diff --git a/dev-client/src/components/projects/ProjectSitesTab.tsx b/dev-client/src/components/projects/ProjectSitesTab.tsx index b97dc8172..b4b2d03a3 100644 --- a/dev-client/src/components/projects/ProjectSitesTab.tsx +++ b/dev-client/src/components/projects/ProjectSitesTab.tsx @@ -23,7 +23,11 @@ import { MaterialCommunityIcons, } from 'terraso-mobile-client/components/common/Icons'; import {RootStackScreenProps} from 'terraso-mobile-client/screens/AppScaffold'; -import {Site, deleteSite} from 'terraso-client-shared/site/siteSlice'; +import { + Site, + deleteSite, + updateSite, +} from 'terraso-client-shared/site/siteSlice'; import { useDispatch, useSelector, @@ -36,6 +40,7 @@ import { import {SiteCard} from 'terraso-mobile-client/components/sites/SiteCard'; import {useTextSearch} from 'terraso-mobile-client/components/common/search/search'; import {CardTopRightButton} from 'terraso-mobile-client/components/common/Card'; +import ConfirmModal from 'terraso-mobile-client/components/common/ConfirmModal'; type SiteMenuProps = { iconName: string; @@ -69,8 +74,14 @@ const SiteMenu = ({site}: SiteProps) => { dispatch(removeSiteFromAllProjects(site.id)); }; + const removeSiteFromProjectCallback = async () => { + const input = {id: site.id, projectId: null}; + return dispatch(updateSite(input)); + }; + return ( ( { {...triggerProps} /> )}> - - ( + + )} + title={t('projects.sites.remove_site_modal.title')} + body={t('projects.sites.remove_site_modal.body', {siteName: site.name})} + actionName={t('projects.sites.remove_site_modal.action_name')} + handleConfirm={removeSiteFromProjectCallback} + /> + + ( + + )} + title={t('projects.sites.delete_site_modal.title')} + body={t('projects.sites.delete_site_modal.body', {siteName: site.name})} + actionName={t('projects.sites.delete_site_modal.action_name')} + handleConfirm={deleteSiteCallback} /> ); diff --git a/dev-client/src/translations/en.json b/dev-client/src/translations/en.json index ff4bcebfd..66a11d747 100644 --- a/dev-client/src/translations/en.json +++ b/dev-client/src/translations/en.json @@ -160,7 +160,17 @@ "go_to": "Go to Site", "audit_log": "Audit Log", "remove_site": "Remove from Project", - "delete_site": "Delete Site" + "delete_site": "Delete Site", + "delete_site_modal": { + "title": "Delete site?", + "body": "This will permanently delete the site {{siteName}} and all of its data. This cannot be undone.\n\nProject managers can remove the site from this project to retain its data.", + "action_name": "Delete" + }, + "remove_site_modal": { + "title": "Remove site from project?", + "body": "Only you will have access to this site and its data. Other project team members will no longer have access.", + "action_name": "Remove Site" + } }, "add": { "name": "Project Name",