Skip to content

Commit

Permalink
fix: maintenance banner should show right away when toggled (#5021)
Browse files Browse the repository at this point in the history
Makes the maintenance banner show right away when toggled. Includes some
misc cleaning up.

Co-authored-by: Nicolae <[email protected]>
  • Loading branch information
nunogois and Nicolae authored Oct 13, 2023
1 parent 75fb7a0 commit e663dc0
Showing 1 changed file with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import React from 'react';
import {
Box,
FormControlLabel,
Expand All @@ -10,6 +9,7 @@ import { useMaintenance } from 'hooks/api/getters/useMaintenance/useMaintenance'
import { useMaintenanceApi } from 'hooks/api/actions/useMaintenanceApi/useMaintenanceApi';
import { usePlausibleTracker } from 'hooks/usePlausibleTracker';
import useToast from 'hooks/useToast';
import useUiConfig from 'hooks/api/getters/useUiConfig/useUiConfig';

const StyledContainer = styled('div')(({ theme }) => ({
display: 'flex',
Expand All @@ -19,12 +19,12 @@ const StyledContainer = styled('div')(({ theme }) => ({
borderRadius: theme.shape.borderRadiusLarge,
}));

const CardTitleRow = styled(Box)(({ theme }) => ({
const CardTitleRow = styled(Box)({
display: 'flex',
flexDirection: 'row',
justifyContent: 'space-between',
alignItems: 'center',
}));
});

const CardDescription = styled(Box)(({ theme }) => ({
color: theme.palette.text.secondary,
Expand All @@ -38,6 +38,7 @@ const SwitchLabel = styled(Typography)(({ theme }) => ({

export const MaintenanceToggle = () => {
const { enabled, refetchMaintenance } = useMaintenance();
const { refetch: refetchUiConfig } = useUiConfig();
const { toggleMaintenance } = useMaintenanceApi();
const { trackEvent } = usePlausibleTracker();
const { setToastData } = useToast();
Expand All @@ -55,6 +56,7 @@ export const MaintenanceToggle = () => {
});
await toggleMaintenance({ enabled: !enabled });
refetchMaintenance();
refetchUiConfig();
};

return (
Expand Down

1 comment on commit e663dc0

@vercel
Copy link

@vercel vercel bot commented on e663dc0 Oct 13, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.