Skip to content

Commit

Permalink
Use authentication for enabling/disabling overwatcher
Browse files Browse the repository at this point in the history
  • Loading branch information
albireox committed Oct 1, 2024
1 parent 11236f4 commit 53f12e2
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@

'use client';

import React from 'react';
import { IconRobot } from '@tabler/icons-react';
import { Box, Group, Pill, Switch } from '@mantine/core';
import fetchFromAPI from '@/src/actions/fetch-from-API';
import APIStatusText from '@/src/components/APITable/APIStatusText/APIStatusText';
import APITable from '@/src/components/APITable/APITable';
import { AuthContext } from '@/src/components/LVMWebRoot/LVMWebRoot';
import useAPICall from '@/src/hooks/use-api-call';
import { Box, Group, Pill, Switch } from '@mantine/core';
import { IconRobot } from '@tabler/icons-react';
import React from 'react';

type OverwatcherResponse = {
running: boolean;
Expand Down Expand Up @@ -87,7 +87,7 @@ function EnabledGroup(props: EnabledGroupProps & OverwatcherPillProps) {
const handleEnabledChange = React.useCallback(() => {
// Send API request to change value
const fullRoute = isOn ? `${route}/disable` : `${route}/enable`;
fetchFromAPI(fullRoute, { method: 'PUT' })
fetchFromAPI(fullRoute, { method: 'PUT' }, true)
.then(() => setOn((prev) => !prev))
.catch(() => {});
}, [isOn, route]);
Expand Down

0 comments on commit 53f12e2

Please sign in to comment.