PromucFlow_constructor/app/client/src/pages/UserProfile/index.tsx

80 lines
2.1 KiB
TypeScript
Raw Normal View History

2021-10-20 07:38:17 +00:00
import React, { useState } from "react";
import PageWrapper from "pages/common/PageWrapper";
import styled from "styled-components";
import { TabComponent, TabProp } from "components/ads/Tabs";
import Text, { TextType } from "components/ads/Text";
import { Icon } from "@blueprintjs/core";
2021-10-20 07:38:17 +00:00
// import { Link } from "react-router-dom";
import General from "./General";
import { Colors } from "constants/Colors";
import GitConfig from "./GitConfig";
2021-10-20 07:38:17 +00:00
import { useLocation } from "react-router";
import { GIT_PROFILE_ROUTE } from "constants/routes";
import { useSelector } from "react-redux";
import { selectFeatureFlags } from "selectors/usersSelectors";
const ProfileWrapper = styled.div`
width: ${(props) => props.theme.pageContentWidth}px;
margin: 0 auto;
`;
2021-10-20 07:38:17 +00:00
const LinkToApplications = styled.div`
margin-top: 30px;
margin-bottom: 35px;
display: inline-block;
width: auto;
&:hover {
text-decoration: none;
}
svg {
cursor: pointer;
}
`;
function UserProfile() {
2021-10-20 07:38:17 +00:00
const location = useLocation();
const featureFlags = useSelector(selectFeatureFlags);
2021-10-20 07:38:17 +00:00
let initialTabIndex = 0;
const tabs: TabProp[] = [
{
key: "general",
title: "General",
panelComponent: <General />,
icon: "general",
},
];
if (featureFlags.GIT) {
tabs.push({
key: "gitConfig",
title: "Git user config",
panelComponent: <GitConfig />,
icon: "git-branch",
});
2021-10-20 07:38:17 +00:00
if (location.pathname === GIT_PROFILE_ROUTE) {
initialTabIndex = 1;
}
}
2021-10-20 07:38:17 +00:00
const [selectedTabIndex, setSelectedTabIndex] = useState(initialTabIndex);
return (
<PageWrapper displayName={"Profile"}>
<ProfileWrapper>
2021-10-20 07:38:17 +00:00
<LinkToApplications className="t--back" onClick={() => history.back()}>
<Icon color={Colors.SILVER_CHALICE} icon="chevron-left" />
<Text type={TextType.H1}>Profile</Text>
</LinkToApplications>
2021-10-20 07:38:17 +00:00
<TabComponent
onSelect={setSelectedTabIndex}
selectedIndex={selectedTabIndex}
tabs={tabs}
/>
</ProfileWrapper>
</PageWrapper>
);
}
export default UserProfile;