Skip to content

Commit 427e13d

Browse files
committed
ci: Format code
1 parent 9fc083d commit 427e13d

File tree

8 files changed

+161
-106
lines changed

8 files changed

+161
-106
lines changed

src/lib/seam/components/DeviceDetails/ThermostatDeviceDetails.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,9 @@ function ClimatePresetRow({
340340
return (
341341
<DetailRow label={t.climatePresets}>
342342
<Button onClick={onClickManage}>
343-
{t.manageNPresets((device.properties.available_climate_presets ?? []).length)}
343+
{t.manageNPresets(
344+
(device.properties.available_climate_presets ?? []).length
345+
)}
344346
</Button>
345347
</DetailRow>
346348
)

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ function getUpdatedDevice(
100100
...device.properties,
101101
available_climate_presets: [
102102
preset,
103-
...(device.properties.available_climate_presets ?? [])
103+
...(device.properties.available_climate_presets ?? []),
104104
],
105105
},
106106
}

src/lib/ui/Button.tsx

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ export function Button({
2424
onMouseDown,
2525
type = 'button',
2626
loading = false,
27-
2827
}: ButtonProps): JSX.Element {
2928
return (
3029
<button
@@ -39,23 +38,21 @@ export function Button({
3938
disabled={disabled}
4039
onClick={(e) => {
4140
if (loading || disabled) {
42-
e.preventDefault();
43-
return;
41+
e.preventDefault()
42+
return
4443
}
4544

46-
onClick?.(e);
45+
onClick?.(e)
4746
}}
4847
onMouseDown={onMouseDown}
4948
type={type}
5049
>
5150
<span className='seam-btn-content'>{children}</span>
52-
{
53-
loading && (
54-
<div className='seam-btn-loading'>
55-
<Spinner size='small' />
56-
</div>
57-
)
58-
}
51+
{loading && (
52+
<div className='seam-btn-loading'>
53+
<Spinner size='small' />
54+
</div>
55+
)}
5956
</button>
6057
)
6158
}

src/lib/ui/thermostat/ClimatePreset.tsx

Lines changed: 49 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ export function ClimatePreset(props: ClimatePresetProps): JSX.Element {
4646
manual_override_allowed: true,
4747
name: '',
4848
}
49-
).current;
49+
).current
5050

5151
const {
5252
register,
@@ -93,27 +93,29 @@ export function ClimatePreset(props: ClimatePresetProps): JSX.Element {
9393
const otherPresets = useMemo(
9494
() =>
9595
allPresets.filter(
96-
(other) =>
97-
other.climate_preset_key !== preset.climate_preset_key
96+
(other) => other.climate_preset_key !== preset.climate_preset_key
9897
),
9998
[allPresets, preset]
10099
)
101100

102101
const isCreate = _preset == null
103-
const createMutation = useCreateThermostatClimatePreset();
104-
const updateMutation = useUpdateThermostatClimatePreset();
105-
const loading = isCreate ? createMutation.isPending : updateMutation.isPending;
102+
const createMutation = useCreateThermostatClimatePreset()
103+
const updateMutation = useUpdateThermostatClimatePreset()
104+
const loading = isCreate ? createMutation.isPending : updateMutation.isPending
106105

107106
const onSubmit = (): void => {
108-
if (isCreate && otherPresets.some((other) => other.climate_preset_key === state.key)) {
107+
if (
108+
isCreate &&
109+
otherPresets.some((other) => other.climate_preset_key === state.key)
110+
) {
109111
setError('key', {
110112
type: 'validate',
111113
message: 'Preset with this key already exists.',
112114
})
113115
return
114116
}
115117

116-
const name = state.name.replace(/\s+/g, ' ').trim();
118+
const name = state.name.replace(/\s+/g, ' ').trim()
117119

118120
const body = {
119121
climate_preset_key: state.key,
@@ -122,8 +124,14 @@ export function ClimatePreset(props: ClimatePresetProps): JSX.Element {
122124
cooling_set_point_fahrenheit: state.coolPoint,
123125
heating_set_point_fahrenheit: state.heatPoint,
124126
fan_mode_setting: state.fanMode,
125-
cooling_set_point_celsius: typeof state.coolPoint === 'number' ? toCelcius(state.coolPoint) : undefined,
126-
heating_set_point_celsius: typeof state.heatPoint === 'number' ? toCelcius(state.heatPoint) : undefined,
127+
cooling_set_point_celsius:
128+
typeof state.coolPoint === 'number'
129+
? toCelcius(state.coolPoint)
130+
: undefined,
131+
heating_set_point_celsius:
132+
typeof state.heatPoint === 'number'
133+
? toCelcius(state.heatPoint)
134+
: undefined,
127135
hvac_mode_setting: state.hvacMode,
128136
}
129137

@@ -142,49 +150,44 @@ export function ClimatePreset(props: ClimatePresetProps): JSX.Element {
142150
{...attrs}
143151
className={classNames('seam-thermostat-climate-preset', attrs.className)}
144152
>
145-
<ContentHeader
146-
title={preset.display_name}
147-
onBack={onBack}
148-
/>
153+
<ContentHeader title={preset.display_name} onBack={onBack} />
149154

150155
<div className='seam-main'>
151156
<form
152157
onSubmit={(e) => {
153158
void handleSubmit(onSubmit)(e)
154159
}}
155160
>
156-
{
157-
isCreate && (
158-
<FormField>
159-
<InputLabel>Key</InputLabel>
160-
<TextField
161-
size='large'
162-
clearable
163-
hasError={errors.key != null}
164-
helperText={errors.key?.message}
165-
inputProps={{
166-
...register('key', {
167-
required: 'required',
168-
maxLength: {
169-
value: 20,
170-
message: 'max 20 chars',
171-
},
172-
minLength: {
173-
value: 3,
174-
message: 'min 3 chars',
175-
},
176-
validate(value) {
177-
const fixedValue = value.replace(/\s+/g, '').trim()
178-
return !otherPresets.some(
179-
(other) => other.climate_preset_key === fixedValue
180-
)
181-
},
182-
}),
183-
}}
184-
/>
185-
</FormField>
186-
)
187-
}
161+
{isCreate && (
162+
<FormField>
163+
<InputLabel>Key</InputLabel>
164+
<TextField
165+
size='large'
166+
clearable
167+
hasError={errors.key != null}
168+
helperText={errors.key?.message}
169+
inputProps={{
170+
...register('key', {
171+
required: 'required',
172+
maxLength: {
173+
value: 20,
174+
message: 'max 20 chars',
175+
},
176+
minLength: {
177+
value: 3,
178+
message: 'min 3 chars',
179+
},
180+
validate(value) {
181+
const fixedValue = value.replace(/\s+/g, '').trim()
182+
return !otherPresets.some(
183+
(other) => other.climate_preset_key === fixedValue
184+
)
185+
},
186+
}),
187+
}}
188+
/>
189+
</FormField>
190+
)}
188191

189192
<FormField>
190193
<InputLabel>Display Name (Optional)</InputLabel>

src/lib/ui/thermostat/ClimatePresets.tsx

Lines changed: 51 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -29,20 +29,30 @@ type Preset =
2929
export function ClimatePresets(props: ClimatePresetsManagement): JSX.Element {
3030
const { device, onBack } = props
3131

32-
const [selectedClimatePreset, setSelectedClimatePreset] =
33-
useState<Preset | typeof CreateNewPresetSymbol | null>(null)
34-
35-
const [inDeletionPresetKey, setInDeletionPresetKey] = useState<Preset['climate_preset_key'] | null>(null);
36-
const deleteMutation = useDeleteThermostatClimatePreset();
37-
38-
if (selectedClimatePreset != null || selectedClimatePreset === CreateNewPresetSymbol) {
32+
const [selectedClimatePreset, setSelectedClimatePreset] = useState<
33+
Preset | typeof CreateNewPresetSymbol | null
34+
>(null)
35+
36+
const [inDeletionPresetKey, setInDeletionPresetKey] = useState<
37+
Preset['climate_preset_key'] | null
38+
>(null)
39+
const deleteMutation = useDeleteThermostatClimatePreset()
40+
41+
if (
42+
selectedClimatePreset != null ||
43+
selectedClimatePreset === CreateNewPresetSymbol
44+
) {
3945
return (
4046
<ClimatePreset
4147
onBack={() => {
4248
setSelectedClimatePreset(null)
4349
}}
4450
device={device}
45-
preset={selectedClimatePreset === CreateNewPresetSymbol ? undefined : selectedClimatePreset}
51+
preset={
52+
selectedClimatePreset === CreateNewPresetSymbol
53+
? undefined
54+
: selectedClimatePreset
55+
}
4656
/>
4757
)
4858
}
@@ -51,9 +61,12 @@ export function ClimatePresets(props: ClimatePresetsManagement): JSX.Element {
5161
<div className='seam-thermostat-climate-presets'>
5262
<ContentHeader title='Climate Presets' onBack={onBack} />
5363
<div className='seam-thermostat-climate-presets-body'>
54-
<Button onClick={() => {
55-
setSelectedClimatePreset(CreateNewPresetSymbol)
56-
}} className='seam-climate-presets-add-button'>
64+
<Button
65+
onClick={() => {
66+
setSelectedClimatePreset(CreateNewPresetSymbol)
67+
}}
68+
className='seam-climate-presets-add-button'
69+
>
5770
<AddIcon />
5871
Create New
5972
</Button>
@@ -74,8 +87,14 @@ export function ClimatePresets(props: ClimatePresetsManagement): JSX.Element {
7487
temperatureUnit={props.temperatureUnit}
7588
preset={preset}
7689
key={preset.climate_preset_key}
77-
deletionLoading={deleteMutation.isPending && inDeletionPresetKey === preset.climate_preset_key}
78-
disabled={deleteMutation.isPending && inDeletionPresetKey !== preset.climate_preset_key}
90+
deletionLoading={
91+
deleteMutation.isPending &&
92+
inDeletionPresetKey === preset.climate_preset_key
93+
}
94+
disabled={
95+
deleteMutation.isPending &&
96+
inDeletionPresetKey !== preset.climate_preset_key
97+
}
7998
/>
8099
))}
81100
</div>
@@ -94,8 +113,15 @@ function PresetCard(
94113
disabled?: boolean
95114
}
96115
): JSX.Element {
97-
const { preset, temperatureUnit, onClickEdit, onClickDelete, deletionLoading = false, disabled = false, ...attrs } =
98-
props
116+
const {
117+
preset,
118+
temperatureUnit,
119+
onClickEdit,
120+
onClickDelete,
121+
deletionLoading = false,
122+
disabled = false,
123+
...attrs
124+
} = props
99125

100126
const heatPoint =
101127
temperatureUnit === 'fahrenheit'
@@ -123,9 +149,7 @@ function PresetCard(
123149
].filter(Boolean) as Array<{ icon: ReactNode; value: string }>
124150
).map(({ icon, value }, index) => (
125151
<div key={index} className='seam-thermostat-climate-preset-chip'>
126-
<span className='seam-thermostat-climate-preset-chip-icon'>
127-
{icon}
128-
</span>
152+
<span className='seam-thermostat-climate-preset-chip-icon'>{icon}</span>
129153
<span className='seam-thermostat-climate-preset-chip-value'>{value}</span>
130154
</div>
131155
))
@@ -150,14 +174,18 @@ function PresetCard(
150174
</div>
151175

152176
<div className='seam-thermostat-climate-presets-card-buttons'>
153-
<IconButton disabled={disabled || deletionLoading || !preset.can_edit} onClick={onClickEdit}>
177+
<IconButton
178+
disabled={disabled || deletionLoading || !preset.can_edit}
179+
onClick={onClickEdit}
180+
>
154181
<EditIcon />
155182
</IconButton>
156183

157-
<IconButton disabled={disabled || !preset.can_delete} onClick={onClickDelete}>
158-
{
159-
deletionLoading ? <Spinner size='small' /> : <TrashIcon />
160-
}
184+
<IconButton
185+
disabled={disabled || !preset.can_delete}
186+
onClick={onClickDelete}
187+
>
188+
{deletionLoading ? <Spinner size='small' /> : <TrashIcon />}
161189
</IconButton>
162190
</div>
163191
</div>

src/styles/_buttons.scss

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,8 @@
173173
display: flex;
174174
justify-content: center;
175175
align-items: center;
176-
--spinner-color: currentColor;
176+
177+
--spinner-color: currentcolor;
177178
}
178179

179180
.seam-btn-content {
@@ -192,4 +193,4 @@
192193
@include button;
193194
@include icon-button;
194195
@include text-button;
195-
}
196+
}

src/styles/_spinner.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,4 @@
4141
border-width: 3px;
4242
}
4343
}
44-
}
44+
}

0 commit comments

Comments
 (0)