Skip to content

Commit

Permalink
tos and privacy policy. more session refresh work
Browse files Browse the repository at this point in the history
  • Loading branch information
a-type committed Apr 8, 2024
1 parent 5230f33 commit 5099f78
Show file tree
Hide file tree
Showing 43 changed files with 1,392 additions and 1,214 deletions.
2 changes: 1 addition & 1 deletion apps/gnocchi/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"@tiptap/starter-kit": "^2.2.4",
"@use-gesture/react": "^10.2.24",
"@vercel/analytics": "^0.1.6",
"@verdant-web/react-router": "^0.6.1",
"@verdant-web/react-router": "^0.6.2",
"@zip.js/zip.js": "^2.7.6",
"classnames": "^2.3.2",
"convert-units": "^3.0.0-beta.4",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { AutoRestoreScroll } from '@/components/nav/AutoRestoreScroll.jsx';
import { useSearch } from '@/components/pantry/hooks.js';
import { PantryListItem } from '@/components/pantry/items/PantryListItem.jsx';
import { hooks } from '@/stores/groceries/index.js';
Expand All @@ -7,31 +8,32 @@ import { CardGrid } from '@a-type/ui/components/card';
export interface PantrySearchResultsProps {}

export function PantrySearchResults({}: PantrySearchResultsProps) {
const [search] = useSearch();
const [results, pagination] = hooks.useAllFoodsInfinite({
index: {
where: 'nameLookup',
startsWith: search.toLowerCase(),
},
key: 'food-search',
});
const [search] = useSearch();
const [results, pagination] = hooks.useAllFoodsInfinite({
index: {
where: 'nameLookup',
startsWith: search.toLowerCase(),
},
key: 'food-search',
});

if (!results.length) {
return <div>No results</div>;
}
if (!results.length) {
return <div>No results</div>;
}

return (
<div className="flex flex-col gap-4 items-center">
<CardGrid className="grid-cols-[repeat(2,1fr)] w-full">
{results.map((item) => {
return <PantryListItem key={item.get('canonicalName')} item={item} />;
})}
</CardGrid>
{pagination.hasMore && (
<Button color="ghost" onClick={pagination.loadMore}>
Load more
</Button>
)}
</div>
);
return (
<div className="flex flex-col gap-4 items-center">
<CardGrid className="grid-cols-[repeat(2,1fr)] w-full">
{results.map((item) => {
return <PantryListItem key={item.get('canonicalName')} item={item} />;
})}
</CardGrid>
{pagination.hasMore && (
<Button color="ghost" onClick={pagination.loadMore}>
Load more
</Button>
)}
<AutoRestoreScroll />
</div>
);
}
168 changes: 85 additions & 83 deletions apps/gnocchi/web/src/components/sync/meetup/MeetupSelect.tsx
Original file line number Diff line number Diff line change
@@ -1,100 +1,102 @@
import { Icon } from '@/components/icons/Icon.jsx';
import { hooks } from '@/stores/groceries/index.js';
import {
Select,
SelectContent,
SelectGroup,
SelectIcon,
SelectItem,
SelectLabel,
SelectTrigger,
SelectValue,
UnstyledSelectTrigger,
Select,
SelectContent,
SelectGroup,
SelectIcon,
SelectItem,
SelectLabel,
SelectTrigger,
SelectValue,
UnstyledSelectTrigger,
} from '@a-type/ui/components/select';
import classNames from 'classnames';
import { ReactNode, useCallback, useEffect } from 'react';

export interface MeetupSelectProps {
children?: (value: string | undefined) => ReactNode;
id?: string;
emptyLabel?: string;
children?: (value: string | undefined) => ReactNode;
id?: string;
emptyLabel?: string;
}

export function MeetupSelect({ children, id, emptyLabel }: MeetupSelectProps) {
const client = hooks.useClient();
const info = hooks.useCollaborationInfo('default');
hooks.useWatch(info);
const meetup = info?.get('meetup') ?? null;
hooks.useWatch(meetup);
const client = hooks.useClient();
const info = hooks.useCollaborationInfo('default');
hooks.useWatch(info);
const meetup = info?.get('meetup') ?? null;
hooks.useWatch(meetup);

useEffect(() => {
if (!info) {
client.collaborationInfo.put({});
}
}, [info]);
useEffect(() => {
if (!info) {
client.collaborationInfo.put({});
}
}, [info, client]);

let location = meetup?.get('location');
const createdAt = meetup?.get('createdAt') || 0;
if (createdAt < Date.now() - 1000 * 60 * 60) {
location = undefined;
}
let location = meetup?.get('location');
const createdAt = meetup?.get('createdAt') || 0;
if (createdAt < Date.now() - 1000 * 60 * 60) {
location = undefined;
}

const categories = hooks.useAllCategories();
const options = categories.map((cat) => cat.get('name'));
const categories = hooks.useAllCategories();
const options = categories.map((cat) => cat.get('name'));

const setMeetup = useCallback(
(value: string) => {
client
.batch({ undoable: false })
.run(() => {
info?.set('meetup', {
location: value,
});
})
.flush();
},
[info, client],
);
const clearMeetup = useCallback(() => {
info?.set('meetup', undefined);
}, [info]);
const Trigger = children ? UnstyledSelectTrigger : SelectTrigger;
const setMeetup = useCallback(
(value: string) => {
if (value === 'clear') {
info?.set('meetup', undefined);
} else {
client
.batch({ undoable: false })
.run(() => {
info?.set('meetup', {
location: value,
});
})
.commit();
}
},
[info, client],
);

return (
<Select value={location || ''} onValueChange={setMeetup}>
<Trigger
asChild={!!children}
className={classNames(
!children && 'py-3 px-6',
!!location && 'bg-accent-wash color-accent-dark',
)}
id={id}
>
{children ? (
children(location)
) : (
<>
<Icon name="locate" />
<SelectValue />
<SelectIcon />
</>
)}
</Trigger>
<SelectContent>
<SelectItem value="">
{location ? 'Clear' : emptyLabel || 'Regroup'}
</SelectItem>
<SelectGroup>
<SelectLabel>Choose a location</SelectLabel>
<SelectItem value="Checkout Lanes">Checkout Lanes</SelectItem>
<SelectItem value="Self Checkout">Self Checkout</SelectItem>
{options.map((option) => (
<SelectItem value={option} key={option}>
{option}
</SelectItem>
))}
</SelectGroup>
</SelectContent>
</Select>
);
const Trigger = children ? UnstyledSelectTrigger : SelectTrigger;

return (
<Select value={location || ''} onValueChange={setMeetup}>
<Trigger
asChild={!!children}
className={classNames(
!children && 'py-3 px-6',
!!location && 'bg-accent-wash color-accent-dark',
)}
id={id}
>
{children ? (
children(location)
) : (
<>
<Icon name="locate" />
<SelectValue />
<SelectIcon />
</>
)}
</Trigger>
<SelectContent>
<SelectItem value="clear">
{location ? 'Clear' : emptyLabel || 'Regroup'}
</SelectItem>
<SelectGroup>
<SelectLabel>Choose a location</SelectLabel>
<SelectItem value="Checkout Lanes">Checkout Lanes</SelectItem>
<SelectItem value="Self Checkout">Self Checkout</SelectItem>
{options.map((option) => (
<SelectItem value={option} key={option}>
{option}
</SelectItem>
))}
</SelectGroup>
</SelectContent>
</Select>
);
}
17 changes: 0 additions & 17 deletions apps/gnocchi/web/src/pages/Pages.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,6 @@ const RecipeEditPage = lazyWithPreload(
const RecipeOverviewPage = lazyWithPreload(
() => import('./recipe/RecipeOverviewPage.jsx'),
);
const PrivacyPolicyPage = lazy(() => import('./PrivacyPolicy.jsx'));
const TermsAndConditionsPage = lazy(() => import('./TermsAndConditions.jsx'));
const PantryPage = lazyWithPreload(() => import('./pantry/PantryPage.js'));
const PantryListPage = lazyWithPreload(
() => import('./pantry/PantryListPage.js'),
Expand Down Expand Up @@ -153,14 +151,6 @@ const routes = makeRoutes([
},
],
},
{
path: 'privacy-policy',
component: PrivacyPolicyPage,
},
{
path: 'tos',
component: TermsAndConditionsPage,
},
{
path: '',
component: NotFoundPage,
Expand All @@ -176,13 +166,6 @@ function LayoutWithNavBar() {
<NavBar />
</PageRoot>
);

// return (
// <PageRoot>
// <SwipeOutlet scroll className="[grid-area:content]" />
// <NavBar />
// </PageRoot>
// );
}

export function Pages() {
Expand Down
2 changes: 2 additions & 0 deletions apps/gnocchi/web/src/pages/PlanPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import { ArrowRightIcon } from '@radix-ui/react-icons';
import { ReactNode, useEffect } from 'react';
import { groceriesDescriptor } from '@/stores/groceries/index.js';
import { VAPID_KEY } from '@/config.js';
import { AutoRestoreScroll } from '@/components/nav/AutoRestoreScroll.jsx';

const contents = {
offline: OfflineContents,
Expand Down Expand Up @@ -74,6 +75,7 @@ export function PlanPage() {
<TextLink to="/tos">Terms and conditions of use</TextLink>
</div>
</div>
<AutoRestoreScroll />
</PageContent>
);
}
Expand Down
Loading

0 comments on commit 5099f78

Please sign in to comment.