diff options
author | Joris | 2025-04-19 12:36:38 +0200 |
---|---|---|
committer | Joris | 2025-04-19 12:38:24 +0200 |
commit | 632eef6424d8dc8d40c2906177892697679e7b85 (patch) | |
tree | 48d9cd60e9e96eab810b5f7bb3c7b1fa79e0438f /frontend/ts/src/pages/layout.ts | |
parent | 063d8ef9eaf874a941f4459e831057dd0a1b7ddd (diff) |
Add ZIG server
Diffstat (limited to 'frontend/ts/src/pages/layout.ts')
-rw-r--r-- | frontend/ts/src/pages/layout.ts | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/frontend/ts/src/pages/layout.ts b/frontend/ts/src/pages/layout.ts new file mode 100644 index 0000000..3140c17 --- /dev/null +++ b/frontend/ts/src/pages/layout.ts @@ -0,0 +1,37 @@ +import { h, Html } from 'lib/rx' +import * as rx from 'lib/rx' +import * as request from 'request' +import * as route from 'route' +import { User } from 'models/user' +import * as modal from 'ui/modal' + +export function view(user: User, children: Html): Html { + return [ + h('header', + h('a', { href: '/' }, 'Maps'), + h('div', + user.name, + rx.withState<string | undefined>(undefined, logoutError => [ + h('button', + { + className: 'g-Logout__Button', + onclick: (event: Event) => { + request + .post_('/api/logout') + .then(_ => window.location.href = '') + .catch(({ message }) => logoutError.update(_ => message)) + } + }, + '(Déconnexion)' + ), + logoutError.map(err => err && modal.error({ + header: 'Erreur lors de la déconnexion', + message: err, + onClose: () => logoutError.update(_ => undefined) + })) + ]) + ) + ), + h('main', children) + ] +} |