@softdin/shared 0.1.3 → 0.3.0
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.
- package/package.json +16 -3
- package/src/components/forms/FormMaximizeButton.vue +143 -143
- package/src/components/navigation/CatalogListPagination.vue +113 -113
- package/src/lib/catalog-pagination.ts +27 -27
- package/src/style.css +278 -278
- package/src/types/auth.ts +147 -146
- package/src/types/softdin-libreria.d.ts +2 -1
- package/src/utils/apiError.ts +55 -55
- package/src/utils/connectivity.ts +33 -33
package/src/types/auth.ts
CHANGED
|
@@ -1,146 +1,147 @@
|
|
|
1
|
-
export interface Tenant {
|
|
2
|
-
id: string
|
|
3
|
-
name: string
|
|
4
|
-
slug: string
|
|
5
|
-
database: string
|
|
6
|
-
status: string
|
|
7
|
-
has_logo?: boolean
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
1
|
+
export interface Tenant {
|
|
2
|
+
id: string
|
|
3
|
+
name: string
|
|
4
|
+
slug: string
|
|
5
|
+
database: string
|
|
6
|
+
status: string
|
|
7
|
+
has_logo?: boolean
|
|
8
|
+
/** Id de EnumRolTenant (1 owner, 2 admin, 3 member, 4 viewer). */
|
|
9
|
+
role?: number
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export interface User {
|
|
13
|
+
id: number
|
|
14
|
+
name: string
|
|
15
|
+
email: string
|
|
16
|
+
is_admin?: boolean
|
|
17
|
+
is_superuser?: boolean
|
|
18
|
+
is_platform_admin?: boolean
|
|
19
|
+
has_avatar?: boolean
|
|
20
|
+
requires_data_processing_consent?: boolean
|
|
21
|
+
data_processing_consent_accepted_at?: string | null
|
|
22
|
+
data_processing_consent_version?: string | null
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export interface PublicTenant {
|
|
26
|
+
id: string
|
|
27
|
+
name: string
|
|
28
|
+
slug: string
|
|
29
|
+
has_logo?: boolean
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export interface RegisterPayload {
|
|
33
|
+
name: string
|
|
34
|
+
email: string
|
|
35
|
+
tenant_mode: 'new' | 'existing'
|
|
36
|
+
tenant_slug: string
|
|
37
|
+
tenant_name?: string
|
|
38
|
+
tenant_domain?: string
|
|
39
|
+
migrate?: boolean
|
|
40
|
+
seed?: boolean
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export interface PublicTenantsResponse {
|
|
44
|
+
tenants: PublicTenant[]
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export interface RegisterResponse {
|
|
48
|
+
message: string
|
|
49
|
+
user: User
|
|
50
|
+
mail_sent?: boolean
|
|
51
|
+
debug_activation_url?: string
|
|
52
|
+
debug_mail_error?: string
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export interface ForgotPasswordResponse {
|
|
56
|
+
message: string
|
|
57
|
+
debug_reset_url?: string
|
|
58
|
+
debug_mail_error?: string
|
|
59
|
+
debug_mail_hint?: string
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export interface ResetPasswordPayload {
|
|
63
|
+
email: string
|
|
64
|
+
token: string
|
|
65
|
+
password: string
|
|
66
|
+
password_confirmation: string
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export interface MessageResponse {
|
|
70
|
+
message: string
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
export interface CentralAdminLoginCredentials {
|
|
74
|
+
email: string
|
|
75
|
+
password: string
|
|
76
|
+
data_processing_consent_accepted?: boolean
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
export interface LoginCredentials {
|
|
80
|
+
email: string
|
|
81
|
+
password: string
|
|
82
|
+
tenant: string
|
|
83
|
+
data_processing_consent_accepted?: boolean
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
export interface UpdateProfilePayload {
|
|
87
|
+
name: string
|
|
88
|
+
password?: string
|
|
89
|
+
password_confirmation?: string
|
|
90
|
+
current_password?: string
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
export interface ProfileUpdateResponse {
|
|
94
|
+
user: User
|
|
95
|
+
message: string
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
export interface ProfilePhotoResponse {
|
|
99
|
+
user: User
|
|
100
|
+
message: string
|
|
101
|
+
avatar_size?: number
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
export interface CentralLoginResponse {
|
|
105
|
+
user: User
|
|
106
|
+
tenants: Tenant[]
|
|
107
|
+
tenant_selection_required?: boolean
|
|
108
|
+
central_access_available?: boolean
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
export interface AuthResponse {
|
|
112
|
+
token: string
|
|
113
|
+
user: User
|
|
114
|
+
tenants: Tenant[]
|
|
115
|
+
active_tenant: Tenant | null
|
|
116
|
+
session_mode?: 'tenant' | 'central' | null
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
export interface MeResponse {
|
|
120
|
+
user: User
|
|
121
|
+
tenants: Tenant[]
|
|
122
|
+
active_tenant: Tenant | null
|
|
123
|
+
token_tenant?: Tenant | null
|
|
124
|
+
session_mode?: 'tenant' | 'central' | null
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
export interface TenantLogoResponse {
|
|
128
|
+
tenant: Tenant
|
|
129
|
+
message: string
|
|
130
|
+
logo_size?: number
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
export interface DataProcessingConsentPolicy {
|
|
134
|
+
version: string
|
|
135
|
+
title: string
|
|
136
|
+
summary: string
|
|
137
|
+
paragraphs: string[]
|
|
138
|
+
accepted?: boolean
|
|
139
|
+
accepted_at?: string | null
|
|
140
|
+
accepted_version?: string | null
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
export interface DataProcessingConsentResponse {
|
|
144
|
+
message: string
|
|
145
|
+
accepted: boolean
|
|
146
|
+
user?: User
|
|
147
|
+
}
|
|
@@ -32,7 +32,8 @@ declare module 'softdinlibreriajs/src/EnumTipoContrato.js' {
|
|
|
32
32
|
static readonly APRENDIZAJE: number
|
|
33
33
|
static readonly OBRA_LABOR: number
|
|
34
34
|
static readonly PRACTICAS_PASANTIAS: number
|
|
35
|
-
static readonly ASOCIACION: number
|
|
35
|
+
// static readonly ASOCIACION: number <- comentado en softdinlibreriajs:
|
|
36
|
+
// no tiene equivalente en el catalogo DIAN de nomina electronica.
|
|
36
37
|
|
|
37
38
|
static getAll(): EnumTipoContratoItem[]
|
|
38
39
|
static getById(id: number): EnumTipoContratoItem | null
|
package/src/utils/apiError.ts
CHANGED
|
@@ -1,55 +1,55 @@
|
|
|
1
|
-
import axios from 'axios'
|
|
2
|
-
import { getConnectivityMessage } from './connectivity'
|
|
3
|
-
|
|
4
|
-
export * from './connectivity'
|
|
5
|
-
|
|
6
|
-
export function extractAxiosErrorMessage(error: unknown, fallback: string): string {
|
|
7
|
-
const connectivityMessage = getConnectivityMessage(error)
|
|
8
|
-
if (connectivityMessage) {
|
|
9
|
-
return connectivityMessage
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
if (!axios.isAxiosError(error) || !error.response) {
|
|
13
|
-
return fallback
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
const status = error.response.status
|
|
17
|
-
const data = error.response.data
|
|
18
|
-
|
|
19
|
-
if (typeof data === 'object' && data !== null) {
|
|
20
|
-
const payload = data as { message?: string; errors?: Record<string, string[]> }
|
|
21
|
-
const firstFieldError = payload.errors
|
|
22
|
-
? Object.values(payload.errors).flat()[0]
|
|
23
|
-
: undefined
|
|
24
|
-
|
|
25
|
-
if (firstFieldError) {
|
|
26
|
-
return firstFieldError
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
if (typeof payload.message === 'string' && payload.message.trim() !== '') {
|
|
30
|
-
return payload.message
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
if (status === 500) {
|
|
35
|
-
return 'Error interno del servidor. Revise storage/logs/laravel.log en softdin-api.'
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
if (status === 503) {
|
|
39
|
-
return 'El servicio no está disponible en este momento.'
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
if (status === 419) {
|
|
43
|
-
return 'La sesión expiró. Recargue la página e intente de nuevo.'
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
if (typeof data === 'string' && data.trim() !== '') {
|
|
47
|
-
if (data.includes('<!DOCTYPE html>') || data.includes('<html')) {
|
|
48
|
-
return `${fallback} (HTTP ${status}: el servidor respondió HTML, no JSON).`
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
return fallback
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
return `${fallback} (HTTP ${status}).`
|
|
55
|
-
}
|
|
1
|
+
import axios from 'axios'
|
|
2
|
+
import { getConnectivityMessage } from './connectivity'
|
|
3
|
+
|
|
4
|
+
export * from './connectivity'
|
|
5
|
+
|
|
6
|
+
export function extractAxiosErrorMessage(error: unknown, fallback: string): string {
|
|
7
|
+
const connectivityMessage = getConnectivityMessage(error)
|
|
8
|
+
if (connectivityMessage) {
|
|
9
|
+
return connectivityMessage
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
if (!axios.isAxiosError(error) || !error.response) {
|
|
13
|
+
return fallback
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const status = error.response.status
|
|
17
|
+
const data = error.response.data
|
|
18
|
+
|
|
19
|
+
if (typeof data === 'object' && data !== null) {
|
|
20
|
+
const payload = data as { message?: string; errors?: Record<string, string[]> }
|
|
21
|
+
const firstFieldError = payload.errors
|
|
22
|
+
? Object.values(payload.errors).flat()[0]
|
|
23
|
+
: undefined
|
|
24
|
+
|
|
25
|
+
if (firstFieldError) {
|
|
26
|
+
return firstFieldError
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
if (typeof payload.message === 'string' && payload.message.trim() !== '') {
|
|
30
|
+
return payload.message
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
if (status === 500) {
|
|
35
|
+
return 'Error interno del servidor. Revise storage/logs/laravel.log en softdin-api.'
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
if (status === 503) {
|
|
39
|
+
return 'El servicio no está disponible en este momento.'
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
if (status === 419) {
|
|
43
|
+
return 'La sesión expiró. Recargue la página e intente de nuevo.'
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
if (typeof data === 'string' && data.trim() !== '') {
|
|
47
|
+
if (data.includes('<!DOCTYPE html>') || data.includes('<html')) {
|
|
48
|
+
return `${fallback} (HTTP ${status}: el servidor respondió HTML, no JSON).`
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
return fallback
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
return `${fallback} (HTTP ${status}).`
|
|
55
|
+
}
|
|
@@ -1,33 +1,33 @@
|
|
|
1
|
-
import axios from 'axios'
|
|
2
|
-
|
|
3
|
-
let backendReachable = false
|
|
4
|
-
|
|
5
|
-
export function markBackendReachable(): void {
|
|
6
|
-
backendReachable = true
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
export function hasReachedBackend(): boolean {
|
|
10
|
-
return backendReachable
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
function isBrowserOffline(): boolean {
|
|
14
|
-
return typeof navigator !== 'undefined' && navigator.onLine === false
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export function isConnectivityError(error: unknown): boolean {
|
|
18
|
-
if (axios.isAxiosError(error)) {
|
|
19
|
-
return !error.response
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
return isBrowserOffline()
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export function getConnectivityMessage(error: unknown): string | null {
|
|
26
|
-
if (!isConnectivityError(error)) {
|
|
27
|
-
return null
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
return hasReachedBackend()
|
|
31
|
-
? 'Se perdió la conexión con el servidor. Verifique su red e intente nuevamente.'
|
|
32
|
-
: 'No hay conexión con el servidor. Verifique su red e intente nuevamente.'
|
|
33
|
-
}
|
|
1
|
+
import axios from 'axios'
|
|
2
|
+
|
|
3
|
+
let backendReachable = false
|
|
4
|
+
|
|
5
|
+
export function markBackendReachable(): void {
|
|
6
|
+
backendReachable = true
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export function hasReachedBackend(): boolean {
|
|
10
|
+
return backendReachable
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
function isBrowserOffline(): boolean {
|
|
14
|
+
return typeof navigator !== 'undefined' && navigator.onLine === false
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export function isConnectivityError(error: unknown): boolean {
|
|
18
|
+
if (axios.isAxiosError(error)) {
|
|
19
|
+
return !error.response
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
return isBrowserOffline()
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export function getConnectivityMessage(error: unknown): string | null {
|
|
26
|
+
if (!isConnectivityError(error)) {
|
|
27
|
+
return null
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
return hasReachedBackend()
|
|
31
|
+
? 'Se perdió la conexión con el servidor. Verifique su red e intente nuevamente.'
|
|
32
|
+
: 'No hay conexión con el servidor. Verifique su red e intente nuevamente.'
|
|
33
|
+
}
|