In place edit company info (#90)

* Add update company functionality

* Fix padding in cells with chips

* Add icons to table headers
This commit is contained in:
Anders Borch
2023-04-28 08:50:04 +02:00
committed by GitHub
parent d5c1bd6365
commit 27070b374e
6 changed files with 92 additions and 26 deletions

View File

@ -1 +1,2 @@
export * from './select';
export * from './update';

View File

@ -0,0 +1,50 @@
import { FetchResult, gql } from '@apollo/client';
import { Company, mapGqlCompany } from '../../interfaces/company.interface';
import { apiClient } from '../../apollo';
export const UPDATE_COMPANY = gql`
mutation UpdateCompany(
$id: uuid
$name: String
$domain_name: String
$account_owner_id: uuid
$address: String
$employees: Int
) {
update_companies(
where: { id: { _eq: $id } }
_set: {
account_owner_id: $account_owner_id
address: $address
domain_name: $domain_name
employees: $employees
name: $name
}
) {
affected_rows
returning {
account_owner {
id
email
displayName
}
address
created_at
domain_name
employees
id
name
}
}
}
`;
export async function updateCompany(
company: Company,
): Promise<FetchResult<Company>> {
const result = await apiClient.mutate({
mutation: UPDATE_COMPANY,
variables: mapGqlCompany(company),
});
return result;
}