Add contract dates to people
Signed-off-by: Sacha Al Himdani <sacha@getprobo.com>
This commit is contained in:
@@ -25,6 +25,8 @@ const createPeopleMutation = graphql`
|
||||
primaryEmailAddress
|
||||
additionalEmailAddresses
|
||||
kind
|
||||
contractStartDate
|
||||
contractEndDate
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -77,6 +79,8 @@ function NewPeopleViewContent() {
|
||||
primaryEmailAddress: "",
|
||||
additionalEmailAddresses: [] as string[],
|
||||
kind: "EMPLOYEE" as "EMPLOYEE" | "CONTRACTOR" | "SERVICE_ACCOUNT",
|
||||
contractStartDate: "",
|
||||
contractEndDate: "",
|
||||
});
|
||||
|
||||
const handleFieldChange = (field: keyof typeof formData, value: unknown) => {
|
||||
@@ -129,6 +133,8 @@ function NewPeopleViewContent() {
|
||||
primaryEmailAddress: formData.primaryEmailAddress,
|
||||
additionalEmailAddresses: formData.additionalEmailAddresses,
|
||||
kind: formData.kind,
|
||||
contractStartDate: formData.contractStartDate ? new Date(formData.contractStartDate).toISOString() : null,
|
||||
contractEndDate: formData.contractEndDate ? new Date(formData.contractEndDate).toISOString() : null,
|
||||
},
|
||||
},
|
||||
onCompleted: () => {
|
||||
@@ -276,6 +282,20 @@ function NewPeopleViewContent() {
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<EditableField
|
||||
label="Contract Start Date"
|
||||
value={formData.contractStartDate}
|
||||
type="date"
|
||||
onChange={(value) => handleFieldChange("contractStartDate", value)}
|
||||
/>
|
||||
|
||||
<EditableField
|
||||
label="Contract End Date"
|
||||
value={formData.contractEndDate}
|
||||
type="date"
|
||||
onChange={(value) => handleFieldChange("contractEndDate", value)}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</Card>
|
||||
|
||||
@@ -35,6 +35,8 @@ const peopleViewQuery = graphql`
|
||||
primaryEmailAddress
|
||||
additionalEmailAddresses
|
||||
kind
|
||||
contractStartDate
|
||||
contractEndDate
|
||||
createdAt
|
||||
updatedAt
|
||||
}
|
||||
@@ -51,6 +53,8 @@ const updatePeopleMutation = graphql`
|
||||
primaryEmailAddress
|
||||
additionalEmailAddresses
|
||||
kind
|
||||
contractStartDate
|
||||
contractEndDate
|
||||
updatedAt
|
||||
}
|
||||
}
|
||||
@@ -100,19 +104,34 @@ function PeopleViewContent({
|
||||
primaryEmailAddress: data.node.primaryEmailAddress || "",
|
||||
additionalEmailAddresses: data.node.additionalEmailAddresses || [],
|
||||
kind: data.node.kind,
|
||||
contractStartDate: data.node.contractStartDate
|
||||
? new Date(data.node.contractStartDate).toISOString().split('T')[0]
|
||||
: "",
|
||||
contractEndDate: data.node.contractEndDate
|
||||
? new Date(data.node.contractEndDate).toISOString().split('T')[0]
|
||||
: "",
|
||||
});
|
||||
const [commit] = useMutation(updatePeopleMutation);
|
||||
const [, loadQuery] = useQueryLoader<PeopleViewQueryType>(peopleViewQuery);
|
||||
const { toast } = useToast();
|
||||
|
||||
const hasChanges = editedFields.size > 0;
|
||||
|
||||
const handleSave = useCallback(() => {
|
||||
const formattedData = {
|
||||
...formData,
|
||||
contractStartDate: formData.contractStartDate
|
||||
? new Date(formData.contractStartDate).toISOString()
|
||||
: null,
|
||||
contractEndDate: formData.contractEndDate
|
||||
? new Date(formData.contractEndDate).toISOString()
|
||||
: null,
|
||||
};
|
||||
|
||||
commit({
|
||||
variables: {
|
||||
input: {
|
||||
id: data.node.id,
|
||||
...formData,
|
||||
...formattedData,
|
||||
},
|
||||
},
|
||||
onCompleted: () => {
|
||||
@@ -157,6 +176,12 @@ function PeopleViewContent({
|
||||
primaryEmailAddress: data.node.primaryEmailAddress || "",
|
||||
additionalEmailAddresses: data.node.additionalEmailAddresses || [],
|
||||
kind: data.node.kind,
|
||||
contractStartDate: data.node.contractStartDate
|
||||
? new Date(data.node.contractStartDate).toISOString().split('T')[0]
|
||||
: "",
|
||||
contractEndDate: data.node.contractEndDate
|
||||
? new Date(data.node.contractEndDate).toISOString().split('T')[0]
|
||||
: "",
|
||||
});
|
||||
setEditedFields(new Set());
|
||||
};
|
||||
@@ -256,6 +281,29 @@ function PeopleViewContent({
|
||||
</SelectContent>
|
||||
</Select>
|
||||
</div>
|
||||
<EditableField
|
||||
label="Contract Start Date"
|
||||
value={formData.contractStartDate || ""}
|
||||
type="date"
|
||||
onChange={(value) =>
|
||||
handleFieldChange(
|
||||
"contractStartDate" as keyof typeof formData,
|
||||
value,
|
||||
)
|
||||
}
|
||||
/>
|
||||
|
||||
<EditableField
|
||||
label="Contract End Date"
|
||||
value={formData.contractEndDate || ""}
|
||||
type="date"
|
||||
onChange={(value) =>
|
||||
handleFieldChange(
|
||||
"contractEndDate" as keyof typeof formData,
|
||||
value,
|
||||
)
|
||||
}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</Card>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* @generated SignedSource<<76fb19bfca9165a9c40d0b306e53c1de>>
|
||||
* @generated SignedSource<<ca6b9dbed6835dd4a9705fe3a90c4b19>>
|
||||
* @lightSyntaxTransform
|
||||
* @nogrep
|
||||
*/
|
||||
@@ -12,6 +12,8 @@ import { ConcreteRequest } from 'relay-runtime';
|
||||
export type PeopleKind = "CONTRACTOR" | "EMPLOYEE" | "SERVICE_ACCOUNT";
|
||||
export type CreatePeopleInput = {
|
||||
additionalEmailAddresses?: ReadonlyArray<string> | null | undefined;
|
||||
contractEndDate?: string | null | undefined;
|
||||
contractStartDate?: string | null | undefined;
|
||||
fullName: string;
|
||||
kind: PeopleKind;
|
||||
organizationId: string;
|
||||
@@ -26,6 +28,8 @@ export type NewPeopleViewCreatePeopleMutation$data = {
|
||||
readonly peopleEdge: {
|
||||
readonly node: {
|
||||
readonly additionalEmailAddresses: ReadonlyArray<string>;
|
||||
readonly contractEndDate: string | null | undefined;
|
||||
readonly contractStartDate: string | null | undefined;
|
||||
readonly fullName: string;
|
||||
readonly id: string;
|
||||
readonly kind: PeopleKind;
|
||||
@@ -107,6 +111,20 @@ v3 = {
|
||||
"kind": "ScalarField",
|
||||
"name": "kind",
|
||||
"storageKey": null
|
||||
},
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "contractStartDate",
|
||||
"storageKey": null
|
||||
},
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "contractEndDate",
|
||||
"storageKey": null
|
||||
}
|
||||
],
|
||||
"storageKey": null
|
||||
@@ -180,16 +198,16 @@ return {
|
||||
]
|
||||
},
|
||||
"params": {
|
||||
"cacheID": "d9cfab5066a89013eef581dc016daf57",
|
||||
"cacheID": "85e329e6fd79fbc4094dd8bf03223456",
|
||||
"id": null,
|
||||
"metadata": {},
|
||||
"name": "NewPeopleViewCreatePeopleMutation",
|
||||
"operationKind": "mutation",
|
||||
"text": "mutation NewPeopleViewCreatePeopleMutation(\n $input: CreatePeopleInput!\n) {\n createPeople(input: $input) {\n peopleEdge {\n node {\n id\n fullName\n primaryEmailAddress\n additionalEmailAddresses\n kind\n }\n }\n }\n}\n"
|
||||
"text": "mutation NewPeopleViewCreatePeopleMutation(\n $input: CreatePeopleInput!\n) {\n createPeople(input: $input) {\n peopleEdge {\n node {\n id\n fullName\n primaryEmailAddress\n additionalEmailAddresses\n kind\n contractStartDate\n contractEndDate\n }\n }\n }\n}\n"
|
||||
}
|
||||
};
|
||||
})();
|
||||
|
||||
(node as any).hash = "fd4b7a5907702712c654005de2a98996";
|
||||
(node as any).hash = "6afa87e237975e9574e42b46139bef29";
|
||||
|
||||
export default node;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* @generated SignedSource<<e7d3adf5f8472b181a64cfa98964984c>>
|
||||
* @generated SignedSource<<891422de01f5f1b88dc80d294c116c24>>
|
||||
* @lightSyntaxTransform
|
||||
* @nogrep
|
||||
*/
|
||||
@@ -16,6 +16,8 @@ export type PeopleViewQuery$variables = {
|
||||
export type PeopleViewQuery$data = {
|
||||
readonly node: {
|
||||
readonly additionalEmailAddresses?: ReadonlyArray<string>;
|
||||
readonly contractEndDate?: string | null | undefined;
|
||||
readonly contractStartDate?: string | null | undefined;
|
||||
readonly createdAt?: string;
|
||||
readonly fullName?: string;
|
||||
readonly id?: string;
|
||||
@@ -83,10 +85,24 @@ v7 = {
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "createdAt",
|
||||
"name": "contractStartDate",
|
||||
"storageKey": null
|
||||
},
|
||||
v8 = {
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "contractEndDate",
|
||||
"storageKey": null
|
||||
},
|
||||
v9 = {
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "createdAt",
|
||||
"storageKey": null
|
||||
},
|
||||
v10 = {
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
@@ -117,7 +133,9 @@ return {
|
||||
(v5/*: any*/),
|
||||
(v6/*: any*/),
|
||||
(v7/*: any*/),
|
||||
(v8/*: any*/)
|
||||
(v8/*: any*/),
|
||||
(v9/*: any*/),
|
||||
(v10/*: any*/)
|
||||
],
|
||||
"type": "People",
|
||||
"abstractKey": null
|
||||
@@ -159,7 +177,9 @@ return {
|
||||
(v5/*: any*/),
|
||||
(v6/*: any*/),
|
||||
(v7/*: any*/),
|
||||
(v8/*: any*/)
|
||||
(v8/*: any*/),
|
||||
(v9/*: any*/),
|
||||
(v10/*: any*/)
|
||||
],
|
||||
"type": "People",
|
||||
"abstractKey": null
|
||||
@@ -170,16 +190,16 @@ return {
|
||||
]
|
||||
},
|
||||
"params": {
|
||||
"cacheID": "fba00a5764659b366e4e11829d75854d",
|
||||
"cacheID": "1a6ca0fa62d60fd18c26a5e3c868f41f",
|
||||
"id": null,
|
||||
"metadata": {},
|
||||
"name": "PeopleViewQuery",
|
||||
"operationKind": "query",
|
||||
"text": "query PeopleViewQuery(\n $peopleId: ID!\n) {\n node(id: $peopleId) {\n __typename\n ... on People {\n id\n fullName\n primaryEmailAddress\n additionalEmailAddresses\n kind\n createdAt\n updatedAt\n }\n id\n }\n}\n"
|
||||
"text": "query PeopleViewQuery(\n $peopleId: ID!\n) {\n node(id: $peopleId) {\n __typename\n ... on People {\n id\n fullName\n primaryEmailAddress\n additionalEmailAddresses\n kind\n contractStartDate\n contractEndDate\n createdAt\n updatedAt\n }\n id\n }\n}\n"
|
||||
}
|
||||
};
|
||||
})();
|
||||
|
||||
(node as any).hash = "b7652de1ad8de6028f493255221f6ce5";
|
||||
(node as any).hash = "473792157216aa14cc6e4e3e0393090b";
|
||||
|
||||
export default node;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* @generated SignedSource<<552b78c5e34c5ce2065dd1190f47f632>>
|
||||
* @generated SignedSource<<86a82de5c4344cc14a120155388e4a6f>>
|
||||
* @lightSyntaxTransform
|
||||
* @nogrep
|
||||
*/
|
||||
@@ -12,6 +12,8 @@ import { ConcreteRequest } from 'relay-runtime';
|
||||
export type PeopleKind = "CONTRACTOR" | "EMPLOYEE" | "SERVICE_ACCOUNT";
|
||||
export type UpdatePeopleInput = {
|
||||
additionalEmailAddresses?: ReadonlyArray<string> | null | undefined;
|
||||
contractEndDate?: string | null | undefined;
|
||||
contractStartDate?: string | null | undefined;
|
||||
fullName?: string | null | undefined;
|
||||
id: string;
|
||||
kind?: PeopleKind | null | undefined;
|
||||
@@ -24,6 +26,8 @@ export type PeopleViewUpdatePeopleMutation$data = {
|
||||
readonly updatePeople: {
|
||||
readonly people: {
|
||||
readonly additionalEmailAddresses: ReadonlyArray<string>;
|
||||
readonly contractEndDate: string | null | undefined;
|
||||
readonly contractStartDate: string | null | undefined;
|
||||
readonly fullName: string;
|
||||
readonly id: string;
|
||||
readonly kind: PeopleKind;
|
||||
@@ -103,6 +107,20 @@ v1 = [
|
||||
"name": "kind",
|
||||
"storageKey": null
|
||||
},
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "contractStartDate",
|
||||
"storageKey": null
|
||||
},
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
"kind": "ScalarField",
|
||||
"name": "contractEndDate",
|
||||
"storageKey": null
|
||||
},
|
||||
{
|
||||
"alias": null,
|
||||
"args": null,
|
||||
@@ -135,16 +153,16 @@ return {
|
||||
"selections": (v1/*: any*/)
|
||||
},
|
||||
"params": {
|
||||
"cacheID": "d09fc02a745b951e278cd492343e49f1",
|
||||
"cacheID": "398ebbc7659400cbc5d0a750ee7e66b5",
|
||||
"id": null,
|
||||
"metadata": {},
|
||||
"name": "PeopleViewUpdatePeopleMutation",
|
||||
"operationKind": "mutation",
|
||||
"text": "mutation PeopleViewUpdatePeopleMutation(\n $input: UpdatePeopleInput!\n) {\n updatePeople(input: $input) {\n people {\n id\n fullName\n primaryEmailAddress\n additionalEmailAddresses\n kind\n updatedAt\n }\n }\n}\n"
|
||||
"text": "mutation PeopleViewUpdatePeopleMutation(\n $input: UpdatePeopleInput!\n) {\n updatePeople(input: $input) {\n people {\n id\n fullName\n primaryEmailAddress\n additionalEmailAddresses\n kind\n contractStartDate\n contractEndDate\n updatedAt\n }\n }\n}\n"
|
||||
}
|
||||
};
|
||||
})();
|
||||
|
||||
(node as any).hash = "15fece3e846bd713533b9e91a1ceffe2";
|
||||
(node as any).hash = "686c8546329ae29bd2880b0b1da9f20c";
|
||||
|
||||
export default node;
|
||||
|
||||
Reference in New Issue
Block a user