Use optimistic mark-as-applied mutation across client entry points
This commit is contained in:
parent
89ff770416
commit
096ac21b19
@ -46,6 +46,7 @@ import {
|
||||
safeFilenamePart,
|
||||
} from "@/lib/utils";
|
||||
import * as api from "../api";
|
||||
import { useMarkAsAppliedMutation } from "../hooks/queries/useJobMutations";
|
||||
import { useProfile } from "../hooks/useProfile";
|
||||
import { useRescoreJob } from "../hooks/useRescoreJob";
|
||||
import { FitAssessment, JobHeader, TailoredSummary } from ".";
|
||||
@ -82,6 +83,7 @@ export const ReadyPanel: React.FC<ReadyPanelProps> = ({
|
||||
timeoutId: ReturnType<typeof setTimeout>;
|
||||
} | null>(null);
|
||||
const previousJobIdRef = useRef<string | null>(null);
|
||||
const markAsAppliedMutation = useMarkAsAppliedMutation();
|
||||
|
||||
const { personName } = useProfile();
|
||||
|
||||
@ -148,7 +150,7 @@ export const ReadyPanel: React.FC<ReadyPanelProps> = ({
|
||||
|
||||
try {
|
||||
setIsMarkingApplied(true);
|
||||
await api.markAsApplied(job.id);
|
||||
await markAsAppliedMutation.mutateAsync(job.id);
|
||||
|
||||
// Store for undo
|
||||
const timeoutId = setTimeout(() => {
|
||||
@ -181,7 +183,7 @@ export const ReadyPanel: React.FC<ReadyPanelProps> = ({
|
||||
} finally {
|
||||
setIsMarkingApplied(false);
|
||||
}
|
||||
}, [job, onJobMoved, onJobUpdated, handleUndoApplied]);
|
||||
}, [job, markAsAppliedMutation, onJobMoved, onJobUpdated, handleUndoApplied]);
|
||||
|
||||
const handleRegenerate = useCallback(async () => {
|
||||
if (!job) return;
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
import { useMarkAsAppliedMutation } from "@client/hooks/queries/useJobMutations";
|
||||
import { useHotkeys } from "@client/hooks/useHotkeys";
|
||||
import { useProfile } from "@client/hooks/useProfile";
|
||||
import { useSettings } from "@client/hooks/useSettings";
|
||||
@ -146,6 +147,7 @@ export const OrchestratorPage: React.FC = () => {
|
||||
);
|
||||
|
||||
const { settings, refreshSettings } = useSettings();
|
||||
const markAsAppliedMutation = useMarkAsAppliedMutation();
|
||||
const {
|
||||
jobs,
|
||||
selectedJob,
|
||||
@ -438,8 +440,8 @@ export const OrchestratorPage: React.FC = () => {
|
||||
if (shortcutActionInFlight.current) return;
|
||||
shortcutActionInFlight.current = true;
|
||||
const jobId = selectedJob.id;
|
||||
api
|
||||
.markAsApplied(jobId)
|
||||
markAsAppliedMutation
|
||||
.mutateAsync(jobId)
|
||||
.then(async () => {
|
||||
toast.success("Marked as applied", {
|
||||
description: `${selectedJob.title} at ${selectedJob.employer}`,
|
||||
|
||||
@ -42,6 +42,7 @@ import {
|
||||
import { JobDetailsEditDrawer } from "../../components/JobDetailsEditDrawer";
|
||||
import { ReadyPanel } from "../../components/ReadyPanel";
|
||||
import { TailoringEditor } from "../../components/TailoringEditor";
|
||||
import { useMarkAsAppliedMutation } from "../../hooks/queries/useJobMutations";
|
||||
import { useProfile } from "../../hooks/useProfile";
|
||||
import type { FilterTab } from "./constants";
|
||||
|
||||
@ -73,6 +74,7 @@ export const JobDetailPanel: React.FC<JobDetailPanelProps> = ({
|
||||
const [isEditDetailsOpen, setIsEditDetailsOpen] = useState(false);
|
||||
const saveTailoringRef = useRef<null | (() => Promise<void>)>(null);
|
||||
const previousSelectedJobIdRef = useRef<string | null>(null);
|
||||
const markAsAppliedMutation = useMarkAsAppliedMutation();
|
||||
|
||||
const { personName } = useProfile();
|
||||
|
||||
@ -227,7 +229,7 @@ export const JobDetailPanel: React.FC<JobDetailPanelProps> = ({
|
||||
const handleApply = async () => {
|
||||
if (!selectedJob) return;
|
||||
try {
|
||||
await api.markAsApplied(selectedJob.id);
|
||||
await markAsAppliedMutation.mutateAsync(selectedJob.id);
|
||||
toast.success("Marked as applied");
|
||||
await onJobUpdated();
|
||||
} catch (error) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user