Update FE case to match BE graphql case (camelCase) (#154)

This commit is contained in:
Charles Bochet 2023-05-29 19:45:55 +02:00 committed by GitHub
parent de9cf61689
commit 2f50cdc07e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
27 changed files with 200 additions and 204 deletions

View File

@ -41,16 +41,16 @@ export function PeopleCompanyCell({ people }: OwnProps) {
variables: {
id: newCompanyId,
name: companyName,
domain_name: companyDomainName,
domainName: companyDomainName,
address: '',
created_at: new Date().toISOString(),
createdAt: new Date().toISOString(),
},
});
await updatePeople({
variables: {
...mapToGqlPerson(people),
company_id: newCompanyId,
companyId: newCompanyId,
},
});
} catch (error) {
@ -86,7 +86,7 @@ export function PeopleCompanyCell({ people }: OwnProps) {
await updatePeople({
variables: {
...mapToGqlPerson(people),
company_id: relation.id,
companyId: relation.id,
},
});
}}

View File

@ -1417,32 +1417,32 @@ export type GetCompaniesQueryVariables = Exact<{
}>;
export type GetCompaniesQuery = { __typename?: 'Query', companies: Array<{ __typename?: 'Company', id: string, name: string, address: string, employees?: number | null, domain_name: string, created_at: any, account_owner?: { __typename?: 'User', id: string, email: string, displayName: string } | null }> };
export type GetCompaniesQuery = { __typename?: 'Query', companies: Array<{ __typename?: 'Company', id: string, domainName: string, name: string, createdAt: any, address: string, employees?: number | null, accountOwner?: { __typename?: 'User', id: string, email: string, displayName: string } | null }> };
export type UpdateCompanyMutationVariables = Exact<{
id?: InputMaybe<Scalars['String']>;
name?: InputMaybe<Scalars['String']>;
domain_name?: InputMaybe<Scalars['String']>;
account_owner_id?: InputMaybe<Scalars['String']>;
created_at?: InputMaybe<Scalars['DateTime']>;
domainName?: InputMaybe<Scalars['String']>;
accountOwnerId?: InputMaybe<Scalars['String']>;
createdAt?: InputMaybe<Scalars['DateTime']>;
address?: InputMaybe<Scalars['String']>;
employees?: InputMaybe<Scalars['Int']>;
}>;
export type UpdateCompanyMutation = { __typename?: 'Mutation', updateOneCompany?: { __typename?: 'Company', address: string, employees?: number | null, id: string, name: string, created_at: any, domain_name: string, accountOwner?: { __typename?: 'User', id: string, email: string, display_name: string } | null } | null };
export type UpdateCompanyMutation = { __typename?: 'Mutation', updateOneCompany?: { __typename?: 'Company', address: string, createdAt: any, domainName: string, employees?: number | null, id: string, name: string, accountOwner?: { __typename?: 'User', id: string, email: string, displayName: string } | null } | null };
export type InsertCompanyMutationVariables = Exact<{
id: Scalars['String'];
name: Scalars['String'];
domain_name: Scalars['String'];
created_at?: InputMaybe<Scalars['DateTime']>;
domainName: Scalars['String'];
createdAt?: InputMaybe<Scalars['DateTime']>;
address: Scalars['String'];
employees?: InputMaybe<Scalars['Int']>;
}>;
export type InsertCompanyMutation = { __typename?: 'Mutation', createOneCompany: { __typename?: 'Company', address: string, employees?: number | null, id: string, name: string, created_at: any, domain_name: string } };
export type InsertCompanyMutation = { __typename?: 'Mutation', createOneCompany: { __typename?: 'Company', address: string, createdAt: any, domainName: string, employees?: number | null, id: string, name: string } };
export type DeleteCompaniesMutationVariables = Exact<{
ids?: InputMaybe<Array<Scalars['String']> | Scalars['String']>;
@ -1458,7 +1458,7 @@ export type GetPeopleQueryVariables = Exact<{
}>;
export type GetPeopleQuery = { __typename?: 'Query', people: Array<{ __typename?: 'Person', id: string, phone: string, email: string, city: string, firstname: string, lastname: string, created_at: any, company?: { __typename?: 'Company', id: string, name: string, domain_name: string } | null }> };
export type GetPeopleQuery = { __typename?: 'Query', people: Array<{ __typename?: 'Person', id: string, phone: string, email: string, city: string, firstname: string, lastname: string, createdAt: any, company?: { __typename?: 'Company', id: string, name: string, domainName: string } | null }> };
export type UpdatePeopleMutationVariables = Exact<{
id?: InputMaybe<Scalars['String']>;
@ -1466,13 +1466,13 @@ export type UpdatePeopleMutationVariables = Exact<{
lastname?: InputMaybe<Scalars['String']>;
phone?: InputMaybe<Scalars['String']>;
city?: InputMaybe<Scalars['String']>;
company_id?: InputMaybe<Scalars['String']>;
companyId?: InputMaybe<Scalars['String']>;
email?: InputMaybe<Scalars['String']>;
created_at?: InputMaybe<Scalars['DateTime']>;
createdAt?: InputMaybe<Scalars['DateTime']>;
}>;
export type UpdatePeopleMutation = { __typename?: 'Mutation', updateOnePerson?: { __typename?: 'Person', city: string, email: string, firstname: string, id: string, lastname: string, phone: string, created_at: any, company?: { __typename?: 'Company', name: string, id: string, domain_name: string } | null } | null };
export type UpdatePeopleMutation = { __typename?: 'Mutation', updateOnePerson?: { __typename?: 'Person', city: string, email: string, firstname: string, id: string, lastname: string, phone: string, createdAt: any, company?: { __typename?: 'Company', domainName: string, name: string, id: string } | null } | null };
export type InsertPersonMutationVariables = Exact<{
id: Scalars['String'];
@ -1481,11 +1481,11 @@ export type InsertPersonMutationVariables = Exact<{
phone: Scalars['String'];
city: Scalars['String'];
email: Scalars['String'];
created_at?: InputMaybe<Scalars['DateTime']>;
createdAt?: InputMaybe<Scalars['DateTime']>;
}>;
export type InsertPersonMutation = { __typename?: 'Mutation', createOnePerson: { __typename?: 'Person', city: string, email: string, firstname: string, id: string, lastname: string, phone: string, created_at: any, company?: { __typename?: 'Company', name: string, id: string, domain_name: string } | null } };
export type InsertPersonMutation = { __typename?: 'Mutation', createOnePerson: { __typename?: 'Person', city: string, email: string, firstname: string, id: string, lastname: string, phone: string, createdAt: any, company?: { __typename?: 'Company', domainName: string, name: string, id: string } | null } };
export type DeletePeopleMutationVariables = Exact<{
ids?: InputMaybe<Array<Scalars['String']> | Scalars['String']>;
@ -1521,14 +1521,14 @@ export type SearchQueryQueryVariables = Exact<{
}>;
export type SearchQueryQuery = { __typename?: 'Query', searchResults: Array<{ __typename?: 'Company', id: string, name: string, domain_name: string }> };
export type SearchQueryQuery = { __typename?: 'Query', searchResults: Array<{ __typename?: 'Company', id: string, name: string, domainName: string }> };
export type GetCurrentUserQueryVariables = Exact<{
uuid?: InputMaybe<Scalars['String']>;
}>;
export type GetCurrentUserQuery = { __typename?: 'Query', users: Array<{ __typename?: 'User', id: string, email: string, displayName: string, workspace_member?: { __typename?: 'WorkspaceMember', workspace: { __typename?: 'Workspace', id: string, logo?: string | null, domain_name: string, display_name: string } } | null }> };
export type GetCurrentUserQuery = { __typename?: 'Query', users: Array<{ __typename?: 'User', id: string, email: string, displayName: string, workspaceMember?: { __typename?: 'WorkspaceMember', workspace: { __typename?: 'Workspace', id: string, domainName: string, displayName: string, logo?: string | null } } | null }> };
export type GetUsersQueryVariables = Exact<{ [key: string]: never; }>;
@ -1540,12 +1540,12 @@ export const GetCompaniesDocument = gql`
query GetCompanies($orderBy: [CompanyOrderByWithRelationInput!], $where: CompanyWhereInput) {
companies(orderBy: $orderBy, where: $where) {
id
domain_name: domainName
domainName
name
created_at: createdAt
createdAt
address
employees
account_owner: accountOwner {
accountOwner: accountOwner {
id
email
displayName
@ -1583,19 +1583,19 @@ export type GetCompaniesQueryHookResult = ReturnType<typeof useGetCompaniesQuery
export type GetCompaniesLazyQueryHookResult = ReturnType<typeof useGetCompaniesLazyQuery>;
export type GetCompaniesQueryResult = Apollo.QueryResult<GetCompaniesQuery, GetCompaniesQueryVariables>;
export const UpdateCompanyDocument = gql`
mutation UpdateCompany($id: String, $name: String, $domain_name: String, $account_owner_id: String, $created_at: DateTime, $address: String, $employees: Int) {
mutation UpdateCompany($id: String, $name: String, $domainName: String, $accountOwnerId: String, $createdAt: DateTime, $address: String, $employees: Int) {
updateOneCompany(
where: {id: $id}
data: {accountOwner: {connect: {id: $account_owner_id}}, address: {set: $address}, domainName: {set: $domain_name}, employees: {set: $employees}, name: {set: $name}, createdAt: {set: $created_at}}
data: {accountOwner: {connect: {id: $accountOwnerId}}, address: {set: $address}, domainName: {set: $domainName}, employees: {set: $employees}, name: {set: $name}, createdAt: {set: $createdAt}}
) {
accountOwner {
id
email
display_name: displayName
displayName
}
address
created_at: createdAt
domain_name: domainName
createdAt
domainName
employees
id
name
@ -1619,9 +1619,9 @@ export type UpdateCompanyMutationFn = Apollo.MutationFunction<UpdateCompanyMutat
* variables: {
* id: // value for 'id'
* name: // value for 'name'
* domain_name: // value for 'domain_name'
* account_owner_id: // value for 'account_owner_id'
* created_at: // value for 'created_at'
* domainName: // value for 'domainName'
* accountOwnerId: // value for 'accountOwnerId'
* createdAt: // value for 'createdAt'
* address: // value for 'address'
* employees: // value for 'employees'
* },
@ -1635,13 +1635,13 @@ export type UpdateCompanyMutationHookResult = ReturnType<typeof useUpdateCompany
export type UpdateCompanyMutationResult = Apollo.MutationResult<UpdateCompanyMutation>;
export type UpdateCompanyMutationOptions = Apollo.BaseMutationOptions<UpdateCompanyMutation, UpdateCompanyMutationVariables>;
export const InsertCompanyDocument = gql`
mutation InsertCompany($id: String!, $name: String!, $domain_name: String!, $created_at: DateTime, $address: String!, $employees: Int) {
mutation InsertCompany($id: String!, $name: String!, $domainName: String!, $createdAt: DateTime, $address: String!, $employees: Int) {
createOneCompany(
data: {id: $id, name: $name, domainName: $domain_name, createdAt: $created_at, address: $address, employees: $employees}
data: {id: $id, name: $name, domainName: $domainName, createdAt: $createdAt, address: $address, employees: $employees}
) {
address
created_at: createdAt
domain_name: domainName
createdAt
domainName
employees
id
name
@ -1665,8 +1665,8 @@ export type InsertCompanyMutationFn = Apollo.MutationFunction<InsertCompanyMutat
* variables: {
* id: // value for 'id'
* name: // value for 'name'
* domain_name: // value for 'domain_name'
* created_at: // value for 'created_at'
* domainName: // value for 'domainName'
* createdAt: // value for 'createdAt'
* address: // value for 'address'
* employees: // value for 'employees'
* },
@ -1721,11 +1721,11 @@ export const GetPeopleDocument = gql`
city
firstname
lastname
created_at: createdAt
createdAt
company {
id
name
domain_name: domainName
domainName
}
}
}
@ -1761,14 +1761,14 @@ export type GetPeopleQueryHookResult = ReturnType<typeof useGetPeopleQuery>;
export type GetPeopleLazyQueryHookResult = ReturnType<typeof useGetPeopleLazyQuery>;
export type GetPeopleQueryResult = Apollo.QueryResult<GetPeopleQuery, GetPeopleQueryVariables>;
export const UpdatePeopleDocument = gql`
mutation UpdatePeople($id: String, $firstname: String, $lastname: String, $phone: String, $city: String, $company_id: String, $email: String, $created_at: DateTime) {
mutation UpdatePeople($id: String, $firstname: String, $lastname: String, $phone: String, $city: String, $companyId: String, $email: String, $createdAt: DateTime) {
updateOnePerson(
where: {id: $id}
data: {city: {set: $city}, company: {connect: {id: $company_id}}, email: {set: $email}, firstname: {set: $firstname}, id: {set: $id}, lastname: {set: $lastname}, phone: {set: $phone}, createdAt: {set: $created_at}}
data: {city: {set: $city}, company: {connect: {id: $companyId}}, email: {set: $email}, firstname: {set: $firstname}, id: {set: $id}, lastname: {set: $lastname}, phone: {set: $phone}, createdAt: {set: $createdAt}}
) {
city
company {
domain_name: domainName
domainName
name
id
}
@ -1777,7 +1777,7 @@ export const UpdatePeopleDocument = gql`
id
lastname
phone
created_at: createdAt
createdAt
}
}
`;
@ -1801,9 +1801,9 @@ export type UpdatePeopleMutationFn = Apollo.MutationFunction<UpdatePeopleMutatio
* lastname: // value for 'lastname'
* phone: // value for 'phone'
* city: // value for 'city'
* company_id: // value for 'company_id'
* companyId: // value for 'companyId'
* email: // value for 'email'
* created_at: // value for 'created_at'
* createdAt: // value for 'createdAt'
* },
* });
*/
@ -1815,13 +1815,13 @@ export type UpdatePeopleMutationHookResult = ReturnType<typeof useUpdatePeopleMu
export type UpdatePeopleMutationResult = Apollo.MutationResult<UpdatePeopleMutation>;
export type UpdatePeopleMutationOptions = Apollo.BaseMutationOptions<UpdatePeopleMutation, UpdatePeopleMutationVariables>;
export const InsertPersonDocument = gql`
mutation InsertPerson($id: String!, $firstname: String!, $lastname: String!, $phone: String!, $city: String!, $email: String!, $created_at: DateTime) {
mutation InsertPerson($id: String!, $firstname: String!, $lastname: String!, $phone: String!, $city: String!, $email: String!, $createdAt: DateTime) {
createOnePerson(
data: {id: $id, firstname: $firstname, lastname: $lastname, phone: $phone, city: $city, email: $email, createdAt: $created_at}
data: {id: $id, firstname: $firstname, lastname: $lastname, phone: $phone, city: $city, email: $email, createdAt: $createdAt}
) {
city
company {
domain_name: domainName
domainName
name
id
}
@ -1830,7 +1830,7 @@ export const InsertPersonDocument = gql`
id
lastname
phone
created_at: createdAt
createdAt
}
}
`;
@ -1855,7 +1855,7 @@ export type InsertPersonMutationFn = Apollo.MutationFunction<InsertPersonMutatio
* phone: // value for 'phone'
* city: // value for 'city'
* email: // value for 'email'
* created_at: // value for 'created_at'
* createdAt: // value for 'createdAt'
* },
* });
*/
@ -2018,7 +2018,7 @@ export const SearchQueryDocument = gql`
searchResults: companies(where: $where, take: $limit) {
id
name
domain_name: domainName
domainName: domainName
}
}
`;
@ -2057,11 +2057,11 @@ export const GetCurrentUserDocument = gql`
id
email
displayName
workspace_member: WorkspaceMember {
workspaceMember: WorkspaceMember {
workspace {
id
domain_name: domainName
display_name: displayName
domainName
displayName
logo
}
}

View File

@ -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);
});

View File

@ -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);
});

View File

@ -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);
});

View File

@ -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',
});

View File

@ -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',
});

View File

@ -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',
});

View File

@ -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',
});

View File

@ -61,7 +61,7 @@ function Companies() {
employees: null,
address: '',
pipes: [],
creationDate: new Date(),
createdAt: new Date(),
accountOwner: null,
__typename: 'companies',
};

View File

@ -1,6 +1,6 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`Companies Filter should render the filter company_employees 1`] = `
exports[`Companies Filter should render the filter employees 1`] = `
Object {
"employees": Object {
"gte": 2,
@ -8,7 +8,7 @@ Object {
}
`;
exports[`Companies Filter should render the filter company_name 1`] = `
exports[`Companies Filter should render the filter name 1`] = `
Object {
"name": Object {
"contains": "%name%",

View File

@ -126,16 +126,16 @@ export const useCompaniesColumns = () => {
),
size: 170,
}),
columnHelper.accessor('creationDate', {
columnHelper.accessor('createdAt', {
header: () => (
<ColumnHead viewName="Creation" viewIcon={<TbCalendar size={16} />} />
),
cell: (props) => (
<EditableDate
value={props.row.original.creationDate || new Date()}
value={props.row.original.createdAt || new Date()}
changeHandler={(value: Date) => {
const company = props.row.original;
company.creationDate = value;
company.createdAt = value;
updateCompany(company);
}}
/>

View File

@ -13,7 +13,7 @@ import { User, mapToUser } from '../../interfaces/entities/user.interface';
import { QueryMode } from '../../generated/graphql';
export const nameFilter = {
key: 'company_name',
key: 'name',
label: 'Company',
icon: <TbBuilding size={16} />,
type: 'text',
@ -43,7 +43,7 @@ export const nameFilter = {
} satisfies FilterConfigType<Company, string>;
export const employeesFilter = {
key: 'company_employees',
key: 'employees',
label: 'Employees',
icon: <TbSum size={16} />,
type: 'text',
@ -70,7 +70,7 @@ export const employeesFilter = {
} satisfies FilterConfigType<Company, string>;
export const urlFilter = {
key: 'company_domain_name',
key: 'domainName',
label: 'Url',
icon: <TbLink size={16} />,
type: 'text',
@ -103,7 +103,7 @@ export const urlFilter = {
} satisfies FilterConfigType<Company, string>;
export const addressFilter = {
key: 'company_address',
key: 'address',
label: 'Address',
icon: <TbMapPin size={16} />,
type: 'text',
@ -132,8 +132,8 @@ export const addressFilter = {
],
} satisfies FilterConfigType<Company, string>;
export const creationDateFilter = {
key: 'company_created_at',
export const ccreatedAtFilter = {
key: 'createdAt',
label: 'Created At',
icon: <TbCalendar size={16} />,
type: 'date',
@ -160,7 +160,7 @@ export const creationDateFilter = {
} satisfies FilterConfigType<Company, string>;
export const accountOwnerFilter = {
key: 'account_owner_name',
key: 'accountOwner',
label: 'Account Owner',
icon: <TbUser size={16} />,
type: 'relation',
@ -207,6 +207,6 @@ export const availableFilters = [
employeesFilter,
urlFilter,
addressFilter,
creationDateFilter,
ccreatedAtFilter,
accountOwnerFilter,
];

View File

@ -64,7 +64,7 @@ function People() {
phone: '',
company: null,
pipes: [],
creationDate: new Date(),
createdAt: new Date(),
city: '',
};

View File

@ -103,16 +103,16 @@ export const usePeopleColumns = () => {
),
size: 130,
}),
columnHelper.accessor('creationDate', {
columnHelper.accessor('createdAt', {
header: () => (
<ColumnHead viewName="Creation" viewIcon={<TbCalendar size={16} />} />
),
cell: (props) => (
<EditableDate
value={props.row.original.creationDate || new Date()}
value={props.row.original.createdAt || new Date()}
changeHandler={(value: Date) => {
const person = props.row.original;
person.creationDate = value;
person.createdAt = value;
updatePerson(person);
}}
/>

View File

@ -162,8 +162,8 @@ export const phoneFilter = {
],
} satisfies FilterConfigType<Person, string>;
export const creationDateFilter = {
key: 'person_created_at',
export const createdAtFilter = {
key: 'createdAt',
label: 'Created At',
icon: <TbCalendar size={16} />,
type: 'date',
@ -224,6 +224,6 @@ export const availableFilters = [
emailFilter,
companyFilter,
phoneFilter,
creationDateFilter,
createdAtFilter,
cityFilter,
] satisfies FilterConfigType<Person>[];

View File

@ -6,13 +6,13 @@ describe('reduceSortsToOrderBy', () => {
const sorts = [
{ key: 'name', label: 'name', order: 'asc', _type: 'default_sort' },
{
key: 'domain_name',
label: 'domain_name',
key: 'domainName',
label: 'domainName',
order: 'desc',
_type: 'default_sort',
},
] satisfies CompaniesSelectedSortType[];
const result = reduceSortsToOrderBy(sorts);
expect(result).toEqual([{ name: 'asc' }, { domain_name: 'desc' }]);
expect(result).toEqual([{ name: 'asc' }, { domainName: 'desc' }]);
});
});

View File

@ -16,12 +16,12 @@ export const GET_COMPANIES = gql`
) {
companies(orderBy: $orderBy, where: $where) {
id
domain_name: domainName
domainName
name
created_at: createdAt
createdAt
address
employees
account_owner: accountOwner {
accountOwner {
id
email
displayName

View File

@ -9,31 +9,31 @@ export const UPDATE_COMPANY = gql`
mutation UpdateCompany(
$id: String
$name: String
$domain_name: String
$account_owner_id: String
$created_at: DateTime
$domainName: String
$accountOwnerId: String
$createdAt: DateTime
$address: String
$employees: Int
) {
updateOneCompany(
where: { id: $id }
data: {
accountOwner: { connect: { id: $account_owner_id } }
accountOwner: { connect: { id: $accountOwnerId } }
address: { set: $address }
domainName: { set: $domain_name }
domainName: { set: $domainName }
employees: { set: $employees }
name: { set: $name }
createdAt: { set: $created_at }
createdAt: { set: $createdAt }
}
) {
accountOwner {
id
email
display_name: displayName
displayName
}
address
created_at: createdAt
domain_name: domainName
createdAt
domainName
employees
id
name
@ -45,8 +45,8 @@ export const INSERT_COMPANY = gql`
mutation InsertCompany(
$id: String!
$name: String!
$domain_name: String!
$created_at: DateTime
$domainName: String!
$createdAt: DateTime
$address: String!
$employees: Int
) {
@ -54,15 +54,15 @@ export const INSERT_COMPANY = gql`
data: {
id: $id
name: $name
domainName: $domain_name
createdAt: $created_at
domainName: $domainName
createdAt: $createdAt
address: $address
employees: $employees
}
) {
address
created_at: createdAt
domain_name: domainName
createdAt
domainName
employees
id
name

View File

@ -41,7 +41,7 @@ it('updates a person', async () => {
icon: '!',
},
],
creationDate: new Date(),
createdAt: new Date(),
city: 'San Francisco',
__typename: 'people',
});

View File

@ -22,11 +22,11 @@ export const GET_PEOPLE = gql`
city
firstname
lastname
created_at: createdAt
createdAt
company {
id
name
domain_name: domainName
domainName
}
}
}

View File

@ -12,26 +12,26 @@ export const UPDATE_PERSON = gql`
$lastname: String
$phone: String
$city: String
$company_id: String
$companyId: String
$email: String
$created_at: DateTime
$createdAt: DateTime
) {
updateOnePerson(
where: { id: $id }
data: {
city: { set: $city }
company: { connect: { id: $company_id } }
company: { connect: { id: $companyId } }
email: { set: $email }
firstname: { set: $firstname }
id: { set: $id }
lastname: { set: $lastname }
phone: { set: $phone }
createdAt: { set: $created_at }
createdAt: { set: $createdAt }
}
) {
city
company {
domain_name: domainName
domainName
name
id
}
@ -40,7 +40,7 @@ export const UPDATE_PERSON = gql`
id
lastname
phone
created_at: createdAt
createdAt
}
}
`;
@ -53,7 +53,7 @@ export const INSERT_PERSON = gql`
$phone: String!
$city: String!
$email: String!
$created_at: DateTime
$createdAt: DateTime
) {
createOnePerson(
data: {
@ -63,12 +63,12 @@ export const INSERT_PERSON = gql`
phone: $phone
city: $city
email: $email
createdAt: $created_at
createdAt: $createdAt
}
) {
city
company {
domain_name: domainName
domainName
name
id
}
@ -77,7 +77,7 @@ export const INSERT_PERSON = gql`
id
lastname
phone
created_at: createdAt
createdAt
}
}
`;

View File

@ -44,7 +44,7 @@ export const SEARCH_COMPANY_QUERY = gql`
searchResults: companies(where: $where, take: $limit) {
id
name
domain_name: domainName
domainName
}
}
`;

View File

@ -7,11 +7,11 @@ export const GET_CURRENT_USER = gql`
id
email
displayName
workspace_member: WorkspaceMember {
workspaceMember: WorkspaceMember {
workspace {
id
domain_name: domainName
display_name: displayName
domainName
displayName
logo
}
}

View File

@ -3,72 +3,72 @@ import { GraphqlQueryCompany } from '../../interfaces/entities/company.interface
export const mockCompaniesData: Array<GraphqlQueryCompany> = [
{
id: '89bb825c-171e-4bcc-9cf7-43448d6fb278',
domain_name: 'airbnb.com',
domainName: 'airbnb.com',
name: 'Airbnb',
created_at: '2023-04-26T10:08:54.724515+00:00',
createdAt: '2023-04-26T10:08:54.724515+00:00',
address: '17 rue de clignancourt',
employees: 12,
account_owner: null,
accountOwner: null,
__typename: 'companies',
},
{
id: 'b396e6b9-dc5c-4643-bcff-61b6cf7523ae',
domain_name: 'aircall.io',
domainName: 'aircall.io',
name: 'Aircall',
created_at: '2023-04-26T10:12:42.33625+00:00',
createdAt: '2023-04-26T10:12:42.33625+00:00',
address: '',
employees: 1,
account_owner: null,
accountOwner: null,
__typename: 'companies',
},
{
id: 'a674fa6c-1455-4c57-afaf-dd5dc086361d',
domain_name: 'algolia.com',
domainName: 'algolia.com',
name: 'Algolia',
created_at: '2023-04-26T10:10:32.530184+00:00',
createdAt: '2023-04-26T10:10:32.530184+00:00',
address: '',
employees: 1,
account_owner: null,
accountOwner: null,
__typename: 'companies',
},
{
id: 'b1cfd51b-a831-455f-ba07-4e30671e1dc3',
domain_name: 'apple.com',
domainName: 'apple.com',
name: 'Apple',
created_at: '2023-03-21T06:30:25.39474+00:00',
createdAt: '2023-03-21T06:30:25.39474+00:00',
address: '',
employees: 10,
account_owner: null,
accountOwner: null,
__typename: 'companies',
},
{
id: '5c21e19e-e049-4393-8c09-3e3f8fb09ecb',
domain_name: 'qonto.com',
domainName: 'qonto.com',
name: 'Qonto',
created_at: '2023-04-26T10:13:29.712485+00:00',
createdAt: '2023-04-26T10:13:29.712485+00:00',
address: '10 rue de la Paix',
employees: 1,
account_owner: null,
accountOwner: null,
__typename: 'companies',
},
{
id: '9d162de6-cfbf-4156-a790-e39854dcd4eb',
domain_name: 'facebook.com',
domainName: 'facebook.com',
name: 'Facebook',
created_at: '2023-04-26T10:09:25.656555+00:00',
createdAt: '2023-04-26T10:09:25.656555+00:00',
address: '',
employees: 1,
account_owner: null,
accountOwner: null,
__typename: 'companies',
},
{
id: '9d162de6-cfbf-4156-a790-e39854dcd4eb',
domain_name: 'sequoia.com',
domainName: 'sequoia.com',
name: 'Sequoia',
created_at: '2023-04-26T10:09:25.656555+00:00',
createdAt: '2023-04-26T10:09:25.656555+00:00',
address: '',
employees: 1,
account_owner: null,
accountOwner: null,
__typename: 'companies',
},
];

View File

@ -10,11 +10,11 @@ export const mockedPeopleData: Array<GraphqlQueryPerson> = [
company: {
id: '7dfbc3f7-6e5e-4128-957e-8d86808cdf6c',
name: 'Qonto',
domain_name: 'qonto.com',
domainName: 'qonto.com',
__typename: 'Company',
},
phone: '06 12 34 56 78',
created_at: '2023-04-20T13:20:09.158312+00:00',
createdAt: '2023-04-20T13:20:09.158312+00:00',
city: 'Paris',
},
@ -27,11 +27,11 @@ export const mockedPeopleData: Array<GraphqlQueryPerson> = [
company: {
id: '7dfbc3f7-6e5e-4128-957e-8d86808cdf6e',
name: 'LinkedIn',
domain_name: 'linkedin.com',
domainName: 'linkedin.com',
__typename: 'Company',
},
phone: '06 12 34 56 78',
created_at: '2023-04-20T13:20:09.158312+00:00',
createdAt: '2023-04-20T13:20:09.158312+00:00',
city: 'Paris',
},
@ -44,11 +44,11 @@ export const mockedPeopleData: Array<GraphqlQueryPerson> = [
company: {
id: '7dfbc3f7-6e5e-4128-957e-8d86808cdf6g',
name: 'Sequoia',
domain_name: 'sequoiacap.com',
domainName: 'sequoiacap.com',
__typename: 'Company',
},
phone: '06 12 34 56 78',
created_at: '2023-04-20T13:20:09.158312+00:00',
createdAt: '2023-04-20T13:20:09.158312+00:00',
city: 'Paris',
},
@ -62,11 +62,11 @@ export const mockedPeopleData: Array<GraphqlQueryPerson> = [
company: {
id: '7dfbc3f7-6e5e-4128-957e-8d86808cdf6i',
name: 'Facebook',
domain_name: 'facebook.com',
domainName: 'facebook.com',
__typename: 'Company',
},
phone: '06 12 34 56 78',
created_at: '2023-04-20T13:20:09.158312+00:00',
createdAt: '2023-04-20T13:20:09.158312+00:00',
city: 'Paris',
},