Add dueDate and assignee on notes (#988)
* Add dueDate and assignee on notes * Fix tests * Fix tests
This commit is contained in:
@ -1,6 +1,5 @@
|
||||
import { useEffect, useState } from 'react';
|
||||
import { useState } from 'react';
|
||||
|
||||
import { EditableField } from '@/ui/editable-field/components/EditableField';
|
||||
import { FieldContext } from '@/ui/editable-field/states/FieldContext';
|
||||
import { RecoilScope } from '@/ui/recoil-scope/components/RecoilScope';
|
||||
import { Person, useUpdateOnePersonMutation } from '~/generated/graphql';
|
||||
@ -21,56 +20,40 @@ export function PeopleFullNameEditableField({ people }: OwnProps) {
|
||||
|
||||
const [updatePeople] = useUpdateOnePersonMutation();
|
||||
|
||||
useEffect(() => {
|
||||
setInternalValueFirstName(people.firstName);
|
||||
setInternalValueLastName(people.lastName);
|
||||
}, [people.firstName, people.lastName]);
|
||||
|
||||
async function handleChange(
|
||||
newValueFirstName: string,
|
||||
newValueLastName: string,
|
||||
) {
|
||||
setInternalValueFirstName(newValueFirstName);
|
||||
setInternalValueLastName(newValueLastName);
|
||||
handleSubmit(newValueFirstName, newValueLastName);
|
||||
}
|
||||
|
||||
async function handleSubmit() {
|
||||
async function handleSubmit(
|
||||
newValueFirstName: string,
|
||||
newValueLastName: string,
|
||||
) {
|
||||
await updatePeople({
|
||||
variables: {
|
||||
where: {
|
||||
id: people.id,
|
||||
},
|
||||
data: {
|
||||
firstName: internalValueFirstName ?? '',
|
||||
lastName: internalValueLastName ?? '',
|
||||
firstName: newValueFirstName ?? '',
|
||||
lastName: newValueLastName ?? '',
|
||||
},
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
async function handleCancel() {
|
||||
setInternalValueFirstName(people.firstName);
|
||||
setInternalValueLastName(people.lastName);
|
||||
}
|
||||
|
||||
return (
|
||||
<RecoilScope SpecificContext={FieldContext}>
|
||||
<EditableField
|
||||
onSubmit={handleSubmit}
|
||||
onCancel={handleCancel}
|
||||
editModeContent={
|
||||
<InplaceInputDoubleText
|
||||
firstValuePlaceholder={'First name'}
|
||||
secondValuePlaceholder={'Last name'}
|
||||
firstValue={internalValueFirstName ?? ''}
|
||||
secondValue={internalValueLastName ?? ''}
|
||||
onChange={handleChange}
|
||||
/>
|
||||
}
|
||||
displayModeContent={`${internalValueFirstName} ${internalValueLastName}`}
|
||||
isDisplayModeContentEmpty={
|
||||
!(internalValueFirstName !== '') && !(internalValueLastName !== '')
|
||||
}
|
||||
<InplaceInputDoubleText
|
||||
firstValuePlaceholder={'First name'}
|
||||
secondValuePlaceholder={'Last name'}
|
||||
firstValue={internalValueFirstName ?? ''}
|
||||
secondValue={internalValueLastName ?? ''}
|
||||
onChange={handleChange}
|
||||
/>
|
||||
</RecoilScope>
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user