Skip to content
This repository has been archived by the owner on Jan 4, 2023. It is now read-only.

Commit

Permalink
Create app (#2)
Browse files Browse the repository at this point in the history
* initialization of profile editor without typescript

* clean variables name and start adding typescript

* add read me

* add redux to project

* redux installed

* taking review and updating code

Co-authored-by: Melina Chamayou &  Pierrick Bellut <[email protected]>
  • Loading branch information
Klochette and Melina Chamayou & Pierrick Bellut authored Jul 29, 2020
1 parent 159682a commit 675ffa8
Show file tree
Hide file tree
Showing 23 changed files with 16,358 additions and 0 deletions.
23 changes: 23 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
/node_modules
/.pnp
.pnp.js

# testing
/coverage

# production
/build

# misc
.DS_Store
.env.local
.env.development.local
.env.test.local
.env.production.local

npm-debug.log*
yarn-debug.log*
yarn-error.log*
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
##Install yarn
`yarn install`

##Launch project
`yarn start:staging`
72 changes: 72 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
{
"name": "youyoucopy",
"version": "0.1.0",
"private": true,
"dependencies": {
"@ahryman40k/ts-fhir-types": "^4.0.32",
"@arkhn/fhir.ts": "^3.4.2",
"@date-io/core": "^1.3.6",
"@material-ui/core": "^4.11.0",
"@material-ui/icons": "^4.9.1",
"@material-ui/lab": "^4.0.0-alpha.53",
"@material-ui/styles": "^4.9.10",
"@testing-library/dom": "^7.20.2",
"@testing-library/jest-dom": "^4.2.4",
"@testing-library/react": "^9.5.0",
"@testing-library/user-event": "^7.2.1",
"@types/fhir": "^0.0.31",
"@types/graphql": "^14.5.0",
"@types/react": "^16.9.43",
"@types/react-redux": "^7.1.9",
"@types/react-router-dom": "^5.1.5",
"axios": "^0.19.2",
"bootstrap": "^4.5.0",
"classnames": "^2.2.6",
"clsx": "^1.1.0",
"d3": "^5.16.0",
"history": "^4.10.1",
"jquery": "1.9.1",
"material-table": "^1.57.2",
"moment": "^2.25.3",
"node-sass": "^4.14.1",
"popper.js": "^1.16.0",
"prop-types": "^15.7.2",
"react": "^16.13.1",
"react-bootstrap": "^1.0.1",
"react-dom": "^16.13.1",
"react-pdf": "^4.1.0",
"react-player": "^2.2.0",
"react-redux": "^7.2.0",
"react-router": "^5.1.2",
"react-router-dom": "^5.2.0",
"react-scripts": "3.4.1",
"redux": "^4.0.5",
"redux-logger": "^3.0.6",
"redux-persist": "^6.0.0",
"redux-promise": "^0.6.0",
"redux-thunk": "^2.3.0",
"serve": "^11.3.1",
"typescript": "^3.9.6"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"eslintConfig": {
"extends": "react-app"
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
}
}
Binary file added public/favicon.ico
Binary file not shown.
43 changes: 43 additions & 0 deletions public/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="#000000" />
<meta
name="description"
content="Web site created using create-react-app"
/>
<link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />
<!--
manifest.json provides metadata used when your web app is installed on a
user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
-->
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
<!--
Notice the use of %PUBLIC_URL% in the tags above.
It will be replaced with the URL of the `public` folder during the build.
Only files inside the `public` folder can be referenced from the HTML.
Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
work correctly both with client-side routing and a non-root public URL.
Learn how to configure a non-root public URL by running `npm run build`.
-->
<title>React App</title>
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
<div id="root"></div>
<!--
This HTML file is a template.
If you open it directly in the browser, you will see an empty page.
You can add webfonts, meta tags, or analytics to this file.
The build step will place the bundled scripts into the <body> tag.
To begin the development, run `npm start` or `yarn start`.
To create a production bundle, use `npm run build` or `yarn build`.
-->
</body>
</html>
Binary file added public/logo192.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/logo512.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
25 changes: 25 additions & 0 deletions public/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"short_name": "React App",
"name": "Create React App Sample",
"icons": [
{
"src": "favicon.ico",
"sizes": "64x64 32x32 24x24 16x16",
"type": "image/x-icon"
},
{
"src": "logo192.png",
"type": "image/png",
"sizes": "192x192"
},
{
"src": "logo512.png",
"type": "image/png",
"sizes": "512x512"
}
],
"start_url": ".",
"display": "standalone",
"theme_color": "#000000",
"background_color": "#ffffff"
}
3 changes: 3 additions & 0 deletions public/robots.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# https://www.robotstxt.org/robotstxt.html
User-agent: *
Disallow:
20 changes: 20 additions & 0 deletions src/components/App.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import React from "react";
import initStore from '../state/store';
import { Provider } from 'react-redux';
import Homepage from './homepage/Homepage';
import { getData } from "../state/thunkMiddleware";


const store = initStore()

const App = () => {
/* @ts-ignore */
store.dispatch(getData())
return (
<Provider store={store}>
<Homepage />
</Provider>
);
}

export default App;
20 changes: 20 additions & 0 deletions src/components/homepage/Homepage.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import React from 'react';
import { useSelector } from 'react-redux';
import { RootState } from '../../state/store';

const Homepage: React.FC<{}> = () => {
const stateApp = useSelector((state: RootState) => state);
if (stateApp.resource.loading === true){
return <p>Loading...</p>
}

return (
<div>
{stateApp.resource.data?.map((data, index) => {
return <button key={index}>{data.id}</button>
})}
</div>);

}

export default Homepage;
2 changes: 2 additions & 0 deletions src/constants.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import React from 'react';
import ReactDOM from 'react-dom';
import App from './components/App';

ReactDOM.render(
<App />,
document.getElementById('root')
);
1 change: 1 addition & 0 deletions src/react-app-env.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/// <reference types="react-scripts" />
3,187 changes: 3,187 additions & 0 deletions src/resources/patient.json

Large diffs are not rendered by default.

13 changes: 13 additions & 0 deletions src/services/api.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import axios from 'axios';
import { AUTH_TOKEN_KEY, FHIR_API_URL } from '../constants';

const token = AUTH_TOKEN_KEY;

const api = axios.create({
baseURL: FHIR_API_URL,
headers: {
authorization: `Bearer ${token}`
}
});

export default api
56 changes: 56 additions & 0 deletions src/state/actions/resourceActions.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import { IStructureDefinition } from "@ahryman40k/ts-fhir-types/lib/R4";

export const SELECT_RESOURCE = 'SELECT_RESOURCE';
export const GET_DATA_START = 'GET_DATA_START';
export const GET_DATA_SUCCESS = 'GET_DATA_SUCCESS';
export const GET_DATA_FAILURE = 'GET_DATA_FAILURE';


export type SelectResourceAction = {
type: typeof SELECT_RESOURCE,
id: string
}

export type GetDataStartAction = {
type: typeof GET_DATA_START,
}

export type GetDataSuccessAction = {
type: typeof GET_DATA_SUCCESS,
payload: IStructureDefinition[]
}

export type GetDataFailureAction = {
type: typeof GET_DATA_FAILURE,
payload: Error
}

export const selectResource = (id: string): SelectResourceAction => {
return {
type: SELECT_RESOURCE,
id
}
}

export const getDataStart = (): GetDataStartAction => {
return {
type: GET_DATA_START
}
}

export const getDataSuccess = (allDatas: IStructureDefinition[]): GetDataSuccessAction => {
return {
type: GET_DATA_SUCCESS,
payload: allDatas
}
}

export const getDataFailure = (error: Error): GetDataFailureAction => {
return {
type: GET_DATA_FAILURE,
payload: error
}
}


export type ResourceAction = SelectResourceAction
54 changes: 54 additions & 0 deletions src/state/reducers/resource.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import { R4 } from '@ahryman40k/ts-fhir-types';
import { ResourceAction, SELECT_RESOURCE, GET_DATA_SUCCESS, GetDataFailureAction, GetDataStartAction, GetDataSuccessAction, GET_DATA_START, GET_DATA_FAILURE } from '../actions/resourceActions';
import { IStructureDefinition } from '@ahryman40k/ts-fhir-types/lib/R4';

export type ResourceState = {
data: R4.IStructureDefinition[];
profiles: R4.IStructureDefinition[];
selectedResourceId: string | null;
selectedAttributeId: string | null;
loading: boolean;
error: Error | null;
}

const initialState: ResourceState = {
data: [],
profiles: [],
selectedResourceId: null,
selectedAttributeId: null,
loading: false,
error: null
}

export type AllResourcesAction = GetDataFailureAction | GetDataStartAction | GetDataSuccessAction | ResourceAction;

export const resource = (state: ResourceState = initialState, action: AllResourcesAction): ResourceState => {
switch (action.type) {
case SELECT_RESOURCE:
return {
...state,
selectedResourceId: action.id
}
case GET_DATA_START:
return {
...state,
loading: true
}
case GET_DATA_SUCCESS:
return {
...state,
loading: false,
data: action.payload,
error: null
}
case GET_DATA_FAILURE:
return {
...state,
loading: false,
data: [],
error: action.payload
}
default:
return state;
}
}
15 changes: 15 additions & 0 deletions src/state/store.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { createStore, combineReducers, applyMiddleware } from 'redux'
import { resource } from './reducers/resource';
import thunk from 'redux-thunk'

const rootReducer = combineReducers({
resource
})

const initStore = () => {
return createStore(rootReducer, applyMiddleware(thunk))
}

export type RootState = ReturnType<typeof rootReducer>

export default initStore;
Loading

0 comments on commit 675ffa8

Please sign in to comment.