forked from Boehringer-Ingelheim/goat-health-app
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(favorites): add page to view favorite marked articles
- add new routes `/favorite` and `/favorites` - add `FavoritesPage` - add i18n context - update chapter-section-id - update user state
- Loading branch information
1 parent
be00070
commit c82cdbe
Showing
12 changed files
with
184 additions
and
34 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import { | ||
IonButtons, | ||
IonContent, | ||
IonHeader, | ||
IonMenuButton, | ||
IonPage, | ||
IonTitle, | ||
IonToolbar, | ||
} from '@ionic/react'; | ||
import React from 'react'; | ||
import { useTranslation } from 'react-i18next'; | ||
import { FavoritesPopover } from './FavoritesPopover'; | ||
import { FavoritesResults } from './FavoritesResults'; | ||
|
||
export const FavoritesPage: React.FC = () => { | ||
const { t } = useTranslation(); | ||
|
||
return ( | ||
<IonPage> | ||
<IonHeader> | ||
<IonToolbar color="primary"> | ||
<IonButtons slot="start"> | ||
<IonMenuButton /> | ||
</IonButtons> | ||
<IonTitle>{t('FAVORITES.TITLE')}</IonTitle> | ||
<IonButtons slot="primary"> | ||
<FavoritesPopover /> | ||
</IonButtons> | ||
</IonToolbar> | ||
</IonHeader> | ||
|
||
<IonContent color="primary-collapse-condense" fullscreen> | ||
<IonHeader collapse="condense"> | ||
<IonToolbar color="primary"> | ||
<IonTitle size="large">{t('FAVORITES.TITLE')}</IonTitle> | ||
</IonToolbar> | ||
</IonHeader> | ||
<div className="app-background app-fullscreen"> | ||
<FavoritesResults /> | ||
</div> | ||
</IonContent> | ||
</IonPage> | ||
); | ||
}; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import { IonGrid, IonNote, IonRow } from '@ionic/react'; | ||
import React from 'react'; | ||
import { useTranslation } from 'react-i18next'; | ||
import { useSelector } from 'react-redux'; | ||
import { Chapter } from '../../components/Chapters'; | ||
import { | ||
selectCurrentFavoritesView, | ||
selectFavorites, | ||
} from '../../data/user/user.selector'; | ||
import { | ||
ChapterId, | ||
getChapterIdAndSectionIdFromId, | ||
} from '../../utils/chapters'; | ||
|
||
export const FavoritesResults: React.FC = () => { | ||
const { t } = useTranslation(); | ||
const currentView = useSelector(selectCurrentFavoritesView); | ||
const results = useSelector(selectFavorites); | ||
|
||
if (results.length === 0) { | ||
return ( | ||
<IonGrid> | ||
<IonRow class="ion-justify-content-center"> | ||
<IonNote class="ion-padding">{t('FAVORITES.RESULTS.NONE')}</IonNote> | ||
</IonRow> | ||
</IonGrid> | ||
); | ||
} | ||
|
||
return ( | ||
<IonGrid> | ||
{results.map((resultId, resultIndex) => { | ||
const { chapterId, sectionId } = getChapterIdAndSectionIdFromId( | ||
resultId, | ||
); | ||
return ( | ||
<IonRow class="ion-justify-content-center" key={resultIndex}> | ||
<Chapter | ||
chapterId={chapterId as ChapterId} | ||
sectionId={sectionId} | ||
view={currentView} | ||
/> | ||
</IonRow> | ||
); | ||
})} | ||
</IonGrid> | ||
); | ||
}; |
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 @@ | ||
export { FavoritesPage } from './FavoritesPage'; |
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