Fetch workspace and user from database (#94)

Co-authored-by: Charles Bochet <charles@twenty.com>
This commit is contained in:
Charles Bochet
2023-05-04 11:09:06 +02:00
committed by GitHub
parent 1490f986f2
commit 27d5edc031
18 changed files with 353 additions and 50 deletions

View File

@ -25,8 +25,7 @@ describe('mapCompany', () => {
'7af20dea-0412-4c4c-8b13-d6f0e6e09e87',
);
expect(company.accountOwner?.email).toBe('john@example.com');
expect(company.accountOwner?.first_name).toBe('John');
expect(company.accountOwner?.last_name).toBe('Doe');
expect(company.accountOwner?.displayName).toBe('John Doe');
expect(company.employees).toBe(10);
expect(company.address).toBe(
'1 Infinite Loop, 95014 Cupertino, California, USA',
@ -68,8 +67,7 @@ describe('mapCompany', () => {
accountOwner: {
id: '522d4ec4-c46b-4360-a0a7-df8df170be81',
email: 'john@example.com',
first_name: 'John',
last_name: 'Doe',
displayName: 'John Doe',
},
creationDate: now,
});

View File

@ -50,11 +50,7 @@ export const mapCompany = (company: GraphqlQueryCompany): Company => ({
? {
id: company.account_owner.id,
email: company.account_owner.email,
first_name: company.account_owner.displayName.split(' ').shift() || '',
last_name: company.account_owner.displayName
.split(' ')
.slice(1)
.join(' '),
displayName: company.account_owner.displayName,
}
: undefined,
creationDate: new Date(company.created_at),

View File

@ -1,6 +1,15 @@
import { GraphqlQueryAccountOwner } from './company.interface';
import { Workspace } from './workspace.interface';
export interface User {
id: string;
email: string;
first_name: string;
last_name: string;
displayName: string;
workspace_member?: {
workspace: Workspace;
};
}
export const mapUser = (user: GraphqlQueryAccountOwner): User => ({
...user,
});

View File

@ -1,5 +1,5 @@
export interface Workspace {
id: string;
name: string;
display_name: string;
logo: string;
}