AECC database project.
1function fillMemberCreatorLogger() {
2 try {
3 fetch(URL + "/api/v1/read/?t=member").then(resp => resp.json()).then(json => {
4 memberCreatorLogger.innerHTML = "";
5 for (var i = 0; i < json.length; ++i) {
6 const obj = json[i];
7 memberCreatorLogger.innerHTML += `
8 <option value="${obj[0]}">${obj[1]} ${obj[2]} ${obj[3]} ${obj[4]}</option>
9 `;
10 }
11 });
12 } catch (error) {
13 console.error(error.message);
14 }
15}
16
17function fillMemberFinder() {
18 try {
19 fetch(URL + "/api/v1/read/?t=member").then(resp => resp.json()).then(json => {
20 memberResultsTable.innerHTML = `
21 <tr>
22 <th>ID</th>
23 <th>Name</th>
24 <th>Second Name</th>
25 <th>Last Name</th>
26 <th>Second Last Name</th>
27 <th>E-mail</th>
28 <th>Phone Number</th>
29 <th>Status</th>
30 </tr>
31 `;
32
33 for (var i = 0; i < json.length; ++i) {
34 const obj = json[i];
35 memberResultsTable.innerHTML += `
36 <tr>
37 <th>${obj[0]}</th>
38 <th>${obj[1]}</th>
39 <th>${obj[2]}</th>
40 <th>${obj[3]}</th>
41 <th>${obj[4]}</th>
42 <th>${obj[5]}</th>
43 <th>${obj[6]}</th>
44 <th>${obj[7]}</th>
45 </tr>
46 `;
47 }
48 });
49 } catch (error) {
50 console.error(error.message);
51 }
52}
53
54function memberCreatorFormHandler(event) {
55 event.preventDefault();
56 console.log(event.target);
57 /*
58 try {
59 const logger = event.target[0];
60 const name = event.target[2];
61 const second_name = event.target[3];
62 const last_name = event.target[4];
63 const second_last_name = event.target[5];
64 const email = event.target[6];
65 const phone_number = event.target[7];
66 const status = event.target[8];
67 const payload = JSON.stringify({
68 name: name,
69 second_name: second_name,
70 })
71 if (confirm(`Do you want to create a member`))
72 fetch(URL + "/api/v1/create/", {
73 method: "POST",
74 headers: { "Content-Type": "application/json" },
75 body: payload
76 }).then(resp => {
77 if (response.status == 201)
78 });
79 } catch (error) {
80 console.error(error.message);
81 }
82 */
83}