feat: disable atomic operation on nestjs graphql models (#751)

* feat: no atomic

* feat: update front not atomic operations

* feat: optional fields for person model & use proper gql type

* Fix bug display name

* Fix bug update user

* Fixed bug avatar URL

* Fixed display name on people cell

* Fix lint

* Fixed storybook display name

* Fix storybook requests

---------

Co-authored-by: Lucas Bordeau <bordeau.lucas@gmail.com>
This commit is contained in:
Jérémy M
2023-07-20 21:23:35 +02:00
committed by GitHub
parent 663c4d5c3f
commit 872ec9e6bb
58 changed files with 622 additions and 652 deletions

View File

@ -5,7 +5,7 @@ import { FieldContext } from '@/ui/editable-field/states/FieldContext';
import { IconMap } from '@/ui/icon';
import { InplaceInputText } from '@/ui/inplace-input/components/InplaceInputText';
import { RecoilScope } from '@/ui/recoil-scope/components/RecoilScope';
import { Company, useUpdateCompanyMutation } from '~/generated/graphql';
import { Company, useUpdateOneCompanyMutation } from '~/generated/graphql';
type OwnProps = {
company: Pick<Company, 'id' | 'address'>;
@ -14,7 +14,7 @@ type OwnProps = {
export function CompanyAddressEditableField({ company }: OwnProps) {
const [internalValue, setInternalValue] = useState(company.address);
const [updateCompany] = useUpdateCompanyMutation();
const [updateCompany] = useUpdateOneCompanyMutation();
useEffect(() => {
setInternalValue(company.address);
@ -27,8 +27,12 @@ export function CompanyAddressEditableField({ company }: OwnProps) {
async function handleSubmit() {
await updateCompany({
variables: {
id: company.id,
address: internalValue ?? '',
where: {
id: company.id,
},
data: {
address: internalValue ?? '',
},
},
});
}

View File

@ -5,7 +5,7 @@ import { FieldContext } from '@/ui/editable-field/states/FieldContext';
import { EditableFieldEditModeDate } from '@/ui/editable-field/variants/components/EditableFieldEditModeDate';
import { IconCalendar } from '@/ui/icon';
import { RecoilScope } from '@/ui/recoil-scope/components/RecoilScope';
import { Company, useUpdateCompanyMutation } from '~/generated/graphql';
import { Company, useUpdateOneCompanyMutation } from '~/generated/graphql';
import { formatToHumanReadableDate } from '~/utils';
import { parseDate } from '~/utils/date-utils';
@ -16,7 +16,7 @@ type OwnProps = {
export function CompanyCreatedAtEditableField({ company }: OwnProps) {
const [internalValue, setInternalValue] = useState(company.createdAt);
const [updateCompany] = useUpdateCompanyMutation();
const [updateCompany] = useUpdateOneCompanyMutation();
useEffect(() => {
setInternalValue(company.createdAt);
@ -29,8 +29,12 @@ export function CompanyCreatedAtEditableField({ company }: OwnProps) {
async function handleSubmit() {
await updateCompany({
variables: {
id: company.id,
createdAt: internalValue ?? '',
where: {
id: company.id,
},
data: {
createdAt: internalValue ?? '',
},
},
});
}

View File

@ -6,7 +6,7 @@ import { FieldContext } from '@/ui/editable-field/states/FieldContext';
import { IconLink } from '@/ui/icon';
import { InplaceInputText } from '@/ui/inplace-input/components/InplaceInputText';
import { RecoilScope } from '@/ui/recoil-scope/components/RecoilScope';
import { Company, useUpdateCompanyMutation } from '~/generated/graphql';
import { Company, useUpdateOneCompanyMutation } from '~/generated/graphql';
type OwnProps = {
company: Pick<Company, 'id' | 'domainName'>;
@ -15,7 +15,7 @@ type OwnProps = {
export function CompanyDomainNameEditableField({ company }: OwnProps) {
const [internalValue, setInternalValue] = useState(company.domainName);
const [updateCompany] = useUpdateCompanyMutation();
const [updateCompany] = useUpdateOneCompanyMutation();
useEffect(() => {
setInternalValue(company.domainName);
@ -28,8 +28,12 @@ export function CompanyDomainNameEditableField({ company }: OwnProps) {
async function handleSubmit() {
await updateCompany({
variables: {
id: company.id,
domainName: internalValue ?? '',
where: {
id: company.id,
},
data: {
domainName: internalValue ?? '',
},
},
});
}

View File

@ -5,7 +5,7 @@ import { FieldContext } from '@/ui/editable-field/states/FieldContext';
import { IconUsers } from '@/ui/icon';
import { InplaceInputText } from '@/ui/inplace-input/components/InplaceInputText';
import { RecoilScope } from '@/ui/recoil-scope/components/RecoilScope';
import { Company, useUpdateCompanyMutation } from '~/generated/graphql';
import { Company, useUpdateOneCompanyMutation } from '~/generated/graphql';
type OwnProps = {
company: Pick<Company, 'id' | 'employees'>;
@ -16,7 +16,7 @@ export function CompanyEmployeesEditableField({ company }: OwnProps) {
company.employees?.toString(),
);
const [updateCompany] = useUpdateCompanyMutation();
const [updateCompany] = useUpdateOneCompanyMutation();
useEffect(() => {
setInternalValue(company.employees?.toString());
@ -38,8 +38,12 @@ export function CompanyEmployeesEditableField({ company }: OwnProps) {
await updateCompany({
variables: {
id: company.id,
employees: numberValue,
where: {
id: company.id,
},
data: {
employees: numberValue,
},
},
});