generated from graasp/graasp-repo
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
238 additions
and
141 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 was deleted.
Oops, something went wrong.
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,42 @@ | ||
import { Stack, Typography } from '@mui/material'; | ||
|
||
import { Button } from '@graasp/ui'; | ||
|
||
import { CircleUser } from 'lucide-react'; | ||
|
||
import { usePlayerTranslation } from '@/config/i18n'; | ||
import { mutations } from '@/config/queryClient'; | ||
import { PLAYER } from '@/langs/constants'; | ||
|
||
// eslint-disable-next-line import/prefer-default-export | ||
export const EnrollContent = ({ itemId }: { itemId: string }): JSX.Element => { | ||
const { t: translatePlayer } = usePlayerTranslation(); | ||
|
||
const { mutate: enroll } = mutations.useEnroll(); | ||
|
||
return ( | ||
<Stack | ||
direction="column" | ||
justifyContent="center" | ||
alignItems="center" | ||
height="100%" | ||
gap={2} | ||
> | ||
<CircleUser size={40} /> | ||
<Typography variant="h3"> | ||
{translatePlayer(PLAYER.ENROLL_TITLE)} | ||
</Typography> | ||
<Typography variant="subtitle2"> | ||
{translatePlayer(PLAYER.ENROLL_DESCRIPTION)} | ||
</Typography> | ||
<Button | ||
// dataCy={ENROLL_BUTTON_SELECTOR} | ||
onClick={() => { | ||
enroll({ itemId }); | ||
}} | ||
> | ||
{translatePlayer(PLAYER.ENROLL_BUTTON)} | ||
</Button> | ||
</Stack> | ||
); | ||
}; |
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 { useNavigate, useParams } from 'react-router-dom'; | ||
|
||
import { AccountType } from '@graasp/sdk'; | ||
import { ItemLoginWrapper } from '@graasp/ui'; | ||
|
||
import { HOME_PATH } from '@/config/paths'; | ||
import { hooks, mutations } from '@/config/queryClient'; | ||
import { | ||
ITEM_LOGIN_PASSWORD_INPUT_ID, | ||
ITEM_LOGIN_SIGN_IN_BUTTON_ID, | ||
ITEM_LOGIN_USERNAME_INPUT_ID, | ||
} from '@/config/selectors'; | ||
import PlayerCookiesBanner from '@/modules/cookies/PlayerCookiesBanner'; | ||
|
||
import ItemForbiddenScreen from '../../item/ItemForbiddenScreen'; | ||
import MainScreen from '../../item/MainScreen'; | ||
import { EnrollContent } from './EnrollContent'; | ||
import { RequestAccessContent } from './RequestAccessContent'; | ||
|
||
const { useItem, useItemLoginSchemaType, useCurrentMember } = hooks; | ||
|
||
const ItemPage = (): JSX.Element | null => { | ||
const { itemId } = useParams(); | ||
const navigate = useNavigate(); | ||
const { mutate: itemLoginSignIn } = mutations.usePostItemLogin(); | ||
const { data: item, isLoading: isItemLoading } = useItem(itemId); | ||
const { data: itemLoginSchemaType, isLoading: isLoadingItemLoginSchemaType } = | ||
useItemLoginSchemaType({ itemId }); | ||
const { data: currentAccount, isLoading: isLoadingMember } = | ||
useCurrentMember(); | ||
|
||
if (!itemId) { | ||
navigate(HOME_PATH); | ||
return null; | ||
} | ||
return ( | ||
<ItemLoginWrapper | ||
itemId={itemId} | ||
item={item} | ||
currentAccount={currentAccount} | ||
signIn={itemLoginSignIn} | ||
itemLoginSchemaType={itemLoginSchemaType} | ||
usernameInputId={ITEM_LOGIN_USERNAME_INPUT_ID} | ||
signInButtonId={ITEM_LOGIN_SIGN_IN_BUTTON_ID} | ||
passwordInputId={ITEM_LOGIN_PASSWORD_INPUT_ID} | ||
enrollContent={<EnrollContent itemId={itemId} />} | ||
forbiddenContent={<ItemForbiddenScreen />} | ||
requestAccessContent={ | ||
currentAccount?.type === AccountType.Individual ? ( | ||
<RequestAccessContent itemId={itemId} member={currentAccount} /> | ||
) : undefined | ||
} | ||
isLoading={ | ||
isLoadingMember || isItemLoading || isLoadingItemLoginSchemaType | ||
} | ||
> | ||
<MainScreen /> | ||
<PlayerCookiesBanner /> | ||
</ItemLoginWrapper> | ||
); | ||
}; | ||
|
||
export default ItemPage; |
Oops, something went wrong.