/* eslint-disable */ // @ts-nocheck import { NumberControl, SelectControl, SelectControlOption, } from "../../../shared/keycloak-ui-shared"; import { UseFormReturn, useWatch } from "react-hook-form"; import { useTranslation } from "react-i18next"; import { FormAccess } from "../../components/form/FormAccess"; import { WizardSectionHeader } from "../../components/wizard-section-header/WizardSectionHeader"; export type SettingsCacheProps = { form: UseFormReturn; showSectionHeading?: boolean; showSectionDescription?: boolean; unWrap?: boolean; }; const getValue = (value: string | string[] | undefined) => { if (Array.isArray(value)) { return value[0]; } return value; }; const CacheFields = ({ form }: { form: UseFormReturn }) => { const { t } = useTranslation(); const cachePolicyType = useWatch({ control: form.control, name: "config.cachePolicy", }); const cachePolicy = getValue(cachePolicyType); const hourOptions: SelectControlOption[] = []; let hourDisplay = ""; for (let index = 0; index < 24; index++) { if (index < 10) { hourDisplay = `0${index}`; } else { hourDisplay = `${index}`; } hourOptions.push({ key: `${index}`, value: hourDisplay }); } const minuteOptions: SelectControlOption[] = []; let minuteDisplay = ""; for (let index = 0; index < 60; index++) { if (index < 10) { minuteDisplay = `0${index}`; } else { minuteDisplay = `${index}`; } minuteOptions.push({ key: `${index}`, value: minuteDisplay }); } return ( <> {cachePolicy === "EVICT_WEEKLY" ? ( ) : null} {cachePolicy === "EVICT_DAILY" || cachePolicy === "EVICT_WEEKLY" ? ( <> ) : null} {cachePolicy === "MAX_LIFESPAN" ? ( ) : null} ); }; export const SettingsCache = ({ form, showSectionHeading = false, showSectionDescription = false, unWrap = false, }: SettingsCacheProps) => { const { t } = useTranslation(); return ( <> {showSectionHeading && ( )} {unWrap ? ( ) : ( )} ); };