-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add verification button in place details view (#149)
* Add verification button in place details view * Display status when it is visited
- Loading branch information
1 parent
62d87d1
commit f6237c8
Showing
9 changed files
with
202 additions
and
81 deletions.
There are no files selected for viewing
21 changes: 21 additions & 0 deletions
21
src/app/[locale]/(app)/explore/_components/place-details-verificate-button.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,21 @@ | ||
'use client' | ||
|
||
import { FC } from 'react' | ||
import { shotConfettiStars } from '~/helpers/confetti' | ||
import { | ||
VerificateButton, | ||
VerificateButtonProps, | ||
} from '../../missions/_components/verificate-button' | ||
|
||
export const PlaceDetailsVerificateButton: FC<VerificateButtonProps> = ( | ||
props | ||
) => { | ||
return ( | ||
<VerificateButton | ||
{...props} | ||
onVerificate={(verificated) => { | ||
shotConfettiStars({ withStars: verificated }) | ||
}} | ||
/> | ||
) | ||
} |
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
81 changes: 81 additions & 0 deletions
81
src/app/[locale]/(app)/missions/_components/verificate-button.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,81 @@ | ||
'use client' | ||
|
||
import { Button, useDisclosure } from '@nextui-org/react' | ||
import { IconDiscountCheckFilled } from '@tabler/icons-react' | ||
import { useTranslations } from 'next-intl' | ||
import { FC } from 'react' | ||
import { MapPoint } from '~/helpers/spatial-data' | ||
import { VerificationRequirements } from '~/server/db/constants/verifications' | ||
import { | ||
OnVerificate, | ||
VerificatePlaceVisitModal, | ||
} from './verificate-place-visit-modal' | ||
|
||
export type VerificateButtonProps = { | ||
expectedLocation: MapPoint | ||
placeId: number | ||
isAlreadyVisited: boolean | ||
isAlreadyVerified: boolean | ||
verificationRequirements: VerificationRequirements | null | ||
className?: string | ||
onVerificate?: OnVerificate | ||
hideIfDone?: boolean | ||
} | ||
|
||
export const VerificateButton: FC<VerificateButtonProps> = ({ | ||
placeId, | ||
expectedLocation, | ||
isAlreadyVisited, | ||
isAlreadyVerified, | ||
verificationRequirements, | ||
className, | ||
onVerificate, | ||
hideIfDone, | ||
}) => { | ||
const t = useTranslations('missions') | ||
const { | ||
isOpen: isVerificateModalOpen, | ||
onOpen: onVerificateModalOpen, | ||
onOpenChange: onVerificateModalOpenChange, | ||
} = useDisclosure() | ||
const isVerificationRequired = | ||
verificationRequirements && verificationRequirements.isLocationRequired | ||
|
||
return ( | ||
<> | ||
{(isVerificationRequired ? isAlreadyVerified : isAlreadyVisited) ? ( | ||
!hideIfDone && ( | ||
<Button | ||
fullWidth | ||
color="primary" | ||
isDisabled | ||
startContent={<IconDiscountCheckFilled size={20} />} | ||
className={className} | ||
> | ||
{t('visit-already-verified')} | ||
</Button> | ||
) | ||
) : ( | ||
<Button | ||
color="primary" | ||
fullWidth | ||
onPress={onVerificateModalOpen} | ||
startContent={<IconDiscountCheckFilled size={20} />} | ||
className={className} | ||
> | ||
{t('verificate-visit')} | ||
</Button> | ||
)} | ||
|
||
<VerificatePlaceVisitModal | ||
isOpen={isVerificateModalOpen} | ||
onOpenChange={onVerificateModalOpenChange} | ||
expectedLocation={expectedLocation} | ||
placeId={placeId} | ||
onVerificate={onVerificate} | ||
isAlreadyVisited={isAlreadyVisited} | ||
verificationRequirements={verificationRequirements} | ||
/> | ||
</> | ||
) | ||
} |
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
Oops, something went wrong.