Skip to content

Commit 87a8dbb

Browse files
committed
Refactor Sponsor component to use search parameters for deck selection; update toggle button handlers for improved state management
Signed-off-by: Steve Yonkeu <yokwejuste@yahoo.com>
1 parent cb45e70 commit 87a8dbb

1 file changed

Lines changed: 9 additions & 4 deletions

File tree

src/pages/Sponsor.jsx

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
1-
import React, { useState } from 'react';
1+
import { useSearchParams } from 'react-router-dom';
22
import useScrollAnimation from '../hooks/useScrollAnimation';
33
import { internationalTiers, localTiers, sponsorshipDeckUrl } from '../data/sponsors';
44

55
const Sponsor = () => {
66
useScrollAnimation();
7-
const [isLocal, setIsLocal] = useState(false);
7+
const [searchParams, setSearchParams] = useSearchParams();
8+
const isLocal = searchParams.get('deck') === 'local';
9+
10+
const handleToggle = (local) => {
11+
setSearchParams({ deck: local ? 'local' : 'international' }, { replace: true });
12+
};
813
const tiers = isLocal ? localTiers : internationalTiers;
914

1015
return (
@@ -123,7 +128,7 @@ const Sponsor = () => {
123128
border: '1px solid var(--color-border)',
124129
}}>
125130
<button
126-
onClick={() => setIsLocal(false)}
131+
onClick={() => handleToggle(false)}
127132
style={{
128133
padding: '0.6rem 1.5rem',
129134
borderRadius: '50px',
@@ -139,7 +144,7 @@ const Sponsor = () => {
139144
International (USD)
140145
</button>
141146
<button
142-
onClick={() => setIsLocal(true)}
147+
onClick={() => handleToggle(true)}
143148
style={{
144149
padding: '0.6rem 1.5rem',
145150
borderRadius: '50px',

0 commit comments

Comments
 (0)