all repos — caroster @ 50124442e0697b0c7b59e9b6adabf98697fb21ae

[Octree] Group carpool to your event https://caroster.io

:lipstick: add menu and fab on screen when we have no events
Hadrien Froger hadrien@octree.ch
Sat, 18 Jul 2020 08:06:26 +0100
commit

50124442e0697b0c7b59e9b6adabf98697fb21ae

parent

091e697e0d29245b95892a59b8ce86ed6f6b37d1

2 files changed, 46 insertions(+), 30 deletions(-)

jump to
M app/src/locales/fr.jsonapp/src/locales/fr.json

@@ -108,9 +108,9 @@ "past" : "Évènement passé",

"past_plural": "Évènements passés" } , "noEvent": { - "title": "Tableau de bord Caroster", - "text_html": "Ceci est votre tableau de bord, vous y verrez <strong>les évènements auxquels vous participer</strong>", - "create_event": "Créer un évènement" + "title": "Bienvenue sur Caroster", + "text_html": "Ici, vous y verrez <strong>les évènements auxquels vous participer</strong>, pour commencer créer un évènement !", + "create_event": "Nouvel évènement" } }, "passenger": {
M app/src/pages/Dashboard.jsapp/src/pages/Dashboard.js

@@ -12,14 +12,48 @@ import {useTranslation} from 'react-i18next';

import GenericMenu from '../containers/GenericMenu'; import {useHistory} from 'react-router-dom'; + +const Menu = () => { + const history = useHistory(); + const {t} = useTranslation(); + + const goProfile = history.push.bind(undefined, '/profile'); + const goNewEvent = history.push.bind(undefined, '/new'); + const goAbout = () => (window.location.href = t('meta.about_href')); + + return ( + <GenericMenu + title={t('dashboard.title')} + actions={[ + { + label: t('dashboard.actions.add_event'), + onClick: goNewEvent, + id: 'AddEventTabs', + }, + { + label: t('dashboard.actions.see_profile'), + onClick: goProfile, + id: 'ProfileTabs', + }, + { + label: t('dashboard.actions.about'), + onClick: goAbout, + id: 'AboutTabs', + }, + ]} + /> + ); +}; const Dashboard = () => { const [myEvents, setMyEvents] = useState([]); const [isLoading, setIsLoading] = useState(true); - const {t} = useTranslation(); const strapi = useStrapi(); const {authState, token} = useAuth(); const history = useHistory(); + const sortDesc = ({date: dateA}, {date: dateB}) => dateB.localeCompare(dateA); + const goNewEvent = history.push.bind(undefined, '/new'); + const pastEvents = useMemo( () => myEvents

@@ -74,37 +108,19 @@ if (!token || !myEvents) return <div>Not connected</div>;

if (!isLoading && myEvents.length === 0) { return ( - <LayoutCentered> - <EmptyDashboard /> - </LayoutCentered> + <> + <Menu /> + <LayoutCentered> + <EmptyDashboard /> + <DashboardFab onClick={() => goNewEvent()} /> + </LayoutCentered> + </> ); } - const goProfile = history.push.bind(undefined, '/profile'); - const goNewEvent = history.push.bind(undefined, '/new'); - const goAbout = () => (window.location.href = t('meta.about_href')); return ( <> - <GenericMenu - title={t('dashboard.title')} - actions={[ - { - label: t('dashboard.actions.add_event'), - onClick: goNewEvent, - id: 'AddEventTabs', - }, - { - label: t('dashboard.actions.see_profile'), - onClick: goProfile, - id: 'ProfileTabs', - }, - { - label: t('dashboard.actions.about'), - onClick: goAbout, - id: 'AboutTabs', - }, - ]} - /> + <Menu /> <LayoutDefault> <DashboardWithCard pastEvents={pastEvents}