shared-ritm 1.2.16 → 1.2.18

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.
Files changed (35) hide show
  1. package/README.md +103 -103
  2. package/dist/index.css +1 -1
  3. package/dist/shared-ritm.es.js +2923 -2909
  4. package/dist/shared-ritm.umd.js +7 -7
  5. package/package.json +1 -1
  6. package/src/App.vue +2445 -2455
  7. package/src/api/services/GanttService.ts +17 -17
  8. package/src/api/services/MetricsService.ts +101 -101
  9. package/src/api/services/ProjectsService.ts +67 -67
  10. package/src/api/settings/ApiService.ts +126 -126
  11. package/src/api/types/Api_Files.ts +1 -1
  12. package/src/api/types/Api_Projects.ts +55 -55
  13. package/src/api/types/Api_Repairs.ts +93 -93
  14. package/src/common/app-checkbox/AppCheckbox.vue +26 -26
  15. package/src/common/app-date-picker/AppDatePicker.vue +81 -81
  16. package/src/common/app-dialogs/AppConfirmDialog.vue +100 -100
  17. package/src/common/app-dropdown/AppDropdown.vue +31 -31
  18. package/src/common/app-input-search/AppInputSearch.vue +170 -170
  19. package/src/common/app-layout/AppLayout.vue +5 -1
  20. package/src/common/app-layout/components/AppLayoutHeader.vue +29 -41
  21. package/src/common/app-select/AppSelect.vue +157 -157
  22. package/src/common/app-sidebar/components/SidebarMenuItem.vue +146 -146
  23. package/src/common/app-toggle/AppToggle.vue +23 -23
  24. package/src/common/app-wrapper/AppWrapper.vue +28 -28
  25. package/src/icons/dialogs/RemoveIcon.vue +12 -12
  26. package/src/icons/dialogs/SafetyIcon.vue +12 -12
  27. package/src/icons/task/attention-icon.vue +13 -13
  28. package/src/icons/task/clock-icon.vue +10 -10
  29. package/src/icons/task/delete-icon.vue +10 -10
  30. package/src/icons/task/fire-icon.vue +16 -16
  31. package/src/index.ts +62 -62
  32. package/src/shared/styles/general.css +96 -96
  33. package/src/utils/confirm.ts +12 -12
  34. package/src/utils/notification.ts +9 -9
  35. package/src/common/app-layout/components/AppPageContent.vue +0 -32
@@ -1,17 +1,17 @@
1
- import ApiService from '@/api/settings/ApiService'
2
-
3
- class GanttService extends ApiService {
4
- public async fetchCriticalPathTasks(params: string): Promise<any> {
5
- return await this.get(`gantt/get_list_task_on_critical_path?${params}`)
6
- }
7
- public async fetchGanttList(params: string): Promise<any> {
8
- return await this.get(`/list/tasks/search?${params}&gantt=1`)
9
- }
10
- }
11
-
12
- let api: GanttService
13
-
14
- export default function useGanttService() {
15
- if (!api) api = new GanttService()
16
- return api
17
- }
1
+ import ApiService from '@/api/settings/ApiService'
2
+
3
+ class GanttService extends ApiService {
4
+ public async fetchCriticalPathTasks(params: string): Promise<any> {
5
+ return await this.get(`gantt/get_list_task_on_critical_path?${params}`)
6
+ }
7
+ public async fetchGanttList(params: string): Promise<any> {
8
+ return await this.get(`/list/tasks/search?${params}&gantt=1`)
9
+ }
10
+ }
11
+
12
+ let api: GanttService
13
+
14
+ export default function useGanttService() {
15
+ if (!api) api = new GanttService()
16
+ return api
17
+ }
@@ -1,101 +1,101 @@
1
- import ApiService, { ResponseApi } from '@/api/settings/ApiService'
2
-
3
- class MetricsService extends ApiService {
4
- public async fetchPieProjects(queryString: string): Promise<ResponseApi<any>> {
5
- return await this.get('repairs/pie/projects' + '?' + queryString)
6
- }
7
-
8
- public async fetchPieTasks(queryString: string): Promise<ResponseApi<any>> {
9
- return await this.get('repairs/pie/tasks' + '?' + queryString)
10
- }
11
-
12
- public async fetchPiePersonnel(queryString: string): Promise<ResponseApi<any>> {
13
- return await this.get('repairs/metrics/get_list_position' + '?' + queryString)
14
- }
15
-
16
- public async fetchPersonnelData(queryString: string): Promise<ResponseApi<any>> {
17
- return await this.get('repairs/metrics/list_position_intersection_group_by_status' + '?' + queryString)
18
- }
19
-
20
- public async fetchPersonnelInfo(params: string): Promise<ResponseApi<any>> {
21
- return await this.get(`repairs/metrics/list_position_intersection_details?${params}`)
22
- }
23
-
24
- public async fetchPiePersonnelInfo(params: string): Promise<any> {
25
- return await this.get(`repairs/metrics/get_list_user_by_position?${params}`)
26
- }
27
-
28
- public async fetchPieCriticalPath(queryString: string): Promise<any[]> {
29
- return await this.get('repairs/metrics/get_critical_path_group_by_status' + '?' + queryString)
30
- }
31
-
32
- public async fetchPieCriticalPathInfo(params: string): Promise<any> {
33
- return await this.get(`repairs/metrics/get_list_task_critical_path_by_status?${params}`)
34
- }
35
-
36
- public async fetchPieTmc(queryString: string): Promise<ResponseApi<any>> {
37
- return await this.get('repairs/metrics/get_list_instrument_type' + '?' + queryString)
38
- }
39
-
40
- public async fetchPieTmcInfo(params: string): Promise<any> {
41
- return await this.get(`repairs/metrics/get_list_warehouse_by_instrument_type?${params}`)
42
- }
43
-
44
- public async fetchPieUntimelyClosedTask(queryString: string): Promise<any[]> {
45
- return await this.get('repairs/metrics/get_list_comment_type' + '?' + queryString)
46
- }
47
-
48
- public async fetchPieUntimelyClosedTaskInfo(params: string): Promise<any> {
49
- return await this.get(`repairs/metrics/get_list_task_by_comment_type?${params}`)
50
- }
51
-
52
- public async fetchPieAdditionalTasks(queryString: string): Promise<any[]> {
53
- return await this.get('repairs/metrics/get_list_task_after_plan_fixate_group_by_status' + '?' + queryString)
54
- }
55
-
56
- public async fetchPieAdditionalTasksInfo(params: string): Promise<any> {
57
- return await this.get(`repairs/metrics/get_list_task_after_plan_fixate_by_status?${params}`)
58
- }
59
-
60
- public async fetchPersonnel(queryString: string): Promise<any[]> {
61
- return await this.get('repairs/statistic/personnel' + '?' + queryString)
62
- }
63
-
64
- public async fetchPieExpired(queryString: string): Promise<any[]> {
65
- return await this.get('repairs/metrics/get_list_task_expired_group_by_status' + '?' + queryString)
66
- }
67
-
68
- public async fetchPieExpiredInfo(params: string): Promise<any> {
69
- return await this.get(`repairs/metrics/get_list_task_expired?${params}`)
70
- }
71
-
72
- public async fetchEconomicsPerformance(params: string): Promise<any> {
73
- return await this.get(`repairs/metrics/get_economic_performance?${params}`)
74
- }
75
-
76
- public async fetchEconomicsInfo(params: string): Promise<any> {
77
- return await this.get(`repairs/metrics/get_list_task_economic_performance?${params}`)
78
- }
79
- public async fetchQualityMetrics(params: string): Promise<any> {
80
- return await this.get(`repairs/metrics/get_quality_metrics?${params}`)
81
- }
82
-
83
- public async fetchQualityInfo(params: string): Promise<any> {
84
- return await this.get(`repairs/metrics/get_list_task_by_quality?${params}`)
85
- }
86
-
87
- public async fetchPieWorkZone(queryString: string): Promise<ResponseApi<any>> {
88
- return await this.get('repairs/metrics/get_list_work_zone_instrument' + '?' + queryString)
89
- }
90
-
91
- public async fetchWorkZoneInfo(queryString: string): Promise<ResponseApi<any>> {
92
- return await this.get('repairs/metrics/get_list_work_zone_instrument_by_status' + '?' + queryString)
93
- }
94
- }
95
-
96
- let api: MetricsService
97
-
98
- export default function useMetricsService() {
99
- if (!api) api = new MetricsService()
100
- return api
101
- }
1
+ import ApiService, { ResponseApi } from '@/api/settings/ApiService'
2
+
3
+ class MetricsService extends ApiService {
4
+ public async fetchPieProjects(queryString: string): Promise<ResponseApi<any>> {
5
+ return await this.get('repairs/pie/projects' + '?' + queryString)
6
+ }
7
+
8
+ public async fetchPieTasks(queryString: string): Promise<ResponseApi<any>> {
9
+ return await this.get('repairs/pie/tasks' + '?' + queryString)
10
+ }
11
+
12
+ public async fetchPiePersonnel(queryString: string): Promise<ResponseApi<any>> {
13
+ return await this.get('repairs/metrics/get_list_position' + '?' + queryString)
14
+ }
15
+
16
+ public async fetchPersonnelData(queryString: string): Promise<ResponseApi<any>> {
17
+ return await this.get('repairs/metrics/list_position_intersection_group_by_status' + '?' + queryString)
18
+ }
19
+
20
+ public async fetchPersonnelInfo(params: string): Promise<ResponseApi<any>> {
21
+ return await this.get(`repairs/metrics/list_position_intersection_details?${params}`)
22
+ }
23
+
24
+ public async fetchPiePersonnelInfo(params: string): Promise<any> {
25
+ return await this.get(`repairs/metrics/get_list_user_by_position?${params}`)
26
+ }
27
+
28
+ public async fetchPieCriticalPath(queryString: string): Promise<any[]> {
29
+ return await this.get('repairs/metrics/get_critical_path_group_by_status' + '?' + queryString)
30
+ }
31
+
32
+ public async fetchPieCriticalPathInfo(params: string): Promise<any> {
33
+ return await this.get(`repairs/metrics/get_list_task_critical_path_by_status?${params}`)
34
+ }
35
+
36
+ public async fetchPieTmc(queryString: string): Promise<ResponseApi<any>> {
37
+ return await this.get('repairs/metrics/get_list_instrument_type' + '?' + queryString)
38
+ }
39
+
40
+ public async fetchPieTmcInfo(params: string): Promise<any> {
41
+ return await this.get(`repairs/metrics/get_list_warehouse_by_instrument_type?${params}`)
42
+ }
43
+
44
+ public async fetchPieUntimelyClosedTask(queryString: string): Promise<any[]> {
45
+ return await this.get('repairs/metrics/get_list_comment_type' + '?' + queryString)
46
+ }
47
+
48
+ public async fetchPieUntimelyClosedTaskInfo(params: string): Promise<any> {
49
+ return await this.get(`repairs/metrics/get_list_task_by_comment_type?${params}`)
50
+ }
51
+
52
+ public async fetchPieAdditionalTasks(queryString: string): Promise<any[]> {
53
+ return await this.get('repairs/metrics/get_list_task_after_plan_fixate_group_by_status' + '?' + queryString)
54
+ }
55
+
56
+ public async fetchPieAdditionalTasksInfo(params: string): Promise<any> {
57
+ return await this.get(`repairs/metrics/get_list_task_after_plan_fixate_by_status?${params}`)
58
+ }
59
+
60
+ public async fetchPersonnel(queryString: string): Promise<any[]> {
61
+ return await this.get('repairs/statistic/personnel' + '?' + queryString)
62
+ }
63
+
64
+ public async fetchPieExpired(queryString: string): Promise<any[]> {
65
+ return await this.get('repairs/metrics/get_list_task_expired_group_by_status' + '?' + queryString)
66
+ }
67
+
68
+ public async fetchPieExpiredInfo(params: string): Promise<any> {
69
+ return await this.get(`repairs/metrics/get_list_task_expired?${params}`)
70
+ }
71
+
72
+ public async fetchEconomicsPerformance(params: string): Promise<any> {
73
+ return await this.get(`repairs/metrics/get_economic_performance?${params}`)
74
+ }
75
+
76
+ public async fetchEconomicsInfo(params: string): Promise<any> {
77
+ return await this.get(`repairs/metrics/get_list_task_economic_performance?${params}`)
78
+ }
79
+ public async fetchQualityMetrics(params: string): Promise<any> {
80
+ return await this.get(`repairs/metrics/get_quality_metrics?${params}`)
81
+ }
82
+
83
+ public async fetchQualityInfo(params: string): Promise<any> {
84
+ return await this.get(`repairs/metrics/get_list_task_by_quality?${params}`)
85
+ }
86
+
87
+ public async fetchPieWorkZone(queryString: string): Promise<ResponseApi<any>> {
88
+ return await this.get('repairs/metrics/get_list_work_zone_instrument' + '?' + queryString)
89
+ }
90
+
91
+ public async fetchWorkZoneInfo(queryString: string): Promise<ResponseApi<any>> {
92
+ return await this.get('repairs/metrics/get_list_work_zone_instrument_by_status' + '?' + queryString)
93
+ }
94
+ }
95
+
96
+ let api: MetricsService
97
+
98
+ export default function useMetricsService() {
99
+ if (!api) api = new MetricsService()
100
+ return api
101
+ }
@@ -1,67 +1,67 @@
1
- import ApiService, { ResponseApi } from '@/api/settings/ApiService'
2
-
3
- import { Api_Project_Dto } from '@/api/types/Api_Projects'
4
-
5
- class ProjectsService extends ApiService {
6
- public async fetchProjectById(id: string): Promise<ResponseApi<Api_Project_Dto>> {
7
- return this.get(`/projects/${id}`)
8
- }
9
-
10
- public createProject(params: any): Promise<ResponseApi<any>> {
11
- return this.post<any, ResponseApi<any>>('/projects', params)
12
- }
13
-
14
- public editProject(id: string, params: any): Promise<ResponseApi<any>> {
15
- return this.put<any, ResponseApi<any>>(`/projects/${id}`, params)
16
- }
17
-
18
- public fetchProjects(params: any): Promise<ResponseApi<Api_Project_Dto[]>> {
19
- return this.get(`/get_list_project`, { params })
20
- }
21
-
22
- public cloneProject(project: any): Promise<ResponseApi<any>> {
23
- return this.post<any, ResponseApi<any>>(`projects/${project.id}/clone`, project)
24
- }
25
-
26
- public archiveProject(id: string, data: any): Promise<ResponseApi<any>> {
27
- return this.put<any, ResponseApi<any>>(`/projects/${id}`, data)
28
- }
29
-
30
- public unArchiveProject(id: string, data: any): Promise<ResponseApi<any>> {
31
- return this.put<any, ResponseApi<any>>(`/projects/${id}`, data)
32
- }
33
-
34
- public moveAprProject(id: string): Promise<ResponseApi<any>> {
35
- return this.post<any, ResponseApi<any>>('repairs/move_plan_to_real', {
36
- repairs: [id],
37
- })
38
- }
39
- public restoreProject(id: string): Promise<ResponseApi<any>> {
40
- return this.post<any, ResponseApi<any>>('/restore_project', { projects_ids: [id] })
41
- }
42
-
43
- public importTasks(payload: any): Promise<ResponseApi<any>> {
44
- return this.post<any, ResponseApi<any>>('tasks/import', payload)
45
- }
46
-
47
- public importKtd(payload: any): Promise<ResponseApi<any>> {
48
- return this.post<any, ResponseApi<any>>('/parse_ktd', payload, {
49
- headers: { 'Content-Type': 'multipart/form-data' },
50
- })
51
- }
52
-
53
- public fetchProjectTeamList(id: string): Promise<ResponseApi<any>> {
54
- return this.put<any, ResponseApi<any>>(`/projects/${id}`, null)
55
- }
56
-
57
- public deleteProject(id: string): Promise<any> {
58
- return this.delete<ResponseApi<any>>(`/projects/${id}`)
59
- }
60
- }
61
-
62
- let api: ProjectsService
63
-
64
- export default function useProjectsService() {
65
- if (!api) api = new ProjectsService()
66
- return api
67
- }
1
+ import ApiService, { ResponseApi } from '@/api/settings/ApiService'
2
+
3
+ import { Api_Project_Dto } from '@/api/types/Api_Projects'
4
+
5
+ class ProjectsService extends ApiService {
6
+ public async fetchProjectById(id: string): Promise<ResponseApi<Api_Project_Dto>> {
7
+ return this.get(`/projects/${id}`)
8
+ }
9
+
10
+ public createProject(params: any): Promise<ResponseApi<any>> {
11
+ return this.post<any, ResponseApi<any>>('/projects', params)
12
+ }
13
+
14
+ public editProject(id: string, params: any): Promise<ResponseApi<any>> {
15
+ return this.put<any, ResponseApi<any>>(`/projects/${id}`, params)
16
+ }
17
+
18
+ public fetchProjects(params: any): Promise<ResponseApi<Api_Project_Dto[]>> {
19
+ return this.get(`/search/projects`, { params })
20
+ }
21
+
22
+ public cloneProject(project: any): Promise<ResponseApi<any>> {
23
+ return this.post<any, ResponseApi<any>>(`projects/${project.id}/clone`, project)
24
+ }
25
+
26
+ public archiveProject(id: string, data: any): Promise<ResponseApi<any>> {
27
+ return this.put<any, ResponseApi<any>>(`/projects/${id}`, data)
28
+ }
29
+
30
+ public unArchiveProject(id: string, data: any): Promise<ResponseApi<any>> {
31
+ return this.put<any, ResponseApi<any>>(`/projects/${id}`, data)
32
+ }
33
+
34
+ public moveAprProject(id: string): Promise<ResponseApi<any>> {
35
+ return this.post<any, ResponseApi<any>>('repairs/move_plan_to_real', {
36
+ repairs: [id],
37
+ })
38
+ }
39
+ public restoreProject(id: string): Promise<ResponseApi<any>> {
40
+ return this.post<any, ResponseApi<any>>('/restore_project', { projects_ids: [id] })
41
+ }
42
+
43
+ public importTasks(payload: any): Promise<ResponseApi<any>> {
44
+ return this.post<any, ResponseApi<any>>('tasks/import', payload)
45
+ }
46
+
47
+ public importKtd(payload: any): Promise<ResponseApi<any>> {
48
+ return this.post<any, ResponseApi<any>>('/parse_ktd', payload, {
49
+ headers: { 'Content-Type': 'multipart/form-data' },
50
+ })
51
+ }
52
+
53
+ public fetchProjectTeamList(id: string): Promise<ResponseApi<any>> {
54
+ return this.put<any, ResponseApi<any>>(`/projects/${id}`, null)
55
+ }
56
+
57
+ public deleteProject(id: string): Promise<any> {
58
+ return this.delete<ResponseApi<any>>(`/projects/${id}`)
59
+ }
60
+ }
61
+
62
+ let api: ProjectsService
63
+
64
+ export default function useProjectsService() {
65
+ if (!api) api = new ProjectsService()
66
+ return api
67
+ }
@@ -1,126 +1,126 @@
1
- import axios, { AxiosError, AxiosInstance, AxiosRequestConfig, AxiosResponse, InternalAxiosRequestConfig } from 'axios'
2
-
3
- export enum ApiServiceType {
4
- SERVICE_AUTH = 'SERVICE_AUTH',
5
- }
6
-
7
- export type ResponseApi<T> = {
8
- count: number
9
- current_page: number
10
- data: T
11
- per_page: number
12
- total: number
13
- total_pages: number
14
- }
15
-
16
- export default class ApiService {
17
- private axiosInstance: AxiosInstance
18
-
19
- constructor() {
20
- this.axiosInstance = axios.create({
21
- baseURL: process.env.VUE_APP_BACKEND,
22
- headers: {
23
- 'Content-Type': 'application/json',
24
- Accept: 'application/json',
25
- },
26
- })
27
-
28
- this.axiosInstance.interceptors.request.use(
29
- (config: InternalAxiosRequestConfig) => {
30
- const token = this.getToken()
31
- if (token && config.headers) {
32
- config.headers.Authorization = `Bearer ${token}`
33
- }
34
- return config
35
- },
36
- (error: AxiosError) => {
37
- return Promise.reject(error)
38
- },
39
- )
40
-
41
- this.axiosInstance.interceptors.response.use(
42
- (response: AxiosResponse) => {
43
- return response.data
44
- },
45
- (error: AxiosError) => {
46
- if (error.response?.status === 401 || error.response?.status === 403) {
47
- this.logout()
48
- }
49
- return Promise.reject(error)
50
- },
51
- )
52
- }
53
-
54
- private getToken() {
55
- return localStorage.getItem('token')
56
- }
57
-
58
- private removeToken() {
59
- localStorage.removeItem('token')
60
- }
61
-
62
- public logout(): void {
63
- this.removeToken()
64
- window.location.href = '/sign-in'
65
- }
66
-
67
- private handleError(error: AxiosError): void {
68
- if (error.response) {
69
- console.error('API Error:', error.response.status, error.response.data)
70
- } else if (error.request) {
71
- console.error('No response received:', error.request)
72
- } else {
73
- console.error('Error during request setup:', error.message)
74
- }
75
- }
76
-
77
- protected async get<T>(url: string, options?: AxiosRequestConfig) {
78
- try {
79
- const response: AxiosResponse<T> = await this.axiosInstance.get<T>(url, options)
80
- return response?.data ?? (response as unknown as T)
81
- } catch (error) {
82
- const axiosError = error as AxiosError
83
- this.handleError(axiosError)
84
- throw error
85
- }
86
- }
87
-
88
- protected async delete<T>(url: string, options?: AxiosRequestConfig) {
89
- try {
90
- return await this.axiosInstance.delete<T>(url, options)
91
- } catch (error) {
92
- const axiosError = error as AxiosError
93
- this.handleError(axiosError)
94
- throw error
95
- }
96
- }
97
-
98
- protected async post<T1, T2>(url: string, payload: T1, options?: AxiosRequestConfig) {
99
- try {
100
- const response: AxiosResponse<T2> = await this.axiosInstance.post<T1, AxiosResponse<T2>>(url, payload, options)
101
- return response.data
102
- } catch (error) {
103
- const axiosError = error as AxiosError
104
- this.handleError(axiosError)
105
- throw error
106
- }
107
- }
108
-
109
- // protected patch<T1, T2>(url: string, payload: T1, type: ApiServiceType, options?: AxiosRequestConfig): Promise<T2> {
110
- // return axios
111
- // .patch<T1, AxiosResponse<T2>>(apiServiceUrls[type] + url, payload, options)
112
- // .catch((err: AxiosError) => processError401<T2>(err))
113
- // .then(extractData)
114
- // }
115
- //
116
- protected async put<T1, T2>(url: string, payload: T1, options?: AxiosRequestConfig) {
117
- try {
118
- const response: AxiosResponse<T2> = await this.axiosInstance.put<T1, AxiosResponse<T2>>(url, payload, options)
119
- return response.data
120
- } catch (error) {
121
- const axiosError = error as AxiosError
122
- this.handleError(axiosError)
123
- throw error
124
- }
125
- }
126
- }
1
+ import axios, { AxiosError, AxiosInstance, AxiosRequestConfig, AxiosResponse, InternalAxiosRequestConfig } from 'axios'
2
+
3
+ export enum ApiServiceType {
4
+ SERVICE_AUTH = 'SERVICE_AUTH',
5
+ }
6
+
7
+ export type ResponseApi<T> = {
8
+ count: number
9
+ current_page: number
10
+ data: T
11
+ per_page: number
12
+ total: number
13
+ total_pages: number
14
+ }
15
+
16
+ export default class ApiService {
17
+ private axiosInstance: AxiosInstance
18
+
19
+ constructor() {
20
+ this.axiosInstance = axios.create({
21
+ baseURL: process.env.VUE_APP_BACKEND,
22
+ headers: {
23
+ 'Content-Type': 'application/json',
24
+ Accept: 'application/json',
25
+ },
26
+ })
27
+
28
+ this.axiosInstance.interceptors.request.use(
29
+ (config: InternalAxiosRequestConfig) => {
30
+ const token = this.getToken()
31
+ if (token && config.headers) {
32
+ config.headers.Authorization = `Bearer ${token}`
33
+ }
34
+ return config
35
+ },
36
+ (error: AxiosError) => {
37
+ return Promise.reject(error)
38
+ },
39
+ )
40
+
41
+ this.axiosInstance.interceptors.response.use(
42
+ (response: AxiosResponse) => {
43
+ return response.data
44
+ },
45
+ (error: AxiosError) => {
46
+ if (error.response?.status === 401 || error.response?.status === 403) {
47
+ this.logout()
48
+ }
49
+ return Promise.reject(error)
50
+ },
51
+ )
52
+ }
53
+
54
+ private getToken() {
55
+ return localStorage.getItem('token')
56
+ }
57
+
58
+ private removeToken() {
59
+ localStorage.removeItem('token')
60
+ }
61
+
62
+ public logout(): void {
63
+ this.removeToken()
64
+ window.location.href = '/sign-in'
65
+ }
66
+
67
+ private handleError(error: AxiosError): void {
68
+ if (error.response) {
69
+ console.error('API Error:', error.response.status, error.response.data)
70
+ } else if (error.request) {
71
+ console.error('No response received:', error.request)
72
+ } else {
73
+ console.error('Error during request setup:', error.message)
74
+ }
75
+ }
76
+
77
+ protected async get<T>(url: string, options?: AxiosRequestConfig) {
78
+ try {
79
+ const response: AxiosResponse<T> = await this.axiosInstance.get<T>(url, options)
80
+ return response?.data ?? (response as unknown as T)
81
+ } catch (error) {
82
+ const axiosError = error as AxiosError
83
+ this.handleError(axiosError)
84
+ throw error
85
+ }
86
+ }
87
+
88
+ protected async delete<T>(url: string, options?: AxiosRequestConfig) {
89
+ try {
90
+ return await this.axiosInstance.delete<T>(url, options)
91
+ } catch (error) {
92
+ const axiosError = error as AxiosError
93
+ this.handleError(axiosError)
94
+ throw error
95
+ }
96
+ }
97
+
98
+ protected async post<T1, T2>(url: string, payload: T1, options?: AxiosRequestConfig) {
99
+ try {
100
+ const response: AxiosResponse<T2> = await this.axiosInstance.post<T1, AxiosResponse<T2>>(url, payload, options)
101
+ return response.data
102
+ } catch (error) {
103
+ const axiosError = error as AxiosError
104
+ this.handleError(axiosError)
105
+ throw error
106
+ }
107
+ }
108
+
109
+ // protected patch<T1, T2>(url: string, payload: T1, type: ApiServiceType, options?: AxiosRequestConfig): Promise<T2> {
110
+ // return axios
111
+ // .patch<T1, AxiosResponse<T2>>(apiServiceUrls[type] + url, payload, options)
112
+ // .catch((err: AxiosError) => processError401<T2>(err))
113
+ // .then(extractData)
114
+ // }
115
+ //
116
+ protected async put<T1, T2>(url: string, payload: T1, options?: AxiosRequestConfig) {
117
+ try {
118
+ const response: AxiosResponse<T2> = await this.axiosInstance.put<T1, AxiosResponse<T2>>(url, payload, options)
119
+ return response.data
120
+ } catch (error) {
121
+ const axiosError = error as AxiosError
122
+ this.handleError(axiosError)
123
+ throw error
124
+ }
125
+ }
126
+ }
@@ -1 +1 @@
1
- export type Api_Files_Responsible_Dto = unknown
1
+ export type Api_Files_Responsible_Dto = unknown