From aa485fa2b1e9cafec1e53ba53de079b795b4cc2d Mon Sep 17 00:00:00 2001 From: Dhaverd Date: Mon, 28 Oct 2024 01:08:10 +0800 Subject: [PATCH] =?UTF-8?q?=D0=9D=D0=B0=D0=BC=D1=83=D1=82=D0=B8=D0=BB=20?= =?UTF-8?q?=D0=BD=D0=B5=D0=BC=D0=BD=D0=BE=D0=B3=D0=BE=20CRUD'a:=20=D0=B2?= =?UTF-8?q?=D1=8B=D0=B2=D0=BE=D0=B4=20=D1=81=D0=BF=D0=B8=D1=81=D0=BA=D0=B0?= =?UTF-8?q?,=20=D1=83=D0=B4=D0=B0=D0=BB=D0=B5=D0=BD=D0=B8=D0=B5=20=D0=B7?= =?UTF-8?q?=D0=B0=D0=BF=D0=B8=D1=81=D0=B8=20=D0=B8=20=D1=81=D0=BE=D0=B7?= =?UTF-8?q?=D0=B4=D0=B0=D0=BD=D0=B8=D0=B5=20=D0=BD=D0=BE=D0=B2=D0=BE=D0=B9?= =?UTF-8?q?=20=D0=B7=D0=B0=D0=BF=D0=B8=D1=81=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- resources/css/app.css | 17 +++-- resources/store/wish.js | 29 +++++++-- resources/views/Auth/Login.vue | 20 +++++- resources/views/Auth/Registration.vue | 27 ++++++-- resources/views/Welcome.vue | 5 -- resources/views/Wishlist/CreateWish.vue | 61 ++++++++++++++++++ resources/views/Wishlist/Wishlist.vue | 85 ++++++++++++++++++++----- 7 files changed, 205 insertions(+), 39 deletions(-) create mode 100644 resources/views/Wishlist/CreateWish.vue diff --git a/resources/css/app.css b/resources/css/app.css index c1b8af1..d82198a 100644 --- a/resources/css/app.css +++ b/resources/css/app.css @@ -1,9 +1,18 @@ .link-no-decor { - color: white; - text-decoration: none; - cursor: pointer; + color: white!important; + text-decoration: none!important; + cursor: pointer!important; } .link-no-decor:hover { - color: #093160; + color: #093160!important; +} + +.cursor-pointer { + cursor: pointer!important; +} + +.card-bg { + background-color: #212022!important; + color: white!important; } diff --git a/resources/store/wish.js b/resources/store/wish.js index 100c4d7..7d53ba6 100644 --- a/resources/store/wish.js +++ b/resources/store/wish.js @@ -9,15 +9,15 @@ export const useWishStore = defineStore('wish', { pushWish(wish){ this.wishesList.push(wish); }, - async getUserWishes(user_id, token){ + async getUserWishes(user_id){ let result = null; await axios.get(`/api/wish/user_wishes/${user_id.toString()}`, - { - headers: { - Authorization: `Bearer ${token}`, - token: token - } - } + // { + // headers: { + // Authorization: `Bearer ${token}`, + // token: token + // } + // } ).then((response)=>{ result = response.data; }); @@ -42,6 +42,21 @@ export const useWishStore = defineStore('wish', { newWish = {status: response.status, statusText: response.statusText, data: response.data}; }); return newWish; + }, + async remove(id, token){ + await axios.post(`/api/wish/destroy`, + { + id: id + }, + { + headers: { + Authorization: `Bearer ${token}`, + token: token + }, + } + ).then((response)=>{ + return response; + }); } }, }) diff --git a/resources/views/Auth/Login.vue b/resources/views/Auth/Login.vue index 3a60f92..adff294 100644 --- a/resources/views/Auth/Login.vue +++ b/resources/views/Auth/Login.vue @@ -12,15 +12,31 @@ export default { data: () => ({ userStore: useUserStore(), valid: false, - email: '', - password: '', + email: null, + password: null, rememberMe: false, errorMessage: '', errorMessageContainerStyle: '', showPassword: false }), methods: { + validate(){ + let emailValidation = rules.email(this.email); + let passwordValidation = rules.notNull(this.password); + if (typeof emailValidation == "boolean" && typeof passwordValidation == "boolean"){ + return emailValidation && passwordValidation; + } else if (typeof emailValidation == "string") { + return emailValidation; + } else if (typeof passwordValidation == "string") { + return passwordValidation; + } + }, loginAction(){ + let validation = this.validate(); + if (validation !== true){ + alert(validation); + return; + } this.userStore.login(this.email, this.password, this.rememberMe).then((isLogged) => { if (typeof isLogged == "boolean") { if (isLogged){ diff --git a/resources/views/Auth/Registration.vue b/resources/views/Auth/Registration.vue index 7a475ae..7cfa62c 100644 --- a/resources/views/Auth/Registration.vue +++ b/resources/views/Auth/Registration.vue @@ -7,10 +7,10 @@ export default { data: () => ({ userStore: useUserStore(), valid: false, - login: '', - email: '', - password: '', - repeatPassword: '', + login: null, + email: null, + password: null, + repeatPassword: null, errorMessage: '', errorMessageContainerStyle: 'display: none;', showPassword: false, @@ -22,7 +22,26 @@ export default { } }, methods: { + validate(){ + let emailValidation = rules.email(this.email); + let loginValidation = rules.notNull(this.login); + let passwordValidation = rules.notNull(this.password); + let repeatPasswordValidation = rules.notNull(this.repeatPassword); + let validation = [emailValidation, loginValidation, passwordValidation, repeatPasswordValidation]; + let check = null; + validation.forEach((element)=>{ + if (typeof element !== "boolean"){ + check = element; + } + }) + return check === null ? true : check; + }, registrationAction(){ + let validation = this.validate(); + if (validation !== true){ + alert(validation); + return; + } this.userStore.registration(this.login, this.email, this.password, this.repeatPassword).then((isRegistred)=>{ if (typeof isRegistred == "boolean") { if (isRegistred){ diff --git a/resources/views/Welcome.vue b/resources/views/Welcome.vue index bd842a9..c197459 100644 --- a/resources/views/Welcome.vue +++ b/resources/views/Welcome.vue @@ -63,9 +63,4 @@ export default { height: 100vh; } -.card-bg { - background-color: #212022; - color: white; -} - diff --git a/resources/views/Wishlist/CreateWish.vue b/resources/views/Wishlist/CreateWish.vue new file mode 100644 index 0000000..262c491 --- /dev/null +++ b/resources/views/Wishlist/CreateWish.vue @@ -0,0 +1,61 @@ + + + + + diff --git a/resources/views/Wishlist/Wishlist.vue b/resources/views/Wishlist/Wishlist.vue index b0b2f61..01191b1 100644 --- a/resources/views/Wishlist/Wishlist.vue +++ b/resources/views/Wishlist/Wishlist.vue @@ -1,36 +1,87 @@