Skip to content

Commit

Permalink
added graphQL mutation
Browse files Browse the repository at this point in the history
  • Loading branch information
Collin Pastika committed Jul 8, 2024
1 parent 11a1f5e commit 71836ea
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 3 deletions.
11 changes: 11 additions & 0 deletions src/components/Tool/FixEmailAddresses/AddEmailAddress.graphql
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
mutation EmailAddresses($input: PersonUpdateMutationInput!) {
updatePerson(input: $input) {
person {
emailAddresses {
nodes {
email
}
}
}
}
}
17 changes: 14 additions & 3 deletions src/components/Tool/FixEmailAddresses/FixEmailAddressPerson.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import { dateFormatShort } from 'src/lib/intlFormat';
import theme from '../../../theme';
import { ConfirmButtonIcon } from '../ConfirmButtonIcon';
import { EmailAddressData } from './FixEmailAddresses';
// import { useEmailAddressesMutation } from './FixEmailAddresses.generated';

const ContactInputField = styled(TextField, {
shouldForwardProp: (prop) => prop !== 'destroyed',
Expand Down Expand Up @@ -137,6 +138,16 @@ interface EmailValidationFormProps {

const onSubmit = () => {};

// const [handleAdd] = useEmailAddressesMutation();
// const email = '';

// const [emailAddressesMutation, { data, loading, error }] =
// useEmailAddressesMutation({
// variables: {
// input: email,
// },
// });

const EmailValidationForm = ({
emails: initialEmail = {
email: '',
Expand All @@ -154,8 +165,8 @@ const EmailValidationForm = ({
});
const { t } = useTranslation();

const handleValidation = (isValid) => {
if (!isValid) {
const handleValidation = (isValid, email) => {
if (!isValid && email !== '') {
enqueueSnackbar(t('Invalid Email Address Format'), {
variant: 'error',
});
Expand Down Expand Up @@ -192,7 +203,7 @@ const EmailValidationForm = ({
name="email"
value={values.email}
onChange={handleChange}
onBlur={() => handleValidation(isValid)}
onBlur={() => handleValidation(isValid, values.email)}
/>
<IconButton
type="submit"
Expand Down

0 comments on commit 71836ea

Please sign in to comment.