All files / src/apps/authentication/pages ViewUserProfilePage.tsx

60% Statements 3/5
100% Branches 0/0
0% Functions 0/2
75% Lines 3/4

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67                                                1x                                                         1x         1x                
import React from "react";
import { Grid, Paper, Typography } from "@mui/material";
import { connect } from "react-redux";
import {
  APIOrg,
  APIProfile,
  getUserDetailsAction,
  profileSelector
} from "../../authentication";
import { AppState } from "../../../redux";
import Header from "../../../components/Header";
import { orgsSelector } from "../redux/reducer";
import {
  UserForm,
  UserOrganisationDetails,
  UserTokenDetails
} from "../components";
 
interface Props {
  userProfile?: APIProfile;
  userOrganisations?: APIOrg[];
  userToken?: string;
}
 
export const ViewUserProfilePage: React.FC<Props> = ({
  userProfile,
  userOrganisations,
  userToken
}: Props) => {
  return (
    <Header title="Your Profile" justifyChildren="space-around">
      <Grid id="viewUserProfilePage" item xs={5} component="div">
        <Paper className="fieldsetParent">
          <fieldset>
            <Typography component="legend" variant="h5" gutterBottom>
              Details
            </Typography>
            <UserForm savedValues={userProfile} loading={true} />
          </fieldset>
        </Paper>
      </Grid>
      <Grid item xs={5} container spacing={2}>
        <Grid item xs={12} component="div">
          <UserTokenDetails token={userToken} />
        </Grid>
        <Grid item xs={12} component="div">
          <UserOrganisationDetails orgs={userOrganisations} />
        </Grid>
      </Grid>
    </Header>
  );
};
 
export const mapStateToProps = (state: AppState) => ({
  userProfile: profileSelector(state),
  userOrganisations: orgsSelector(state),
  userToken: state.auth.token
});
export const mapDispatchToProps = {
  retrieveUserDetails: getUserDetailsAction
};
 
export default connect(
  mapStateToProps,
  mapDispatchToProps
)(ViewUserProfilePage);