Skip to content

Commit

Permalink
feat: add better typings for authService method params
Browse files Browse the repository at this point in the history
  • Loading branch information
trevor-anderson committed Dec 15, 2022
1 parent 665dcd9 commit 6d5f282
Showing 1 changed file with 11 additions and 14 deletions.
25 changes: 11 additions & 14 deletions src/services/authService.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { httpService } from "./httpService";
import type { User, EncodedAuthToken, WorkOrder, Invoice, Contact } from "../types";
import type { User, EncodedAuthToken, WorkOrder, Invoice, Contact } from "@types";

export const authService = {
registerNewUser: async (
Expand All @@ -11,7 +11,7 @@ export const authService = {
});
},
login: async (
userLoginArgs: Expand<Omit<RegisterNewUserArgs, "phone" | "profile">>
userLoginArgs: Omit<RegisterNewUserArgs, "phone" | "profile">
): Promise<AuthTokenAndPreFetchedUserItems> => {
return await httpService.post("/api/auth/login", {
...userLoginArgs,
Expand All @@ -33,23 +33,20 @@ type AuthServiceCredentials = {
googleAccessToken?: string;
};

type RegisterNewUserArgs = Expand<
Required<Pick<User, "email" | "phone" | "profile">> & AuthServiceCredentials
>;
type RegisterNewUserArgs = Required<Pick<User, "email" | "phone" | "profile">> &
AuthServiceCredentials;

type RegisterNewUserReturnValue = {
token: EncodedAuthToken;
};

type AuthTokenAndPreFetchedUserItems = Expand<
RegisterNewUserReturnValue & {
userItems?: {
workOrders?: Array<WorkOrder>;
invoices?: Array<Invoice>;
contacts?: Array<Contact>;
};
}
>;
type AuthTokenAndPreFetchedUserItems = RegisterNewUserReturnValue & {
userItems?: {
workOrders?: Array<WorkOrder>;
invoices?: Array<Invoice>;
contacts?: Array<Contact>;
};
};

export interface PreFetchedUserItems {
workOrders?: Array<WorkOrder>;
Expand Down

0 comments on commit 6d5f282

Please sign in to comment.