Skip to content

Commit 88ee365

Browse files
authored
Merge pull request #6 from workfloworchestrator/1602-pydantic-forms-code
1602 Pydantic forms ui - first working field
2 parents 6a9e9b7 + 1251d9c commit 88ee365

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+2118
-1373
lines changed

backend/main.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -55,13 +55,12 @@ class TestForm(FormPage):
5555

5656
form_data_1 = yield TestForm
5757

58-
class TestForm2(SubmitFormPage):
59-
model_config = ConfigDict(title="Form 2 Title")
60-
61-
name_2: str | None = None
62-
63-
form_data_2 = yield TestForm2
64-
return form_data_1.model_dump() | form_data_2.model_dump()
58+
# class TestForm2(SubmitFormPage):
59+
# model_config = ConfigDict(title="Form 2 Title")
60+
#
61+
# name_2: str | None = None
62+
# form_data_2 = yield TestForm2
63+
return form_data_1.model_dump() #| form_data_2.model_dump()
6564

6665
data = post_form(form_generator, state={}, user_inputs=form_data)
6766
return data

frontend/.changeset/config.json

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
{
2-
"$schema": "https://unpkg.com/@changesets/config@2.0.0/schema.json",
2+
"$schema": "https://unpkg.com/@changesets/config@3.0.5/schema.json",
33
"changelog": "@changesets/cli/changelog",
4-
"baseBranch": "main",
54
"commit": false,
65
"fixed": [],
76
"linked": [],
8-
"access": "public",
9-
"updateInternalDependencies": "patch"
7+
"access": "restricted",
8+
"baseBranch": "main",
9+
"updateInternalDependencies": "patch",
10+
"ignore": []
1011
}

frontend/.changeset/selfish-ravens-smile.md renamed to frontend/.changeset/little-hats-grab.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@
33
'example': patch
44
---
55

6-
Tests npm publish
6+
Initial publish trigger

frontend/.changeset/serious-cheetahs-jump.md

Lines changed: 0 additions & 5 deletions
This file was deleted.

frontend/.changeset/silly-mirrors-love.md

Lines changed: 0 additions & 6 deletions
This file was deleted.

frontend/apps/example/next-env.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
/// <reference types="next/image-types/global" />
33

44
// NOTE: This file should not be edited
5-
// see https://nextjs.org/docs/app/building-your-application/configuring/typescript for more information.
5+
// see https://nextjs.org/docs/app/api-reference/config/typescript for more information.

frontend/apps/example/package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,19 @@
33
"version": "0.1.0",
44
"private": true,
55
"scripts": {
6-
"dev": "next dev --turbopack",
6+
"dev": "next dev",
77
"build": "next build",
88
"start": "next start",
99
"test": "jest --passWithNoTests",
1010
"tsc": "tsc --noEmit",
11-
"lint": "next lint"
11+
"lint": "next lint",
12+
"clean": "rm -rf .turbo && rm -rf node_modules && rm -rf dist"
1213
},
1314
"dependencies": {
15+
"next": "^15.1.3",
1416
"pydantic-forms": "*",
15-
"next": "15.0.3",
1617
"react": "18.*",
17-
"react-dom": "18.*",
18-
"swr": "^2.2.5"
18+
"react-dom": "18.*"
1919
},
2020
"devDependencies": {
2121
"@orchestrator-ui/eslint-config-custom": "^1.4.1",
Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,40 @@
11
'use client';
22

3-
import { useEffect, useState } from 'react';
3+
import PydanticForm from 'pydantic-forms';
4+
import type { PydanticFormProvider } from 'pydantic-forms';
45

5-
// import PydanticForm from 'pydantic-forms';
66
import styles from './page.module.css';
77

88
export default function Home() {
9-
const [formDefinition, setFormDefinition] = useState(null);
10-
11-
useEffect(() => {
12-
fetch('http://localhost:8000/form', {
9+
const pydanticFormProvider: PydanticFormProvider = async ({
10+
requestBody,
11+
}) => {
12+
const fetchResult = await fetch('http://localhost:8000/form', {
1313
method: 'POST',
1414
headers: {
1515
'Content-Type': 'application/json',
1616
},
17-
body: JSON.stringify([]),
18-
})
19-
.then((response) => response.json())
20-
.then((data) => {
21-
setFormDefinition(data.form);
22-
});
23-
}, []);
17+
body: JSON.stringify(requestBody),
18+
});
19+
const jsonResult = await fetchResult.json();
20+
return jsonResult;
21+
};
2422

2523
return (
2624
<div className={styles.page}>
2725
<h1>Pydantic Form</h1>
2826

29-
<div>{JSON.stringify(formDefinition)}</div>
27+
<PydanticForm
28+
id="theForm"
29+
onSuccess={() => {
30+
alert('Form submitted successfully');
31+
}}
32+
config={{
33+
formProvider: pydanticFormProvider,
34+
}}
35+
headerComponent={<div>HEADER COMPONENT</div>}
36+
footerComponent={<div>FOOTER COMPONENT</div>}
37+
/>
3038
</div>
3139
);
3240
}

0 commit comments

Comments
 (0)