diff --git a/client/src/components/time-ticket-modal/time-ticket-modal.component.jsx b/client/src/components/time-ticket-modal/time-ticket-modal.component.jsx index fe2547b64..f1ce47b85 100644 --- a/client/src/components/time-ticket-modal/time-ticket-modal.component.jsx +++ b/client/src/components/time-ticket-modal/time-ticket-modal.component.jsx @@ -1,6 +1,7 @@ import { useLazyQuery } from "@apollo/client"; import { useTreatmentsWithConfig } from "@splitsoftware/splitio-react"; import { Card, Form, Input, InputNumber, Select, Space, Switch } from "antd"; +import { useEffect } from "react"; import { useTranslation } from "react-i18next"; import { connect } from "react-redux"; import { createStructuredSelector } from "reselect"; @@ -34,7 +35,9 @@ export function TimeTicketModalComponent({ authLevel, employeeAutoCompleteOptions, disabled, - employeeSelectDisabled + employeeSelectDisabled, + lineTicketRefreshKey, + isOpen }) { const { t } = useTranslation(); const { @@ -49,6 +52,18 @@ export function TimeTicketModalComponent({ fetchPolicy: "network-only", nextFetchPolicy: "network-only" }); + + // Watch the jobid field so we can refetch the bottom section without relying on jobid changes + const watchedJobId = Form.useWatch("jobid", form); + + useEffect(() => { + if (!isOpen) return; + if (!watchedJobId) return; + if (!lineTicketRefreshKey) return; + + loadLineTicketData({ variables: { id: watchedJobId } }); + }, [lineTicketRefreshKey, watchedJobId, isOpen]); + const CostCenterSelect = ({ emps, value, ...props }) => { return (