diff --git a/src/features/resources/edit/components/ResourceComponent.js b/src/features/resources/edit/components/ResourceComponent.js
new file mode 100644
index 0000000..186d80a
--- /dev/null
+++ b/src/features/resources/edit/components/ResourceComponent.js
@@ -0,0 +1,74 @@
+import React from "react";
+import PropTypes from "prop-types";
+import { Grid, Paper, ButtonBase, TextField } from "@material-ui/core";
+import { makeStyles } from "@material-ui/core/styles";
+import style from "../styles";
+import ResourcePreviewComponent from "./ResourcePreviewComponent";
+import { onTextFieldChange } from "../../../../utils/adapters";
+
+const useStyles = makeStyles(style);
+
+const ResourceComponent = ({ resource, onPropertyChange }) => {
+ const classes = useStyles();
+ return (
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ );
+};
+
+ResourceComponent.propTypes = {
+ resource: PropTypes.object.isRequired,
+ onPropertyChange: PropTypes.func.isRequired
+};
+
+export default ResourceComponent;
diff --git a/src/features/resources/edit/components/ResourceContainer.js b/src/features/resources/edit/components/ResourceContainer.js
index 06764ac..dbbac7c 100644
--- a/src/features/resources/edit/components/ResourceContainer.js
+++ b/src/features/resources/edit/components/ResourceContainer.js
@@ -3,11 +3,17 @@ import PageTitle from "../../../../components/PageTitle";
import { useParams } from "react-router-dom";
import { useResourcesApi } from "../../api";
import { LoadingText } from "../../../../components";
+import ResourceComponent from "./ResourceComponent";
+import { makeStyles } from "@material-ui/core/styles";
+import style from "../styles";
+
+const useStyles = makeStyles(style);
const ResourceContainer = () => {
const [state, setState] = useState(null);
const [loading, setLoading] = useState(false);
+ const classes = useStyles();
const params = useParams();
const { getResource } = useResourcesApi();
@@ -23,12 +29,21 @@ const ResourceContainer = () => {
});
}, [getResource, isNew, params.id]);
+ const handlePropertyChange = (prop) => (value) => {
+ setState((prev) => ({ ...prev, [prop]: value }));
+ };
+
if (loading || state === null) return ;
return (
<>
- <>.................>
+
+
+
>
);
};
diff --git a/src/features/resources/edit/components/ResourcePreviewComponent.js b/src/features/resources/edit/components/ResourcePreviewComponent.js
index 79329a3..058961f 100644
--- a/src/features/resources/edit/components/ResourcePreviewComponent.js
+++ b/src/features/resources/edit/components/ResourcePreviewComponent.js
@@ -1,3 +1,61 @@
-const ResourcePreviewComponent = () => {};
+import React, { useMemo } from "react";
+import PropTypes from "prop-types";
+import UnknownResourceType from "../../../../images/UnknownResourceType.jpg";
+import style from "../styles";
+import { makeStyles } from "@material-ui/core/styles";
+import { useResourceSecurity } from "../../../../hooks";
+
+const useStyles = makeStyles(style);
+
+const RESOURCE_TYPES = {
+ UNKNOWN: "UNKNOWN",
+ IMAGE: "IMAGE"
+};
+
+const getResourceType = (mimeType) => {
+ if (mimeType.startsWith("image/")) return RESOURCE_TYPES.IMAGE;
+ return RESOURCE_TYPES.UNKNOWN;
+};
+
+const ResourcePreviewComponent = ({ resource }) => {
+ const classes = useStyles();
+ const { secureUrl } = useResourceSecurity();
+
+ const resourceType = useMemo(() => getResourceType(resource.mimeType), [
+ resource.mimeType
+ ]);
+
+ const resourceUrl = useMemo(
+ () => (resource.secured ? secureUrl(resource.urls[2]) : resource.urls[2]),
+ [resource.secured, resource.urls, secureUrl]
+ );
+
+ const isImage = useMemo(() => resourceType === RESOURCE_TYPES.IMAGE, [
+ resourceType
+ ]);
+ const isUnknown = useMemo(() => resourceType === RESOURCE_TYPES.UNKNOWN, [
+ resourceType
+ ]);
+
+ return (
+ <>
+ {isImage && (
+
+ )}
+
+ {isUnknown && (
+
+ )}
+ >
+ );
+};
+
+ResourcePreviewComponent.propTypes = {
+ resource: PropTypes.object.isRequired
+};
export default ResourcePreviewComponent;
diff --git a/src/features/resources/edit/styles.js b/src/features/resources/edit/styles.js
new file mode 100644
index 0000000..1bba25a
--- /dev/null
+++ b/src/features/resources/edit/styles.js
@@ -0,0 +1,19 @@
+const style = (theme) => {
+ return {
+ root: {
+ flexGrow: 1
+ },
+ paper: {
+ padding: theme.spacing(2),
+ margin: "auto"
+ },
+ resourceImage: {
+ margin: "auto",
+ display: "block",
+ maxWidth: "100%",
+ maxHeight: "100%"
+ }
+ };
+};
+
+export default style;
diff --git a/src/images/UnknownResourceType.jpg b/src/images/UnknownResourceType.jpg
new file mode 100644
index 0000000..1478d0a
Binary files /dev/null and b/src/images/UnknownResourceType.jpg differ
diff --git a/src/utils/adapters/index.js b/src/utils/adapters/index.js
new file mode 100644
index 0000000..68529f5
--- /dev/null
+++ b/src/utils/adapters/index.js
@@ -0,0 +1,2 @@
+export const onTextFieldChange = (onPropertyChange) => (event) =>
+ onPropertyChange(event.target.value);