UIPackage React Native
Search
Menu

Pickup Handoff

Pickup handoff with location, collection window and a presentation code shown only when ready.

Select an available time, then choose Reserve pickup window to see the handoff.

Install

First install? Set up the registry in your app.

npx --yes --package=https://native.uipkge.dev/cli/uipkge-native-0.1.1.tgz uipkge-native add pickup-handoff

Source files

Expand a file to read the source the installer copies into your app.

components/blocks/pickup-handoff/PickupHandoff.tsx
import type { ReactElement } from 'react'
import { View, type ViewProps } from 'react-native'
import { Badge } from '@/components/ui/badge'
import { Text } from '@/components/ui/text'
import { useAnnouncement } from '@/lib/accessibility'
import { cn } from '@/lib/utils'

export type PickupHandoffStatus = 'preparing' | 'ready' | 'collected'

export interface PickupHandoffProps extends Omit<ViewProps, 'children'> {
  className?: string
  storeName: string
  address?: string
  /** A localized pickup window from the order. */
  window?: string
  instructions?: string
  status?: PickupHandoffStatus
  /** Visible and selectable only while the order is ready. */
  collectionCode?: string
  /** Optional scannable pass. It is never mounted before the order is ready or after collection. */
  verification?: ReactElement
  action?: ReactElement
  labels?: Partial<Record<PickupHandoffStatus | 'code' | 'window', string>>
}

export function PickupHandoff({
  className,
  storeName,
  address,
  window,
  instructions,
  status = 'preparing',
  collectionCode,
  verification,
  action,
  labels,
  ...props
}: PickupHandoffProps) {
  const ready = status === 'ready'
  const collected = status === 'collected'
  const statusLabel = ready
    ? (labels?.ready ?? 'Ready for pickup')
    : collected
      ? (labels?.collected ?? 'Collected')
      : (labels?.preparing ?? 'Preparing your order')
  useAnnouncement(`${storeName}. ${statusLabel}`)

  return (
    <View {...props} className={cn('gap-[16px] rounded-lg border border-border bg-card p-[16px]', className)}>
      <View className="items-start">
        <Badge variant={ready ? 'success' : 'secondary'}>{statusLabel}</Badge>
      </View>
      <View className="gap-[4px]">
        <Text size="lg" accessibilityRole="header" className="font-semibold text-card-foreground">
          {storeName}
        </Text>
        {address ? <Text variant="muted">{address}</Text> : null}
      </View>
      {window ? (
        <View className="gap-[4px]">
          <Text size="sm" variant="muted">
            {labels?.window ?? 'Pickup window'}
          </Text>
          <Text className="font-semibold text-card-foreground">{window}</Text>
        </View>
      ) : null}
      {instructions ? <Text className="text-card-foreground">{instructions}</Text> : null}
      {ready && (collectionCode || verification) ? (
        <View className="items-center gap-[8px] border-t border-border pt-[16px]">
          {verification}
          {collectionCode ? (
            <>
              <Text size="sm" variant="muted">
                {labels?.code ?? 'Pickup code'}
              </Text>
              <Text
                selectable
                size="title"
                className="text-center text-card-foreground"
                style={{ fontVariant: ['tabular-nums'] }}
              >
                {collectionCode}
              </Text>
            </>
          ) : null}
        </View>
      ) : null}
      {action}
    </View>
  )
}
components/blocks/pickup-handoff/index.ts
export { PickupHandoff, type PickupHandoffProps, type PickupHandoffStatus } from './PickupHandoff'

Dependencies

Browse shopping and reservations