Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function *handle_verify_email({ payload }) {
const { _t } = app.context
try {
yield api({ name: 'auth/registration/verify-email' }).save({
language: 'zh_CN',
...payload
})
yield put({ type: '@@xadmin/ADD_NOTICE', payload: {
type: 'success', headline: 'Success', message: _t('Send verify code to your email, please check')
} })
} catch(err) {
app.error(err)
}
}
getCodeUrl() {
const { field } = this.props
return api({}).host + (field.captcha_url || '/get_captcha_code') + '?random=' + Math.random().toString()
}
const rest = useMemo(() => api(model), [ model ])
getCodeUrl() {
const { field } = this.props
return api({}).host + (field.captcha_url || '/get_captcha_code') + '?random=' + Math.random().toString()
}
function *handle_get_list({ model, filter, wheres }) {
yield put({ type: 'START_LOADING', model, key: `${model.key}.items` })
const { store } = app.context
const modelState = store.getState().model[model.key]
try {
const { items, total } = yield api(model).query(filter || modelState.filter, wheres || modelState.wheres)
yield put({ type: 'GET_ITEMS', model: model, items: items || [], filter, wheres, count: total })
} catch(err) {
app.error(err)
yield put({ type: 'GET_ITEMS', model: model, items: [], filter, wheres, count: 0 })
}
yield put({ type: 'END_LOADING', model, key: `${model.key}.items` })
}
function *handle_get_item({ model, id }) {
yield put({ type: 'START_LOADING', model, key: `${model.key}.get` })
const { _t } = app.context
try {
const item = yield api(model).get(id)
if(item) {
yield put({ type: 'GET_ITEM', model, item, success: true })
}
} catch(err) {
app.error(err)
}
yield put({ type: 'END_LOADING', model, key: `${model.key}.get` })
}
const loadOptions = React.useCallback(inputValue => {
const displayField = field.displayField || 'name'
setLoadig(true)
return api(field.schema)
.query({ limit: 1000, fields: [ 'id', displayField ] },
inputValue ? { search: { [displayField]: { like: inputValue } } } : {})
.then(({ items }) => {
setLoadig(false)
setOptions(items.map(item =>
({ value: item.id, label: item[displayField], item })
))
}
)
}, [ model, field ])