Skip to content

Commit 4f8d0d9

Browse files
committed
ci: Format code
1 parent f82323a commit 4f8d0d9

File tree

10 files changed

+334
-228
lines changed

10 files changed

+334
-228
lines changed

src/lib/seam/thermostats/use-create-thermostat-climate-preset.ts

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,14 @@ import { NullSeamClientError, useSeamClient } from 'lib/seam/use-seam-client.js'
1414
export type UseCreateThermostatClimatePresetParams = never
1515
export type UseCreateThermostatClimatePresetData = undefined
1616

17-
export type UseCreateThermostatClimatePresetVariables = ThermostatsCreateClimatePresetBody
17+
export type UseCreateThermostatClimatePresetVariables =
18+
ThermostatsCreateClimatePresetBody
1819

19-
const fhToCelsius = (t?: number): number | undefined => t == null ? undefined : (t - 32) * (5 / 9)
20+
const fhToCelsius = (t?: number): number | undefined =>
21+
t == null ? undefined : (t - 32) * (5 / 9)
2022

21-
type ClimatePreset = ThermostatDevice['properties']['available_climate_presets'][number];
23+
type ClimatePreset =
24+
ThermostatDevice['properties']['available_climate_presets'][number]
2225

2326
export function useCreateThermostatClimatePreset(): UseMutationResult<
2427
UseCreateThermostatClimatePresetData,
@@ -40,19 +43,23 @@ export function useCreateThermostatClimatePreset(): UseMutationResult<
4043
onSuccess: (_data, variables) => {
4144
const preset: ClimatePreset = {
4245
...variables,
43-
cooling_set_point_celsius: fhToCelsius(variables.cooling_set_point_fahrenheit),
44-
heating_set_point_celsius: fhToCelsius(variables.heating_set_point_fahrenheit),
46+
cooling_set_point_celsius: fhToCelsius(
47+
variables.cooling_set_point_fahrenheit
48+
),
49+
heating_set_point_celsius: fhToCelsius(
50+
variables.heating_set_point_fahrenheit
51+
),
4552
display_name: variables.name ?? variables.climate_preset_key,
4653
can_delete: true,
4754
can_edit: true,
4855
manual_override_allowed: true,
49-
};
56+
}
5057

5158
queryClient.setQueryData<ThermostatDevice | null>(
5259
['devices', 'get', { device_id: variables.device_id }],
5360
(device) => {
5461
if (device == null) {
55-
return;
62+
return
5663
}
5764

5865
return getUpdatedDevice(device, preset)
@@ -79,10 +86,12 @@ export function useCreateThermostatClimatePreset(): UseMutationResult<
7986
})
8087
}
8188

82-
83-
function getUpdatedDevice(device: ThermostatDevice, preset: ClimatePreset): ThermostatDevice {
89+
function getUpdatedDevice(
90+
device: ThermostatDevice,
91+
preset: ClimatePreset
92+
): ThermostatDevice {
8493
if (device == null) {
85-
return device;
94+
return device
8695
}
8796

8897
return {

src/lib/seam/thermostats/use-delete-thermostat-climate-preset.ts

Lines changed: 38 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ export type UseDeleteThermostatClimatePresetParams = never
1515

1616
export type UseDeleteThermostatClimatePresetData = undefined
1717

18-
export type UseDeleteThermostatClimatePresetVariables = ThermostatsDeleteClimatePresetBody
18+
export type UseDeleteThermostatClimatePresetVariables =
19+
ThermostatsDeleteClimatePresetBody
1920

2021
export function useDeleteThermostatClimatePreset(): UseMutationResult<
2122
UseDeleteThermostatClimatePresetData,
@@ -35,44 +36,49 @@ export function useDeleteThermostatClimatePreset(): UseMutationResult<
3536
await client.thermostats.deleteClimatePreset(variables)
3637
},
3738
onSuccess: (_data, variables) => {
38-
queryClient.setQueryData<ThermostatDevice | null>(
39-
['devices', 'get', { device_id: variables.device_id }],
40-
(device) => {
41-
if (device == null) {
42-
return
43-
}
44-
39+
queryClient.setQueryData<ThermostatDevice | null>(
40+
['devices', 'get', { device_id: variables.device_id }],
41+
(device) => {
42+
if (device == null) {
43+
return
44+
}
45+
46+
return getUpdatedDevice(device, variables.climate_preset_key)
47+
}
48+
)
49+
50+
queryClient.setQueryData<ThermostatDevice[]>(
51+
['devices', 'list', { device_id: variables.device_id }],
52+
(devices): ThermostatDevice[] => {
53+
if (devices == null) {
54+
return []
55+
}
56+
57+
return devices.map((device) => {
58+
if (device.device_id === variables.device_id) {
4559
return getUpdatedDevice(device, variables.climate_preset_key)
4660
}
47-
)
48-
49-
queryClient.setQueryData<ThermostatDevice[]>(
50-
['devices', 'list', { device_id: variables.device_id }],
51-
(devices): ThermostatDevice[] => {
52-
if (devices == null) {
53-
return []
54-
}
55-
56-
return devices.map((device) => {
57-
if (device.device_id === variables.device_id) {
58-
return getUpdatedDevice(device, variables.climate_preset_key)
59-
}
60-
61-
return device
62-
})
63-
}
64-
)
65-
},
61+
62+
return device
63+
})
64+
}
65+
)
66+
},
6667
})
6768
}
6869

69-
70-
function getUpdatedDevice(device: ThermostatDevice, climatePresetKey: string): ThermostatDevice {
70+
function getUpdatedDevice(
71+
device: ThermostatDevice,
72+
climatePresetKey: string
73+
): ThermostatDevice {
7174
return {
7275
...device,
7376
properties: {
7477
...device.properties,
75-
available_climate_presets: device.properties.available_climate_presets.filter(preset => preset.climate_preset_key !== climatePresetKey),
76-
}
78+
available_climate_presets:
79+
device.properties.available_climate_presets.filter(
80+
(preset) => preset.climate_preset_key !== climatePresetKey
81+
),
82+
},
7783
}
78-
}
84+
}

src/lib/seam/thermostats/use-update-thermostat-climate-preset.ts

Lines changed: 28 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,20 @@ import { NullSeamClientError, useSeamClient } from 'lib/seam/use-seam-client.js'
1414
export type UseUpdateThermostatClimatePresetParams = never
1515
export type UseUpdateThermostatClimatePresetData = undefined
1616

17-
export type UseUpdateThermostatClimatePresetVariables = ThermostatsUpdateClimatePresetBody
17+
export type UseUpdateThermostatClimatePresetVariables =
18+
ThermostatsUpdateClimatePresetBody
1819

19-
const fhToCelsius = (t?: number): number | undefined => t == null ? undefined : (t - 32) * (5 / 9)
20+
const fhToCelsius = (t?: number): number | undefined =>
21+
t == null ? undefined : (t - 32) * (5 / 9)
2022

21-
type ClimatePreset = ThermostatDevice['properties']['available_climate_presets'][number];
23+
type ClimatePreset =
24+
ThermostatDevice['properties']['available_climate_presets'][number]
2225

23-
export function useUpdateThermostatClimatePreset({ originalKey }: { originalKey: ClimatePreset['climate_preset_key'] }): UseMutationResult<
26+
export function useUpdateThermostatClimatePreset({
27+
originalKey,
28+
}: {
29+
originalKey: ClimatePreset['climate_preset_key']
30+
}): UseMutationResult<
2431
UseUpdateThermostatClimatePresetData,
2532
SeamHttpApiError,
2633
UseUpdateThermostatClimatePresetVariables
@@ -40,19 +47,23 @@ export function useUpdateThermostatClimatePreset({ originalKey }: { originalKey:
4047
onSuccess: (_data, variables) => {
4148
const preset: ClimatePreset = {
4249
...variables,
43-
cooling_set_point_celsius: fhToCelsius(variables.cooling_set_point_fahrenheit),
44-
heating_set_point_celsius: fhToCelsius(variables.heating_set_point_fahrenheit),
50+
cooling_set_point_celsius: fhToCelsius(
51+
variables.cooling_set_point_fahrenheit
52+
),
53+
heating_set_point_celsius: fhToCelsius(
54+
variables.heating_set_point_fahrenheit
55+
),
4556
display_name: variables.name ?? variables.climate_preset_key,
4657
can_delete: true,
4758
can_edit: true,
4859
manual_override_allowed: true,
49-
};
60+
}
5061

5162
queryClient.setQueryData<ThermostatDevice | null>(
5263
['devices', 'get', { device_id: variables.device_id }],
5364
(device) => {
5465
if (device == null) {
55-
return;
66+
return
5667
}
5768

5869
return getUpdatedDevice(device, originalKey, preset)
@@ -79,10 +90,13 @@ export function useUpdateThermostatClimatePreset({ originalKey }: { originalKey:
7990
})
8091
}
8192

82-
83-
function getUpdatedDevice(device: ThermostatDevice, originalKey: ClimatePreset['climate_preset_key'], preset: ClimatePreset): ThermostatDevice {
93+
function getUpdatedDevice(
94+
device: ThermostatDevice,
95+
originalKey: ClimatePreset['climate_preset_key'],
96+
preset: ClimatePreset
97+
): ThermostatDevice {
8498
if (device == null) {
85-
return device;
99+
return device
86100
}
87101

88102
return {
@@ -91,8 +105,9 @@ function getUpdatedDevice(device: ThermostatDevice, originalKey: ClimatePreset['
91105
...device.properties,
92106
available_climate_presets: [
93107
preset,
94-
...(device.properties.available_climate_presets ?? [])
95-
.filter(preset => preset.climate_preset_key !== originalKey),
108+
...(device.properties.available_climate_presets ?? []).filter(
109+
(preset) => preset.climate_preset_key !== originalKey
110+
),
96111
],
97112
},
98113
}

src/lib/ui/IconButton.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,13 @@ import type { ButtonProps } from 'lib/ui/types.js'
44

55
export function IconButton({ className, ...props }: ButtonProps): JSX.Element {
66
return (
7-
<button {...props} className={classNames('seam-icon-btn', props.disabled === true && "seam-icon-btn-disabled", className)} />
7+
<button
8+
{...props}
9+
className={classNames(
10+
'seam-icon-btn',
11+
props.disabled === true && 'seam-icon-btn-disabled',
12+
className
13+
)}
14+
/>
815
)
916
}

src/lib/ui/thermostat/ClimateModeMenu.tsx

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ interface ClimateModeMenuProps {
1616
buttonTextVisible?: boolean
1717
className?: string
1818
style?: React.CSSProperties
19-
block?: boolean,
20-
size?: 'regular' | 'large',
19+
block?: boolean
20+
size?: 'regular' | 'large'
2121
}
2222

2323
export function ClimateModeMenu({
@@ -33,16 +33,28 @@ export function ClimateModeMenu({
3333
return (
3434
<Menu
3535
renderButton={({ onOpen }) => (
36-
<button style={style} onClick={onOpen} className={classNames('seam-climate-mode-menu-button', {
37-
'seam-climate-mode-menu-button-block': block,
38-
'seam-climate-mode-menu-button-regular': size === 'regular',
39-
'seam-climate-mode-menu-button-large': size === 'large',
40-
}, className)}>
36+
<button
37+
style={style}
38+
onClick={onOpen}
39+
className={classNames(
40+
'seam-climate-mode-menu-button',
41+
{
42+
'seam-climate-mode-menu-button-block': block,
43+
'seam-climate-mode-menu-button-regular': size === 'regular',
44+
'seam-climate-mode-menu-button-large': size === 'large',
45+
},
46+
className
47+
)}
48+
>
4149
<div className='seam-climate-mode-menu-button-icon'>
4250
<ModeIcon mode={mode} />
4351
</div>
4452

45-
{buttonTextVisible && <span className='seam-climate-mode-menu-button-text'>{t[mode]}</span>}
53+
{buttonTextVisible && (
54+
<span className='seam-climate-mode-menu-button-text'>
55+
{t[mode]}
56+
</span>
57+
)}
4658

4759
<ChevronDownIcon className='seam-climate-mode-menu-button-chevron' />
4860
</button>

0 commit comments

Comments
 (0)