set up for deployment

This commit is contained in:
M1ngdaXie
2026-01-12 00:16:55 -08:00
parent 6b1ed8d11c
commit 819760662a
26 changed files with 568 additions and 13 deletions

View File

@@ -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}`;

View File

@@ -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) {

View File

@@ -1,4 +1,4 @@
import { CSSProperties } from 'react';
import type { CSSProperties } from 'react';
interface FloatingGemProps {
position?: { top?: string; right?: string; bottom?: string; left?: string };

View File

@@ -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';

View File

@@ -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';

View File

@@ -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;

View File

@@ -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> => {

View File

@@ -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 = () => {