import { Text } from '@wix/design-system';
import React from 'react';
import { useWixPatternsContainer } from '@wix/bex-core/react';
import { MessageActionModal } from '../ActionModal';
import { observer } from 'mobx-react-lite';
import { DeleteFieldModalState } from '@wix/bex-core';
import { Trans } from '../Trans';

export const _DeleteFieldModal = ({
  state,
}: {
  state: DeleteFieldModalState;
}) => {
  const container = useWixPatternsContainer();
  const { translate: t } = container;
  const { dataExtension, modal } = state;

  return (
    <MessageActionModal
      dataHook="archived-items-delete-confirm-modal"
      state={modal}
      skin="destructive"
      title={t('cairo.customFields.delete.modal.title', {
        selectedField:
          dataExtension.extractFieldValuesFromSchema(modal.value?.id || '')
            ?.name || '',
      })}
      content={
        <Text>
          <Trans
            i18nKey="cairo.customFields.delete.modal.description"
            values={{
              selectedField:
                dataExtension.extractFieldValuesFromSchema(
                  modal.value?.id || '',
                )?.name || '',
            }}
            components={{
              bold: <Text weight="bold" />,
            }}
          />
        </Text>
      }
      primaryButtonText={t('cairo.customFields.delete.modal.delete.CTA')}
      secondaryButtonText={t('cairo.customFields.delete.modal.cancel.CTA')}
    />
  );
};

export const DeleteFieldModal = observer(_DeleteFieldModal);
