-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* Updating subject fetching logic I've added a new query that allows both full account participants and team members to fetch their own subject details. I've also modified the logic for fetching the source and target subjects. In the admin panel, a temporary relation is only created if the subjects differ. Since this relation is required for fetching the subjects, I conditionally fetch them based on this difference. * Fix query enabled checks Tanstack query depends on a proper boolean value (not boolean | undefined) to disable the query * Simplify boolean checks At this point in the code we've already narrowed the type, so we don't have to worry about `undefined` * Change isLoading to isFetching According to tanstack query docs, isLoading will be true even if th query is disabled, so we should use `fetchStatus` to determine if it is actively fetching data. `isFetching` is a convenience property for this. See https://tanstack.com/query/v4/docs/framework/react/reference/useQuery
- Loading branch information
1 parent
c6855b5
commit aaba54d
Showing
4 changed files
with
127 additions
and
76 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { QueryOptions, ReturnAwaited, subjectService, useBaseQuery } from '~/shared/api'; | ||
|
||
type FetchFn = typeof subjectService.getMySubjectByAppletId; | ||
type Options<TData> = QueryOptions<FetchFn, TData>; | ||
|
||
export const useGetMySubjectQuery = <TData = ReturnAwaited<FetchFn>>( | ||
appletId: string, | ||
options?: Options<TData>, | ||
) => { | ||
return useBaseQuery( | ||
['mySubject', { appletId }], | ||
() => subjectService.getMySubjectByAppletId({ appletId }), | ||
options, | ||
); | ||
}; |
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