PageFiles.jsx 2.22 KB
Newer Older
1
2
3
import React from "react";
import PropTypes from "prop-types";
import Paper from "@material-ui/core/Paper";
4
5
import { compose } from "recompose";
import { Typography } from "@material-ui/core";
6
import { makeStyles } from "@material-ui/styles";
Florent Chehab's avatar
Florent Chehab committed
7
import RequestParams from "../../utils/api/RequestParams";
8
import Pictures from "../user/Pictures";
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import withNetworkWrapper, { NetWrapParam } from "../../hoc/withNetworkWrapper";

const useStyles = makeStyles(theme => ({
  paper: theme.myPaper
}));

function getUserIdFromUrl(match) {
  return match.params.userId;
}

const buildPictureParams = match =>
  RequestParams.Builder.withQueryParam(
    "owner",
    getUserIdFromUrl(match)
  ).build();

const buildFilesParams = match =>
  RequestParams.Builder.withQueryParam(
    "owner",
    getUserIdFromUrl(match)
  ).build();
30
31

/**
32
 * WARNING BETA files & padding
33
34
 * Page that lists the files available
 */
35
36
37
// eslint-disable-next-line no-unused-vars
function PageFiles({ pictures, files }) {
  const classes = useStyles();
38

39
40
41
42
  return (
    <>
      <Paper className={classes.paper}>
        <Typography variant="h3">Photos</Typography>
Florent Chehab's avatar
Florent Chehab committed
43
        <Pictures pictures={pictures} onSomethingWasSaved={() => {}} />
44
45
46
47
48
49
      </Paper>
      {/* <Paper style={theme.myPaper}> */}
      {/*  <Typography variant={"h3"}>Fichiers</Typography> */}
      {/* </Paper> */}
    </>
  );
50
51
52
53
54
}

PageFiles.propTypes = {
  match: PropTypes.shape({
    params: PropTypes.shape({
55
      userId: PropTypes.string.isRequired
56
57
    })
  }).isRequired,
58
59
  pictures: PropTypes.array.isRequired,
  files: PropTypes.array.isRequired
60
61
62
};

export default compose(
63
  withNetworkWrapper([
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
    new NetWrapParam("pictures", "all", {
      propKey: "pictures",
      params: props => buildPictureParams(props.match),
      propTypes: {
        match: PropTypes.shape({
          params: PropTypes.shape({
            userId: PropTypes.string.isRequired
          })
        }).isRequired
      }
    }),
    new NetWrapParam("files", "all", {
      propKey: "files",
      params: props => buildFilesParams(props.match),
      propTypes: {
        match: PropTypes.shape({
          params: PropTypes.shape({
            userId: PropTypes.string.isRequired
          })
        }).isRequired
      }
    })
86
  ])
87
)(PageFiles);