Skip to content

armgit / orca

Public Imported from GitHub
0

Orca is the place for working with a fleet of agents (e.g. Grok Bot, Claude Code). Run any coding agent with your own subscription. Available on desktop, mobile and remote runtime.

888 B
Raw Blame
import { translate } from '../i18n/mobile-i18n'
import { parsePairingCode } from './pairing'
import type { PairingOffer } from './types'

export type PairConfirmRouteState =
  | { kind: 'ready'; offer: PairingOffer; errorMessage: '' }
  | { kind: 'error'; offer: null; errorMessage: string }

export function resolvePairConfirmRouteState(
  code: string | string[] | undefined
): PairConfirmRouteState {
  if (!code) {
    return {
      kind: 'error',
      offer: null,
      errorMessage: translate('connection.pairConfirmState.missingCode', 'Missing pairing code')
    }
  }

  const offer = typeof code === 'string' ? parsePairingCode(code) : null
  if (!offer) {
    return {
      kind: 'error',
      offer: null,
      errorMessage: translate('connection.pairConfirmState.invalidCode', 'Not a valid pairing code')
    }
  }

  return { kind: 'ready', offer, errorMessage: '' }
}