Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 0 additions & 12 deletions .example.env

This file was deleted.

4 changes: 2 additions & 2 deletions app/(private)/preview/client.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ export default function PreviewClient() {

return (
<div className="w-full min-h-screen bg-background flex flex-col gap-4 pb-8">
<div className="max-w-3xl mx-auto w-full md:px-0 px-4">
<div className="max-w-[50rem] mx-auto w-full md:px-0 px-4">
<PreviewActionbar
initialUsername={usernameQuery.data.username}
status={resumeQuery.data?.resume?.status}
Expand All @@ -94,7 +94,7 @@ export default function PreviewClient() {
/>
</div>

<div className="max-w-3xl mx-auto w-full md:rounded-lg border-[0.5px] border-neutral-300 flex items-center justify-between px-4">
<div className="max-w-[50rem] mx-auto w-full md:rounded-lg border-[0.5px] border-neutral-300 flex items-center justify-between px-4">
<FullResume
resume={resumeQuery.data?.resume?.resumeData}
profilePicture={user?.imageUrl}
Expand Down
39 changes: 35 additions & 4 deletions components/PreviewActionbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@

import { Button } from '@/components/ui/button';
import { cn, getSelfSoUrl } from '@/lib/utils';
import { ExternalLink, Pencil } from 'lucide-react';
import { ExternalLink, Pencil,QrCode } from 'lucide-react';
import { useState } from 'react';
import { toast } from 'sonner';
import UsernameEditorView from './UsernameEditorView';
import QRCode from 'qrcode';

export type PublishStatuses = 'draft' | 'live';

Expand All @@ -32,6 +33,24 @@ export default function PreviewActionbar({
}
};


const handleQRDownload = async () => {
if (!initialUsername || status !== 'live') return;

const portfolioUrl = getSelfSoUrl(initialUsername);
console.log(portfolioUrl)
const canvas = document.createElement('canvas');

await QRCode.toCanvas(canvas, portfolioUrl, { width: 300 });

const image = canvas.toDataURL('image/png');
const link = document.createElement('a');
link.href = image;
link.download = `${initialUsername}-qr.png`;
link.click();
};


return (
<>
<div className="w-full rounded-lg bg-[#fcfcfc] border-[0.5px] border-neutral-300 flex items-center justify-between py-3 px-5 sm:px-4 sm:py-2.5 flex-col sm:flex-row gap-4">
Expand Down Expand Up @@ -95,9 +114,9 @@ export default function PreviewActionbar({
onClick={handleStatusChange}
className={`flex items-center min-w-[100px] min-h-8 gap-1.5 px-3 py-1.5 h-auto ${
status === 'draft'
? 'bg-design-black hover:bg-[#333333] text-[#fcfcfc]'
: 'bg-design-white text-design-black hover:bg-gray-100'
}`}
? 'bg-design-black hover:bg-[#333333] text-[#fcfcfc]'
: 'bg-design-white text-design-black hover:bg-gray-100'
}`}
>
{isChangingStatus ? (
<>
Expand All @@ -109,6 +128,18 @@ export default function PreviewActionbar({
</span>
)}
</Button>

{status === 'live' && (
<Button
onClick={handleQRDownload}
className="flex items-center gap-2 bg-white border text-black hover:bg-gray-100 min-h-8 px-3 py-1.5"
>
<QrCode className="w-6 h-6 text-gray-600" />
QR
</Button>
)}


{status === 'live' && (
<Button className="flex items-center min-w-[100px] min-h-8 gap-1.5 px-3 py-1.5 h-auto">
<a
Expand Down
Loading