Include credentials on client-side dashboard API requests
This commit is contained in:
@ -96,6 +96,7 @@ export function AuditTrailBoard({
|
|||||||
|
|
||||||
const response = await fetch(`/api/audit-trail?${params.toString()}`, {
|
const response = await fetch(`/api/audit-trail?${params.toString()}`, {
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
|
credentials: 'include',
|
||||||
signal: controller.signal,
|
signal: controller.signal,
|
||||||
cache: 'no-store',
|
cache: 'no-store',
|
||||||
});
|
});
|
||||||
|
|||||||
@ -83,6 +83,7 @@ export function CampaignDetailActions({ campaign }: Props) {
|
|||||||
setIsDuplicating(true);
|
setIsDuplicating(true);
|
||||||
const response = await fetch(`/api/campaigns/${campaign.id}/duplicate`, {
|
const response = await fetch(`/api/campaigns/${campaign.id}/duplicate`, {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
|
credentials: 'include',
|
||||||
});
|
});
|
||||||
const payload = await readPayload(response);
|
const payload = await readPayload(response);
|
||||||
router.push(`/dashboard/campaigns/${payload.id}`);
|
router.push(`/dashboard/campaigns/${payload.id}`);
|
||||||
@ -107,6 +108,7 @@ export function CampaignDetailActions({ campaign }: Props) {
|
|||||||
setIsSendingNow(true);
|
setIsSendingNow(true);
|
||||||
const response = await fetch(`/api/campaigns/${campaign.id}/send`, {
|
const response = await fetch(`/api/campaigns/${campaign.id}/send`, {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
|
credentials: 'include',
|
||||||
headers: { 'Content-Type': 'application/json' },
|
headers: { 'Content-Type': 'application/json' },
|
||||||
body: JSON.stringify({ mode: 'now' }),
|
body: JSON.stringify({ mode: 'now' }),
|
||||||
});
|
});
|
||||||
@ -133,6 +135,7 @@ export function CampaignDetailActions({ campaign }: Props) {
|
|||||||
setIsScheduling(true);
|
setIsScheduling(true);
|
||||||
const response = await fetch(`/api/campaigns/${campaign.id}/send`, {
|
const response = await fetch(`/api/campaigns/${campaign.id}/send`, {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
|
credentials: 'include',
|
||||||
headers: { 'Content-Type': 'application/json' },
|
headers: { 'Content-Type': 'application/json' },
|
||||||
body: JSON.stringify({ mode: 'scheduled', scheduledAt: new Date(scheduledAt).toISOString() }),
|
body: JSON.stringify({ mode: 'scheduled', scheduledAt: new Date(scheduledAt).toISOString() }),
|
||||||
});
|
});
|
||||||
@ -180,7 +183,10 @@ export function CampaignDetailActions({ campaign }: Props) {
|
|||||||
try {
|
try {
|
||||||
setMessage(null);
|
setMessage(null);
|
||||||
setIsDeleting(true);
|
setIsDeleting(true);
|
||||||
const response = await fetch(`/api/campaigns/${campaign.id}`, { method: 'DELETE' });
|
const response = await fetch(`/api/campaigns/${campaign.id}`, {
|
||||||
|
method: 'DELETE',
|
||||||
|
credentials: 'include',
|
||||||
|
});
|
||||||
if (!response.ok && response.status !== 204) {
|
if (!response.ok && response.status !== 204) {
|
||||||
await readPayload(response);
|
await readPayload(response);
|
||||||
}
|
}
|
||||||
@ -211,6 +217,7 @@ export function CampaignDetailActions({ campaign }: Props) {
|
|||||||
setIsSaving(true);
|
setIsSaving(true);
|
||||||
const response = await fetch(`/api/campaigns/${campaign.id}`, {
|
const response = await fetch(`/api/campaigns/${campaign.id}`, {
|
||||||
method: 'PATCH',
|
method: 'PATCH',
|
||||||
|
credentials: 'include',
|
||||||
headers: { 'Content-Type': 'application/json' },
|
headers: { 'Content-Type': 'application/json' },
|
||||||
body: JSON.stringify({
|
body: JSON.stringify({
|
||||||
...form,
|
...form,
|
||||||
|
|||||||
@ -192,6 +192,7 @@ export function CampaignsManagementBoard({ campaigns, metrics }: Props) {
|
|||||||
try {
|
try {
|
||||||
const response = await fetch('/api/campaigns', {
|
const response = await fetch('/api/campaigns', {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
|
credentials: 'include',
|
||||||
headers: { 'Content-Type': 'application/json' },
|
headers: { 'Content-Type': 'application/json' },
|
||||||
body: JSON.stringify({
|
body: JSON.stringify({
|
||||||
...createForm,
|
...createForm,
|
||||||
|
|||||||
@ -237,6 +237,7 @@ export function ContactDetailBoard({ contact }: Props) {
|
|||||||
setIsSaving(true);
|
setIsSaving(true);
|
||||||
const response = await fetch(`/api/contacts/${contact.id}`, {
|
const response = await fetch(`/api/contacts/${contact.id}`, {
|
||||||
method: 'PATCH',
|
method: 'PATCH',
|
||||||
|
credentials: 'include',
|
||||||
headers: { 'Content-Type': 'application/json' },
|
headers: { 'Content-Type': 'application/json' },
|
||||||
body: JSON.stringify(form),
|
body: JSON.stringify(form),
|
||||||
});
|
});
|
||||||
@ -290,7 +291,10 @@ export function ContactDetailBoard({ contact }: Props) {
|
|||||||
try {
|
try {
|
||||||
setError(null);
|
setError(null);
|
||||||
setIsDeleting(true);
|
setIsDeleting(true);
|
||||||
const response = await fetch(`/api/contacts/${contact.id}`, { method: 'DELETE' });
|
const response = await fetch(`/api/contacts/${contact.id}`, {
|
||||||
|
method: 'DELETE',
|
||||||
|
credentials: 'include',
|
||||||
|
});
|
||||||
const payload = await response.json();
|
const payload = await response.json();
|
||||||
if (!response.ok) {
|
if (!response.ok) {
|
||||||
throw new Error(typeof payload?.message === 'string' ? payload.message : 'Failed to delete contact');
|
throw new Error(typeof payload?.message === 'string' ? payload.message : 'Failed to delete contact');
|
||||||
|
|||||||
@ -110,6 +110,7 @@ export function ContactsDirectoryBoard({ data, filters }: Props) {
|
|||||||
for (const item of items) {
|
for (const item of items) {
|
||||||
const response = await fetch('/api/contacts', {
|
const response = await fetch('/api/contacts', {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
|
credentials: 'include',
|
||||||
headers: { 'Content-Type': 'application/json' },
|
headers: { 'Content-Type': 'application/json' },
|
||||||
body: JSON.stringify(item),
|
body: JSON.stringify(item),
|
||||||
});
|
});
|
||||||
@ -350,6 +351,7 @@ export function ContactsDirectoryBoard({ data, filters }: Props) {
|
|||||||
setIsSubmitting(true);
|
setIsSubmitting(true);
|
||||||
const response = await fetch('/api/contacts', {
|
const response = await fetch('/api/contacts', {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
|
credentials: 'include',
|
||||||
headers: { 'Content-Type': 'application/json' },
|
headers: { 'Content-Type': 'application/json' },
|
||||||
body: JSON.stringify(form),
|
body: JSON.stringify(form),
|
||||||
});
|
});
|
||||||
|
|||||||
@ -119,6 +119,7 @@ export function ConversationsInbox({
|
|||||||
const params = new URLSearchParams({ filter: normalizeFilter(filter) });
|
const params = new URLSearchParams({ filter: normalizeFilter(filter) });
|
||||||
if (searchTerm) params.set('search', searchTerm);
|
if (searchTerm) params.set('search', searchTerm);
|
||||||
const response = await fetch(`/api/conversations?${params.toString()}`, {
|
const response = await fetch(`/api/conversations?${params.toString()}`, {
|
||||||
|
credentials: 'include',
|
||||||
signal: controller.signal,
|
signal: controller.signal,
|
||||||
cache: 'no-store',
|
cache: 'no-store',
|
||||||
});
|
});
|
||||||
@ -168,6 +169,7 @@ export function ConversationsInbox({
|
|||||||
try {
|
try {
|
||||||
setIsThreadLoading(true);
|
setIsThreadLoading(true);
|
||||||
const response = await fetch(`/api/conversations/${activeConversationId}`, {
|
const response = await fetch(`/api/conversations/${activeConversationId}`, {
|
||||||
|
credentials: 'include',
|
||||||
signal: controller.signal,
|
signal: controller.signal,
|
||||||
cache: 'no-store',
|
cache: 'no-store',
|
||||||
});
|
});
|
||||||
@ -201,6 +203,7 @@ export function ConversationsInbox({
|
|||||||
const params = new URLSearchParams({ filter: normalizeFilter(filter) });
|
const params = new URLSearchParams({ filter: normalizeFilter(filter) });
|
||||||
if (searchTerm) params.set('search', searchTerm);
|
if (searchTerm) params.set('search', searchTerm);
|
||||||
const response = await fetch(`/api/conversations?${params.toString()}`, {
|
const response = await fetch(`/api/conversations?${params.toString()}`, {
|
||||||
|
credentials: 'include',
|
||||||
cache: 'no-store',
|
cache: 'no-store',
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -224,6 +227,7 @@ export function ConversationsInbox({
|
|||||||
setIsAssigning(true);
|
setIsAssigning(true);
|
||||||
const response = await fetch(`/api/conversations/${activeConversation.id}/assign`, {
|
const response = await fetch(`/api/conversations/${activeConversation.id}/assign`, {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
|
credentials: 'include',
|
||||||
});
|
});
|
||||||
if (!response.ok) {
|
if (!response.ok) {
|
||||||
return;
|
return;
|
||||||
@ -231,6 +235,7 @@ export function ConversationsInbox({
|
|||||||
|
|
||||||
await refreshSummaries(activeConversation.id);
|
await refreshSummaries(activeConversation.id);
|
||||||
const detailResponse = await fetch(`/api/conversations/${activeConversation.id}`, {
|
const detailResponse = await fetch(`/api/conversations/${activeConversation.id}`, {
|
||||||
|
credentials: 'include',
|
||||||
cache: 'no-store',
|
cache: 'no-store',
|
||||||
});
|
});
|
||||||
if (!detailResponse.ok) {
|
if (!detailResponse.ok) {
|
||||||
@ -265,6 +270,7 @@ export function ConversationsInbox({
|
|||||||
setIsSending(true);
|
setIsSending(true);
|
||||||
const response = await fetch(`/api/conversations/${activeConversation.id}/messages`, {
|
const response = await fetch(`/api/conversations/${activeConversation.id}/messages`, {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
|
credentials: 'include',
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
},
|
},
|
||||||
|
|||||||
@ -134,6 +134,7 @@ export function RolesPermissionsBoard({ initialRoles, initialAuditHighlights }:
|
|||||||
try {
|
try {
|
||||||
const response = await fetch(`/api/roles/${selectedRole.id}`, {
|
const response = await fetch(`/api/roles/${selectedRole.id}`, {
|
||||||
method: 'PATCH',
|
method: 'PATCH',
|
||||||
|
credentials: 'include',
|
||||||
headers: { 'Content-Type': 'application/json' },
|
headers: { 'Content-Type': 'application/json' },
|
||||||
body: JSON.stringify({
|
body: JSON.stringify({
|
||||||
permissions: selectedRole.permissionRows,
|
permissions: selectedRole.permissionRows,
|
||||||
@ -219,6 +220,7 @@ export function RolesPermissionsBoard({ initialRoles, initialAuditHighlights }:
|
|||||||
try {
|
try {
|
||||||
const response = await fetch('/api/roles', {
|
const response = await fetch('/api/roles', {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
|
credentials: 'include',
|
||||||
headers: { 'Content-Type': 'application/json' },
|
headers: { 'Content-Type': 'application/json' },
|
||||||
body: JSON.stringify({
|
body: JSON.stringify({
|
||||||
name: trimmedName,
|
name: trimmedName,
|
||||||
|
|||||||
@ -164,6 +164,7 @@ export function UsersManagementBoard({
|
|||||||
if (roleFilter !== 'all') params.set('roleId', roleFilter);
|
if (roleFilter !== 'all') params.set('roleId', roleFilter);
|
||||||
|
|
||||||
const response = await fetch(`/api/users?${params.toString()}`, {
|
const response = await fetch(`/api/users?${params.toString()}`, {
|
||||||
|
credentials: 'include',
|
||||||
signal: controller.signal,
|
signal: controller.signal,
|
||||||
cache: 'no-store',
|
cache: 'no-store',
|
||||||
});
|
});
|
||||||
@ -215,6 +216,7 @@ export function UsersManagementBoard({
|
|||||||
try {
|
try {
|
||||||
const response = await fetch('/api/users', {
|
const response = await fetch('/api/users', {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
|
credentials: 'include',
|
||||||
headers: { 'Content-Type': 'application/json' },
|
headers: { 'Content-Type': 'application/json' },
|
||||||
body: JSON.stringify({
|
body: JSON.stringify({
|
||||||
name: inviteName,
|
name: inviteName,
|
||||||
@ -251,6 +253,7 @@ export function UsersManagementBoard({
|
|||||||
try {
|
try {
|
||||||
const response = await fetch(`/api/users/${editingUser.id}`, {
|
const response = await fetch(`/api/users/${editingUser.id}`, {
|
||||||
method: 'PATCH',
|
method: 'PATCH',
|
||||||
|
credentials: 'include',
|
||||||
headers: { 'Content-Type': 'application/json' },
|
headers: { 'Content-Type': 'application/json' },
|
||||||
body: JSON.stringify({
|
body: JSON.stringify({
|
||||||
name: editName,
|
name: editName,
|
||||||
@ -293,6 +296,7 @@ export function UsersManagementBoard({
|
|||||||
try {
|
try {
|
||||||
const response = await fetch('/api/users', {
|
const response = await fetch('/api/users', {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
|
credentials: 'include',
|
||||||
headers: { 'Content-Type': 'application/json' },
|
headers: { 'Content-Type': 'application/json' },
|
||||||
body: JSON.stringify({
|
body: JSON.stringify({
|
||||||
name: user.name,
|
name: user.name,
|
||||||
|
|||||||
Reference in New Issue
Block a user