Use optimistic skip mutation across Jobs page actions
This commit is contained in:
parent
096ac21b19
commit
5ed9069813
@ -46,7 +46,10 @@ import {
|
||||
safeFilenamePart,
|
||||
} from "@/lib/utils";
|
||||
import * as api from "../api";
|
||||
import { useMarkAsAppliedMutation } from "../hooks/queries/useJobMutations";
|
||||
import {
|
||||
useMarkAsAppliedMutation,
|
||||
useSkipJobMutation,
|
||||
} from "../hooks/queries/useJobMutations";
|
||||
import { useProfile } from "../hooks/useProfile";
|
||||
import { useRescoreJob } from "../hooks/useRescoreJob";
|
||||
import { FitAssessment, JobHeader, TailoredSummary } from ".";
|
||||
@ -84,6 +87,7 @@ export const ReadyPanel: React.FC<ReadyPanelProps> = ({
|
||||
} | null>(null);
|
||||
const previousJobIdRef = useRef<string | null>(null);
|
||||
const markAsAppliedMutation = useMarkAsAppliedMutation();
|
||||
const skipJobMutation = useSkipJobMutation();
|
||||
|
||||
const { personName } = useProfile();
|
||||
|
||||
@ -211,7 +215,7 @@ export const ReadyPanel: React.FC<ReadyPanelProps> = ({
|
||||
if (!job) return;
|
||||
|
||||
try {
|
||||
await api.skipJob(job.id);
|
||||
await skipJobMutation.mutateAsync(job.id);
|
||||
toast.message("Job skipped");
|
||||
onJobMoved(job.id);
|
||||
await onJobUpdated();
|
||||
@ -219,7 +223,7 @@ export const ReadyPanel: React.FC<ReadyPanelProps> = ({
|
||||
const message = error instanceof Error ? error.message : "Failed to skip";
|
||||
toast.error(message);
|
||||
}
|
||||
}, [job, onJobMoved, onJobUpdated]);
|
||||
}, [job, onJobMoved, onJobUpdated, skipJobMutation]);
|
||||
|
||||
const handleCopyInfo = useCallback(async () => {
|
||||
if (!job) return;
|
||||
|
||||
@ -3,6 +3,7 @@ import type React from "react";
|
||||
import { useEffect, useRef, useState } from "react";
|
||||
import { toast } from "sonner";
|
||||
import * as api from "../../api";
|
||||
import { useSkipJobMutation } from "../../hooks/queries/useJobMutations";
|
||||
import { useRescoreJob } from "../../hooks/useRescoreJob";
|
||||
import { JobDetailsEditDrawer } from "../JobDetailsEditDrawer";
|
||||
import { DecideMode } from "./DecideMode";
|
||||
@ -30,6 +31,7 @@ export const DiscoveredPanel: React.FC<DiscoveredPanelProps> = ({
|
||||
const [isFinalizing, setIsFinalizing] = useState(false);
|
||||
const [isEditDetailsOpen, setIsEditDetailsOpen] = useState(false);
|
||||
const previousJobIdRef = useRef<string | null>(null);
|
||||
const skipJobMutation = useSkipJobMutation();
|
||||
const { isRescoring, rescoreJob } = useRescoreJob(onJobUpdated);
|
||||
|
||||
useEffect(() => {
|
||||
@ -57,7 +59,7 @@ export const DiscoveredPanel: React.FC<DiscoveredPanelProps> = ({
|
||||
if (!job) return;
|
||||
try {
|
||||
setIsSkipping(true);
|
||||
await api.skipJob(job.id);
|
||||
await skipJobMutation.mutateAsync(job.id);
|
||||
toast.message("Job skipped");
|
||||
onJobMoved(job.id);
|
||||
await onJobUpdated();
|
||||
|
||||
@ -1,4 +1,7 @@
|
||||
import { useMarkAsAppliedMutation } from "@client/hooks/queries/useJobMutations";
|
||||
import {
|
||||
useMarkAsAppliedMutation,
|
||||
useSkipJobMutation,
|
||||
} from "@client/hooks/queries/useJobMutations";
|
||||
import { useHotkeys } from "@client/hooks/useHotkeys";
|
||||
import { useProfile } from "@client/hooks/useProfile";
|
||||
import { useSettings } from "@client/hooks/useSettings";
|
||||
@ -148,6 +151,7 @@ export const OrchestratorPage: React.FC = () => {
|
||||
|
||||
const { settings, refreshSettings } = useSettings();
|
||||
const markAsAppliedMutation = useMarkAsAppliedMutation();
|
||||
const skipJobMutation = useSkipJobMutation();
|
||||
const {
|
||||
jobs,
|
||||
selectedJob,
|
||||
@ -417,8 +421,8 @@ export const OrchestratorPage: React.FC = () => {
|
||||
if (!selectedJob) return;
|
||||
shortcutActionInFlight.current = true;
|
||||
const jobId = selectedJob.id;
|
||||
api
|
||||
.skipJob(jobId)
|
||||
skipJobMutation
|
||||
.mutateAsync(jobId)
|
||||
.then(async () => {
|
||||
toast.message("Job skipped");
|
||||
selectNextAfterAction(jobId);
|
||||
|
||||
@ -42,7 +42,10 @@ import {
|
||||
import { JobDetailsEditDrawer } from "../../components/JobDetailsEditDrawer";
|
||||
import { ReadyPanel } from "../../components/ReadyPanel";
|
||||
import { TailoringEditor } from "../../components/TailoringEditor";
|
||||
import { useMarkAsAppliedMutation } from "../../hooks/queries/useJobMutations";
|
||||
import {
|
||||
useMarkAsAppliedMutation,
|
||||
useSkipJobMutation,
|
||||
} from "../../hooks/queries/useJobMutations";
|
||||
import { useProfile } from "../../hooks/useProfile";
|
||||
import type { FilterTab } from "./constants";
|
||||
|
||||
@ -75,6 +78,7 @@ export const JobDetailPanel: React.FC<JobDetailPanelProps> = ({
|
||||
const saveTailoringRef = useRef<null | (() => Promise<void>)>(null);
|
||||
const previousSelectedJobIdRef = useRef<string | null>(null);
|
||||
const markAsAppliedMutation = useMarkAsAppliedMutation();
|
||||
const skipJobMutation = useSkipJobMutation();
|
||||
|
||||
const { personName } = useProfile();
|
||||
|
||||
@ -242,7 +246,7 @@ export const JobDetailPanel: React.FC<JobDetailPanelProps> = ({
|
||||
const handleSkip = async () => {
|
||||
if (!selectedJob) return;
|
||||
try {
|
||||
await api.skipJob(selectedJob.id);
|
||||
await skipJobMutation.mutateAsync(selectedJob.id);
|
||||
toast.message("Job skipped");
|
||||
await onJobUpdated();
|
||||
} catch (error) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user