Skip to content

Commit aaed0e2

Browse files
authored
Merge pull request #20 from niksbanna/feature-multipage
Feature multipage
2 parents b8ed07b + 7a3ad36 commit aaed0e2

19 files changed

Lines changed: 155 additions & 122 deletions

src/components/ContactForm.tsx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,13 +77,14 @@ const ContactForm = () => {
7777
{ threshold: 0.1, rootMargin: "0px 0px -100px 0px" }
7878
);
7979

80-
if (sectionRef.current) {
81-
observer.observe(sectionRef.current);
80+
const currentSection = sectionRef.current;
81+
if (currentSection) {
82+
observer.observe(currentSection);
8283
}
8384

8485
return () => {
85-
if (sectionRef.current) {
86-
observer.unobserve(sectionRef.current);
86+
if (currentSection) {
87+
observer.unobserve(currentSection);
8788
}
8889
};
8990
}, []);

src/components/FAQSection.tsx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,13 +58,14 @@ const FAQSection = () => {
5858
{ threshold: 0.1, rootMargin: "0px 0px -100px 0px" }
5959
);
6060

61-
if (sectionRef.current) {
62-
observer.observe(sectionRef.current);
61+
const currentSection = sectionRef.current;
62+
if (currentSection) {
63+
observer.observe(currentSection);
6364
}
6465

6566
return () => {
66-
if (sectionRef.current) {
67-
observer.unobserve(sectionRef.current);
67+
if (currentSection) {
68+
observer.unobserve(currentSection);
6869
}
6970
};
7071
}, []);

src/components/GLP1Section.tsx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,14 @@ const GLP1Section = () => {
2424
{ threshold: 0.1, rootMargin: "0px 0px -100px 0px" }
2525
);
2626

27-
if (sectionRef.current) {
28-
observer.observe(sectionRef.current);
27+
const currentSection = sectionRef.current;
28+
if (currentSection) {
29+
observer.observe(currentSection);
2930
}
3031

3132
return () => {
32-
if (sectionRef.current) {
33-
observer.unobserve(sectionRef.current);
33+
if (currentSection) {
34+
observer.unobserve(currentSection);
3435
}
3536
};
3637
}, []);

src/components/Hero.tsx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,14 @@ const Hero = () => {
2323
{ threshold: 0.1 }
2424
);
2525

26-
if (sectionRef.current) {
27-
observer.observe(sectionRef.current);
26+
const currentSection = sectionRef.current;
27+
if (currentSection) {
28+
observer.observe(currentSection);
2829
}
2930

3031
return () => {
31-
if (sectionRef.current) {
32-
observer.unobserve(sectionRef.current);
32+
if (currentSection) {
33+
observer.unobserve(currentSection);
3334
}
3435
};
3536
}, []);

src/components/HowItWorks.tsx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,14 @@ const HowItWorks = () => {
4949
{ threshold: 0.1, rootMargin: "0px 0px -100px 0px" }
5050
);
5151

52-
if (sectionRef.current) {
53-
observer.observe(sectionRef.current);
52+
const currentSection = sectionRef.current;
53+
if (currentSection) {
54+
observer.observe(currentSection);
5455
}
5556

5657
return () => {
57-
if (sectionRef.current) {
58-
observer.unobserve(sectionRef.current);
58+
if (currentSection) {
59+
observer.unobserve(currentSection);
5960
}
6061
};
6162
}, []);

src/components/Journey.tsx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,14 @@ const Journey = () => {
3333
{ threshold: 0.1, rootMargin: "0px 0px -100px 0px" }
3434
);
3535

36-
if (sectionRef.current) {
37-
observer.observe(sectionRef.current);
36+
const currentSection = sectionRef.current;
37+
if (currentSection) {
38+
observer.observe(currentSection);
3839
}
3940

4041
return () => {
41-
if (sectionRef.current) {
42-
observer.unobserve(sectionRef.current);
42+
if (currentSection) {
43+
observer.unobserve(currentSection);
4344
}
4445
};
4546
}, []);

src/components/Questionnaire.tsx

Lines changed: 39 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ const questions: QuestionType[] = [
8686

8787
const Questionnaire = () => {
8888
const [currentQuestion, setCurrentQuestion] = useState(0);
89-
const [answers, setAnswers] = useState<Record<string, any>>({});
89+
const [answers, setAnswers] = useState<Record<string, string | number | string[]>>({});
9090
const [submitted, setSubmitted] = useState(false);
9191
const sectionRef = useRef<HTMLElement>(null);
9292
const { toast } = useToast();
@@ -144,7 +144,7 @@ const Questionnaire = () => {
144144
};
145145

146146
// Handle answer updates
147-
const handleAnswer = (value: any) => {
147+
const handleAnswer = (value: string | number | string[]) => {
148148
const question = questions[currentQuestion];
149149
setAnswers({
150150
...answers,
@@ -213,13 +213,14 @@ const Questionnaire = () => {
213213
{ threshold: 0.1, rootMargin: "0px 0px -100px 0px" }
214214
);
215215

216-
if (sectionRef.current) {
217-
observer.observe(sectionRef.current);
216+
const currentSection = sectionRef.current;
217+
if (currentSection) {
218+
observer.observe(currentSection);
218219
}
219220

220221
return () => {
221-
if (sectionRef.current) {
222-
observer.unobserve(sectionRef.current);
222+
if (currentSection) {
223+
observer.unobserve(currentSection);
223224
}
224225
};
225226
}, []);
@@ -290,36 +291,39 @@ const Questionnaire = () => {
290291
case 'checkbox':
291292
return (
292293
<div className="space-y-3">
293-
{question.options?.map((option) => (
294-
<label
295-
key={option}
296-
className={cn(
297-
"flex items-center p-4 border rounded-lg cursor-pointer transition-all",
298-
answers[question.id]?.includes(option)
299-
? "border-wellness-500 bg-wellness-50 ring-2 ring-wellness-200"
300-
: "border-border hover:border-wellness-300"
301-
)}
302-
>
303-
<input
304-
type="checkbox"
305-
name={question.id}
306-
checked={answers[question.id]?.includes(option) || false}
307-
onChange={() => handleCheckboxChange(option)}
308-
className="sr-only"
309-
/>
310-
<div className={cn(
311-
"w-5 h-5 rounded border-2 flex items-center justify-center mr-3 transition-all",
312-
answers[question.id]?.includes(option)
313-
? "border-wellness-500 bg-wellness-500"
314-
: "border-border"
315-
)}>
316-
{answers[question.id]?.includes(option) && (
317-
<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="white" strokeWidth="3" strokeLinecap="round" strokeLinejoin="round"><polyline points="20 6 9 17 4 12"></polyline></svg>
294+
{question.options?.map((option) => {
295+
const answerArray = Array.isArray(answers[question.id]) ? answers[question.id] as string[] : [];
296+
return (
297+
<label
298+
key={option}
299+
className={cn(
300+
"flex items-center p-4 border rounded-lg cursor-pointer transition-all",
301+
answerArray.includes(option)
302+
? "border-wellness-500 bg-wellness-50 ring-2 ring-wellness-200"
303+
: "border-border hover:border-wellness-300"
318304
)}
319-
</div>
320-
<span>{option}</span>
321-
</label>
322-
))}
305+
>
306+
<input
307+
type="checkbox"
308+
name={question.id}
309+
checked={answerArray.includes(option)}
310+
onChange={() => handleCheckboxChange(option)}
311+
className="sr-only"
312+
/>
313+
<div className={cn(
314+
"w-5 h-5 rounded border-2 flex items-center justify-center mr-3 transition-all",
315+
answerArray.includes(option)
316+
? "border-wellness-500 bg-wellness-500"
317+
: "border-border"
318+
)}>
319+
{answerArray.includes(option) && (
320+
<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="white" strokeWidth="3" strokeLinecap="round" strokeLinejoin="round"><polyline points="20 6 9 17 4 12"></polyline></svg>
321+
)}
322+
</div>
323+
<span>{option}</span>
324+
</label>
325+
);
326+
})}
323327
</div>
324328
);
325329

src/components/Testimonials.tsx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,13 +82,14 @@ const Testimonials = () => {
8282
{ threshold: 0.1, rootMargin: "0px 0px -100px 0px" }
8383
);
8484

85-
if (sectionRef.current) {
86-
observer.observe(sectionRef.current);
85+
const currentSection = sectionRef.current;
86+
if (currentSection) {
87+
observer.observe(currentSection);
8788
}
8889

8990
return () => {
90-
if (sectionRef.current) {
91-
observer.unobserve(sectionRef.current);
91+
if (currentSection) {
92+
observer.unobserve(currentSection);
9293
}
9394
};
9495
}, []);

src/components/TrustSection.tsx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,14 @@ const TrustSection = () => {
2424
{ threshold: 0.1, rootMargin: "0px 0px -100px 0px" }
2525
);
2626

27-
if (sectionRef.current) {
28-
observer.observe(sectionRef.current);
27+
const currentSection = sectionRef.current;
28+
if (currentSection) {
29+
observer.observe(currentSection);
2930
}
3031

3132
return () => {
32-
if (sectionRef.current) {
33-
observer.unobserve(sectionRef.current);
33+
if (currentSection) {
34+
observer.unobserve(currentSection);
3435
}
3536
};
3637
}, []);

src/components/ui/command.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ const Command = React.forwardRef<
2121
))
2222
Command.displayName = CommandPrimitive.displayName
2323

24-
interface CommandDialogProps extends DialogProps {}
24+
type CommandDialogProps = DialogProps
2525

2626
const CommandDialog = ({ children, ...props }: CommandDialogProps) => {
2727
return (

0 commit comments

Comments
 (0)