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
979c4243
Commit
979c4243
authored
Aug 19, 2021
by
Sebastián Long
Browse files
Options
Browse Files
Download
Plain Diff
Finish ordenar-provincias
parents
0fd49a6d
ba1cb95c
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
18 additions
and
15 deletions
+18
-15
is.js
endpoints/is.js
+12
-15
package-lock.json
package-lock.json
+5
-0
package.json
package.json
+1
-0
No files found.
endpoints/is.js
View file @
979c4243
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
);
...
...
package-lock.json
View file @
979c4243
...
...
@@ -716,6 +716,11 @@
"package-json"
:
"^6.3.0"
}
},
"lodash"
:
{
"version"
:
"4.17.21"
,
"resolved"
:
"https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz"
,
"integrity"
:
"sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg=="
},
"loose-envify"
:
{
"version"
:
"1.4.0"
,
"resolved"
:
"https://registry.npmjs.org/loose-envify/-/loose-envify-1.4.0.tgz"
,
...
...
package.json
View file @
979c4243
...
...
@@ -13,6 +13,7 @@
"dependencies"
:
{
"
axios
"
:
"
^0.21.1
"
,
"
config
"
:
"
^3.3.6
"
,
"
lodash
"
:
"
^4.17.21
"
,
"
node-crisp-api
"
:
"
^1.12.2
"
},
"devDependencies"
:
{
...
...
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