Skip to content

Commit edbdfd8

Browse files
pyphiliakimspaenleh
authored
feat: show notice for old deleted items (#1174)
* feat: show notice for old deleted items * fix: update notice message Co-authored-by: Basile Spaenlehauer <spaenleh@gmail.com> --------- Co-authored-by: kim <kim.phanhoang@epfl.ch> Co-authored-by: Basile Spaenlehauer <spaenleh@gmail.com>
1 parent e390132 commit edbdfd8

5 files changed

Lines changed: 51 additions & 2 deletions

File tree

src/locales/en/home.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,6 @@
2323
},
2424
"SURVEY": {
2525
"INFO": "We are conducting a user survey to better understand how you use Graasp. Your feedback is valuable!<br/>Please find the survey link <l1>here</l1>."
26-
}
26+
},
27+
"OLD_DELETED_ITEMS_NOTICE": "Starting mid-January, items <b>deleted</b> more than 90 days ago will be permanently removed from your Trash. To prevent accidental loss of important items, please review your Trash."
2728
}

src/locales/fr/home.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,6 @@
2323
},
2424
"SURVEY": {
2525
"INFO": "Nous lançons une enquête afin de mieux comprendre votre utilisation de la plateforme Graasp. Votre avis compte !<br/>Retrouvez le lien de l'enquête <l1>ici</l1>."
26-
}
26+
},
27+
"OLD_DELETED_ITEMS_NOTICE": "A partir de mi-janvier, les éléments <b>supprimés</b> depuis plus de 90 jours seront définitivement retirés de votre Corbeille. Pour éviter la perte accidentelle d'éléments importants, veuillez vérifier le contenu de votre Corbeille."
2728
}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
import { Trans, useTranslation } from 'react-i18next';
2+
3+
import { Alert } from '@mui/material';
4+
5+
import { NS } from '@/config/constants';
6+
7+
import { useLocalStorage } from './useLocalStorage';
8+
9+
export function OldDeletedItemsNotice({
10+
forceOpen = false,
11+
}: Readonly<{
12+
forceOpen?: boolean;
13+
}>) {
14+
const { t } = useTranslation(NS.Home);
15+
16+
const { value: isClosed, changeValue: setIsClosed } = useLocalStorage(
17+
`old-deleted-items-notice-closed`,
18+
false,
19+
);
20+
21+
if (!forceOpen && isClosed) {
22+
return null;
23+
}
24+
25+
return (
26+
<Alert
27+
severity="info"
28+
onClose={
29+
forceOpen
30+
? undefined
31+
: () => {
32+
setIsClosed(true);
33+
}
34+
}
35+
>
36+
<Trans
37+
t={t}
38+
i18nKey={'OLD_DELETED_ITEMS_NOTICE'}
39+
components={{ b: <b /> }}
40+
/>
41+
</Alert>
42+
);
43+
}

src/routes/_memberOnly/_homeLayout/home.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { Divider, Stack, useMediaQuery, useTheme } from '@mui/material';
33
import { createFileRoute } from '@tanstack/react-router';
44

55
import { MaintenanceAnnouncement } from '@/modules/home/MaintenanceAnnouncement';
6+
import { OldDeletedItemsNotice } from '@/modules/home/OldDeletedItemsNotice';
67
import SurveyBanner from '@/modules/home/SurveyBanner';
78
import { BookmarkedItems } from '@/modules/home/bookmarks/BookmarkedItems';
89

@@ -27,6 +28,7 @@ function HomeRoute() {
2728
<>
2829
<MaintenanceAnnouncement suffix="home" />
2930
<SurveyBanner />
31+
<OldDeletedItemsNotice />
3032
<BookmarkedItems />
3133
<Divider flexItem />
3234
<SelectionContextProvider>

src/routes/_memberOnly/_homeLayout/recycled.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import {
99
RECYCLED_ITEMS_EMPTY_ID,
1010
RECYCLED_ITEMS_ERROR_ALERT_ID,
1111
} from '@/config/selectors';
12+
import { OldDeletedItemsNotice } from '@/modules/home/OldDeletedItemsNotice';
1213
import { useInfiniteOwnRecycledItems } from '@/query/item/recycled/hooks';
1314

1415
import DeleteButton from '~builder/components/common/DeleteButton';
@@ -67,6 +68,7 @@ function RecycledItemsScreenContent() {
6768
return (
6869
<>
6970
<Stack gap={1} height="100%">
71+
<OldDeletedItemsNotice forceOpen />
7072
<Stack
7173
alignItems="space-between"
7274
direction="column"

0 commit comments

Comments
 (0)