Skip to content

Commit

Permalink
Add initial files
Browse files Browse the repository at this point in the history
  • Loading branch information
akainic committed Jun 5, 2018
0 parents commit d38aeac
Show file tree
Hide file tree
Showing 12 changed files with 11,001 additions and 0 deletions.
1 change: 1 addition & 0 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{ "presets": ["react", "es2015"] }
11 changes: 11 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Directories to ignore
node_modules/
.babelcache/
build/

# Files to ignore
._*
.cache
.DS_Store
npm-debug.log
*.log
29 changes: 29 additions & 0 deletions app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import React from 'react';
import ReactDOM from 'react-dom';
import { IndexRedirect, Route, Router, useRouterHistory } from 'react-router';
import { Provider } from 'react-redux';
import { createStore, combineReducers } from 'redux';
import { createHistory } from 'history';

import route from './js/routes.jsx';
import reducer from './js/reducers';
import Form from './js/components/Form.jsx';

const store = createStore(combineReducers(reducer));

const browserHistory = useRouterHistory(createHistory)({
basename: '/'
});

console.log(browserHistory);
console.log(route);

ReactDOM.render(
(
<Provider store={store}>
<Router history={browserHistory}>
{route}
</Router>
</Provider>
), document.getElementById('root')
);
12 changes: 12 additions & 0 deletions js/components/Form.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import React from 'react';

import FormApp from 'us-forms-system/lib/js/containers/FormApp';
import formConfig from '../config/form';

export default function Form({ location, children }) {
return (
<FormApp formConfig={formConfig} currentLocation={location}>
{children}
</FormApp>
);
}
51 changes: 51 additions & 0 deletions js/config/form.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import fullName from '../definitions/fullName';

const formConfig = {
title: 'Form',
subTitle: 'Test',
formId: '',
urlPrefix: '/',
trackingPrefix: 'form-',
transformForSubmit: '',
submitUrl: '',
introduction: '',
confirmation: '',
defaultDefinitions: {
fullName
},
chapters: {
firstSection: {
title: 'First Section',
pages: {
firstPage: {
path: 'first-section/first-page',
title: 'First Page',
uiSchema: {},
schema: {
type: 'object',
properties: {
fullName
}
}
},
secondPage: {
path: 'first-section/second-page',
title: 'Second Page',
uiSchema: {},
schema: {
type: 'object',
properties: {}
}
}
}
},
secondSection: {
title: 'Second Section',
pages: {

}
}
}
};

export default formConfig;
38 changes: 38 additions & 0 deletions js/definitions/fullName.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
const suffixes = [
'Jr.',
'Sr.',
'II',
'III',
'IV'
];

const schema = {
type: 'object',
properties: {
first: {
type: 'string',
pattern: '^.*\\S.*',
minLength: 1,
maxLength: 30
},
middle: {
type: 'string'
},
last: {
type: 'string',
pattern: '^.*\\S.*',
minLength: 2,
maxLength: 30
},
suffix: {
type: 'string',
'enum': suffixes
},
},
required: [
'first',
'last'
]
};

export default schema;
6 changes: 6 additions & 0 deletions js/reducers.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import formConfig from './config/form';
import createSchemaFormReducer from 'us-forms-system/lib/js/state';

export default {
form: createSchemaFormReducer(formConfig)
};
13 changes: 13 additions & 0 deletions js/routes.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { createRoutes } from 'us-forms-system/lib/js/helpers';

import formConfig from './config/form';
import Form from './components/Form.jsx';

const route = {
path: '/',
component: Form,
indexRoute: { onEnter: (nextState, replace) => replace('/first-section/first-page') },
childRoutes: createRoutes(formConfig),
};

export default route;
Loading

0 comments on commit d38aeac

Please sign in to comment.