Skip to content

Commit

Permalink
fix(corel): update BundleIconEditorPicker types
Browse files Browse the repository at this point in the history
  • Loading branch information
pedrobonamin committed Jul 8, 2024
1 parent 5c698f5 commit e0156ec
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {DatePicker} from '../../../form/inputs/DateInputs/base/DatePicker'
import {getCalendarLabels} from '../../../form/inputs/DateInputs/utils'
import {type BundleDocument} from '../../../store/bundles/types'
import {isDraftOrPublished} from '../../util/dummyGetters'
import {BundleIconEditorPicker} from './BundleIconEditorPicker'
import {BundleIconEditorPicker, type BundleIconEditorPickerValue} from './BundleIconEditorPicker'

export function BundleForm(props: {
onChange: (params: Partial<BundleDocument>) => void
Expand All @@ -34,7 +34,7 @@ export function BundleForm(props: {
const {t: coreT} = useTranslation()
const calendarLabels: CalendarLabels = useMemo(() => getCalendarLabels(coreT), [coreT])

const iconValue: Partial<BundleDocument> = useMemo(
const iconValue: BundleIconEditorPickerValue = useMemo(
() => ({
icon: icon ?? 'cube',
hue: hue ?? 'gray',
Expand Down Expand Up @@ -98,7 +98,7 @@ export function BundleForm(props: {
)

const handleIconValueChange = useCallback(
(pickedIcon: Partial<BundleDocument>) => {
(pickedIcon: BundleIconEditorPickerValue) => {
onChange({...value, icon: pickedIcon.icon, hue: pickedIcon.hue})
},
[onChange, value],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,14 @@ const IconPickerFlex = styled(Flex)`
max-width: 269px;
`

export interface BundleIconEditorPickerValue {
hue: BundleDocument['hue']
icon: BundleDocument['icon']
}

export function BundleIconEditorPicker(props: {
onChange: (value: {hue: BundleDocument['hue']; icon: BundleDocument['icon']}) => void
value: {
hue: BundleDocument['hue']
icon: BundleDocument['icon']
}
onChange: (value: BundleIconEditorPickerValue) => void
value: BundleIconEditorPickerValue
}): JSX.Element {
const {onChange, value} = props

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ type Screen = 'overview' | 'review'

const useFetchBundleDocuments = (bundleName: string) => {
const client = useClient({apiVersion: API_VERSION})
const query = `*[defined(_version) && _id match "${bundleName}*"]`
const query = `*[defined(_version) && _id in path("${bundleName}.*")]`
return useListener<BundleDocument>({query, client})
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@ import {type SanityDocument} from '@sanity/types'
import {AvatarStack, Card, Flex, Heading, Stack, Text, useToast} from '@sanity/ui'
import {useCallback, useState} from 'react'

import {BundleIconEditorPicker} from '../../../bundles/components/dialog/BundleIconEditorPicker'
import {
BundleIconEditorPicker,
type BundleIconEditorPickerValue,
} from '../../../bundles/components/dialog/BundleIconEditorPicker'
import {RelativeTime} from '../../../components/RelativeTime'
import {UserAvatar} from '../../../components/userAvatar/UserAvatar'
import {type BundleDocument} from '../../../store/bundles/types'
Expand All @@ -18,10 +21,7 @@ export function ReleaseOverview(props: {documents: SanityDocument[]; release: Bu
* This state is created here but will be updated by the DocumentRow component when fetching the history
*/
const [collaborators, setCollaborators] = useState<string[]>([])
const [iconValue, setIconValue] = useState<{
hue: BundleDocument['hue']
icon: BundleDocument['icon']
}>({
const [iconValue, setIconValue] = useState<BundleIconEditorPickerValue>({
hue: release.hue ?? 'gray',
icon: release.icon ?? 'documents',
})
Expand Down

0 comments on commit e0156ec

Please sign in to comment.