-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Hel 509/search history #349
Merged
Merged
Changes from 1 commit
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
54055d5
(hel-508) page favoris + userContext
schlaifa d99a56f
(hel-508) les ws getAllFavoris, addToFavoris et removeFromFavoris
schlaifa d92eb6d
(hel-508) page favoris
schlaifa fa64941
(hel-508) Add star component to summary page and clean code
schlaifa d52e478
(hel-508) merge develop into favoris
schlaifa 16e3bd4
(hel-508) add a popover to star button
schlaifa 004718e
(hel-508) retour demo
schlaifa b7a86d7
(hel-509) merge favoris into search history
schlaifa d1a780c
(hel-509) save search history back and front
schlaifa 767e26e
(hel-509) get all user search history front and back
schlaifa 45d33dd
(hel-509) get only the newest searchs
schlaifa e95ca0d
(hel-508) create migration script to add favori table
schlaifa 8518f5c
(hel-509) add migrattion script to create search_history table
schlaifa 8431a03
(hel-508) correct PR errors
schlaifa a9d8ac2
(hel-509) correct code issues
schlaifa 8999f4f
(hel-508) fix merge conflict
schlaifa f89bd9c
(hel-509) fix merge conflict
schlaifa 79d3d09
(hel-509) fix merge conflicts
schlaifa 428ddf5
(hel-509) fix merge conflicts
schlaifa 5c260ea
(hel-509) fix code issues
schlaifa 84c35a4
(hel-509) fix code issues
schlaifa 3f184b2
(hel-509) fix code issues
schlaifa 6674201
(hel-509) fix code issues
schlaifa a06cf96
(hel-509) protect favoris and history routes
schlaifa f4eb046
(hel-509) fix code issues
schlaifa e1d16b1
(hel-509) fix code issues
schlaifa File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
(hel-509) merge favoris into search history
- Loading branch information
commit b7a86d73b65cd3e90b48a1281dc9ad660d8425d9
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { Entity, PrimaryGeneratedColumn, Column, ManyToOne, JoinColumn } from "typeorm"; | ||
|
||
import { UtilisateurModel } from "./UtilisateurModel"; | ||
|
||
@Entity({ name: "search_history" }) | ||
export class SearchHistoryModel { | ||
@PrimaryGeneratedColumn({ name: "id" }) | ||
public id!: number; | ||
|
||
@Column({ name: "title" }) | ||
public title!: string; | ||
|
||
@Column({ name: "finess_number" }) | ||
public finessNumber!: string; | ||
|
||
@Column({ name: "date" }) | ||
public date!: Date; | ||
|
||
@Column({ name: 'user_id' }) | ||
public userId!: string; | ||
|
||
@ManyToOne(() => UtilisateurModel) | ||
@JoinColumn({ name: "user_id", referencedColumnName: "id" }) | ||
public user!: UtilisateurModel; | ||
|
||
} |
15 changes: 15 additions & 0 deletions
15
src/backend/infrastructure/controllers/saveSearchHistoryEndpoint.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { SaveSearchHistoryUseCase } from "../../métier/use-cases/saveSearchHistoryUseCase"; | ||
import { Dependencies } from "../dependencies"; | ||
|
||
export async function saveSearchHistoryEndpoint(dependencies: Dependencies, titre: string, idUser: string, finessNumber: string): Promise<void> { | ||
try { | ||
// eslint-disable-next-line no-console | ||
console.log('from endpoint', idUser); | ||
const saveSearchHistoryUseCase = new SaveSearchHistoryUseCase(dependencies.searchHistoryLoader); | ||
|
||
return await saveSearchHistoryUseCase.exécute(titre, idUser, finessNumber); | ||
} catch (error) { | ||
dependencies.logger.error(error); | ||
throw error; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
src/backend/infrastructure/gateways/search-history-loader/TypeOrmSearchHistoryLoader.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { DataSource } from "typeorm"; | ||
|
||
import { SearchHistoryModel } from "../../../../../database/models/SearchHistoryModel"; | ||
import { SearchHistoryLoader } from "../../../métier/gateways/SearchHistoryLoader"; | ||
|
||
export class TypeOrmSearchHistoryLoader implements SearchHistoryLoader { | ||
constructor(private readonly orm: Promise<DataSource>) { } | ||
|
||
|
||
async saveSearchHistory(title: string, idUser: string, finessNumber: string) { | ||
const searchHistory = new SearchHistoryModel(); | ||
searchHistory.date = new Date(); | ||
searchHistory.finessNumber = finessNumber; | ||
searchHistory.title = title; | ||
searchHistory.userId = idUser; | ||
await (await this.orm).getRepository(SearchHistoryModel).save(searchHistory); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export interface SearchHistoryLoader { | ||
saveSearchHistory(titre: string, idUser: string, finessNumber: string): Promise<void>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { SearchHistoryLoader } from "../gateways/SearchHistoryLoader"; | ||
|
||
export class SaveSearchHistoryUseCase { | ||
constructor(private searchHistoryLoader: SearchHistoryLoader) { } | ||
|
||
async exécute(titre: string, idUser: string, finessNumber: string): Promise<void> { | ||
return await this.searchHistoryLoader.saveSearchHistory(titre, idUser, finessNumber); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
.title { | ||
text-align: center; | ||
margin-top: 2rem; | ||
color: #000091; | ||
} | ||
|
||
.align table { | ||
display: table; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import "@gouvfr/dsfr/dist/component/table/table.min.css"; | ||
import { useDependencies } from "../commun/contexts/useDependencies"; | ||
import styles from "./SearchHistory.module.css"; | ||
|
||
export const SearchHistoryPage = () => { | ||
const { wording } = useDependencies(); | ||
|
||
return ( | ||
<main className="fr-container"> | ||
<h1 className={styles["title"]}>{wording.HISTORIQUE_DE_RECHERECHE_TITRE}</h1> | ||
<div className={"fr-table fr-table--blue-ecume fr-mt-8w " + styles["align"]}> | ||
<table> | ||
<thead> | ||
<tr> | ||
<th scope="col">{wording.ETABLISSEMENT_CONSULTE}</th> | ||
<th scope="col">{wording.DATE}</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
<tr> | ||
<td>{wording.ETABLISSEMENT_CONSULTE}</td> | ||
<td>{wording.DATE}</td> | ||
</tr> | ||
<tr> | ||
<td>{wording.ETABLISSEMENT_CONSULTE}</td> | ||
<td>{wording.DATE}</td> | ||
</tr> | ||
</tbody> | ||
</table> | ||
</div> | ||
</main> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
export function useSearchHistory() { | ||
const saveSearchHistory = (title: string, idUser: string, finessNumber: string) => { | ||
fetch("/api/history/save-search-history", { | ||
body: JSON.stringify({ title, idUser, finessNumber }), | ||
headers: { "Content-Type": "application/json" }, | ||
method: "POST", | ||
}) | ||
} | ||
|
||
return { | ||
saveSearchHistory, | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { NextApiRequest, NextApiResponse } from "next"; | ||
|
||
import { saveSearchHistoryEndpoint } from "../../../backend/infrastructure/controllers/saveSearchHistoryEndpoint"; | ||
import { dependencies } from "../../../backend/infrastructure/dependencies"; | ||
|
||
export default async function handler(request: NextApiRequest, response: NextApiResponse) { | ||
if (request.method !== "POST") { | ||
return response.status(405).send("Method not allowed"); | ||
} | ||
|
||
const { title, idUser, finessNumber } = request.body; | ||
// eslint-disable-next-line no-console | ||
console.log('from pages api', idUser); | ||
const recherche = await saveSearchHistoryEndpoint(dependencies, title, idUser, finessNumber); | ||
|
||
return response.status(200).json(recherche); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import { SearchHistoryPage } from "../frontend/ui/search-history/SearchHistoryPage"; | ||
|
||
export default function Favoris() { | ||
return <SearchHistoryPage />; | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
file name "add"