mirror of
https://github.com/vercel/commerce.git
synced 2025-07-23 04:36:49 +00:00
Removed redundant strings
This commit is contained in:
@@ -1,38 +0,0 @@
|
||||
import styled from 'styled-components'
|
||||
import {PreviewLayoutKey, SchemaType, useSchema} from 'sanity'
|
||||
import {Box} from '@sanity/ui'
|
||||
import {HotspotTooltipProps} from 'sanity-plugin-hotspot-array'
|
||||
import {useMemo} from 'react'
|
||||
|
||||
interface HotspotFields {
|
||||
productWithVariant?: {
|
||||
product: {
|
||||
_ref: string
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const StyledBox = styled(Box)`
|
||||
width: 200px;
|
||||
`
|
||||
|
||||
export default function ProductPreview(props: HotspotTooltipProps<HotspotFields>) {
|
||||
const {value, renderPreview} = props
|
||||
const productSchemaType = useSchema().get('product')
|
||||
const hasProduct = value?.productWithVariant?.product?._ref && productSchemaType
|
||||
|
||||
const previewProps = useMemo(
|
||||
() => ({
|
||||
value: value?.productWithVariant?.product,
|
||||
schemaType: productSchemaType as SchemaType,
|
||||
layout: 'default' as PreviewLayoutKey,
|
||||
}),
|
||||
[productSchemaType, value?.productWithVariant?.product]
|
||||
)
|
||||
|
||||
return (
|
||||
<StyledBox padding={2}>
|
||||
{hasProduct && previewProps ? renderPreview(previewProps) : `No product selected`}
|
||||
</StyledBox>
|
||||
)
|
||||
}
|
@@ -1,20 +0,0 @@
|
||||
import {StringInputProps, useFormValue, SanityDocument, StringSchemaType} from 'sanity'
|
||||
import get from 'lodash.get'
|
||||
|
||||
type Props = StringInputProps<StringSchemaType & {options?: {field?: string}}>
|
||||
|
||||
const PlaceholderStringInput = (props: Props) => {
|
||||
const {schemaType} = props
|
||||
|
||||
const path = schemaType?.options?.field
|
||||
const doc = useFormValue([]) as SanityDocument
|
||||
|
||||
const proxyValue = path ? (get(doc, path) as string) : ''
|
||||
|
||||
return props.renderDefault({
|
||||
...props,
|
||||
elementProps: {placeholder: proxyValue, ...props.elementProps},
|
||||
})
|
||||
}
|
||||
|
||||
export default PlaceholderStringInput
|
@@ -1,32 +0,0 @@
|
||||
import {LockIcon} from '@sanity/icons'
|
||||
import {Box, Text, TextInput, Tooltip} from '@sanity/ui'
|
||||
import {StringInputProps, useFormValue, SanityDocument, StringSchemaType} from 'sanity'
|
||||
import get from 'lodash.get'
|
||||
|
||||
type Props = StringInputProps<StringSchemaType & {options?: {field?: string}}>
|
||||
|
||||
const ProxyString = (props: Props) => {
|
||||
const {schemaType} = props
|
||||
|
||||
const path = schemaType?.options?.field
|
||||
const doc = useFormValue([]) as SanityDocument
|
||||
|
||||
const proxyValue = path ? (get(doc, path) as string) : ''
|
||||
|
||||
return (
|
||||
<Tooltip
|
||||
content={
|
||||
<Box padding={2}>
|
||||
<Text muted size={1}>
|
||||
This value is set in Shopify (<code>{path}</code>)
|
||||
</Text>
|
||||
</Box>
|
||||
}
|
||||
portal
|
||||
>
|
||||
<TextInput iconRight={LockIcon} readOnly={true} value={proxyValue} />
|
||||
</Tooltip>
|
||||
)
|
||||
}
|
||||
|
||||
export default ProxyString
|
Reference in New Issue
Block a user