import {WarningOutlineIcon} from '@sanity/icons'
import {StringFieldProps, useFormValue} from 'sanity'
import {Box, Card, Flex, Stack, Text} from '@sanity/ui'
import {productUrl} from '../../utils/shopifyUrls'
type Store = {
id: number
status: string
isDeleted: boolean
}
export default function ProductHiddenInput(props: StringFieldProps) {
const store: Store = useFormValue(['store']) as Store
let message
if (!store) {
return <>>
} else {
const shopifyProductUrl = productUrl(store?.id)
const isActive = store?.status === 'active'
const isDeleted = store?.isDeleted
if (!isActive) {
message = (
<>
It does not have an active status in Shopify.
>
)
}
if (isDeleted) {
message = 'It has been deleted from Shopify.'
}
return (
This product is hidden
{message}
{!isDeleted && shopifyProductUrl && (
→{' '}
View this product on Shopify
)}
)
}
}