Update FE case to match BE graphql case (camelCase) (#154)
This commit is contained in:
@ -13,11 +13,11 @@ describe('Company mappers', () => {
|
||||
const graphQLCompany = {
|
||||
id: '7dfbc3f7-6e5e-4128-957e-8d86808cdf6b',
|
||||
name: 'ACME',
|
||||
domain_name: 'exmaple.com',
|
||||
created_at: now.toUTCString(),
|
||||
domainName: 'exmaple.com',
|
||||
createdAt: now.toUTCString(),
|
||||
employees: 10,
|
||||
address: '1 Infinite Loop, 95014 Cupertino, California, USA',
|
||||
account_owner: {
|
||||
accountOwner: {
|
||||
id: '7af20dea-0412-4c4c-8b13-d6f0e6e09e87',
|
||||
email: 'john@example.com',
|
||||
displayName: 'John Doe',
|
||||
@ -39,8 +39,8 @@ describe('Company mappers', () => {
|
||||
__typename: 'companies',
|
||||
id: graphQLCompany.id,
|
||||
name: graphQLCompany.name,
|
||||
domainName: graphQLCompany.domain_name,
|
||||
creationDate: new Date(now.toUTCString()),
|
||||
domainName: graphQLCompany.domainName,
|
||||
createdAt: new Date(now.toUTCString()),
|
||||
employees: graphQLCompany.employees,
|
||||
address: graphQLCompany.address,
|
||||
accountOwner: {
|
||||
@ -70,18 +70,18 @@ describe('Company mappers', () => {
|
||||
displayName: 'John Doe',
|
||||
__typename: 'users',
|
||||
},
|
||||
creationDate: now,
|
||||
createdAt: now,
|
||||
__typename: 'companies',
|
||||
} satisfies Company;
|
||||
const graphQLCompany = mapToGqlCompany(company);
|
||||
expect(graphQLCompany).toStrictEqual({
|
||||
id: company.id,
|
||||
name: company.name,
|
||||
domain_name: company.domainName,
|
||||
created_at: now.toUTCString(),
|
||||
domainName: company.domainName,
|
||||
createdAt: now.toUTCString(),
|
||||
employees: company.employees,
|
||||
address: company.address,
|
||||
account_owner_id: '522d4ec4-c46b-4360-a0a7-df8df170be81',
|
||||
accountOwnerId: '522d4ec4-c46b-4360-a0a7-df8df170be81',
|
||||
__typename: 'companies',
|
||||
} satisfies GraphqlMutationCompany);
|
||||
});
|
||||
|
||||
@ -14,7 +14,7 @@ describe('Person mappers', () => {
|
||||
id: '7dfbc3f7-6e5e-4128-957e-8d86808cdf6b',
|
||||
firstname: 'John',
|
||||
lastname: 'Doe',
|
||||
created_at: now.toUTCString(),
|
||||
createdAt: now.toUTCString(),
|
||||
email: 'john.doe@gmail.com',
|
||||
phone: '+1 (555) 123-4567',
|
||||
city: 'Paris',
|
||||
@ -32,7 +32,7 @@ describe('Person mappers', () => {
|
||||
id: graphQLPerson.id,
|
||||
firstname: graphQLPerson.firstname,
|
||||
lastname: graphQLPerson.lastname,
|
||||
creationDate: new Date(now.toUTCString()),
|
||||
createdAt: new Date(now.toUTCString()),
|
||||
email: graphQLPerson.email,
|
||||
city: graphQLPerson.city,
|
||||
phone: graphQLPerson.phone,
|
||||
@ -41,7 +41,7 @@ describe('Person mappers', () => {
|
||||
id: '7af20dea-0412-4c4c-8b13-d6f0e6e09e87',
|
||||
accountOwner: undefined,
|
||||
address: undefined,
|
||||
creationDate: undefined,
|
||||
createdAt: undefined,
|
||||
domainName: undefined,
|
||||
employees: undefined,
|
||||
name: 'John Doe',
|
||||
@ -57,7 +57,7 @@ describe('Person mappers', () => {
|
||||
id: '7dfbc3f7-6e5e-4128-957e-8d86808cdf6b',
|
||||
firstname: 'John',
|
||||
lastname: 'Doe',
|
||||
creationDate: new Date(now.toUTCString()),
|
||||
createdAt: new Date(now.toUTCString()),
|
||||
email: 'john.doe@gmail.com',
|
||||
phone: '+1 (555) 123-4567',
|
||||
city: 'Paris',
|
||||
@ -71,11 +71,11 @@ describe('Person mappers', () => {
|
||||
id: person.id,
|
||||
firstname: person.firstname,
|
||||
lastname: person.lastname,
|
||||
created_at: now.toUTCString(),
|
||||
createdAt: now.toUTCString(),
|
||||
email: person.email,
|
||||
city: person.city,
|
||||
phone: person.phone,
|
||||
company_id: '7af20dea-0412-4c4c-8b13-d6f0e6e09e87',
|
||||
companyId: '7af20dea-0412-4c4c-8b13-d6f0e6e09e87',
|
||||
__typename: 'people',
|
||||
} satisfies GraphqlMutationPerson);
|
||||
});
|
||||
|
||||
@ -14,11 +14,11 @@ describe('User mappers', () => {
|
||||
id: '7dfbc3f7-6e5e-4128-957e-8d86808cdf6b',
|
||||
displayName: 'John Doe',
|
||||
email: 'john.doe@gmail.com',
|
||||
workspace_member: {
|
||||
workspaceMember: {
|
||||
id: '7af20dea-0412-4c4c-8b13-d6f0e6e09e88',
|
||||
workspace: {
|
||||
id: '7af20dea-0412-4c4c-8b13-d6f0e6e09e89',
|
||||
display_name: 'John Doe',
|
||||
displayName: 'John Doe',
|
||||
__typename: 'workspace',
|
||||
},
|
||||
__typename: 'workspace_members',
|
||||
@ -33,10 +33,10 @@ describe('User mappers', () => {
|
||||
displayName: graphQLUser.displayName,
|
||||
email: graphQLUser.email,
|
||||
workspaceMember: {
|
||||
id: graphQLUser.workspace_member.id,
|
||||
id: graphQLUser.workspaceMember.id,
|
||||
workspace: {
|
||||
id: graphQLUser.workspace_member.workspace.id,
|
||||
displayName: graphQLUser.workspace_member.workspace.display_name,
|
||||
id: graphQLUser.workspaceMember.workspace.id,
|
||||
displayName: graphQLUser.workspaceMember.workspace.displayName,
|
||||
domainName: undefined,
|
||||
logo: undefined,
|
||||
},
|
||||
@ -66,7 +66,7 @@ describe('User mappers', () => {
|
||||
id: user.id,
|
||||
displayName: user.displayName,
|
||||
email: user.email,
|
||||
workspace_member_id: user.workspaceMember.id,
|
||||
workspaceMemberId: user.workspaceMember.id,
|
||||
__typename: 'users',
|
||||
} satisfies GraphqlMutationUser);
|
||||
});
|
||||
|
||||
@ -10,7 +10,7 @@ export type Company = {
|
||||
employees?: number | null;
|
||||
address?: string;
|
||||
|
||||
creationDate?: Date;
|
||||
createdAt?: Date;
|
||||
|
||||
pipes?: Pipe[];
|
||||
accountOwner?: User | null;
|
||||
@ -19,13 +19,13 @@ export type Company = {
|
||||
export type GraphqlQueryCompany = {
|
||||
id: string;
|
||||
name?: string;
|
||||
domain_name?: string;
|
||||
domainName?: string;
|
||||
employees?: number | null;
|
||||
address?: string;
|
||||
|
||||
created_at?: string;
|
||||
createdAt?: string;
|
||||
|
||||
account_owner?: GraphqlQueryUser | null;
|
||||
accountOwner?: GraphqlQueryUser | null;
|
||||
pipes?: GraphqlQueryPipe[] | null;
|
||||
__typename: string;
|
||||
};
|
||||
@ -33,13 +33,13 @@ export type GraphqlQueryCompany = {
|
||||
export type GraphqlMutationCompany = {
|
||||
id: string;
|
||||
name?: string;
|
||||
domain_name?: string;
|
||||
domainName?: string;
|
||||
employees?: number | null;
|
||||
address?: string;
|
||||
|
||||
created_at?: string;
|
||||
createdAt?: string;
|
||||
|
||||
account_owner_id?: string;
|
||||
accountOwnerId?: string;
|
||||
__typename: string;
|
||||
};
|
||||
|
||||
@ -49,26 +49,24 @@ export const mapToCompany = (company: GraphqlQueryCompany): Company => ({
|
||||
employees: company.employees,
|
||||
name: company.name,
|
||||
address: company.address,
|
||||
domainName: company.domain_name,
|
||||
creationDate: company.created_at ? new Date(company.created_at) : undefined,
|
||||
domainName: company.domainName,
|
||||
createdAt: company.createdAt ? new Date(company.createdAt) : undefined,
|
||||
|
||||
accountOwner: company.account_owner
|
||||
? mapToUser(company.account_owner)
|
||||
: company.account_owner,
|
||||
accountOwner: company.accountOwner
|
||||
? mapToUser(company.accountOwner)
|
||||
: company.accountOwner,
|
||||
pipes: [],
|
||||
});
|
||||
|
||||
export const mapToGqlCompany = (company: Company): GraphqlMutationCompany => ({
|
||||
id: company.id,
|
||||
name: company.name,
|
||||
domain_name: company.domainName,
|
||||
domainName: company.domainName,
|
||||
address: company.address,
|
||||
employees: company.employees,
|
||||
|
||||
created_at: company.creationDate
|
||||
? company.creationDate.toUTCString()
|
||||
: undefined,
|
||||
createdAt: company.createdAt ? company.createdAt.toUTCString() : undefined,
|
||||
|
||||
account_owner_id: company.accountOwner?.id,
|
||||
accountOwnerId: company.accountOwner?.id,
|
||||
__typename: 'companies',
|
||||
});
|
||||
|
||||
@ -15,7 +15,7 @@ export type Person = {
|
||||
phone?: string;
|
||||
city?: string;
|
||||
|
||||
creationDate?: Date;
|
||||
createdAt?: Date;
|
||||
|
||||
company?: Company | null;
|
||||
pipes?: Pipe[] | null;
|
||||
@ -29,7 +29,7 @@ export type GraphqlQueryPerson = {
|
||||
email?: string;
|
||||
phone?: string;
|
||||
|
||||
created_at?: string;
|
||||
createdAt?: string;
|
||||
|
||||
company?: GraphqlQueryCompany | null;
|
||||
|
||||
@ -43,8 +43,8 @@ export type GraphqlMutationPerson = {
|
||||
email?: string;
|
||||
phone?: string;
|
||||
city?: string;
|
||||
created_at?: string;
|
||||
company_id?: string;
|
||||
createdAt?: string;
|
||||
companyId?: string;
|
||||
__typename: 'people';
|
||||
};
|
||||
|
||||
@ -57,7 +57,7 @@ export const mapToPerson = (person: GraphqlQueryPerson): Person => ({
|
||||
phone: person.phone,
|
||||
city: person.city,
|
||||
|
||||
creationDate: person.created_at ? new Date(person.created_at) : undefined,
|
||||
createdAt: person.createdAt ? new Date(person.createdAt) : undefined,
|
||||
|
||||
company: person.company ? mapToCompany(person.company) : null,
|
||||
});
|
||||
@ -70,10 +70,8 @@ export const mapToGqlPerson = (person: Person): GraphqlMutationPerson => ({
|
||||
phone: person.phone,
|
||||
city: person.city,
|
||||
|
||||
created_at: person.creationDate
|
||||
? person.creationDate.toUTCString()
|
||||
: undefined,
|
||||
createdAt: person.createdAt ? person.createdAt.toUTCString() : undefined,
|
||||
|
||||
company_id: person.company?.id,
|
||||
companyId: person.company?.id,
|
||||
__typename: 'people',
|
||||
});
|
||||
|
||||
@ -2,7 +2,7 @@ import {
|
||||
GraphqlQueryWorkspaceMember,
|
||||
WorkspaceMember,
|
||||
mapToWorkspaceMember,
|
||||
} from './workspace_member.interface';
|
||||
} from './workspaceMember.interface';
|
||||
|
||||
export interface User {
|
||||
__typename: 'users';
|
||||
@ -16,7 +16,7 @@ export type GraphqlQueryUser = {
|
||||
id: string;
|
||||
email?: string;
|
||||
displayName?: string;
|
||||
workspace_member?: GraphqlQueryWorkspaceMember;
|
||||
workspaceMember?: GraphqlQueryWorkspaceMember;
|
||||
__typename: string;
|
||||
};
|
||||
|
||||
@ -24,7 +24,7 @@ export type GraphqlMutationUser = {
|
||||
id: string;
|
||||
email?: string;
|
||||
displayName?: string;
|
||||
workspace_member_id?: string;
|
||||
workspaceMember_id?: string;
|
||||
__typename: string;
|
||||
};
|
||||
|
||||
@ -33,15 +33,15 @@ export const mapToUser = (user: GraphqlQueryUser): User => ({
|
||||
id: user.id,
|
||||
email: user.email,
|
||||
displayName: user.displayName,
|
||||
workspaceMember: user.workspace_member
|
||||
? mapToWorkspaceMember(user.workspace_member)
|
||||
: user.workspace_member,
|
||||
workspaceMember: user.workspaceMember
|
||||
? mapToWorkspaceMember(user.workspaceMember)
|
||||
: user.workspaceMember,
|
||||
});
|
||||
|
||||
export const mapToGqlUser = (user: User): GraphqlMutationUser => ({
|
||||
id: user.id,
|
||||
email: user.email,
|
||||
displayName: user.displayName,
|
||||
workspace_member_id: user.workspaceMember?.id,
|
||||
workspaceMember_id: user.workspaceMember?.id,
|
||||
__typename: 'users',
|
||||
});
|
||||
|
||||
@ -7,16 +7,16 @@ export interface Workspace {
|
||||
|
||||
export type GraphqlQueryWorkspace = {
|
||||
id: string;
|
||||
display_name?: string;
|
||||
domain_name?: string;
|
||||
displayName?: string;
|
||||
domainName?: string;
|
||||
logo?: string | null;
|
||||
__typename: string;
|
||||
};
|
||||
|
||||
export type GraphqlMutationWorkspace = {
|
||||
id: string;
|
||||
display_name?: string;
|
||||
domain_name?: string;
|
||||
displayName?: string;
|
||||
domainName?: string;
|
||||
logo?: string | null;
|
||||
__typename: string;
|
||||
};
|
||||
@ -25,8 +25,8 @@ export const mapToWorkspace = (
|
||||
workspace: GraphqlQueryWorkspace,
|
||||
): Workspace => ({
|
||||
id: workspace.id,
|
||||
domainName: workspace.domain_name,
|
||||
displayName: workspace.display_name,
|
||||
domainName: workspace.domainName,
|
||||
displayName: workspace.displayName,
|
||||
logo: workspace.logo,
|
||||
});
|
||||
|
||||
@ -34,8 +34,8 @@ export const mapToGqlWorkspace = (
|
||||
workspace: Workspace,
|
||||
): GraphqlMutationWorkspace => ({
|
||||
id: workspace.id,
|
||||
domain_name: workspace.domainName,
|
||||
display_name: workspace.displayName,
|
||||
domainName: workspace.domainName,
|
||||
displayName: workspace.displayName,
|
||||
logo: workspace.logo,
|
||||
__typename: 'workspaces',
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user