Skip to content

Commit

Permalink
Feat: add next prefetching
Browse files Browse the repository at this point in the history
  • Loading branch information
justiandevs committed Oct 23, 2024
1 parent a354cc7 commit b1c5656
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ export const IncidentQuestionsLocationForm = () => {
formState: { errors },
} = useForm()

useEffect(() => {
router.prefetch('/incident/contact')
}, [router])

// TODO: remove hardcoded marker
const marker = [0, 0]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ export const IncidentDescriptionForm = () => {
const { addOneStep, setLastCompletedStep } = useStepperStore()
const router = useRouter()

useEffect(() => {
router.prefetch('/incident/add')
}, [router])

const incidentDescriptionFormSchema = z.object({
description: z.string().min(1, t('errors.textarea_required')),
files: z.any(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,18 @@ import validator from 'validator'
import { Input } from '@/components/ui/Input'
import { Checkbox } from '@/components/ui/Checkbox'
import { useFormStore } from '@/store/form_store'
import { useEffect } from 'react'

const IncidentContactForm = () => {
const t = useTranslations('describe-contact.form')
const { updateForm, formState } = useFormStore()
const { addOneStep, setLastCompletedStep } = useStepperStore()
const router = useRouter()

useEffect(() => {
router.prefetch('/incident/summary')
}, [router])

const incidentContactFormSchema = z.object({
phone: z
.string()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { useTranslations } from 'next-intl'
import { Divider } from '@/components/ui/Divider'
import { LinkWrapper } from '@/components/ui/LinkWrapper'
import { useStepperStore } from '@/store/stepper_store'
import React from 'react'
import React, { useEffect } from 'react'
import { LocationMap } from '@/components/ui/LocationMap'
import { signalsClient } from '@/services/client/api-client'
import { useRouter } from '@/routing/navigation'
Expand All @@ -18,6 +18,10 @@ const IncidentSummaryForm = () => {
const { goToStep } = useStepperStore()
const router = useRouter()

useEffect(() => {
router.prefetch('/incident/thankyou')
}, [router])

/**
* We decided to use `@ts-ignore` here because our client is generated by typescript-openapi-gen.
* The `v1PublicSignalsCreate` method expects a large number of fields according to the TypeScript
Expand Down

0 comments on commit b1c5656

Please sign in to comment.