Skip to content

Commit

Permalink
Merge pull request #179 from CBIIT/2.6-updates
Browse files Browse the repository at this point in the history
2.6 updates
  • Loading branch information
alifr authored Aug 22, 2022
2 parents 9b21794 + ac5e753 commit 306739f
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 22 deletions.
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,7 @@
"trim": "^1.0.1"
},
"scripts": {
"dev": "npm run mock & ./node_modules/.bin/env-cmd -e local react-scripts start",
"start": "npm run copyfiles & npm run mock & ./node_modules/.bin/env-cmd -e local react-scripts start",
"start": "npm run mock & ./node_modules/.bin/env-cmd -e local react-scripts start",
"build": "npm run copyfiles & react-scripts build",
"test": "npm run copyfiles & react-scripts test",
"mock": "json-server --watch ./src/data/mockData.json --port 5000 --routes ./server/routes.json --middlewares ./server/getUser.js ./server/getProviders.js ./server/singular.js",
Expand Down
4 changes: 2 additions & 2 deletions src/components/NewsEvents/NewsEventsTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const useStyles = makeStyles( theme => ({
// fontWeight: 'bold'
// },
tableDate: {
width: 120,
width: 170,
}

}),{name: 'ViewMessages'})
Expand Down Expand Up @@ -69,7 +69,7 @@ const NewsEventsTable = (props) => {
<TableBody>
{data.slice(page * rowsPerPage, page * rowsPerPage + rowsPerPage).map((item, i) => (
<TableRow key={item.id} className={classes.tableRow} data-index={i}>
<TableCell className={classes.tableDate}>{moment(item.publishedDate).format('M/D/YYYY')}</TableCell>
<TableCell className={classes.tableDate}>{moment(item.publishedDate).format('MMMM YYYY')}</TableCell>
<TableCell className={classes.tableTitle}><a href={item.link} rel='noopener noreferrer' target="_blank">{item.title}</a></TableCell>
</TableRow>
))}
Expand Down
2 changes: 2 additions & 0 deletions src/components/region/Header/Header.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import {
Search as SearchIcon,
Clear as ClearIcon,
} from '@material-ui/icons'
import moment from 'moment'

import LoginButton from '../../login/LoginButton'
import MenuGroup from './MenuGroup'
Expand Down Expand Up @@ -228,6 +229,7 @@ const Header = () => {
e.preventDefault()
const newLang = i18n.languages[0] === 'en' ? "es" : "en"
i18n.changeLanguage(newLang)
moment.locale(newLang)
}

return (
Expand Down
42 changes: 24 additions & 18 deletions src/pages/research/ArticlePage.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,16 @@ const useStyles = makeStyles( theme => ({

const Article = (props) => {
const classes = useStyles()
const { t, i18n } = useTranslation(`r_${caseConverter(props.article)}`)
const nameSpace = `r_${caseConverter(props.article)}`
const { t, i18n } = useTranslation([nameSpace,'common'])
const theme = useTheme()
const isMobile = useMediaQuery(theme.breakpoints.down('xs'))

useEffect(() => {
PubSub.publish('ANALYTICS', {
event:'pageview',
prop6: t('metaData.title'),
prop10: t('metaData.title'),
prop6: t('pageTitle'),
prop10: `${t("pageTitle")} | ${t("common:nav.research")}`,
})
},[t])

Expand All @@ -56,13 +57,13 @@ const Article = (props) => {
return (
<Box component="article">
<Helmet>
<title>{t("metaData.title")}</title>
<meta name="title" content={t("metaData.title")} />
<meta property="og:title" content={t("metaData.OG_title")} />
<meta name="description" content={t("metaData.description")} />
<meta property="og:description" content={t("metaData.OG_description")} />
<link rel="canonical" href={`${process.env.REACT_APP_PUBLIC_URL}/research`} />
<meta property="og:url" content={`${process.env.REACT_APP_PUBLIC_URL}/research`} />
<title>{`${t("pageTitle")} | ${t("common:nav.research")}`}</title>
<meta name="title" content={`${t("pageTitle")} | ${t("common:nav.research")}`} />
<meta property="og:title" content={t("pageTitle")} />
<meta name="description" content={t("intro_text")} />
<meta property="og:description" content={t("intro_text")} />
<link rel="canonical" href={process.env.REACT_APP_PUBLIC_URL + t('pageRoute')} />
<meta property="og:url" content={process.env.REACT_APP_PUBLIC_URL + t('pageRoute')} />
</Helmet>
<Container className="pageHeader--gradient">
<Typography variant="h2" component="h1">
Expand All @@ -78,7 +79,7 @@ const Article = (props) => {
</Typography>
</Grid>

{t('img') !== 'img' && <Grid className={classes.gridItemImg} item xs={12} md={6} component="aside">
{i18n.exists(`${nameSpace}:img`) && <Grid className={classes.gridItemImg} item xs={12} md={6} component="aside">
<ArticleImage src={t('img.0.file_name')} alt={t('img.0.alt_text')} />
</Grid>
}
Expand All @@ -87,18 +88,23 @@ const Article = (props) => {

{Object.keys(t('sections', { returnObjects: true })).map((section, i) =>
<Grid item xs={12} md={8} component="section" key={i}>
<Typography variant="h3" component="h3">
<RenderContent children={t(`sections.${i}.title`)} />
</Typography>
{i18n.exists(`${nameSpace}:sections.${i}.title`) &&
<Typography variant="h3" component="h3">
<RenderContent children={t(`sections.${i}.title`)} />
</Typography>
}
{/* Render blockquotes if they're provided for this section */}
{t(`sections.${i}.quote`) !== `sections.${i}.quote` && <blockquote>
{i18n.exists(`${nameSpace}:sections.${i}.quote`) &&
<blockquote>
<Typography>{t(`sections.${i}.quote.text`)}</Typography>
<cite>{t(`sections.${i}.quote.cite`)}</cite>
</blockquote>
}
<Typography component="div">
<RenderContent children={t(`sections.${i}.body`)} />
</Typography>
{i18n.exists(`${nameSpace}:sections.${i}.body`) &&
<Typography component="div">
<RenderContent children={t(`sections.${i}.body`)} />
</Typography>
}
</Grid>
)}
</Grid>
Expand Down
1 change: 1 addition & 0 deletions src/routers/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ import { useTranslation } from 'react-i18next'
// imports for time
import moment from 'moment'
import 'moment/locale/es'
moment.locale('en')

const SearchResults = lazy(() => import('../pages/SearchResultsPage'))

Expand Down
2 changes: 2 additions & 0 deletions src/routers/routes_dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ import { useTranslation } from 'react-i18next'
// imports for time
import moment from 'moment'
import 'moment/locale/es'
moment.locale('en')

const SearchResults = lazy(() => import('../pages/SearchResultsPage'))

Expand Down Expand Up @@ -80,6 +81,7 @@ const PrivateRoute = ({ component: Component, ...rest }) => {
if(state.auth) {
// set default language in case it's not specified
const lang = state.lang || "en"
console.log('lang', lang)
// set date format based on language
moment.locale(lang)
if(lang !== i18n.language) {
Expand Down

0 comments on commit 306739f

Please sign in to comment.