-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1519 from AmruthPillai/feat/v4/implement-resume-l…
…ocking feat(resume): ✨ implement resume locking feature
- Loading branch information
Showing
23 changed files
with
289 additions
and
84 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
apps/client/src/pages/builder/sidebars/right/sections/notes.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import { RichInput } from "@reactive-resume/ui"; | ||
|
||
import { useResumeStore } from "@/client/stores/resume"; | ||
|
||
import { getSectionIcon } from "../shared/section-icon"; | ||
|
||
export const NotesSection = () => { | ||
const setValue = useResumeStore((state) => state.setValue); | ||
const notes = useResumeStore((state) => state.resume.data.metadata.notes); | ||
|
||
return ( | ||
<section id="notes" className="grid gap-y-6"> | ||
<header className="flex items-center justify-between"> | ||
<div className="flex items-center gap-x-4"> | ||
{getSectionIcon("notes")} | ||
<h2 className="line-clamp-1 text-3xl font-bold">Notes</h2> | ||
</div> | ||
</header> | ||
|
||
<main className="grid gap-y-4"> | ||
<p className="leading-relaxed"> | ||
This section is reserved for your personal notes specific to this resume. The content here | ||
remains private and is not shared with anyone else. | ||
</p> | ||
|
||
<div className="space-y-1.5"> | ||
<RichInput content={notes} onChange={(content) => setValue("metadata.notes", content)} /> | ||
|
||
<p className="text-xs leading-relaxed opacity-75"> | ||
For example, information regarding which companies you sent this resume to or the links | ||
to the job descriptions can be noted down here. | ||
</p> | ||
</div> | ||
</main> | ||
</section> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import { ResumeDto } from "@reactive-resume/dto"; | ||
import { | ||
AlertDialog, | ||
AlertDialogAction, | ||
AlertDialogCancel, | ||
AlertDialogContent, | ||
AlertDialogDescription, | ||
AlertDialogFooter, | ||
AlertDialogHeader, | ||
AlertDialogTitle, | ||
} from "@reactive-resume/ui"; | ||
|
||
import { useLockResume } from "@/client/services/resume/lock"; | ||
import { useDialog } from "@/client/stores/dialog"; | ||
|
||
export const LockDialog = () => { | ||
const { isOpen, mode, payload, close } = useDialog<ResumeDto>("lock"); | ||
|
||
const isLockMode = mode === "create"; | ||
const isUnlockMode = mode === "update"; | ||
|
||
const { lockResume, loading } = useLockResume(); | ||
|
||
const onSubmit = async () => { | ||
if (!payload.item) return; | ||
|
||
await lockResume({ id: payload.item.id, set: isLockMode }); | ||
|
||
close(); | ||
}; | ||
|
||
return ( | ||
<AlertDialog open={isOpen} onOpenChange={close}> | ||
<AlertDialogContent> | ||
<AlertDialogHeader> | ||
<AlertDialogTitle> | ||
{isLockMode && "Are you sure you want to lock this resume?"} | ||
{isUnlockMode && "Are you sure you want to unlock this resume?"} | ||
</AlertDialogTitle> | ||
<AlertDialogDescription> | ||
{isLockMode && | ||
"Locking a resume will prevent any further changes to it. This is useful when you have already shared your resume with someone and you don't want to accidentally make any changes to it."} | ||
{isUnlockMode && "Unlocking a resume will allow you to make changes to it again."} | ||
</AlertDialogDescription> | ||
</AlertDialogHeader> | ||
|
||
<AlertDialogFooter> | ||
<AlertDialogCancel>Cancel</AlertDialogCancel> | ||
|
||
<AlertDialogAction variant="info" disabled={loading} onClick={onSubmit}> | ||
{isLockMode && "Lock"} | ||
{isUnlockMode && "Unlock"} | ||
</AlertDialogAction> | ||
</AlertDialogFooter> | ||
</AlertDialogContent> | ||
</AlertDialog> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import { ResumeDto } from "@reactive-resume/dto"; | ||
import { useMutation } from "@tanstack/react-query"; | ||
|
||
import { axios } from "@/client/libs/axios"; | ||
import { queryClient } from "@/client/libs/query-client"; | ||
|
||
type LockResumeArgs = { | ||
id: string; | ||
set: boolean; | ||
}; | ||
|
||
export const lockResume = async ({ id, set }: LockResumeArgs) => { | ||
const response = await axios.patch(`/resume/${id}/lock`, { set }); | ||
|
||
queryClient.setQueryData<ResumeDto>(["resume", { id: response.data.id }], response.data); | ||
|
||
queryClient.setQueryData<ResumeDto[]>(["resumes"], (cache) => { | ||
if (!cache) return [response.data]; | ||
return cache.map((resume) => { | ||
if (resume.id === response.data.id) return response.data; | ||
return resume; | ||
}); | ||
}); | ||
|
||
return response.data; | ||
}; | ||
|
||
export const useLockResume = () => { | ||
const { | ||
error, | ||
isPending: loading, | ||
mutateAsync: lockResumeFn, | ||
} = useMutation({ | ||
mutationFn: lockResume, | ||
}); | ||
|
||
return { lockResume: lockResumeFn, loading, error }; | ||
}; |
Oops, something went wrong.