Skip to content

Commit

Permalink
implement README in doc; add c8 and monocart in order to make test co…
Browse files Browse the repository at this point in the history
…verage; delete getUserName logic and its tests, handler and logic in app; add styles with tailwindcss; create new test spec of getNews; b00tc4mp#87
  • Loading branch information
Samu2196 committed Aug 22, 2024
1 parent 27e4822 commit 3d21592
Show file tree
Hide file tree
Showing 40 changed files with 1,114 additions and 386 deletions.
19 changes: 19 additions & 0 deletions staff/samuele-spinetti/project/api/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# api

## install

```sh
$ npm i
```

## run

```sh
$ npm start
```

## inspect

```sh
$ npm run inspect
```
15 changes: 0 additions & 15 deletions staff/samuele-spinetti/project/api/handlers/getUserNameHandler.js

This file was deleted.

2 changes: 0 additions & 2 deletions staff/samuele-spinetti/project/api/handlers/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import authenticateUserHandler from './authenticateUserHandler.js'
import registerUserHandler from './registerUserHandler.js'
import getUserNameHandler from './getUserNameHandler.js'
import getUserHandler from './getUserHandler.js'
import updateAvatarHandler from './updateAvatarHandler.js'
import updatePasswordHandler from './updatePasswordHandler.js'
Expand All @@ -20,7 +19,6 @@ import deleteCommentHandler from './deleteCommentHandler.js'
export {
authenticateUserHandler,
registerUserHandler,
getUserNameHandler,
getUserHandler,
updateAvatarHandler,
updatePasswordHandler,
Expand Down
45 changes: 23 additions & 22 deletions staff/samuele-spinetti/project/api/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import { cors, jsonBodyParser, jwtVerifier, errorHandler } from './middlewares/i
import {
authenticateUserHandler,
registerUserHandler,
getUserNameHandler,
getUserHandler,
updateAvatarHandler,
updatePasswordHandler,
Expand Down Expand Up @@ -43,8 +42,6 @@ mongoose.connect(process.env.MONGODB_URI)

api.post('/comments/:postId', jwtVerifier, jsonBodyParser, createCommentHandler)

api.get('/users/:targetUserId/name', jwtVerifier, getUserNameHandler)

api.get('/users/:targetUserId/settings', jwtVerifier, getUserHandler)

api.get('/healthcareproviders', jwtVerifier, getAllHCPsHandler)
Expand All @@ -71,27 +68,31 @@ mongoose.connect(process.env.MONGODB_URI)

api.delete('/comments/:commentId', jwtVerifier, deleteCommentHandler)

new cron('0 * * * * *', () => {

api.get('/', jwtVerifier, (req, res, next) => {
const { userId } = req

try {
logic.getNews(userId)
.then(newsArticles => res.json(newsArticles))
.catch(error => next(error))
} catch (error) {
next(error)
}
})
},
null,
true,
'Europe/Madrid'
)
// new cron('0 * * * * *', () => {

// console.log('works')

// api.get('/', jwtVerifier, (req, res, next) => {
// const { userId } = req

// try {
// logic.getNews(userId)
// .then(newsArticles => res.json(newsArticles))
// .catch(error => next(error))
// } catch (error) {
// next(error)
// }
// })
// },
// null,
// true,
// 'Europe/Madrid'
// )

api.use(errorHandler)

api.listen(process.env.PORT, () => console.info(`API listening on PORT ${process.env.PORT}`))
})
.catch(error => console.error(error))
.catch(error => console.error(error))

//0 */2 * * *
1 change: 0 additions & 1 deletion staff/samuele-spinetti/project/api/test/get-user-name.sh

This file was deleted.

21 changes: 16 additions & 5 deletions staff/samuele-spinetti/project/app/README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,19 @@
# React + Vite
# app

This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules.
## install

Currently, two official plugins are available:
```sh
$ npm i
```

- [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react/README.md) uses [Babel](https://babeljs.io/) for Fast Refresh
- [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react-swc) uses [SWC](https://swc.rs/) for Fast Refresh
## run

```sh
$ npm start
```

## compile

```sh
$ npm run build
```
6 changes: 6 additions & 0 deletions staff/samuele-spinetti/project/app/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@

<link rel="stylesheet" href="https://unpkg.com/[email protected]/dist/leaflet.css"
integrity="sha256-p4NxAoJBhIIN+hmNHrzRCf9tD/miZyoHS5obTRR9BMY=" crossorigin="" />

<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Cabin:ital,wght@0,400..700;1,400..700&display=swap"
rel="stylesheet">

</head>

<body>
Expand Down
32 changes: 0 additions & 32 deletions staff/samuele-spinetti/project/app/logic/getUserName.js

This file was deleted.

2 changes: 0 additions & 2 deletions staff/samuele-spinetti/project/app/logic/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import getUserName from './getUserName'
import isUserLoggedIn from './isUserLoggedIn'
import loginUser from './loginUser'
import logoutUser from './logoutUser'
Expand Down Expand Up @@ -26,7 +25,6 @@ const logic = {
loginUser,
logoutUser,
registerUser,
getUserName,
getUser,
updateAvatar,
updatePassword,
Expand Down
10 changes: 10 additions & 0 deletions staff/samuele-spinetti/project/app/util/randomQuery.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
function randomQuery() {
const querys = ['LGBTQI+', 'lgbtqi+', 'gay', 'lesbian', 'homosexual', 'LGBTQ health', 'queer', 'gay pride']

const query = querys[Math.floor(Math.random() * querys.length)]

return query

}

export default randomQuery
6 changes: 3 additions & 3 deletions staff/samuele-spinetti/project/app/view/common/Alert.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ export default function Alert({ message, onAccept }) {
<Container className="fixed w-screen top-0 h-screen bg-black opacity-60"></Container>

<Container className="fixed w-screen top-0 h-screen flex items-center justify-center">
<Container className="p-4 border bg-white flex-col w-[10rem] h-[10rem] flex items-center justify-center gap-5 rounded-xl">
<Paragraph className="font-semibold">{message}</Paragraph>
<Button className="border border-black rounded-xl w-24 h-10 bg-gradient-to-br from-green-400 to-fuchsia-500" onClick={onAccept}><Span className="text-white">Accept</Span></Button>
<Container className="p-4 border bg-white flex-col h-52 w-52 flex items-center justify-center gap-5 rounded-xl">
<Paragraph className="text-lg">{message}</Paragraph>
<Button className="border w-20 h-10 border-gray-300 bg-white rounded-lg" onClick={onAccept}>Accept</Button>
</Container>
</Container>
</>
Expand Down
4 changes: 2 additions & 2 deletions staff/samuele-spinetti/project/app/view/common/Confirm.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import Paragraph from '../library/Paragraph'

export default function Confirm({ message, onAccept, onCancel }) {
return <>
<Container className="fixed w-screen top-0 left-0 h-screen justify-center items-center bg-black opacity-60"></Container>
<Container className="fixed w-screen top-0 left-0 h-screen bg-black opacity-60"></Container>

<Container className="fixed w-screen top-0 h-screen flex items-center justify-center">
<Container className="fixed w-screen top-0 left-0 h-screen flex items-center justify-center">
<Container className="p-4 border bg-white h-52 w-52 rounded-xl flex flex-col justify-center items-center">
<Paragraph className="text-base font-semibold">{message}</Paragraph>
<br />
Expand Down
4 changes: 2 additions & 2 deletions staff/samuele-spinetti/project/app/view/home/Footer.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export default function Footer({ onHomeClicked, onHealthCareProvidersListClicked

const handleCommunityClick = () => onCommunityClicked()

return <footer className="fixed items-center bottom-0 left-0 w-full flex justify-around shadow-[0_-1px_1px] bg-gradient-to-br from-green-400 to-fuchsia-500 h-20">
return <footer className="fixed items-center bottom-0 left-0 w-full flex justify-around shadow-[0_-1px_1px] bg-gradient-to-br from-green-400 to-fuchsia-500 h-20 z-40">

<Container>
<Button onClick={handleHomeClick}>
Expand All @@ -19,7 +19,7 @@ export default function Footer({ onHomeClicked, onHealthCareProvidersListClicked

<Container>
<Button onClick={handleCommunityClick}>
<Image src="/communityIcon.svg" alt="Community icon" className="h-[50px] w-[50px]" />
<Image src="/communityIcon.svg" alt="Community icon" className="h-[70px] w-[70px]" />
</Button>
</Container>

Expand Down
4 changes: 2 additions & 2 deletions staff/samuele-spinetti/project/app/view/home/Header.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export default function Header({ onProfileSettingsClicked, onNewsArticlesListCli
</Button>
</Container>

{location.pathname === '/' &&
{(location.pathname === '/' || location.pathname === '/saved') && (
<Container className="inline-flex">
<Button className="bg-gray-100 hover:bg-gray-300 py-2 px-4 rounded-l" onClick={handleNewsArticlesListClick}>
<Image className="w-[20px] h-[20px]" src="./news.svg" />
Expand All @@ -47,7 +47,7 @@ export default function Header({ onProfileSettingsClicked, onNewsArticlesListCli
<Image className="w-[20px] h-[20px]" src="./heart.svg" />
</Button>
</Container>
}
)}

<Container className="mr-5">
<Button className="border-black " onClick={handleLogoutClick}>Logout</Button>
Expand Down
Loading

0 comments on commit 3d21592

Please sign in to comment.