| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 |
- import Page from "./Page.js";
- import Elem from "../Elem.js";
- export default class CreateIncome extends Page{
- constructor(){
- super("CreateIncome");
- this.render();
- }
- async submit(event){
- event.preventDefault();
- await user.account.addIncome(
- this.container.querySelector(".name").value,
- this.container.querySelector(".amount").value
- );
- changePage("home");
- }
- render(){
- new Elem("form")
- .addClass("standardForm")
- .onsubmit(this.submit.bind(this))
- .append(new Elem("h1")
- .text("Create Income")
- )
- .append(new Elem("label")
- .text("Name")
- .append(new Elem("input")
- .type("text")
- .addClass("name")
- .placeholder("Name")
- .required()
- .focus()
- )
- )
- .append(new Elem("label")
- .text("Amount")
- .append(new Elem("input")
- .type("number")
- .addClass("amount")
- .placeholder("Amount")
- .min("0")
- .step("0.01")
- .required()
- )
- )
- .append(new Elem("button")
- .text("Create")
- )
- .append(new Elem("button")
- .text("Cancel")
- .addClass("cancel")
- .type("button")
- .onclick(()=>{changePage("home")})
- )
- .appendTo(this.container);
- }
- }
|