${trip.name}`;
+ let id = `load_info_${trip.id}`;
+ // almsot all the fucking data is here
+ // how can I add it from here
+ // alert(id);
+ // this just runs alert non stop CAUSE I CALLED ALERT
+ // $(`#` + id).click(alert(id));
+ // when you have something in parans, the things in parens RUNS RIGHT AWAY
+ // CALLED A CONTINUATION OR A THUNK
+ holderName += ``;
+ // const holderNode = $(holderName)
+ // holderNode.click(function is the thing that displays it)
+ tripList.append(holderName);
+
+ $(`#` + id).click(() => {
+ alert(id);
+ let deets = `
`;
-
-// Based on our exploration, we determined that
-// fieldProblems will be of form:
-// {
-// field: [problem, problem, problem],
-// field: [problem...],
-// ...
-// }
const fieldProblems = error.response.data.errors;
// JavaScript is weird about looping through a hash
+// All Dan + Dee's from Ports Pets, thank you
Object.keys(fieldProblems).forEach(field => {
const problems = fieldProblems[field];
problems.forEach(problem => {
@@ -36,15 +53,15 @@ const readRegForm = () => {
let email = $("#trip-form input[name=email]").val();
console.log(name);
console.log(email);
+ // is there a way to do the thing below running the jQuery in the K/V pairing?
return {
'name': name,
- 'email': email
+ 'email': email
};
}
const addRegistration = (id) => {
-
- postUrl = `https://trektravel.herokuapp.com/trips/${id}/reservations`
+ let postUrl = url + id + '/reservations';
console.log(postUrl)
const tripData = readRegForm();
@@ -55,7 +72,6 @@ const addRegistration = (id) => {
.then((response) => {
console.log("successfully posted registration data", response);
- // its creating an id, right?
const regId = response.data.id;
reportStatus(`Successfully created a new registration with ID ${regId}`);
})
@@ -71,66 +87,57 @@ const loadTrips = () => {
tripList.empty();
let getTrips = url + 'trips';
- console.log('MADE IT HERE');
axios.get(getTrips)
.then((response) => {
reportStatus(`Successfully loaded ${response.data.length} trips`);
response.data.forEach((trip) => {
-
- let holderName = `
${trip.name}`;
+ let holderName = `
${trip.name}
`;
let id = `load_info_${trip.id}`;
- // almsot all the fucking data is here
- // how can I add it from here
- // alert(id);
- // this just runs alert non stop CAUSE I CALLED ALERT
- // $(`#` + id).click(alert(id));
- // when you have something in parans, the things in parens RUNS RIGHT AWAY
- // CALLED A CONTINUATION OR A THUNK
- holderName += ``;
- // const holderNode = $(holderName)
- // holderNode.click(function is the thing that displays it)
+ holderName +=
+ `
`;
+ // really should probably do a second api call
+ const deets = `
+
trip id: ${trip.id}
+
trip name: ${trip.name}
+
continent: ${trip.continent}
+
duration: ${trip.weeks}
+
cost: ${trip.cost}
` +
+ registerHTML("name", "email");
$(`.` + id).html(deets);
+ $(`#` + id).remove();
$('#trip-form').submit((event) => {
event.preventDefault();
addRegistration(trip.id);
});
})
});
- // $(`#` + id).click(alert(id));
})
.catch((error) => {
reportStatus(`Encountered an error while loading trips: ${error.message}`);
console.log(error);
});
- // $(`#` + id).click(alert(id));
};
-
-
$(document).ready(() => {
$('#load').click(loadTrips);
+
+
+ console.log(makeFormInputBox("name"));
});
-// lots of credit goes to Dan's Aweosme live coding
\ No newline at end of file
+// lots of credit goes to Dan's Aweosme live coding
+
+
+// Notes from stuff that I got stuck on
+// this just runs alert non stop CAUSE I CALLED ALERT
+// $(`#` + id).click(alert(id));
+// when you have something in parans, the things in parens RUNS RIGHT AWAY
+// CALLED A CONTINUATION OR A THUNK
\ No newline at end of file