Skip to content

Commit

Permalink
[LINT] Applied linter fix
Browse files Browse the repository at this point in the history
  • Loading branch information
adbusnel authored and github-actions[bot] committed Aug 13, 2024
1 parent 0e1ec8f commit f2efbe9
Show file tree
Hide file tree
Showing 12 changed files with 92 additions and 102 deletions.
52 changes: 24 additions & 28 deletions src/Components/Accounts/Adm/admAccountsTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import cross from '../../../assets/Cross.png'
export default function AdmAccountsTable () {
const [accountList, setAccountList] = useState([]) // list of accounts
const [isPopupOpen, setIsPopupOpen] = useState(false)
const [userId, setUserId] = useState("")
const [userId, setUserId] = useState('')

async function getAccountList () {
const baseUrl = process.env.REACT_APP_BACKEND_URL + '/user/all'
Expand All @@ -35,42 +35,38 @@ export default function AdmAccountsTable () {
}, [])

const openPopup = () => {
if (isPopupOpen)
setUserId('')
if (isPopupOpen) { setUserId('') }
setIsPopupOpen(!isPopupOpen)
}

const callDeleteAccount = (deleteType, user_id) => {
setUserId(user_id)
if (deleteType)
setIsPopupOpen(!isPopupOpen)
else
deleteAccount(deleteType, user_id)
if (deleteType) { setIsPopupOpen(!isPopupOpen) } else { deleteAccount(deleteType, user_id) }
}

async function deleteAccount (deleteType, accountId) {
const baseUrl = process.env.REACT_APP_BACKEND_URL + '/adm/deleteUser/' + accountId
const token = sessionStorage.getItem('token')
const token = sessionStorage.getItem('token')

const resp = await fetch(baseUrl, {
method: 'DELETE',
headers: {
'x-auth-token': token,
'Content-Type': 'application/json'
},
body: JSON.stringify({
deletePermanently: deleteType
})
const resp = await fetch(baseUrl, {
method: 'DELETE',
headers: {
'x-auth-token': token,
'Content-Type': 'application/json'
},
body: JSON.stringify({
deletePermanently: deleteType
})
if (resp.status === 401) {
disconnect()
} else if (resp.status === 200) {
toast.success(deleteType ? 'Le compte a été supprimé' : 'Le compte a été suspendu')
getAccountList()
} else {
toast.error("une alerte s'est produite")
getAccountList()
}
})
if (resp.status === 401) {
disconnect()
} else if (resp.status === 200) {
toast.success(deleteType ? 'Le compte a été supprimé' : 'Le compte a été suspendu')
getAccountList()
} else {
toast.error("une alerte s'est produite")
getAccountList()
}
}

return (
Expand Down Expand Up @@ -101,8 +97,8 @@ export default function AdmAccountsTable () {
<td>{data.firstname}</td>
<td>{data.lastname}</td>
<td>{data.email}</td>
<td><button onClick={() => callDeleteAccount(false, data._id)} >Suspendre le Compte</button></td>
<td><button onClick={() => callDeleteAccount(true, data._id)} >Supprimer le Compte</button></td>
<td><button onClick={() => callDeleteAccount(false, data._id)}>Suspendre le Compte</button></td>
<td><button onClick={() => callDeleteAccount(true, data._id)}>Supprimer le Compte</button></td>
</tr>
)
}
Expand Down
56 changes: 26 additions & 30 deletions src/Components/Accounts/SchoolAdm/schoolAccountsTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export default function SchoolAccountsTable () {
const [teacherList, setTeacherList] = useState([])
const [studentList, setStudentList] = useState([])
const [isPopupOpen, setIsPopupOpen] = useState(false)
const [userId, setUserId] = useState("")
const [userId, setUserId] = useState('')

async function getAccountList () {
const baseUrl = process.env.REACT_APP_BACKEND_URL + '/user/all'
Expand Down Expand Up @@ -56,41 +56,37 @@ export default function SchoolAccountsTable () {

async function deleteAccount (deleteType, accountId) {
const baseUrl = process.env.REACT_APP_BACKEND_URL + '/adm/deleteUser/' + accountId
const token = sessionStorage.getItem('token')
const token = sessionStorage.getItem('token')

const resp = await fetch(baseUrl, {
method: 'DELETE',
headers: {
'x-auth-token': token,
'Content-Type': 'application/json'
},
body: JSON.stringify({
deletePermanently: deleteType
})
const resp = await fetch(baseUrl, {
method: 'DELETE',
headers: {
'x-auth-token': token,
'Content-Type': 'application/json'
},
body: JSON.stringify({
deletePermanently: deleteType
})
if (resp.status === 401) {
disconnect()
} else if (resp.status === 200) {
toast.success(deleteType ? 'Le compte a été supprimé' : 'Le compte a été suspendu')
getAccountList()
} else {
toast.error("une alerte s'est produite")
getAccountList()
}
})
if (resp.status === 401) {
disconnect()
} else if (resp.status === 200) {
toast.success(deleteType ? 'Le compte a été supprimé' : 'Le compte a été suspendu')
getAccountList()
} else {
toast.error("une alerte s'est produite")
getAccountList()
}
}

const openPopup = () => {
if (isPopupOpen)
setUserId('')
if (isPopupOpen) { setUserId('') }
setIsPopupOpen(!isPopupOpen)
}

const callDeleteAccount = (deleteType, user_id) => {
setUserId(user_id)
if (deleteType)
setIsPopupOpen(!isPopupOpen)
else
deleteAccount(deleteType, user_id)
if (deleteType) { setIsPopupOpen(!isPopupOpen) } else { deleteAccount(deleteType, user_id) }
}

return (
Expand Down Expand Up @@ -132,8 +128,8 @@ export default function SchoolAccountsTable () {
<td>{data.email}</td>
{/* <td>{data.title}</td> */}
<td>{showClasses(data.classes)}</td>
<td><button onClick={(e) => { e.stopPropagation(); callDeleteAccount(false, data._id)}} >Suspendre le Compte</button></td>
<td><button onClick={(e) => { e.stopPropagation(); callDeleteAccount(true, data._id)}} >Supprimer le Compte</button></td>
<td><button onClick={(e) => { e.stopPropagation(); callDeleteAccount(false, data._id) }}>Suspendre le Compte</button></td>
<td><button onClick={(e) => { e.stopPropagation(); callDeleteAccount(true, data._id) }}>Supprimer le Compte</button></td>
</tr>
)
}
Expand Down Expand Up @@ -168,8 +164,8 @@ export default function SchoolAccountsTable () {
<td>{data.lastname}</td>
<td>{data.email}</td>
<td>{showClasses(data.classes)}</td>
<td><button onClick={(e) => { e.stopPropagation(); callDeleteAccount(false, data._id)}} >Suspendre le Compte</button></td>
<td><button onClick={(e) => { e.stopPropagation(); callDeleteAccount(true, data._id)}} >Supprimer le Compte</button></td>
<td><button onClick={(e) => { e.stopPropagation(); callDeleteAccount(false, data._id) }}>Suspendre le Compte</button></td>
<td><button onClick={(e) => { e.stopPropagation(); callDeleteAccount(true, data._id) }}>Supprimer le Compte</button></td>
</tr>
)
}
Expand Down
12 changes: 6 additions & 6 deletions src/Components/Aides/aides.jsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import React, { useState, useEffect } from 'react'
import '../../css/Components/Aides/aides.scss'
import { disconnect } from '../../functions/disconnect'
import phoneIcon from "../../assets/phoneIcon.png"
import mailIcon from "../../assets/mailIcon.png"
import phoneIcon from '../../assets/phoneIcon.png'
import mailIcon from '../../assets/mailIcon.png'

export default function AidePage (props) {
const [categories, setCategories] = useState([])
Expand Down Expand Up @@ -80,7 +80,7 @@ export default function AidePage (props) {
}

return (
<div style={{display: "flex", flexDirection: "column"}}>
<div style={{ display: 'flex', flexDirection: 'column' }}>
<p>{errMessage || ''}</p>
<div id='category-container'>
{categories.map((category) => (
Expand All @@ -89,10 +89,10 @@ export default function AidePage (props) {
</button>
))}
</div>
<div id="help-container">
<div id='help-container'>
<div id='filtered-contacts-container'>
{filteredContacts.map((contact) =>
<div key={contact._id} className={selectedContact === contact._id ? 'selected-contact-btn contact-btn' : 'contact-btn' } data-testid={'contact-btn-' + contact.id} onClick={() => filterContact(contact._id)}>
<div key={contact._id} className={selectedContact === contact._id ? 'selected-contact-btn contact-btn' : 'contact-btn'} data-testid={'contact-btn-' + contact.id} onClick={() => filterContact(contact._id)}>
{contact.name}
</div>
)}
Expand All @@ -114,7 +114,7 @@ export default function AidePage (props) {
chosenContact.email
? (
<div className='contact-element-container'>
<img src={mailIcon} alt='Adresse Email' className='contact-element-title'/>
<img src={mailIcon} alt='Adresse Email' className='contact-element-title' />
<p className='contact-element-content'>{chosenContact.email}</p>
</div>
)
Expand Down
2 changes: 1 addition & 1 deletion src/Components/ChatRoom/chatRoomSidebar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const ChatRoomSidebar = ({
const handleClick = (conversation) => {
clearMessageAndError()
setCurrentConversation(conversation)
let conv = []
const conv = []
conversation.participants.map((participant) => (
conv.push(participant.firstname + ' ' + participant.lastname)
))
Expand Down
4 changes: 2 additions & 2 deletions src/Components/ChatRoom/message.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,9 @@ const Message = ({ message, participants, next }) => {
)}
</div>
</div>
<div className="message-identification" style={isMyMessage ? {flexDirection: "row-reverse"} : {flexDirection: 'row'}}>
<div className='message-identification' style={isMyMessage ? { flexDirection: 'row-reverse' } : { flexDirection: 'row' }}>
{
(next !== undefined && next.user === message.user) ? <span className="img image-right" /> : (isMyMessage ? <img className='img image-right' src={messageUser?.picture ? messageUser.picture : userIcon} alt={userIcon}/> : <img className='img image-left' src={messageUser?.picture ? messageUser.picture : userIcon} alt={userIcon}/>)
(next !== undefined && next.user === message.user) ? <span className='img image-right' /> : (isMyMessage ? <img className='img image-right' src={messageUser?.picture ? messageUser.picture : userIcon} alt={userIcon} /> : <img className='img image-left' src={messageUser?.picture ? messageUser.picture : userIcon} alt={userIcon} />)
}
<span className='message-time'>{(next !== undefined && moment(message.date).format('DD/MM/YY HH:mm') === moment(next.date).format('DD/MM/YY HH:mm')) ? '' : moment(message.date).format('DD/MM/YY HH:mm')}</span>
</div>
Expand Down
24 changes: 11 additions & 13 deletions src/Components/Header/headerComp.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import React, {useState, useEffect, useContext} from 'react'
import React, { useState, useEffect, useContext } from 'react'
import backButton from '../../assets/backButton.png'
import '../../css/Components/Header/headerComp.scss'
import { useNavigate, useLocation } from 'react-router-dom'
import { WebsocketContext } from '../../contexts/websocket'
import Popup from 'reactjs-popup'
import moment from 'moment'
import {disconnect} from '../../functions/disconnect'
import { disconnect } from '../../functions/disconnect'

import '../../css/Components/Popup/popup.scss'

Expand Down Expand Up @@ -55,7 +55,6 @@ export default function HeaderComp ({ title, withLogo = true, subtitle, withRetu
setProfile(JSON.parse(sessionStorage.getItem('profile')))
}, [])


function handleGetNotifications () {
fetch(`${process.env.REACT_APP_BACKEND_URL}/shared/notifications/`, {
method: 'GET',
Expand Down Expand Up @@ -94,7 +93,6 @@ export default function HeaderComp ({ title, withLogo = true, subtitle, withRetu
handleGetNotifications()
}


return (
<div id='header'>
<Popup open={isShown} onClose={handleShowNotifications} modal>
Expand Down Expand Up @@ -148,16 +146,16 @@ export default function HeaderComp ({ title, withLogo = true, subtitle, withRetu
)
: ''}
{withLogo && (
<div className='profile' style={{display: "flex", flexDirection: "row", gap: "10px", justifyContent: "center"}}>
<div className='firstname-lastname' style={{display: "flex", flexDirection: "column", color: '#4f23e2', fontFamily: 'Inter', fontSize: "larger"}}>
<span>{profile?.firstname}</span>
<span>{profile?.lastname}</span>
</div>
<img style={{width: "60px", borderRadius: "50%"}} src={profile?.picture ? profile.picture : userIcon} alt='Image de profile' />
<div style={{ background: 'none' }} onClick={handleShowNotifications} className='notifications' data-tooltip-id='notification-tooltip'>
<FontAwesomeIcon icon={faBell} style={{ fontSize: "3em", cursor: "pointer", color: '#4f23e2' }} />
</div>
<div className='profile' style={{ display: 'flex', flexDirection: 'row', gap: '10px', justifyContent: 'center' }}>
<div className='firstname-lastname' style={{ display: 'flex', flexDirection: 'column', color: '#4f23e2', fontFamily: 'Inter', fontSize: 'larger' }}>
<span>{profile?.firstname}</span>
<span>{profile?.lastname}</span>
</div>
<img style={{ width: '60px', borderRadius: '50%' }} src={profile?.picture ? profile.picture : userIcon} alt='Image de profile' />
<div style={{ background: 'none' }} onClick={handleShowNotifications} className='notifications' data-tooltip-id='notification-tooltip'>
<FontAwesomeIcon icon={faBell} style={{ fontSize: '3em', cursor: 'pointer', color: '#4f23e2' }} />
</div>
</div>
)}
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion src/Components/Popup/deleteAccount.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from 'react'
import '../../css/Components/Popup/popup.scss'
import '../../css/pages/createAlerts.scss'

const DeleteAccountPopupContent = ({user_id, deleteUserAccount, closeDeleteAccountPopup}) => {
const DeleteAccountPopupContent = ({ user_id, deleteUserAccount, closeDeleteAccountPopup }) => {
return (
<>
<div>
Expand Down
4 changes: 2 additions & 2 deletions src/Components/Sidebar/sidebar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ export default function Sidebar () {
<div data-testid='expanded' className='collapsed'>
<div className='top'>
<Link to='/'>
<img style={{width: "90%", paddingTop: "10px"}} id='logo' src={schoodIcon} alt='Schood' />
<img style={{ width: '90%', paddingTop: '10px' }} id='logo' src={schoodIcon} alt='Schood' />
</Link>
<span className='divider' />
</div>
Expand Down Expand Up @@ -297,7 +297,7 @@ export default function Sidebar () {
<div data-testid='expanded' className='expanded'>
<div className='top'>
<Link to='/'>
<img style={{width: "90%", padding: "20px"}} id='logo' src={logoSchood} alt='Schood' />
<img style={{ width: '90%', padding: '20px' }} id='logo' src={logoSchood} alt='Schood' />
</Link>
<span className='divider' />
{role === 'student' && (
Expand Down
2 changes: 1 addition & 1 deletion src/Components/userProfile/userProfile.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import userIcon from '../../assets/userIcon.png'
export function UserProfile ({ profile, fullname = false, whiteMode = false, img = true }) {
return (
<div className='profile'>
{
{
img ? <img className='img' src={profile?.picture ? profile.picture : userIcon} alt='user icon' title={profile?.firstname && profile?.lastname ? profile.firstname + ' ' + profile.lastname : ''} /> : ''
}
<div className='profile-content'>
Expand Down
2 changes: 1 addition & 1 deletion src/Users/Teacher/formTeacherPage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ const FormTeacherPage = () => {
/>
</div>
<div className='different-page-content'>
<div className='left-half' style={{ marginBottom: '20px', height: 'calc(100vh - 124px)', overflowY: 'auto', display: "flex", justifyContent: "center" }}>
<div className='left-half' style={{ marginBottom: '20px', height: 'calc(100vh - 124px)', overflowY: 'auto', display: 'flex', justifyContent: 'center' }}>
<TeacherFormContent form={formData} error={error} />
</div>
</div>
Expand Down
6 changes: 3 additions & 3 deletions src/Users/Teacher/newFormPage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -180,10 +180,10 @@ const NewFormPage = () => {
returnCall={handlePopup}
/>
</div>
<div className='form-container' >
<Popup contentStyle={{width: "500px"}} open={isOpen} onClose={() => setIsOpen(false)} modal>
<div className='form-container'>
<Popup contentStyle={{ width: '500px' }} open={isOpen} onClose={() => setIsOpen(false)} modal>
{(close) => (
<div style={{maxWidth: "500px", height: "600px"}} className='popup-modal-container'>
<div style={{ maxWidth: '500px', height: '600px' }} className='popup-modal-container'>
<span className='title-popup'>Sauvegarder les modifications ?</span>
<span className='content-popup'>Vous êtes sur le point de quitter la page et vous avez des modifications en cours qui ne sont pas sauvegardées. En quittant sans sauvegarder, vous perdrez toutes vos modifications.</span>
{errMessage ? <span className='error-message' style={{ color: 'red' }}>{errMessage}</span> : ''}
Expand Down
28 changes: 14 additions & 14 deletions src/Users/Teacher/teacherAccountsPage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,17 @@ import '../../css/pages/accountsPage.scss'
import '../../css/Components/Popup/popup.scss'

export default function TeacherAccountsPage () {
return (
<div>
<div>
<HeaderComp
title='Liste des Comptes'
withLogo
/>
</div>
<div className='page-content'>
<TeacherAccountsTable />
</div>
</div>
)
}
return (
<div>
<div>
<HeaderComp
title='Liste des Comptes'
withLogo
/>
</div>
<div className='page-content'>
<TeacherAccountsTable />
</div>
</div>
)
}

0 comments on commit f2efbe9

Please sign in to comment.