diff --git a/src/reduxStore/bars/actions.js b/src/reduxStore/bars/actions.js index 18405d9..f82e3c5 100644 --- a/src/reduxStore/bars/actions.js +++ b/src/reduxStore/bars/actions.js @@ -2,12 +2,12 @@ import * as actionTypes from './actionTypes'; import { barApi } from '../../service/api/bar'; export const getBars = () => async dispatch => { - dispatch({ type: actionTypes.GET_ALL_BARS }); + dispatch({ type: actionTypes.GET_ALL_BARS }); - try { - const bars = await barApi.getBars(); - dispatch({ type: actionTypes.GET_ALL_BARS_SUCCESS, payload: bars }); - } catch(e) { - dispatch({ type: actionTypes.GET_ALL_BARS_ERROR, payload: e }); - } -} \ No newline at end of file + try { + const bars = await barApi.getBars(); + dispatch({ type: actionTypes.GET_ALL_BARS_SUCCESS, payload: bars }); + } catch (e) { + dispatch({ type: actionTypes.GET_ALL_BARS_ERROR, payload: e }); + } +}; diff --git a/src/reduxStore/bars/reducer.js b/src/reduxStore/bars/reducer.js index 704437b..a6cce42 100644 --- a/src/reduxStore/bars/reducer.js +++ b/src/reduxStore/bars/reducer.js @@ -1,31 +1,31 @@ import * as actionTypes from './actionTypes'; const initialState = { - allBars: [], - isBarListLoading: false, - barListLoadingError: {}, -} + allBars: [], + isBarListLoading: false, + barListLoadingError: {}, +}; export function barsReducer(state = initialState, action) { - switch (action.type) { - case actionTypes.GET_ALL_BARS: - return { - ...state, - isBarListLoading: true, - }; - case actionTypes.GET_ALL_BARS_SUCCESS: - return { - ...state, - allBars: action.payload, - isBarListLoading: false, - }; - case actionTypes.GET_ALL_BARS_ERROR: - return { - ...state, - isBarListLoading: false, - barListLoadingError: action.payload, - } - default: - return state; - } + switch (action.type) { + case actionTypes.GET_ALL_BARS: + return { + ...state, + isBarListLoading: true, + }; + case actionTypes.GET_ALL_BARS_SUCCESS: + return { + ...state, + allBars: action.payload, + isBarListLoading: false, + }; + case actionTypes.GET_ALL_BARS_ERROR: + return { + ...state, + isBarListLoading: false, + barListLoadingError: action.payload, + }; + default: + return state; + } } diff --git a/src/routes/ProtectedRoutes.js b/src/routes/ProtectedRoutes.js index 4468f60..79d83fa 100644 --- a/src/routes/ProtectedRoutes.js +++ b/src/routes/ProtectedRoutes.js @@ -3,7 +3,7 @@ import { Switch } from 'react-router-dom'; // eslint-disable-next-line import/no-named-as-default-member import PrivateRoute from '../ui/components/AuthHOC'; import BarCrawlPage from '../ui/components/BarCrawlPage'; -import Bars from '../ui/components/Bars'; +import BarPage from '../ui/components/BarPage'; const ProtectedRoutes = () => { return ( @@ -15,7 +15,7 @@ const ProtectedRoutes = () => { - + ); diff --git a/src/ui/components/BarCrawlPage/BarCrawlItem/BarCrawlItem.scss b/src/ui/components/BarCrawlPage/BarCrawlItem/BarCrawlItem.scss new file mode 100644 index 0000000..ecc1f22 --- /dev/null +++ b/src/ui/components/BarCrawlPage/BarCrawlItem/BarCrawlItem.scss @@ -0,0 +1,7 @@ +.barCrawl { + border: 2px solid rgb(212, 36, 36); + margin-left: 10px; + padding-left: 3px; + margin-top: 40px; + width: 300px; +} \ No newline at end of file diff --git a/src/ui/components/BarCrawlPage/BarCrawlItem/BarCrawlItemComponent.js b/src/ui/components/BarCrawlPage/BarCrawlItem/BarCrawlItemComponent.js new file mode 100644 index 0000000..835001a --- /dev/null +++ b/src/ui/components/BarCrawlPage/BarCrawlItem/BarCrawlItemComponent.js @@ -0,0 +1,32 @@ +import React from 'react'; +import { object, func, string } from 'prop-types'; +import './BarCrawlItem.scss'; + +const propTypes = { + barCrawlItem: object, + onClickHandler: func, + bcName: string, + bcTime: string, + bcPrice: string, +}; + +const BarCrawlItemComponent = ({ barCrawlItem }) => { + const { bcName, bcTime, bcPrice } = barCrawlItem; + function onClickHandler() { + console.log(barCrawlItem._id); + } + return ( +
+

{bcName}

+

{bcTime}

+

{bcPrice}

+ +
+ ); +}; + +BarCrawlItemComponent.propTypes = propTypes; + +export { BarCrawlItemComponent }; diff --git a/src/ui/components/BarCrawlPage/BarItem/BarCrawlItemContainer.js b/src/ui/components/BarCrawlPage/BarCrawlItem/BarCrawlItemContainer.js similarity index 100% rename from src/ui/components/BarCrawlPage/BarItem/BarCrawlItemContainer.js rename to src/ui/components/BarCrawlPage/BarCrawlItem/BarCrawlItemContainer.js diff --git a/src/ui/components/BarCrawlPage/BarItem/index.js b/src/ui/components/BarCrawlPage/BarCrawlItem/index.js similarity index 100% rename from src/ui/components/BarCrawlPage/BarItem/index.js rename to src/ui/components/BarCrawlPage/BarCrawlItem/index.js diff --git a/src/ui/components/BarCrawlPage/BarCrawlPageComponent.js b/src/ui/components/BarCrawlPage/BarCrawlPageComponent.js index 96eb791..7b0d70f 100644 --- a/src/ui/components/BarCrawlPage/BarCrawlPageComponent.js +++ b/src/ui/components/BarCrawlPage/BarCrawlPageComponent.js @@ -1,5 +1,5 @@ import React from 'react'; -import BarItem from './BarItem'; +import BarCrawlItem from './BarCrawlItem'; import { array } from 'prop-types'; const propTypes = { @@ -12,7 +12,7 @@ const BarCrawlPageComponent = ({ barCrawlFeed }) => {
{barCrawlFeed.length > 0 && barCrawlFeed.map(barCrawlItem => { - return ; + return ; })}
); diff --git a/src/ui/components/BarCrawlPage/BarItem/BarCrawlItemComponent.js b/src/ui/components/BarCrawlPage/BarItem/BarCrawlItemComponent.js deleted file mode 100644 index f53f4df..0000000 --- a/src/ui/components/BarCrawlPage/BarItem/BarCrawlItemComponent.js +++ /dev/null @@ -1,18 +0,0 @@ -import React from 'react'; -import { object } from 'prop-types'; - -const propTypes = { - barCrawlItem: object, -}; - -const BarCrawlItemComponent = ({ barCrawlItem }) => { - return ( -
-

test bar

-
- ); -}; - -BarCrawlItemComponent.propTypes = propTypes; - -export { BarCrawlItemComponent }; diff --git a/src/ui/components/Bars/BarItem/BarItem.scss b/src/ui/components/BarPage/BarItem/BarItem.scss similarity index 100% rename from src/ui/components/Bars/BarItem/BarItem.scss rename to src/ui/components/BarPage/BarItem/BarItem.scss diff --git a/src/ui/components/BarPage/BarItem/BarItemComponent.js b/src/ui/components/BarPage/BarItem/BarItemComponent.js new file mode 100644 index 0000000..763f96c --- /dev/null +++ b/src/ui/components/BarPage/BarItem/BarItemComponent.js @@ -0,0 +1,28 @@ +import React from 'react'; +import './BarItem.scss'; +import { object } from 'prop-types'; + +const propTypes = { + barItem: object, +}; + +const BarItemComponent = ({ barItem }) => { + const { barName, address, barInfo } = barItem; + function onClickHandler() { + console.log(barItem._id); + } + return ( +
+

{barName}

+

{address}

+

{barInfo}

+ +
+ ); +}; + +BarItemComponent.propTypes = propTypes; + +export { BarItemComponent }; diff --git a/src/ui/components/Bars/BarItem/BarItemContainer.js b/src/ui/components/BarPage/BarItem/BarItemContainer.js similarity index 100% rename from src/ui/components/Bars/BarItem/BarItemContainer.js rename to src/ui/components/BarPage/BarItem/BarItemContainer.js diff --git a/src/ui/components/Bars/BarItem/index.js b/src/ui/components/BarPage/BarItem/index.js similarity index 100% rename from src/ui/components/Bars/BarItem/index.js rename to src/ui/components/BarPage/BarItem/index.js diff --git a/src/ui/components/BarPage/BarPageComponent.js b/src/ui/components/BarPage/BarPageComponent.js new file mode 100644 index 0000000..1b52fdc --- /dev/null +++ b/src/ui/components/BarPage/BarPageComponent.js @@ -0,0 +1,14 @@ +import React from 'react'; +import BarItem from './BarItem'; + +const BarPageComponent = ({ allBars }) => { + return ( +
+ {allBars.map(item => { + return ; + })} +
+ ); +}; + +export default BarPageComponent; diff --git a/src/ui/components/BarPage/BarPageContainer.js b/src/ui/components/BarPage/BarPageContainer.js new file mode 100644 index 0000000..6bf3e31 --- /dev/null +++ b/src/ui/components/BarPage/BarPageContainer.js @@ -0,0 +1,28 @@ +import React, { useEffect } from 'react'; +import { useDispatch, useSelector } from 'react-redux'; +import BarPageComponent from './BarPageComponent'; +import { getBars } from '../../../reduxStore/bars/actions'; +import { func } from 'prop-types'; + +const propTypes = { + getBars: func, +}; + +const BarPageContainer = () => { + const allBars = useSelector(state => state.barsReducer.allBars); + const dispatch = useDispatch(); + + const useBar = someFetchActionCreator => { + useEffect(() => { + dispatch(someFetchActionCreator()); + }, [someFetchActionCreator]); + }; + + useBar(getBars); + + return ; +}; + +BarPageContainer.propTypes = propTypes; + +export default BarPageContainer; diff --git a/src/ui/components/BarPage/index.js b/src/ui/components/BarPage/index.js new file mode 100644 index 0000000..7f69b4f --- /dev/null +++ b/src/ui/components/BarPage/index.js @@ -0,0 +1,3 @@ +import BarPageContainer from './BarPageContainer'; + +export default BarPageContainer; diff --git a/src/ui/components/Bars/BarComponent.js b/src/ui/components/Bars/BarComponent.js deleted file mode 100644 index abd8396..0000000 --- a/src/ui/components/Bars/BarComponent.js +++ /dev/null @@ -1,14 +0,0 @@ -import React from 'react'; -import BarItem from './BarItem'; - -const BarComponent = ({ allBars }) => { - return ( -
- {allBars.map(item => { - return - })} -
- ); -}; - -export default BarComponent; \ No newline at end of file diff --git a/src/ui/components/Bars/BarContainer.js b/src/ui/components/Bars/BarContainer.js deleted file mode 100644 index daf7928..0000000 --- a/src/ui/components/Bars/BarContainer.js +++ /dev/null @@ -1,30 +0,0 @@ -import React, { useEffect } from 'react'; -import { useDispatch, useSelector } from 'react-redux'; -import BarComponent from './BarComponent'; -import { getBars } from '../../../reduxStore/bars/actions'; -import { func } from 'prop-types'; - -const propTypes = { - getBars: func, -}; - -const BarContainer = () => { - const allBars = useSelector(state => state.barsReducer.allBars); - const dispatch = useDispatch(); - - - - const useBar = someFetchActionCreator => { - useEffect(() => { - dispatch(someFetchActionCreator()); - }, [someFetchActionCreator]); - }; - - useBar(getBars); - - return ; -}; - -BarContainer.propTypes = propTypes; - -export default BarContainer; \ No newline at end of file diff --git a/src/ui/components/Bars/BarItem/BarItemComponent.js b/src/ui/components/Bars/BarItem/BarItemComponent.js deleted file mode 100644 index b8ae124..0000000 --- a/src/ui/components/Bars/BarItem/BarItemComponent.js +++ /dev/null @@ -1,28 +0,0 @@ -import React from 'react'; -import './BarItem.scss'; -// import propTypes from 'prop-types'; - -const BarItemComponent = ({barItem}) => { - const { barName, address, barInfo } = barItem - function onClickHandler() { - console.log(barItem._id) - } - return ( -
-

{barName}

-

{address}

-

{barInfo}

- -
- ) - -}; - -// BarsItemComponent.propTypes = { -// -// } - -export { BarItemComponent }; \ No newline at end of file diff --git a/src/ui/components/Bars/index.js b/src/ui/components/Bars/index.js deleted file mode 100644 index b3dbec6..0000000 --- a/src/ui/components/Bars/index.js +++ /dev/null @@ -1,3 +0,0 @@ -import BarContainer from "./BarContainer"; - -export default BarContainer; \ No newline at end of file