Skip to content
Snippets Groups Projects
Commit 33369fd9 authored by Bastien DUMONT's avatar Bastien DUMONT :angel:
Browse files

refactor: use react-query for customPopup

parent 075a28a2
No related branches found
No related tags found
2 merge requests!167chore(release): Ecolyo 3.1.0,!158refactor: use react-query for customPopup
# Ecolyo Agent Client # Ecolyo Agent Client
[check documentation here](https://doc-self-data.apps.grandlyon.com/ecolyo-agent/technical/getting_started/#local-usage) [check documentation here](https://doc-self-data.apps.grandlyon.com/docs/ecolyo-agent/Technical/getting-started/#local-usage)
...@@ -16,7 +16,7 @@ const endpoints = { ...@@ -16,7 +16,7 @@ const endpoints = {
animator: { animator: {
partnersInfo: '/api/animator/partnersInfo', partnersInfo: '/api/animator/partnersInfo',
imageNames: '/api/animator/imageNames', imageNames: '/api/animator/imageNames',
savePartnersInfo: '/api/animator/savePartnersInfo', customPopup: '/api/animator/customPopup',
}, },
} as const } as const
...@@ -38,7 +38,7 @@ export const fetchEcogestureImages = async ( ...@@ -38,7 +38,7 @@ export const fetchEcogestureImages = async (
axiosHeaders: AxiosRequestConfig axiosHeaders: AxiosRequestConfig
) => { ) => {
const { data: imageNames } = await axios.get<string[]>( const { data: imageNames } = await axios.get<string[]>(
`/api/animator/imageNames`, endpoints.animator.imageNames,
axiosHeaders axiosHeaders
) )
if (imageNames && imageNames !== null) { if (imageNames && imageNames !== null) {
...@@ -55,12 +55,12 @@ export const fetchPartnersIssue = async () => { ...@@ -55,12 +55,12 @@ export const fetchPartnersIssue = async () => {
return data return data
} catch (error) { } catch (error) {
console.error('error partnersInfo', error) console.error('error partnersInfo', error)
toast.error('Accès refusé, veuillez vous connecter') toast.error('Aucune information des partenaires trouvée')
throw error throw error
} }
} }
export const savePartnersInfo = async ( export const putPartnersInfo = async (
partnersInfo: IPartnersInfo, partnersInfo: IPartnersInfo,
axiosHeaders: AxiosRequestConfig axiosHeaders: AxiosRequestConfig
) => { ) => {
...@@ -88,7 +88,26 @@ export const fetchCustomPopup = async (): Promise<ICustomPopup> => { ...@@ -88,7 +88,26 @@ export const fetchCustomPopup = async (): Promise<ICustomPopup> => {
return data return data
} catch (error) { } catch (error) {
console.error('error customPopup', error) console.error('error customPopup', error)
toast.error('Accès refusé, veuillez vous connecter') toast.error('Aucune pop-up personnalisée trouvée')
throw error throw error
} }
} }
export const putCustomPopup = async (
customPopup: ICustomPopup,
axiosHeaders: AxiosRequestConfig
) => {
try {
await axios.put(
endpoints.animator.customPopup,
{
...customPopup,
},
axiosHeaders
)
toast.success('Pop-up personnalisée enregistrée !')
} catch (e) {
toast.error('Erreur lors de l’enregistrement de la pop-up personnalisée')
console.error(e)
}
}
...@@ -12,6 +12,7 @@ import React, { useEffect, useState } from 'react' ...@@ -12,6 +12,7 @@ import React, { useEffect, useState } from 'react'
import 'react-draft-wysiwyg/dist/react-draft-wysiwyg.css' import 'react-draft-wysiwyg/dist/react-draft-wysiwyg.css'
import { Link } from 'react-router-dom' import { Link } from 'react-router-dom'
import { getAxiosXSRFHeader } from '../../axios.config' import { getAxiosXSRFHeader } from '../../axios.config'
import { useCustomPopup } from '../../hooks/useCustomPopup'
import { usePartnersIssue } from '../../hooks/usePartnersIssue' import { usePartnersIssue } from '../../hooks/usePartnersIssue'
import { useWhoAmI } from '../../hooks/useWhoAmI' import { useWhoAmI } from '../../hooks/useWhoAmI'
import { ICustomPopup, PopupDuration } from '../../models/customPopup.model' import { ICustomPopup, PopupDuration } from '../../models/customPopup.model'
...@@ -21,7 +22,6 @@ import { ...@@ -21,7 +22,6 @@ import {
durationType, durationType,
mapDuration, mapDuration,
} from '../../models/durationOptions.model' } from '../../models/durationOptions.model'
import { CustomPopupService } from '../../services/customPopup.service'
import { convertStringToEditorState } from '../../utils/editorStateManagement' import { convertStringToEditorState } from '../../utils/editorStateManagement'
import { getFilenameFromPath } from '../../utils/imagesUrlsGetter' import { getFilenameFromPath } from '../../utils/imagesUrlsGetter'
import ImagePicker from '../ImagePicker/ImagePicker' import ImagePicker from '../ImagePicker/ImagePicker'
...@@ -29,6 +29,7 @@ import Loader from '../Loader/Loader' ...@@ -29,6 +29,7 @@ import Loader from '../Loader/Loader'
import CustomEditor from '../Newsletter/CustomEditor' import CustomEditor from '../Newsletter/CustomEditor'
import { links } from '../Routes/Router' import { links } from '../Routes/Router'
import './popups.scss' import './popups.scss'
import { PopupWrapper } from './Wrapper'
const OPTIONS: Option[] = [ const OPTIONS: Option[] = [
{ {
...@@ -46,37 +47,75 @@ const OPTIONS: Option[] = [ ...@@ -46,37 +47,75 @@ const OPTIONS: Option[] = [
] ]
export const CustomPopup: React.FC = () => { export const CustomPopup: React.FC = () => {
const { data: user } = useWhoAmI()
const { partnersIssue } = usePartnersIssue() const { partnersIssue } = usePartnersIssue()
const defaultIcon = '/assets/ecogesture/bullhorn.png' const { customPopup } = useCustomPopup()
const isPartnerNotificationOn = Boolean(
partnersIssue.data &&
(partnersIssue.data.enedis_failure ||
partnersIssue.data.egl_failure ||
partnersIssue.data.grdf_failure)
)
if (isPartnerNotificationOn) {
return (
<PopupWrapper>
<p className="singlePopupWarning">
La pop-up personnalisée ne peut pas être activée en même temps que la{' '}
<Link to={links.partnersIssue.path}>
pop-up maintenance des partenaires
</Link>
</p>
</PopupWrapper>
)
}
if (customPopup.isLoading) {
return <Loader />
}
if (customPopup.error) {
return <p>Une erreur est survenue</p>
}
if (customPopup.data) {
return (
<PopupWrapper>
<CustomPopupForm initialData={customPopup.data} />
</PopupWrapper>
)
}
}
export const CustomPopupForm = ({
initialData,
}: {
initialData: ICustomPopup
}) => {
const { data: user } = useWhoAmI()
const { saveCustomPopup } = useCustomPopup()
const isPopupOutdated = (date: string) =>
DateTime.local() >= DateTime.fromISO(date)
const isOutdated = isPopupOutdated(initialData.endDate)
const isEnabled = isOutdated ? false : initialData.popupEnabled
const [refreshData, setRefreshData] = useState(false)
const [isLoading, setIsLoading] = useState(false)
const [previousEndDate, setPreviousEndDate] = useState<string>()
const [popupDuration, setPopupDuration] = useState<PopupDuration>({ const [popupDuration, setPopupDuration] = useState<PopupDuration>({
type: durationEnum.infinite, type: durationEnum.infinite,
duration: 5, duration: 5,
}) })
const [customPopup, setCustomPopup] = useState<ICustomPopup>({ const [customPopup, setCustomPopup] = useState<ICustomPopup>({
popupEnabled: false, popupEnabled: isEnabled,
title: '', title: initialData.title,
image: '', image: initialData.image || 'bullhorn',
description: '', description: initialData.description,
endDate: DateTime.local().plus({ days: 365 }).toISO(), endDate: isOutdated
? DateTime.local().plus({ days: 365 }).toISO()
: initialData.endDate,
}) })
const isPartnerNotificationOn = () =>
Boolean(
partnersIssue.data &&
(partnersIssue.data.enedis_failure ||
partnersIssue.data.egl_failure ||
partnersIssue.data.grdf_failure)
)
/** Only one type of popup can be enabled */
const isPageValid = () =>
!(isPartnerNotificationOn() && customPopup.popupEnabled)
const toggleCustomPopup = (value: boolean): void => { const toggleCustomPopup = (value: boolean): void => {
setCustomPopup(prev => ({ setCustomPopup(prev => ({
...prev, ...prev,
...@@ -94,57 +133,15 @@ export const CustomPopup: React.FC = () => { ...@@ -94,57 +133,15 @@ export const CustomPopup: React.FC = () => {
})) }))
} }
useEffect(() => {
let subscribed = true
setIsLoading(true)
async function loadCustomPopup() {
if (user) {
const customPopupService = new CustomPopupService()
const previousPopup = await customPopupService.getCustomPopupInfo()
if (previousPopup) {
const isOutdated = isPopupOutdated(previousPopup.endDate)
/** If outdated, set value to false, otherwise, set it to its value */
const isEnabled = isOutdated ? false : previousPopup.popupEnabled
const popupImage =
previousPopup.image === ''
? defaultIcon
: `/assets/ecogesture/${previousPopup.image}.png`
setCustomPopup({
...previousPopup,
image: popupImage,
endDate: customPopup.endDate,
popupEnabled: isEnabled,
})
setPreviousEndDate(
isOutdated ? customPopup.endDate : previousPopup.endDate
)
}
}
setIsLoading(false)
}
if (subscribed) {
loadCustomPopup()
}
return () => {
subscribed = false
setRefreshData(false)
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [user, refreshData, setCustomPopup])
const handleSave = async (): Promise<void> => { const handleSave = async (): Promise<void> => {
if (user) { if (user) {
const customPopupService = new CustomPopupService() saveCustomPopup(
await customPopupService.saveCustomPopup(
{ {
...customPopup, ...customPopup,
image: getFilenameFromPath(customPopup.image), image: getFilenameFromPath(customPopup.image),
}, },
getAxiosXSRFHeader(user.xsrftoken) getAxiosXSRFHeader(user.xsrftoken)
) )
setPreviousEndDate(customPopup.endDate)
} }
} }
...@@ -158,30 +155,22 @@ export const CustomPopup: React.FC = () => { ...@@ -158,30 +155,22 @@ export const CustomPopup: React.FC = () => {
/** Handles duration change */ /** Handles duration change */
useEffect(() => { useEffect(() => {
const now = DateTime.local() const now = DateTime.local()
let newDate: DateTime const newDate =
if (popupDuration.type !== durationEnum.infinite) { popupDuration.type !== durationEnum.infinite
newDate = now.plus({ ? now.plus({ [popupDuration.type]: popupDuration.duration })
[popupDuration.type]: popupDuration.duration, : now.plus({ years: 1 })
})
} else {
newDate = now.plus({
years: 1,
})
}
setCustomPopup(prev => ({ setCustomPopup(prev => ({
...prev, ...prev,
endDate: newDate.toISO() ?? '', endDate: newDate.toISO() ?? '',
})) }))
}, [popupDuration]) }, [popupDuration])
const isPopupOutdated = (date: string) =>
DateTime.local() >= DateTime.fromISO(date)
/** /**
* Returns "Popup expirée" OR "Temps restant : ..." * Returns "Popup expirée" OR "Temps restant : ..."
*/ */
const getRemainingDuration = (date: string) => { const getRemainingDuration = (date: string) => {
if (isPopupOutdated(date)) { if (isOutdated) {
return <p className="endDate">Popup expirée</p> return <p className="endDate">Popup expirée</p>
} }
return ( return (
...@@ -197,136 +186,105 @@ export const CustomPopup: React.FC = () => { ...@@ -197,136 +186,105 @@ export const CustomPopup: React.FC = () => {
return ( return (
<> <>
<div className="header"> <div className="customPopup">
<h1>Création de Pop-up</h1> <h3>Affichage de pop-up personnalisée</h3>
</div> <FormGroup style={{ flexDirection: 'row' }}>
<FormControlLabel
label="Pop-up active"
labelPlacement="top"
control={
<Switch
checked={customPopup.popupEnabled}
onChange={event => toggleCustomPopup(event.target.checked)}
/>
}
/>
{customPopup.popupEnabled &&
initialData.endDate &&
getRemainingDuration(initialData.endDate)}
</FormGroup>
<div className="content popups"> <div className="popupEndDate">
{isLoading && <Loader />} <h4>Durée</h4>
{!isLoading && ( <div>
<> <FormControl style={{ flexDirection: 'row', gap: '1rem' }}>
<div className="customPopup"> <NativeSelect
<h3>Affichage de pop-up personnalisée</h3> inputProps={{
<FormGroup style={{ flexDirection: 'row' }}> name: 'age',
<FormControlLabel id: 'uncontrolled-native',
label="Pop-up active" }}
labelPlacement="top" onChange={event => handleSelectChange(event)}
control={ value={popupDuration.type}
<Switch >
disabled={isPartnerNotificationOn()} {OPTIONS.map(option => (
checked={customPopup.popupEnabled} <option key={option.value} value={option.value}>
onChange={event => {option.label}
toggleCustomPopup(event.target.checked) </option>
} ))}
/> </NativeSelect>
}
/>
{customPopup.popupEnabled &&
previousEndDate &&
getRemainingDuration(previousEndDate)}
{isPartnerNotificationOn() && (
<p className="singlePopupWarning">
La pop-up personnalisée ne peut pas être activée en même
temps que la{' '}
<Link to={links.partnersIssue.path}>
pop-up maintenance des partenaires
</Link>
</p>
)}
</FormGroup>
<div className="popupEndDate">
<h4>Durée</h4>
<div>
<FormControl style={{ flexDirection: 'row', gap: '1rem' }}>
<NativeSelect
inputProps={{
name: 'age',
id: 'uncontrolled-native',
}}
onChange={event => handleSelectChange(event)}
value={popupDuration.type}
>
{OPTIONS.map(option => (
<option key={option.value} value={option.value}>
{option.label}
</option>
))}
</NativeSelect>
{popupDuration.type !== 'infinite' && (
<TextField
style={{ width: '6rem' }}
inputProps={{
inputMode: 'numeric',
pattern: '[0-9]*',
}}
id="outlined-number"
type="number"
label={mapDuration[popupDuration.type]}
InputLabelProps={{
shrink: true,
}}
value={popupDuration.duration}
onChange={e =>
setPopupDuration(prev => ({
...prev,
duration: Number(e.target.value),
}))
}
/>
)}
</FormControl>
</div>
</div>
<h4>Image</h4>
<div>
<ImagePicker
imageURL={customPopup.image}
handleChange={handlePopupChange}
defaultIcon={defaultIcon}
/>
</div>
<h4>Contenu</h4> {popupDuration.type !== 'infinite' && (
<div className="popupTitle">
<TextField <TextField
type="text" style={{ width: '6rem' }}
placeholder="Titre de la popup" inputProps={{
fullWidth inputMode: 'numeric',
label="Titre" pattern: '[0-9]*',
value={customPopup.title} }}
onChange={event => id="outlined-number"
handlePopupChange(event.target.value, 'title') type="number"
label={mapDuration[popupDuration.type]}
InputLabelProps={{
shrink: true,
}}
value={popupDuration.duration}
onChange={e =>
setPopupDuration(prev => ({
...prev,
duration: Number(e.target.value),
}))
} }
/> />
</div> )}
</FormControl>
</div>
</div>
<div className="popupDescription"> <h4>Image</h4>
<CustomEditor <div>
baseState={convertStringToEditorState( <ImagePicker
customPopup.description imageURL={`/assets/ecogesture/${customPopup.image}.png`}
)} handleChange={handlePopupChange}
handleChange={value => />
handlePopupChange(value, 'description') </div>
}
type="custom_popup" <h4>Contenu</h4>
/> <div className="popupTitle">
</div> <TextField
</div> type="text"
placeholder="Titre de la popup"
fullWidth
label="Titre"
value={customPopup.title}
onChange={event => handlePopupChange(event.target.value, 'title')}
/>
</div>
<div className="popupDescription">
<CustomEditor
baseState={convertStringToEditorState(customPopup.description)}
handleChange={value => handlePopupChange(value, 'description')}
type="custom_popup"
/>
</div>
</div>
<div className="buttons"> <div className="buttons">
<Button variant="outlined" onClick={() => setRefreshData(true)}> <Button variant="outlined" onClick={() => setCustomPopup(initialData)}>
Annuler Annuler
</Button> </Button>
<Button disabled={!isPageValid()} onClick={handleSave}> <Button onClick={handleSave} disabled={!user}>
Sauvegarder Sauvegarder
</Button> </Button>
</div>
</>
)}
</div> </div>
</> </>
) )
......
...@@ -7,6 +7,7 @@ import { useWhoAmI } from '../../hooks/useWhoAmI' ...@@ -7,6 +7,7 @@ import { useWhoAmI } from '../../hooks/useWhoAmI'
import Loader from '../Loader/Loader' import Loader from '../Loader/Loader'
import { links } from '../Routes/Router' import { links } from '../Routes/Router'
import './popups.scss' import './popups.scss'
import { PopupWrapper } from './Wrapper'
export const PartnersIssue = () => { export const PartnersIssue = () => {
const { data: user } = useWhoAmI() const { data: user } = useWhoAmI()
...@@ -40,85 +41,70 @@ export const PartnersIssue = () => { ...@@ -40,85 +41,70 @@ export const PartnersIssue = () => {
} }
} }
return ( if (partnersIssue.isLoading) {
<> return <Loader />
<div className="header"> }
<h1>Création de Pop-up</h1>
</div> if (partnersIssue.error) {
<div className="content popups"> return <p>Une erreur est survenue</p>
<div className="partnersInfo"> }
<h3>Affichage des pop-up de panne</h3>
<div>
{partnersIssue.isPending && <Loader />}
{partnersIssue.isError && <p>Erreur</p>}
{partnersIssue.data && (
<div>
<p>Services concernés</p>
<FormGroup style={{ flexDirection: 'row' }}>
<FormControlLabel
label={'Panne Enedis'}
labelPlacement="top"
control={
<Switch
disabled={isCustomPopupEnabled}
checked={partnersIssue.data.enedis_failure}
onChange={event => {
handlePartnerIssue(
event.target.checked,
'enedis_failure'
)
}}
/>
}
/>
<FormControlLabel
label={'Panne EGL'}
labelPlacement="top"
control={
<Switch
disabled={isCustomPopupEnabled}
checked={partnersIssue.data.egl_failure}
onChange={event => {
handlePartnerIssue(
event.target.checked,
'egl_failure'
)
}}
/>
}
/>
<FormControlLabel
label={'Panne GRDF'}
labelPlacement="top"
control={
<Switch
disabled={isCustomPopupEnabled}
checked={partnersIssue.data.grdf_failure}
onChange={event => {
handlePartnerIssue(
event.target.checked,
'grdf_failure'
)
}}
/>
}
/>
</FormGroup>
{isCustomPopupEnabled && ( if (partnersIssue.data) {
<p className="singlePopupWarning"> return (
La pop-up maintenance des partenaires ne peut pas être <PopupWrapper>
activée en même temps que la{' '} <h3>Affichage des pop-up de panne</h3>
<Link to={links.customPopup.path}>
pop-up personnalisée <p>Services concernés</p>
</Link> <FormGroup style={{ flexDirection: 'row' }}>
</p> <FormControlLabel
)} label={'Panne Enedis'}
</div> labelPlacement="top"
)} control={
</div> <Switch
</div> disabled={isCustomPopupEnabled}
</div> checked={partnersIssue.data.enedis_failure}
</> onChange={event => {
) handlePartnerIssue(event.target.checked, 'enedis_failure')
}}
/>
}
/>
<FormControlLabel
label={'Panne EGL'}
labelPlacement="top"
control={
<Switch
disabled={isCustomPopupEnabled}
checked={partnersIssue.data.egl_failure}
onChange={event => {
handlePartnerIssue(event.target.checked, 'egl_failure')
}}
/>
}
/>
<FormControlLabel
label={'Panne GRDF'}
labelPlacement="top"
control={
<Switch
disabled={isCustomPopupEnabled}
checked={partnersIssue.data.grdf_failure}
onChange={event => {
handlePartnerIssue(event.target.checked, 'grdf_failure')
}}
/>
}
/>
</FormGroup>
{isCustomPopupEnabled && (
<p className="singlePopupWarning">
La pop-up maintenance des partenaires ne peut pas être activée en
même temps que la{' '}
<Link to={links.customPopup.path}>pop-up personnalisée</Link>
</p>
)}
</PopupWrapper>
)
}
} }
import './popups.scss'
export const PopupWrapper = ({ children }: { children: React.ReactNode }) => {
return (
<>
<div className="header">
<h1>Création de Pop-up</h1>
</div>
<div className="content popups">{children}</div>
</>
)
}
@import '../../styles/config/colors'; @import '../../styles/config/colors';
.popups { .popups {
.partnersInfo {
margin-bottom: 2rem;
}
p.endDate { p.endDate {
color: $gold-dark; color: $gold-dark;
font-weight: bold; font-weight: bold;
......
import { useQuery } from '@tanstack/react-query' import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query'
import { fetchCustomPopup } from '../API' import { AxiosRequestConfig } from 'axios'
import { fetchCustomPopup, putCustomPopup } from '../API'
import { ICustomPopup } from '../models/customPopup.model'
import { queryKeys } from './query-keys' import { queryKeys } from './query-keys'
export const useCustomPopup = () => { export const useCustomPopup = () => {
const queryClient = useQueryClient()
const customPopup = useQuery({ const customPopup = useQuery({
queryKey: [queryKeys.customPopup], queryKey: [queryKeys.customPopup],
queryFn: fetchCustomPopup, queryFn: fetchCustomPopup,
}) })
return { customPopup } const mutation = useMutation<
void,
unknown,
{ customPopup: ICustomPopup; axiosHeaders: AxiosRequestConfig }
>({
mutationFn: ({ customPopup, axiosHeaders }) =>
putCustomPopup(customPopup, axiosHeaders),
onSuccess: () =>
queryClient.invalidateQueries({ queryKey: [queryKeys.customPopup] }),
})
const saveCustomPopup = (
customPopup: ICustomPopup,
axiosHeaders: AxiosRequestConfig
) => {
mutation.mutate({ customPopup, axiosHeaders })
}
return { customPopup, saveCustomPopup }
} }
import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query' import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query'
import { AxiosRequestConfig } from 'axios' import { AxiosRequestConfig } from 'axios'
import { fetchPartnersIssue, savePartnersInfo } from '../API' import { fetchPartnersIssue, putPartnersInfo } from '../API'
import { IPartnersInfo } from '../models/partnersInfo.model' import { IPartnersInfo } from '../models/partnersInfo.model'
import { queryKeys } from './query-keys' import { queryKeys } from './query-keys'
...@@ -18,10 +18,9 @@ export const usePartnersIssue = () => { ...@@ -18,10 +18,9 @@ export const usePartnersIssue = () => {
{ partnersInfo: IPartnersInfo; axiosHeaders: AxiosRequestConfig } { partnersInfo: IPartnersInfo; axiosHeaders: AxiosRequestConfig }
>({ >({
mutationFn: ({ partnersInfo, axiosHeaders }) => mutationFn: ({ partnersInfo, axiosHeaders }) =>
savePartnersInfo(partnersInfo, axiosHeaders), putPartnersInfo(partnersInfo, axiosHeaders),
onSuccess: () => { onSuccess: () =>
queryClient.invalidateQueries({ queryKey: [queryKeys.partnersInfo] }) queryClient.invalidateQueries({ queryKey: [queryKeys.partnersInfo] }),
},
}) })
const savePartnersIssue = ( const savePartnersIssue = (
......
...@@ -10,5 +10,6 @@ export interface ICustomPopup { ...@@ -10,5 +10,6 @@ export interface ICustomPopup {
export interface PopupDuration { export interface PopupDuration {
type: durationType type: durationType
/** number of days or hours */
duration: number duration: number
} }
import axios, { AxiosRequestConfig } from 'axios'
import { toast } from 'react-toastify'
import { ICustomPopup } from '../models/customPopup.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/animator/customPopup`,
{
...customPopup,
},
axiosHeaders
)
toast.success('Pop-up personnalisée enregistrée !')
} catch (e) {
toast.error('Erreur lors de l’enregistrement 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<ICustomPopup>(`/api/common/customPopup`)
return data
} catch (e) {
console.error('error', e)
return null
}
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment