Skip to content

Commit a6b5256

Browse files
committed
fix: create statement buttons on final screens of wizzard lock to avoid duplicates
1 parent 473f8d1 commit a6b5256

File tree

3 files changed

+36
-5
lines changed

3 files changed

+36
-5
lines changed

src/components/statementWizard/PrivacySelector.tsx

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,14 @@ interface PrivacySelectorProps {
66
isPublic: boolean;
77
onChange: (isPublic: boolean) => void;
88
onComplete: () => void;
9+
isSubmitting?: boolean;
910
}
1011

1112
export const PrivacySelector: React.FC<PrivacySelectorProps> = ({
1213
isPublic,
1314
onChange,
1415
onComplete,
16+
isSubmitting = false,
1517
}) => {
1618
return (
1719
<div className='space-y-6'>
@@ -53,8 +55,13 @@ export const PrivacySelector: React.FC<PrivacySelectorProps> = ({
5355
</div>
5456
</Button>
5557
</div>
56-
<Button variant='pink' className='mx-auto' onClick={onComplete}>
57-
Create Statement
58+
<Button
59+
variant='pink'
60+
className='mx-auto'
61+
onClick={onComplete}
62+
disabled={isSubmitting}
63+
>
64+
{isSubmitting ? 'Submitting...' : 'Create Statement'}
5865
</Button>
5966
</div>
6067
);

src/components/statementWizard/StatementWizard.tsx

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,8 @@ const StatementWizard: React.FC<StatementWizardProps> = ({
191191
/>
192192
);
193193
case 'privacy':
194-
return (
194+
return isPreset ? (
195+
// In preset flow, privacy isn't final (next goes to complement)
195196
<PrivacyStep
196197
isPublic={selection.isPublic}
197198
onUpdate={(val) =>
@@ -202,10 +203,31 @@ const StatementWizard: React.FC<StatementWizardProps> = ({
202203
}
203204
onNext={goNext}
204205
onBack={goBack}
206+
isSubmitting={isSubmitting}
207+
/>
208+
) : (
209+
// In custom flow, privacy is the final step so we call handleComplete
210+
<PrivacyStep
211+
isPublic={selection.isPublic}
212+
onUpdate={(val) =>
213+
setSelection((prev) => ({
214+
...prev,
215+
isPublic: val,
216+
}))
217+
}
218+
onNext={handleComplete}
219+
onBack={goBack}
220+
isSubmitting={isSubmitting}
205221
/>
206222
);
207223
case 'complement':
208-
return <ComplementStep onComplete={handleComplete} onBack={goBack} />;
224+
return (
225+
<ComplementStep
226+
onComplete={handleComplete}
227+
onBack={goBack}
228+
isSubmitting={isSubmitting}
229+
/>
230+
);
209231
default:
210232
return null;
211233
}

src/components/statementWizard/steps/PrivacyStep.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
// src/components/statementWizard/steps/PrivacyStep.tsx
21
import React from 'react';
32
import StepContainer from '../StepContainer';
43
import { PrivacySelector } from '../PrivacySelector';
@@ -8,13 +7,15 @@ interface PrivacyStepProps {
87
onUpdate: (isPublic: boolean) => void;
98
onNext: () => void;
109
onBack: () => void;
10+
isSubmitting?: boolean;
1111
}
1212

1313
export const PrivacyStep: React.FC<PrivacyStepProps> = ({
1414
isPublic,
1515
onUpdate,
1616
onNext,
1717
onBack,
18+
isSubmitting = false,
1819
}) => {
1920
const subQuestion = `Who can see this statement?`;
2021
return (
@@ -23,6 +24,7 @@ export const PrivacyStep: React.FC<PrivacyStepProps> = ({
2324
isPublic={isPublic}
2425
onChange={onUpdate}
2526
onComplete={() => onNext()}
27+
isSubmitting={isSubmitting} // Pass along the submission state
2628
/>
2729
</StepContainer>
2830
);

0 commit comments

Comments
 (0)