diff --git a/client/src/components/shop-employees/shop-employees-add-vacation.component.jsx b/client/src/components/shop-employees/shop-employees-add-vacation.component.jsx index 29b7ad09f..e00e83c14 100644 --- a/client/src/components/shop-employees/shop-employees-add-vacation.component.jsx +++ b/client/src/components/shop-employees/shop-employees-add-vacation.component.jsx @@ -21,15 +21,21 @@ export default function ShopEmployeeAddVacation({ employee }) { logImEXEvent("employee_add_vacation"); setLoading(true); - let result; + if (!employee?.id) { + notification.error({ + title: t("employees.errors.adding", { message: "Employee not loaded yet." }) + }); + return; + } - result = await insertVacation({ - variables: { vacation: { ...values, employeeid: employee?.id } }, + setLoading(true); + const result = await insertVacation({ + variables: { vacation: { ...values, employeeid: employee.id } }, update(cache, { data }) { cache.modify({ id: cache.identify({ id: employee.id, __typename: "employees" }), fields: { - employee_vacations(ex) { + employee_vacations(ex = []) { return [data.insert_employee_vacation_one, ...ex]; } }