Refactor js

Rewriting our js to be more readable and less hacky.


We should adjust the backend to return real error codes along with error rather than success >  data.errors