From a3c66866d39d76aee84c11360d8e09dbd979dd86 Mon Sep 17 00:00:00 2001 From: Patrick Fic Date: Fri, 7 Feb 2020 17:03:21 -0800 Subject: [PATCH] File clean up. Refactor header. --- bodyshop_translations.babel | 42 ++++++++++ client/public/manifest.json | 7 +- .../current-user-dropdown.component.jsx | 79 ------------------- .../components/footer/footer.component.jsx | 2 +- .../global-search/global-search.component.jsx | 79 ------------------- .../components/header/header.component.jsx | 75 +++++++++++++----- .../components/header/header.container.jsx | 50 +++++++++++- .../profile-my/profile-my.component.jsx | 11 ++- .../sign-out/sign-out.component.jsx | 8 -- .../with-inline-edit.component.jsx | 45 ----------- client/src/logo.svg | 1 - .../manage-root.page.container.jsx | 15 ++-- client/src/pages/manage/manage.page.jsx | 1 - client/src/redux/user/user.sagas.js | 2 + client/src/translations/en_us/common.json | 4 +- client/src/translations/es/common.json | 4 +- client/src/translations/fr/common.json | 4 +- 17 files changed, 181 insertions(+), 248 deletions(-) delete mode 100644 client/src/components/current-user-dropdown/current-user-dropdown.component.jsx delete mode 100644 client/src/components/global-search/global-search.component.jsx delete mode 100644 client/src/components/sign-out/sign-out.component.jsx delete mode 100644 client/src/components/with-inline-edit/with-inline-edit.component.jsx delete mode 100644 client/src/logo.svg diff --git a/bodyshop_translations.babel b/bodyshop_translations.babel index 7dbc275db..935ef11e6 100644 --- a/bodyshop_translations.babel +++ b/bodyshop_translations.babel @@ -5165,6 +5165,27 @@ + + manageroot + false + + + + + + en-US + false + + + es-MX + false + + + fr-CA + false + + + profile false @@ -5304,6 +5325,27 @@ + + photourl + false + + + + + + en-US + false + + + es-MX + false + + + fr-CA + false + + + diff --git a/client/public/manifest.json b/client/public/manifest.json index 8bcd1cbcb..ad4743790 100644 --- a/client/public/manifest.json +++ b/client/public/manifest.json @@ -1,6 +1,7 @@ { - "short_name": "Bodyshop", + "short_name": "Bodyshop.app", "name": "Bodyshop Management System", + "description": "The ultimate bodyshop management system", "icons": [ { "src": "favicon.ico", @@ -20,6 +21,6 @@ ], "start_url": ".", "display": "standalone", - "theme_color": "#002366", - "background_color": "#000000" + "theme_color": "#fff", + "background_color": "#fff" } diff --git a/client/src/components/current-user-dropdown/current-user-dropdown.component.jsx b/client/src/components/current-user-dropdown/current-user-dropdown.component.jsx deleted file mode 100644 index dbf6b6a45..000000000 --- a/client/src/components/current-user-dropdown/current-user-dropdown.component.jsx +++ /dev/null @@ -1,79 +0,0 @@ -import { Avatar, Col, Dropdown, Icon, Menu, Row } from "antd"; -import i18next from "i18next"; -import React from "react"; -import { useTranslation } from "react-i18next"; -import { connect } from "react-redux"; -import { Link } from "react-router-dom"; -import { createStructuredSelector } from "reselect"; -import UserImage from "../../assets/User.svg"; -import { setUserLanguage, signOutStart } from "../../redux/user/user.actions"; -import { selectCurrentUser } from "../../redux/user/user.selectors"; -import SignOut from "../sign-out/sign-out.component"; - -const mapStateToProps = createStructuredSelector({ - currentUser: selectCurrentUser -}); - -const mapDispatchToProps = dispatch => ({ - signOutStart: () => dispatch(signOutStart()), - setUserLanguage: language => dispatch(setUserLanguage(language)) -}); - -export default connect( - mapStateToProps, - mapDispatchToProps -)(function CurrentUserDropdown({ currentUser, signOutStart, setUserLanguage }) { - const { t } = useTranslation(); - - const handleMenuClick = e => { - if (e.item.props.actiontype === "lang-select") { - i18next.changeLanguage(e.key, (err, t) => { - if (err) - return console.log("Error encountered when changing languages.", err); - setUserLanguage(e.key); - console.log("clicking"); - }); - } - }; - const menu = ( - - - - - - {t("menus.currentuser.profile")} - - - - {t("menus.currentuser.languageselector")} - - } - > - - {t("general.languages.english")} - - - {t("general.languages.french")} - - - {t("general.languages.spanish")} - - - - ); - - return ( - - - - - - - {currentUser.displayName || t("general.labels.unknown")} - - - - ); -}); diff --git a/client/src/components/footer/footer.component.jsx b/client/src/components/footer/footer.component.jsx index a8be82b23..491546987 100644 --- a/client/src/components/footer/footer.component.jsx +++ b/client/src/components/footer/footer.component.jsx @@ -4,7 +4,7 @@ import React from "react"; export default function FooterComponent() { return ( - + Copyright Snapt Software 2019. All rights reserved. diff --git a/client/src/components/global-search/global-search.component.jsx b/client/src/components/global-search/global-search.component.jsx deleted file mode 100644 index b537b5f11..000000000 --- a/client/src/components/global-search/global-search.component.jsx +++ /dev/null @@ -1,79 +0,0 @@ -import React from "react"; -// import { Icon, Button, Input, AutoComplete } from "antd"; - -// const { Option } = AutoComplete; - -// function onSelect(value) { -// console.log("onSelect", value); -// } - -// function getRandomInt(max, min = 0) { -// return Math.floor(Math.random() * (max - min + 1)) + min; // eslint-disable-line no-mixed-operators -// } - -// function searchResult(query) { -// return new Array(getRandomInt(5)) -// .join(".") -// .split(".") -// .map((item, idx) => ({ -// query, -// category: `${query}${idx}`, -// count: getRandomInt(200, 100) -// })); -// } - -// function renderOption(item) { -// return ( -// -// ); -// } - -export default class GlobalSearch extends React.Component { - state = { - dataSource: [] - }; - - // handleSearch = value => { - // this.setState({ - // dataSource: value ? searchResult(value) : [] - // }); - // }; - - render() { - return ( -
- //
- // - // - // - // - // } - // /> - // - //
- ); - } -} diff --git a/client/src/components/header/header.component.jsx b/client/src/components/header/header.component.jsx index 640678a7b..0114f278e 100644 --- a/client/src/components/header/header.component.jsx +++ b/client/src/components/header/header.component.jsx @@ -1,27 +1,35 @@ -import { Col, Icon, Menu, Row } from "antd"; +import { Avatar, Col, Icon, Menu, Row } from "antd"; import React from "react"; import { useTranslation } from "react-i18next"; import { Link } from "react-router-dom"; -import CurrentUserDropdown from "../current-user-dropdown/current-user-dropdown.component"; -import GlobalSearch from "../global-search/global-search.component"; +import UserImage from "../../assets/User.svg"; +import { signOutStart } from "../../redux/user/user.actions"; import ManageSignInButton from "../manage-sign-in-button/manage-sign-in-button.component"; -export default ({ landingHeader, selectedNavItem }) => { +export default ({ + landingHeader, + selectedNavItem, + logo, + handleMenuClick, + currentUser +}) => { const { t } = useTranslation(); - + //TODO Add return ( - - + + {logo ? ( + + Shop Logo + + ) : null} + - - - - @@ -64,16 +72,47 @@ export default ({ landingHeader, selectedNavItem }) => { - {!landingHeader ? null : ( - - + + + {currentUser.displayName || t("general.labels.unknown")} +
+ } + > + + {t("user.actions.signout")} - )} + + {t("menus.currentuser.profile")} + + + + {t("menus.currentuser.languageselector")} + + } + > + + {t("general.languages.english")} + + + {t("general.languages.french")} + + + {t("general.languages.spanish")} + + + - - {!landingHeader ? : null} - + {!landingHeader ? null : } ); }; diff --git a/client/src/components/header/header.container.jsx b/client/src/components/header/header.container.jsx index d971b7c46..77a5feb4c 100644 --- a/client/src/components/header/header.container.jsx +++ b/client/src/components/header/header.container.jsx @@ -1,8 +1,52 @@ import React from "react"; import HeaderComponent from "./header.component"; +import { connect } from "react-redux"; +import { createStructuredSelector } from "reselect"; +import i18next from "i18next"; +import { setUserLanguage, signOutStart } from "../../redux/user/user.actions"; +import { + selectCurrentUser, + selectBodyshop +} from "../../redux/user/user.selectors"; + +const mapStateToProps = createStructuredSelector({ + currentUser: selectCurrentUser, + bodyshop: selectBodyshop +}); + +const mapDispatchToProps = dispatch => ({ + signOutStart: () => dispatch(signOutStart()), + setUserLanguage: language => dispatch(setUserLanguage(language)) +}); + +export default connect( + mapStateToProps, + mapDispatchToProps +)(function HeaderContainer({ + landingHeader, + currentUser, + bodyshop, + signOutStart, + setUserLanguage +}) { + const handleMenuClick = e => { + if (e.item.props.actiontype === "lang-select") { + i18next.changeLanguage(e.key, (err, t) => { + if (err) + return console.log("Error encountered when changing languages.", err); + setUserLanguage(e.key); + }); + } + }; -export default ({ landingHeader, signedIn }) => { return ( - + ); -}; +}); diff --git a/client/src/components/profile-my/profile-my.component.jsx b/client/src/components/profile-my/profile-my.component.jsx index 6eb734b4c..3f2db1eb1 100644 --- a/client/src/components/profile-my/profile-my.component.jsx +++ b/client/src/components/profile-my/profile-my.component.jsx @@ -37,7 +37,10 @@ export default connect( } if (!err) { console.log("values", values); - updateUserDetails({ displayName: values.displayname }); + updateUserDetails({ + displayName: values.displayname, + photoURL: values.photoURL + }); } }); }; @@ -59,6 +62,12 @@ export default connect( rules: [{ required: true }] })()} + + {getFieldDecorator("photoURL", { + initialValue: currentUser.photoURL + })()} + +