Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
N
node_crisp
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
web
node_crisp
Commits
ba1cb95c
You need to sign in or sign up before continuing.
Commit
ba1cb95c
authored
Aug 19, 2021
by
Gabriel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Cambia orden de provincias
parent
01577297
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
15 deletions
+12
-15
is.js
endpoints/is.js
+12
-15
No files found.
endpoints/is.js
View file @
ba1cb95c
const
config
=
require
(
'config'
);
const
axios
=
require
(
'axios'
);
let
_
=
require
(
'lodash'
);
var
AUTH_TOKEN
=
config
.
get
(
'credenciales.isApiToken'
);
...
...
@@ -8,21 +9,17 @@ let isClient = axios.create({
headers
:
{
'Authorization'
:
`Bearer
${
AUTH_TOKEN
}
`
}
});
function
sortProvinciasById
(
provincias
)
{
let
ids
=
[];
for
(
let
i
=
0
;
i
<
provincias
.
length
;
i
++
)
{
ids
.
push
(
provincias
[
i
].
id_provincia
);
}
const
CABA
=
"CIUDAD AUTONOMA DE BUENOS AIRES"
;
const
BUENOS_AIRES
=
"BUENOS AIRES"
;
const
MISIONES
=
"MISIONES"
;
ids
.
sort
(
function
(
a
,
b
)
{
return
parseInt
(
a
)
-
parseInt
(
b
)
});
let
sortedProvincias
=
[];
for
(
let
i
=
0
;
i
<
ids
.
length
;
i
++
)
{
sortedProvincias
.
push
(
getProvinciaById
(
provincias
,
ids
[
i
]));
}
return
sortedProvincias
;
function
sortProvinciasByName
(
provincias
){
//Orden alfabetico, pero con (1) CABA, (2) Buenos Aires y (3) Misiones al principio
let
provinciasByName
=
_
.
orderBy
(
provincias
,
[
provincia
=>
provincia
.
descripcion
],
[
'asc'
]);
provinciasByName
=
_
.
sortBy
(
provinciasByName
,
({
descripcion
})
=>
descripcion
===
MISIONES
?
0
:
1
);
provinciasByName
=
_
.
sortBy
(
provinciasByName
,
({
descripcion
})
=>
descripcion
===
BUENOS_AIRES
?
0
:
1
);
provinciasByName
=
_
.
sortBy
(
provinciasByName
,
({
descripcion
})
=>
descripcion
===
CABA
?
0
:
1
);
return
provinciasByName
;
}
function
getProvinciaById
(
provincias
,
id
)
{
...
...
@@ -39,7 +36,7 @@ module.exports =
return
await
isClient
.
get
(
'provincias/atencion'
)
.
then
(
async
function
(
response
)
{
let
provincias
=
response
.
data
;
return
sortProvinciasBy
Id
(
provincias
);
return
sortProvinciasBy
Name
(
provincias
);
})
.
catch
(
function
(
error
)
{
console
.
log
(
error
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment