Skip to content

Commit

Permalink
Add views and config dirs
Browse files Browse the repository at this point in the history
Move apollo config
Move uri and clientID keys (get_uri)
Closes #179
  • Loading branch information
thinktwice13 committed Dec 6, 2018
1 parent d96a105 commit 3827a79
Show file tree
Hide file tree
Showing 23 changed files with 661 additions and 670 deletions.
10 changes: 4 additions & 6 deletions build_fragments.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const fetch = require('node-fetch');
const fs = require('fs');
const { uri } = require('./src/get_uri')
const { uri } = require('config/keys');

fetch(uri, {
method: 'POST',
Expand All @@ -26,16 +26,14 @@ fetch(uri, {
.then(result => result.json())
.then(result => {
// here we're filtering out any type information unrelated to unions or interfaces
const filteredData = result.data.__schema.types.filter(
type => type.possibleTypes !== null,
);
const filteredData = result.data.__schema.types.filter(type => type.possibleTypes !== null);
result.data.__schema.types = filteredData;
fs.writeFile('./src/fragmentTypes.json', JSON.stringify(result.data), err => {
if (err) {
console.error('Error writing fragmentTypes file', err);
} else {
console.log('Fragment types successfully extracted!');
}
console.log({ uri })
console.log({ uri });
});
});
});
112 changes: 60 additions & 52 deletions src/App.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import * as React from 'react';
import { Switch, Route } from "react-router-dom";
import Footer from "./components/Footer/Footer";
import Landing from "./components/Landing";
import Staff from "./components/Pages/Staff";
import PrivacyPolicy from "./components/Pages/PrivacyPolicy";
import FAQ from "./components/Pages/FAQ";
import companyFAQ from "./static-api-elements/companyFAQ";
import programFAQ from "./static-api-elements/programFAQ";
import CurrentPrograms from "./components/Pages/CurrentPrograms";
import { Switch, Route } from 'react-router-dom';
import Footer from './components/Footer/Footer';
import Landing from './components/Landing';
import Staff from './components/Pages/Staff';
import PrivacyPolicy from './components/Pages/PrivacyPolicy';
import FAQ from './components/Pages/FAQ';
import companyFAQ from './static-api-elements/companyFAQ';
import programFAQ from './static-api-elements/programFAQ';
import CurrentPrograms from './components/Pages/CurrentPrograms';
import UserProfile from './components/UserProfile';
import Missing404Page from './components/404/404';
import Header from './components/Header/Header';
Expand All @@ -16,67 +16,75 @@ import VoyagePortal from './components/VoyagePortal';
import VoyageApplication from './components/VoyageApplication';
import Register from './components/Register';
import Login from './components/Login';
import FeedPortal from "./components/FeedPortal"
import Private from "./components/utilities/PrivateRoute"
import FeedPortal from './components/FeedPortal';
import Private from './components/utilities/PrivateRoute';
import AllProjects from './components/AllProjects';
import ProjectStandup from "./components/ProjectStandup";
import ProjectShowcase from "./components/ProjectShowcase"
import ProjectStandup from './components/ProjectStandup';
import ProjectShowcase from './components/ProjectShowcase';
import Ticketbox from './components/Ticketbox';
// import HelpPage from "./components/HelpPage" TODO: uncomment when ready


export default () => (
<div className="App">
<div className='App'>
<Header />
<Switch>
<Route exact path="/" component={Landing} />
<Route exact path="/login" component={Login} />
<Route exact path='/' component={Landing} />
<Route exact path='/login' component={Login} />
<Private
exact path="/register"
exact
path='/register'
render={
() => <Register version={null} /> // set custom 'chingu_application' version here
}
/>
<Private exact path="/profile" component={UserProfile} />
<Route exact path="/profile/:username" component={UserProfile} />
<Private exact path="/voyage" component={VoyagePortal} />
<Private exact path='/profile' component={UserProfile} />
<Route exact path='/profile/:username' component={UserProfile} />
<Private exact path='/voyage' component={VoyagePortal} />
<Private
exact path="/voyage/application/:voyage_id"
render={
({ match: { params: { voyage_id } } }) => (
<VoyageApplication
voyage_id={voyage_id}
voyageVersion={null} // set custom 'voyage_application' version here
newUserVersion={null} // set custom 'new_voyage_user' version here
/>
)
}
exact
path='/voyage/application/:voyage_id'
render={({
match: {
params: { voyage_id },
},
}) => (
<VoyageApplication
voyage_id={voyage_id}
voyageVersion={null} // set custom 'voyage_application' version here
newUserVersion={null} // set custom 'new_voyage_user' version here
/>
)}
/>
<Private exact path="/newsfeed" component={FeedPortal} />
<Private exact path="/team/checkin/:id" component={WeeklyCheckin} />
<Route exact path="/projects" component={AllProjects} />
<Private exact path='/newsfeed' component={FeedPortal} />
<Private exact path='/team/checkin/:id' component={WeeklyCheckin} />
<Route exact path='/projects' component={AllProjects} />
<Private
exact path="/project/standup/:standup_id"
render={
({ match: { params: { standup_id } } }) => (
<ProjectStandup
standup_id={standup_id}
standupVersion={null}
/>
)
}
exact
path='/project/standup/:standup_id'
render={({
match: {
params: { standup_id },
},
}) => <ProjectStandup standup_id={standup_id} standupVersion={null} />}
/>
<Route exact path="/current" component={CurrentPrograms} />
<Route exact path="/team" component={Staff} />
<Route exact path="/privacy" component={PrivacyPolicy} />
<Route exact path='/current' component={CurrentPrograms} />
<Route exact path='/team' component={Staff} />
<Route exact path='/privacy' component={PrivacyPolicy} />
{/* TODO: uncomment when ready <Route exact path="/help" component={HelpPage} /> */}
<Route exact path="/companyfaq" render={() => <FAQ headerText="Company FAQs" data={companyFAQ} />} />
<Route exact path="/programfaq" render={() => <FAQ headerText="Program FAQs" data={programFAQ} />} />
<Route exact path="/project/:project_id" component={ProjectShowcase} />
<Route path="*" exact component={Missing404Page} />
<Route
exact
path='/companyfaq'
render={() => <FAQ headerText='Company FAQs' data={companyFAQ} />}
/>
<Route
exact
path='/programfaq'
render={() => <FAQ headerText='Program FAQs' data={programFAQ} />}
/>
<Route exact path='/project/:project_id' component={ProjectShowcase} />
<Route path='*' exact component={Missing404Page} />
</Switch>
<Ticketbox />
<Footer />
</div>
)

);
100 changes: 45 additions & 55 deletions src/components/DynamicForm/index.jsx
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
import React from "react";
import PropTypes from "prop-types";
import { Query } from "react-apollo";
import React from 'react';
import PropTypes from 'prop-types';
import { Query } from 'react-apollo';

import './DynamicForm.css';
import { client } from 'config/apollo';
import Loader from '../Loader';
import Error from '../Error';
import { client } from "../../";
import {
DynamicFormWrapper,
DynamicFormContainer,
dynamicFormMaker,
questionComponents,
} from "./components";
} from './components';

import dynamicFormQuery from "./dynamicFormQuery";
import dynamicFormSubmitMutation from "./dynamicFormSubmitMutation";
import dynamicFormQuery from './dynamicFormQuery';
import dynamicFormSubmitMutation from './dynamicFormSubmitMutation';

const parseParams = (queryString) => {
const parseParams = queryString => {
const queryParams = new URLSearchParams(queryString);
const params = {};
for(let entry of queryParams.entries()) {
if(entry.length) {
if(params[entry[0]]) {
if(Array.isArray(params[entry[0]])) {
for (const entry of queryParams.entries()) {
if (entry.length) {
if (params[entry[0]]) {
if (Array.isArray(params[entry[0]])) {
params[entry[0]].push(...entry.slice(1));
} else {
params[entry[0]] = [params[entry[0]], ...entry.slice(1)];
Expand All @@ -33,7 +33,7 @@ const parseParams = (queryString) => {
}
}
return params;
}
};

/**
* @prop {string} purpose Dynamic Form purpose
Expand All @@ -47,50 +47,40 @@ const parseParams = (queryString) => {
* @prop {func} onResponse custom handler for mutation response data
* @prop {func} onError custom handler for mutation error
*/
const DynamicForm = (
{
purpose,
version,
hiddenData,
queryString,
mutation,
onValidate,
onSubmit,
onResponse,
onError,
},
) => (
const DynamicForm = ({
purpose,
version,
hiddenData,
queryString,
mutation,
onValidate,
onSubmit,
onResponse,
onError,
}) => (
<Query query={dynamicFormQuery} variables={{ purpose, version }}>
{
({ data, loading, error }) => {
if (loading) return <Loader />;
if (error) return <Error error={error.message} />;
if (data.dynamicFormData) {
const { dynamicFormData } = data;
return (
<DynamicFormWrapper
client={client}
mutation={mutation}
hiddenData={
queryString || hiddenData ?
Object.assign(hiddenData, parseParams(queryString)) :
null
}
onValidate={onValidate}
onSubmit={onSubmit}
onResponse={onResponse}
onError={onError}
{...dynamicFormData}
/>
);
}
{({ data, loading, error }) => {
if (loading) return <Loader />;
if (error) return <Error error={error.message} />;
if (data.dynamicFormData) {
const { dynamicFormData } = data;
return (
<Error
error={`No Dynamic Form found: purpose: ${purpose}, version: ${version}`}
<DynamicFormWrapper
client={client}
mutation={mutation}
hiddenData={
queryString || hiddenData ? Object.assign(hiddenData, parseParams(queryString)) : null
}
onValidate={onValidate}
onSubmit={onSubmit}
onResponse={onResponse}
onError={onError}
{...dynamicFormData}
/>
)
);
}
}
return <Error error={`No Dynamic Form found: purpose: ${purpose}, version: ${version}`} />;
}}
</Query>
);

Expand All @@ -103,15 +93,15 @@ DynamicForm.propTypes = {
onSubmit: PropTypes.func,
onResponse: PropTypes.func,
onError: PropTypes.func,
}
};

DynamicForm.defaultProps = {
mutation: dynamicFormSubmitMutation,
onValidate: null,
onSubmit: null,
onResponse: null,
onError: null,
}
};

export {
DynamicForm,
Expand Down
Loading

0 comments on commit 3827a79

Please sign in to comment.