Skip to content

Commit

Permalink
fix flow issues
Browse files Browse the repository at this point in the history
  • Loading branch information
erichartline committed Aug 21, 2018
1 parent 3908d53 commit ae3caaf
Show file tree
Hide file tree
Showing 4 changed files with 106 additions and 101 deletions.
9 changes: 9 additions & 0 deletions flow-typed/Types.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,12 @@ declare module "ProtVista/style/main.css" {
declare module "font-awesome/css/font-awesome.min.css" {
declare module.exports: any
}

class process {
static env: {
REACT_APP_API_SERVER: string,
REACT_APP_BASENAME: string,
REACT_APP_NAVBAR_JSON: string,
REACT_APP_FOOTER_JSON: string,
}
}
12 changes: 9 additions & 3 deletions src/common/components/GeneNotFound.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,27 @@
import React from "react"
import { Flex, Box } from "rebass"
import FontAwesome from "react-fontawesome"
import { SaveButton, Jumbotron, RouterLink } from "styles/style"
import { Jumbotron } from "styles/style"

type Props = {
/** The ID of the gene that cannot be found */
gene: string,
}

/**
* Gene not found error page
*/

const GeneNotFound = props => {
const GeneNotFound = (props: Props) => {
const { gene } = props
return (
<Flex justify="center" style={{ marginTop: "20px" }}>
<Box w="60%">
<Jumbotron>
<h3>
<FontAwesome name="info" /> Gene not found
</h3>
<p>{props.gene} is not in the database</p>
<p>{gene} is not in the database</p>
<Flex justify="center">
<Box w={["90%", "60%", "25%"]}>
<ul>
Expand Down
93 changes: 44 additions & 49 deletions src/features/Ontology/goaActions.js
Original file line number Diff line number Diff line change
@@ -1,70 +1,65 @@
// @flow
import printError from "common/utils/printError"
import {
FETCH_GOA_REQUEST,
FETCH_GOA_FAILURE,
FETCH_GOA_SUCCESS,
} from "./goaConstants"
import printError from "common/utils/printError"

/**
* All of the Redux actions related to GOA data
*/

const fetchGoaRequest = () => {
return {
type: FETCH_GOA_REQUEST,
payload: {
isFetching: true,
},
}
}
const fetchGoaRequest = () => ({
type: FETCH_GOA_REQUEST,
payload: {
isFetching: true,
},
})

const fetchGoaFailure = error => {
return {
type: FETCH_GOA_FAILURE,
payload: {
isFetching: false,
error: error,
},
}
}
const fetchGoaFailure = error => ({
type: FETCH_GOA_FAILURE,
payload: {
isFetching: false,
error,
},
})

const fetchGoaSuccess = (data: Object) => {
return {
type: FETCH_GOA_SUCCESS,
payload: {
isFetching: false,
data,
},
}
}
const fetchGoaSuccess = (data: Object) => ({
type: FETCH_GOA_SUCCESS,
payload: {
isFetching: false,
data,
},
})

export const fetchGoa = (url: string) => {
return async (dispatch: Function, getState) => {
if (getState().goa.data) {
return
}
try {
dispatch(fetchGoaRequest())
const res = await fetch(url, {
headers: { Accept: "application/json" },
})
const json = await res.json()
if (res.ok) {
if (json.status >= 300) {
dispatch(fetchGoaFailure(json.title))
}
dispatch(fetchGoaSuccess(json))
} else {
export const fetchGoa = (url: string) => async (
dispatch: Function,
getState: Function,
) => {
if (getState().goa.data) {
return
}
try {
dispatch(fetchGoaRequest())
const res = await fetch(url, {
headers: { Accept: "application/json" },
})
const json = await res.json()
if (res.ok) {
if (json.status >= 300) {
dispatch(fetchGoaFailure(json.title))
if (process.env.NODE_ENV !== "production") {
printError(res, json)
}
}
} catch (error) {
dispatch(fetchGoaSuccess(json))
} else {
dispatch(fetchGoaFailure(json.title))
if (process.env.NODE_ENV !== "production") {
console.error(`Network error: ${error.message}`)
printError(res, json)
}
}
} catch (error) {
if (process.env.NODE_ENV !== "production") {
console.error(`Network error: ${error.message}`)
}
}
}
93 changes: 44 additions & 49 deletions src/features/Summary/summaryActions.js
Original file line number Diff line number Diff line change
@@ -1,71 +1,66 @@
// @flow
// import { push } from "connected-react-router"
import printError from "common/utils/printError"
import {
FETCH_GENERAL_DATA_REQUEST,
FETCH_GENERAL_DATA_FAILURE,
FETCH_GENERAL_DATA_SUCCESS,
} from "./summaryConstants"
import printError from "common/utils/printError"

/**
* All of the Redux actions related to the Summary tab
*/

const fetchGeneralDataRequest = () => {
return {
type: FETCH_GENERAL_DATA_REQUEST,
payload: {
isFetching: true,
},
}
}
const fetchGeneralDataRequest = () => ({
type: FETCH_GENERAL_DATA_REQUEST,
payload: {
isFetching: true,
},
})

const fetchGeneralDataFailure = error => {
return {
type: FETCH_GENERAL_DATA_FAILURE,
payload: {
isFetching: false,
error: error,
},
}
}
const fetchGeneralDataFailure = error => ({
type: FETCH_GENERAL_DATA_FAILURE,
payload: {
isFetching: false,
error,
},
})

const fetchGeneralDataSuccess = (data: Array<Object>) => {
return {
type: FETCH_GENERAL_DATA_SUCCESS,
payload: {
isFetching: false,
data,
},
}
}
const fetchGeneralDataSuccess = (data: Array<Object>) => ({
type: FETCH_GENERAL_DATA_SUCCESS,
payload: {
isFetching: false,
data,
},
})

export const fetchGeneralData = (url: string) => {
return async (dispatch: Function, getState) => {
if (getState().general.data) {
return
}
try {
dispatch(fetchGeneralDataRequest())
const res = await fetch(url, {
headers: { Accept: "application/json" },
})
const json = await res.json()
if (res.ok) {
if (json.status >= 300) {
dispatch(fetchGeneralDataFailure(json.title))
}
dispatch(fetchGeneralDataSuccess(json))
} else {
export const fetchGeneralData = (url: string) => async (
dispatch: Function,
getState: Function,
) => {
if (getState().general.data) {
return
}
try {
dispatch(fetchGeneralDataRequest())
const res = await fetch(url, {
headers: { Accept: "application/json" },
})
const json = await res.json()
if (res.ok) {
if (json.status >= 300) {
dispatch(fetchGeneralDataFailure(json.title))
if (process.env.NODE_ENV !== "production") {
printError(res, json)
}
}
} catch (error) {
dispatch(fetchGeneralDataSuccess(json))
} else {
dispatch(fetchGeneralDataFailure(json.title))
if (process.env.NODE_ENV !== "production") {
console.error(`Network error: ${error.message}`)
printError(res, json)
}
}
} catch (error) {
if (process.env.NODE_ENV !== "production") {
console.error(`Network error: ${error.message}`)
}
}
}

0 comments on commit ae3caaf

Please sign in to comment.