Skip to content
Snippets Groups Projects

feat(ui): use mui components and upgrade to v5

Merged Bastien DUMONT requested to merge mui-v5 into dev
4 files
+ 154
143
Compare changes
  • Side-by-side
  • Inline
Files
4
import {
Button,
FormControl,
FormControlLabel,
FormGroup,
NativeSelect,
Switch,
} from '@mui/material'
import { DateTime } from 'luxon'
import React, { useCallback, useContext, useEffect, useState } from 'react'
import 'react-draft-wysiwyg/dist/react-draft-wysiwyg.css'
@@ -238,82 +246,83 @@ const Popups: React.FC = () => {
<h2 className="title">Affichage des pop-up de panne</h2>
<div className={customPopup.popupEnabled ? 'disabled' : ''}>
<p>Services concernés</p>
<div className="switch_div">
<span>Panne Enedis</span>
<input
type="checkbox"
id="switch_enedis"
disabled={customPopup.popupEnabled}
checked={partnersInfo.enedis_failure}
onChange={event => {
handleCheckboxChange(
event.currentTarget.checked,
CheckboxType.ENEDIS
)
}}
<FormGroup style={{ flexDirection: 'row' }}>
<FormControlLabel
label="Panne Enedis"
labelPlacement="top"
control={
<Switch
disabled={customPopup.popupEnabled}
checked={partnersInfo.enedis_failure}
onChange={event => {
handleCheckboxChange(
event.target.checked,
CheckboxType.ENEDIS
)
}}
/>
}
/>
<label htmlFor="switch_enedis" />
</div>
<div className="switch_div">
<span>Panne EGL</span>
<input
type="checkbox"
id="switch_egl"
disabled={customPopup.popupEnabled}
checked={partnersInfo.egl_failure}
onChange={event => {
handleCheckboxChange(
event.currentTarget.checked,
CheckboxType.EGL
)
}}
<FormControlLabel
label="Panne EGL"
labelPlacement="top"
control={
<Switch
disabled={customPopup.popupEnabled}
checked={partnersInfo.egl_failure}
onChange={event => {
handleCheckboxChange(
event.target.checked,
CheckboxType.EGL
)
}}
/>
}
/>
<label htmlFor="switch_egl" />
</div>
<div className="switch_div">
<span>Panne GRDF</span>
<input
type="checkbox"
id="switch_grdf"
disabled={customPopup.popupEnabled}
checked={partnersInfo.grdf_failure}
onChange={event => {
handleCheckboxChange(
event.currentTarget.checked,
CheckboxType.GRDF
)
}}
<FormControlLabel
label="Panne GRDF"
labelPlacement="top"
control={
<Switch
disabled={customPopup.popupEnabled}
checked={partnersInfo.grdf_failure}
onChange={event => {
handleCheckboxChange(
event.target.checked,
CheckboxType.GRDF
)
}}
/>
}
/>
<label htmlFor="switch_grdf" />
</div>
</FormGroup>
</div>
</div>
<div className="customPopup">
<h2 className="title">Affichage de pop-up personnalisée</h2>
<div className={isPartnerNotificationOn() ? 'disabled' : ''}>
<div className="currentPopup">
<div className="switch_div">
<span>Pop-up active</span>
<input
type="checkbox"
id="switch_popup"
disabled={isPartnerNotificationOn()}
checked={customPopup.popupEnabled}
onChange={event => {
handleCheckboxChange(
event.currentTarget.checked,
CheckboxType.CUSTOM
)
}}
/>
<label htmlFor="switch_popup" />
</div>
<FormGroup style={{ flexDirection: 'row' }}>
<FormControlLabel
label="Pop-up active"
labelPlacement="top"
control={
<Switch
disabled={isPartnerNotificationOn()}
checked={customPopup.popupEnabled}
onChange={event => {
handleCheckboxChange(
event.target.checked,
CheckboxType.CUSTOM
)
}}
/>
}
/>
{customPopup.popupEnabled &&
previousEndDate &&
getRemainingDuration(previousEndDate)}
</div>
</FormGroup>
<div className="popupTitle">
<label htmlFor="title">Titre</label>
@@ -345,7 +354,26 @@ const Popups: React.FC = () => {
<div className="popupEndDate">
<label htmlFor="title">Nouvelle Durée</label>
<div className="durationInput">
<select
<FormControl>
<NativeSelect
defaultValue={30}
inputProps={{
name: 'age',
id: 'uncontrolled-native',
}}
>
{OPTIONS.map(option => (
<option
key={option.value}
value={option.value}
selected={popupDuration.type === option.value}
>
{option.label}
</option>
))}
</NativeSelect>
</FormControl>
{/* <select
value={popupDuration.type}
onChange={event => handleSelectChange(event)}
>
@@ -358,7 +386,7 @@ const Popups: React.FC = () => {
{option.label}
</option>
))}
</select>
</select> */}
{popupDuration.type !== 'infinite' && (
<input
type="number"
@@ -378,17 +406,16 @@ const Popups: React.FC = () => {
</div>
<div className="buttons">
<button className="btnCancel" onClick={handleCancel}>
<Button variant="outlined" onClick={handleCancel}>
Annuler
</button>
<button
className="btnValid"
onClick={handleSave}
</Button>
<Button
variant="contained"
disabled={!isPageValid()}
title="Un seul type de popup peut être activé"
onClick={handleSave}
>
Sauvegarder
</button>
</Button>
</div>
</>
)}
Loading