Skip to content

Commit

Permalink
Merge pull request #5297 from signalco-io/next
Browse files Browse the repository at this point in the history
Next
  • Loading branch information
AleksandarDev authored May 29, 2024
2 parents a84520c + 90ed6bf commit 9d7a74a
Show file tree
Hide file tree
Showing 16 changed files with 37 additions and 43 deletions.
2 changes: 1 addition & 1 deletion web/apps/app/app/entities/[id]/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export default function EntityLayout({ children, params }: PropsWithChildren<{ p
{`${level}%`}
</Chip>
}
{(!disabledContact.isLoading && !disabledContact.isError) && (
{(!disabledContact.isLoading && !disabledContact.error) && (
<DisableButton disabled={isDisabled} onClick={handleDisableToggle} />
)}
<ShareEntityChip entity={entity} entityType={1} />
Expand Down
6 changes: 3 additions & 3 deletions web/apps/app/components/widgets/parts/WidgetState.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,9 @@ function WidgetState(props: WidgetSharedProps<ConfigProps>) {
continue;

const contactOnValueSerialized = config?.on?.find((e: IContact) =>
e.entityId === contact.data.entityId &&
e.channelName === contact.data.channelName &&
e.contactName === contact.data.contactName)?.valueSerialized;
e.entityId === contact.data?.entityId &&
e.channelName === contact.data?.channelName &&
e.contactName === contact.data?.contactName)?.valueSerialized;
if (contact.data.valueSerialized === contactOnValueSerialized) {
state = true;
break;
Expand Down
2 changes: 1 addition & 1 deletion web/apps/app/src/hooks/dashboards/useDeleteDashboard.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { UseMutationResult, useMutation, useQueryClient } from '@tanstack/react-query';
import { entityKey } from '../signalco/entity/useEntity';
import { entityKey } from '../signalco/entity/useEntities';
import { allEntitiesKey } from '../signalco/entity/useAllEntities';
import { deleteDashboardAsync } from '../../dashboards/DashboardsRepository';

Expand Down
2 changes: 1 addition & 1 deletion web/apps/app/src/hooks/dashboards/useSaveDashboard.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { UseMutationResult, useMutation, useQueryClient } from '@tanstack/react-query';
import { entityKey } from '../signalco/entity/useEntity';
import { entityKey } from '../signalco/entity/useEntities';
import { allEntitiesKey } from '../signalco/entity/useAllEntities';
import { IDashboardSetModel, saveDashboardAsync } from '../../dashboards/DashboardsRepository';

Expand Down
2 changes: 1 addition & 1 deletion web/apps/app/src/hooks/signalco/entity/useDeleteEntity.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { UseMutationResult, useMutation, useQueryClient } from '@tanstack/react-query';
import { entityDeleteAsync } from '../../../entity/EntityRepository';
import { entityKey } from './useEntity';
import { entityKey } from './useEntities';
import { allEntitiesKey } from './useAllEntities';

export default function useDeleteEntity(): UseMutationResult<void, Error, string, unknown> {
Expand Down
18 changes: 16 additions & 2 deletions web/apps/app/src/hooks/signalco/entity/useEntities.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,21 @@
import { useQueries, useQueryClient } from '@tanstack/react-query';
import { QueryClient, useQueries, useQueryClient } from '@tanstack/react-query';
import IEntityDetails from '../../../entity/IEntityDetails';
import { entityAsync } from '../../../entity/EntityRepository';
import { entityKey, findEntity } from './useEntity';
import { entityTypes } from '../../../entity/EntityHelper';
import { allEntitiesKey } from './useAllEntities';

export function entityKey(id: string | undefined) {
if (typeof id === 'undefined')
return ['entity'];
return ['entity', id];
}

export function findEntity(client: QueryClient, id: string | undefined) {
return entityTypes
.map(entityType => client.getQueryData<IEntityDetails[]>(allEntitiesKey(entityType.value))?.find(e => e.id === id))
.filter(Boolean)
.at(0);
}

export function useEntities(ids: (string | undefined)[] | undefined) {
const client = useQueryClient();
Expand Down
17 changes: 0 additions & 17 deletions web/apps/app/src/hooks/signalco/entity/useEntity.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,4 @@
import { QueryClient } from '@tanstack/react-query';
import IEntityDetails from '../../../entity/IEntityDetails';
import { entityTypes } from '../../../entity/EntityHelper';
import { useEntities } from './useEntities';
import { allEntitiesKey } from './useAllEntities';

export function entityKey(id: string | undefined) {
if (typeof id === 'undefined')
return ['entity'];
return ['entity', id];
}

export function findEntity(client: QueryClient, id: string | undefined) {
return entityTypes
.map(entityType => client.getQueryData<IEntityDetails[]>(allEntitiesKey(entityType.value))?.find(e => e.id === id))
.filter(Boolean)
.at(0);
}

export default function useEntity(id: string | undefined) {
const result = useEntities([id]);
Expand Down
2 changes: 1 addition & 1 deletion web/apps/app/src/hooks/signalco/entity/useUpsertEntity.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { UseMutationResult, useMutation, useQueryClient } from '@tanstack/react-query';
import { entityUpsertAsync } from '../../../entity/EntityRepository';
import { entityKey } from './useEntity';
import { entityKey } from './useEntities';
import { allEntitiesKey } from './useAllEntities';

type EntityUpsertArgs = { id: string | undefined, type: number, alias: string };
Expand Down
3 changes: 0 additions & 3 deletions web/apps/app/src/hooks/signalco/useContact.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
import { UseQueryResult, useQuery } from '@tanstack/react-query';
import type IContactPointer from '../../contacts/IContactPointer';
import IContact from '../../contacts/IContact';
import useContacts from './useContacts';
import useEntity from './entity/useEntity';

export function contactKey(pointer: Partial<IContactPointer> | null | undefined) {
if (!pointer)
Expand Down
2 changes: 1 addition & 1 deletion web/apps/app/src/hooks/signalco/useDeleteContact.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { UseMutationResult, useMutation, useQueryClient } from '@tanstack/react-
import IContactPointer from '../../contacts/IContactPointer';
import { deleteContactAsync } from '../../../src/contacts/ContactRepository';
import { contactKey } from './useContact';
import { entityKey } from './entity/useEntity';
import { entityKey } from './entity/useEntities';
import { allEntitiesKey } from './entity/useAllEntities';

export default function useDeleteContact(): UseMutationResult<void, Error, IContactPointer, unknown> {
Expand Down
2 changes: 1 addition & 1 deletion web/apps/app/src/hooks/signalco/useSetContact.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { UseMutationResult, useMutation, useQueryClient } from '@tanstack/react-
import type IContactPointer from '../../contacts/IContactPointer';
import { setAsync } from '../../../src/contacts/ContactRepository';
import { contactKey } from './useContact';
import { entityKey } from './entity/useEntity';
import { entityKey } from './entity/useEntities';
import { allEntitiesKey } from './entity/useAllEntities';

export default function useSetContact(): UseMutationResult<void, Error, {
Expand Down
2 changes: 1 addition & 1 deletion web/apps/app/src/hooks/signalco/useSetMetadataContact.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { UseMutationResult, useMutation, useQueryClient } from '@tanstack/react-
import type IContactPointer from '../../contacts/IContactPointer';
import { setMetadataAsync } from '../../contacts/ContactRepository';
import { contactKey } from './useContact';
import { entityKey } from './entity/useEntity';
import { entityKey } from './entity/useEntities';
import { allEntitiesKey } from './entity/useAllEntities';

export default function useSetMetadataContact(): UseMutationResult<void, Error, {
Expand Down
2 changes: 1 addition & 1 deletion web/apps/app/src/realtime/realtimeService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { showNotification } from '@signalco/ui-notifications';
import { HubConnection, HubConnectionBuilder, LogLevel } from '@microsoft/signalr';
import { getApiUrl, getTokenFactory } from '../services/HttpService';
import { contactKey } from '../hooks/signalco/useContact';
import { entityKey } from '../hooks/signalco/entity/useEntity';
import { entityKey } from '../hooks/signalco/entity/useEntities';

class SignalSignalRDeviceStateDto {
entityId?: string;
Expand Down
2 changes: 1 addition & 1 deletion web/apps/doprocess/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
"next": "14.2.3",
"next-secure-headers": "2.2.0",
"next-themes": "0.3.0",
"openai": "4.47.1",
"openai": "4.47.2",
"react": "18.3.1",
"react-cool-inview": "3.0.1",
"react-dom": "18.3.1",
Expand Down
2 changes: 1 addition & 1 deletion web/apps/workingparty/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
"next-secure-headers": "2.2.0",
"next-themes": "0.3.0",
"nanoid": "5.0.7",
"openai": "4.47.1",
"openai": "4.47.2",
"react": "18.3.1",
"react-dom": "18.3.1",
"react-email": "2.1.4",
Expand Down
14 changes: 7 additions & 7 deletions web/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 9d7a74a

Please sign in to comment.