mirror of
https://github.com/Shadowfita/docmost.git
synced 2025-11-17 10:11:03 +10:00
more work on attachments
* fix frontend env usage
This commit is contained in:
@ -1,24 +1,7 @@
|
||||
import { getCollaborationUrl } from "@/lib/config.ts";
|
||||
|
||||
const useCollaborationURL = (): string => {
|
||||
const PATH = "/collab";
|
||||
|
||||
// TODO: revisit
|
||||
/*
|
||||
if (import.meta.env.VITE_COLLABORATION_URL) {
|
||||
return import.meta.env.VITE_COLLABORATION_URL + PATH;
|
||||
}
|
||||
|
||||
const API_URL = import.meta.env.VITE_BACKEND_API_URL;
|
||||
if (!API_URL) {
|
||||
throw new Error("Backend API URL is not defined");
|
||||
}
|
||||
*/
|
||||
|
||||
const API_URL = import.meta.env.DEV
|
||||
? "http://localhost:3000"
|
||||
: window.location.protocol + "//" + window.location.host;
|
||||
|
||||
const wsProtocol = API_URL.startsWith("https") ? "wss" : "ws";
|
||||
return `${wsProtocol}://${API_URL.split("://")[1]}${PATH}`;
|
||||
return getCollaborationUrl();
|
||||
};
|
||||
|
||||
export default useCollaborationURL;
|
||||
|
||||
@ -165,10 +165,10 @@ export default function SpaceTree({ spaceId }: SpaceTreeProps) {
|
||||
}, [isDataLoaded.current, currentPage?.id]);
|
||||
|
||||
useEffect(() => {
|
||||
if (currentPage) {
|
||||
setTimeout(() => {
|
||||
treeApiRef.current?.select(currentPage.id, { align: "auto" });
|
||||
}, 100);
|
||||
if (currentPage?.id) {
|
||||
treeApiRef.current?.select(currentPage.id, { align: "auto" });
|
||||
} else {
|
||||
treeApiRef.current?.deselectAll();
|
||||
}
|
||||
}, [currentPage?.id]);
|
||||
|
||||
@ -179,12 +179,6 @@ export default function SpaceTree({ spaceId }: SpaceTreeProps) {
|
||||
}
|
||||
}, [treeApiRef.current]);
|
||||
|
||||
useEffect(() => {
|
||||
if (location.pathname === APP_ROUTE.HOME && treeApiRef.current) {
|
||||
treeApiRef.current.deselectAll();
|
||||
}
|
||||
}, [location.pathname]);
|
||||
|
||||
return (
|
||||
<div ref={mergedRef} className={classes.treeContainer}>
|
||||
{rootElement.current && (
|
||||
|
||||
@ -3,7 +3,7 @@ import { currentUserAtom } from "@/features/user/atoms/current-user-atom.ts";
|
||||
import { useState } from "react";
|
||||
import { useAtom } from "jotai";
|
||||
import { UserAvatar } from "@/components/ui/user-avatar.tsx";
|
||||
import { FileButton, Button, Text, Popover, Tooltip } from "@mantine/core";
|
||||
import { FileButton, Tooltip } from "@mantine/core";
|
||||
import { uploadAvatar } from "@/features/user/services/user-service.ts";
|
||||
|
||||
const userAtom = focusAtom(currentUserAtom, (optic) => optic.prop("user"));
|
||||
@ -29,8 +29,7 @@ export default function AccountAvatar() {
|
||||
|
||||
try {
|
||||
setIsLoading(true);
|
||||
const upload = await uploadAvatar(selectedFile);
|
||||
console.log(upload);
|
||||
await uploadAvatar(selectedFile);
|
||||
} catch (err) {
|
||||
console.log(err);
|
||||
} finally {
|
||||
|
||||
@ -13,8 +13,10 @@ export async function updateUser(data: Partial<IUser>): Promise<IUser> {
|
||||
|
||||
export async function uploadAvatar(file: File) {
|
||||
const formData = new FormData();
|
||||
formData.append("avatar", file);
|
||||
const req = await api.post("/attachments/upload/avatar", formData, {
|
||||
formData.append("type", "avatar");
|
||||
formData.append("image", file);
|
||||
|
||||
const req = await api.post("/attachments/upload-image", formData, {
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data",
|
||||
},
|
||||
|
||||
@ -77,3 +77,16 @@ export async function getInvitationById(data: {
|
||||
const req = await api.post("/workspace/invites/info", data);
|
||||
return req.data;
|
||||
}
|
||||
|
||||
export async function uploadLogo(file: File) {
|
||||
const formData = new FormData();
|
||||
formData.append("type", "workspace-logo");
|
||||
formData.append("image", file);
|
||||
|
||||
const req = await api.post("/attachments/upload-image", formData, {
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data",
|
||||
},
|
||||
});
|
||||
return req.data;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user