main
Last change
on this file since d24f17c was d24f17c, checked in by Aleksandar Panovski <apano77@…>, 15 months ago |
Initial commit
|
-
Property mode
set to
100644
|
File size:
1.3 KB
|
Rev | Line | |
---|
[d24f17c] | 1 | import React, { useEffect, useState } from 'react';
|
---|
| 2 | import axios from 'axios';
|
---|
| 3 | import { useParams } from 'react-router-dom';
|
---|
| 4 |
|
---|
| 5 | const CustomerDetails = () => {
|
---|
| 6 | const { id } = useParams();
|
---|
| 7 | const [customer, setCustomer] = useState(null);
|
---|
| 8 |
|
---|
| 9 | useEffect(() => {
|
---|
| 10 | const fetchCustomer = async () => {
|
---|
| 11 | try {
|
---|
| 12 | const response = await axios.get(`http://localhost:8080/api/customers/${id}`);
|
---|
| 13 | setCustomer(response.data);
|
---|
| 14 | } catch (error) {
|
---|
| 15 | console.error('Error fetching customer:', error);
|
---|
| 16 | }
|
---|
| 17 | };
|
---|
| 18 |
|
---|
| 19 | fetchCustomer();
|
---|
| 20 | }, [id]);
|
---|
| 21 |
|
---|
| 22 | if (!customer) {
|
---|
| 23 | return <div>Loading...</div>;
|
---|
| 24 | }
|
---|
| 25 |
|
---|
| 26 | return (
|
---|
| 27 | <div>
|
---|
| 28 | <h2>Customer Details</h2>
|
---|
| 29 | <p className="card-text"><strong>Email:</strong> {customer.email}</p>
|
---|
| 30 | <p className="card-text"><strong>Phone:</strong> {customer.phone}</p>
|
---|
| 31 | <p className="card-text"><strong>Address:</strong> {customer.address}</p>
|
---|
| 32 | <p className="card-text"><strong>Membership
|
---|
| 33 | Level:</strong> {customer.membershipLevel}</p>
|
---|
| 34 | <p className="card-text"><strong>Registration
|
---|
| 35 | Date:</strong> {new Date(customer.registrationDate).toLocaleString()}</p>
|
---|
| 36 | </div>
|
---|
| 37 | );
|
---|
| 38 | }
|
---|
| 39 |
|
---|
| 40 | export default CustomerDetails;
|
---|
Note:
See
TracBrowser
for help on using the repository browser.