main
Last change
on this file since f5b256e was f5b256e, checked in by Aleksandar Panovski <apano77@…>, 3 weeks ago |
Big change done works with handle_reservation_update() trigger
|
-
Property mode
set to
100644
|
File size:
1.4 KB
|
Line | |
---|
1 | import * as React from 'react';
|
---|
2 | import { request } from "../axios_helper";
|
---|
3 |
|
---|
4 | export default class AuthContent extends React.Component {
|
---|
5 | constructor(props) {
|
---|
6 | super(props);
|
---|
7 | this.state = {
|
---|
8 | data: []
|
---|
9 | };
|
---|
10 | }
|
---|
11 |
|
---|
12 | // componentDidMount() {
|
---|
13 | // request(
|
---|
14 | // "GET",
|
---|
15 | // "/api/restaurants",
|
---|
16 | // []
|
---|
17 | // ).then((response) => {
|
---|
18 | // this.setState({ data: response.data });
|
---|
19 | // });
|
---|
20 | // }
|
---|
21 | componentDidMount() {
|
---|
22 | const token = localStorage.getItem('token');
|
---|
23 | console.log("Stored Token on Reload:", token);
|
---|
24 |
|
---|
25 | if (token) {
|
---|
26 | this.setAuthToken(token);
|
---|
27 | this.fetchUserDetails(token);
|
---|
28 | } else {
|
---|
29 | console.log("No token found. Redirecting to login.");
|
---|
30 | this.setState({ componentToShow: "login", isAuthenticated: false });
|
---|
31 | }
|
---|
32 | }
|
---|
33 |
|
---|
34 | render() {
|
---|
35 | return (
|
---|
36 | <div>
|
---|
37 | {this.state.data && this.state.data.map((restaurant) => (
|
---|
38 | <div key={restaurant.restaurantId}>
|
---|
39 | <p>Name: {restaurant.name}</p>
|
---|
40 | <p>Cuisine Type: {restaurant.cuisineType}</p>
|
---|
41 | <p>Address: {restaurant.address}</p>
|
---|
42 | <p>User: {}</p>
|
---|
43 | </div>
|
---|
44 | ))}
|
---|
45 | </div>
|
---|
46 | );
|
---|
47 | }
|
---|
48 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.