Feature: Mark guests as invited #60
@ -5,6 +5,8 @@ import React, { useState, useEffect } from 'react';
|
|||||||
import { Guest } from '@/app/lib/definitions';
|
import { Guest } from '@/app/lib/definitions';
|
||||||
|
|
||||||
export default function guestsTable() {
|
export default function guestsTable() {
|
||||||
|
const [guests, setGuests] = useState<Array<Guest>>([]);
|
||||||
|
|
||||||
function loadGuests() {
|
function loadGuests() {
|
||||||
fetch("http://localhost:3001/guests.json")
|
fetch("http://localhost:3001/guests.json")
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
@ -20,10 +22,18 @@ export default function guestsTable() {
|
|||||||
}));
|
}));
|
||||||
}, (error) => {
|
}, (error) => {
|
||||||
return [];
|
return [];
|
||||||
});
|
}
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
function handleInviteGuest() {
|
||||||
|
fetch("http://localhost:3001/guests/123.json", { method: 'PATCH', body: JSON.stringify({ guest: { status: 'Invited' } }) })
|
||||||
|
.then((response) => console.log(response.json()))
|
||||||
|
.catch((error) => console.error(error));
|
||||||
}
|
}
|
||||||
|
|
||||||
const [guests, setGuests] = useState<Array<Guest>>([]);
|
|
||||||
|
|
||||||
guests.length === 0 && loadGuests();
|
guests.length === 0 && loadGuests();
|
||||||
|
|
||||||
@ -81,7 +91,7 @@ export default function guestsTable() {
|
|||||||
</span>
|
</span>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
{guest.status === 'Considered' && (<button className="bg-blue-300 hover:bg-blue-500 text-white py-1 px-2 rounded">
|
{guest.status === 'Considered' && (<button onClick={handleInviteGuest} className="bg-blue-300 hover:bg-blue-500 text-white py-1 px-2 rounded">
|
||||||
Invite
|
Invite
|
||||||
</button>)}
|
</button>)}
|
||||||
</td>
|
</td>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user