git ssb

2+

mixmix / ticktack



Tree: 14ac2ad367289482ef190e031665686d5734bf6a

Files: 14ac2ad367289482ef190e031665686d5734bf6a / app / page / userEdit.js

1335 bytesRaw
1const nest = require('depnest')
2const { h } = require('mutant')
3
4exports.gives = nest('app.page.userEdit')
5
6exports.needs = nest({
7 'about.page.edit': 'first',
8 'history.sync.push': 'first',
9 'translations.sync.strings': 'first'
10})
11
12exports.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

Built with git-ssb-web