Files: ef657f44520e88d070e53be978b7cc34f3ddb5b1 / app / page / userEdit.js
1169 bytesRaw
1 | const nest = require('depnest') |
2 | const { h } = require('mutant') |
3 | |
4 | exports.gives = nest('app.page.userEdit') |
5 | |
6 | exports.needs = nest({ |
7 | 'about.page.edit': 'first', |
8 | 'history.sync.push': 'first', |
9 | 'translations.sync.strings': 'first', |
10 | }) |
11 | |
12 | exports.create = (api) => { |
13 | return nest('app.page.userEdit', userEdit) |
14 | |
15 | function userEdit (location) { |
16 | // location is an object { feed, page: 'userEdit' } |
17 | const { feed } = location |
18 | |
19 | const strings = api.translations.sync.strings() |
20 | |
21 | const options = Object.assign({}, location, { |
22 | feed, |
23 | labels: { |
24 | name: strings.userEdit.section.name, |
25 | avatar: strings.userEdit.section.avatar, |
26 | instructionCrop: strings.userEdit.instruction.crop, |
27 | okay: strings.userEdit.action.okay, |
28 | cancel: strings.userEdit.action.cancel, |
29 | save: strings.userEdit.action.save, |
30 | } |
31 | }) |
32 | |
33 | const callback = (err, didEdit) => { |
34 | if (err) throw new Error ('Error editing profile', err) |
35 | |
36 | api.history.sync.push({ page: 'userShow', feed }) |
37 | } |
38 | |
39 | return h('Page -userEdit', {}, [ |
40 | h('div.container', [ |
41 | api.about.page.edit(options, callback) |
42 | ]) |
43 | ]) |
44 | } |
45 | } |
46 | |
47 |
Built with git-ssb-web