From 4b6be9f09ff56dfae1c719cb744f2312e11be317 Mon Sep 17 00:00:00 2001 From: jdlugosz963 Date: Sun, 12 Dec 2021 23:09:20 +0100 Subject: add group maker --- src/services/AuthService.js | 34 +++++++++++++++------------------- src/services/ChatService.js | 17 +++++++++++++++++ src/services/CommandsService.js | 21 +++++++++++---------- src/services/NotifyErrorService.js | 20 ++++++++++++++++++++ 4 files changed, 63 insertions(+), 29 deletions(-) create mode 100644 src/services/ChatService.js create mode 100644 src/services/NotifyErrorService.js (limited to 'src/services') diff --git a/src/services/AuthService.js b/src/services/AuthService.js index 758157c..2f58076 100644 --- a/src/services/AuthService.js +++ b/src/services/AuthService.js @@ -1,25 +1,8 @@ import axios from "axios"; -import Vue from 'vue' +import error_notify from './NotifyErrorService.js' const url = 'http://localhost:8000/api/auth/' -const error_notify = (error) => { - for (const [key, values] of Object.entries(error.response.data)) { - console.log(values) - values.forEach(value => { - Vue.notify({ - type: 'error', - title: value, - text: (key !== 'non_field_errors') ? key : '' - }) - }) - } - return { - data: error.response.data, - status: error.response.status - } -} - export default { async login(data) { return await axios @@ -46,6 +29,19 @@ export default { }, + async info(data) { + return await axios + .get(url+'info/?'+data) + .then(res => { + return { + data: res.data, + status: res.status + } + }) + .catch(error => error_notify(error)) + + }, + async logout() { return await axios .post(url+'logout/') @@ -56,4 +52,4 @@ export default { }) .catch(error => error_notify(error)) } -} \ No newline at end of file +} diff --git a/src/services/ChatService.js b/src/services/ChatService.js new file mode 100644 index 0000000..ab1e6c2 --- /dev/null +++ b/src/services/ChatService.js @@ -0,0 +1,17 @@ +import axios from "axios"; +import error_notify from './NotifyErrorService.js' + +const url = 'http://localhost:8000/api/chat/' + +export default { + async group_create(data) { + return await axios + .post(url+'groups/', data) + .then(res => { + return { + status: res.status + } + }) + .catch(error => error_notify(error)) + } +} diff --git a/src/services/CommandsService.js b/src/services/CommandsService.js index f8a815f..01a758e 100644 --- a/src/services/CommandsService.js +++ b/src/services/CommandsService.js @@ -3,18 +3,19 @@ import store from "@/store/index.js" import router from '@/router/index.js' export default { - logout() { + groups() { + return { + send(searcher) {console.log(searcher)}, + + make(searcher) { + searcher.$emit('toogle_group_maker') + }, + } + }, + + logout() { AuthService.logout() store.dispatch('logout') router.push('/login') }, - friends() { - console.log("list") - }, - tab() { - return { - on() {}, - off() {} - } - } } diff --git a/src/services/NotifyErrorService.js b/src/services/NotifyErrorService.js new file mode 100644 index 0000000..b28e664 --- /dev/null +++ b/src/services/NotifyErrorService.js @@ -0,0 +1,20 @@ +import Vue from 'vue' + +const error_notify = (error) => { + for (const [key, values] of Object.entries(error.response.data)) { + console.log(values) + values.forEach(value => { + Vue.notify({ + type: 'error', + title: value, + text: (key !== 'non_field_errors') ? key : '' + }) + }) + } + return { + data: error.response.data, + status: error.response.status + } +} + +export default error_notify -- cgit v1.2.3