Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
backoffice_client
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
web-et-numerique
Factory
LLLE_Project
backoffice_client
Commits
afbd18c3
Commit
afbd18c3
authored
1 year ago
by
Bastien DUMONT
Browse files
Options
Downloads
Patches
Plain Diff
refactor: move sge consent route
parent
2912d84c
No related branches found
No related tags found
1 merge request
!141
Release 2024-02-29
Pipeline
#90138
failed
1 year ago
Stage: build
Stage: build-push
Stage: deploy
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/services/sgeConsent.service.ts
+87
-0
87 additions, 0 deletions
src/services/sgeConsent.service.ts
with
87 additions
and
0 deletions
src/services/sgeConsent.service.ts
0 → 100644
+
87
−
0
View file @
afbd18c3
import
axios
,
{
AxiosRequestConfig
}
from
'
axios
'
import
{
DateTime
}
from
'
luxon
'
import
{
toast
}
from
'
react-toastify
'
import
{
ISgeConsent
,
ISgeConsentPagination
,
SgeConsentEntity
,
SgeConsentPaginationEntity
,
}
from
'
../models/sgeConsent.model
'
export
class
SgeConsentService
{
/**
* Search for consents
* @param search
* @param limit
* @param page
* @param axiosHeaders
*/
public
searchConsents
=
async
(
search
:
string
,
limit
:
number
,
page
:
number
,
axiosHeaders
:
AxiosRequestConfig
):
Promise
<
ISgeConsentPagination
|
null
>
=>
{
try
{
const
{
data
}
=
await
axios
.
get
(
`/api/admin/sge/consent?search=
${
search
}
&limit=
${
limit
}
&page=
${
page
}
`
,
axiosHeaders
)
const
consentPagination
=
data
as
SgeConsentPaginationEntity
return
this
.
parseConsentPagination
(
consentPagination
)
}
catch
(
e
)
{
if
(
e
.
response
.
status
===
403
)
{
toast
.
error
(
"
Accès refusé : vous n'avez pas les droits nécessaires
"
)
}
else
{
toast
.
error
(
'
Erreur lors de la récupération des consentements
'
)
}
console
.
error
(
e
)
return
null
}
}
/**
* Converts consent entity into consent
* @param consentEntity
*/
public
parseConsent
=
(
consentEntity
:
SgeConsentEntity
):
ISgeConsent
=>
{
const
startDate
=
DateTime
.
fromISO
(
consentEntity
.
CreatedAt
,
{
zone
:
'
utc
'
,
}).
setLocale
(
'
fr-FR
'
)
const
endDate
=
DateTime
.
fromISO
(
consentEntity
.
endDate
,
{
zone
:
'
utc
'
,
}).
setLocale
(
'
fr-FR
'
)
return
{
ID
:
consentEntity
.
ID
,
startDate
:
startDate
,
endDate
:
endDate
,
firstname
:
consentEntity
.
firstname
,
lastname
:
consentEntity
.
lastname
,
pointID
:
consentEntity
.
pointID
,
address
:
consentEntity
.
address
,
postalCode
:
consentEntity
.
postalCode
,
city
:
consentEntity
.
city
,
safetyOnBoarding
:
consentEntity
.
safetyOnBoarding
,
}
}
/**
* Converts consent pagination entity into consent pagination
* @param consentPaginationEntity
*/
public
parseConsentPagination
=
(
consentPaginationEntity
:
SgeConsentPaginationEntity
):
ISgeConsentPagination
=>
{
const
rows
=
consentPaginationEntity
.
rows
.
map
(
consent
=>
this
.
parseConsent
(
consent
)
)
const
consentPagination
:
ISgeConsentPagination
=
{
rows
:
rows
,
totalRows
:
consentPaginationEntity
.
totalRows
,
totalPages
:
consentPaginationEntity
.
totalPages
,
}
return
consentPagination
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment