Skip to content
This repository was archived by the owner on Aug 2, 2025. It is now read-only.

Commit 15ff2f6

Browse files
committed
fix: fix settings page
1 parent 8c4cec7 commit 15ff2f6

File tree

2 files changed

+40
-23
lines changed

2 files changed

+40
-23
lines changed

src/routes/Main/Settings/General.tsx

Lines changed: 29 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import {
1717
Button,
1818
} from "@chakra-ui/react";
1919
import { Check } from "phosphor-react";
20+
import { useState } from "react";
2021
import { useSettingsStore } from "../../../stores/settings";
2122

2223
const PrimaryColour = (props: UseRadioProps) => {
@@ -69,7 +70,10 @@ const ColourPicker = ({
6970
onChange: (nextValue: string) => void;
7071
}) => {
7172
const { getRootProps, getRadioProps } = useRadioGroup({
72-
onChange,
73+
onChange: (value) => {
74+
onChange(value);
75+
console.log(value);
76+
},
7377
value,
7478
});
7579

@@ -93,16 +97,16 @@ export default () => {
9397
expanded,
9498
hoverExpand,
9599
showTimesInsteadOfRooms,
96-
actions: {
97-
setPrimary,
98-
setExpanded,
99-
setPeriodColours,
100-
setHoverExpand,
101-
setShowTimesInsteadOfRooms,
102-
reset,
103-
},
100+
setPrimary,
101+
setExpanded,
102+
setPeriodColours,
103+
setHoverExpand,
104+
setShowTimesInsteadOfRooms,
105+
reset,
104106
} = useSettingsStore();
105107

108+
const [deleting, setDeleting] = useState(false);
109+
106110
return (
107111
<>
108112
<Heading size={"md"} fontFamily={"Poppins, sans-serif"}>
@@ -162,7 +166,22 @@ export default () => {
162166
Recovery
163167
</Heading>
164168
<FormControl display="flex">
165-
<Button onClick={reset}>Reset all settings</Button>
169+
<Button
170+
colorScheme={deleting ? "red" : undefined}
171+
variant={deleting ? "outline" : undefined}
172+
onClick={() => {
173+
if (!deleting) {
174+
setDeleting(true);
175+
navigator.vibrate(20);
176+
} else {
177+
reset();
178+
setDeleting(false);
179+
navigator.vibrate(100);
180+
}
181+
}}
182+
>
183+
{deleting ? "Are you sure?" : "Reset all settings"}
184+
</Button>
166185
</FormControl>
167186
</>
168187
);

src/stores/settings/settings.ts

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,34 +17,32 @@ export type SettingsState = {
1717
periodColours: "default" | "primary" | "none";
1818
hoverExpand: boolean;
1919
showTimesInsteadOfRooms: boolean;
20-
actions: Actions;
2120
};
2221

23-
export const initialState: Omit<SettingsState, "actions"> = {
22+
export const initialState: SettingsState = {
2423
primary: "blue",
2524
expanded: false,
2625
periodColours: "default",
2726
hoverExpand: false,
2827
showTimesInsteadOfRooms: false,
2928
};
3029

31-
export const useSettingsStore = create<SettingsState>()(
30+
export const useSettingsStore = create<SettingsState & Actions>()(
3231
devtools(
3332
persist(
34-
(set): SettingsState => ({
33+
(set): SettingsState & Actions => ({
3534
...initialState,
36-
actions: {
37-
setPrimary: (primary) => set({ primary }),
38-
setExpanded: (expanded) => set({ expanded }),
39-
setPeriodColours: (periodColours) => set({ periodColours }),
40-
setHoverExpand: (hoverExpand) => set({ hoverExpand }),
41-
setShowTimesInsteadOfRooms: (showTimesInsteadOfRooms) =>
42-
set({ showTimesInsteadOfRooms }),
43-
reset: () => set(initialState),
44-
},
35+
setPrimary: (primary) => set({ primary }),
36+
setExpanded: (expanded) => set({ expanded }),
37+
setPeriodColours: (periodColours) => set({ periodColours }),
38+
setHoverExpand: (hoverExpand) => set({ hoverExpand }),
39+
setShowTimesInsteadOfRooms: (showTimesInsteadOfRooms) =>
40+
set({ showTimesInsteadOfRooms }),
41+
reset: () => set(initialState),
4542
}),
4643
{
4744
name: "settings-storage",
45+
version: 1,
4846
}
4947
)
5048
)

0 commit comments

Comments
 (0)