-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add published tab and fix flickering in main menu (#695)
- Loading branch information
Alexandre Chau
authored
Jul 27, 2023
1 parent
848213e
commit a187372
Showing
9 changed files
with
153 additions
and
51 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
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,63 @@ | ||
import { List } from 'immutable'; | ||
|
||
import { Box } from '@mui/material'; | ||
|
||
import { Member } from '@graasp/sdk'; | ||
import { BUILDER } from '@graasp/translations'; | ||
import { Loader } from '@graasp/ui'; | ||
|
||
import { useBuilderTranslation } from '../../config/i18n'; | ||
import { hooks } from '../../config/queryClient'; | ||
import { | ||
PUBLISHED_ITEMS_ERROR_ALERT_ID, | ||
PUBLISHED_ITEMS_ID, | ||
} from '../../config/selectors'; | ||
import ErrorAlert from '../common/ErrorAlert'; | ||
import { useCurrentUserContext } from '../context/CurrentUserContext'; | ||
import ItemHeader from '../item/header/ItemHeader'; | ||
import Items from './Items'; | ||
import Main from './Main'; | ||
|
||
const PublishedItemsDisplay = ({ member }: { member: Member }): JSX.Element => { | ||
const { t: translateBuilder } = useBuilderTranslation(); | ||
const { | ||
data: sharedItems, | ||
isLoading, | ||
isError, | ||
} = hooks.usePublishedItemsForMember(member.id); | ||
|
||
if (isError) { | ||
return <ErrorAlert id={PUBLISHED_ITEMS_ERROR_ALERT_ID} />; | ||
} | ||
|
||
if (isLoading) { | ||
return <Loader />; | ||
} | ||
|
||
return ( | ||
<Box mx={2}> | ||
<ItemHeader showNavigation={false} /> | ||
<Items | ||
id={PUBLISHED_ITEMS_ID} | ||
title={translateBuilder(BUILDER.PUBLISHED_ITEMS_TITLE)} | ||
items={sharedItems ?? List()} | ||
/> | ||
</Box> | ||
); | ||
}; | ||
|
||
const PublishedItems = (): JSX.Element => { | ||
const { data: member, isError } = useCurrentUserContext(); | ||
|
||
if (!member || isError) { | ||
return <ErrorAlert id={PUBLISHED_ITEMS_ERROR_ALERT_ID} />; | ||
} | ||
|
||
return ( | ||
<Main> | ||
<PublishedItemsDisplay member={member} /> | ||
</Main> | ||
); | ||
}; | ||
|
||
export default PublishedItems; |
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