1
mirror of https://github.com/xitanggg/open-resume synced 2024-11-03 09:19:21 +01:00

hide empty sections on cv import only for returning users

This commit is contained in:
Anton Kulikalov 2023-07-04 08:36:48 -04:00 committed by Xitang Zhao
parent 4e7ad5980f
commit 2906db90b1
2 changed files with 13 additions and 4 deletions

View File

@ -2,7 +2,10 @@ import { useState } from "react";
import { LockClosedIcon } from "@heroicons/react/24/solid"; import { LockClosedIcon } from "@heroicons/react/24/solid";
import { XMarkIcon } from "@heroicons/react/24/outline"; import { XMarkIcon } from "@heroicons/react/24/outline";
import { parseResumeFromPdf } from "lib/parse-resume-from-pdf"; import { parseResumeFromPdf } from "lib/parse-resume-from-pdf";
import { saveStateToLocalStorage } from "lib/redux/local-storage"; import {
isLocalStorageEmpty,
saveStateToLocalStorage,
} from "lib/redux/local-storage";
import { initialSettings } from "lib/redux/settingsSlice"; import { initialSettings } from "lib/redux/settingsSlice";
import { useRouter } from "next/navigation"; import { useRouter } from "next/navigation";
import addPdfSrc from "public/assets/add-pdf.svg"; import addPdfSrc from "public/assets/add-pdf.svg";
@ -75,9 +78,11 @@ export const ResumeDropzone = ({
const sections = Object.keys( const sections = Object.keys(
settings.formToShow settings.formToShow
) as (keyof typeof settings.formToShow)[]; ) as (keyof typeof settings.formToShow)[];
for (const section of sections) { if (!isLocalStorageEmpty()) {
if (isEmpty(resume[section])) { for (const section of sections) {
settings.formToShow[section] = false; if (isEmpty(resume[section])) {
settings.formToShow[section] = false;
}
} }
} }

View File

@ -14,6 +14,10 @@ export function loadStateFromLocalStorage() {
} }
} }
export function isLocalStorageEmpty() {
return !localStorage.length;
}
export function saveStateToLocalStorage(state: RootState) { export function saveStateToLocalStorage(state: RootState) {
try { try {
const stringifiedState = JSON.stringify(state); const stringifiedState = JSON.stringify(state);