Skip to content

Commit

Permalink
refactor: update from pr
Browse files Browse the repository at this point in the history
  • Loading branch information
pyphilia committed Apr 11, 2024
1 parent 6830b66 commit 0e7390a
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 36 deletions.
3 changes: 1 addition & 2 deletions src/components/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,10 @@ const App = (): JSX.Element => {
RecycledItemsScreen,
withAuthorizationProps,
);
const MapWithAuthorization = MapItemsScreen;

return (
<Routes>
<Route path={MAP_ITEMS_PATH} element={<MapWithAuthorization />} />
<Route path={MAP_ITEMS_PATH} element={<MapItemsScreen />} />
<Route
element={
<Main>
Expand Down
58 changes: 31 additions & 27 deletions src/components/item/MapView.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Typography } from '@mui/material';
import { Stack, Typography } from '@mui/material';

import { Map } from '@graasp/map';
import { type DiscriminatedItem, redirect } from '@graasp/sdk';
Expand All @@ -13,35 +13,39 @@ type Props = {
height?: string;
};

const MapView = ({ parentId, title, height = '80vh' }: Props): JSX.Element => {
const MapView = ({ parentId, title, height = '100vh' }: Props): JSX.Element => {
const { data: currentMember } = hooks.useCurrentMember();

return (
<>
{title && (
<Typography variant="h4" sx={{ wordWrap: 'break-word' }}>
{title}
</Typography>
)}
<div style={{ width: '100%', height }}>
<Map
useDeleteItemGeolocation={mutations.useDeleteItemGeolocation}
usePostItem={mutations.usePostItem}
useRecycleItems={mutations.useRecycleItems}
useAddressFromGeolocation={hooks.useAddressFromGeolocation}
useSuggestionsForAddress={hooks.useSuggestionsForAddress}
useItemsInMap={hooks.useItemsInMap}
viewItem={(item) => {
redirect(window, buildGraaspPlayerView(item.id), {
name: buildPlayerTabName(item.id),
openInNewTab: true,
});
}}
currentMember={currentMember}
itemId={parentId}
/>
</div>
</>
<Stack height={height}>
<Stack>
{title && (
<Typography variant="h4" sx={{ wordWrap: 'break-word' }}>
{title}
</Typography>
)}
</Stack>
<Stack flex={1}>
<div style={{ width: '100%', height: '100%' }}>
<Map
useDeleteItemGeolocation={mutations.useDeleteItemGeolocation}
usePostItem={mutations.usePostItem}
useRecycleItems={mutations.useRecycleItems}
useAddressFromGeolocation={hooks.useAddressFromGeolocation}
useSuggestionsForAddress={hooks.useSuggestionsForAddress}
useItemsInMap={hooks.useItemsInMap}
viewItem={(item) => {
redirect(window, buildGraaspPlayerView(item.id), {
name: buildPlayerTabName(item.id),
openInNewTab: true,
});
}}
currentMember={currentMember}
itemId={parentId}
/>
</div>
</Stack>
</Stack>
);
};

Expand Down
3 changes: 2 additions & 1 deletion src/components/main/Items.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@ const Items = ({
});
switch (mode) {
case ItemLayoutMode.Map:
return <MapView title={title} parentId={parentId} />;
// todo: change when we deal with item screen
return <MapView title={title} parentId={parentId} height="90%" />;
case ItemLayoutMode.Grid:
return (
<ItemsGrid
Expand Down
7 changes: 1 addition & 6 deletions src/components/pages/MapItemsScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,7 @@ import MapView from '../item/MapView';
const MapItemScreen = (): JSX.Element | null => {
const [urlSearchParams] = useSearchParams();

return (
<MapView
parentId={urlSearchParams.get('parentId') ?? undefined}
height="100vh"
/>
);
return <MapView parentId={urlSearchParams.get('parentId') ?? undefined} />;
};

export default MapItemScreen;

0 comments on commit 0e7390a

Please sign in to comment.