import React, { useState } from "react"; import { useTranslation } from "react-i18next"; import { Controller, useFormContext, useWatch } from "react-hook-form"; import { ActionGroup, Button, FormGroup, PageSection, Select, SelectOption, SelectVariant, Switch, } from "@patternfly/react-core"; import type RealmRepresentation from "keycloak-admin/lib/defs/realmRepresentation"; import { FormAccess } from "../components/form-access/FormAccess"; import { HelpItem } from "../components/help-enabler/HelpItem"; import { useServerInfo } from "../context/server-info/ServerInfoProvider"; type RealmSettingsThemesTabProps = { save: (realm: RealmRepresentation) => void; reset: () => void; realm: RealmRepresentation; }; export const RealmSettingsThemesTab = ({ save, reset, realm, }: RealmSettingsThemesTabProps) => { const { t } = useTranslation("realm-settings"); const [loginThemeOpen, setLoginThemeOpen] = useState(false); const [accountThemeOpen, setAccountThemeOpen] = useState(false); const [adminConsoleThemeOpen, setAdminConsoleThemeOpen] = useState(false); const [emailThemeOpen, setEmailThemeOpen] = useState(false); const [supportedLocalesOpen, setSupportedLocalesOpen] = useState(false); const [defaultLocaleOpen, setDefaultLocaleOpen] = useState(false); const { control, handleSubmit } = useFormContext(); const themeTypes = useServerInfo().themes!; const watchSupportedLocales = useWatch({ control, name: "supportedLocales", defaultValue: themeTypes?.account![0].locales, }); const internationalizationEnabled = useWatch({ control, name: "internationalizationEnabled", defaultValue: realm?.internationalizationEnabled, }); return ( <> } > ( )} /> } > ( )} /> } > ( )} /> } > ( )} /> ( )} /> {internationalizationEnabled && ( <> ( )} /> ( )} /> )} ); };