-
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.
Merge pull request #365 from ChildMindInstitute/feature-2.5/auto-comp…
…letion-preparation AutoCompletion feature preparation
- Loading branch information
Showing
10 changed files
with
95 additions
and
26 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 |
---|---|---|
@@ -1,3 +1,9 @@ | ||
export const getProgressId = (entityId: string, eventId: string): string => { | ||
return `${entityId}/${eventId}` | ||
} | ||
|
||
export const getDataFromProgressId = (progressId: string): { entityId: string; eventId: string } => { | ||
const [entityId, eventId] = progressId.split("/") | ||
|
||
return { entityId, eventId } | ||
} |
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 +1,2 @@ | ||
export * from "./useEventsByAppletIdQuery" | ||
export * from "./useUserEventsMutation" |
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,7 @@ | ||
import { MutationOptions, eventsService, useBaseMutation } from "~/shared/api" | ||
|
||
type Options = MutationOptions<typeof eventsService.getUserEvents> | ||
|
||
export const useUserEventsMutation = (options?: Options) => { | ||
return useBaseMutation(["getUserEvents"], eventsService.getUserEvents, { ...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
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,22 @@ | ||
import { matchPath } from "react-router-dom" | ||
|
||
type Params = { | ||
end?: boolean | ||
caseSensitive?: boolean | ||
} | ||
|
||
export const matchPaths = ( | ||
patterns: string[], | ||
pathname: string, | ||
params: Params = { end: false, caseSensitive: false }, | ||
) => { | ||
return patterns.map(path => | ||
matchPath( | ||
{ | ||
path, | ||
...params, | ||
}, | ||
pathname, | ||
), | ||
) | ||
} |
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,29 @@ | ||
import { useCallback, useRef } from "react" | ||
|
||
type SetTimerProps = { | ||
callback: () => void | ||
delay: number | ||
} | ||
|
||
export const useTimer = () => { | ||
const timerRef = useRef<number | undefined>(undefined) | ||
|
||
// this resets the timer if it exists. | ||
const resetTimer = useCallback(() => { | ||
if (timerRef) window.clearTimeout(timerRef.current) | ||
}, [timerRef]) | ||
|
||
const setTimer = useCallback( | ||
(props: SetTimerProps) => { | ||
timerRef.current = window.setTimeout(() => { | ||
// clears any pending timer. | ||
resetTimer() | ||
|
||
props.callback() | ||
}, props.delay) | ||
}, | ||
[resetTimer], | ||
) | ||
|
||
return { setTimer, resetTimer } | ||
} |
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