diff --git a/components/Resume/Preview.js b/components/Resume/Preview.js index 63e46cc..064ca95 100644 --- a/components/Resume/Preview.js +++ b/components/Resume/Preview.js @@ -12,8 +12,6 @@ import { usePDF } from '@react-pdf/renderer'; import { Document, Page, pdfjs } from 'react-pdf'; import { FaDownload, FaEye } from 'react-icons/fa6'; -pdfjs.GlobalWorkerOptions.workerSrc = new URL('pdfjs-dist/build/pdf.worker.min.js', import.meta.url).toString(); - const Loader = () => (
@@ -34,6 +32,10 @@ const Preview = () => { const document = ; const [instance, updateInstance] = usePDF({ document }); + useEffect(() => { + pdfjs.GlobalWorkerOptions.workerSrc = new URL('pdfjs-dist/build/pdf.worker.min.js', import.meta.url).toString(); + }, []); + useEffect(() => { if (resumeData.saved) updateInstance(document); }, [resumeData.saved]); diff --git a/components/Resume/Styles.js b/components/Resume/Styles.js index 67f3f7c..0738c69 100644 --- a/components/Resume/Styles.js +++ b/components/Resume/Styles.js @@ -1,3 +1,5 @@ +'use client'; + import { StyleSheet } from '@react-pdf/renderer'; const styles = StyleSheet.create({ diff --git a/components/Resume/html/ListItem.js b/components/Resume/html/ListItem.js index 84a3859..91f0d64 100644 --- a/components/Resume/html/ListItem.js +++ b/components/Resume/html/ListItem.js @@ -1,3 +1,5 @@ +'use client'; + import { Text, View, StyleSheet } from '@react-pdf/renderer'; const ListItem = ({ children }) => { diff --git a/components/Resume/html/index.js b/components/Resume/html/index.js index f09da51..3ddc1a8 100644 --- a/components/Resume/html/index.js +++ b/components/Resume/html/index.js @@ -7,6 +7,12 @@ import ListItem from './ListItem'; import formatDate from '@/utils/formatDate'; import { Link, Text, View } from './Renderer'; +const ensureProtocol = url => { + if (!url) return url; + if (url.startsWith('http://') || url.startsWith('https://') || url.startsWith('mailto:')) return url; + return `https://${url}`; +}; + const Header = ({ data }) => { const contactLinks = [ { @@ -46,7 +52,7 @@ const Header = ({ data }) => { {contactLinks .filter(obj => obj.value) .map(({ value, name }) => ( - + {name} ))} @@ -62,7 +68,7 @@ const Education = ({ data }) => ( {degree} - {formatDate(start)}- {formatDate(end)} + {formatDate(start)} - {formatDate(end)} diff --git a/components/Resume/pdf/ListItem.js b/components/Resume/pdf/ListItem.js index a153ce0..9571867 100644 --- a/components/Resume/pdf/ListItem.js +++ b/components/Resume/pdf/ListItem.js @@ -1,3 +1,5 @@ +'use client'; + import { Text, View, StyleSheet } from '@react-pdf/renderer'; const ListItem = ({ children }) => { diff --git a/components/Resume/pdf/Section.js b/components/Resume/pdf/Section.js index f9f1f31..f87a85d 100644 --- a/components/Resume/pdf/Section.js +++ b/components/Resume/pdf/Section.js @@ -1,3 +1,5 @@ +'use client'; + import { StyleSheet, Text, View } from '@react-pdf/renderer'; const Section = ({ title, style, children }) => { diff --git a/components/Resume/pdf/index.js b/components/Resume/pdf/index.js index e071ce8..d33b6bd 100644 --- a/components/Resume/pdf/index.js +++ b/components/Resume/pdf/index.js @@ -6,6 +6,12 @@ import ListItem from './ListItem'; import styles from '../Styles'; import formatDate from '@/utils/formatDate'; +const ensureProtocol = url => { + if (!url) return url; + if (url.startsWith('http://') || url.startsWith('https://') || url.startsWith('mailto:')) return url; + return `https://${url}`; +}; + const Header = ({ data }) => { const contactLinks = [ { @@ -45,7 +51,7 @@ const Header = ({ data }) => { {contactLinks .filter(obj => obj.value) .map(({ value, name }) => ( - + {name} ))} @@ -61,7 +67,7 @@ const Education = ({ data }) => ( {degree} - {formatDate(start)}- {formatDate(end)} + {formatDate(start)} - {formatDate(end)} diff --git a/components/UI/Input.js b/components/UI/Input.js index f9f4a24..c72e6a1 100644 --- a/components/UI/Input.js +++ b/components/UI/Input.js @@ -110,6 +110,41 @@ const Input = ({ label, name, type, placeholder, options, span, value, ...props ); } + if (type === 'month-current') { + const { onChange } = props; + const isPresent = value === 'Present'; + return ( +
+ + +
+ ); + } + if (type == 'color') { return ( { if (!date) return ''; + if (date === 'Present') return 'Present'; const d = new Date(date); return d.toLocaleDateString(undefined, {