import { Box, Newline, Text } from 'ink'; import Link from 'ink-link'; import { UncontrolledTextInput } from 'ink-text-input'; import React from 'react'; import { useState } from 'react'; import { colors } from '../../../../config/colors.js'; import { Tenant } from '../../../../types.js'; import { Select } from '../../../components/Select.js'; import { useJourney } from '../context/provider.js'; export const SelectTenant: React.FC = () => { const { state, dispatch } = useJourney(); const [shouldAskForInput, askForInput] = useState(state.bootstrapTenant && !state.tenant); return ( <> {!shouldAskForInput && !state.tenant && ( <> Please select a Crystallize tenant Don't have a tenant yet? Create one at {/*@ts-ignore*/} https://crystallize.com/signup options={[ { label: 'Our demo tenant', value: { identifier: state.boilerplate?.blueprint!, boostrap: false, }, render: () => ( <> Our demo tenant ({state.boilerplate?.blueprint!}) Lots of demo data here already ), }, { label: 'My own existing tenant', value: { identifier: '', boostrap: false, }, render: () => ( <> My own existing tenant Of course your tenant content model (shapes, items) must fit the boilerplate. ), }, { label: 'Create a new tenant for me', value: { identifier: '', boostrap: true, }, render: () => ( <> Create a new tenant for me A tenant will be bootstrapped for you with boilerplate content. (same as `install -b`) ), }, ]} onSelect={( answer: Tenant & { boostrap: boolean; }, ) => { if (answer.identifier === '') { if (answer.boostrap === true) { dispatch.setBootstrapTenant(); } askForInput(true); } else { dispatch.setTenant(answer); } }} /> )} {shouldAskForInput && ( <> Enter a tenant identifier: { dispatch.setTenant({ identifier: tenant }); askForInput(false); }} /> {state.bootstrapTenant && ( <> If this tenant identifier is not available we'll pick a very close name for you. )} )} {state.tenant && ( Using the Tenant with identifier: {state.tenant.identifier}. )} ); };