🌐(frontend) add Content-Language on doc access endpoint

We send an internationalized email from
the POST /api/docs/:docId/access endpoint.
We add the language of the website with the
Content-Language header.
This commit is contained in:
Anthony LC
2024-08-15 15:41:58 +02:00
committed by Anthony LC
parent 1abbf0539f
commit 143f1a02eb
3 changed files with 10 additions and 0 deletions

View File

@@ -121,6 +121,9 @@ test.describe('Document create member', () => {
).toBeVisible();
const responseAddUser = await responsePromiseAddUser;
expect(responseAddUser.ok()).toBeTruthy();
expect(responseAddUser.request().headers()['content-language']).toBe(
'en-us',
);
});
test('it try to add twice the same user', async ({ page, browserName }) => {

View File

@@ -9,6 +9,7 @@ import {
Role,
} from '@/features/docs/doc-management';
import { KEY_LIST_DOC_ACCESSES } from '@/features/docs/members/members-list';
import { ContentLanguage } from '@/i18n/types';
import { OptionType } from '../types';
@@ -18,15 +19,20 @@ interface CreateDocAccessParams {
role: Role;
docId: Doc['id'];
memberId: User['id'];
contentLanguage: ContentLanguage;
}
export const createDocAccess = async ({
memberId,
role,
docId,
contentLanguage,
}: CreateDocAccessParams): Promise<Access> => {
const response = await fetchAPI(`documents/${docId}/accesses/`, {
method: 'POST',
headers: {
'Content-Language': contentLanguage,
},
body: JSON.stringify({
user_id: memberId,
role,

View File

@@ -62,6 +62,7 @@ export const AddMembers = ({ currentRole, doc }: ModalAddMembersProps) => {
role: selectedRole,
docId: doc.id,
memberId: selectedUser.value.id,
contentLanguage,
});
break;
}