Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found
Select Git revision
  • dev
  • master
  • renovate/devdependencies-(non-major)
  • renovate/eslint-9.x
  • renovate/major-ag-grid-monorepo
  • renovate/major-react-monorepo
  • renovate/major-react-router-monorepo
  • renovate/mui-material-7.x
  • renovate/nginxinc-nginx-unprivileged-1.x
  • renovate/node-24.x
  • renovate/react-19.x
  • renovate/react-dom-19.x
  • renovate/react-toastify-11.x
  • renovate/vite-7.x
  • renovate/vite-tsconfig-paths-5.x
  • renovate/vitejs-plugin-basic-ssl-2.x
  • renovate/web-vitals-5.x
17 results

Target

Select target project
  • web-et-numerique/factory/llle_project/backoffice-client
1 result
Select Git revision
  • dev
  • master
  • renovate/devdependencies-(non-major)
  • renovate/eslint-9.x
  • renovate/major-ag-grid-monorepo
  • renovate/major-react-monorepo
  • renovate/major-react-router-monorepo
  • renovate/mui-material-7.x
  • renovate/nginxinc-nginx-unprivileged-1.x
  • renovate/node-24.x
  • renovate/react-19.x
  • renovate/react-dom-19.x
  • renovate/react-toastify-11.x
  • renovate/vite-7.x
  • renovate/vite-tsconfig-paths-5.x
  • renovate/vitejs-plugin-basic-ssl-2.x
  • renovate/web-vitals-5.x
17 results
Show changes
Commits on Source (6)
Showing
with 100 additions and 82 deletions
...@@ -6,6 +6,32 @@ module.exports = { ...@@ -6,6 +6,32 @@ module.exports = {
'prettier', // Uses eslint-config-prettier to disable ESLint rules from @typescript-eslint/eslint-plugin that would conflict with prettier 'prettier', // Uses eslint-config-prettier to disable ESLint rules from @typescript-eslint/eslint-plugin that would conflict with prettier
'plugin:prettier/recommended', // Enables eslint-plugin-prettier and displays prettier errors as ESLint errors. Make sure this is always the last configuration in the extends array. 'plugin:prettier/recommended', // Enables eslint-plugin-prettier and displays prettier errors as ESLint errors. Make sure this is always the last configuration in the extends array.
'plugin:react-hooks/recommended', 'plugin:react-hooks/recommended',
'react-app',
],
plugins: ['@typescript-eslint', 'react', 'react-hooks'],
overrides: [
{
extends: [
'plugin:@typescript-eslint/recommended',
'plugin:@typescript-eslint/eslint-recommended', // Uses the recommended rules from @typescript-eslint/eslint-plugin
// This enables a lot of type checking
// 'plugin:@typescript-eslint/recommended-requiring-type-checking', // Uses the recommended rules from @typescript-eslint/eslint-plugin
],
files: ['**/*.{ts,tsx}'],
parserOptions: {
tsconfigRootDir: __dirname,
project: ['./tsconfig.json'],
},
rules: {
'@typescript-eslint/explicit-function-return-type': 'off',
'@typescript-eslint/no-unused-vars': 'warn',
'@typescript-eslint/no-explicit-any': 'warn',
'@typescript-eslint/prefer-optional-chain': 'warn',
'@typescript-eslint/prefer-as-const': 'error',
'@typescript-eslint/await-thenable': 'error',
'@typescript-eslint/no-var-requires': 'off',
},
},
], ],
parserOptions: { parserOptions: {
ecmaVersion: 2020, // Allows for the parsing of modern ECMAScript features ecmaVersion: 2020, // Allows for the parsing of modern ECMAScript features
...@@ -16,9 +42,9 @@ module.exports = { ...@@ -16,9 +42,9 @@ module.exports = {
}, },
rules: { rules: {
// Place to specify ESLint rules. Can be used to overwrite rules specified from the extended configs // Place to specify ESLint rules. Can be used to overwrite rules specified from the extended configs
'@typescript-eslint/explicit-function-return-type': 'off',
'react/react-in-jsx-scope': 'off', 'react/react-in-jsx-scope': 'off',
'react/prop-types': 'warn', 'react/prop-types': 'warn',
'react/self-closing-comp': 'warn',
}, },
settings: { settings: {
react: { react: {
......
...@@ -3,5 +3,6 @@ ...@@ -3,5 +3,6 @@
"semi": false, "semi": false,
"singleQuote": true, "singleQuote": true,
"tabWidth": 2, "tabWidth": 2,
"trailingComma": "es5" "trailingComma": "es5",
"arrowParens": "avoid"
} }
...@@ -34,10 +34,11 @@ ...@@ -34,10 +34,11 @@
"editor.defaultFormatter": "esbenp.prettier-vscode", "editor.defaultFormatter": "esbenp.prettier-vscode",
"peacock.color": "#2aa63d", "peacock.color": "#2aa63d",
"sonarlint.connectedMode.project": { "sonarlint.connectedMode.project": {
"connectionId": "sonarqube-forge-grandlyon", "connectionId": "Sonar",
"projectKey": "web-et-numerique-llle-project-backoffice-client" "projectKey": "web-et-numerique-factory-llle-project-backoffice-client"
}, },
"cSpell.words": [ "cSpell.words": [
"backoffice",
"draftjs", "draftjs",
"ecogesture", "ecogesture",
"ecolyo", "ecolyo",
......
...@@ -4,11 +4,11 @@ ...@@ -4,11 +4,11 @@
"private": true, "private": true,
"scripts": { "scripts": {
"start": "react-scripts start", "start": "react-scripts start",
"build": "react-scripts build", "build": "CI=false && react-scripts build",
"local-up": "docker-compose -f docker-compose.local.yml up -d && yarn start", "local-up": "docker-compose -f docker-compose.local.yml up -d && yarn start",
"local-down": "docker-compose -f docker-compose.local.yml down", "local-down": "docker-compose -f docker-compose.local.yml down",
"docker": "docker run -it --rm -p 3000:3000 front-backoffice", "docker": "docker run -it --rm -p 3000:3000 front-backoffice",
"lint": "eslint .", "lint": "eslint src -c .eslintrc.js --fix",
"lint:fix": "eslint --fix .", "lint:fix": "eslint --fix .",
"format": "prettier --write \"./src/**/*.{js,jsx,ts,tsx,json,md}\"", "format": "prettier --write \"./src/**/*.{js,jsx,ts,tsx,json,md}\"",
"test": "react-scripts test", "test": "react-scripts test",
...@@ -27,7 +27,6 @@ ...@@ -27,7 +27,6 @@
] ]
}, },
"devDependencies": { "devDependencies": {
"@types/jest": "^26.0.15",
"@types/node": "^12.0.0", "@types/node": "^12.0.0",
"@types/react": "^17.0.0", "@types/react": "^17.0.0",
"@types/react-dom": "^17.0.0", "@types/react-dom": "^17.0.0",
...@@ -37,8 +36,6 @@ ...@@ -37,8 +36,6 @@
"eslint": "^8.21.0", "eslint": "^8.21.0",
"eslint-config-prettier": "^8.5.0", "eslint-config-prettier": "^8.5.0",
"eslint-config-react-app": "^6.0.0", "eslint-config-react-app": "^6.0.0",
"eslint-plugin-import": "^2.23.4",
"eslint-plugin-jest": "^24.4.0",
"eslint-plugin-prettier": "^5.0.0", "eslint-plugin-prettier": "^5.0.0",
"eslint-plugin-react": "7.30.1", "eslint-plugin-react": "7.30.1",
"eslint-plugin-react-hooks": "^4.2.0", "eslint-plugin-react-hooks": "^4.2.0",
...@@ -48,9 +45,6 @@ ...@@ -48,9 +45,6 @@
"dependencies": { "dependencies": {
"@material-ui/core": "^4.12.3", "@material-ui/core": "^4.12.3",
"@material-ui/lab": "^4.0.0-alpha.60", "@material-ui/lab": "^4.0.0-alpha.60",
"@testing-library/jest-dom": "^5.11.4",
"@testing-library/react": "^11.1.0",
"@testing-library/user-event": "^12.1.10",
"@types/draft-js": "^0.11.4", "@types/draft-js": "^0.11.4",
"@types/draftjs-to-html": "^0.8.1", "@types/draftjs-to-html": "^0.8.1",
"@types/html-to-draftjs": "^1.4.0", "@types/html-to-draftjs": "^1.4.0",
......
...@@ -45,7 +45,7 @@ const Consents: React.FC = () => { ...@@ -45,7 +45,7 @@ const Consents: React.FC = () => {
}, []) }, [])
const toggleOpenModal = useCallback(() => { const toggleOpenModal = useCallback(() => {
setOpenDowloadModal((prev) => !prev) setOpenDowloadModal(prev => !prev)
}, []) }, [])
const defaultColDef = useMemo( const defaultColDef = useMemo(
...@@ -134,7 +134,7 @@ const Consents: React.FC = () => { ...@@ -134,7 +134,7 @@ const Consents: React.FC = () => {
}, },
[] []
) )
const handleChangeRowsPerPage = useCallback((event: any) => { const handleChangeRowsPerPage = useCallback(event => {
setRowsPerPage(event.target.value) setRowsPerPage(event.target.value)
setPage(0) setPage(0)
}, []) }, [])
...@@ -143,10 +143,10 @@ const Consents: React.FC = () => { ...@@ -143,10 +143,10 @@ const Consents: React.FC = () => {
if (gridApi) { if (gridApi) {
const newNodes = gridApi.getRenderedNodes() const newNodes = gridApi.getRenderedNodes()
const idsToCheck: string[] = selectedNodes const idsToCheck: string[] = selectedNodes
.filter((node: RowNode) => node.isSelected) .filter(node => node.isSelected)
.map((node: RowNode) => node.data.ID) .map(node => node.data.ID)
newNodes.forEach((node: RowNode) => { newNodes.forEach(node => {
if (idsToCheck.includes(node.data.ID)) if (idsToCheck.includes(node.data.ID))
node.setSelected(true, false, true) node.setSelected(true, false, true)
}) })
...@@ -187,14 +187,14 @@ const Consents: React.FC = () => { ...@@ -187,14 +187,14 @@ const Consents: React.FC = () => {
(event: RowSelectedEvent) => { (event: RowSelectedEvent) => {
if (event.node.isSelected()) { if (event.node.isSelected()) {
const index = selectedNodes.findIndex( const index = selectedNodes.findIndex(
(node) => node.data.ID === event.node.data.ID node => node.data.ID === event.node.data.ID
) )
if (index === -1) { if (index === -1) {
setSelectedNodes((prev) => [...prev, event.node]) setSelectedNodes(prev => [...prev, event.node])
} }
} else { } else {
setSelectedNodes((prev) => setSelectedNodes(prev =>
prev.filter((node) => { prev.filter(node => {
return node.data.ID != event.node.data.ID return node.data.ID != event.node.data.ID
}) })
) )
...@@ -279,7 +279,7 @@ const Consents: React.FC = () => { ...@@ -279,7 +279,7 @@ const Consents: React.FC = () => {
} }
disabled={isShowingSelection} disabled={isShowingSelection}
autoComplete="off" autoComplete="off"
></input> />
</div> </div>
</div> </div>
<div <div
...@@ -301,9 +301,9 @@ const Consents: React.FC = () => { ...@@ -301,9 +301,9 @@ const Consents: React.FC = () => {
pagination={false} pagination={false}
suppressCellFocus={true} suppressCellFocus={true}
rowClassRules={{ rowClassRules={{
expired: (params) => params.data.endDate < DateTime.now(), expired: params => params.data.endDate < DateTime.now(),
}} }}
></AgGridReact> />
{!isShowingSelection && ( {!isShowingSelection && (
<TablePagination <TablePagination
labelRowsPerPage="Consentements par page" labelRowsPerPage="Consentements par page"
......
...@@ -14,7 +14,7 @@ const BottomBar: React.FC = () => { ...@@ -14,7 +14,7 @@ const BottomBar: React.FC = () => {
<div className="menu-list"> <div className="menu-list">
{user && {user &&
routes.map( routes.map(
(route) => route =>
(!route.adminOnly || user?.isAdmin) && ( (!route.adminOnly || user?.isAdmin) && (
<NavLink <NavLink
key={route.label} key={route.label}
......
...@@ -18,7 +18,7 @@ const SideBar: React.FC = () => { ...@@ -18,7 +18,7 @@ const SideBar: React.FC = () => {
<div className="menu-list"> <div className="menu-list">
{user && {user &&
routes.map( routes.map(
(route) => route =>
(!route.adminOnly || user.isAdmin) && ( (!route.adminOnly || user.isAdmin) && (
<NavLink <NavLink
key={route.label} key={route.label}
......
...@@ -60,7 +60,7 @@ const CustomEditor: React.FC<CustomEditorProps> = ({ ...@@ -60,7 +60,7 @@ const CustomEditor: React.FC<CustomEditorProps> = ({
return ( return (
<Editor <Editor
editorState={editorState} editorState={editorState}
onEditorStateChange={(state) => handleStateChange(state)} onEditorStateChange={state => handleStateChange(state)}
handlePastedText={() => false} handlePastedText={() => false}
wrapperClassName="wrapper-class" wrapperClassName="wrapper-class"
editorClassName="editor-class" editorClassName="editor-class"
......
...@@ -77,7 +77,7 @@ const CustomLink: React.FC<EcolyoLinkProps> = ({ onChange, editorState }) => { ...@@ -77,7 +77,7 @@ const CustomLink: React.FC<EcolyoLinkProps> = ({ onChange, editorState }) => {
: 'rdw-dropdown-optionwrapper placeholder-ul' : 'rdw-dropdown-optionwrapper placeholder-ul'
} }
> >
{links.map((item: LinkState) => { {links.map(item => {
return ( return (
<li <li
className="rdw-dropdownoption-default placeholder-li" className="rdw-dropdownoption-default placeholder-li"
......
...@@ -17,7 +17,7 @@ const DateSelector: React.FC<DateSelectorProps> = ({ ...@@ -17,7 +17,7 @@ const DateSelector: React.FC<DateSelectorProps> = ({
}) => { }) => {
const [openModal, setOpenModal] = useState<boolean>(false) const [openModal, setOpenModal] = useState<boolean>(false)
const [isPrev, setIsPrev] = useState<boolean>(false) const [isPrev, setIsPrev] = useState<boolean>(false)
const toggleOpenModal = () => setOpenModal((prev) => !prev) const toggleOpenModal = () => setOpenModal(prev => !prev)
const handleNextMonth = () => { const handleNextMonth = () => {
setIsPrev(false) setIsPrev(false)
......
...@@ -28,7 +28,7 @@ const ImagePicker: React.FC<ImagePickerProps> = ({ ...@@ -28,7 +28,7 @@ const ImagePicker: React.FC<ImagePickerProps> = ({
const imagePerPage = 10 const imagePerPage = 10
const toggleModal = () => { const toggleModal = () => {
setOpenModal((prev) => !prev) setOpenModal(prev => !prev)
} }
const handleChangePage = (page: number) => { const handleChangePage = (page: number) => {
setCurrentPage(page) setCurrentPage(page)
...@@ -95,7 +95,7 @@ const ImagePicker: React.FC<ImagePickerProps> = ({ ...@@ -95,7 +95,7 @@ const ImagePicker: React.FC<ImagePickerProps> = ({
{imageNames && {imageNames &&
imageNames.length !== 0 && imageNames.length !== 0 &&
imageNames[currentPage - 1].length !== 0 && imageNames[currentPage - 1].length !== 0 &&
imageNames[currentPage - 1].map((imageName) => ( imageNames[currentPage - 1].map(imageName => (
<SingleImage <SingleImage
imageURL={imageName} imageURL={imageName}
key={imageName} key={imageName}
......
...@@ -298,7 +298,7 @@ const Newsletter: React.FC = () => { ...@@ -298,7 +298,7 @@ const Newsletter: React.FC = () => {
subject={subject} subject={subject}
handleChange={handleEditorChange} handleChange={handleEditorChange}
onDelete={handleOpenDeleteModal} onDelete={handleOpenDeleteModal}
></MailSubject> />
<hr /> <hr />
<MonthlyInfo <MonthlyInfo
info={info} info={info}
......
...@@ -70,25 +70,25 @@ const Popups: React.FC = () => { ...@@ -70,25 +70,25 @@ const Popups: React.FC = () => {
const handleCheckboxChange = (value: boolean, type: CheckboxType): void => { const handleCheckboxChange = (value: boolean, type: CheckboxType): void => {
switch (type) { switch (type) {
case CheckboxType.GRDF: case CheckboxType.GRDF:
setPartnersInfo((prevPartnersInfo) => ({ setPartnersInfo(prevPartnersInfo => ({
...prevPartnersInfo, ...prevPartnersInfo,
grdf_failure: value, grdf_failure: value,
})) }))
break break
case CheckboxType.ENEDIS: case CheckboxType.ENEDIS:
setPartnersInfo((prevPartnersInfo) => ({ setPartnersInfo(prevPartnersInfo => ({
...prevPartnersInfo, ...prevPartnersInfo,
enedis_failure: value, enedis_failure: value,
})) }))
break break
case CheckboxType.EGL: case CheckboxType.EGL:
setPartnersInfo((prevPartnersInfo) => ({ setPartnersInfo(prevPartnersInfo => ({
...prevPartnersInfo, ...prevPartnersInfo,
egl_failure: value, egl_failure: value,
})) }))
break break
case CheckboxType.CUSTOM: case CheckboxType.CUSTOM:
setCustomPopup((prev) => ({ setCustomPopup(prev => ({
...prev, ...prev,
popupEnabled: value, popupEnabled: value,
})) }))
...@@ -99,7 +99,7 @@ const Popups: React.FC = () => { ...@@ -99,7 +99,7 @@ const Popups: React.FC = () => {
} }
const handlePopupChange = (field: 'title' | 'description', value: string) => { const handlePopupChange = (field: 'title' | 'description', value: string) => {
setCustomPopup((prev) => ({ setCustomPopup(prev => ({
...prev, ...prev,
[field]: value, [field]: value,
})) }))
...@@ -176,7 +176,7 @@ const Popups: React.FC = () => { ...@@ -176,7 +176,7 @@ const Popups: React.FC = () => {
} }
const handleSelectChange = (event: React.ChangeEvent<HTMLSelectElement>) => { const handleSelectChange = (event: React.ChangeEvent<HTMLSelectElement>) => {
setPopupDuration((prev) => ({ setPopupDuration(prev => ({
...prev, ...prev,
type: event.target.value as durationType, type: event.target.value as durationType,
})) }))
...@@ -197,7 +197,7 @@ const Popups: React.FC = () => { ...@@ -197,7 +197,7 @@ const Popups: React.FC = () => {
years: 1, years: 1,
}) })
} }
setCustomPopup((prev) => ({ setCustomPopup(prev => ({
...prev, ...prev,
endDate: newDate.toISO(), endDate: newDate.toISO(),
})) }))
...@@ -246,14 +246,14 @@ const Popups: React.FC = () => { ...@@ -246,14 +246,14 @@ const Popups: React.FC = () => {
id="switch_enedis" id="switch_enedis"
disabled={customPopup.popupEnabled} disabled={customPopup.popupEnabled}
checked={partnersInfo.enedis_failure} checked={partnersInfo.enedis_failure}
onChange={(event) => { onChange={event => {
handleCheckboxChange( handleCheckboxChange(
event.currentTarget.checked, event.currentTarget.checked,
CheckboxType.ENEDIS CheckboxType.ENEDIS
) )
}} }}
/> />
<label htmlFor="switch_enedis"></label> <label htmlFor="switch_enedis" />
</div> </div>
<div className="switch_div"> <div className="switch_div">
<span>Panne EGL</span> <span>Panne EGL</span>
...@@ -262,14 +262,14 @@ const Popups: React.FC = () => { ...@@ -262,14 +262,14 @@ const Popups: React.FC = () => {
id="switch_egl" id="switch_egl"
disabled={customPopup.popupEnabled} disabled={customPopup.popupEnabled}
checked={partnersInfo.egl_failure} checked={partnersInfo.egl_failure}
onChange={(event) => { onChange={event => {
handleCheckboxChange( handleCheckboxChange(
event.currentTarget.checked, event.currentTarget.checked,
CheckboxType.EGL CheckboxType.EGL
) )
}} }}
/> />
<label htmlFor="switch_egl"></label> <label htmlFor="switch_egl" />
</div> </div>
<div className="switch_div"> <div className="switch_div">
<span>Panne GRDF</span> <span>Panne GRDF</span>
...@@ -278,14 +278,14 @@ const Popups: React.FC = () => { ...@@ -278,14 +278,14 @@ const Popups: React.FC = () => {
id="switch_grdf" id="switch_grdf"
disabled={customPopup.popupEnabled} disabled={customPopup.popupEnabled}
checked={partnersInfo.grdf_failure} checked={partnersInfo.grdf_failure}
onChange={(event) => { onChange={event => {
handleCheckboxChange( handleCheckboxChange(
event.currentTarget.checked, event.currentTarget.checked,
CheckboxType.GRDF CheckboxType.GRDF
) )
}} }}
/> />
<label htmlFor="switch_grdf"></label> <label htmlFor="switch_grdf" />
</div> </div>
</div> </div>
</div> </div>
...@@ -301,14 +301,14 @@ const Popups: React.FC = () => { ...@@ -301,14 +301,14 @@ const Popups: React.FC = () => {
id="switch_popup" id="switch_popup"
disabled={isPartnerNotificationOn()} disabled={isPartnerNotificationOn()}
checked={customPopup.popupEnabled} checked={customPopup.popupEnabled}
onChange={(event) => { onChange={event => {
handleCheckboxChange( handleCheckboxChange(
event.currentTarget.checked, event.currentTarget.checked,
CheckboxType.CUSTOM CheckboxType.CUSTOM
) )
}} }}
/> />
<label htmlFor="switch_popup"></label> <label htmlFor="switch_popup" />
</div> </div>
{customPopup.popupEnabled && {customPopup.popupEnabled &&
...@@ -325,7 +325,7 @@ const Popups: React.FC = () => { ...@@ -325,7 +325,7 @@ const Popups: React.FC = () => {
min={1} min={1}
placeholder="Titre" placeholder="Titre"
value={customPopup.title} value={customPopup.title}
onChange={(event) => onChange={event =>
handlePopupChange('title', event.target.value) handlePopupChange('title', event.target.value)
} }
/> />
...@@ -336,7 +336,7 @@ const Popups: React.FC = () => { ...@@ -336,7 +336,7 @@ const Popups: React.FC = () => {
baseState={convertStringToEditorState( baseState={convertStringToEditorState(
customPopup.description customPopup.description
)} )}
handleChange={(value) => handleChange={value =>
handlePopupChange('description', value) handlePopupChange('description', value)
} }
type="custom_popup" type="custom_popup"
...@@ -348,9 +348,9 @@ const Popups: React.FC = () => { ...@@ -348,9 +348,9 @@ const Popups: React.FC = () => {
<div className="durationInput"> <div className="durationInput">
<select <select
value={popupDuration.type} value={popupDuration.type}
onChange={(event) => handleSelectChange(event)} onChange={event => handleSelectChange(event)}
> >
{OPTIONS.map((option) => ( {OPTIONS.map(option => (
<option <option
key={option.value} key={option.value}
value={option.value} value={option.value}
...@@ -365,8 +365,8 @@ const Popups: React.FC = () => { ...@@ -365,8 +365,8 @@ const Popups: React.FC = () => {
type="number" type="number"
min="0" min="0"
value={popupDuration.duration} value={popupDuration.duration}
onChange={(e) => onChange={e =>
setPopupDuration((prev) => ({ setPopupDuration(prev => ({
...prev, ...prev,
duration: Number(e.target.value), duration: Number(e.target.value),
})) }))
......
...@@ -21,7 +21,7 @@ const PriceRow: React.FC<PriceSectionProps> = ({ ...@@ -21,7 +21,7 @@ const PriceRow: React.FC<PriceSectionProps> = ({
index, index,
isNextPrice, isNextPrice,
}) => { }) => {
const editableLimit: number = 3 const editableLimit = 3
return ( return (
<> <>
...@@ -47,7 +47,7 @@ const PriceRow: React.FC<PriceSectionProps> = ({ ...@@ -47,7 +47,7 @@ const PriceRow: React.FC<PriceSectionProps> = ({
/> />
)} )}
</li> </li>
<hr></hr> <hr />
</> </>
) )
} }
......
...@@ -36,13 +36,13 @@ const PriceSection: React.FC<PriceSectionProps> = ({ fluid, frequency }) => { ...@@ -36,13 +36,13 @@ const PriceSection: React.FC<PriceSectionProps> = ({ fluid, frequency }) => {
endDate: null, endDate: null,
}) })
const { user }: Partial<UserContextProps> = useContext(UserContext) const { user }: Partial<UserContextProps> = useContext(UserContext)
const maxPerList: number = 8 const maxPerList = 8
const handlePriceSelection = useCallback((val: string) => { const handlePriceSelection = useCallback((val: string) => {
if (val === '') val = '0' if (val === '') val = '0'
val = val.replace(/,/g, '.') val = val.replace(/,/g, '.')
val = val.replace(/([^0-9.]+)/, '') val = val.replace(/([^0-9.]+)/, '')
setPriceToSave((prev) => { setPriceToSave(prev => {
return { ...prev, price: val } return { ...prev, price: val }
}) })
}, []) }, [])
...@@ -68,7 +68,7 @@ const PriceSection: React.FC<PriceSectionProps> = ({ fluid, frequency }) => { ...@@ -68,7 +68,7 @@ const PriceSection: React.FC<PriceSectionProps> = ({ fluid, frequency }) => {
}, [priceToSave, user]) }, [priceToSave, user])
const toggleHistory = useCallback(() => { const toggleHistory = useCallback(() => {
setShowHistory((prev) => !prev) setShowHistory(prev => !prev)
}, []) }, [])
const getDate = useCallback((isoString: string): string => { const getDate = useCallback((isoString: string): string => {
...@@ -79,7 +79,7 @@ const PriceSection: React.FC<PriceSectionProps> = ({ fluid, frequency }) => { ...@@ -79,7 +79,7 @@ const PriceSection: React.FC<PriceSectionProps> = ({ fluid, frequency }) => {
}, []) }, [])
const toggleFullList = useCallback(() => { const toggleFullList = useCallback(() => {
setShowFullList((prev) => !prev) setShowFullList(prev => !prev)
}, []) }, [])
useEffect(() => { useEffect(() => {
...@@ -120,7 +120,7 @@ const PriceSection: React.FC<PriceSectionProps> = ({ fluid, frequency }) => { ...@@ -120,7 +120,7 @@ const PriceSection: React.FC<PriceSectionProps> = ({ fluid, frequency }) => {
} }
}, [refreshData, frequency, fluid]) }, [refreshData, frequency, fluid])
if (isLoading) return <Loader></Loader> if (isLoading) return <Loader />
if (!prices.length) return <section> Aucun prix trouvé</section> if (!prices.length) return <section> Aucun prix trouvé</section>
return ( return (
<section> <section>
...@@ -136,7 +136,7 @@ const PriceSection: React.FC<PriceSectionProps> = ({ fluid, frequency }) => { ...@@ -136,7 +136,7 @@ const PriceSection: React.FC<PriceSectionProps> = ({ fluid, frequency }) => {
className="input-dark price-select" className="input-dark price-select"
type="text" type="text"
value={priceToSave.price.toString()} value={priceToSave.price.toString()}
onChange={(e) => handlePriceSelection(e.target.value)} onChange={e => handlePriceSelection(e.target.value)}
placeholder={priceToSave.price === '' ? 'Saisir le nouveau prix' : ''} placeholder={priceToSave.price === '' ? 'Saisir le nouveau prix' : ''}
/> />
<span className="euro"></span> <span className="euro"></span>
......
...@@ -29,7 +29,7 @@ export const links: { ...@@ -29,7 +29,7 @@ export const links: {
}, },
} }
export const routes = Object.keys(links).map((key) => ({ export const routes = Object.keys(links).map(key => ({
label: links[key].label, label: links[key].label,
path: links[key].path, path: links[key].path,
adminOnly: links[key].adminOnly, adminOnly: links[key].adminOnly,
......
...@@ -4,7 +4,7 @@ import { useHistory } from 'react-router-dom' ...@@ -4,7 +4,7 @@ import { useHistory } from 'react-router-dom'
import { links } from '../components/Routes/Router' import { links } from '../components/Routes/Router'
import { UserContext } from './userContext' import { UserContext } from './userContext'
export interface Auth { interface Auth {
loginUser: () => Promise<void> loginUser: () => Promise<void>
error: null error: null
logoutUser: () => void logoutUser: () => void
......
import axios, { AxiosRequestConfig } from 'axios' import axios, { AxiosRequestConfig } from 'axios'
import { DateTime } from 'luxon' import { DateTime } from 'luxon'
import { toast } from 'react-toastify' import { toast } from 'react-toastify'
import { ConsentEntity, IConsent } from '../models/consent.model'
import { import {
ConsentEntity,
ConsentPaginationEntity, ConsentPaginationEntity,
IConsent,
IConsentPagination, IConsentPagination,
} from './../models/consent.model' } from '../models/consent.model'
export class ConsentService { export class ConsentService {
/** /**
...@@ -28,7 +29,7 @@ export class ConsentService { ...@@ -28,7 +29,7 @@ export class ConsentService {
) )
const consentPagination = data as ConsentPaginationEntity const consentPagination = data as ConsentPaginationEntity
return this.parseConsentPagination(consentPagination) return this.parseConsentPagination(consentPagination)
} catch (e: any) { } catch (e) {
if (e.response.status === 403) { if (e.response.status === 403) {
toast.error("Accès refusé : vous n'avez pas les droits nécessaires") toast.error("Accès refusé : vous n'avez pas les droits nécessaires")
} else { } else {
...@@ -72,7 +73,7 @@ export class ConsentService { ...@@ -72,7 +73,7 @@ export class ConsentService {
public parseConsentPagination = ( public parseConsentPagination = (
consentPaginationEntity: ConsentPaginationEntity consentPaginationEntity: ConsentPaginationEntity
): IConsentPagination => { ): IConsentPagination => {
const rows = consentPaginationEntity.rows.map((consent) => const rows = consentPaginationEntity.rows.map(consent =>
this.parseConsent(consent) this.parseConsent(consent)
) )
......
...@@ -27,7 +27,7 @@ export class NewsletterService { ...@@ -27,7 +27,7 @@ export class NewsletterService {
axiosHeaders axiosHeaders
) )
toast.success('Objet de la newsletter enregistré !') toast.success('Objet de la newsletter enregistré !')
} catch (e: any) { } catch (e) {
if (e.response.status === 403) { if (e.response.status === 403) {
toast.error("Accès refusé : vous n'avez pas les droits nécessaires") toast.error("Accès refusé : vous n'avez pas les droits nécessaires")
} else { } else {
...@@ -56,7 +56,7 @@ export class NewsletterService { ...@@ -56,7 +56,7 @@ export class NewsletterService {
axiosHeaders axiosHeaders
) )
return data as IMailSubject return data as IMailSubject
} catch (e: any) { } catch (e) {
console.error('error', e) console.error('error', e)
return null return null
} }
...@@ -79,7 +79,7 @@ export class NewsletterService { ...@@ -79,7 +79,7 @@ export class NewsletterService {
axiosHeaders axiosHeaders
) )
toast.success('Objet de la newsletter supprimé !') toast.success('Objet de la newsletter supprimé !')
} catch (e: any) { } catch (e) {
if (e.response.status === 403) { if (e.response.status === 403) {
toast.error("Accès refusé : vous n'avez pas les droits nécessaires") toast.error("Accès refusé : vous n'avez pas les droits nécessaires")
} else { } else {
...@@ -112,7 +112,7 @@ export class NewsletterService { ...@@ -112,7 +112,7 @@ export class NewsletterService {
axiosHeaders axiosHeaders
) )
toast.success('Information du mois enregistrée !') toast.success('Information du mois enregistrée !')
} catch (e: any) { } catch (e) {
if (e.response.status === 403) { if (e.response.status === 403) {
toast.error("Accès refusé : vous n'avez pas les droits nécessaires") toast.error("Accès refusé : vous n'avez pas les droits nécessaires")
} else { } else {
...@@ -139,7 +139,7 @@ export class NewsletterService { ...@@ -139,7 +139,7 @@ export class NewsletterService {
axiosHeaders axiosHeaders
) )
return data as IMonthlyInfo return data as IMonthlyInfo
} catch (e: any) { } catch (e) {
console.error('error', e) console.error('error', e)
return null return null
} }
...@@ -162,7 +162,7 @@ export class NewsletterService { ...@@ -162,7 +162,7 @@ export class NewsletterService {
axiosHeaders axiosHeaders
) )
toast.success('Informations du mois supprimées !') toast.success('Informations du mois supprimées !')
} catch (e: any) { } catch (e) {
if (e.response.status === 403) { if (e.response.status === 403) {
toast.error("Accès refusé : vous n'avez pas les droits nécessaires") toast.error("Accès refusé : vous n'avez pas les droits nécessaires")
} else { } else {
...@@ -196,7 +196,7 @@ export class NewsletterService { ...@@ -196,7 +196,7 @@ export class NewsletterService {
axiosHeaders axiosHeaders
) )
toast.success('Nouveautés du mois enregistrés !') toast.success('Nouveautés du mois enregistrés !')
} catch (e: any) { } catch (e) {
if (e.response.status === 403) { if (e.response.status === 403) {
toast.error("Accès refusé : vous n'avez pas les droits nécessaires") toast.error("Accès refusé : vous n'avez pas les droits nécessaires")
} else { } else {
...@@ -246,7 +246,7 @@ export class NewsletterService { ...@@ -246,7 +246,7 @@ export class NewsletterService {
axiosHeaders axiosHeaders
) )
toast.success('Nouveautés du mois supprimées !') toast.success('Nouveautés du mois supprimées !')
} catch (e: any) { } catch (e) {
if (e.response.status === 403) { if (e.response.status === 403) {
toast.error("Accès refusé : vous n'avez pas les droits nécessaires") toast.error("Accès refusé : vous n'avez pas les droits nécessaires")
} else { } else {
...@@ -280,7 +280,7 @@ export class NewsletterService { ...@@ -280,7 +280,7 @@ export class NewsletterService {
axiosHeaders axiosHeaders
) )
toast.success('Sondage enregistré !') toast.success('Sondage enregistré !')
} catch (e: any) { } catch (e) {
if (e.response.status === 403) { if (e.response.status === 403) {
toast.error("Accès refusé : vous n'avez pas les droits nécessaires") toast.error("Accès refusé : vous n'avez pas les droits nécessaires")
} else { } else {
...@@ -326,7 +326,7 @@ export class NewsletterService { ...@@ -326,7 +326,7 @@ export class NewsletterService {
axiosHeaders axiosHeaders
) )
toast.success('Sondage supprimé !') toast.success('Sondage supprimé !')
} catch (e: any) { } catch (e) {
if (e.response.status === 403) { if (e.response.status === 403) {
toast.error("Accès refusé : vous n'avez pas les droits nécessaires") toast.error("Accès refusé : vous n'avez pas les droits nécessaires")
} else { } else {
......
// jest-dom adds custom jest matchers for asserting on DOM nodes.
// allows you to do things like:
// expect(element).toHaveTextContent(/react/i)
// learn more: https://github.com/testing-library/jest-dom
import '@testing-library/jest-dom'