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