示例#1
0
export const editDescription = ({listId, wishId}) => async (dispatch, getState) => {
  const description = await showPrompt({
    title: 'Legg inn beskrivelse og/eller pris',
    value: getState().myList.wishes[wishId].description
  })
  if (description === null) {
    return
  }
  tryOrNotify(async () => {
    const wish = await Api.setDescription({
      listId,
      wishId,
      description
    })
    dispatch(wishUpdated(wish))
  })
}
示例#2
0
export const shareList = listId => async dispatch => {
  const input = await showPrompt({
    title: 'Skriv inn epostadressen til de du vil dele listen med',
    placeholder: 'eksempel@epost.com, ...'
  })
  if (input === null) {
    return
  }
  // TODO: Validation
  const emails = input.split(',').map(email => email.trim())
  tryOrNotify(async () => {
    await Api.shareList({
      listId,
      emails
    })
    showSuccess('Ønskeliste delt!')
  })
}
示例#3
0
export const editUrl = ({listId, wishId}) => async (dispatch, getState) => {
  const url = await showPrompt({
    title: 'Legg inn en lenke til gaven',
    placeholder: 'http://eksempel.no',
    value: getState().myList.wishes[wishId].url
  })
  if (url === null) {
    return
  }
  // TODO: Validation
  tryOrNotify(async () => {
    const wish = await Api.setUrl({
      listId,
      wishId,
      url
    })
    dispatch(wishUpdated(wish))
  })
}