shared-ritm 1.0.28 → 1.0.30

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,12 @@
1
+ import ApiService from '@/api/settings/ApiService';
2
+ type LoginResponse = {
3
+ token: string;
4
+ user: any;
5
+ };
6
+ declare class AuthService extends ApiService {
7
+ login(email: string, password: string): Promise<LoginResponse>;
8
+ logout(): Promise<LoginResponse>;
9
+ configs(): Promise<any>;
10
+ }
11
+ export default function useAuthService(): AuthService;
12
+ export {};
@@ -15,7 +15,7 @@ export default class ApiService {
15
15
  constructor();
16
16
  private getToken;
17
17
  private removeToken;
18
- private logout;
18
+ logout(): void;
19
19
  private handleError;
20
20
  protected get<T>(url: string, options?: AxiosRequestConfig): Promise<T>;
21
21
  protected delete<T>(url: string, options?: AxiosRequestConfig): Promise<AxiosResponse<T, any>>;
@@ -15,5 +15,5 @@ import useRepairsService from '@/api/services/RepairsService';
15
15
  import useTasksService from '@/api/services/TasksService';
16
16
  export { AppButton, AppInput, AppToggle, AppInputSearch, AppLayout, AppSelect, AppWrapper, AppSidebar, AppLayoutHeader, AppLoader, };
17
17
  export { useGanttService, useMetricsService, useProjectsService, useRepairsService, useTasksService };
18
- export * from '@/api/types/Api_Repairs';
19
18
  export * from '@/api/types/Api_Tasks';
19
+ export * from '@/api/types/Api_Repairs';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "shared-ritm",
3
- "version": "1.0.28",
3
+ "version": "1.0.30",
4
4
  "private": false,
5
5
  "files": [
6
6
  "dist",
@@ -0,0 +1,37 @@
1
+ import ApiService from '@/api/settings/ApiService'
2
+
3
+ type LoginPayload = {
4
+ email: string
5
+ password: string
6
+ }
7
+
8
+ type LoginResponse = {
9
+ token: string
10
+ user: any
11
+ }
12
+
13
+ type ConfigResponse = any
14
+
15
+ class AuthService extends ApiService {
16
+ public login(email: string, password: string) {
17
+ return this.post<LoginPayload, LoginResponse>(`/login`, {
18
+ email,
19
+ password,
20
+ })
21
+ }
22
+
23
+ public logout() {
24
+ return this.post<null, LoginResponse>(`/logout`, null)
25
+ }
26
+
27
+ public configs() {
28
+ return this.get<ConfigResponse>(`/configs`)
29
+ }
30
+ }
31
+
32
+ let api: AuthService
33
+
34
+ export default function useAuthService() {
35
+ if (!api) api = new AuthService()
36
+ return api
37
+ }
@@ -57,7 +57,7 @@ export default class ApiService {
57
57
  localStorage.removeItem('token')
58
58
  }
59
59
 
60
- private logout(): void {
60
+ public logout(): void {
61
61
  this.removeToken()
62
62
  window.location.href = '/sign-in'
63
63
  }
@@ -56,7 +56,7 @@
56
56
  </template>
57
57
 
58
58
  <script setup lang="ts">
59
- import { computed, defineProps, ref, watch } from 'vue'
59
+ import { computed, defineProps, defineEmits, ref, watch } from 'vue'
60
60
  import SidebarMenu from './components/SidebarMenu.vue'
61
61
 
62
62
  import { useQuasar } from 'quasar'
@@ -67,6 +67,7 @@ interface Props {
67
67
  minify?: boolean
68
68
  menuItems?: any[]
69
69
  }
70
+ const emits = defineEmits(['logout'])
70
71
  const props = defineProps<Props>()
71
72
  const $q = useQuasar()
72
73
 
@@ -89,7 +90,7 @@ function openDrawerIsTablet() {
89
90
  }
90
91
 
91
92
  function logout(): void {
92
- window.location.href = '/sign-out'
93
+ emits('logout')
93
94
  }
94
95
 
95
96
  watch(
package/src/index.ts CHANGED
@@ -30,5 +30,5 @@ export {
30
30
 
31
31
  export { useGanttService, useMetricsService, useProjectsService, useRepairsService, useTasksService }
32
32
 
33
- export * from '@/api/types/Api_Repairs'
34
33
  export * from '@/api/types/Api_Tasks'
34
+ export * from '@/api/types/Api_Repairs'