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
73a16644
Commit
73a16644
authored
3 years ago
by
Rémi PAILHAREY
Browse files
Options
Downloads
Patches
Plain Diff
fix: changed month range from [0;11] to [1;12]
parent
3a6b22c7
No related branches found
No related tags found
3 merge requests
!24
fix(typo): écogestes + optionnel poll
,
!22
feat: Add partners issue info
,
!14
Fix requested month is -1
Pipeline
#16481
passed
3 years ago
Stage: build
Stage: quality
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/components/Editing/Editing.tsx
+6
-27
6 additions, 27 deletions
src/components/Editing/Editing.tsx
src/services/newsletter.service.ts
+52
-46
52 additions, 46 deletions
src/services/newsletter.service.ts
with
58 additions
and
73 deletions
src/components/Editing/Editing.tsx
+
6
−
27
View file @
73a16644
...
@@ -67,31 +67,19 @@ const Editing: React.FC = () => {
...
@@ -67,31 +67,19 @@ const Editing: React.FC = () => {
const
handleDeleteMonthlyInfo
=
async
():
Promise
<
void
>
=>
{
const
handleDeleteMonthlyInfo
=
async
():
Promise
<
void
>
=>
{
if
(
user
)
{
if
(
user
)
{
await
newsletterService
.
deleteMonthlyInfo
(
await
newsletterService
.
deleteMonthlyInfo
(
date
,
user
.
xsrftoken
)
date
.
getFullYear
(),
date
.
getMonth
(),
user
.
xsrftoken
)
setRefreshData
(
true
)
setRefreshData
(
true
)
}
}
}
}
const
handleDeleteMonthlyNews
=
async
():
Promise
<
void
>
=>
{
const
handleDeleteMonthlyNews
=
async
():
Promise
<
void
>
=>
{
if
(
user
)
{
if
(
user
)
{
await
newsletterService
.
deleteMonthlyNews
(
await
newsletterService
.
deleteMonthlyNews
(
date
,
user
.
xsrftoken
)
date
.
getFullYear
(),
date
.
getMonth
(),
user
.
xsrftoken
)
setRefreshData
(
true
)
setRefreshData
(
true
)
}
}
}
}
const
handleDeletePoll
=
async
():
Promise
<
void
>
=>
{
const
handleDeletePoll
=
async
():
Promise
<
void
>
=>
{
if
(
user
)
{
if
(
user
)
{
await
newsletterService
.
deletePoll
(
await
newsletterService
.
deletePoll
(
date
,
user
.
xsrftoken
)
date
.
getFullYear
(),
date
.
getMonth
(),
user
.
xsrftoken
)
setRefreshData
(
true
)
setRefreshData
(
true
)
}
}
}
}
...
@@ -167,20 +155,11 @@ const Editing: React.FC = () => {
...
@@ -167,20 +155,11 @@ const Editing: React.FC = () => {
if
(
user
)
{
if
(
user
)
{
const
newsletterService
=
new
NewsletterService
()
const
newsletterService
=
new
NewsletterService
()
const
montlhyInfo
:
IMonthlyInfo
|
null
=
const
montlhyInfo
:
IMonthlyInfo
|
null
=
await
newsletterService
.
getSingleMonthlyInfo
(
await
newsletterService
.
getSingleMonthlyInfo
(
date
,
user
.
xsrftoken
)
date
.
getFullYear
(),
date
.
getMonth
(),
user
.
xsrftoken
)
const
montlhyNews
:
IMonthlyNews
|
null
=
const
montlhyNews
:
IMonthlyNews
|
null
=
await
newsletterService
.
getSingleMonthlyNews
(
await
newsletterService
.
getSingleMonthlyNews
(
date
,
user
.
xsrftoken
)
date
.
getFullYear
(),
date
.
getMonth
(),
user
.
xsrftoken
)
const
poll
:
IPoll
|
null
=
await
newsletterService
.
getSinglePoll
(
const
poll
:
IPoll
|
null
=
await
newsletterService
.
getSinglePoll
(
date
.
getFullYear
(),
date
,
date
.
getMonth
(),
user
.
xsrftoken
user
.
xsrftoken
)
)
if
(
montlhyInfo
)
{
if
(
montlhyInfo
)
{
...
...
This diff is collapsed.
Click to expand it.
src/services/newsletter.service.ts
+
52
−
46
View file @
73a16644
...
@@ -19,7 +19,7 @@ export class NewsletterService {
...
@@ -19,7 +19,7 @@ export class NewsletterService {
await
axios
.
put
(
await
axios
.
put
(
`/api/admin/monthlyInfo`
,
`/api/admin/monthlyInfo`
,
{
{
month
:
date
.
getMonth
(),
month
:
date
.
getMonth
()
+
1
,
year
:
date
.
getFullYear
(),
year
:
date
.
getFullYear
(),
info
:
info
,
info
:
info
,
image
:
image
,
image
:
image
,
...
@@ -39,15 +39,16 @@ export class NewsletterService {
...
@@ -39,15 +39,16 @@ export class NewsletterService {
/**
/**
* Gets the information for selected month
* Gets the information for selected month
* @param date
* @param token
*/
*/
public
getSingleMonthlyInfo
=
async
(
public
getSingleMonthlyInfo
=
async
(
year
:
number
,
date
:
Date
,
month
:
number
,
token
:
string
token
:
string
):
Promise
<
IMonthlyInfo
|
null
>
=>
{
):
Promise
<
IMonthlyInfo
|
null
>
=>
{
try
{
try
{
const
{
data
}
=
await
axios
.
get
(
const
{
data
}
=
await
axios
.
get
(
`/api/admin/monthlyInfo/
${
y
ear
}
/
${
month
}
`
,
`/api/admin/monthlyInfo/
${
date
.
getFullY
ear
()
}
/
${
date
.
getMonth
()
+
1
}
`
,
{
{
headers
:
{
headers
:
{
'
XSRF-TOKEN
'
:
token
,
'
XSRF-TOKEN
'
:
token
,
...
@@ -63,21 +64,22 @@ export class NewsletterService {
...
@@ -63,21 +64,22 @@ export class NewsletterService {
/**
/**
* Deletes a Monthly Info for selected month
* Deletes a Monthly Info for selected month
* @param year
* @param date
* @param month
* @param token
* @param token
*/
*/
public
deleteMonthlyInfo
=
async
(
public
deleteMonthlyInfo
=
async
(
year
:
number
,
date
:
Date
,
month
:
number
,
token
:
string
token
:
string
):
Promise
<
void
>
=>
{
):
Promise
<
void
>
=>
{
try
{
try
{
await
axios
.
delete
(
`/api/admin/monthlyInfo/
${
year
}
/
${
month
}
`
,
{
await
axios
.
delete
(
headers
:
{
`/api/admin/monthlyInfo/
${
date
.
getFullYear
()}
/
${
date
.
getMonth
()
+
1
}
`
,
'
XSRF-TOKEN
'
:
token
,
{
},
headers
:
{
})
'
XSRF-TOKEN
'
:
token
,
},
}
)
toast
.
success
(
'
Monthly info succesfully deleted !
'
)
toast
.
success
(
'
Monthly info succesfully deleted !
'
)
}
catch
(
e
)
{
}
catch
(
e
)
{
toast
.
error
(
'
Failed to delete monthly info
'
)
toast
.
error
(
'
Failed to delete monthly info
'
)
...
@@ -101,7 +103,7 @@ export class NewsletterService {
...
@@ -101,7 +103,7 @@ export class NewsletterService {
await
axios
.
put
(
await
axios
.
put
(
`/api/admin/monthlyNews`
,
`/api/admin/monthlyNews`
,
{
{
month
:
date
.
getMonth
(),
month
:
date
.
getMonth
()
+
1
,
year
:
date
.
getFullYear
(),
year
:
date
.
getFullYear
(),
title
:
title
,
title
:
title
,
content
:
content
,
content
:
content
,
...
@@ -121,15 +123,16 @@ export class NewsletterService {
...
@@ -121,15 +123,16 @@ export class NewsletterService {
/**
/**
* Gets a news title and content for selected month
* Gets a news title and content for selected month
* @param date
* @param token
*/
*/
public
getSingleMonthlyNews
=
async
(
public
getSingleMonthlyNews
=
async
(
year
:
number
,
date
:
Date
,
month
:
number
,
token
:
string
token
:
string
):
Promise
<
IMonthlyNews
|
null
>
=>
{
):
Promise
<
IMonthlyNews
|
null
>
=>
{
try
{
try
{
const
{
data
}
=
await
axios
.
get
(
const
{
data
}
=
await
axios
.
get
(
`/api/admin/monthlyNews/
${
y
ear
}
/
${
month
}
`
,
`/api/admin/monthlyNews/
${
date
.
getFullY
ear
()
}
/
${
date
.
getMonth
()
+
1
}
`
,
{
{
headers
:
{
headers
:
{
'
XSRF-TOKEN
'
:
token
,
'
XSRF-TOKEN
'
:
token
,
...
@@ -145,21 +148,22 @@ export class NewsletterService {
...
@@ -145,21 +148,22 @@ export class NewsletterService {
/**
/**
* Deletes a Monthly News for selected month
* Deletes a Monthly News for selected month
* @param year
* @param date
* @param month
* @param token
* @param token
*/
*/
public
deleteMonthlyNews
=
async
(
public
deleteMonthlyNews
=
async
(
year
:
number
,
date
:
Date
,
month
:
number
,
token
:
string
token
:
string
):
Promise
<
void
>
=>
{
):
Promise
<
void
>
=>
{
try
{
try
{
await
axios
.
delete
(
`/api/admin/monthlyNews/
${
year
}
/
${
month
}
`
,
{
await
axios
.
delete
(
headers
:
{
`/api/admin/monthlyNews/
${
date
.
getFullYear
()}
/
${
date
.
getMonth
()
+
1
}
`
,
'
XSRF-TOKEN
'
:
token
,
{
},
headers
:
{
})
'
XSRF-TOKEN
'
:
token
,
},
}
)
toast
.
success
(
'
Monthly news succesfully deleted !
'
)
toast
.
success
(
'
Monthly news succesfully deleted !
'
)
}
catch
(
e
)
{
}
catch
(
e
)
{
toast
.
error
(
'
Failed to delete monthly news
'
)
toast
.
error
(
'
Failed to delete monthly news
'
)
...
@@ -183,7 +187,7 @@ export class NewsletterService {
...
@@ -183,7 +187,7 @@ export class NewsletterService {
await
axios
.
put
(
await
axios
.
put
(
`/api/admin/poll`
,
`/api/admin/poll`
,
{
{
month
:
date
.
getMonth
(),
month
:
date
.
getMonth
()
+
1
,
year
:
date
.
getFullYear
(),
year
:
date
.
getFullYear
(),
link
:
link
,
link
:
link
,
question
:
question
,
question
:
question
,
...
@@ -203,18 +207,22 @@ export class NewsletterService {
...
@@ -203,18 +207,22 @@ export class NewsletterService {
/**
/**
* Gets a poll with question and link for selected month
* Gets a poll with question and link for selected month
* @param date
* @param token
*/
*/
public
getSinglePoll
=
async
(
public
getSinglePoll
=
async
(
year
:
number
,
date
:
Date
,
month
:
number
,
token
:
string
token
:
string
):
Promise
<
IPoll
|
null
>
=>
{
):
Promise
<
IPoll
|
null
>
=>
{
try
{
try
{
const
{
data
}
=
await
axios
.
get
(
`/api/admin/poll/
${
year
}
/
${
month
}
`
,
{
const
{
data
}
=
await
axios
.
get
(
headers
:
{
`/api/admin/poll/
${
date
.
getFullYear
()}
/
${
date
.
getMonth
()
+
1
}
`
,
'
XSRF-TOKEN
'
:
token
,
{
},
headers
:
{
})
'
XSRF-TOKEN
'
:
token
,
},
}
)
return
data
as
IPoll
return
data
as
IPoll
}
catch
(
e
)
{
}
catch
(
e
)
{
console
.
error
(
'
error
'
,
e
)
console
.
error
(
'
error
'
,
e
)
...
@@ -224,21 +232,19 @@ export class NewsletterService {
...
@@ -224,21 +232,19 @@ export class NewsletterService {
/**
/**
* Deletes a poll for selected month
* Deletes a poll for selected month
* @param month
* @param date
* @param year
* @param token
* @param token
*/
*/
public
deletePoll
=
async
(
public
deletePoll
=
async
(
date
:
Date
,
token
:
string
):
Promise
<
void
>
=>
{
year
:
number
,
month
:
number
,
token
:
string
):
Promise
<
void
>
=>
{
try
{
try
{
await
axios
.
delete
(
`/api/admin/poll/
${
year
}
/
${
month
}
`
,
{
await
axios
.
delete
(
headers
:
{
`/api/admin/poll/
${
date
.
getFullYear
()}
/
${
date
.
getMonth
()
+
1
}
`
,
'
XSRF-TOKEN
'
:
token
,
{
},
headers
:
{
})
'
XSRF-TOKEN
'
:
token
,
},
}
)
toast
.
success
(
'
Poll succesfully deleted !
'
)
toast
.
success
(
'
Poll succesfully deleted !
'
)
}
catch
(
e
)
{
}
catch
(
e
)
{
toast
.
error
(
'
Failed to delete poll
'
)
toast
.
error
(
'
Failed to delete poll
'
)
...
...
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