/******************************************************************************** * Copyright (c) 2019 TypeFox and others * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v. 2.0 which is available at * http://www.eclipse.org/legal/epl-2.0. * * SPDX-License-Identifier: EPL-2.0 ********************************************************************************/ import { FunctionComponent, ReactNode, useContext } from 'react'; import { Theme, Grid, Typography, Avatar } from '@mui/material'; import { styled } from '@mui/material/styles'; import { toLocalTime } from '../../utils'; import { UserData } from '../../extension-registry-types'; import { UserPublisherAgreement } from './user-publisher-agreement'; import { MainContext } from "../../context"; const ProfileGrid = styled(Grid)(({ theme }: {theme: Theme}) => ({ [theme.breakpoints.up('lg')]: { justifyContent: 'space-between' }, ['@media(max-width: 1040px)']: { flexDirection: 'row-reverse', justifyContent: 'flex-end', '& > div:first-of-type': { marginLeft: '2rem' } }, [theme.breakpoints.down('sm')]: { textAlign: 'center', flexDirection: 'column-reverse', '& > div:first-of-type': { marginLeft: '0', marginTop: '2rem' } }, marginBottom: theme.spacing(2) })); export const UserSettingsProfile: FunctionComponent = ({ user, isAdmin }) => { const { pageSettings } = useContext(MainContext); let publisherAgreementPanel: ReactNode = null; if (user.publisherAgreement) { if (isAdmin) { let statusText = 'has not signed'; if (user.publisherAgreement.status === 'signed') { statusText = 'has signed'; } else if (user.publisherAgreement.status === 'outdated') { statusText = 'has signed an outdated version of'; } const publisherAgreementName = pageSettings?.publisherAgreement?.name ?? ''; publisherAgreementPanel = {user.loginName} {statusText} the {publisherAgreementName} Publisher Agreement. ; } else { publisherAgreementPanel = ; } } return <> Profile Login name: {user.loginName} Full name: {user.fullName} {publisherAgreementPanel} ; }; export interface UserSettingsProfileProps { user: UserData; isAdmin?: boolean; }