Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Ecolyo
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
Ecolyo
Commits
df755292
Commit
df755292
authored
3 years ago
by
Guilhem CARRON
Browse files
Options
Downloads
Patches
Plain Diff
fix(init): Prevent backoffice issue to make the app crash
parent
c523f78a
No related branches found
No related tags found
2 merge requests
!610
chore(release): 1.9.3
,
!607
Fix/1.9.1
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/services/partnersInfo.service.spec.ts
+3
-1
3 additions, 1 deletion
src/services/partnersInfo.service.spec.ts
src/services/partnersInfo.service.ts
+3
-17
3 additions, 17 deletions
src/services/partnersInfo.service.ts
with
6 additions
and
18 deletions
src/services/partnersInfo.service.spec.ts
+
3
−
1
View file @
df755292
...
...
@@ -14,7 +14,9 @@ describe('PartnersInfo service', () => {
const
partnersInfoService
=
new
PartnersInfoService
(
mockClient
)
it
(
'
should return partnersInfo
'
,
async
()
=>
{
const
result
:
PartnersInfo
=
await
partnersInfoService
.
getPartnersInfo
()
const
result
:
|
PartnersInfo
|
undefined
=
await
partnersInfoService
.
getPartnersInfo
()
expect
(
result
).
toEqual
(
undefined
)
})
it
(
'
should return an error
'
,
async
()
=>
{
...
...
This diff is collapsed.
Click to expand it.
src/services/partnersInfo.service.ts
+
3
−
17
View file @
df755292
import
{
Client
}
from
'
cozy-client
'
import
{
InitStepsErrors
}
from
'
models/initialisationSteps.model
'
import
{
PartnersInfo
}
from
'
models/partnersInfo.model
'
import
EnvironmentService
from
'
./environment.service
'
export
default
class
PartnersInfoService
{
private
readonly
_client
:
Client
private
readonly
_setinitStepError
?:
React
.
Dispatch
<
React
.
SetStateAction
<
InitStepsErrors
|
null
>
>
constructor
(
_client
:
Client
,
_setinitStepError
?:
React
.
Dispatch
<
React
.
SetStateAction
<
InitStepsErrors
|
null
>
>
)
{
constructor
(
_client
:
Client
)
{
this
.
_client
=
_client
this
.
_setinitStepError
=
_setinitStepError
}
/*
...
...
@@ -24,7 +13,7 @@ export default class PartnersInfoService {
* On success, respond the partnersInfo
* Else, throw an error
*/
public
async
getPartnersInfo
():
Promise
<
PartnersInfo
>
{
public
async
getPartnersInfo
():
Promise
<
PartnersInfo
|
undefined
>
{
const
env
=
new
EnvironmentService
()
const
remoteUrl
=
env
.
isProduction
()
?
`/remote/org.ecolyo.backoffice.partners.info`
...
...
@@ -35,10 +24,7 @@ export default class PartnersInfoService {
.
fetchJSON
(
'
GET
'
,
remoteUrl
)
return
result
as
PartnersInfo
}
catch
(
error
)
{
this
.
_setinitStepError
&&
this
.
_setinitStepError
(
InitStepsErrors
.
PARTNERS_ERROR
)
console
.
error
(
error
)
throw
new
Error
(
"
Failed to get partners' info
"
)
console
.
error
(
`getPartnersInfo: Failed to get partners info:
${
error
}
`
)
}
}
}
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