type TranslationFn = (key: string) => string;

export const getNonTextReadOnlySx = (
  isRequestingEditionApproval: boolean,
):
  | {
      opacity: number;
      filter: string;
    }
  | undefined =>
  isRequestingEditionApproval
    ? {
        opacity: 0.55,
        filter: 'grayscale(1)',
      }
    : undefined;

export const getEditionPublishText = ({
  t,
  isSubmitting,
  isEdit,
  isRequestingEditionApproval,
}: {
  t: TranslationFn;
  isSubmitting: boolean;
  isEdit: boolean;
  isRequestingEditionApproval: boolean;
}) => {
  if (isSubmitting) {
    if (isRequestingEditionApproval) {
      return t('post:sending_for_review');
    }
    return isEdit ? t('SAVING') : t('post:publishing');
  }
  if (isRequestingEditionApproval) {
    return t('post:send_for_review');
  }
  return isEdit ? t('general:save') : t('post:publish');
};
