From 270b7063e5d244f9c058d91e504489bcfb879789 Mon Sep 17 00:00:00 2001
From: bmodee <bjomo323@student.liu.se>
Date: Sun, 9 May 2021 15:30:52 +0200
Subject: [PATCH] Fix server bug

---
 .../admin/dashboard/components/CurrentUser.tsx    | 15 +++++++++++++--
 metrics/README.md                                 |  2 +-
 server/app/database/models.py                     |  5 -----
 3 files changed, 14 insertions(+), 8 deletions(-)

diff --git a/client/src/pages/admin/dashboard/components/CurrentUser.tsx b/client/src/pages/admin/dashboard/components/CurrentUser.tsx
index 933a320b..61d6e5f0 100644
--- a/client/src/pages/admin/dashboard/components/CurrentUser.tsx
+++ b/client/src/pages/admin/dashboard/components/CurrentUser.tsx
@@ -6,6 +6,17 @@ import { useAppSelector } from '../../../../hooks'
 
 const CurrentUser: React.FC = () => {
   const currentUser = useAppSelector((state: { user: { userInfo: any } }) => state.user.userInfo)
+  const roles = useAppSelector((state) => state.roles.roles)
+  const region = useAppSelector((state) => state.cities.cities)
+
+  const handleRole = (id: number) => {
+    return id
+  }
+
+  const handleRegion = (id: number) => {
+    return id
+  }
+
   return (
     <div>
       <Box display="flex" flexDirection="column" alignContent="flex-start">
@@ -20,10 +31,10 @@ const CurrentUser: React.FC = () => {
           </Typography>
         </div>
         <div>
-          <Typography variant="h6">Region: {currentUser && currentUser.city && currentUser.city.name}</Typography>
+          <Typography variant="h6">Region: {handleRegion(currentUser.city_id)}</Typography>
         </div>
         <div>
-          <Typography variant="h6">Roll: {currentUser && currentUser.role && currentUser.role.name}</Typography>
+          <Typography variant="h6">Roll: {handleRole(currentUser.role_id)}</Typography>
         </div>
       </Box>
     </div>
diff --git a/metrics/README.md b/metrics/README.md
index 401002d0..8686aaab 100644
--- a/metrics/README.md
+++ b/metrics/README.md
@@ -50,7 +50,7 @@ For each function space, rust-code-analysis computes the list of metrics describ
 
 # Metrics
 
-Now the tool has analyzed the projekt and has outputted json files which the script will extrac the metrics from.
+Now the tool has analyzed the project and has outputted json files which the script will extract the metrics from.
 Don't forget to change the path in the script.
 
 ```bash
diff --git a/server/app/database/models.py b/server/app/database/models.py
index 90eabf24..97eb6097 100644
--- a/server/app/database/models.py
+++ b/server/app/database/models.py
@@ -66,10 +66,7 @@ class User(db.Model):
     locked = db.Column(db.DateTime(timezone=True), nullable=True, default=None)
 
     role_id = db.Column(db.Integer, db.ForeignKey("role.id"), nullable=False)
-    role_name = db.Column(db.Integer, db.ForeignKey("role.name"), nullable=False)
-
     city_id = db.Column(db.Integer, db.ForeignKey("city.id"), nullable=False)
-    city_name = db.Column(db.Integer, db.ForeignKey("city.name"), nullable=False)
 
     media = db.relationship("Media", backref="upload_by")
 
@@ -77,9 +74,7 @@ class User(db.Model):
         self._password = bcrypt.generate_password_hash(plaintext_password)
         self.email = email
         self.role_id = role_id
-        self.role_name = role_name
         self.city_id = city_id
-        self.city_name = city_name
         self.authenticated = False
         self.name = name
 
-- 
GitLab