diff --git a/api/src/graphql/leads.sdl.ts b/api/src/graphql/leads.sdl.ts index ed6d471..ce41a3e 100644 --- a/api/src/graphql/leads.sdl.ts +++ b/api/src/graphql/leads.sdl.ts @@ -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 } diff --git a/web/src/components/LeadForm/LeadForm.tsx b/web/src/components/LeadForm/LeadForm.tsx index 0065219..c14e1ce 100644 --- a/web/src/components/LeadForm/LeadForm.tsx +++ b/web/src/components/LeadForm/LeadForm.tsx @@ -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 (