Skip to content

Commit

Permalink
feat(unlock-app): adding hideRemaining for events
Browse files Browse the repository at this point in the history
  • Loading branch information
julien51 committed May 22, 2024
1 parent 9f3c17f commit 0e2ee73
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 11 deletions.
1 change: 1 addition & 0 deletions packages/core/src/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,7 @@ export const EventObject = z.object({
image: z.string().url(),
description: z.string(),
requiresApproval: z.boolean(),
hideRemaining: z.boolean().optional(), // This should rather be a checkoutConfig property.
emailSender: z.string(),
replyTo: z.string(),
ticket: z.object({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ export const EventBannerlessLayout = ({
<RegistrationCard
requiresApproval={event.requiresApproval}
checkoutConfig={checkoutConfig}
hideRemaining={!!event.hideRemaining}
/>
)}
{hasPassed && (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ export const EventDefaultLayout = ({
<RegistrationCard
requiresApproval={event.requiresApproval}
checkoutConfig={checkoutConfig}
hideRemaining={!!event.hideRemaining}
/>
)}
{hasPassed && (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ interface LockPriceInternalsProps {
keysLeft: number
showContract?: boolean
lockCheckoutConfig: PaywallLockConfigType
hideRemaining: boolean
}
export const LockPriceInternals = ({
lock,
Expand All @@ -29,6 +30,7 @@ export const LockPriceInternals = ({
keysLeft,
showContract = false,
lockCheckoutConfig,
hideRemaining,
}: LockPriceInternalsProps) => {
const name = lockCheckoutConfig.name || lock.name
return (
Expand All @@ -47,17 +49,19 @@ export const LockPriceInternals = ({
</span>
</>
</div>
<div className="flex items-center gap-2">
<Icon icon={TicketIcon} size={30} />
{hasUnlimitedKeys ? (
<span className="text-base font-bold">&infin;</span>
) : (
<span className="text-base font-bold">
{isSoldOut ? 'Sold out' : keysLeft}
</span>
)}
{!isSoldOut && <span className="text-gray-600">Left</span>}
</div>
{!hideRemaining && (
<div className="flex items-center gap-2">
<Icon icon={TicketIcon} size={30} />
{hasUnlimitedKeys ? (
<span className="text-base font-bold">&infin;</span>
) : (
<span className="text-base font-bold">
{isSoldOut ? 'Sold out' : keysLeft}
</span>
)}
{!isSoldOut && <span className="text-gray-600">Left</span>}
</div>
)}
</div>
</div>
)
Expand All @@ -68,12 +72,14 @@ interface LockPriceDetailsProps {
network: number
showContract?: boolean
lockCheckoutConfig: PaywallLockConfigType
hideRemaining: boolean
}
export const LockPriceDetails = ({
lockAddress,
network,
showContract = false,
lockCheckoutConfig,
hideRemaining,
}: LockPriceDetailsProps) => {
const { lock, isLockLoading } = useLockData({
lockAddress,
Expand Down Expand Up @@ -119,6 +125,7 @@ export const LockPriceDetails = ({
isSoldOut={isSoldOut}
keysLeft={keysLeft}
showContract={showContract}
hideRemaining={hideRemaining}
/>
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,13 @@ export interface RegistrationCardProps {
config: PaywallConfigType
}
requiresApproval: boolean
hideRemaining: boolean
}

export const RegistrationCard = ({
requiresApproval,
checkoutConfig,
hideRemaining,
}: RegistrationCardProps) => {
const [hasRefreshed, setHasRefreshed] = useState(false)
// Check if the user has a key!
Expand Down Expand Up @@ -48,6 +50,7 @@ export const RegistrationCard = ({
requiresApproval={requiresApproval}
refresh={refresh}
checkoutConfig={checkoutConfig}
hideRemaining={hideRemaining}
/>
</Card>
)
Expand Down Expand Up @@ -75,6 +78,7 @@ export const RegistrationCard = ({
}
lockCheckoutConfig={checkoutConfig.config.locks[lockAddress]}
showContract
hideRemaining={hideRemaining}
/>
)
})}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,14 @@ export interface RegistrationCardSingleLockProps {
}
refresh: any
requiresApproval: boolean
hideRemaining: boolean
}

export const RegistrationCardSingleLock = ({
checkoutConfig,
refresh,
requiresApproval,
hideRemaining,
}: RegistrationCardSingleLockProps) => {
const lockAddress = Object.keys(checkoutConfig.config.locks)[0]
const network = (checkoutConfig.config.locks[lockAddress].network ||
Expand Down Expand Up @@ -93,6 +95,7 @@ export const RegistrationCardSingleLock = ({
isSoldOut={isSoldOut}
keysLeft={keysLeft}
showContract={true}
hideRemaining={hideRemaining}
/>
{!isSoldOut && isClaimable && (
<WalletlessRegistrationClaim
Expand Down

0 comments on commit 0e2ee73

Please sign in to comment.