Skip to content

Commit eba4baa

Browse files
Shadow-MMNShadow-MMN
andauthored
feat: implemented loading and success states for createprojectmodal form (#300)
Co-authored-by: Shadow-MMN <nnajimakuochukwu4@example.com>
1 parent 5d438c8 commit eba4baa

4 files changed

Lines changed: 98 additions & 11 deletions

File tree

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
'use client';
2+
import { motion } from 'framer-motion';
3+
4+
const LoadingScreen = () => {
5+
return (
6+
<div className='flex h-screen w-screen items-center justify-center bg-[#030303]'>
7+
<div className='flex items-center gap-2'>
8+
{[...Array(3)].map((_, index) => (
9+
<motion.div
10+
key={index}
11+
className='h-[9.85px] w-[9.85px] rounded-full bg-[#A7F95014]' // 🔥 use background color
12+
animate={{
13+
backgroundColor: ['#A7F95014', '#A7F950', '#A7F95014'],
14+
height: ['9.85px', '39.38px', '9.85px'],
15+
}}
16+
transition={{
17+
duration: 1,
18+
ease: 'easeInOut',
19+
repeat: Infinity,
20+
delay: index * 0.2, // ✅ use delay instead of repeatDelay
21+
}}
22+
/>
23+
))}
24+
</div>
25+
</div>
26+
);
27+
};
28+
29+
export default LoadingScreen;
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import { BoundlessButton } from '@/components/buttons';
2+
import Image from 'next/image';
3+
4+
const SuccessScreen = ({ onContinue }: { onContinue: () => void }) => {
5+
return (
6+
<div className='flex h-screen w-screen items-center justify-center bg-[#030303] px-10'>
7+
<div className='mx-auto flex max-w-[400px] flex-col items-center gap-10'>
8+
<Image
9+
src='/Success@4x.png'
10+
alt='Green good mark'
11+
width={120}
12+
height={120}
13+
className='max-h-[150px] max-w-[150px]'
14+
/>
15+
<div className='flex flex-col gap-3 text-center text-white'>
16+
<h2 className='text-[20px] font-medium'>Submission Successful!</h2>
17+
<p>
18+
Your project has been sent for admin review and will be processed
19+
within 72 hours. You can track its status anytime on the{' '}
20+
<span className='font-medium text-[#A7F950] underline'>
21+
Projects Page
22+
</span>
23+
</p>
24+
</div>
25+
26+
<BoundlessButton onClick={onContinue}>Continue</BoundlessButton>
27+
</div>
28+
</div>
29+
);
30+
};
31+
32+
export default SuccessScreen;

components/landing-page/project/CreateProjectModal/index.tsx

Lines changed: 37 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ import Details from './Details';
77
import Milestones from './Milestones';
88
import Team from './Team';
99
import Contact from './Contact';
10+
import LoadingScreen from './LoadingScreen';
11+
import SuccessScreen from './SuccessScreen';
1012

1113
const CreateProjectModal = ({
1214
open,
@@ -16,6 +18,8 @@ const CreateProjectModal = ({
1618
setOpen: (open: boolean) => void;
1719
}) => {
1820
const [currentStep, setCurrentStep] = useState(1);
21+
const [isLoading, setIsLoading] = useState(false);
22+
const [showSuccess, setShowSuccess] = useState(false);
1923

2024
const handleBack = () => {
2125
if (currentStep > 1) {
@@ -24,19 +28,37 @@ const CreateProjectModal = ({
2428
};
2529

2630
const handleContinue = () => {
31+
if (showSuccess) return; // prevent clicks when success is showing
32+
2733
if (currentStep < 5) {
28-
setCurrentStep(currentStep + 1);
34+
setIsLoading(true);
35+
setTimeout(() => {
36+
setCurrentStep(prev => prev + 1);
37+
setIsLoading(false);
38+
}, 1000);
2939
} else {
30-
// Handle final submission
31-
// TODO: Implement project submission logic
32-
// This could include API calls, form validation, etc.
40+
// ✅ After final step, show success screen
41+
setShowSuccess(true);
3342
}
3443
};
3544

36-
// Placeholder for step validation - you can implement actual validation logic here
45+
const handleReset = () => {
46+
// reset all states to start fresh
47+
setShowSuccess(false);
48+
setCurrentStep(1);
49+
setIsLoading(false);
50+
};
51+
3752
const isStepValid = true;
3853

3954
const renderStepContent = () => {
55+
if (isLoading) {
56+
return <LoadingScreen />;
57+
}
58+
if (showSuccess) {
59+
return <SuccessScreen onContinue={handleReset} />;
60+
}
61+
4062
switch (currentStep) {
4163
case 1:
4264
return <Basic />;
@@ -59,15 +81,19 @@ const CreateProjectModal = ({
5981
open={open}
6082
setOpen={setOpen}
6183
>
62-
<Header currentStep={currentStep} onBack={handleBack} />
84+
{!showSuccess && <Header currentStep={currentStep} onBack={handleBack} />}
85+
6386
<div className='min-h-[calc(55vh)] px-4 md:px-[50px] lg:px-[75px] xl:px-[150px]'>
6487
{renderStepContent()}
6588
</div>
66-
<Footer
67-
currentStep={currentStep}
68-
onContinue={handleContinue}
69-
isStepValid={isStepValid}
70-
/>
89+
90+
{!showSuccess && (
91+
<Footer
92+
currentStep={currentStep}
93+
onContinue={handleContinue}
94+
isStepValid={isStepValid}
95+
/>
96+
)}
7197
</BoundlessSheet>
7298
);
7399
};

public/Success@4x.png

186 KB
Loading

0 commit comments

Comments
 (0)