Skip to content

Commit

Permalink
lead form updates & @skipAuth
Browse files Browse the repository at this point in the history
  • Loading branch information
pantheredeye committed Dec 13, 2024
1 parent a31b324 commit 70492d2
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
2 changes: 1 addition & 1 deletion api/src/graphql/leads.sdl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export const schema = gql`
}
type Mutation {
createLead(input: CreateLeadInput!): Lead!
createLead(input: CreateLeadInput!): Lead! @skipAuth
updateLead(id: Int!, input: UpdateLeadInput!): Lead! @requireAuth
deleteLead(id: Int!): Lead! @requireAuth
}
Expand Down
18 changes: 12 additions & 6 deletions web/src/components/LeadForm/LeadForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,20 @@ const CREATE_LEAD = gql`
`

const LeadForm = () => {
const [createLead] = useMutation(CREATE_LEAD, {
onCompleted: () => {
alert('Thanks for signing up!')
},
})
const [createLead] = useMutation(CREATE_LEAD)

const handleLeadSubmit = async (input) => {
try {
await createLead({ variables: { input } })
alert('Thank you for your interest!')
} catch (error) {
console.error('Submission failed:', error)
alert('Something went wrong. Please try again later.')
}
}

const onSubmit = (data) => {
createLead({ variables: { input: data } })
handleLeadSubmit(data)
}

return (
Expand Down

0 comments on commit 70492d2

Please sign in to comment.