Companies table (#79)

* Add columns to companies:
* account_owner_id
* employees
* address

Add foreign key constraint companies_account_owner_id_fkey
to auth.users.id

* Add select permissions to:
* account_owner_id
* employees
* address

Add relationship between companies and auth.users.

* Update Companies interface to include:
* account_owner_id
* employees
* address

Opportunity is expected to be replace by actual opportunity in a separate PR.

* Add GetCompanies query

* Add initial companies table

* Update test to use mock apollo provider

* Update to match changed company column names

* Add company interface mapping tests

* Test entire object

* Add test for companies being rendered in table.

* Add test for sorting reduce.

* Fix prettier errors
This commit is contained in:
Anders Borch
2023-04-27 12:46:43 +02:00
committed by GitHub
parent 42bf653e4a
commit d4b1b2f661
21 changed files with 450 additions and 12 deletions

View File

@ -2,6 +2,9 @@ import { MemoryRouter } from 'react-router-dom';
import Companies from '../Companies';
import { ThemeProvider } from '@emotion/react';
import { lightTheme } from '../../../layout/styles/themes';
import { GET_COMPANIES } from '../../../services/companies';
import { defaultData } from './mock-data';
import { MockedProvider } from '@apollo/client/testing';
const component = {
title: 'Companies',
@ -10,10 +13,28 @@ const component = {
export default component;
const mocks = [
{
request: {
query: GET_COMPANIES,
variables: {
orderBy: [{ name: 'asc' }],
},
},
result: {
data: {
companies: defaultData,
},
},
},
];
export const CompaniesDefault = () => (
<ThemeProvider theme={lightTheme}>
<MemoryRouter>
<Companies />
</MemoryRouter>
</ThemeProvider>
<MockedProvider mocks={mocks}>
<ThemeProvider theme={lightTheme}>
<MemoryRouter>
<Companies />
</MemoryRouter>
</ThemeProvider>
</MockedProvider>
);

View File

@ -0,0 +1,17 @@
import { GraphqlQueryCompany } from '../../../interfaces/company.interface';
export const defaultData: Array<GraphqlQueryCompany> = [
{
id: 'f121ab32-fac4-4b8c-9a3d-150c877319c2',
name: 'ACME',
domain_name: 'example.com',
account_owner: {
id: '91510aa5-ede6-451f-8029-a7fa69e4bad6',
email: 'john@example.com',
displayName: 'John Doe',
},
employees: 10,
address: '1 Infinity Loop, 95014 Cupertino, California',
created_at: new Date().toUTCString(),
},
];