Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
import { motion, AnimatePresence } from 'framer-motion';
import { useNavigate } from 'react-router-dom';
import { documentGenerateAPI } from '../../services/api';
import { SkeletonLoader } from '../../components/LoadingSpinner';

const DOC_TYPES = [
{
Expand Down Expand Up @@ -44,6 +45,33 @@ const DOC_TYPES = [
},
];

const DocumentSkeleton = () => (
<div style={{ maxWidth: '800px' }}>
<SkeletonLoader count={1} />

<div
style={{
marginTop: '1rem',
padding: '1rem',
background: 'var(--bg-surface)',
borderRadius: '0.75rem',
border: '1px solid var(--color-border)',
}}
>
<div
style={{
height: '350px',
background:
'linear-gradient(90deg, rgba(203,213,225,0.4) 0%, rgba(203,213,225,0.6) 50%, rgba(203,213,225,0.4) 100%)',
backgroundSize: '200% 100%',
animation: 'shimmer 1.5s infinite',
borderRadius: '8px',
}}
/>
</div>
</div>
);

const DocumentGeneratePage = () => {
const navigate = useNavigate();
const [step, setStep] = useState(1);
Expand Down Expand Up @@ -134,9 +162,12 @@ const DocumentGeneratePage = () => {
pioName: form.pioName,
};

setStep(3);

const response = await documentGenerateAPI.preview(payload);

setGeneratedDoc(response.data);
setStep(3);

} catch (err) {
handleApiError(err);
} finally {
Expand Down Expand Up @@ -452,7 +483,7 @@ const DocumentGeneratePage = () => {
)}

{/* ─── Step 2: Dynamic Form ──────────────────────────── */}
{step === 2 && (
{step === 2 && !isGenerating && (
<motion.div
key="step2"
initial={{ opacity: 0, x: -20 }}
Expand Down Expand Up @@ -704,6 +735,15 @@ const DocumentGeneratePage = () => {
</motion.div>
)}

{isGenerating && !generatedDoc && (
<motion.div
initial={{ opacity: 0 }}
animate={{ opacity: 1 }}
>
<DocumentSkeleton />
</motion.div>
)}

{/* ─── Step 3: Preview & Download ─────────────────────── */}
{step === 3 && generatedDoc && (
<motion.div
Expand Down
Loading