AddressCommunity Asset

Open in new window
Open in new window
Open in new window
Open in new window
Open in new window
Open in new window
Open in new window
Open in new window
View RTL
<script setup lang="ts">
import { z } from 'zod'

const { activeDepartment } = useAuth()
const activeDepartmentCountry = computed(
  () => activeDepartment.value.attributes?.country,
)

const inlineForm = ref(false)

// Form logic:
const formElement = useTemplateRef('formRef')
const { handleErrors } = useFormValidation(formElement)
const addressValidationchema = useAddressValidation()
const formSchema = z.object({
  address: addressValidationchema,
})
const validationSchema = toTypedSchema(formSchema)
const initialValues = {
  address: {
    street_address: '',
    street_address_2: '',
    street_address_3: '',
    zip_code: '',
    city: '',
    state: '',
    country: activeDepartmentCountry.value || '',
  },
}
const { handleSubmit } = useForm({
  validationSchema,
  initialValues,
})
const onSubmit = handleSubmit(
  (data) => {
    console.log(data)
  },
  () => handleErrors(),
)
</script>

<template>
  <form
    ref="formRef"
    v-data-pc="'demo-form'"
    class="form-main"
    @submit="onSubmit"
  >
    <nord-card padding="l">
      <h2 slot="header">Address Form - Standard example</h2>
      <div slot="header-end">
        <nord-toggle label="Inline forms" @change="inlineForm = !inlineForm">
        </nord-toggle>
      </div>

      <FormAddressField
        hide-label
        label="Address"
        name="address"
        :inline-edit="inlineForm"
      />

      <nord-button class="n-margin-bs-l" variant="primary">
        Submit
      </nord-button>
    </nord-card>
  </form>
</template>

Integration

This community asset is currently only available to use in the New Frontend for Provet Cloud.


Troubleshooting

If you experience any issues while using this community asset, please ask for support in the #vet-frontend Slack channel.


Was this page helpful?

YesNo
Send feedback

We use this feedback to improve our documentation.

 
Edit page
Choose therapy brandChoose veterinary brandAbout Nord Design SystemGet support