Populating the user form
This commit is contained in:
		@ -20,6 +20,7 @@ type templateData struct {
 | 
			
		||||
	API             string
 | 
			
		||||
	CSSVersion      string
 | 
			
		||||
	IsAuthenticated int
 | 
			
		||||
	UserID          int
 | 
			
		||||
	StripeSecretKey string
 | 
			
		||||
	StripePubKey    string
 | 
			
		||||
}
 | 
			
		||||
@ -43,6 +44,7 @@ func (app *application) addDefaultData(td *templateData, r *http.Request) *templ
 | 
			
		||||
 | 
			
		||||
	if app.Session.Exists(r.Context(), "userID") {
 | 
			
		||||
		td.IsAuthenticated = 1
 | 
			
		||||
		td.UserID = app.Session.GetInt(r.Context(), "userID")
 | 
			
		||||
	} else {
 | 
			
		||||
		td.IsAuthenticated = 0
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
@ -16,6 +16,7 @@ Admin User
 | 
			
		||||
        <label for="first_name" class="form-label">First Name</label>
 | 
			
		||||
        <input type="text"
 | 
			
		||||
               name="first_name"
 | 
			
		||||
               id="first_name"
 | 
			
		||||
               class="form-control"
 | 
			
		||||
               required=""
 | 
			
		||||
               autocomplete="first_name-new">
 | 
			
		||||
@ -24,6 +25,7 @@ Admin User
 | 
			
		||||
        <label for="last_name" class="form-label">Last Name</label>
 | 
			
		||||
        <input type="text"
 | 
			
		||||
               name="last_name"
 | 
			
		||||
               id="last_name"
 | 
			
		||||
               class="form-control"
 | 
			
		||||
               required=""
 | 
			
		||||
               autocomplete="last_name-new">
 | 
			
		||||
@ -32,6 +34,7 @@ Admin User
 | 
			
		||||
        <label for="email" class="form-label">Email</label>
 | 
			
		||||
        <input type="text"
 | 
			
		||||
               name="email"
 | 
			
		||||
               id="email"
 | 
			
		||||
               class="form-control"
 | 
			
		||||
               required=""
 | 
			
		||||
               autocomplete="email-new">
 | 
			
		||||
@ -40,6 +43,7 @@ Admin User
 | 
			
		||||
        <label for="password" class="form-label">Password</label>
 | 
			
		||||
        <input type="text"
 | 
			
		||||
               name="password"
 | 
			
		||||
               id="password"
 | 
			
		||||
               class="form-control"
 | 
			
		||||
               autocomplete="password-new">
 | 
			
		||||
    </div>
 | 
			
		||||
@ -47,6 +51,7 @@ Admin User
 | 
			
		||||
        <label for="verify_password" class="form-label">Verify Password</label>
 | 
			
		||||
        <input type="text"
 | 
			
		||||
               name="verify_password"
 | 
			
		||||
               id="verify_password"
 | 
			
		||||
               class="form-control"
 | 
			
		||||
               autocomplete="veryfy_password-new">
 | 
			
		||||
    </div>
 | 
			
		||||
@ -56,14 +61,15 @@ Admin User
 | 
			
		||||
        <a href="javascript:void(0)" class="btn btn-warning" id="cancelBtn">Cancel</a>
 | 
			
		||||
    </div>
 | 
			
		||||
    <div class="float-end">
 | 
			
		||||
        <a href="javascript:void(0)" class="btn btn-danger" id="deleteBtn">Delete</a>
 | 
			
		||||
        <a href="javascript:void(0)" class="btn btn-danger d-none" id="deleteBtn">Delete</a>
 | 
			
		||||
    </div>
 | 
			
		||||
    <div class="clearfix"></div>
 | 
			
		||||
</form>
 | 
			
		||||
{{ end }}
 | 
			
		||||
{{ define "js" }}
 | 
			
		||||
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>
 | 
			
		||||
<script type="module">
 | 
			
		||||
import {showUser} from "/static/js/users.js"
 | 
			
		||||
showUser({{.API}});
 | 
			
		||||
showUser({{.API}}, {{.UserID}});
 | 
			
		||||
</script>
 | 
			
		||||
{{ end }}
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user