import { OSForm } from '@osforms/react';
import type { FormSchema } from '@osforms/react';
const schema: FormSchema = {
mode: 'conversational',
fields: [
{
id: 'name',
type: 'text',
label: "What's your name?",
required: true,
validation: { minLength: 2 },
},
{
id: 'role',
type: 'radio',
label: "What's your role?",
required: true,
options: [
{ id: 'dev', label: 'Developer', value: 'developer' },
{ id: 'design', label: 'Designer', value: 'designer' },
{ id: 'pm', label: 'Product Manager', value: 'pm' },
{ id: 'other', label: 'Other', value: 'other' },
],
},
{
id: 'role_other',
type: 'text',
label: 'Please specify',
required: false,
conditionalLogic: {
action: 'show',
match: 'all',
conditions: [{ fieldId: 'role', operator: 'equals', value: 'other' }],
},
},
{
id: 'nps',
type: 'scale',
label: 'How likely are you to recommend us?',
required: false,
config: {
scaleMin: 0,
scaleMax: 10,
scaleLowLabel: 'Not likely',
scaleHighLabel: 'Very likely',
},
},
],
welcomeScreen: {
enabled: true,
title: 'Quick survey',
description: 'Takes less than 2 minutes.',
buttonLabel: 'Start',
},
thankYouScreen: {
enabled: true,
title: 'Thanks!',
description: 'Your response has been recorded.',
},
};
export default function SurveyPage() {
return (
<OSForm
schema={schema}
endpoint="https://osforms.com/api/v1/f/your-slug"
mode="conversational"
fullScreen
onComplete={() => console.log('done')}
/>
);
}