Skip to content

Commit babc5ca

Browse files
committed
Format
1 parent 8b2f71a commit babc5ca

File tree

12 files changed

+529
-413
lines changed

12 files changed

+529
-413
lines changed

src/components/Dashboard/Tiles/Widgets/Inputs/AppSelector.tsx

+11-10
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,37 @@
11
import { Group, Select, Text } from '@mantine/core';
2+
import { ComponentProps, forwardRef } from 'react';
3+
import { AppAvatar } from '~/components/AppAvatar';
24
import { useConfigContext } from '~/config/provider';
35
import { IntegrationType } from '~/types/app';
4-
import { AppAvatar } from '~/components/AppAvatar';
5-
import { ComponentProps, forwardRef } from 'react';
66

77
export type AppSelectorProps = {
88
value: string;
99
onChange: (value: string) => void;
1010
integrations: IntegrationType[];
1111
selectProps?: Omit<ComponentProps<typeof Select>, 'value' | 'data' | 'onChange'>;
12-
}
12+
};
1313

1414
export function AppSelector(props: AppSelectorProps) {
1515
const { value, integrations, onChange } = props;
1616
const { config } = useConfigContext();
1717

18-
const apps = config?.apps.filter((app) => app.integration.type && integrations.includes(app.integration.type)) ?? [];
19-
const selectedApp = apps.find(app => app.id === value);
18+
const apps =
19+
config?.apps.filter(
20+
(app) => app.integration.type && integrations.includes(app.integration.type)
21+
) ?? [];
22+
const selectedApp = apps.find((app) => app.id === value);
2023

2124
return (
2225
<Select
2326
value={value}
24-
data={apps.map(app => ({
27+
data={apps.map((app) => ({
2528
value: app.id,
2629
label: app.name,
2730
}))}
2831
onChange={onChange}
2932
icon={selectedApp ? <AppAvatar iconUrl={selectedApp?.appearance.iconUrl} /> : undefined}
3033
itemComponent={forwardRef(({ value, label, ...rest }, ref) => {
31-
const app = apps.find(app => app.id === value);
34+
const app = apps.find((app) => app.id === value);
3235

3336
if (!app) {
3437
return null;
@@ -37,9 +40,7 @@ export function AppSelector(props: AppSelectorProps) {
3740
return (
3841
<Group ref={ref} {...rest}>
3942
<AppAvatar iconUrl={app.appearance.iconUrl} />
40-
<Text size="xs">
41-
{label}
42-
</Text>
43+
<Text size="xs">{label}</Text>
4344
</Group>
4445
);
4546
})}

src/components/Dashboard/Tiles/Widgets/WidgetsEditModal.tsx

+20-20
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import { ContextModalProps } from '@mantine/modals';
1818
import { IconAlertTriangle, IconPlaylistX, IconPlus } from '@tabler/icons-react';
1919
import { Trans, useTranslation } from 'next-i18next';
2020
import { FC, useState } from 'react';
21+
import { AppSelector } from '~/components/Dashboard/Tiles/Widgets/Inputs/AppSelector';
2122
import { useConfigContext } from '~/config/provider';
2223
import { useConfigStore } from '~/config/store';
2324
import { mapObject } from '~/tools/client/objects';
@@ -29,7 +30,6 @@ import { InfoCard } from '../../../InfoCard/InfoCard';
2930
import { DraggableList } from './Inputs/DraggableList';
3031
import { LocationSelection } from './Inputs/LocationSelection';
3132
import { StaticDraggableList } from './Inputs/StaticDraggableList';
32-
import { AppSelector } from '~/components/Dashboard/Tiles/Widgets/Inputs/AppSelector';
3333

3434
export type WidgetEditModalInnerProps = {
3535
widgetId: string;
@@ -41,10 +41,10 @@ export type WidgetEditModalInnerProps = {
4141
export type IntegrationOptionsValueType = IWidget<string, any>['properties'][string];
4242

4343
export const WidgetsEditModal = ({
44-
context,
45-
id,
46-
innerProps,
47-
}: ContextModalProps<WidgetEditModalInnerProps>) => {
44+
context,
45+
id,
46+
innerProps,
47+
}: ContextModalProps<WidgetEditModalInnerProps>) => {
4848
const { t } = useTranslation([`modules/${innerProps.widgetType}`, 'common']);
4949
const [moduleProperties, setModuleProperties] = useState(innerProps.options);
5050
const items = Object.entries(innerProps.widgetOptions ?? {}) as [
@@ -79,7 +79,7 @@ export const WidgetsEditModal = ({
7979
widgets: [...prev.widgets.filter((x) => x.id !== innerProps.widgetId), currentWidget!],
8080
};
8181
},
82-
true,
82+
true
8383
);
8484
context.closeModal(id);
8585
};
@@ -194,9 +194,9 @@ const WidgetOptionTypeSwitch: FC<{
194194
const data = items.map((dataType) => {
195195
return !dataType.label
196196
? {
197-
value: dataType.value,
198-
label: t(`descriptor.settings.${key}.data.${dataType.value}`),
199-
}
197+
value: dataType.value,
198+
label: t(`descriptor.settings.${key}.data.${dataType.value}`),
199+
}
200200
: dataType;
201201
});
202202
return (
@@ -279,14 +279,14 @@ const WidgetOptionTypeSwitch: FC<{
279279
typedVal.map((oldVal) =>
280280
oldVal.key === liName
281281
? {
282-
...oldVal,
283-
subValues: {
284-
...oldVal.subValues,
285-
[settingName]: newVal,
286-
},
287-
}
288-
: oldVal,
289-
),
282+
...oldVal,
283+
subValues: {
284+
...oldVal.subValues,
285+
[settingName]: newVal,
286+
},
287+
}
288+
: oldVal
289+
)
290290
);
291291

292292
return (
@@ -299,7 +299,7 @@ const WidgetOptionTypeSwitch: FC<{
299299
value={typedVal}
300300
onChange={(v) => handleChange(key, v)}
301301
labels={mapObject(option.items, (liName) =>
302-
t(`descriptor.settings.${key}.${liName}.label`),
302+
t(`descriptor.settings.${key}.${liName}.label`)
303303
)}
304304
>
305305
{mapObject(option.items, (liName, liSettings) =>
@@ -312,7 +312,7 @@ const WidgetOptionTypeSwitch: FC<{
312312
value={extractSubValue(liName, settingName)}
313313
handleChange={handleSubChange(liName, settingName)}
314314
/>
315-
)),
315+
))
316316
)}
317317
</StaticDraggableList>
318318
</Stack>
@@ -337,7 +337,7 @@ const WidgetOptionTypeSwitch: FC<{
337337
onChange={(values) =>
338338
handleChange(
339339
key,
340-
values.map((item: string) => item),
340+
values.map((item: string) => item)
341341
)
342342
}
343343
/>

src/server/api/root.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ export const rootRouter = createTRPCRouter({
4848
password: passwordRouter,
4949
notebook: notebookRouter,
5050
smartHomeEntityState: smartHomeEntityStateRouter,
51-
tdarr: tdarrRouter
51+
tdarr: tdarrRouter,
5252
});
5353

5454
// export type definition of API

0 commit comments

Comments
 (0)