1 import React, { Component } from 'react';
2 import { FormattedMessage } from 'react-intl';
3 import Firebase from './Firebase';
4 import app from 'firebase/app';
5
6 type ContactProps = {
7 firebase: Firebase | null
8 }
9
10 type ContactState = {
11 content: string
12 }
13
14 class Contact extends Component<ContactProps, ContactState> {
15
16 contactRef: app.database.Reference | undefined;
17
18 constructor(props: ContactProps) {
19 super(props);
20 this.contactRef = this.props.firebase?.contactRef();
21 this.state = {
22 content: "Loading ..."
23 }
24 }
25 componentDidMount() {
26 this.contactRef?.on('value', (snapshot) => {
27 let items = snapshot?.val();
28 this.setState({
29 content: items.content
30 });
31 });
32 }
33
34 componentWillUnmount() {
35 this.contactRef?.off();
36 }
37
38 render() {
39 return (
40 <div>
41 <h1>
42 <FormattedMessage id="contact.title"
43 defaultMessage="Contact"
44 description="Contact page title"/>
45 </h1>
46 <p style={{lineHeight: "150%"}}>{this.state.content}</p>
47 </div>
48 );
49 }
50 }
51
52 export default Contact;