import { Card, CardContent, Typography } from "@material-ui/core"; import CardTitle from "@saleor/components/CardTitle"; import RadioGroupField from "@saleor/components/RadioGroupField"; import { AttributeTypeEnum } from "@saleor/graphql"; import { makeStyles } from "@saleor/macaw-ui"; import React from "react"; import { defineMessages, FormattedMessage, useIntl } from "react-intl"; import { AttributePageFormData } from "../AttributePage"; export interface AttributeOrganizationProps { canChangeType: boolean; data: AttributePageFormData; disabled: boolean; onChange: (event: React.ChangeEvent) => void; } const messages = defineMessages({ contentAttribute: { defaultMessage: "Content Attribute", description: "attribute type" }, productAttribute: { defaultMessage: "Product Attribute", description: "attribute type" } }); const useStyles = makeStyles( theme => ({ card: { overflow: "visible" }, cardSubtitle: { fontSize: theme.typography.body1.fontSize, marginBottom: theme.spacing(0.5) }, label: { marginBottom: theme.spacing(0.5) } }), { name: "AttributeOrganization" } ); const AttributeOrganization: React.FC = props => { const { canChangeType, data, disabled, onChange } = props; const classes = useStyles(props); const intl = useIntl(); return ( {canChangeType ? ( } name={"type" as keyof FormData} value={data.type} onChange={onChange} /> ) : ( <> {data.type === AttributeTypeEnum.PRODUCT_TYPE ? intl.formatMessage(messages.productAttribute) : intl.formatMessage(messages.contentAttribute)} )} ); }; AttributeOrganization.displayName = "AttributeOrganization"; export default AttributeOrganization;