set up for deployment
This commit is contained in:
@@ -3,11 +3,18 @@ const API_BASE_URL = import.meta.env.VITE_API_URL || "http://localhost:8080/api"
|
||||
export async function authFetch(url: string, options?: RequestInit): Promise<Response> {
|
||||
const token = localStorage.getItem('auth_token');
|
||||
|
||||
const headers: HeadersInit = {
|
||||
const headers: Record<string, string> = {
|
||||
'Content-Type': 'application/json',
|
||||
...options?.headers,
|
||||
};
|
||||
|
||||
// Merge existing headers if provided
|
||||
if (options?.headers) {
|
||||
const existingHeaders = new Headers(options.headers);
|
||||
existingHeaders.forEach((value, key) => {
|
||||
headers[key] = value;
|
||||
});
|
||||
}
|
||||
|
||||
// Add Authorization header if token exists
|
||||
if (token) {
|
||||
headers['Authorization'] = `Bearer ${token}`;
|
||||
|
||||
@@ -70,7 +70,7 @@ const KanbanBoard = ({ providers }: KanbanBoardProps) => {
|
||||
|
||||
if (columnIndex !== -1) {
|
||||
providers.ydoc.transact(() => {
|
||||
const column = cols[columnIndex];
|
||||
const column = cols[columnIndex] as KanbanColumn;
|
||||
column.tasks.push(task);
|
||||
yarray.delete(columnIndex, 1);
|
||||
yarray.insert(columnIndex, [column]);
|
||||
@@ -91,8 +91,8 @@ const KanbanBoard = ({ providers }: KanbanBoardProps) => {
|
||||
|
||||
if (fromIndex !== -1 && toIndex !== -1) {
|
||||
providers.ydoc.transact(() => {
|
||||
const fromCol = { ...cols[fromIndex] };
|
||||
const toCol = { ...cols[toIndex] };
|
||||
const fromCol = { ...(cols[fromIndex] as KanbanColumn) };
|
||||
const toCol = { ...(cols[toIndex] as KanbanColumn) };
|
||||
|
||||
const taskIndex = fromCol.tasks.findIndex((t: Task) => t.id === taskId);
|
||||
if (taskIndex !== -1) {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { CSSProperties } from 'react';
|
||||
import type { CSSProperties } from 'react';
|
||||
|
||||
interface FloatingGemProps {
|
||||
position?: { top?: string; right?: string; bottom?: string; left?: string };
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { ReactNode } from 'react';
|
||||
import type { ReactNode } from 'react';
|
||||
import { Navigate, useLocation } from 'react-router-dom';
|
||||
import { useAuth } from '../contexts/AuthContext';
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { createContext, useContext, useState, useEffect, ReactNode } from 'react';
|
||||
import { createContext, useContext, useState, useEffect } from 'react';
|
||||
import type { ReactNode } from 'react';
|
||||
import type { User, AuthContextType } from '../types/auth';
|
||||
import { authApi } from '../api/auth';
|
||||
|
||||
|
||||
@@ -3,13 +3,13 @@ import * as Y from 'yjs';
|
||||
import { documentsApi } from '../api/document';
|
||||
|
||||
export const useAutoSave = (documentId: string, ydoc: Y.Doc | null) => {
|
||||
const saveTimeoutRef = useRef<NodeJS.Timeout | null>(null);
|
||||
const saveTimeoutRef = useRef<number | null>(null);
|
||||
const isSavingRef = useRef(false);
|
||||
|
||||
useEffect(() => {
|
||||
if (!ydoc) return;
|
||||
|
||||
const handleUpdate = (update: Uint8Array, origin: any) => {
|
||||
const handleUpdate = (_update: Uint8Array, origin: any) => {
|
||||
// Ignore updates from initial sync or remote sources
|
||||
if (origin === 'init' || origin === 'remote') return;
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ import { WebsocketProvider } from "y-websocket";
|
||||
import * as Y from "yjs";
|
||||
import { documentsApi } from "../api/document";
|
||||
|
||||
const WS_URL = import.meta.env.VITE_WS_URL || "ws://localhost:8080/ws";
|
||||
const WS_URL = import.meta.env.VITE_WS_URL;
|
||||
|
||||
export interface YjsProviders {
|
||||
ydoc: Y.Doc;
|
||||
@@ -21,7 +21,7 @@ export interface YjsUser {
|
||||
|
||||
export const createYjsDocument = async (
|
||||
documentId: string,
|
||||
user: YjsUser,
|
||||
_user: YjsUser,
|
||||
token: string,
|
||||
shareToken?: string
|
||||
): Promise<YjsProviders> => {
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import { useState } from "react";
|
||||
import { useNavigate, useParams, useSearchParams } from "react-router-dom";
|
||||
import Editor from "../components/Editor/Editor.tsx";
|
||||
import Navbar from "../components/Navbar.tsx";
|
||||
import UserList from "../components/Presence/UserList.tsx";
|
||||
import ShareModal from "../components/Share/ShareModal.tsx";
|
||||
import Navbar from "../components/Navbar.tsx";
|
||||
import { useYjsDocument } from "../hooks/useYjsDocument.ts";
|
||||
|
||||
const EditorPage = () => {
|
||||
|
||||
Reference in New Issue
Block a user