Files: aa4c25f3c365e275c42b08f8e34ef4e6c2b66d93 / app / page / userEdit.js
1338 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', callback } |
17 | var { feed, callback } = location |
18 | |
19 | const strings = api.translations.sync.strings() |
20 | |
21 | const options = Object.assign({}, location, { |
22 | feed, |
23 | labels: { |
24 | avatar: strings.userEdit.section.avatar, |
25 | name: strings.userEdit.section.name, |
26 | description: strings.userEdit.section.introduction, |
27 | instructionCrop: strings.userEdit.instruction.crop, |
28 | okay: strings.userEdit.action.okay, |
29 | cancel: strings.userEdit.action.cancel, |
30 | save: strings.userEdit.action.save, |
31 | } |
32 | }) |
33 | |
34 | const defaultCallback = (err, didEdit) => { |
35 | if (err) throw new Error ('Error editing profile', err) |
36 | |
37 | api.history.sync.push({ page: 'userShow', feed }) |
38 | } |
39 | callback = typeof callback == 'function' |
40 | ? callback |
41 | : defaultCallback |
42 | |
43 | return h('Page -userEdit', {}, [ |
44 | h('div.content', [ |
45 | api.about.page.edit(options, callback) |
46 | ]) |
47 | ]) |
48 | } |
49 | } |
50 | |
51 |
Built with git-ssb-web