Skip to content

Commit

Permalink
feat: add FixitUser type, add 'handle' to User+Contact
Browse files Browse the repository at this point in the history
  • Loading branch information
trevor-anderson committed Dec 22, 2022
1 parent 364b859 commit 7b63e98
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 8 deletions.
4 changes: 4 additions & 0 deletions src/hooks/useAuthToken.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@ export const useAuthToken = () => {
// prettier-ignore
const {
id,
handle,
email,
phone,
profile,
stripeCustomerID,
stripeConnectAccount,
subscription
Expand All @@ -37,8 +39,10 @@ export const useAuthToken = () => {
user: {
__typename: "User",
id,
handle,
email,
phone,
profile,
stripeCustomerID,
stripeConnectAccount: {
__typename: "StripeConnectAccount",
Expand Down
1 change: 1 addition & 0 deletions src/types/AuthToken.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import type { UserSubscription } from "./UserSubscription.types";

export type AuthTokenPayload = {
id: User["id"];
handle: User["handle"];
email: User["email"];
phone: User["phone"];
profile: User["profile"];
Expand Down
6 changes: 4 additions & 2 deletions src/types/Contact.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@ import type { User } from "./User.types";

export type Contact = {
id: string;
handle: User["handle"];
email: User["email"];
phone: User["phone"];
profile: User["profile"];
createdAt: Date;
updatedAt: Date;
// These two are not currently available via the GQL API:
// createdAt: Date;
// updatedAt: Date;
};
4 changes: 4 additions & 0 deletions src/types/FixitUser.types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import type { User } from "./User.types";
import type { Contact } from "./Contact.types";

export type FixitUser = User | Contact;
6 changes: 3 additions & 3 deletions src/types/Invoice.types.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import type { User } from "./User.types";
import type { FixitUser } from "./FixitUser.types";

export const INVOICE_CONSTANTS = {
STATUSES: ["OPEN", "CLOSED", "DISPUTED"]
} as const;

export type Invoice = {
id: string;
createdBy: User;
assignedTo: User;
createdBy: FixitUser;
assignedTo: FixitUser;
amount: number;
status: typeof INVOICE_CONSTANTS.STATUSES[number];
stripePaymentIntentID?: string;
Expand Down
1 change: 1 addition & 0 deletions src/types/User.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import type { UserStripeConnectAccount } from "./UserStripeConnectAccount.types"

export type User = {
id: string;
handle: string;
email: string;
phone: string;
expoPushToken?: string;
Expand Down
6 changes: 3 additions & 3 deletions src/types/WorkOrder.types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { User } from "./User.types";
import type { FixitUser } from "./FixitUser.types";
import type { WorkOrderChecklist } from "./WorkOrderChecklist.types";

// prettier-ignore
Expand All @@ -13,8 +13,8 @@ export const WORK_ORDER_CONSTANTS = {

export type WorkOrder = {
id: string;
createdBy: User;
assignedTo?: User;
createdBy: FixitUser;
assignedTo?: FixitUser;
location: Location;
status: typeof WORK_ORDER_CONSTANTS.STATUSES[number];
priority: typeof WORK_ORDER_CONSTANTS.PRIORITIES[number];
Expand Down
1 change: 1 addition & 0 deletions src/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export const CONSTANTS = {
// Export all API types:
export * from "./AuthToken.types";
export * from "./Contact.types";
export * from "./FixitUser.types";
export * from "./Invoice.types";
export * from "./User.types";
export * from "./UserLogin.types";
Expand Down

0 comments on commit 7b63e98

Please sign in to comment.