adding "admin" section to see all rsvps
This commit is contained in:
parent
9c7c52a0de
commit
79496e8e49
3 changed files with 33 additions and 2 deletions
12
client/rsvps_list.html
Normal file
12
client/rsvps_list.html
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<link rel="stylesheet" type="text/css" href="/style.css">
|
||||
</head>
|
||||
<body>
|
||||
<h1 class="title fontXL textCenter backgroundLightGreen colorWhite">Collin and Lucy's Wedding</h1>
|
||||
<div class="contents">
|
||||
</div>
|
||||
<script src="/rsvps_list.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
13
client/rsvps_list.js
Normal file
13
client/rsvps_list.js
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
function createRsvpEntry(rsvp) {
|
||||
|
||||
}
|
||||
|
||||
async function getRsvps() {
|
||||
// token is test:test for now
|
||||
const resp = await fetch('/api/rsvps', { headers: { 'Authorization': 'Basic dGVzdDp0ZXN0'} })
|
||||
JSON.parse(resp.body)
|
||||
}
|
||||
|
||||
window.onload = async function () {
|
||||
await getRsvps();
|
||||
};
|
||||
|
|
@ -70,7 +70,7 @@ func isAuthorized(r *http.Request) bool {
|
|||
return false
|
||||
}
|
||||
|
||||
return auth == token
|
||||
return auth == fmt.Sprintf("Basic %s", token)
|
||||
}
|
||||
|
||||
func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
|
|
@ -86,12 +86,18 @@ func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
|||
case r.Method == "GET" && r.URL.Path == "/rsvp_confirmed":
|
||||
getStaticFile("./client/rsvp_confirmed.html", "text/html", w)
|
||||
|
||||
case r.Method == "GET" && r.URL.Path == "/rsvps_list":
|
||||
getStaticFile("./client/rsvps_list.html", "text/html", w)
|
||||
|
||||
case r.Method == "GET" && r.URL.Path == "/index.js":
|
||||
getStaticFile("./client/index.js", "text/javascript", w)
|
||||
|
||||
case r.Method == "GET" && r.URL.Path == "/rsvp.js":
|
||||
getStaticFile("./client/rsvp.js", "text/javascript", w)
|
||||
|
||||
case r.Method == "GET" && r.URL.Path == "/rsvps_list.js":
|
||||
getStaticFile("./client/rsvps_list.js", "text/javascript", w)
|
||||
|
||||
case r.Method == "GET" && r.URL.Path == "/style.css":
|
||||
getStaticFile("./client/style.css", "text/css", w)
|
||||
|
||||
|
|
@ -121,7 +127,7 @@ func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
|||
}
|
||||
|
||||
attending := r.Form.Get("attending") == "true"
|
||||
partySize, err := strconv.ParseInt(r.Form.Get("party-size"), 10, 1)
|
||||
partySize, err := strconv.ParseInt(r.Form.Get("party-size"), 10, 64)
|
||||
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue