Repository: medusajs/medusa
File: packages/admin/dashboard/src/routes/promotions/promotion-create/components/create-promotion-form/create-promotion-form.tsx (TypeScript)

Code before:
    control: form.control,
    name: "template_id",
  })

  const currentTemplate = useMemo(() => {
    const currentTemplate = templates.find(
      (template) => template.id === watchTemplateId
    )

    if (!currentTemplate) {
      return
    }

    reset({ ...defaultValues, template_id: watchTemplateId })

    for (const [key, value] of Object.entries(currentTemplate.defaults)) {
      if (typeof value === "object") {
        for (const [subKey, subValue] of Object.entries(value)) {
          setValue(`application_method.${subKey}`, subValue)
        }
      } else {
        setValue(key, value)
      }
    }

    // if switching from `across` to `across` allocation, reset call above will set the max quantity to 1 which is forbidden for this allocation type
    // but since there wasn't change in the `application_method.allocation` field, useEffect below responsible for resetting will not be triggered
    if (currentTemplate.defaults?.application_method?.allocation === "across") {
      setValue("application_method.max_quantity", null)
    }

    return currentTemplate
  }, [watchTemplateId, setValue, reset])

  const watchValueType = useWatch({
    control: form.control,
    name: "application_method.type",
  })

  const isFixedValueType = watchValueType === "fixed"
  const watchAllocation = useWatch({
    control: form.control,
    name: "application_method.allocation",
  })

  useEffect(() => {
    if (watchAllocation === "across") {
      setValue("application_method.max_quantity", null)
    }
  }, [watchAllocation, setValue])


Review comment (suggestion):
```suggestion
    // if switching to `across` allocation, reset call above will set the max quantity to 1 which is forbidden for this allocation type
```

Code after:
    control: form.control,
    name: "template_id",
  })

  const currentTemplate = useMemo(() => {
    const currentTemplate = templates.find(
      (template) => template.id === watchTemplateId
    )

    if (!currentTemplate) {
      return
    }

    reset({ ...defaultValues, template_id: watchTemplateId })

    for (const [key, value] of Object.entries(currentTemplate.defaults)) {
      if (typeof value === "object") {
        for (const [subKey, subValue] of Object.entries(value)) {
          setValue(`application_method.${subKey}`, subValue)
        }
      } else {
        setValue(key, value)
      }
    }

    // if switching to `across` allocation, reset call above will set the max quantity to 1 which is forbidden for this allocation type
    // but since there wasn't change in the `application_method.allocation` field, useEffect below responsible for resetting will not be triggered
    if (currentTemplate.defaults?.application_method?.allocation === "across") {
      setValue("application_method.max_quantity", null)
    }

    return currentTemplate
  }, [watchTemplateId, setValue, reset])

  const watchValueType = useWatch({
    control: form.control,
    name: "application_method.type",
  })

  const isFixedValueType = watchValueType === "fixed"
  const watchAllocation = useWatch({
    control: form.control,
    name: "application_method.allocation",
  })

  useEffect(() => {
    if (watchAllocation === "across") {
      setValue("application_method.max_quantity", null)
    }
  }, [watchAllocation, setValue])