Skip to content

Commit

Permalink
chore(sanity): clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
RitaDias committed Jul 12, 2024
1 parent c5d42d0 commit 86d51f1
Showing 1 changed file with 5 additions and 12 deletions.
17 changes: 5 additions & 12 deletions packages/sanity/src/core/bundles/components/dialog/BundleForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -110,21 +110,14 @@ export function BundleForm(props: {
[icon, hue],
)

const titleHasErrors = useCallback(
(pickedTitle: string) => {
return Boolean(
isDraftOrPublished(pickedTitle) || // title cannot be "drafts" or "published"
data?.find((bundle) => bundle.name === speakingurl(pickedTitle)), // bundle already exists
)
},
[data],
)

const handleBundleTitleChange = useCallback(
(event: React.ChangeEvent<HTMLInputElement>) => {
const pickedTitle = event.target.value

if (titleHasErrors(pickedTitle)) {
if (
isDraftOrPublished(pickedTitle) ||
data?.find((bundle) => bundle.name === speakingurl(pickedTitle))
) {
if (isDraftOrPublished(pickedTitle)) {
setShowIsDraftPublishError(true)
} else {
Expand All @@ -146,7 +139,7 @@ export function BundleForm(props: {
setIsInitialRender(false)
onChange({...value, title: pickedTitle, name: speakingurl(pickedTitle)})
},
[data, onChange, onError, titleHasErrors, value],
[data, onChange, onError, value],
)

const handleBundleDescriptionChange = useCallback(
Expand Down

0 comments on commit 86d51f1

Please sign in to comment.