move state to parent

This commit is contained in:
Alex Holliday committed 2025-06-17 10:58:41 +08:00
1 parent 7d333c6d93
commit 456798ca15
4 files changed
+57 -19

No files matched your search

@@ -17,13 +17,14 @@ const SettingsPagespeed = ({
settingsData,
setSettingsData,
isApiKeySet,
apiKeyHasBeenReset,
setApiKeyHasBeenReset,
}) => {
const { t } = useTranslation();
const theme = useTheme();
// Local state
const [apiKey, setApiKey] = useState("");
const [hasBeenReset, setHasBeenReset] = useState(false);
// Handler
const handleChange = (e) => {
@@ -50,7 +51,7 @@ const SettingsPagespeed = ({
<Typography sx={HEADING_SX}>{t("pageSpeedApiKeyFieldDescription")}</Typography>
</Box>
<Stack gap={theme.spacing(20)}>
{(isApiKeySet === false || hasBeenReset === true) && (
{(isApiKeySet === false || apiKeyHasBeenReset === true) && (
<TextInput
name="pagespeedApiKey"
label={t("pageSpeedApiKeyFieldLabel")}
@@ -62,7 +63,7 @@ const SettingsPagespeed = ({
/>
)}
{isApiKeySet === true && hasBeenReset === false && (
{isApiKeySet === true && apiKeyHasBeenReset === false && (
<Box>
<Typography>{t("pageSpeedApiKeyFieldResetLabel")}</Typography>
<Button
@@ -72,7 +73,7 @@ const SettingsPagespeed = ({
...settingsData,
settings: { ...settingsData.settings, pagespeedApiKey: "" },
});
setHasBeenReset(true);
setApiKeyHasBeenReset(true);
}}
variant="contained"
color="error"
@@ -93,6 +94,9 @@ SettingsPagespeed.propTypes = {
settingsData: PropTypes.object,
setSettingsData: PropTypes.func,
isApiKeySet: PropTypes.bool,
setIsApiKeySet: PropTypes.func,
apiKeyHasBeenReset: PropTypes.bool,
setApiKeyHasBeenReset: PropTypes.func,
};
export default SettingsPagespeed;