Commit d61c0c68 authored by Live Jortveit Sagebakken's avatar Live Jortveit Sagebakken
Browse files

(#3) State changes to the selected value

parent a2f6f824
import React from "react";
import React, { useState } from "react";
import commitView from "./commitView";
import commit from "./commit";
class filterCommits extends React.Component {
// Resource: https://reactjs.org/docs/forms.html
class filterCommits extends React.Component<{}, { value: string }>{
constructor(props: string) {
super(props);
this.state = {value: 'Alle commits'};
this.handleChange = this.handleChange.bind(this);
}
handleChange(event: React.ChangeEvent<HTMLInputElement>) {
this.setState({value: event.target.value});
console.log(event.target.value);
// Todo: Trenger å finne ut av hva slags type event er
// Bytte navn til filter-funksjon eller noe mer spesifikt
handleChange(event: any) {
this.setState({value: event.currentTarget.value});
alert("Filter on: " + event.currentTarget.value);
}
// Videre: Tror jeg må flytte alle commitsa hit fra commitView, eventuelt lage et interface eller noe (refactoring)
render(){
return (
<div>
<label>Filtrer commits:
<select>
<select value = {this.state.value} onChange = {this.handleChange}>
<option value="AllCommits">Alle commits</option>
<option value="lastSevenDays">Siste 7 dager</option>
<option value="lastFourteenDays">Siste 14 dager</option>
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment