Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import axios, { AxiosRequestConfig } from 'axios'
import { toast } from 'react-toastify'
import { ICustomPopup } from '../models/cutomPopup.model'
export class CustomPopupService {
/**
* Save the customPopup info
* @param customPopup
* @param axiosHeaders
*/
public saveCustomPopup = async (
customPopup: ICustomPopup,
axiosHeaders: AxiosRequestConfig
): Promise<void> => {
try {
await axios.put(
`/api/admin/customPopup`,
{
...customPopup,
},
axiosHeaders
)
toast.success('Pop-up personnalisée enregistrée !')
} catch (e) {
toast.error("Erreur lors de l'enregistement de la pop-up personnalisée")
console.error(e)
}
}
/**
* Gets the custom pop-up information
*/
public getCustomPopupInfo = async (): Promise<ICustomPopup | null> => {
try {
const { data } = await axios.get(`/api/common/customPopup`)
return data as ICustomPopup
} catch (e) {
console.error('error', e)
return null
}
}
}