import { CellIdentifier } from '$app/stores/effects/database/cell/cell_bd_svc'; import { useCell } from '$app/components/_shared/database-hooks/useCell'; import { CellCache } from '$app/stores/effects/database/cell/cell_cache'; import { FieldController } from '$app/stores/effects/database/field/field_controller'; import { DateCellDataPB, FieldType, SelectOptionCellDataPB } from '@/services/backend'; import { TextTypeSvg } from '$app/components/_shared/svg/TextTypeSvg'; import { NumberTypeSvg } from '$app/components/_shared/svg/NumberTypeSvg'; import { DateTypeSvg } from '$app/components/_shared/svg/DateTypeSvg'; import { SingleSelectTypeSvg } from '$app/components/_shared/svg/SingleSelectTypeSvg'; import { MultiSelectTypeSvg } from '$app/components/_shared/svg/MultiSelectTypeSvg'; import { ChecklistTypeSvg } from '$app/components/_shared/svg/ChecklistTypeSvg'; import { UrlTypeSvg } from '$app/components/_shared/svg/UrlTypeSvg'; import { useAppSelector } from '$app/stores/store'; import { getBgColor } from '$app/components/_shared/getColor'; import { CheckboxSvg } from '$app/components/_shared/svg/CheckboxSvg'; import { EditorCheckSvg } from '$app/components/_shared/svg/EditorCheckSvg'; import { EditorUncheckSvg } from '$app/components/_shared/svg/EditorUncheckSvg'; import { useState } from 'react'; import { EditCellText } from '$app/components/board/EditBoardRow/EditCellText'; export const EditCellWrapper = ({ cellIdentifier, cellCache, fieldController, }: { cellIdentifier: CellIdentifier; cellCache: CellCache; fieldController: FieldController; }) => { const { data, cellController } = useCell(cellIdentifier, cellCache, fieldController); const databaseStore = useAppSelector((state) => state.database); const [showEditField, setShowEditField] = useState(false); const onEditFieldClick = () => { setShowEditField(true); }; return (
onEditFieldClick()} className={'flex w-[180px] cursor-pointer items-center gap-2 rounded-lg px-4 py-2 hover:bg-shade-6'} >
{cellIdentifier.fieldType === FieldType.RichText && } {cellIdentifier.fieldType === FieldType.Number && } {cellIdentifier.fieldType === FieldType.DateTime && } {cellIdentifier.fieldType === FieldType.SingleSelect && } {cellIdentifier.fieldType === FieldType.MultiSelect && } {cellIdentifier.fieldType === FieldType.Checklist && } {cellIdentifier.fieldType === FieldType.URL && } {cellIdentifier.fieldType === FieldType.Checkbox && }
{databaseStore.fields[cellIdentifier.fieldId].title}
{(cellIdentifier.fieldType === FieldType.SingleSelect || cellIdentifier.fieldType === FieldType.MultiSelect || cellIdentifier.fieldType === FieldType.Checklist) && (
{(data as SelectOptionCellDataPB | undefined)?.select_options?.map((option, index) => (
{option?.name || ''}
)) || ''}
)} {cellIdentifier.fieldType === FieldType.Checkbox && (
{(data as boolean | undefined) ? : }
)} {cellIdentifier.fieldType === FieldType.DateTime &&
{(data as DateCellDataPB | undefined)?.date}
} {(cellIdentifier.fieldType === FieldType.RichText || cellIdentifier.fieldType === FieldType.URL || cellIdentifier.fieldType === FieldType.Number) && cellController && }
); };