A full-featured CRM built with React, shadcn/ui, and Supabase.
Make the cache authoritative again after a failed save
Jeromec80a4382f872
diff --git a/src/components/atomic-crm/settings/SettingsPageMobile.tsx b/src/components/atomic-crm/settings/SettingsPageMobile.tsxindex c5eb8c99..ebb230a1 100644--- a/src/components/atomic-crm/settings/SettingsPageMobile.tsx+++ b/src/components/atomic-crm/settings/SettingsPageMobile.tsx@@ -177,8 +177,8 @@ const ProfileSection = () => {messageArgs: { _: "Your profile has been updated" },});} catch (error) {+ await refetchUser();refetchIdentity();- refetchUser();const { message, args } = getSalesErrorNotification(error);notify(message, {type: "error",diff --git a/supabase/functions/postmark/index.ts b/supabase/functions/postmark/index.tsindex 3b39457e..dbf02b2d 100644--- a/supabase/functions/postmark/index.ts+++ b/supabase/functions/postmark/index.ts@@ -174,11 +174,14 @@ Deno.serve(async (req) => {}if (failedContacts.length) {- // Return a 403 to let Postmark know that it's no use to retry this request:- // the notes already written are not idempotent, a redelivery would duplicate them+ // A partial failure answers 403 so Postmark does not redeliver: the notes+ // already written are not idempotent and would be duplicated. When every+ // contact failed there is no note to duplicate, so a retry is safe.+ // https://postmarkapp.com/developer/webhooks/inbound-webhook#errors-and-retries+ const status = failedContacts.length === contacts.length ? 500 : 403;return new Response(`Could not add the note for: ${failedContacts.join(", ")}`,- { status: 403 },+ { status },);}diff --git a/supabase/functions/users/index.ts b/supabase/functions/users/index.tsindex 4a94b5f1..76491d77 100644--- a/supabase/functions/users/index.ts+++ b/supabase/functions/users/index.ts@@ -315,15 +315,6 @@ async function patchUser(req: Request, currentUserSale: any) {);}- const primaryEmail = (email ?? sale.email).trim().toLowerCase();- if (normalizedSecondaryEmails.includes(primaryEmail)) {- return createErrorResponse(- 409,- `Secondary email is already the main address: ${primaryEmail}`,- { code: "secondary_email_is_primary", email: primaryEmail },- );- }-const takenEmail = await findEmailUsedByAnotherSale(normalizedSecondaryEmails,sales_id,@@ -337,6 +328,19 @@ async function patchUser(req: Request, currentUserSale: any) {}}+ const primaryEmail = (email ?? sale.email).trim().toLowerCase();+ const effectiveSecondaryEmails =+ normalizedSecondaryEmails ??+ (Array.isArray(sale.secondary_emails) ? sale.secondary_emails : []);++ if (effectiveSecondaryEmails.includes(primaryEmail)) {+ return createErrorResponse(+ 409,+ `Secondary email is already the main address: ${primaryEmail}`,+ { code: "secondary_email_is_primary", email: primaryEmail },+ );+ }+const { data, error: userError } =await supabaseAdmin.auth.admin.updateUserById(sale.user_id, {email,