diff --git a/src/Components/ContactButtons/FollowingButton.js b/src/Components/ContactButtons/FollowingButton.js index fd30943f896adf3349bf3b893afa5f4c88fb8ac6..cee2ddda0a7deed483f47eb47e85b5bfbea5525a 100644 --- a/src/Components/ContactButtons/FollowingButton.js +++ b/src/Components/ContactButtons/FollowingButton.js @@ -64,26 +64,24 @@ export default function FollowingButton(props) { followingHover ? ( [ - <StyledButton className={`${props.contrast}LinkColor`} - style={props.contrast === "" ? {border: "2px solid #00bcd4", borderRadius : "5px", color :"white", backgroundColor: "#00bcd4"} : {border: "1px solid white", borderRadius : "5px", color :"#00bcd4"}} - > + <div className={`${props.contrast}LinkColor`}> DEIXAR DE SEGUIR - </StyledButton> + </div> ] ) : ( [ - <StyledButton className={`${props.contrast}LinkColor`} - style={props.contrast === "" ? {border: "2px solid #00bcd4", borderRadius : "5px", color :"white", backgroundColor: "#00bcd4"} : {border: "1px solid white", borderRadius : "5px", color :"#00bcd4"}} - > + <div className={`${props.contrast}LinkColor`}> <GroupIcon - className={`${props.contrast}IconColor`} - style={{ - fontSize: "24px", - display: "inline-block", - verticalAlign: "middle", - }} />SEGUINDO - </StyledButton> + className={`${props.contrast}IconColor`} + style={{ + fontSize: "24px", + display: "inline-block", + verticalAlign: "middle", + }} + /> + SEGUINDO + </div> ] ) } @@ -147,6 +145,9 @@ export function NoIconFollowing(props) { export const StyledButton = styled(Button)` + border : 1px solid white !important; + background-color: ${props => props.contrast === "" ? "#00bcd4" : "black"} !important; + color: white !important; font-size : 14px important; font-weight : 500 !important; @@ -154,9 +155,6 @@ export const StyledButton = styled(Button)` font-size : 24px; } - &:hover { - color: rgb(107, 35, 142); - } ` const NoIconButton = styled(Button)` diff --git a/src/Components/TabPanels/StyledComponents.js b/src/Components/TabPanels/StyledComponents.js index b0e0f4b5688d77447e7feb1dcc6a309977c66561..9e3ee1c84d32f75cbe03a52723075feef30c7056 100644 --- a/src/Components/TabPanels/StyledComponents.js +++ b/src/Components/TabPanels/StyledComponents.js @@ -188,27 +188,27 @@ export const UserProfileContainer = styled.div` ` export const CoverContainer = styled.div` - height : 230px; - position : relative; - @media screen and (max-width: 600px) { - height : 128px - } + height : 230px; + position : relative; + @media screen and (max-width: 600px) { + height : 128px + } ` export const UserProfileInfoDiv = styled.div` - position : absolute; - bottom : 0; - left : 260px; - overflow : hidden; - margin-bottom : 20px; - p{ - font-size: 28px; - color: #fff; - padding: 5px 10px; - font-weight: 500; - background-color: ${props => props.contrast === "" ? "#77777796" : "black"}; - border-radius: 5px; - } + position : absolute; + bottom : 0; + left : 260px; + overflow : hidden; + margin-bottom : 20px; + p { + font-size: 28px; + color: #fff; + padding: 5px 10px; + font-weight: 500; + border-radius: 5px; + text-shadow: 0 1px 2px rgba(0,0,0,.45); + } ` export const CheckTeacherDiv = styled.div` diff --git a/src/Pages/PublicUserPage.js b/src/Pages/PublicUserPage.js index 8a314c145d9fe2a033ddbdaf26941ab9aae24a5b..0b7638739ba092df4f866b5d998cd5d58f51a987 100644 --- a/src/Pages/PublicUserPage.js +++ b/src/Pages/PublicUserPage.js @@ -64,11 +64,11 @@ function RenderFollowContainer(props) { <FollowContainer> <> {props.id !== state.currentUser.id && followed ? ( - <FollowingButton - contrast={state.contrast} - followedID={props.id} - toggleFollowed={toggleFollowed} - /> + <FollowingButton + contrast={state.contrast} + followedID={props.id} + toggleFollowed={toggleFollowed} + /> ) : ( <FollowButton contrast={state.contrast} followerID={props.id} toggleFollowed={toggleFollowed} /> )} @@ -98,16 +98,7 @@ const RenderProfileAvatar = (userAvatar) => { const RenderUserProfileInfo = (userName, contrast) => { return ( <UserProfileInfoDiv contrast={contrast}> - <p - style={{ - fontSize: "28px", - color: "#fff", - marginBottom: "2px", - fontWeight: "500", - borderRadius: "5px", - textShadow: "0 1px 2px rgba(0,0,0,.45)", - }} - > + <p> {userName} </p> </UserProfileInfoDiv> @@ -241,159 +232,159 @@ export default function PublicUserPage(props) { /> </div> ); - else - return ( - <React.Fragment> - <link - href="https://fonts.googleapis.com/css?family=Roboto:100,400,500&display=swap" - rel="stylesheet" - /> - <BackgroundDiv contrast={state.contrast}> - <CustomizedBreadcrumbs contrast={state.contrast} values={["Usuário Público", tabs[tabValue]]} /> - <Grid container spacing={2}> - <Grid item xs={12}> - <div style={{ padding: "10px 0 8px 0" }}> - <UserProfileContainer> - <HeaderContainer contrast={state.contrast}> - <> - {!loading && ( - <RenderFollowContainer - followed={userData.followed} - id={id} - followCount={userData.follows_count} - /> - )} - {RenderProfileAvatar( - userData.avatar ? userData.avatar : undefined - )} - <CoverContainer contrast={state.contrast}> - {userData.cover && ( - <img - src={apiDomain + userData.cover} - alt="" - style={{ - width: "100%", - height: "100%", - objectFit: "cover", - }} + else + return ( + <React.Fragment> + <link + href="https://fonts.googleapis.com/css?family=Roboto:100,400,500&display=swap" + rel="stylesheet" + /> + <BackgroundDiv contrast={state.contrast}> + <CustomizedBreadcrumbs contrast={state.contrast} values={["Usuário Público", tabs[tabValue]]} /> + <Grid container spacing={2}> + <Grid item xs={12}> + <div style={{ padding: "10px 0 8px 0" }}> + <UserProfileContainer> + <HeaderContainer contrast={state.contrast}> + <> + {!loading && ( + <RenderFollowContainer + followed={userData.followed} + id={id} + followCount={userData.follows_count} /> )} - </CoverContainer> - {WIDTH <= 501 - ? null - : RenderUserProfileInfo(userData.name, state.contrast)} - </> - </HeaderContainer> - {WIDTH <= 501 ? ( - <Grid - style={state.contrast === "" ? { marginTop: "4em" } : { paddingTop: "4em", backgroundColor: "black", borderLeft: "1px solid white", borderRight: "1px solid white", }} - container - justify="center" - alignItems="center" - direction="column" - > - <Grid item> - <Typography - variant="h4" - gutterBottom - style={state.contrast === "" ? { textAlign: "center" } : { color: "white", textAlign: "center" }} - > - {userData.name} - </Typography> - </Grid> + {RenderProfileAvatar( + userData.avatar ? userData.avatar : undefined + )} + <CoverContainer contrast={state.contrast}> + {userData.cover && ( + <img + src={apiDomain + userData.cover} + alt="imagem de capa do usuário" + style={{ + width: "100%", + height: "100%", + objectFit: "cover", + }} + /> + )} + </CoverContainer> + {WIDTH <= 501 + ? null + : RenderUserProfileInfo(userData.name, state.contrast)} + </> + </HeaderContainer> + {WIDTH <= 501 ? ( <Grid - style={{ - marginTop: "0.5em", - marginBottom: "0.5em", - borderTop: "1px solid white", - borderBottom: "1px solid white", - }} + style={state.contrast === "" ? { marginTop: "4em" } : { paddingTop: "4em", backgroundColor: "black", borderLeft: "1px solid white", borderRight: "1px solid white", }} container - spacing={4} justify="center" alignItems="center" - direction="row" + direction="column" > <Grid item> - <Typography style={state.contrast === "" ? {} : { color: "white" }} variant="h6" onClick={(e) => { handleChangeTab(e, 4) }}> - {loading ? ( - <CircularProgress size={20} /> - ) : ( - `${userData.follows_count} seguidores` - )} + <Typography + variant="h4" + gutterBottom + style={state.contrast === "" ? { textAlign: "center" } : { color: "white", textAlign: "center" }} + > + {userData.name} </Typography> </Grid> - <Grid item> - <Typography style={state.contrast === "" ? {} : { color: "white" }} variant="h6" onClick={(e) => { handleChangeTab(e, 4) }}> - {loading ? ( - <CircularProgress size={20} /> - ) : ( - `${following} seguindo` - )} - </Typography> + <Grid + style={{ + marginTop: "0.5em", + marginBottom: "0.5em", + borderTop: "1px solid white", + borderBottom: "1px solid white", + }} + container + spacing={4} + justify="center" + alignItems="center" + direction="row" + > + <Grid item> + <Typography style={state.contrast === "" ? {} : { color: "white" }} variant="h6" onClick={(e) => { handleChangeTab(e, 4) }}> + {loading ? ( + <CircularProgress size={20} /> + ) : ( + `${userData.follows_count} seguidores` + )} + </Typography> + </Grid> + <Grid item> + <Typography style={state.contrast === "" ? {} : { color: "white" }} variant="h6" onClick={(e) => { handleChangeTab(e, 4) }}> + {loading ? ( + <CircularProgress size={20} /> + ) : ( + `${following} seguindo` + )} + </Typography> + </Grid> </Grid> </Grid> - </Grid> - ) : ( - RenderCheckTeacher(userData.submitter_request) - )} - <RodapeDiv contrast={state.contrast}> - <NavBarContentContainer contrast={state.contrast}> - <StyledTabs - contrast={state.contrast} - value={tabValue} - onChange={handleChangeTab} - indicatorColor="primary" - textColor="primary" - variant="scrollable" - scrollButtons="on" - TabIndicatorProps={{ style: state.contrast === "" ? { background: "#00bcd4" } : { background: "yellow" } }} - > - {tabs.map((tab) => ( - <Tab - label={tab} - key={tab} - disabled={ - (tab === "Recursos" && - learningObjArr.length === 0) || - (tab === "Coleções" && - collectionsArr.length === 0) || - (tab === "Rede" && state.currentUser.id === "") - } - /> - ))} - </StyledTabs> - </NavBarContentContainer> - <ReportButton - className="report-button" - complainableId={userData.id} - complainableType={"User"} - /> - </RodapeDiv> - </UserProfileContainer> - </div> - </Grid> + ) : ( + RenderCheckTeacher(userData.submitter_request) + )} + <RodapeDiv contrast={state.contrast}> + <NavBarContentContainer contrast={state.contrast}> + <StyledTabs + contrast={state.contrast} + value={tabValue} + onChange={handleChangeTab} + indicatorColor="primary" + textColor="primary" + variant="scrollable" + scrollButtons="on" + TabIndicatorProps={{ style: state.contrast === "" ? { background: "#00bcd4" } : { background: "yellow" } }} + > + {tabs.map((tab) => ( + <Tab + label={tab} + key={tab} + disabled={ + (tab === "Recursos" && + learningObjArr.length === 0) || + (tab === "Coleções" && + collectionsArr.length === 0) || + (tab === "Rede" && state.currentUser.id === "") + } + /> + ))} + </StyledTabs> + </NavBarContentContainer> + <ReportButton + className="report-button" + complainableId={userData.id} + complainableType={"User"} + /> + </RodapeDiv> + </UserProfileContainer> + </div> + </Grid> - {!loading && ( - <Grid item xs={12}> - {tabValue === 0 && ( - <TabInicio - contrast={state.contrast} - id={id} - user={userData} - learningObjs={learningObjArr} - collections={collectionsArr} - /> + {!loading && ( + <Grid item xs={12}> + {tabValue === 0 && ( + <TabInicio + contrast={state.contrast} + id={id} + user={userData} + learningObjs={learningObjArr} + collections={collectionsArr} + /> + )} + {tabValue === 1 && <TabRecursos contrast={state.contrast} id={id} username={userData.name} />} + {tabValue === 2 && <TabColecoes contrast={state.contrast} id={id} username={userData.name} />} + {tabValue === 3 && <TabRede contrast={state.contrast} id={id} username={userData.name} />} + </Grid> )} - {tabValue === 1 && <TabRecursos contrast={state.contrast} id={id} username={userData.name} />} - {tabValue === 2 && <TabColecoes contrast={state.contrast} id={id} username={userData.name} />} - {tabValue === 3 && <TabRede contrast={state.contrast} id={id} username={userData.name} />} </Grid> - )} - </Grid> - </BackgroundDiv> - </React.Fragment> - ); + </BackgroundDiv> + </React.Fragment> + ); } const ProfileAvatarDiv = styled.div` diff --git a/src/Pages/UserPage.js b/src/Pages/UserPage.js index 9de1400f65abd87b3e85a25d4531892eed25cc8c..9d0600c743d1158903f58f2c83ed20e3675fbd02 100644 --- a/src/Pages/UserPage.js +++ b/src/Pages/UserPage.js @@ -17,7 +17,6 @@ You should have received a copy of the GNU Affero General Public License along with Plataforma Integrada MEC. If not, see <http://www.gnu.org/licenses/>.*/ import React, { useState, useContext, useEffect } from "react"; -import styled from "styled-components"; import CustomizedBreadcrumbs from "../Components/TabPanels/Breadcrumbs.js"; import { Store } from "../Store.js"; import Tab from "@material-ui/core/Tab"; @@ -38,7 +37,6 @@ import { NavBarContentContainer, BackgroundDiv, } from "../Components/TabPanels/StyledComponents.js"; -import CircularProgress from "@material-ui/core/CircularProgress"; import Cover from "../Components/UserPageComponents/Cover.js"; import ProfileAvatar from "../Components/UserPageComponents/Avatar.js"; import UserInfo from "../Components/UserPageComponents/UserInfo.js"; @@ -46,6 +44,7 @@ import EditProfileButton from "../Components/UserPageComponents/EditProfileButto import SubmitterStatus from "../Components/UserPageComponents/SubmitterStatus.js"; import { getRequest } from "../Components/HelperFunctions/getAxiosConfig.js"; import Typography from "@material-ui/core/Typography"; +import LoadingSpinner from '../Components/LoadingSpinner'; export default function UserPage(props) { const { state, dispatch } = useContext(Store); @@ -53,7 +52,7 @@ export default function UserPage(props) { const [follows, setFollows] = useState(0); const [following, setFollowing] = useState(0); - const [loading, setLoading] = useState(false); + const [loading, setLoading] = useState(true); const [tabValue, setTabValue] = useState(Number(props.location.state) || 0); const [tabs, setTabs] = useState([ "Atividades", @@ -67,7 +66,6 @@ export default function UserPage(props) { }; function handleSuccessfulGet(data) { - console.log(data); dispatch({ type: "GET_USER", user: data, @@ -89,14 +87,13 @@ export default function UserPage(props) { function handleSuccesGetFollowing(data) { setFollowing(data.length); - setLoading(false); } useEffect(() => { + setLoading(true); if (id !== "") { const url = `/users/${id}`; const url2 = `/users/${id}/following/User`; - setLoading(true); getRequest(url, handleSuccessfulGet, (error) => { console.log(error); }); @@ -104,6 +101,7 @@ export default function UserPage(props) { console.log(error); }); } + setLoading(false); }, []); useEffect(() => { @@ -119,134 +117,128 @@ export default function UserPage(props) { return ( <div> - <link - href="https://fonts.googleapis.com/css?family=Roboto:100,400,500&display=swap" - rel="stylesheet" - /> - { - state.userIsLoggedIn ? ( - [ - <React.Fragment> - <ModalAlterarAvatar - contrast={state.contrast} - open={modalOpen} - handleClose={() => { - toggleModal(false); - }} - userAvatar={state.currentUser.avatar} - /> - - <BackgroundDiv contrast={state.contrast}> - <CustomizedBreadcrumbs contrast={state.contrast} values={["Minha área", tabs[tabValue]]} /> - <Grid container spacing={2}> - <Grid item xs={12}> - <div style={{ padding: "10px 0 8px 0" }}> - <UserProfileContainer> - <HeaderContainer contrast={state.contrast}> - <Cover id={id} /> - <ProfileAvatar id={id} /> - {WIDTH <= 600 ? null : <UserInfo />} - <EditProfileButton contrast={state.contrast} /> - </HeaderContainer> - {WIDTH <= 600 ? ( - <Grid - style={state.contrast === "" ? { marginTop: "4em" } : { paddingTop: "4em", backgroundColor: "black", borderLeft: "1px solid white", borderRight: "1px solid white", }} - container - justify="center" - alignItems="center" - direction="column" - > - <Grid item> - <Typography - variant="h4" - gutterBottom - style={state.contrast === "" ? { textAlign: "center" } : { color: "white", textAlign: "center" }} - > - {state.currentUser.name} - </Typography> - </Grid> - <Grid - style={{ - marginTop: "0.5em", - marginBottom: "0.5em", - borderTop: "1px solid white", - borderBottom: "1px solid white", - }} - container - spacing={4} - justify="center" - alignItems="center" - direction="row" - > - <Grid item> - <Typography style={state.contrast === "" ? {} : { color: "white" }} variant="h6" onClick={(e) => { handleChangeTab(e, 4) }}> - {loading ? ( - <CircularProgress size={20} /> - ) : ( - `${follows} seguidores` - )} - </Typography> - </Grid> - <Grid item> - <Typography style={state.contrast === "" ? {} : { color: "white" }} variant="h6" onClick={(e) => { handleChangeTab(e, 4) }}> - {loading ? ( - <CircularProgress size={20} /> - ) : ( - `${following} seguindo` - )} - </Typography> + <link + href="https://fonts.googleapis.com/css?family=Roboto:100,400,500&display=swap" + rel="stylesheet" + /> + { + loading ? + ( + <LoadingSpinner text="Carregando..." /> + ) + : + ( + state.userIsLoggedIn ? + ( + <React.Fragment> + <ModalAlterarAvatar + contrast={state.contrast} + open={modalOpen} + handleClose={() => { + toggleModal(false); + }} + userAvatar={state.currentUser.avatar} + /> + <BackgroundDiv contrast={state.contrast}> + <CustomizedBreadcrumbs contrast={state.contrast} values={["Minha área", tabs[tabValue]]} /> + <Grid container spacing={2}> + <Grid item xs={12}> + <div style={{ padding: "10px 0 8px 0" }}> + <UserProfileContainer> + <HeaderContainer contrast={state.contrast}> + <Cover id={id} /> + <ProfileAvatar id={id} /> + {WIDTH <= 600 ? null : <UserInfo />} + <EditProfileButton contrast={state.contrast} /> + </HeaderContainer> + {WIDTH <= 600 ? ( + <Grid + style={state.contrast === "" ? { marginTop: "4em" } : { paddingTop: "4em", backgroundColor: "black", borderLeft: "1px solid white", borderRight: "1px solid white", }} + container + justify="center" + alignItems="center" + direction="column" + > + <Grid item> + <Typography + variant="h4" + gutterBottom + style={state.contrast === "" ? { textAlign: "center" } : { color: "white", textAlign: "center" }} + > + {state.currentUser.name} + </Typography> + </Grid> + <Grid + style={{ + marginTop: "0.5em", + marginBottom: "0.5em", + borderTop: "1px solid white", + borderBottom: "1px solid white", + }} + container + spacing={4} + justify="center" + alignItems="center" + direction="row" + > + <Grid item> + <Typography style={state.contrast === "" ? {} : { color: "white" }} variant="h6" onClick={(e) => { handleChangeTab(e, 4) }}> + {follows} seguidores + </Typography> + </Grid> + <Grid item> + <Typography style={state.contrast === "" ? {} : { color: "white" }} variant="h6" onClick={(e) => { handleChangeTab(e, 4) }}> + {following} seguindo + </Typography> + </Grid> + </Grid> + </Grid> + ) : ( + <CheckTeacherDiv contrast={state.contrast}> + <SubmitterStatus /> + </CheckTeacherDiv> + )} + <RodapeDiv contrast={state.contrast}> + <NavBarContentContainer contrast={state.contrast}> + <StyledTabs + contrast={state.contrast} + value={tabValue} + onChange={handleChangeTab} + indicatorColor="primary" + textColor="primary" + variant="scrollable" + scrollButtons="on" + TabIndicatorProps={{ style: state.contrast === "" ? { background: "#00bcd4" } : { background: "yellow" } }} + > + {tabs.map((tab) => ( + <Tab contrast={state.contrast} label={tab} key={tab} /> + ))} + </StyledTabs> + </NavBarContentContainer> + </RodapeDiv> + </UserProfileContainer> + </div> + </Grid> + <Grid item xs={12}> + {tabValue === 0 && <TabPanelAtividades id={id} contrast={state.contrast} />} + {tabValue === 1 && <TabPanelMeusRecursos id={id} contrast={state.contrast} />} + {tabValue === 2 && <TabPanelFavoritos id={id} contrast={state.contrast} />} + {tabValue === 3 && <TabPanelColecoes id={id} contrast={state.contrast} />} + {tabValue === 4 && <TabPanelRede id={id} contrast={state.contrast} />} + {tabValue === 5 && <TabPanelCuradoria id={id} contrast={state.contrast} />} + </Grid> </Grid> - </Grid> - </Grid> - ) : ( - <CheckTeacherDiv contrast={state.contrast}> - <SubmitterStatus /> - </CheckTeacherDiv> - )} - <RodapeDiv contrast={state.contrast}> - <NavBarContentContainer contrast={state.contrast}> - <StyledTabs - contrast={state.contrast} - value={tabValue} - onChange={handleChangeTab} - indicatorColor="primary" - textColor="primary" - variant="scrollable" - scrollButtons="on" - TabIndicatorProps={{ style: state.contrast === "" ? { background: "#00bcd4" } : { background: "yellow" } }} - > - {tabs.map((tab) => ( - <StyledTab contrast={state.contrast} label={tab} key={tab} /> - ))} - </StyledTabs> - </NavBarContentContainer> - </RodapeDiv> - </UserProfileContainer> - </div> - </Grid> - <Grid item xs={12}> - {tabValue === 0 && <TabPanelAtividades id={id} contrast={state.contrast} />} - {tabValue === 1 && <TabPanelMeusRecursos id={id} contrast={state.contrast} />} - {tabValue === 2 && <TabPanelFavoritos id={id} contrast={state.contrast} />} - {tabValue === 3 && <TabPanelColecoes id={id} contrast={state.contrast} />} - {tabValue === 4 && <TabPanelRede id={id} contrast={state.contrast} />} - {tabValue === 5 && <TabPanelCuradoria id={id} contrast={state.contrast} />} - </Grid> - </Grid> - </BackgroundDiv> - </React.Fragment> - ] - ) - : - ( - <> - {redirect()} - </> - ) - } + </BackgroundDiv> + </React.Fragment> + ) + : + ( + <> + {redirect()} + </> + ) + ) + } </div> ) } - -const StyledTab = styled(Tab)` -`