From a99939a207c39793d2ffb191286ad6d1546a64a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Sworze=C5=84?= Date: Thu, 11 Apr 2024 12:28:22 +0200 Subject: [PATCH] [#546] move provider types/change names --- CHANGELOG.md | 2 +- .../frontend/src/context/usersnapContext.tsx | 22 ++++++++++--------- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index db93aa7f2..2a38176e0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,7 +10,7 @@ changes. ## [Unreleased] -- Inicjalize Usersnap into App [Issue 546](https://github.com/IntersectMBO/govtool/issues/546) +- Inicialize Usersnap into App [Issue 546](https://github.com/IntersectMBO/govtool/issues/546) - Integrate frontend with metadata validation service [Issue 617](https://github.com/IntersectMBO/govtool/issues/617) - Implement a loading modal for the validation of the metadata [Issue 646](https://github.com/IntersectMBO/govtool/issues/646) diff --git a/govtool/frontend/src/context/usersnapContext.tsx b/govtool/frontend/src/context/usersnapContext.tsx index e877cabfe..d121f9624 100644 --- a/govtool/frontend/src/context/usersnapContext.tsx +++ b/govtool/frontend/src/context/usersnapContext.tsx @@ -13,13 +13,12 @@ import { const API_KEY = import.meta.env.VITE_USERSNAP_SPACE_API_KEY; -const defaultValues = { - openFeedbackWindow: () => {}, +type UsersnapProviderProps = { + initParams?: InitOptions; + children?: React.ReactNode; }; -export const UsersnapContext = React.createContext(defaultValues); - -type API = { +type UsersnapAPI = { init: (params?: InitOptions | undefined) => Promise; logEvent: (eventName: string) => Promise; show: (apiKey: string) => Promise; @@ -29,14 +28,17 @@ type API = { off: (eventName: SpaceEventName, callback: SpaceEventCallback) => void; }; +const defaultValues = { + openFeedbackWindow: () => {}, +}; + +export const UsersnapContext = React.createContext(defaultValues); + export const UsersnapProvider = ({ initParams, children, -}: { - initParams?: InitOptions; - children?: React.ReactNode; -}) => { - const [usersnapApi, setUsersnapApi] = useState(null); +}: UsersnapProviderProps) => { + const [usersnapApi, setUsersnapApi] = useState(null); const openFeedbackWindow = useCallback(() => { if (usersnapApi) {