import { type PageContext, input, label, modal, stringSelect } from '@star-kitten/discord'; import type { LocationsState } from './state'; import { Page } from './router'; import { StructureType } from '@/lib/db/types/routes'; export default async function (ctx: PageContext) { const isAdd = ctx.custom_id === Page.addLocationModal; const location = ctx.state.data.selected; return modal(isAdd ? Page.addLocationModalSubmit : Page.editLocationModalSubmit, `${isAdd ? 'Add Location' : 'Edit: ' + ctx.state.data.selected?.short_name || ''}`, isAdd && label({ label: 'Location ID' }, input('loc-id', { placeholder: 'Enter the structure id', required: true }), ), label({ label: 'Location Name' }, input('loc-name', { placeholder: 'Enter the location name', required: true, value: location?.name }), ), label({ label: 'Location Short Name' }, input('loc-short-name', { placeholder: 'Enter the location short name', required: true, value: location?.short_name }), ), label({ label: 'System' }, input('loc-system', { placeholder: 'Enter the system (e.g. Jita)', required: true, value: location?.system }), ), label({ label: 'Structure Type' }, stringSelect('loc-structure-type', { placeholder: 'Select Structure Type', min_values: 1, max_values: 1, required: true }, ...Object.values(StructureType).map((type) => ({ label: type, value: type, default: location?.structure_type === type, })), ), ), ); }