-
Notifications
You must be signed in to change notification settings - Fork 199
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
21ffdd4
commit f6f5fea
Showing
16 changed files
with
153 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
...src/pages/Entity/components/Notes/hooks/queries/useNotesByNoteable/useNotesByNoteable.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { useIsAuthenticated } from '@/domains/auth/context/AuthProvider/hooks/useIsAuthenticated/useIsAuthenticated'; | ||
import { useQuery } from '@tanstack/react-query'; | ||
import { isString } from '@/common/utils/is-string/is-string'; | ||
import { notesQueryKey } from '@/pages/Entity/components/Notes/hooks/query-keys'; | ||
import { NoteableType } from '@/pages/Entity/components/Notes/types'; | ||
|
||
export const useNotesByNoteable = ({ | ||
noteableType, | ||
noteableId = '', | ||
}: { | ||
noteableType: NoteableType; | ||
noteableId?: string; | ||
}) => { | ||
const isAuthenticated = useIsAuthenticated(); | ||
|
||
return useQuery({ | ||
...notesQueryKey.byNoteable({ noteableType, noteableId }), | ||
enabled: isAuthenticated && isString(noteableId) && !!noteableId.length, | ||
staleTime: 100_000, | ||
refetchInterval: 1_000_000, | ||
}); | ||
}; |
17 changes: 17 additions & 0 deletions
17
apps/backoffice-v2/src/pages/Entity/components/Notes/hooks/query-keys.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { createQueryKeys } from '@lukemorales/query-key-factory'; | ||
|
||
import { NoteableType } from '@/pages/Entity/components/Notes/types'; | ||
import { getNotesByNotable } from '@/pages/Entity/components/Notes/hooks/fetchers'; | ||
|
||
export const notesQueryKey = createQueryKeys('notes', { | ||
byNoteable: ({ | ||
noteableType, | ||
noteableId, | ||
}: { | ||
noteableType: NoteableType; | ||
noteableId: string; | ||
}) => ({ | ||
queryKey: [{ noteableType, noteableId }], | ||
queryFn: () => getNotesByNotable({ noteableType, noteableId }), | ||
}), | ||
}); |
File renamed without changes.
18 changes: 18 additions & 0 deletions
18
apps/backoffice-v2/src/pages/Entity/components/Notes/hooks/schemas/note-schema.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { z } from 'zod'; | ||
|
||
const BasicNoteSchema = z.object({ | ||
id: z.string(), | ||
entityId: z.string(), | ||
entityType: z.enum(['Business', 'EndUser']), | ||
noteableId: z.string(), | ||
noteableType: z.enum(['Report', 'Alert', 'Workflow']), | ||
content: z.string(), | ||
fileIds: z.array(z.string()), | ||
createdAt: z.string().datetime(), | ||
updatedAt: z.string().datetime(), | ||
}); | ||
|
||
export const NoteSchema = BasicNoteSchema.extend({ | ||
parentNote: z.union([BasicNoteSchema, z.null()]), | ||
childrenNotes: z.array(BasicNoteSchema), | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export type NoteableType = 'Report' | 'Alert' | 'Workflow'; |
6 changes: 6 additions & 0 deletions
6
apps/backoffice-v2/src/pages/Entity/hooks/useEntityLogic/useEntityLogic.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,17 @@ | ||
import { useCurrentCaseQuery } from '@/pages/Entity/hooks/useCurrentCaseQuery/useCurrentCaseQuery'; | ||
import { useParams } from 'react-router-dom'; | ||
import { useNotesByNoteable } from '@/pages/Entity/components/Notes/hooks/queries/useNotesByNoteable/useNotesByNoteable'; | ||
|
||
export const useEntityLogic = () => { | ||
const { entityId } = useParams(); | ||
const { data: notes } = useNotesByNoteable({ noteableId: entityId, noteableType: 'Workflow' }); | ||
|
||
const { data: workflow } = useCurrentCaseQuery(); | ||
const selectedEntity = workflow?.entity; | ||
|
||
return { | ||
selectedEntity, | ||
workflow, | ||
notes, | ||
}; | ||
}; |
20 changes: 20 additions & 0 deletions
20
services/workflows-service/src/note/dtos/get-by-noteable.dto.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { IsNotEmpty, IsString } from 'class-validator'; | ||
import { ApiProperty } from '@nestjs/swagger'; | ||
import { Noteable } from '@prisma/client'; | ||
|
||
export class GetByNoteableDto { | ||
@ApiProperty({ | ||
required: true, | ||
type: String, | ||
}) | ||
@IsString() | ||
@IsNotEmpty() | ||
noteableId!: string; | ||
|
||
@ApiProperty({ | ||
required: true, | ||
enum: ['Workflow', 'Report', 'Alert'], | ||
}) | ||
@IsString() | ||
noteableType!: Noteable; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters