import React, { useCallback } from 'react'; import * as need from 'lib/need'; import { Grid, H5, Text, Button } from 'indigo-react'; import { usePointCursor } from 'store/pointCursor'; // import { usePointCache } from 'store/pointCache'; import View from 'components/View'; import Crumbs from 'components/Crumbs'; import useInvites from 'lib/useInvites'; import useSyncPoint from 'lib/useSyncPoint'; import useCurrentPointName from 'lib/useCurrentPointName'; import { useHistory } from 'store/history'; import { ForwardButton } from 'components/Buttons'; import FooterButton from 'components/FooterButton'; import useRouter from 'lib/useRouter'; import InvitesSend from './InvitesSend'; const kInviteNames = { URL: 'URL', EMAIL: 'EMAIL', }; const kInviteViews = { URL: InviteUrl, EMAIL: InvitesSend, }; const valOrLoading = val => val.matchWith({ Nothing: () => '▓', Just: p => p.value, }); function Highlighted(props) { return ; } function InviteUrl({ names, push }) { const pushEmail = useCallback(() => push(names.EMAIL), [push, names]); return ( <> Generate Invite Send Invite via Email Advanced ); } export default function Invite() { const history = useHistory(); const { Route, ...routeProps } = useRouter({ names: kInviteNames, views: kInviteViews, initialRoutes: [{ key: kInviteNames.URL }], }); const { pointCursor } = usePointCursor(); const point = need.pointCursor(pointCursor); const name = useCurrentPointName(); // sync the current cursor useSyncPoint(point); // fetch the invites for the current cursor const { availableInvites, sentInvites, acceptedInvites } = useInvites(point); const availableInvitesText = valOrLoading(availableInvites); const sentInvitesText = valOrLoading(sentInvites); const acceptedInvitesText = valOrLoading(acceptedInvites); return ( history.pop(), }, { text: 'Invite', }, ]} full /> Invite You currently have{' '} {availableInvitesText} invitations left.
Out of the {sentInvitesText} invites you sent, {acceptedInvitesText} have been accepted.
{/* TODO(shrugs): use context isntead of this routeProps nonsense */}
); }