🚧 Søkefelt henter array med feilmeldinger fra backend
WIP: arrayet er tomt fordi søk ikke fungerer Co-authored-by: Sindre Kjelsrud <sindre.kjelsrud@nav.no>
This commit is contained in:
parent
76c34abd2b
commit
8134cfc239
4 changed files with 37 additions and 5 deletions
backend/src/main/kotlin/no/nav/helse/sprik
frontend/src
|
@ -8,12 +8,18 @@ class Sokemotor {
|
|||
private val feilmeldingRepository = FeilmeldingRepository()
|
||||
|
||||
fun sok(s: String): List<Feilmelding> {
|
||||
|
||||
val feilmeldinger = feilmeldingRepository.hentAlleFeilmeldinger()
|
||||
val resultat = ArrayList<Feilmelding>()
|
||||
|
||||
val processed = s.lowercase()
|
||||
|
||||
for (i in feilmeldinger) {
|
||||
if (i.tittel.equals(s) or i.beskrivelse.equals(s)) {
|
||||
if (i.tittel.lowercase().contains(processed) or i.beskrivelse.lowercase().contains(processed) or processed.equals("")) {
|
||||
println(i.toString() + " matcher" + processed)
|
||||
resultat.add(i)
|
||||
}else{
|
||||
println(i.toString() + " matcher ikke")
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -14,11 +14,13 @@ import io.ktor.server.request.*
|
|||
import no.nav.helse.sprik.Test
|
||||
import no.nav.helse.sprik.db.FeilmeldingRepository
|
||||
import no.nav.helse.sprik.modell.Feilmelding
|
||||
import no.nav.helse.sprik.modell.Sokemotor
|
||||
import java.time.LocalDateTime
|
||||
|
||||
fun configureRouting(): ApplicationEngine = embeddedServer(CIO, applicationEngineEnvironment {
|
||||
//Repositories for handlinger mot database:
|
||||
val feilmeldingRepository = FeilmeldingRepository()
|
||||
val sokemotor = Sokemotor()
|
||||
|
||||
module {
|
||||
install(CORS) {
|
||||
|
@ -57,6 +59,10 @@ fun configureRouting(): ApplicationEngine = embeddedServer(CIO, applicationEngin
|
|||
val testMelding = feilmeldingRepository.hentAlleFeilmeldinger()
|
||||
call.respond(status = HttpStatusCode.Created, message = testMelding)
|
||||
}
|
||||
post("/api/hentsok"){
|
||||
val sokestreng = call.receive<String>()
|
||||
call.respond(status = HttpStatusCode.Created, message = sokestreng + ": " + sokemotor.sok(sokestreng))
|
||||
}
|
||||
}
|
||||
}
|
||||
connector {
|
||||
|
|
|
@ -2,5 +2,5 @@
|
|||
* Konstanter vi bruker i diverse filer i applikasjonen
|
||||
*/
|
||||
|
||||
//export const backendURL = "http://localhost:8080"
|
||||
export const backendURL = "https://helse-sprik.intern.dev.nav.no"
|
||||
export const backendURL = "http://localhost:8080"
|
||||
//export const backendURL = "https://helse-sprik.intern.dev.nav.no"
|
|
@ -5,11 +5,26 @@ import Header from "./components/Header";
|
|||
import { PlusIcon } from "@navikt/aksel-icons";
|
||||
import Filtermeny from "./components/Filtermeny";
|
||||
import { useNavigate } from "react-router-dom";
|
||||
import axios from "axios";
|
||||
import { backendURL } from "./const";
|
||||
|
||||
export default function Home() {
|
||||
|
||||
const navigate = useNavigate()
|
||||
|
||||
const handleChange = (soeketekst: string) => {
|
||||
console.log("search changed")
|
||||
|
||||
axios.post(backendURL + "/api/hentsok", soeketekst, {
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
}).then((response) => {
|
||||
console.log(response.data);
|
||||
}).catch((error) => {
|
||||
console.log(error);
|
||||
})
|
||||
}
|
||||
|
||||
return (
|
||||
<main className="flex flex-col h-screen">
|
||||
<Header/>
|
||||
|
@ -17,7 +32,12 @@ export default function Home() {
|
|||
<Filtermeny/>
|
||||
<div className="grow bg-bg-subtle px-32 py-8 flex flex-col gap-10">
|
||||
<div className="flex gap-12 items-end">
|
||||
<Search label="Søkefelt" description="Søk gjennom innmeldte feil (nøkkelord, tags, status)" hideLabel={false}/>
|
||||
<Search
|
||||
label="Søkefelt"
|
||||
description="Søk gjennom innmeldte feil (nøkkelord, tags, status)"
|
||||
hideLabel={false}
|
||||
onChange={(soeketekst) => handleChange(soeketekst)}
|
||||
/>
|
||||
<Button
|
||||
className="w-64 h-min"
|
||||
icon={<PlusIcon/>}
|
||||
|
|
Reference in a new issue