searchbar.tsx 1.66 KB
Newer Older
1
2
3
4
5
import './searchbar.css'
import React from 'react';
import { Country } from '../../interfaces/Country';
import './SearchbarStore.tsx'
import { searchbarStore } from './SearchbarStore';
6
import { Search } from '@navikt/ds-icons';
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29

interface IProps {
    items?: string[]
}
interface IState {
    active: boolean,
    items: string[]
}

export class Searchbar extends React.Component<IProps, IState> {
    constructor(props: IState) {
        super(props);
        this.state = {
            active: false,
            items: []
        };
    }
    onSearch() {
        searchbarStore.dispatch({ type: 'setState', NewCountry: dummyData });
    }
    render() {
        return (
            <div className="searchbar">
30
31
                
                <input type="text" className="form-control" placeholder="Enter Country" />
32
33
                <div className="input-group-append">
                    <button onClick={() => this.onSearch()}
Duvara Nishaharan's avatar
Duvara Nishaharan committed
34
                        className="btn btn-outline-secondary" type="button" id="buttonclick"><Search/>Search</button>
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
                </div>
                {this.state.active && <div>Jeg er active</div>}
            </div>)
    }
}
const dummyData: Country[] = [
    { name: "Norway", population: 20, area: 10 },
    { name: "Sweden", population: 25, area: 11 },
    { name: "Iceland", population: 5, area: 3 },
    { name: "England", population: 60, area: 14 },
    { name: "Sri Lanka", population: 55, area: 8 },
    { name: "USA", population: 120, area: 60 },
    { name: "Poland", population: 35, area: 14 },
    { name: "Japan", population: 110, area: 40 },
    { name: "Denmark", population: 26, area: 9 },
    { name: "Finland", population: 22, area: 12 },
]