mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-29 09:30:59 +00:00
feat: WIP element Chat intergration
This commit is contained in:
13
apps/edr-freight-web/backoffice/src/features/chat/chatApi.ts
Normal file
13
apps/edr-freight-web/backoffice/src/features/chat/chatApi.ts
Normal file
@@ -0,0 +1,13 @@
|
||||
import { api } from "@/auth/http";
|
||||
|
||||
/**
|
||||
* Internal chat (Matrix/Element) REST calls. Just the one endpoint — Chat
|
||||
* itself is a separate app (chat.edr.et); this backoffice only ever asks for
|
||||
* a fresh sign-in link into it.
|
||||
*/
|
||||
export const chatApi = {
|
||||
getSsoUrl: async (): Promise<string> => {
|
||||
const { data } = await api.get<{ url: string }>("/chat/sso");
|
||||
return data.url;
|
||||
},
|
||||
};
|
||||
@@ -0,0 +1,19 @@
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
|
||||
import { chatApi } from "./chatApi";
|
||||
|
||||
export const CHAT_SSO_KEY = ["chat", "sso"] as const;
|
||||
|
||||
/**
|
||||
* The login_token this resolves to is single-use and expires in 5 minutes
|
||||
* (Synapse default) — the global `staleTime: 0` (queryClient.ts) already
|
||||
* means every fresh mount of the launch page refetches rather than reusing
|
||||
* a possibly-spent link.
|
||||
*/
|
||||
export function useChatSso() {
|
||||
return useQuery({
|
||||
queryKey: CHAT_SSO_KEY,
|
||||
queryFn: chatApi.getSsoUrl,
|
||||
retry: false,
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user