-
Notifications
You must be signed in to change notification settings - Fork 245
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'MI-746-gifting-plus' into feat-gift-tracking
- Loading branch information
Showing
11 changed files
with
181 additions
and
37 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
116 changes: 116 additions & 0 deletions
116
packages/shared/src/components/plus/GiftReceivedPlusModal.tsx
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,116 @@ | ||
import type { ReactElement } from 'react'; | ||
import React from 'react'; | ||
import { useQuery } from '@tanstack/react-query'; | ||
import type { ModalProps } from '../modals/common/Modal'; | ||
import { Modal } from '../modals/common/Modal'; | ||
|
||
import type { UserShortProfile } from '../../lib/user'; | ||
import { PlusTitle } from './PlusTitle'; | ||
import { | ||
Typography, | ||
TypographyColor, | ||
TypographyType, | ||
} from '../typography/Typography'; | ||
import CloseButton from '../CloseButton'; | ||
import { ButtonSize, ButtonVariant } from '../buttons/common'; | ||
import { cloudinaryGiftedPlusModalImage } from '../../lib/image'; | ||
import { PlusList } from './PlusList'; | ||
import { Button } from '../buttons/Button'; | ||
import { getPlusGifterUser } from '../../graphql/users'; | ||
import { generateQueryKey, RequestKey } from '../../lib/query'; | ||
import { ProfileImageSize, ProfilePicture } from '../ProfilePicture'; | ||
import Link from '../utilities/Link'; | ||
import { useAuthContext } from '../../contexts/AuthContext'; | ||
import { Loader } from '../Loader'; | ||
|
||
const GifterProfile = ({ gifter }: { gifter: UserShortProfile }) => ( | ||
<Link href={`/${gifter.username}`} passHref> | ||
<a | ||
className="flex items-center gap-2" | ||
title={`View ${gifter.username}'s profile`} | ||
> | ||
<ProfilePicture user={gifter} size={ProfileImageSize.Medium} /> | ||
<Typography | ||
bold | ||
color={TypographyColor.Primary} | ||
type={TypographyType.Callout} | ||
> | ||
{gifter.name} | ||
</Typography> | ||
<Typography | ||
type={TypographyType.Footnote} | ||
color={TypographyColor.Secondary} | ||
> | ||
@{gifter.username} | ||
</Typography> | ||
</a> | ||
</Link> | ||
); | ||
|
||
export function GiftReceivedPlusModal(props: ModalProps): ReactElement { | ||
const { onRequestClose } = props; | ||
const { user } = useAuthContext(); | ||
const { data: gifter, isLoading } = useQuery({ | ||
queryKey: generateQueryKey(RequestKey.GifterUser), | ||
queryFn: getPlusGifterUser, | ||
enabled: Boolean(user?.isPlus), | ||
}); | ||
|
||
if (!gifter || isLoading) { | ||
return ( | ||
<Modal | ||
{...props} | ||
isDrawerOnMobile | ||
kind={Modal.Kind.FixedCenter} | ||
size={Modal.Size.Small} | ||
> | ||
<Modal.Body className="flex flex-1 tablet:!px-4"> | ||
<Loader /> | ||
</Modal.Body> | ||
</Modal> | ||
); | ||
} | ||
|
||
return ( | ||
<Modal | ||
{...props} | ||
isDrawerOnMobile | ||
kind={Modal.Kind.FixedCenter} | ||
size={Modal.Size.Small} | ||
> | ||
<Modal.Body className="flex flex-1 tablet:!px-4"> | ||
<div className="flex flex-1 flex-col gap-4"> | ||
<div className="flex flex-row justify-between"> | ||
<PlusTitle type={TypographyType.Callout} bold /> | ||
<CloseButton | ||
type="button" | ||
size={ButtonSize.Small} | ||
onClick={onRequestClose} | ||
/> | ||
</div> | ||
<GifterProfile gifter={gifter} /> | ||
<Typography bold type={TypographyType.Title1}> | ||
Surprise! 🎁 {gifter.username} thought of you and gifted you a | ||
one-year daily.dev Plus membership! | ||
</Typography> | ||
<img | ||
src={cloudinaryGiftedPlusModalImage} | ||
alt="gift pack with daily.dev logo" | ||
height={140} | ||
width={386} | ||
className="h-auto w-full" | ||
/> | ||
<PlusList className="overflow-clip !py-0" /> | ||
</div> | ||
<Button | ||
className="mt-4 w-full" | ||
href="/squads/plus" | ||
tag="a" | ||
variant={ButtonVariant.Primary} | ||
>{`See what's inside`}</Button> | ||
</Modal.Body> | ||
</Modal> | ||
); | ||
} | ||
|
||
export default GiftReceivedPlusModal; |
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
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