fix(web): pass bearer auth in document revision api and fix ts unused imports
This commit is contained in:
@@ -5,15 +5,20 @@ import type {
|
||||
PatchContentBody,
|
||||
RevisionState,
|
||||
} from '../features/documentRevision/types';
|
||||
import { mergeAuthHeaders } from './authHeaders';
|
||||
|
||||
async function api<T>(path: string, init?: RequestInit): Promise<T> {
|
||||
const extra =
|
||||
init?.headers instanceof Headers
|
||||
? Object.fromEntries(init.headers.entries())
|
||||
: ((init?.headers as Record<string, string> | undefined) ?? {});
|
||||
const contentType =
|
||||
typeof extra['Content-Type'] === 'string' ? extra['Content-Type'] : 'application/json';
|
||||
const headers = mergeAuthHeaders(extra, contentType);
|
||||
const res = await fetch(path, {
|
||||
credentials: 'include',
|
||||
...init,
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
...(init?.headers || {}),
|
||||
},
|
||||
headers,
|
||||
});
|
||||
const data = await res.json().catch(() => ({}));
|
||||
if (!res.ok) {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import React, { useEffect, useState } from 'react';
|
||||
import { useEffect, useState } from 'react';
|
||||
import type { ChangeReport } from '../../features/documentRevision/types';
|
||||
import { getChangeReport } from '../../api/documentRevision';
|
||||
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import React from 'react';
|
||||
import type { DiffHunk } from '../../features/documentRevision/types';
|
||||
|
||||
export function DiffNavigator(props: { hunks: DiffHunk[] }) {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import React, { useEffect, useState } from 'react';
|
||||
import { useEffect, useState } from 'react';
|
||||
import type { DiffResult, DocumentVersion, OverlayMode, RevisionState } from '../../features/documentRevision/types';
|
||||
import { getDiff, getManualOverlay, getRevisionState, listVersions } from '../../api/documentRevision';
|
||||
import { VersionHistoryDrawer } from './VersionHistoryDrawer';
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
import React from 'react';
|
||||
|
||||
/** Marker component — decorations are applied via overlay hunks on blocks. */
|
||||
export function ManualChangeOverlay() {
|
||||
return (
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import React from 'react';
|
||||
import type { DiffResult } from '../../features/documentRevision/types';
|
||||
import { DiffNavigator } from './DiffNavigator';
|
||||
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import React from 'react';
|
||||
import { patchNotification } from '../../api/documentRevision';
|
||||
|
||||
export type DocNotificationItem = {
|
||||
|
||||
Reference in New Issue
Block a user