diff --git a/.storybook/webpack.config.js b/.storybook/webpack.config.js index 38c50f2..4511c66 100644 --- a/.storybook/webpack.config.js +++ b/.storybook/webpack.config.js @@ -1,6 +1,20 @@ const path = require('path'); module.exports = async ({ config, mode }) => { + // See https://medium.com/@derek_19900/config-storybook-4-to-use-svgr-webpack-plugin-22cb1152f004 + const fileLoaderRule = config.module.rules.find(rule => + rule.test.test('.svg') + ); + fileLoaderRule.exclude = [path.resolve(__dirname, '../src')]; + + config.module.rules.unshift( + // SVG + { + test: /\.svg$/, + use: ['@svgr/webpack'] + } + ); + config.module.rules.push({ test: /\.css$/, sideEffects: true, diff --git a/src/components/home.stories.js b/src/components/home.stories.js index 6a0daac..3eca8e1 100644 --- a/src/components/home.stories.js +++ b/src/components/home.stories.js @@ -1,8 +1,16 @@ import React from 'react'; import Home from './home'; +import { BrowserRouter as Router } from 'react-router-dom'; +import { UserProvider } from '../contexts/user-context'; export default { title: 'home' }; export function empty() { - return ; + return ( + + + + + + ); } diff --git a/src/utils/actions.js b/src/utils/actions.js index a4e46f3..c650e7a 100644 --- a/src/utils/actions.js +++ b/src/utils/actions.js @@ -37,3 +37,25 @@ export function getReviewAnswers(answerMap = {}) { export function checkIfAllAnswered(answerMap = {}) { return QUESTIONS.every(({ identifier }) => answerMap[identifier]); } + +export function checkIfHasReviewed(user = {}, actions = []) { + return arrayify(user.hasRole).some(role => { + return arrayify(actions).some(action => { + return ( + action['@type'] === 'RapidPREreviewAction' && + getId(action.agent) === getId(role) + ); + }); + }); +} + +export function checkIfHasRequested(user = {}, actions = []) { + return arrayify(user.hasRole).some(role => { + return arrayify(actions).some(action => { + return ( + action['@type'] === 'RequestForRapidPREreviewAction' && + getId(action.agent) === getId(role) + ); + }); + }); +}