move to api.ts
This commit is contained in:
parent
2add2bc9cd
commit
d99fc0e4d8
|
|
@ -1,8 +1,8 @@
|
|||
import { FormikForm } from "@shared/nej-react-utils/Form/FormikForm";
|
||||
import { useApiClient, useProject } from "@utils/NejManager/NejProvider";
|
||||
import { useApiClient } from "@utils/NejManager/NejProvider";
|
||||
import useMethod from "../macros/useMethod.macro";
|
||||
import useQuery from "../macros/useQuery.macro";
|
||||
import { CancelablePromise, PortalApiClient, ProjectResponse } from "@services/portal-api";
|
||||
import { CancelablePromise, ApiClient, OwnerResponse, useOwner } from "@services/api";
|
||||
|
||||
type FormProps<T> = {
|
||||
refresh: () => void;
|
||||
|
|
@ -10,10 +10,10 @@ type FormProps<T> = {
|
|||
initialData?: T;
|
||||
};
|
||||
export type WithFormProps<T, P> = P & FormProps<T>;
|
||||
export function withForm<T extends object, P extends FormProps<T>>(WrappedForm: React.ComponentType, method: (client: PortalApiClient, project: ProjectResponse, props: P) => (body: T) => CancelablePromise<any>, submitText: string) {
|
||||
export function withForm<T extends object, P extends FormProps<T>>(WrappedForm: React.ComponentType, method: (client: ApiClient, project: OwnerResponse, props: P) => (body: T) => CancelablePromise<any>, submitText: string) {
|
||||
return function GameFormWrapper({ refresh, afterSubmit, initialData, ...props }: P) {
|
||||
const client = useApiClient();
|
||||
const company = useProject();
|
||||
const company = useOwner();
|
||||
|
||||
const fnc = method(client, company, { ...props, initialData } as P);
|
||||
console.log(fnc);
|
||||
|
|
|
|||
|
|
@ -78,7 +78,7 @@ function useMethod({ references, state, babel }) {
|
|||
let useStateHookImport = addNamed(declPath, "useState", "react");
|
||||
let useCallbackHookImport = addNamed(declPath, "useCallback", "react");
|
||||
|
||||
let servicePath = "@services/portal-api";
|
||||
let servicePath = "@services/api";
|
||||
let apiErrorImport = addNamed(declPath, "ApiError", servicePath);
|
||||
|
||||
let nejServicesPath = "@utils/NejManager/NejProvider";
|
||||
|
|
|
|||
2
macros/useMethod.macro.d.ts
vendored
2
macros/useMethod.macro.d.ts
vendored
|
|
@ -1,4 +1,4 @@
|
|||
import { CancelablePromise, Error } from "src/services/portal-api";
|
||||
import { CancelablePromise, Error } from "src/services/api";
|
||||
|
||||
export default function useMethod<T, Arg>(method: (...args: Arg) => CancelablePromise<T>,
|
||||
onDone?: (data: T) => void,
|
||||
|
|
|
|||
|
|
@ -87,7 +87,7 @@ function useQuery({ references, state, babel }) {
|
|||
}
|
||||
let fullCallPathString = reduceCallee(call.callee)
|
||||
|
||||
let servicePath = "@services/portal-api";
|
||||
let servicePath = "@services/api";
|
||||
let apiErrorImport = addNamed(declPath, "ApiError", servicePath);
|
||||
|
||||
let useStateSrc = babel.template("[DATA, CALL_SET] = USE_STATE({data: null, error: null, loading: true})")({
|
||||
|
|
|
|||
2
macros/useQuery.macro.d.ts
vendored
2
macros/useQuery.macro.d.ts
vendored
|
|
@ -1,4 +1,4 @@
|
|||
import { CancelablePromise, Error } from "src/services/portal-api";
|
||||
import { CancelablePromise, Error } from "src/services/api";
|
||||
|
||||
//default export is a function
|
||||
/*
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user