Files: b10ce2e3fb81fd4e7ded0080858d4a7ff1d508f9 / app / page / userEdit.js
1278 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 | 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 defaultCallback = (err, didEdit) => { |
34 | if (err) throw new Error ('Error editing profile', err) |
35 | |
36 | api.history.sync.push({ page: 'userShow', feed }) |
37 | } |
38 | callback = typeof callback == 'function' |
39 | ? callback |
40 | : defaultCallback |
41 | |
42 | return h('Page -userEdit', {}, [ |
43 | h('div.content', [ |
44 | api.about.page.edit(options, callback) |
45 | ]) |
46 | ]) |
47 | } |
48 | } |
49 | |
50 |
Built with git-ssb-web