Skip to content

Commit

Permalink
[#546] move types
Browse files Browse the repository at this point in the history
  • Loading branch information
Sworzen1 committed Apr 16, 2024
1 parent 0af6a23 commit 0382ff4
Showing 1 changed file with 30 additions and 4 deletions.
34 changes: 30 additions & 4 deletions govtool/frontend/src/context/usersnapContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,36 @@ import React, {
useMemo,
} from "react";
import { InitOptions, WidgetApi, loadSpace } from "@usersnap/browser";
import {
SpaceEventCallback,
SpaceEventName,
} from "node_modules/@usersnap/browser/dist/types";

type WidgetValues = {
assignee?: string;
custom?: object;
labels?: Array<string>;
visitor?: string;
};
type WidgetEventApi = {
setValue: <K extends keyof WidgetValues>(
key: K,
value: WidgetValues[K],
) => void;
};

type WidgetBeforeSubmitEvent = {
apiKey: string;
api: WidgetEventApi;
values: WidgetValues;
};

type WidgetOpenEvent = {
api: WidgetEventApi;
type: "open";
};

type SpaceEventCallback = (
event: WidgetOpenEvent | WidgetBeforeSubmitEvent,
) => void;

type SpaceEventName = "open" | "close" | "beforeSubmit" | "submit";

const API_KEY = import.meta.env.VITE_USERSNAP_SPACE_API_KEY;

Expand Down

0 comments on commit 0382ff4

Please sign in to comment.