import { Button, Card, CardContent, TextField } from "@material-ui/core"; import CardTitle from "@saleor/components/CardTitle"; import Hr from "@saleor/components/Hr"; import ImageUpload from "@saleor/components/ImageUpload"; import MediaTile from "@saleor/components/MediaTile"; import Skeleton from "@saleor/components/Skeleton"; import { commonMessages } from "@saleor/intl"; import { makeStyles } from "@saleor/macaw-ui"; import React from "react"; import { FormattedMessage, useIntl } from "react-intl"; import { CollectionDetails_collection_backgroundImage } from "../../types/CollectionDetails"; const useStyles = makeStyles( theme => ({ PhotosIcon: { height: "64px", margin: "0 auto", width: "64px" }, PhotosIconContainer: { margin: theme.spacing(5, 0), textAlign: "center" }, fileField: { display: "none" }, image: { height: "100%", objectFit: "contain", userSelect: "none", width: "100%" }, imageContainer: { background: "#ffffff", border: "1px solid #eaeaea", borderRadius: theme.spacing(), height: 148, justifySelf: "start", overflow: "hidden", padding: theme.spacing(2), position: "relative", width: 148 } }), { name: "CollectionImage" } ); export interface CollectionImageProps { data: { backgroundImageAlt: string; }; image: CollectionDetails_collection_backgroundImage; onChange: (event: React.ChangeEvent) => void; onImageDelete: () => void; onImageUpload: (file: File) => void; } export const CollectionImage: React.FC = props => { const { data, onImageUpload, image, onChange, onImageDelete } = props; const anchor = React.useRef(); const classes = useStyles(props); const intl = useIntl(); const handleImageUploadButtonClick = () => anchor.current.click(); return ( onImageUpload(event.target.files[0])} type="file" ref={anchor} accept="image/*" /> } /> {image === undefined ? (
) : image === null ? ( onImageUpload(files[0])} /> ) : ( )} {image && ( <>
)}
); }; CollectionImage.displayName = "CollectionImage"; export default CollectionImage;