Missign translation

This commit is contained in:
Kilian committed 2024-07-27 01:40:45 +02:00
1 parent 581cacb636
commit 683b6020b7
12 files changed
+55 -20

No files matched your search

+14
View File
@@ -0,0 +1,14 @@
# Veränderungen Datenbank
## Tabelle `egb_benutzer`
- Neue Spalten `token` (Auth token): VarChar(36), Nullable, UNIQUE Constraint
- Abänderung der Spalte `zeitstempel`: Entfernen des `ON UPDATE` (da sonst die Mitgliedszeit beim Ändern der Daten sich ändert)
- Abänderung der Spalte `benutzername`: Non-Nullable gemacht, UNIQUE Constraint
- Abänderung der Spalte `email`: Non-Nullable gemacht, UNIQUE Constraint
- Abänderung der Spalte `passwort`: Non-Nullable gemacht
- Abänderung der Spalte `confirmationcode`: Default auf `NULL` gesetzt
## Tabelle `egb_gaestebuch`
- Abänderung der Spalte `benutzer_id`: Non-Nullable gemacht
- Abänderung der Spalte `beitrag`: Non-Nullable gemacht
- Hinzufüge eines Foreign Key Constraints auf `benutzer_id`
-1
View File
@@ -1 +0,0 @@
import{j as e,M as V,a as D,T as d,B as E,b as U,c as x,A as ge,d as W,L as v,C as X,I,e as pe,f as A,P,g as xe,u as je,h as Z,i as fe,k as J,l as _,D as Y,m as ee,n as L,o as ye,p as te,S as F,q as Ce,G as C,r as we,s as ve,t as be,v as Ae}from"./mui-BZej3Yg3.js";import{u as M,a as se,b as Pe,c as ke,L as y,d as Ee,O as Fe,e as De,r as S,f as ne,g as re,q,h as N,i as B,Q as Se,j as $e,k as Oe,R as Te,l as Ie}from"./tanstack-DeUNQvBN.js";import{c as Ue,r as p}from"./react-DXd9vB-a.js";import{i as b,B as Le,a as Re,b as Me,u as w,t as m}from"./i18n-DJgSTqOl.js";(function(){const s=document.createElement("link").relList;if(s&&s.supports&&s.supports("modulepreload"))return;for(const r of document.querySelectorAll('link[rel="modulepreload"]'))o(r);new MutationObserver(r=>{for(const i of r)if(i.type==="childList")for(const n of i.addedNodes)n.tagName==="LINK"&&n.rel==="modulepreload"&&o(n)}).observe(document,{childList:!0,subtree:!0});function a(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 o(r){if(r.ep)return;r.ep=!0;const i=a(r);fetch(r.href,i)}})();var R={},H=Ue;R.createRoot=H.createRoot,R.hydrateRoot=H.hydrateRoot;const f="https://khofmann.userpage.fu-berlin.de/phpCourse/exam/api/";let K;class qe{constructor(){if(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.logIn=async(s,a)=>{const{user:o,token:r}=await(await this.post("login",{email:s,password:a})).json();this.self=o,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 s=>{const a=`posts?p=${s??0}&l=9`;return this.token?await(await this.getAuth(a)).json():await(await this.get(a)).json()},this.deletePost=async s=>await(await this.delete(`posts/${s}`)).json(),this.user=async s=>{var a;return await(await this.getAuth(`users/${s??((a=this.self)==null?void 0:a.id)}`)).json()},this.updateUser=async(s,a)=>await(await this.patch(`users/${a??"self"}`,s)).json(),this.post=async(s,a,o)=>{const r=await fetch(`${f}${s}`,{mode:"cors",method:"post",headers:o,body:JSON.stringify(a)});if(r.ok)return r;throw await r.json()},this.postAuth=async(s,a,o)=>{const r=await fetch(`${f}${s}`,{mode:"cors",method:"post",headers:{token:this.token??"",...o},body:JSON.stringify(a)});if(r.ok)return r;throw await r.json()},this.get=async(s,a)=>{const o=await fetch(`${f}${s}`,{mode:"cors",method:"get",headers:a});if(o.ok)return o;throw await o.json()},this.getAuth=async(s,a)=>{const o=await fetch(`${f}${s}`,{mode:"cors",method:"get",headers:{token:this.token??"",...a}});if(o.ok)return o;throw await o.json()},this.delete=async(s,a)=>{const o=await fetch(`${f}${s}`,{mode:"cors",method:"delete",headers:{token:this.token??"",...a}});if(o.ok)return o;throw await o.json()},this.patch=async(s,a,o)=>{const r=await fetch(`${f}${s}`,{mode:"cors",method:"patch",headers:{token:this.token??"",...o},body:JSON.stringify(a)});if(r.ok)return r;throw await r.json()},K)throw new Error("New instance cannot be created!!");K=this}}const l=new qe;var k=(t=>(t.NOT_FOUND="NotFound",t.UNAUTHORIZED="Unauthorized",t.FAILEDUPDATE="FailedUpdate",t))(k||{});b.use(Le).use(Re).use(Me).init({fallbackLng:"en",debug:!1,interpolation:{escapeValue:!1},backend:{loadPath:"/phpCourse/exam/dist/locales/{{lng}}/{{ns}}.json"}});const Ne=({anchorEl:t,handleClose:s})=>e.jsxs(V,{anchorEl:t,anchorOrigin:{vertical:"bottom",horizontal:"right"},keepMounted:!0,transformOrigin:{vertical:"top",horizontal:"right"},open:!!t,onClose:s,sx:{"& .MuiMenu-paper":{minWidth:"240px"}},children:[e.jsx(D,{selected:b.language==="en",onClick:()=>{b.changeLanguage("en"),s()},children:"English"},"de"),e.jsx(D,{selected:b.language==="de",onClick:()=>{b.changeLanguage("de"),s()},children:"Deutsch"},"en")]});var g=(t=>(t.INDEX="/",t.PROFILE="/profile",t))(g||{});const Q=({error:t,context:s})=>{const{t:a}=w();if(!t)return null;if(t.code)switch(t.code){case k.NOT_FOUND:return e.jsx(d,{color:"error.main",children:a(t.code,{context:`${t.entity}:${s}`})});case k.UNAUTHORIZED:return e.jsx(d,{color:"error.main",children:a(t.code,{context:s})});case k.FAILEDUPDATE:return t.fields.map(o=>e.jsx(d,{color:"error.main",children:a(t.code,{context:s,name:a(o)})},`error_${o}`))}return e.jsx(d,{color:"error.main",children:a((t==null?void 0:t.message)??"Unknown",{context:s})})},Be=({handleClose:t})=>{const[s,a]=p.useState(),{t:o}=w(),r=M(),i=se({defaultValues:{email:"",password:""},onSubmit:async({value:n})=>{try{await l.logIn(n.email,n.password),r.invalidate(),t()}catch(u){a(u)}}});return e.jsx("form",{onSubmit:n=>{n.preventDefault(),n.stopPropagation(),i.handleSubmit()},onKeyDoLine truncated
+1
View File
@@ -0,0 +1 @@
import{j as e,M as X,a as $,T as d,B as F,b as L,c as x,A as ge,d as H,L as b,C as Z,I as U,e as pe,f as P,P as k,g as xe,u as je,h as J,i as fe,k as _,l as Y,D as ee,m as te,n as R,o as ye,p as se,S as D,q as Ce,G as C,r as we,s as ve,t as be,v as Ae}from"./mui-BZej3Yg3.js";import{u as q,a as ne,b as Pe,c as ke,L as y,d as Ee,O as Fe,e as De,r as T,f as re,g as oe,q as N,h as B,i as Q,Q as Se,j as $e,k as Te,R as Oe,l as Ie}from"./tanstack-DeUNQvBN.js";import{c as Ue,r as g}from"./react-DXd9vB-a.js";import{i as A,B as Le,a as Re,b as Me,u as w,t as m}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"]'))o(n);new MutationObserver(n=>{for(const i of n)if(i.type==="childList")for(const r of i.addedNodes)r.tagName==="LINK"&&r.rel==="modulepreload"&&o(r)}).observe(document,{childList:!0,subtree:!0});function a(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 o(n){if(n.ep)return;n.ep=!0;const i=a(n);fetch(n.href,i)}})();var M={},K=Ue;M.createRoot=K.createRoot,M.hydrateRoot=K.hydrateRoot;const f="https://khofmann.userpage.fu-berlin.de/phpCourse/exam/api/";let G;class qe{constructor(){if(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.logIn=async(s,a)=>{const{user:o,token:n}=await(await this.post("login",{email:s,password:a})).json();this.self=o,this.token=n},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 s=>{const a=`posts?p=${s??0}&l=9`;return this.token?await(await this.getAuth(a)).json():await(await this.get(a)).json()},this.deletePost=async s=>await(await this.delete(`posts/${s}`)).json(),this.user=async s=>{var a;return await(await this.getAuth(`users/${s??((a=this.self)==null?void 0:a.id)}`)).json()},this.updateUser=async(s,a)=>await(await this.patch(`users/${a??"self"}`,s)).json(),this.post=async(s,a,o)=>{const n=await fetch(`${f}${s}`,{mode:"cors",method:"post",headers:o,body:JSON.stringify(a)});if(n.ok)return n;throw await n.json()},this.postAuth=async(s,a,o)=>{const n=await fetch(`${f}${s}`,{mode:"cors",method:"post",headers:{token:this.token??"",...o},body:JSON.stringify(a)});if(n.ok)return n;throw await n.json()},this.get=async(s,a)=>{const o=await fetch(`${f}${s}`,{mode:"cors",method:"get",headers:a});if(o.ok)return o;throw await o.json()},this.getAuth=async(s,a)=>{const o=await fetch(`${f}${s}`,{mode:"cors",method:"get",headers:{token:this.token??"",...a}});if(o.ok)return o;throw await o.json()},this.delete=async(s,a)=>{const o=await fetch(`${f}${s}`,{mode:"cors",method:"delete",headers:{token:this.token??"",...a}});if(o.ok)return o;throw await o.json()},this.patch=async(s,a,o)=>{const n=await fetch(`${f}${s}`,{mode:"cors",method:"patch",headers:{token:this.token??"",...o},body:JSON.stringify(a)});if(n.ok)return n;throw await n.json()},G)throw new Error("New instance cannot be created!!");G=this}}const l=new qe;var E=(t=>(t.NOT_FOUND="NotFound",t.UNAUTHORIZED="Unauthorized",t.FAILEDUPDATE="FailedUpdate",t))(E||{});A.use(Le).use(Re).use(Me).init({fallbackLng:"en",debug:!1,interpolation:{escapeValue:!1},backend:{loadPath:"/phpCourse/exam/dist/locales/{{lng}}/{{ns}}.json"}});const Ne=({anchorEl:t,handleClose:s})=>e.jsxs(X,{anchorEl:t,anchorOrigin:{vertical:"bottom",horizontal:"right"},keepMounted:!0,transformOrigin:{vertical:"top",horizontal:"right"},open:!!t,onClose:s,sx:{"& .MuiMenu-paper":{minWidth:"240px"}},children:[e.jsx($,{selected:A.language==="en",onClick:()=>{A.changeLanguage("en"),s()},children:"English"},"de"),e.jsx($,{selected:A.language==="de",onClick:()=>{A.changeLanguage("de"),s()},children:"Deutsch"},"en")]});var p=(t=>(t.INDEX="/",t.PROFILE="/profile",t))(p||{});const z=({error:t,context:s,color:a="error.main"})=>{const{t:o}=w();if(!t)return null;if(t.code)switch(t.code){case E.NOT_FOUND:return e.jsx(d,{color:a,children:o(t.code,{context:`${t.entity}:${s}`})});case E.UNAUTHORIZED:return e.jsx(d,{color:a,children:o(t.code,{context:s})});case E.FAILEDUPDATE:return t.fields.map(n=>e.jsx(d,{color:a,children:o(t.code,{context:s,name:o(n)})},`error_${n}`))}return e.jsx(d,{color:a,children:o((t==null?void 0:t.message)??"Unknown",{context:s})})},Be=({handleClose:t})=>{const[s,a]=g.useState(),{t:o}=w(),n=q(),i=ne({defaultValues:{email:"",password:""},onSubmit:async({value:r})=>{try{await l.logIn(r.email,r.password),n.invalidate(),t()}catch(u){a(u)}}});return e.jsx("form",{onSubmit:r=>{r.preventDefault(),r.stopPropagation(),i.handleSubmit()},onKeyDown:r=>{Line truncated
+1 -1
View File
@@ -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-CmwTmvyQ.js"></script>
<script type="module" crossorigin src="/phpCourse/exam/dist/assets/index-DNzu9OIf.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-BZej3Yg3.js">
<link rel="modulepreload" crossorigin href="/phpCourse/exam/dist/assets/tanstack-DeUNQvBN.js">
+4 -2
View File
@@ -1,9 +1,11 @@
{
"Unauthorized": "Keine Berechtigung",
"NotFound_user:login": "Benutzer existiert nicht",
"Unauthorized_login": "Ungültige E-Mail oder Passwort",
"Unauthorized_delete": "Keine Berechtigung",
"NotFound_post:delete": "Post nicht gefunden",
"Unauthorized_deletePost": "Keine Berechtigung",
"NotFound_post:deletePost": "Post nicht gefunden",
"Unauthorized_userUpdate": "Keine Berechtigung",
"NotFound_user:userUpdate": "Benutzer nicht gefunden",
+4 -2
View File
@@ -1,9 +1,11 @@
{
"Unauthorized": "Unauthorized",
"NotFound_user:login": "User does not exist",
"Unauthorized_login": "Invalid email or password",
"Unauthorized_delete": "Unauthorized",
"NotFound_post:delete": "Post not found",
"Unauthorized_deletPost": "Unauthorized",
"NotFound_post:deletePost": "Post not found",
"Unauthorized_userUpdate": "Unauthorized",
"NotFound_user:userUpdate": "User not found",
+1 -1
View File
@@ -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":"58c2885d-1","name":"use-sync-external-store-shim.production.min.js?commonjs-exports"},{"uid":"58c2885d-5","name":"use-sync-external-store-shim.production.min.js?commonjs-proxy"},{"name":"use-sync-external-store-shim","children":[{"uid":"58c2885d-13","name":"with-selector.production.min.js?commonjs-exports"},{"uid":"58c2885d-17","name":"with-selector.production.min.js?commonjs-proxy"}]}]},{"name":"shim","children":[{"uid":"58c2885d-7","name":"index.js?commonjs-module"},{"uid":"58c2885d-11","name":"index.js?commonjs-proxy"},{"uid":"58c2885d-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":"58c2885d-3","name":"use-sync-external-store-shim.production.min.js"},{"name":"use-sync-external-store-shim/with-selector.production.min.js","uid":"58c2885d-15"}]},{"name":"shim","children":[{"uid":"58c2885d-9","name":"index.js"},{"uid":"58c2885d-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":"58c2885d-23","name":"vanilla.mjs"},{"uid":"58c2885d-25","name":"index.mjs"}]}]}]},{"name":"assets/index-CmwTmvyQ.js","children":[{"name":"\u0000vite/modulepreload-polyfill.js","uid":"58c2885d-27"},{"name":"\u0000/node_modules/.pnpm/react-dom@18.3.1_react@18.3.1/node_modules/react-dom/client.js?commonjs-exports","uid":"58c2885d-29"},{"name":"node_modules/.pnpm","children":[{"name":"react-dom@18.3.1_react@18.3.1/node_modules/react-dom/client.js","uid":"58c2885d-31"},{"name":"@fontsource+roboto@5.0.13/node_modules/@fontsource/roboto","children":[{"uid":"58c2885d-73","name":"300.css"},{"uid":"58c2885d-75","name":"400.css"},{"uid":"58c2885d-77","name":"500.css"},{"uid":"58c2885d-79","name":"700.css"}]}]},{"name":"src","children":[{"name":"api/Api.ts","uid":"58c2885d-33"},{"name":"components","children":[{"name":"Error","children":[{"uid":"58c2885d-35","name":"Errors.ts"},{"uid":"58c2885d-43","name":"ErrorComponent.tsx"}]},{"name":"Menus","children":[{"name":"Language/LanguageMenu.tsx","uid":"58c2885d-39"},{"name":"User/UserMenu.tsx","uid":"58c2885d-47"}]},{"name":"Forms","children":[{"name":"Login/LoginForm.tsx","uid":"58c2885d-45"},{"name":"UserEdit/UserEditDialog.tsx","uid":"58c2885d-61"}]},{"name":"Header/Header.tsx","uid":"58c2885d-49"},{"name":"Post/Post.tsx","uid":"58c2885d-55"},{"name":"Profile/Profile.tsx","uid":"58c2885d-63"}]},{"uid":"58c2885d-37","name":"i18n.ts"},{"name":"types/Routes.ts","uid":"58c2885d-41"},{"name":"routes","children":[{"uid":"58c2885d-51","name":"__root.tsx"},{"uid":"58c2885d-59","name":"index.tsx"},{"name":"profile","children":[{"uid":"58c2885d-67","name":"index.tsx"},{"uid":"58c2885d-69","name":"$id.tsx"}]}]},{"name":"utils/date.ts","uid":"58c2885d-53"},{"name":"queries","children":[{"uid":"58c2885d-57","name":"postsQuery.ts"},{"uid":"58c2885d-65","name":"profileQuery.ts"}]},{"uid":"58c2885d-71","name":"routeTree.gen.ts"},{"uid":"58c2885d-81","name":"main.tsx"}]},{"uid":"58c2885d-83","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":"58c2885d-85"},{"name":"html-parse-stringify@3.0.1/node_modules/html-parse-stringify/dist/html-parse-stringify.module.js","uid":"58c2885d-87"},{"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":"58c2885d-89","name":"utils.js"},{"uid":"58c2885d-91","name":"unescape.js"},{"uid":"58c2885d-93","name":"defaults.js"},{"uid":"58c2885d-95","name":"i18nInstance.js"},{"uid":"58c2885d-97","name":"TransWithoutContext.js"},{"uid":"58c2885d-99","name":"initReactI18next.js"},{"uid":"58c2885d-101","name":"context.js"},{"uid":"58c2885d-103","name":"Trans.js"},{"uid":"58c2885d-105","name":"useTranslation.js"},{"uid":"58c2885d-107","name":"withTranslation.js"},{"uid":"58c2885d-109","name":"Translation.js"},{"uid":"58c2885d-111","name":"I18nextProvider.js"},{"uid":"58c2885d-113","name":"useSSR.js"},{"uid":"58c2885d-115","name":"withSSR.js"},{"uid":"58c2885d-117","name":"index.js"}]},{"name":"i18next@23.12.2/node_modules/i18next/dist/esm/i18next.js","uid":"58c2885d-119"},{"name":"i18next-browser-languagedetector@8.0.0/node_modules/i18next-browser-languagedetector/dist/esm/i18nextBrowserLanguageDetector.js","uid":"58c2885d-121"},{"name":"i18next-http-backend@2.5.2/node_modules/i18next-http-backend/esm","children":[{"uid":"58c2885d-123","name":"utils.js"},{"uid":"58c2885d-133","name":"getFetch.cjs"},{"uid":"58c2885d-135","name":"request.js"},{"uidLine 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":"589f5197-1","name":"use-sync-external-store-shim.production.min.js?commonjs-exports"},{"uid":"589f5197-5","name":"use-sync-external-store-shim.production.min.js?commonjs-proxy"},{"name":"use-sync-external-store-shim","children":[{"uid":"589f5197-13","name":"with-selector.production.min.js?commonjs-exports"},{"uid":"589f5197-17","name":"with-selector.production.min.js?commonjs-proxy"}]}]},{"name":"shim","children":[{"uid":"589f5197-7","name":"index.js?commonjs-module"},{"uid":"589f5197-11","name":"index.js?commonjs-proxy"},{"uid":"589f5197-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":"589f5197-3","name":"use-sync-external-store-shim.production.min.js"},{"name":"use-sync-external-store-shim/with-selector.production.min.js","uid":"589f5197-15"}]},{"name":"shim","children":[{"uid":"589f5197-9","name":"index.js"},{"uid":"589f5197-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":"589f5197-23","name":"vanilla.mjs"},{"uid":"589f5197-25","name":"index.mjs"}]}]}]},{"name":"assets/index-DNzu9OIf.js","children":[{"name":"\u0000vite/modulepreload-polyfill.js","uid":"589f5197-27"},{"name":"\u0000/node_modules/.pnpm/react-dom@18.3.1_react@18.3.1/node_modules/react-dom/client.js?commonjs-exports","uid":"589f5197-29"},{"name":"node_modules/.pnpm","children":[{"name":"react-dom@18.3.1_react@18.3.1/node_modules/react-dom/client.js","uid":"589f5197-31"},{"name":"@fontsource+roboto@5.0.13/node_modules/@fontsource/roboto","children":[{"uid":"589f5197-73","name":"300.css"},{"uid":"589f5197-75","name":"400.css"},{"uid":"589f5197-77","name":"500.css"},{"uid":"589f5197-79","name":"700.css"}]}]},{"name":"src","children":[{"name":"api/Api.ts","uid":"589f5197-33"},{"name":"components","children":[{"name":"Error","children":[{"uid":"589f5197-35","name":"Errors.ts"},{"uid":"589f5197-43","name":"ErrorComponent.tsx"}]},{"name":"Menus","children":[{"name":"Language/LanguageMenu.tsx","uid":"589f5197-39"},{"name":"User/UserMenu.tsx","uid":"589f5197-47"}]},{"name":"Forms","children":[{"name":"Login/LoginForm.tsx","uid":"589f5197-45"},{"name":"UserEdit/UserEditDialog.tsx","uid":"589f5197-61"}]},{"name":"Header/Header.tsx","uid":"589f5197-49"},{"name":"Post/Post.tsx","uid":"589f5197-55"},{"name":"Profile/Profile.tsx","uid":"589f5197-63"}]},{"uid":"589f5197-37","name":"i18n.ts"},{"name":"types/Routes.ts","uid":"589f5197-41"},{"name":"routes","children":[{"uid":"589f5197-51","name":"__root.tsx"},{"uid":"589f5197-59","name":"index.tsx"},{"name":"profile","children":[{"uid":"589f5197-67","name":"index.tsx"},{"uid":"589f5197-69","name":"$id.tsx"}]}]},{"name":"utils/date.ts","uid":"589f5197-53"},{"name":"queries","children":[{"uid":"589f5197-57","name":"postsQuery.ts"},{"uid":"589f5197-65","name":"profileQuery.ts"}]},{"uid":"589f5197-71","name":"routeTree.gen.ts"},{"uid":"589f5197-81","name":"main.tsx"}]},{"uid":"589f5197-83","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":"589f5197-85"},{"name":"html-parse-stringify@3.0.1/node_modules/html-parse-stringify/dist/html-parse-stringify.module.js","uid":"589f5197-87"},{"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":"589f5197-89","name":"utils.js"},{"uid":"589f5197-91","name":"unescape.js"},{"uid":"589f5197-93","name":"defaults.js"},{"uid":"589f5197-95","name":"i18nInstance.js"},{"uid":"589f5197-97","name":"TransWithoutContext.js"},{"uid":"589f5197-99","name":"initReactI18next.js"},{"uid":"589f5197-101","name":"context.js"},{"uid":"589f5197-103","name":"Trans.js"},{"uid":"589f5197-105","name":"useTranslation.js"},{"uid":"589f5197-107","name":"withTranslation.js"},{"uid":"589f5197-109","name":"Translation.js"},{"uid":"589f5197-111","name":"I18nextProvider.js"},{"uid":"589f5197-113","name":"useSSR.js"},{"uid":"589f5197-115","name":"withSSR.js"},{"uid":"589f5197-117","name":"index.js"}]},{"name":"i18next@23.12.2/node_modules/i18next/dist/esm/i18next.js","uid":"589f5197-119"},{"name":"i18next-browser-languagedetector@8.0.0/node_modules/i18next-browser-languagedetector/dist/esm/i18nextBrowserLanguageDetector.js","uid":"589f5197-121"},{"name":"i18next-http-backend@2.5.2/node_modules/i18next-http-backend/esm","children":[{"uid":"589f5197-123","name":"utils.js"},{"uid":"589f5197-133","name":"getFetch.cjs"},{"uid":"589f5197-135","name":"request.js"},{"uidLine truncated
const run = () => {
const width = window.innerWidth;
@@ -1,9 +1,11 @@
{
"Unauthorized": "Keine Berechtigung",
"NotFound_user:login": "Benutzer existiert nicht",
"Unauthorized_login": "Ungültige E-Mail oder Passwort",
"Unauthorized_delete": "Keine Berechtigung",
"NotFound_post:delete": "Post nicht gefunden",
"Unauthorized_deletePost": "Keine Berechtigung",
"NotFound_post:deletePost": "Post nicht gefunden",
"Unauthorized_userUpdate": "Keine Berechtigung",
"NotFound_user:userUpdate": "Benutzer nicht gefunden",
@@ -1,9 +1,11 @@
{
"Unauthorized": "Unauthorized",
"NotFound_user:login": "User does not exist",
"Unauthorized_login": "Invalid email or password",
"Unauthorized_delete": "Unauthorized",
"NotFound_post:delete": "Post not found",
"Unauthorized_deletPost": "Unauthorized",
"NotFound_post:deletePost": "Post not found",
"Unauthorized_userUpdate": "Unauthorized",
"NotFound_user:userUpdate": "User not found",
@@ -1,4 +1,4 @@
import { Typography } from '@mui/material';
import { Typography, TypographyTypeMap } from '@mui/material';
import { FC } from 'react';
import { useTranslation } from 'react-i18next';
import { ERRORS } from './Errors';
@@ -7,9 +7,10 @@ interface Props {
//eslint-disable-next-line @typescript-eslint/no-explicit-any
error: any;
context?: string;
color?: TypographyTypeMap['props']['color'];
}
const ErrorComponent: FC<Props> = ({ error, context }) => {
const ErrorComponent: FC<Props> = ({ error, context, color = 'error.main' }) => {
const { t } = useTranslation();
if (!error) return null;
@@ -17,19 +18,19 @@ const ErrorComponent: FC<Props> = ({ error, context }) => {
if (error.code) {
switch (error.code) {
case ERRORS.NOT_FOUND:
return <Typography color="error.main">{t(error.code, { context: `${error.entity}:${context}` })}</Typography>;
return <Typography color={color}>{t(error.code, { context: `${error.entity}:${context}` })}</Typography>;
case ERRORS.UNAUTHORIZED:
return <Typography color="error.main">{t(error.code, { context })}</Typography>;
return <Typography color={color}>{t(error.code, { context })}</Typography>;
case ERRORS.FAILEDUPDATE:
return error.fields.map((field: string) => (
<Typography key={`error_${field}`} color="error.main">
<Typography key={`error_${field}`} color={color}>
{t(error.code, { context, name: t(field) })}
</Typography>
));
}
}
return <Typography color="error.main">{t(error?.message ?? 'Unknown', { context })}</Typography>;
return <Typography color={color}>{t(error?.message ?? 'Unknown', { context })}</Typography>;
};
export default ErrorComponent;
+14 -2
View File
@@ -31,6 +31,8 @@ interface Props {
const Post: FC<Props> = ({ post }) => {
const [open, setOpen] = useState(false);
//eslint-disable-next-line @typescript-eslint/no-explicit-any
const [error, setError] = useState<any>();
const deleteMutation = useMutation({
mutationFn: (id: number) => {
@@ -112,6 +114,7 @@ const Post: FC<Props> = ({ post }) => {
queryKey: ['posts'],
});
},
onError: setError,
});
setOpen(false);
}}
@@ -123,9 +126,18 @@ const Post: FC<Props> = ({ post }) => {
</>
)}
</CardActions>
<Snackbar open={deleteMutation.isError} autoHideDuration={2000} onClose={() => deleteMutation.reset()}>
<Snackbar
open={deleteMutation.isError}
autoHideDuration={2000}
onClose={() => {
deleteMutation.reset();
}}
TransitionProps={{
onExited: () => setError(undefined),
}}
>
<Alert severity="error" variant="filled" sx={{ width: '100%' }}>
{deleteMutation.isError && <ErrorComponent error={deleteMutation.error} context="delete" />}
{error && <ErrorComponent error={error} context="delete" color="white" />}
</Alert>
</Snackbar>
<Snackbar open={deleteMutation.isPending} message={t('Deleting')} />
+1 -1
View File
@@ -15,7 +15,7 @@ const Root = () => {
<>
<Header />
<Box sx={{ display: 'flex', justifyContent: 'center' }}>
<Box sx={{ maxWidth: '800px' }}>
<Box sx={{ maxWidth: '800px', flexGrow: 1 }}>
<Outlet />
</Box>
</Box>