Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(landing): contact form #1636

Open
wants to merge 13 commits into
base: master
Choose a base branch
from
Open

feat(landing): contact form #1636

wants to merge 13 commits into from

Conversation

purusott
Copy link
Collaborator

@purusott purusott commented Sep 5, 2024

image

tavla/app/components/ContactForm.tsx Show resolved Hide resolved
tavla/app/components/ContactForm.tsx Outdated Show resolved Hide resolved
tavla/app/components/ContactForm.tsx Outdated Show resolved Hide resolved
tavla/app/components/ContactForm.tsx Show resolved Hide resolved
tavla/app/components/Expandable.tsx Outdated Show resolved Hide resolved
tavla/app/components/actions.ts Outdated Show resolved Hide resolved
tavla/app/components/actions.ts Show resolved Hide resolved
tavla/app/layout.tsx Show resolved Hide resolved
tavla/helm/tavla/values.yaml Outdated Show resolved Hide resolved
tavla/app/components/ContactForm.tsx Outdated Show resolved Hide resolved
tavla/app/components/actions.ts Outdated Show resolved Hide resolved
tavla/app/components/actions.ts Outdated Show resolved Hide resolved
tavla/app/components/ContactForm.tsx Show resolved Hide resolved
tavla/app/components/Expandable.tsx Show resolved Hide resolved
tavla/app/components/ContactForm.tsx Outdated Show resolved Hide resolved
tavla/app/components/ContactForm.tsx Outdated Show resolved Hide resolved
tavla/app/components/ContactForm.tsx Show resolved Hide resolved
} else {
formRef.current?.reset()
setIsOpen(false)
addToast('Takk for din tilbakemelding!')
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Burde denne heller bli kalt når submit trykkes på?

    const submit = async (data: FormData) => {
        action(data)
        setIsOpen(false)
        addToast('Tavle slettet!')
    }

import { Expandable } from './Expandable'

export function ContactForm() {
const formRef = useRef<HTMLFormElement>(null)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Jeg antar vi setter en ref fordi vi vil klare å nullstille formen, men i følge react kan vi heller gjøre det via en key: https://react.dev/learn/preserving-and-resetting-state#resetting-a-form-with-a-key

Copy link
Collaborator Author

@purusott purusott Sep 20, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fjernet ref, prøvde med key men fant ikke noen lur måte å oppdatere verdien på fra parent. Skal funke nå med usestate pga formerror, men lmk om det er en bedre måte 👍

@SelmaBergstrand
Copy link
Collaborator

Er den litt bred? På min skjerm overskygger den litt tavlekarusellen. Blir mer en designting da.
Screenshot 2024-09-20 at 12 12 24

Copy link
Collaborator

@SelmaBergstrand SelmaBergstrand left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hadde bare en liten kommentar på bredde men hvis det er sjekka med Hannah og hun sier det er good så er det null stress.

bra jobba 👏👏👏

}
case 'form/reset': {
return
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Synes det virker litt rart å legge til en error-handling for å resette en form. Vi burde finne en annen løsning. Jeg tittet litt rundt, kanskje vi kan legge til et ekstra felt som heter "success"? Litt som de gjør her: https://react.dev/reference/react/useActionState#display-information-after-submitting-a-form

Vi kan sette oss ned å gjøre denne sammen tenker jeg:)

tavla/app/components/actions.ts Outdated Show resolved Hide resolved
tavla/app/components/ContactForm.tsx Show resolved Hide resolved
if (isEmptyOrSpaces(message))
return setFormError(
getFormFeedbackForError('contact/message-missing'),
)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Kan man flytte all denne valideringen til server-siden?

    const validEmail = new RegExp(/^[\w.-]+@([\w-]+\.)+[\w-]{2,4}$/g)

    if (!validEmail.test(email))
        return getFormFeedbackForError('auth/missing-email')

    if (isEmptyOrSpaces(message)) 
        return getFormFeedbackForError('contact/message-missing')
    

Da tror jeg kanskje vi kan eliminere setFormError helt

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Det skjer i server også, så kan i prinsippet fjerne det helt. Tenkte bare det blir dårlig UX å validere bare i server (selv om det er viktigere der) mtp nettverkskall og latency.

Et alternativ er å bruke html sin innebygde validering. Da blir feilmeldingene på engelsk med mindre vi overstyrer med userefs
Men hvis vi kun ønsker server validering kan jeg fjerne usestate greiene :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants