import React from 'react' import { Box, Text } from 'ink' import { Surface } from '../../../ui/Surface.js' import { Select } from '../../../ui/Select.js' import { theme } from '../../../ui/theme.js' import { PinataJwtInput } from '../shared/components/PinataJwtInput.js' import type { Step } from '../reducer.js' type StorageCredentialAction = 'edit' | 'forget' | 'back' type StorageCredentialScreenProps = { step: Extract hasCredential: boolean footer: React.ReactNode onEdit: () => void onForget: () => void onConfirmForget: () => void onSubmit: (input: string) => void onCancel: () => void } export const StorageCredentialScreen: React.FC = ({ step, hasCredential, footer, onEdit, onForget, onConfirmForget, onSubmit, onCancel, }) => { if (step.kind === 'storage-credential-input') { return ( ) } if (step.kind === 'storage-credential-forget-confirm') { return ( Removes the saved pinning token from this machine. Existing IPFS backups and agent data are not affected. options={[ { value: 'forget', label: 'Forget Credential' }, { value: 'back', label: 'Keep Credential', role: 'utility' }, ]} hintLayout="inline" onSubmit={choice => choice === 'forget' ? onConfirmForget() : onCancel()} onCancel={onCancel} /> ) } return ( options={[ { value: 'edit', label: hasCredential ? 'Replace Credential' : 'Save Credential' }, { value: 'forget', label: 'Forget Credential', disabled: !hasCredential }, { value: 'back', label: 'Back', role: 'utility' }, ]} hintLayout="inline" onSubmit={choice => { if (choice === 'edit') return onEdit() if (choice === 'forget') return onForget() return onCancel() }} onCancel={onCancel} /> ) }