Skip to content

Commit

Permalink
Merge pull request #29 from agokrim/Resolve-jobFom-State-Issue
Browse files Browse the repository at this point in the history
Resolve the state issue : when editing a job we get the last job edited
  • Loading branch information
ManiruzzamanAkash authored Dec 20, 2024
2 parents f53b354 + 246916f commit 3693936
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/components/jobs/JobForm.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
/**
* External dependencies.
*/
import { useEffect } from '@wordpress/element';
import { useParams } from 'react-router-dom';
import { useSelect, useDispatch } from '@wordpress/data';
import { __ } from '@wordpress/i18n';

Expand All @@ -21,6 +23,9 @@ type Props = {

export default function JobForm({ job }: Props) {
const dispatch = useDispatch();
const { id } = useParams();
const { invalidateResolutionForStoreSelector } = useDispatch(jobStore);

const jobTypes: Array<Select2SingleRow> = useSelect(
(select) => select(jobStore).getJobTypes(),
[]
Expand All @@ -36,6 +41,12 @@ export default function JobForm({ job }: Props) {
[]
);

useEffect(() => {
if (parseInt(id + '') !== form.id) {
invalidateResolutionForStoreSelector('getJobDetail');
}
}, [id, invalidateResolutionForStoreSelector]);

const loadingJobs: boolean = useSelect(
(select) => select(jobStore).getLoadingJobs(),
[]
Expand Down

0 comments on commit 3693936

Please sign in to comment.