This commit is contained in:
Kilian committed 2024-07-27 21:49:23 +02:00
1 parent eb3516bfb2
commit a3ec9ae318
7 files changed
+41 -19

No files matched your search

+1
View File
@@ -0,0 +1 @@
import{j as e,M as le,a as $,T as y,B as w,b as P,c as C,A as Ce,d as re,L as U,C as M,I as O,e as be,f as D,P as T,g as we,u as Se,h as ce,i as X,k as Z,D as Q,l as W,m as E,n as K,o as ue,p as Pe,q as de,r as he,s as Ee,S as q,t as Fe,G as v,v as J,w as Ae,x as ke,y as De,z as Te,F as $e,E as Ie,H as Ue}from"./mui-CxHUbSMi.js";import{u as Y,a as R,b as H,c as Le,d as Oe,L as A,e as qe,O as Me,f as Re,r as N,g as B,h as z,q as ee,i as te,j as ne,Q as Be,k as ze,l as Ne,R as Qe,m as We}from"./tanstack-xmxrKlZO.js";import{c as Ke,r as f}from"./react-DXd9vB-a.js";import{i as L,B as He,a as Ve,b as _e,u as F,t as h}from"./i18n-DJgSTqOl.js";(function(){const n=document.createElement("link").relList;if(n&&n.supports&&n.supports("modulepreload"))return;for(const s of document.querySelectorAll('link[rel="modulepreload"]'))a(s);new MutationObserver(s=>{for(const i of s)if(i.type==="childList")for(const r of i.addedNodes)r.tagName==="LINK"&&r.rel==="modulepreload"&&a(r)}).observe(document,{childList:!0,subtree:!0});function o(s){const i={};return s.integrity&&(i.integrity=s.integrity),s.referrerPolicy&&(i.referrerPolicy=s.referrerPolicy),s.crossOrigin==="use-credentials"?i.credentials="include":s.crossOrigin==="anonymous"?i.credentials="omit":i.credentials="same-origin",i}function a(s){if(s.ep)return;s.ep=!0;const i=o(s);fetch(s.href,i)}})();var G={},ae=Ke;G.createRoot=ae.createRoot,G.hydrateRoot=ae.hydrateRoot;const _=15,S="https://khofmann.userpage.fu-berlin.de/phpCourse/exam/api/";let oe;class Ge{constructor(){if(this.userListeners=[],this.hasAuth=()=>this.token!==void 0,this.isAdmin=()=>{var n;return this.hasAuth()&&((n=this.self)==null?void 0:n.isAdmin)},this.getAuthenticatedUser=()=>this.self,this.getCurrentSession=()=>[this.token,this.refreshToken],this.subscribeToAuthenticatedUser=n=>(this.userListeners.push(n),()=>{this.userListeners=this.userListeners.filter(o=>o!==n)}),this.logIn=async(n,o)=>{const{user:a,token:s}=await(await this.post("login",{email:n,password:o})).json();this.self=a,this.token=s,this.userListeners.forEach(i=>i(a))},this.logOut=async()=>{try{return await(await this.postAuth("logout")).json()}catch{return!1}finally{this.self=void 0,this.token=void 0,this.userListeners.forEach(n=>n())}},this.posts=async n=>{const o=`posts?p=${n??0}&l=${_}`;return this.token?await(await this.getAuth(o)).json():await(await this.get(o)).json()},this.deletePost=async n=>await(await this.delete(`posts/${n}?l=${_}`)).json(),this.user=async n=>{var o;return await(await this.getAuth(`users/${n??((o=this.self)==null?void 0:o.id)}`)).json()},this.updateUser=async(n,o)=>{const a=await(await this.patch(`users/${o??"self"}`,n)).json();return this.self=a,this.userListeners.forEach(s=>s(a)),a},this.updateUserImage=async(n,o)=>{const a=new FormData;n.image&&a.append("image",n.image),!n.image&&n.predefined&&a.append("predefined",n.predefined);const s=await(await this.postAuthRaw(`users/${o??"self"}/image`,a)).json();return this.self=s,this.userListeners.forEach(i=>i(s)),s},this.newPost=async n=>await(await this.postAuth(`posts?l=${_}`,{...n})).json(),this.updatePost=async(n,o)=>await(await this.patch(`posts/${o}`,n)).json(),this.post=async(n,o,a)=>{const s=await fetch(`${S}${n}`,{mode:"cors",method:"post",headers:a,body:JSON.stringify(o)});if(s.ok)return s;throw await s.json()},this.postAuth=async(n,o,a)=>{const s=await fetch(`${S}${n}`,{mode:"cors",method:"post",headers:{token:this.token??"",...a},body:JSON.stringify(o)});if(s.ok)return s;throw await s.json()},this.postAuthRaw=async(n,o,a)=>{const s=await fetch(`${S}${n}`,{mode:"cors",method:"post",headers:{token:this.token??"",...a},body:o});if(s.ok)return s;throw await s.json()},this.get=async(n,o)=>{const a=await fetch(`${S}${n}`,{mode:"cors",method:"get",headers:o});if(a.ok)return a;throw await a.json()},this.getAuth=async(n,o)=>{const a=await fetch(`${S}${n}`,{mode:"cors",method:"get",headers:{token:this.token??"",...o}});if(a.ok)return a;throw await a.json()},this.delete=async(n,o)=>{const a=await fetch(`${S}${n}`,{mode:"cors",method:"delete",headers:{token:this.token??"",...o}});if(a.ok)return a;throw await a.json()},this.patch=async(n,o,a)=>{const s=await fetch(`${S}${n}`,{mode:"cors",method:"patch",headers:{token:this.token??"",...a},body:JSON.stringify(o)});if(s.ok)return s;throw await s.json()},oe)throw new Error("New instance cannot be created!!");oe=this}}const m=new Ge;var k=(t=>(t.NOT_FOUND="NotFound",t.UNAUTHORIZED="Unauthorized",t.FAILED_UPDATE="FailedUpdate",t.MISSING_FIELD="MissingField",t))(k||{});L.use(He).use(Ve).use(_e).init({fallbackLng:"en",debug:!1,interpolation:{escapeValue:!1},backend:{loadPath:"/phpCourse/exam/dist/locales/{{lng}}/{{ns}}.json"}});const Xe=({anchorEl:t,handleClose:n})=>e.jsxs(le,{anchorEl:t,anchorOrigin:{vertical:"bottom",horizontal:"right"},keepMounted:!0,transformOrigin:{vertical:"top",horizontal:"right"},open:!!t,onClose:n,sx:{"& .MuiMenu-paper":{minWidth:"240px"}},children:[e.jsx($,{selected:L.language==="en",onClick:()=>{Line truncated
-1
View File
@@ -1 +0,0 @@
import{j as e,M as le,a as q,T as y,B as w,b as P,c as C,A as Ce,d as re,L as T,C as L,I as O,e as be,f as D,P as $,g as we,u as Se,h as ce,i as X,k as Z,D as Q,l as W,m as F,n as K,o as ue,p as Pe,q as de,r as he,s as Fe,S as M,t as Ae,G as v,v as J,w as Ee,x as ke,y as De,z as $e,F as Ie,E as Te,H as Ue}from"./mui-CxHUbSMi.js";import{u as Y,a as R,b as H,c as Oe,d as qe,L as E,e as Me,O as Le,f as Re,r as N,g as B,h as z,q as ee,i as te,j as ne,Q as Be,k as ze,l as Ne,R as Qe,m as We}from"./tanstack-xmxrKlZO.js";import{c as Ke,r as f}from"./react-DXd9vB-a.js";import{i as U,B as He,a as Ve,b as _e,u as A,t as m}from"./i18n-DJgSTqOl.js";(function(){const n=document.createElement("link").relList;if(n&&n.supports&&n.supports("modulepreload"))return;for(const r of document.querySelectorAll('link[rel="modulepreload"]'))a(r);new MutationObserver(r=>{for(const i of r)if(i.type==="childList")for(const s of i.addedNodes)s.tagName==="LINK"&&s.rel==="modulepreload"&&a(s)}).observe(document,{childList:!0,subtree:!0});function o(r){const i={};return r.integrity&&(i.integrity=r.integrity),r.referrerPolicy&&(i.referrerPolicy=r.referrerPolicy),r.crossOrigin==="use-credentials"?i.credentials="include":r.crossOrigin==="anonymous"?i.credentials="omit":i.credentials="same-origin",i}function a(r){if(r.ep)return;r.ep=!0;const i=o(r);fetch(r.href,i)}})();var G={},ae=Ke;G.createRoot=ae.createRoot,G.hydrateRoot=ae.hydrateRoot;const _=15,S="https://khofmann.userpage.fu-berlin.de/phpCourse/exam/api/";let oe;class Ge{constructor(){if(this.hasAuth=()=>this.token!==void 0,this.isAdmin=()=>{var n;return this.hasAuth()&&((n=this.self)==null?void 0:n.isAdmin)},this.getAuthenticatedUser=()=>this.self,this.getCurrentSession=()=>[this.token,this.refreshToken],this.logIn=async(n,o)=>{const{user:a,token:r}=await(await this.post("login",{email:n,password:o})).json();this.self=a,this.token=r},this.logOut=async()=>{try{return await(await this.postAuth("logout")).json()}catch{return!1}finally{this.self=void 0,this.token=void 0}},this.posts=async n=>{const o=`posts?p=${n??0}&l=${_}`;return this.token?await(await this.getAuth(o)).json():await(await this.get(o)).json()},this.deletePost=async n=>await(await this.delete(`posts/${n}?l=${_}`)).json(),this.user=async n=>{var o;return await(await this.getAuth(`users/${n??((o=this.self)==null?void 0:o.id)}`)).json()},this.updateUser=async(n,o)=>{const a=await(await this.patch(`users/${o??"self"}`,n)).json();return this.self=a,a},this.updateUserImage=async(n,o)=>{const a=new FormData;n.image&&a.append("image",n.image),!n.image&&n.predefined&&a.append("predefined",n.predefined);const r=await(await this.postAuthRaw(`users/${o??"self"}/image`,a)).json();return this.self=r,r},this.newPost=async n=>await(await this.postAuth(`posts?l=${_}`,{...n})).json(),this.updatePost=async(n,o)=>await(await this.patch(`posts/${o}`,n)).json(),this.post=async(n,o,a)=>{const r=await fetch(`${S}${n}`,{mode:"cors",method:"post",headers:a,body:JSON.stringify(o)});if(r.ok)return r;throw await r.json()},this.postAuth=async(n,o,a)=>{const r=await fetch(`${S}${n}`,{mode:"cors",method:"post",headers:{token:this.token??"",...a},body:JSON.stringify(o)});if(r.ok)return r;throw await r.json()},this.postAuthRaw=async(n,o,a)=>{const r=await fetch(`${S}${n}`,{mode:"cors",method:"post",headers:{token:this.token??"",...a},body:o});if(r.ok)return r;throw await r.json()},this.get=async(n,o)=>{const a=await fetch(`${S}${n}`,{mode:"cors",method:"get",headers:o});if(a.ok)return a;throw await a.json()},this.getAuth=async(n,o)=>{const a=await fetch(`${S}${n}`,{mode:"cors",method:"get",headers:{token:this.token??"",...o}});if(a.ok)return a;throw await a.json()},this.delete=async(n,o)=>{const a=await fetch(`${S}${n}`,{mode:"cors",method:"delete",headers:{token:this.token??"",...o}});if(a.ok)return a;throw await a.json()},this.patch=async(n,o,a)=>{const r=await fetch(`${S}${n}`,{mode:"cors",method:"patch",headers:{token:this.token??"",...a},body:JSON.stringify(o)});if(r.ok)return r;throw await r.json()},oe)throw new Error("New instance cannot be created!!");oe=this}}const g=new Ge;var k=(t=>(t.NOT_FOUND="NotFound",t.UNAUTHORIZED="Unauthorized",t.FAILED_UPDATE="FailedUpdate",t.MISSING_FIELD="MissingField",t))(k||{});U.use(He).use(Ve).use(_e).init({fallbackLng:"en",debug:!1,interpolation:{escapeValue:!1},backend:{loadPath:"/phpCourse/exam/dist/locales/{{lng}}/{{ns}}.json"}});const Xe=({anchorEl:t,handleClose:n})=>e.jsxs(le,{anchorEl:t,anchorOrigin:{vertical:"bottom",horizontal:"right"},keepMounted:!0,transformOrigin:{vertical:"top",horizontal:"right"},open:!!t,onClose:n,sx:{"& .MuiMenu-paper":{minWidth:"240px"}},children:[e.jsx(q,{selected:U.language==="en",onClick:()=>{U.changeLanguage("en"),n()},children:"English"},"de"),e.jsx(q,{selected:U.language==="de",onClick:()=>{U.changeLanguage("de"),n()},children:"Deutsch"},"en")]});var b=(t=>(t.INDEX="/",t.PROFILE="/profile",t))(b||{});const I=({error:t,context:n,color:o="error.main"})=>{const{t:a}=A();if(consolLine truncated
+1 -1
View File
@@ -5,7 +5,7 @@
<link rel="icon" type="image/svg+xml" href="/phpCourse/exam/dist/vite.svg" /> <link rel="icon" type="image/svg+xml" href="/phpCourse/exam/dist/vite.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Vite + React + TS</title> <title>Vite + React + TS</title>
<script type="module" crossorigin src="/phpCourse/exam/dist/assets/index-CMO4zI4G.js"></script> <script type="module" crossorigin src="/phpCourse/exam/dist/assets/index-Bw9FCd3M.js"></script>
<link rel="modulepreload" crossorigin href="/phpCourse/exam/dist/assets/react-DXd9vB-a.js"> <link rel="modulepreload" crossorigin href="/phpCourse/exam/dist/assets/react-DXd9vB-a.js">
<link rel="modulepreload" crossorigin href="/phpCourse/exam/dist/assets/mui-CxHUbSMi.js"> <link rel="modulepreload" crossorigin href="/phpCourse/exam/dist/assets/mui-CxHUbSMi.js">
<link rel="modulepreload" crossorigin href="/phpCourse/exam/dist/assets/tanstack-xmxrKlZO.js"> <link rel="modulepreload" crossorigin href="/phpCourse/exam/dist/assets/tanstack-xmxrKlZO.js">
+1 -1
View File
@@ -4822,7 +4822,7 @@ var drawChart = (function (exports) {
</script> </script>
<script> <script>
/*<!--*/ /*<!--*/
const data = {"version":2,"tree":{"name":"root","children":[{"name":"assets/zustand-Cc7ZFYQr.js","children":[{"name":"\u0000/node_modules/.pnpm/use-sync-external-store@1.2.0_react@18.3.1/node_modules/use-sync-external-store","children":[{"name":"cjs","children":[{"uid":"94558adf-1","name":"use-sync-external-store-shim.production.min.js?commonjs-exports"},{"uid":"94558adf-5","name":"use-sync-external-store-shim.production.min.js?commonjs-proxy"},{"name":"use-sync-external-store-shim","children":[{"uid":"94558adf-13","name":"with-selector.production.min.js?commonjs-exports"},{"uid":"94558adf-17","name":"with-selector.production.min.js?commonjs-proxy"}]}]},{"name":"shim","children":[{"uid":"94558adf-7","name":"index.js?commonjs-module"},{"uid":"94558adf-11","name":"index.js?commonjs-proxy"},{"uid":"94558adf-19","name":"with-selector.js?commonjs-module"}]}]},{"name":"node_modules/.pnpm","children":[{"name":"use-sync-external-store@1.2.0_react@18.3.1/node_modules/use-sync-external-store","children":[{"name":"cjs","children":[{"uid":"94558adf-3","name":"use-sync-external-store-shim.production.min.js"},{"name":"use-sync-external-store-shim/with-selector.production.min.js","uid":"94558adf-15"}]},{"name":"shim","children":[{"uid":"94558adf-9","name":"index.js"},{"uid":"94558adf-21","name":"with-selector.js"}]}]},{"name":"zustand@4.5.4_@types+react@18.3.3_react@18.3.1/node_modules/zustand/esm","children":[{"uid":"94558adf-23","name":"vanilla.mjs"},{"uid":"94558adf-25","name":"index.mjs"}]}]}]},{"name":"assets/index-CMO4zI4G.js","children":[{"name":"\u0000vite/modulepreload-polyfill.js","uid":"94558adf-27"},{"name":"\u0000/node_modules/.pnpm/react-dom@18.3.1_react@18.3.1/node_modules/react-dom/client.js?commonjs-exports","uid":"94558adf-29"},{"name":"node_modules/.pnpm","children":[{"name":"react-dom@18.3.1_react@18.3.1/node_modules/react-dom/client.js","uid":"94558adf-31"},{"name":"@fontsource+roboto@5.0.13/node_modules/@fontsource/roboto","children":[{"uid":"94558adf-81","name":"300.css"},{"uid":"94558adf-83","name":"400.css"},{"uid":"94558adf-85","name":"500.css"},{"uid":"94558adf-87","name":"700.css"}]}]},{"name":"src","children":[{"uid":"94558adf-33","name":"constanst.ts"},{"name":"api/Api.ts","uid":"94558adf-35"},{"name":"components","children":[{"name":"Error","children":[{"uid":"94558adf-37","name":"Errors.ts"},{"uid":"94558adf-45","name":"ErrorComponent.tsx"}]},{"name":"Menus","children":[{"name":"Language/LanguageMenu.tsx","uid":"94558adf-41"},{"name":"User/UserMenu.tsx","uid":"94558adf-49"}]},{"name":"Forms","children":[{"name":"Login/LoginForm.tsx","uid":"94558adf-47"},{"name":"Post/PostForm.tsx","uid":"94558adf-55"}]},{"name":"Header/Header.tsx","uid":"94558adf-51"},{"name":"Dialogs","children":[{"name":"PostEdit/PostEditDialog.tsx","uid":"94558adf-59"},{"name":"UserEdit/UserEditDialog.tsx","uid":"94558adf-67"},{"name":"UserImage/UserImageDialog.tsx","uid":"94558adf-69"}]},{"name":"Post/Post.tsx","uid":"94558adf-61"},{"name":"Profile/Profile.tsx","uid":"94558adf-71"}]},{"uid":"94558adf-39","name":"i18n.ts"},{"name":"types/Routes.ts","uid":"94558adf-43"},{"name":"routes","children":[{"uid":"94558adf-53","name":"__root.tsx"},{"uid":"94558adf-65","name":"index.tsx"},{"name":"profile","children":[{"uid":"94558adf-75","name":"index.tsx"},{"uid":"94558adf-77","name":"$id.tsx"}]}]},{"name":"utils/date.ts","uid":"94558adf-57"},{"name":"queries","children":[{"uid":"94558adf-63","name":"postsQuery.ts"},{"uid":"94558adf-73","name":"profileQuery.ts"}]},{"uid":"94558adf-79","name":"routeTree.gen.ts"},{"uid":"94558adf-89","name":"main.tsx"}]},{"uid":"94558adf-91","name":"index.html"}]},{"name":"assets/i18n-DJgSTqOl.js","children":[{"name":"node_modules/.pnpm","children":[{"name":"void-elements@3.1.0/node_modules/void-elements/index.js","uid":"94558adf-93"},{"name":"html-parse-stringify@3.0.1/node_modules/html-parse-stringify/dist/html-parse-stringify.module.js","uid":"94558adf-95"},{"name":"react-i18next@15.0.0_i18next@23.12.2_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/react-i18next/dist/es","children":[{"uid":"94558adf-97","name":"utils.js"},{"uid":"94558adf-99","name":"unescape.js"},{"uid":"94558adf-101","name":"defaults.js"},{"uid":"94558adf-103","name":"i18nInstance.js"},{"uid":"94558adf-105","name":"TransWithoutContext.js"},{"uid":"94558adf-107","name":"initReactI18next.js"},{"uid":"94558adf-109","name":"context.js"},{"uid":"94558adf-111","name":"Trans.js"},{"uid":"94558adf-113","name":"useTranslation.js"},{"uid":"94558adf-115","name":"withTranslation.js"},{"uid":"94558adf-117","name":"Translation.js"},{"uid":"94558adf-119","name":"I18nextProvider.js"},{"uid":"94558adf-121","name":"useSSR.js"},{"uid":"94558adf-123","name":"withSSR.js"},{"uid":"94558adf-125","name":"index.js"}]},{"name":"i18next@23.12.2/node_modules/i18next/dist/esm/i18next.js","uid":"94558adf-127"},{"name":"i18next-browser-languagedetector@8.0.0/node_modules/i18next-browser-languagedetector/dist/esm/i18nextBrowserLanguageDetectoLine truncated const data = {"version":2,"tree":{"name":"root","children":[{"name":"assets/zustand-Cc7ZFYQr.js","children":[{"name":"\u0000/node_modules/.pnpm/use-sync-external-store@1.2.0_react@18.3.1/node_modules/use-sync-external-store","children":[{"name":"cjs","children":[{"uid":"4f95c39c-1","name":"use-sync-external-store-shim.production.min.js?commonjs-exports"},{"uid":"4f95c39c-5","name":"use-sync-external-store-shim.production.min.js?commonjs-proxy"},{"name":"use-sync-external-store-shim","children":[{"uid":"4f95c39c-13","name":"with-selector.production.min.js?commonjs-exports"},{"uid":"4f95c39c-17","name":"with-selector.production.min.js?commonjs-proxy"}]}]},{"name":"shim","children":[{"uid":"4f95c39c-7","name":"index.js?commonjs-module"},{"uid":"4f95c39c-11","name":"index.js?commonjs-proxy"},{"uid":"4f95c39c-19","name":"with-selector.js?commonjs-module"}]}]},{"name":"node_modules/.pnpm","children":[{"name":"use-sync-external-store@1.2.0_react@18.3.1/node_modules/use-sync-external-store","children":[{"name":"cjs","children":[{"uid":"4f95c39c-3","name":"use-sync-external-store-shim.production.min.js"},{"name":"use-sync-external-store-shim/with-selector.production.min.js","uid":"4f95c39c-15"}]},{"name":"shim","children":[{"uid":"4f95c39c-9","name":"index.js"},{"uid":"4f95c39c-21","name":"with-selector.js"}]}]},{"name":"zustand@4.5.4_@types+react@18.3.3_react@18.3.1/node_modules/zustand/esm","children":[{"uid":"4f95c39c-23","name":"vanilla.mjs"},{"uid":"4f95c39c-25","name":"index.mjs"}]}]}]},{"name":"assets/index-Bw9FCd3M.js","children":[{"name":"\u0000vite/modulepreload-polyfill.js","uid":"4f95c39c-27"},{"name":"\u0000/node_modules/.pnpm/react-dom@18.3.1_react@18.3.1/node_modules/react-dom/client.js?commonjs-exports","uid":"4f95c39c-29"},{"name":"node_modules/.pnpm","children":[{"name":"react-dom@18.3.1_react@18.3.1/node_modules/react-dom/client.js","uid":"4f95c39c-31"},{"name":"@fontsource+roboto@5.0.13/node_modules/@fontsource/roboto","children":[{"uid":"4f95c39c-81","name":"300.css"},{"uid":"4f95c39c-83","name":"400.css"},{"uid":"4f95c39c-85","name":"500.css"},{"uid":"4f95c39c-87","name":"700.css"}]}]},{"name":"src","children":[{"uid":"4f95c39c-33","name":"constanst.ts"},{"name":"api/Api.ts","uid":"4f95c39c-35"},{"name":"components","children":[{"name":"Error","children":[{"uid":"4f95c39c-37","name":"Errors.ts"},{"uid":"4f95c39c-45","name":"ErrorComponent.tsx"}]},{"name":"Menus","children":[{"name":"Language/LanguageMenu.tsx","uid":"4f95c39c-41"},{"name":"User/UserMenu.tsx","uid":"4f95c39c-49"}]},{"name":"Forms","children":[{"name":"Login/LoginForm.tsx","uid":"4f95c39c-47"},{"name":"Post/PostForm.tsx","uid":"4f95c39c-55"}]},{"name":"Header/Header.tsx","uid":"4f95c39c-51"},{"name":"Dialogs","children":[{"name":"PostEdit/PostEditDialog.tsx","uid":"4f95c39c-59"},{"name":"UserEdit/UserEditDialog.tsx","uid":"4f95c39c-67"},{"name":"UserImage/UserImageDialog.tsx","uid":"4f95c39c-69"}]},{"name":"Post/Post.tsx","uid":"4f95c39c-61"},{"name":"Profile/Profile.tsx","uid":"4f95c39c-71"}]},{"uid":"4f95c39c-39","name":"i18n.ts"},{"name":"types/Routes.ts","uid":"4f95c39c-43"},{"name":"routes","children":[{"uid":"4f95c39c-53","name":"__root.tsx"},{"uid":"4f95c39c-65","name":"index.tsx"},{"name":"profile","children":[{"uid":"4f95c39c-75","name":"index.tsx"},{"uid":"4f95c39c-77","name":"$id.tsx"}]}]},{"name":"utils/date.ts","uid":"4f95c39c-57"},{"name":"queries","children":[{"uid":"4f95c39c-63","name":"postsQuery.ts"},{"uid":"4f95c39c-73","name":"profileQuery.ts"}]},{"uid":"4f95c39c-79","name":"routeTree.gen.ts"},{"uid":"4f95c39c-89","name":"main.tsx"}]},{"uid":"4f95c39c-91","name":"index.html"}]},{"name":"assets/i18n-DJgSTqOl.js","children":[{"name":"node_modules/.pnpm","children":[{"name":"void-elements@3.1.0/node_modules/void-elements/index.js","uid":"4f95c39c-93"},{"name":"html-parse-stringify@3.0.1/node_modules/html-parse-stringify/dist/html-parse-stringify.module.js","uid":"4f95c39c-95"},{"name":"react-i18next@15.0.0_i18next@23.12.2_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/react-i18next/dist/es","children":[{"uid":"4f95c39c-97","name":"utils.js"},{"uid":"4f95c39c-99","name":"unescape.js"},{"uid":"4f95c39c-101","name":"defaults.js"},{"uid":"4f95c39c-103","name":"i18nInstance.js"},{"uid":"4f95c39c-105","name":"TransWithoutContext.js"},{"uid":"4f95c39c-107","name":"initReactI18next.js"},{"uid":"4f95c39c-109","name":"context.js"},{"uid":"4f95c39c-111","name":"Trans.js"},{"uid":"4f95c39c-113","name":"useTranslation.js"},{"uid":"4f95c39c-115","name":"withTranslation.js"},{"uid":"4f95c39c-117","name":"Translation.js"},{"uid":"4f95c39c-119","name":"I18nextProvider.js"},{"uid":"4f95c39c-121","name":"useSSR.js"},{"uid":"4f95c39c-123","name":"withSSR.js"},{"uid":"4f95c39c-125","name":"index.js"}]},{"name":"i18next@23.12.2/node_modules/i18next/dist/esm/i18next.js","uid":"4f95c39c-127"},{"name":"i18next-browser-languagedetector@8.0.0/node_modules/i18next-browser-languagedetector/dist/esm/i18nextBrowserLanguageDetectoLine truncated
const run = () => { const run = () => {
const width = window.innerWidth; const width = window.innerWidth;
+13
View File
@@ -10,6 +10,7 @@ class ApiImpl {
private token?: string; private token?: string;
private refreshToken?: string; private refreshToken?: string;
private self?: User; private self?: User;
private userListeners: ((user?: User) => void)[] = [];
constructor() { constructor() {
if (instance) { if (instance) {
@@ -26,10 +27,19 @@ class ApiImpl {
public getAuthenticatedUser = () => this.self; public getAuthenticatedUser = () => this.self;
public getCurrentSession = () => [this.token, this.refreshToken]; public getCurrentSession = () => [this.token, this.refreshToken];
public subscribeToAuthenticatedUser = (callback: (user?: User) => void) => {
this.userListeners.push(callback);
return () => {
this.userListeners = this.userListeners.filter((item) => item !== callback);
};
};
public logIn = async (email: string, password: string): Promise<void> => { public logIn = async (email: string, password: string): Promise<void> => {
const { user, token } = await (await this.post('login', { email, password })).json(); const { user, token } = await (await this.post('login', { email, password })).json();
this.self = user; this.self = user;
this.token = token; this.token = token;
this.userListeners.forEach((listener) => listener(user));
}; };
public logOut = async (): Promise<boolean> => { public logOut = async (): Promise<boolean> => {
@@ -40,6 +50,7 @@ class ApiImpl {
} finally { } finally {
this.self = undefined; this.self = undefined;
this.token = undefined; this.token = undefined;
this.userListeners.forEach((listener) => listener());
} }
}; };
@@ -62,6 +73,7 @@ class ApiImpl {
public updateUser = async (data: UserUpdate, id?: number): Promise<User> => { public updateUser = async (data: UserUpdate, id?: number): Promise<User> => {
const user = await (await this.patch(`users/${id ?? 'self'}`, data as Record<string, unknown>)).json(); const user = await (await this.patch(`users/${id ?? 'self'}`, data as Record<string, unknown>)).json();
this.self = user; this.self = user;
this.userListeners.forEach((listener) => listener(user));
return user; return user;
}; };
@@ -72,6 +84,7 @@ class ApiImpl {
const user = await (await this.postAuthRaw(`users/${id ?? 'self'}/image`, formData)).json(); const user = await (await this.postAuthRaw(`users/${id ?? 'self'}/image`, formData)).json();
this.self = user; this.self = user;
this.userListeners.forEach((listener) => listener(user));
return user; return user;
}; };
@@ -168,14 +168,18 @@ const UserImageDialog: FC<Props> = ({ user, open, onClose }) => {
<InputLabel size="small">{t('Predefined')}</InputLabel> <InputLabel size="small">{t('Predefined')}</InputLabel>
<Select <Select
name={field.name} name={field.name}
value={field.state.value} value={field.state.value ?? ''}
onBlur={field.handleBlur} onBlur={field.handleBlur}
onChange={(e) => field.handleChange(e.target.value)} onChange={(e) => field.handleChange(e.target.value)}
size="small" size="small"
label={t('Predefined')} label={t('Predefined')}
autoComplete="off" autoComplete="off"
fullWidth fullWidth
//renderValue={(selected) => selected ?? 'Keine Auswahl'}
> >
<MenuItem value="" selected>
Keine Auswahl
</MenuItem>
{[...Array(10).keys()].map((i) => ( {[...Array(10).keys()].map((i) => (
<MenuItem key={`avatar-${i + 1}`} value={`avatar-${i + 1}`}> <MenuItem key={`avatar-${i + 1}`} value={`avatar-${i + 1}`}>
{t('Avatar', { name: i + 1 })} {t('Avatar', { name: i + 1 })}
+20 -15
View File
@@ -10,9 +10,10 @@ import {
useScrollTrigger, useScrollTrigger,
} from '@mui/material'; } from '@mui/material';
import { Link, useRouterState } from '@tanstack/react-router'; import { Link, useRouterState } from '@tanstack/react-router';
import { cloneElement, FC, ReactElement, useState } from 'react'; import { cloneElement, FC, ReactElement, useEffect, useState } from 'react';
import { useTranslation } from 'react-i18next'; import { useTranslation } from 'react-i18next';
import Api from '../../api/Api'; import Api from '../../api/Api';
import { User } from '../../types/User';
import LanguageMenu from '../Menus/Language/LanguageMenu'; import LanguageMenu from '../Menus/Language/LanguageMenu';
import UserMenu from '../Menus/User/UserMenu'; import UserMenu from '../Menus/User/UserMenu';
@@ -30,11 +31,12 @@ const ElevationScroll = ({ children }: { children: ReactElement }) => {
const Header: FC = () => { const Header: FC = () => {
const [anchorUserMenu, setAnchorUserMenu] = useState<null | HTMLElement>(null); const [anchorUserMenu, setAnchorUserMenu] = useState<null | HTMLElement>(null);
const [anchorLanguageMenu, setAnchorLanguageMenu] = useState<null | HTMLElement>(null); const [anchorLanguageMenu, setAnchorLanguageMenu] = useState<null | HTMLElement>(null);
const [user, setUser] = useState<User>();
const { t } = useTranslation(); const { t } = useTranslation();
const isLoading = useRouterState({ select: (s) => s.status === 'pending' }); const isLoading = useRouterState({ select: (s) => s.status === 'pending' });
const user = Api.getAuthenticatedUser(); useEffect(() => Api.subscribeToAuthenticatedUser((user) => setUser(user)), []);
const handleClose = () => { const handleClose = () => {
setAnchorLanguageMenu(null); setAnchorLanguageMenu(null);
@@ -52,20 +54,23 @@ const Header: FC = () => {
</MUILink> </MUILink>
{isLoading && <CircularProgress size={16} thickness={10} sx={{ color: 'white' }} />} {isLoading && <CircularProgress size={16} thickness={10} sx={{ color: 'white' }} />}
</Box> </Box>
<IconButton size="large" onClick={(event) => setAnchorLanguageMenu(event.currentTarget)}>
<Translate sx={{ color: 'white' }} /> <Box sx={{ display: 'flex', gap: 1 }}>
</IconButton> <IconButton size="large" onClick={(event) => setAnchorLanguageMenu(event.currentTarget)}>
{user ? ( <Translate sx={{ color: 'white' }} />
<IconButton onClick={(event) => setAnchorUserMenu(event.currentTarget)} sx={{ p: 0 }}>
<Avatar alt={user.username} src={`storage/${user.image}`}>
<Person />
</Avatar>
</IconButton> </IconButton>
) : ( {user ? (
<IconButton size="large" onClick={(event) => setAnchorUserMenu(event.currentTarget)} color="inherit"> <IconButton onClick={(event) => setAnchorUserMenu(event.currentTarget)} sx={{ p: 0 }}>
<AccountCircle /> <Avatar alt={user.username} src={`storage/${user.image}`}>
</IconButton> <Person />
)} </Avatar>
</IconButton>
) : (
<IconButton size="large" onClick={(event) => setAnchorUserMenu(event.currentTarget)} color="inherit">
<AccountCircle />
</IconButton>
)}
</Box>
<LanguageMenu anchorEl={anchorLanguageMenu} handleClose={handleClose} /> <LanguageMenu anchorEl={anchorLanguageMenu} handleClose={handleClose} />
<UserMenu anchorEl={anchorUserMenu} handleClose={handleClose} /> <UserMenu anchorEl={anchorUserMenu} handleClose={handleClose} />
</Toolbar> </Toolbar>