Recent posts
This commit is contained in:
1 parent
a950f6770a
commit
2c9f8caff4
11 files changed
+55
-20
No files matched your search
Vendored
+1
@@ -0,0 +1 @@
|
||||
import{j as e,M as ce,a as $,T as v,B as w,b as S,c as C,A as we,d as ae,L,C as B,I as q,e as Pe,f as T,P as I,g as Se,u as Fe,h as ue,i as ee,k as te,D as K,l as _,m as F,n as H,o as de,p as Ee,q as he,r as me,s as Ae,S as M,t as ke,G as y,v as se,w as De,x as Te,y as Ie,z as $e,F as Ue,E as Le,H as Oe}from"./mui-CxHUbSMi.js";import{u as ne,a as Q,b as V,c as qe,d as Me,L as k,e as Re,O as Be,f as Qe,r as W,g as z,h as N,q as G,i as re,j as R,Q as ze,k as Ne,l as We,R as Ke,m as _e}from"./tanstack-xmxrKlZO.js";import{c as He,r as j}from"./react-DXd9vB-a.js";import{i as O,B as Ve,a as Ge,b as Xe,u as E,t as p}from"./i18n-DJgSTqOl.js";(function(){const s=document.createElement("link").relList;if(s&&s.supports&&s.supports("modulepreload"))return;for(const n of document.querySelectorAll('link[rel="modulepreload"]'))r(n);new MutationObserver(n=>{for(const i of n)if(i.type==="childList")for(const a of i.addedNodes)a.tagName==="LINK"&&a.rel==="modulepreload"&&r(a)}).observe(document,{childList:!0,subtree:!0});function o(n){const i={};return n.integrity&&(i.integrity=n.integrity),n.referrerPolicy&&(i.referrerPolicy=n.referrerPolicy),n.crossOrigin==="use-credentials"?i.credentials="include":n.crossOrigin==="anonymous"?i.credentials="omit":i.credentials="same-origin",i}function r(n){if(n.ep)return;n.ep=!0;const i=o(n);fetch(n.href,i)}})();var Y={},oe=He;Y.createRoot=oe.createRoot,Y.hydrateRoot=oe.hydrateRoot;const J=15,Ze=3,P="https://khofmann.userpage.fu-berlin.de/phpCourse/exam/api/";let ie;class Je{constructor(){if(this.userListeners=[],this.hasAuth=()=>this.token!==void 0,this.isAdmin=()=>{var s;return this.hasAuth()&&((s=this.self)==null?void 0:s.isAdmin)},this.getAuthenticatedUser=()=>this.self,this.getCurrentSession=()=>[this.token,this.refreshToken],this.subscribeToAuthenticatedUser=s=>(this.userListeners.push(s),()=>{this.userListeners=this.userListeners.filter(o=>o!==s)}),this.logIn=async(s,o)=>{const{user:r,token:n}=await(await this.post("login",{email:s,password:o})).json();this.self=r,this.token=n,this.userListeners.forEach(i=>i(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.userListeners.forEach(s=>s())}},this.posts=async s=>{const o=`posts?p=${s??0}&l=${J}`;return this.token?await(await this.getAuth(o)).json():await(await this.get(o)).json()},this.deletePost=async s=>await(await this.delete(`posts/${s}?l=${J}`)).json(),this.user=async s=>{var o;return await(await this.getAuth(`users/${s??((o=this.self)==null?void 0:o.id)}`)).json()},this.updateUser=async(s,o)=>{const r=await(await this.patch(`users/${o??"self"}`,s)).json();return this.self=r,this.userListeners.forEach(n=>n(r)),r},this.updateUserImage=async(s,o)=>{const r=new FormData;s.image&&r.append("image",s.image),!s.image&&s.predefined&&r.append("predefined",s.predefined);const n=await(await this.postAuthRaw(`users/${o??"self"}/image`,r)).json();return this.self=n,this.userListeners.forEach(i=>i(n)),n},this.newPost=async s=>await(await this.postAuth(`posts?l=${J}`,{...s})).json(),this.updatePost=async(s,o)=>await(await this.patch(`posts/${o}`,s)).json(),this.userPosts=async s=>await(await this.getAuth(`users/${s}/posts?l=${Ze}&s=desc`)).json(),this.post=async(s,o,r)=>{const n=await fetch(`${P}${s}`,{mode:"cors",method:"post",headers:r,body:JSON.stringify(o)});if(n.ok)return n;throw await n.json()},this.postAuth=async(s,o,r)=>{const n=await fetch(`${P}${s}`,{mode:"cors",method:"post",headers:{token:this.token??"",...r},body:JSON.stringify(o)});if(n.ok)return n;throw await n.json()},this.postAuthRaw=async(s,o,r)=>{const n=await fetch(`${P}${s}`,{mode:"cors",method:"post",headers:{token:this.token??"",...r},body:o});if(n.ok)return n;throw await n.json()},this.get=async(s,o)=>{const r=await fetch(`${P}${s}`,{mode:"cors",method:"get",headers:o});if(r.ok)return r;throw await r.json()},this.getAuth=async(s,o)=>{const r=await fetch(`${P}${s}`,{mode:"cors",method:"get",headers:{token:this.token??"",...o}});if(r.ok)return r;throw await r.json()},this.delete=async(s,o)=>{const r=await fetch(`${P}${s}`,{mode:"cors",method:"delete",headers:{token:this.token??"",...o}});if(r.ok)return r;throw await r.json()},this.patch=async(s,o,r)=>{const n=await fetch(`${P}${s}`,{mode:"cors",method:"patch",headers:{token:this.token??"",...r},body:JSON.stringify(o)});if(n.ok)return n;throw await n.json()},ie)throw new Error("New instance cannot be created!!");ie=this}}const h=new Je;var D=(t=>(t.NOT_FOUND="NotFound",t.UNAUTHORIZED="Unauthorized",t.FAILED_UPDATE="FailedUpdate",t.MISSING_FIELD="MissingField",t))(D||{});O.use(Ve).use(Ge).use(Xe).init({fallbackLng:"en",debug:!1,interpolation:{escapeValue:!1},backend:{loadPath:"/phpCourse/exam/dist/locales/{{lng}}/{{ns}}.json"}});const Ye=({anchorEl:t,handleClose:s})=>e.jsxs(ce,{anchorEl:t,anchorOrigin:{vertical:"bottom",horizontal:"right"},keepMounted:!0,transformOrigin:{vertical:"top",horizontal:"right"},open:!!t,onClose:s,sx:{"& .Line truncated
|
||||
Vendored
-1
@@ -1 +0,0 @@
|
||||
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
|
||||
Vendored
+1
-1
@@ -5,7 +5,7 @@
|
||||
<link rel="icon" type="image/svg+xml" href="/phpCourse/exam/dist/vite.svg" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>Vite + React + TS</title>
|
||||
<script type="module" crossorigin src="/phpCourse/exam/dist/assets/index-Bw9FCd3M.js"></script>
|
||||
<script type="module" crossorigin src="/phpCourse/exam/dist/assets/index-B1n77CT9.js"></script>
|
||||
<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/tanstack-xmxrKlZO.js">
|
||||
|
||||
Vendored
+1
-1
@@ -4822,7 +4822,7 @@ var drawChart = (function (exports) {
|
||||
</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":"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 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":"67e95226-1","name":"use-sync-external-store-shim.production.min.js?commonjs-exports"},{"uid":"67e95226-5","name":"use-sync-external-store-shim.production.min.js?commonjs-proxy"},{"name":"use-sync-external-store-shim","children":[{"uid":"67e95226-13","name":"with-selector.production.min.js?commonjs-exports"},{"uid":"67e95226-17","name":"with-selector.production.min.js?commonjs-proxy"}]}]},{"name":"shim","children":[{"uid":"67e95226-7","name":"index.js?commonjs-module"},{"uid":"67e95226-11","name":"index.js?commonjs-proxy"},{"uid":"67e95226-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":"67e95226-3","name":"use-sync-external-store-shim.production.min.js"},{"name":"use-sync-external-store-shim/with-selector.production.min.js","uid":"67e95226-15"}]},{"name":"shim","children":[{"uid":"67e95226-9","name":"index.js"},{"uid":"67e95226-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":"67e95226-23","name":"vanilla.mjs"},{"uid":"67e95226-25","name":"index.mjs"}]}]}]},{"name":"assets/index-B1n77CT9.js","children":[{"name":"\u0000vite/modulepreload-polyfill.js","uid":"67e95226-27"},{"name":"\u0000/node_modules/.pnpm/react-dom@18.3.1_react@18.3.1/node_modules/react-dom/client.js?commonjs-exports","uid":"67e95226-29"},{"name":"node_modules/.pnpm","children":[{"name":"react-dom@18.3.1_react@18.3.1/node_modules/react-dom/client.js","uid":"67e95226-31"},{"name":"@fontsource+roboto@5.0.13/node_modules/@fontsource/roboto","children":[{"uid":"67e95226-81","name":"300.css"},{"uid":"67e95226-83","name":"400.css"},{"uid":"67e95226-85","name":"500.css"},{"uid":"67e95226-87","name":"700.css"}]}]},{"name":"src","children":[{"uid":"67e95226-33","name":"constanst.ts"},{"name":"api/Api.ts","uid":"67e95226-35"},{"name":"components","children":[{"name":"Error","children":[{"uid":"67e95226-37","name":"Errors.ts"},{"uid":"67e95226-45","name":"ErrorComponent.tsx"}]},{"name":"Menus","children":[{"name":"Language/LanguageMenu.tsx","uid":"67e95226-41"},{"name":"User/UserMenu.tsx","uid":"67e95226-49"}]},{"name":"Forms","children":[{"name":"Login/LoginForm.tsx","uid":"67e95226-47"},{"name":"Post/PostForm.tsx","uid":"67e95226-55"}]},{"name":"Header/Header.tsx","uid":"67e95226-51"},{"name":"Dialogs","children":[{"name":"PostEdit/PostEditDialog.tsx","uid":"67e95226-59"},{"name":"UserEdit/UserEditDialog.tsx","uid":"67e95226-67"},{"name":"UserImage/UserImageDialog.tsx","uid":"67e95226-69"}]},{"name":"Post/Post.tsx","uid":"67e95226-61"},{"name":"Profile/Profile.tsx","uid":"67e95226-71"}]},{"uid":"67e95226-39","name":"i18n.ts"},{"name":"types/Routes.ts","uid":"67e95226-43"},{"name":"routes","children":[{"uid":"67e95226-53","name":"__root.tsx"},{"uid":"67e95226-65","name":"index.tsx"},{"name":"profile","children":[{"uid":"67e95226-75","name":"index.tsx"},{"uid":"67e95226-77","name":"$id.tsx"}]}]},{"name":"utils/date.ts","uid":"67e95226-57"},{"name":"queries","children":[{"uid":"67e95226-63","name":"postsQuery.ts"},{"uid":"67e95226-73","name":"profileQuery.ts"}]},{"uid":"67e95226-79","name":"routeTree.gen.ts"},{"uid":"67e95226-89","name":"main.tsx"}]},{"uid":"67e95226-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":"67e95226-93"},{"name":"html-parse-stringify@3.0.1/node_modules/html-parse-stringify/dist/html-parse-stringify.module.js","uid":"67e95226-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":"67e95226-97","name":"utils.js"},{"uid":"67e95226-99","name":"unescape.js"},{"uid":"67e95226-101","name":"defaults.js"},{"uid":"67e95226-103","name":"i18nInstance.js"},{"uid":"67e95226-105","name":"TransWithoutContext.js"},{"uid":"67e95226-107","name":"initReactI18next.js"},{"uid":"67e95226-109","name":"context.js"},{"uid":"67e95226-111","name":"Trans.js"},{"uid":"67e95226-113","name":"useTranslation.js"},{"uid":"67e95226-115","name":"withTranslation.js"},{"uid":"67e95226-117","name":"Translation.js"},{"uid":"67e95226-119","name":"I18nextProvider.js"},{"uid":"67e95226-121","name":"useSSR.js"},{"uid":"67e95226-123","name":"withSSR.js"},{"uid":"67e95226-125","name":"index.js"}]},{"name":"i18next@23.12.2/node_modules/i18next/dist/esm/i18next.js","uid":"67e95226-127"},{"name":"i18next-browser-languagedetector@8.0.0/node_modules/i18next-browser-languagedetector/dist/esm/i18nextBrowserLanguageDetectoLine truncated
|
||||
|
||||
const run = () => {
|
||||
const width = window.innerWidth;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { POST_LIMIT } from '../constanst';
|
||||
import { POST_LIMIT, PROFILE_POST_LIMIT } from '../constanst';
|
||||
import { PostAuth, PostDelete, PostListAuth, PostListNonAuth, PostNew, PostUpdate } from '../types/Post';
|
||||
import { User, UserImageUpdate, UserUpdate } from '../types/User';
|
||||
|
||||
@@ -96,6 +96,10 @@ class ApiImpl {
|
||||
return await (await this.patch(`posts/${id}`, data as Record<string, unknown>)).json();
|
||||
};
|
||||
|
||||
public userPosts = async (id?: number): Promise<PostListAuth> => {
|
||||
return await (await this.getAuth(`users/${id}/posts?l=${PROFILE_POST_LIMIT}&s=desc`)).json();
|
||||
};
|
||||
|
||||
/* Internal */
|
||||
|
||||
private post = async (endpoint: string, body?: Record<string, unknown>, headers?: HeadersInit) => {
|
||||
|
||||
@@ -28,9 +28,10 @@ import ErrorComponent from '../Error/ErrorComponent';
|
||||
|
||||
interface Props {
|
||||
post: PostNonAuth | PostAuth;
|
||||
disableActions?: boolean;
|
||||
}
|
||||
|
||||
const Post: FC<Props> = ({ post }) => {
|
||||
const Post: FC<Props> = ({ post, disableActions }) => {
|
||||
const [deleteOpen, setDeleteOpen] = useState(false);
|
||||
const [editOpen, setEditOpen] = useState(false);
|
||||
//eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
@@ -50,7 +51,7 @@ const Post: FC<Props> = ({ post }) => {
|
||||
<Card>
|
||||
<CardHeader
|
||||
avatar={
|
||||
'id' in post.user ? (
|
||||
!disableActions && 'id' in post.user ? (
|
||||
post.user.id !== Api.getAuthenticatedUser()?.id ? (
|
||||
<MUILink component={Link} to="/profile/$id" params={{ id: post.user.id }}>
|
||||
<Avatar alt={post.user.username} src={`storage/${post.user.image}`}>
|
||||
@@ -71,7 +72,7 @@ const Post: FC<Props> = ({ post }) => {
|
||||
)
|
||||
}
|
||||
title={
|
||||
'id' in post.user ? (
|
||||
!disableActions && 'id' in post.user ? (
|
||||
post.user.id !== Api.getAuthenticatedUser()?.id ? (
|
||||
<MUILink component={Link} to="/profile/$id" params={{ id: post.user.id }}>
|
||||
{post.user.username}
|
||||
@@ -94,7 +95,8 @@ const Post: FC<Props> = ({ post }) => {
|
||||
</CardContent>
|
||||
|
||||
<CardActions>
|
||||
{(Api.isAdmin() || ('id' in post.user && post.user.id === Api.getAuthenticatedUser()?.id)) && (
|
||||
{!disableActions &&
|
||||
(Api.isAdmin() || ('id' in post.user && post.user.id === Api.getAuthenticatedUser()?.id)) && (
|
||||
<>
|
||||
<Button size="small" onClick={() => setEditOpen(true)}>
|
||||
{t('Edit')}
|
||||
@@ -102,7 +104,7 @@ const Post: FC<Props> = ({ post }) => {
|
||||
<PostEditDialog post={post as PostAuth} open={editOpen} onClose={() => setEditOpen(false)} />
|
||||
</>
|
||||
)}
|
||||
{Api.isAdmin() && (
|
||||
{!disableActions && Api.isAdmin() && (
|
||||
<>
|
||||
<Button size="small" color="error" onClick={() => setDeleteOpen(true)}>
|
||||
{t('Delete')}
|
||||
|
||||
@@ -13,17 +13,20 @@ import {
|
||||
} from '@mui/material';
|
||||
import { FC, useState } from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { PostAuth } from '../../types/Post';
|
||||
import { User } from '../../types/User';
|
||||
import convertDate from '../../utils/date';
|
||||
import UserEditDialog from '../Dialogs/UserEdit/UserEditDialog';
|
||||
import UserImageDialog from '../Dialogs/UserImage/UserImageDialog';
|
||||
import Post from '../Post/Post';
|
||||
|
||||
interface Props {
|
||||
user: User;
|
||||
posts: PostAuth[];
|
||||
canEdit?: boolean;
|
||||
}
|
||||
|
||||
const Profile: FC<Props> = ({ user, canEdit }) => {
|
||||
const Profile: FC<Props> = ({ user, posts, canEdit }) => {
|
||||
const [editOpen, setEditOpen] = useState(false);
|
||||
const [imageOpen, setImageOpen] = useState(false);
|
||||
|
||||
@@ -74,6 +77,11 @@ const Profile: FC<Props> = ({ user, canEdit }) => {
|
||||
<Typography sx={{ opacity: 0.36 }}>{t('Recent posts')}</Typography>
|
||||
</Divider>
|
||||
</Grid>
|
||||
{posts.map((post) => (
|
||||
<Grid item xs={12}>
|
||||
<Post post={post} disableActions />
|
||||
</Grid>
|
||||
))}
|
||||
</Grid>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -1 +1,3 @@
|
||||
export const POST_LIMIT = 15;
|
||||
export const PROFILE_POST_LIMIT = 3;
|
||||
export const POST_CHAR_LIMIT = 250;
|
||||
@@ -11,3 +11,9 @@ export const profileQueryOptions = (id?: number) =>
|
||||
queryKey: ['profile', { id }],
|
||||
queryFn: () => Api.user(id),
|
||||
});
|
||||
|
||||
export const profilePostsQueryOptions = (id: number) =>
|
||||
queryOptions({
|
||||
queryKey: ['profilePosts', { id }],
|
||||
queryFn: () => Api.userPosts(id),
|
||||
});
|
||||
@@ -4,17 +4,19 @@ import { createFileRoute, redirect } from '@tanstack/react-router';
|
||||
import { t } from 'i18next';
|
||||
import Api from '../../api/Api';
|
||||
import Profile from '../../components/Profile/Profile';
|
||||
import { profileQueryOptions } from '../../queries/profileQuery';
|
||||
import { profilePostsQueryOptions, profileQueryOptions } from '../../queries/profileQuery';
|
||||
import { PostAuth } from '../../types/Post';
|
||||
import { ROUTES } from '../../types/Routes';
|
||||
|
||||
const ProfilePage = () => {
|
||||
const { id } = Route.useParams();
|
||||
const { data: profileQuery, isFetching } = useSuspenseQuery(profileQueryOptions(id));
|
||||
const { data: profileQuery, isFetching: isFetchingProfile } = useSuspenseQuery(profileQueryOptions(id));
|
||||
const { data: profilePostsQuery, isFetching: isFetchingPosts } = useSuspenseQuery(profilePostsQueryOptions(id));
|
||||
|
||||
return (
|
||||
<>
|
||||
<Snackbar open={isFetching} message={t('Updating')} />
|
||||
<Profile user={profileQuery} canEdit={Api.isAdmin()} />
|
||||
<Snackbar open={isFetchingProfile || isFetchingPosts} message={t('Updating')} />
|
||||
<Profile user={profileQuery} posts={profilePostsQuery.data as PostAuth[]} canEdit={Api.isAdmin()} />
|
||||
</>
|
||||
);
|
||||
};
|
||||
@@ -24,7 +26,10 @@ export const Route = createFileRoute(`${ROUTES.PROFILE}/$id`)({
|
||||
parse: ({ id }) => ({ id: parseInt(id) }),
|
||||
stringify: ({ id }) => ({ id: id.toString() }),
|
||||
},
|
||||
loader: ({ context: { queryClient }, params: { id } }) => queryClient.ensureQueryData(profileQueryOptions(id)),
|
||||
loader: ({ context: { queryClient }, params: { id } }) => {
|
||||
queryClient.ensureQueryData(profileQueryOptions(id));
|
||||
queryClient.ensureQueryData(profilePostsQueryOptions(id));
|
||||
},
|
||||
beforeLoad: ({ params: { id } }) => {
|
||||
if (!Api.hasAuth()) throw redirect({ to: ROUTES.INDEX });
|
||||
if (id === Api.getAuthenticatedUser()?.id) throw redirect({ to: ROUTES.PROFILE });
|
||||
|
||||
@@ -4,22 +4,30 @@ import { createFileRoute, redirect } from '@tanstack/react-router';
|
||||
import { t } from 'i18next';
|
||||
import Api from '../../api/Api';
|
||||
import Profile from '../../components/Profile/Profile';
|
||||
import { profileSelfQueryOptions } from '../../queries/profileQuery';
|
||||
import { profilePostsQueryOptions, profileSelfQueryOptions } from '../../queries/profileQuery';
|
||||
import { PostAuth } from '../../types/Post';
|
||||
import { ROUTES } from '../../types/Routes';
|
||||
|
||||
const ProfilePage = () => {
|
||||
const { data: profileQuery, isFetching } = useSuspenseQuery(profileSelfQueryOptions);
|
||||
const { data: profileQuery, isFetching: isFetchingProfile } = useSuspenseQuery(profileSelfQueryOptions);
|
||||
const { data: profilePostsQuery, isFetching: isFetchingPosts } = useSuspenseQuery(
|
||||
profilePostsQueryOptions(Api.getAuthenticatedUser()?.id ?? 0)
|
||||
);
|
||||
console.log(profilePostsQuery.data);
|
||||
|
||||
return (
|
||||
<>
|
||||
<Snackbar open={isFetching} message={t('Updating')} />
|
||||
<Profile user={profileQuery} canEdit={true} />
|
||||
<Snackbar open={isFetchingProfile || isFetchingPosts} message={t('Updating')} />
|
||||
<Profile user={profileQuery} posts={profilePostsQuery.data as PostAuth[]} canEdit={true} />
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
export const Route = createFileRoute(`${ROUTES.PROFILE}/`)({
|
||||
loader: ({ context: { queryClient } }) => queryClient.ensureQueryData(profileSelfQueryOptions),
|
||||
loader: ({ context: { queryClient } }) => {
|
||||
queryClient.ensureQueryData(profileSelfQueryOptions);
|
||||
queryClient.ensureQueryData(profilePostsQueryOptions(Api.getAuthenticatedUser()?.id ?? 0));
|
||||
},
|
||||
beforeLoad: () => {
|
||||
if (!Api.hasAuth()) throw redirect({ to: ROUTES.INDEX });
|
||||
},
|
||||
|
||||
Reference in new issue
Block a user