From d7d0233eafe70bb7037d2bb7a01b372866cfd5a2 Mon Sep 17 00:00:00 2001
From: krisskol <krisskol@stud.ntnu.no>
Date: Wed, 3 Apr 2024 12:37:29 +0200
Subject: [PATCH] complete api requests for testing

---
 FullstackProsjekt/src/frontend/src/api.js     |  2 +-
 .../src/frontend/src/views/LoginView.vue      | 10 ++++++--
 .../src/frontend/src/views/SignupView.vue     | 25 ++++++++++++-------
 3 files changed, 25 insertions(+), 12 deletions(-)

diff --git a/FullstackProsjekt/src/frontend/src/api.js b/FullstackProsjekt/src/frontend/src/api.js
index 79898c4..17162e5 100644
--- a/FullstackProsjekt/src/frontend/src/api.js
+++ b/FullstackProsjekt/src/frontend/src/api.js
@@ -1,6 +1,6 @@
 import axios from 'axios';
 
 export const apiClient = axios.create({
-    baseURL: '/api',
+    baseURL: 'http://localhost:5173/api',
     //TODO: set api URL
 });
\ No newline at end of file
diff --git a/FullstackProsjekt/src/frontend/src/views/LoginView.vue b/FullstackProsjekt/src/frontend/src/views/LoginView.vue
index 84d35a5..56d3428 100644
--- a/FullstackProsjekt/src/frontend/src/views/LoginView.vue
+++ b/FullstackProsjekt/src/frontend/src/views/LoginView.vue
@@ -8,6 +8,7 @@ export default {
 	//components: {Svg},
 	data() {
 		return {
+      username: '',
 			email: '',
 			password: '',
 			showPassword: false, // Add showPassword property
@@ -17,8 +18,8 @@ export default {
 	methods: {
 		async handleSubmit() {
       try {
-        await apiClient.post('/login', {
-          email: this.email,
+        await apiClient.post('/auth/login', {
+          username: this.username,
           password: this.password
         }).then(response => {
           setToken(response.data.token); //TODO: check token name
@@ -43,14 +44,19 @@ export default {
 				<h1 id="login">Login</h1>
 				<p> Sign in to your already existing account</p>
 				<div class="loginBox">
+          <label>Username</label> <br>
+          <input type="text" required v-model="username" placeholder="username"/> <br>
+          <!--
 					<label>Email</label> <br>
 					<input type="email" placeholder="JohnDoe@email.com" required v-model="email"/> <br>
+          -->
 					<label>Password</label> <br>
 					<input :type="showPassword ? 'text' : 'password'" required v-model="password"/>
 					<button  type="button" class="showPasswordIcon" @click="togglePasswordVisibility">
 						<Svg v-if="showPassword" :name="'hide-password-icon'" />
 						<Svg v-else :name="'show-password-icon'" />
 					</button><br>
+          <label></label>{{errorMsg}}<br>
 					<router-link to="/signup" id="signUpLink">SIGNUP</router-link>
 				</div>
 			</div>
diff --git a/FullstackProsjekt/src/frontend/src/views/SignupView.vue b/FullstackProsjekt/src/frontend/src/views/SignupView.vue
index ebb9787..e76797b 100644
--- a/FullstackProsjekt/src/frontend/src/views/SignupView.vue
+++ b/FullstackProsjekt/src/frontend/src/views/SignupView.vue
@@ -6,9 +6,10 @@
 		name: 'Register',
 		data(){
 			return{
-				first_name:'',
-				last_name:'',
-				email:'',
+        username: '',
+				//first_name:'',
+				//last_name:'',
+				//email:'',
 				password:'',
 				password_confirm:'',
         errorMsg: '', //TODO: display error to user
@@ -18,10 +19,11 @@
 			async handleSubmit() {
         //TODO: use interceptor to check matching password, send one password
         try {
-          await apiClient.post('/api/auth/register', {
-            first_name: this.first_name,
-            last_name: this.last_name,
-            email: this.email,
+          await apiClient.post('/auth/register', {
+            //first_name: this.first_name,
+            //last_name: this.last_name,
+            //email: this.email,
+            username: this.username,
             password: this.password
             //password_confirm: this.password_confirm
           }).then(response => {
@@ -47,13 +49,18 @@
 				<h1 id="signup">Signup</h1>
 				<p> Create an account to get started!</p>
 				<div class="signupBox">
-					<label>First Name</label> <br>
+          <label>First Name</label> <br>
+          <input type="text" required v-model="username" placeholder="username"/> <br>
+          <!--
+            <label>First Name</label> <br>
 					<input type="text" required v-model="first_name" placeholder="John"/> <br>
 					<label>Last Name</label> <br>
 					<input type="text" required v-model="last_name" placeholder="Doe"/> <br>
 					<label>Email</label> <br>
 					<input type="email" required v-model="email" placeholder="JohnDoe@email.com"/> <br>
-					<label>Password</label> <br>
+
+          -->
+          <label>Password</label> <br>
 					<input type="text" required v-model="password" /> <br>
 					<label>Confirm Password</label> <br>
 					<input type="text" required v-model="password_confirm" /> <br>
-- 
GitLab