instantjob-recruiter-client
Version:
a set of tools for creating an instantjob recruiter react client
32 lines (29 loc) • 1.11 kB
JSX
import store from 'common/store'
import request from 'common/request'
import {store_workplaces, update_workplace} from 'actions/missions'
import {show_popover, dismiss_popover} from 'actions/display'
import NewWorkplace from 'components/popovers/new_workplace'
export function action_create_workplace(workplace_name = "") {
return new Promise((resolve, reject) => {
store.dispatch(show_popover(
NewWorkplace,
{
name: workplace_name,
on_create_workplace(name, address, latitude, longitude) {
store.dispatch(dismiss_popover())
const workplace = {name, address, latitude, longitude}
request.post(`agencies/${store.getState().profile.agency_id}/workplaces`, {workplace})
.then((workplace) => {
store.dispatch(store_workplaces([workplace]))
resolve(workplace.id)
})
},
},
'Créer un nouveau lieu de travail'
))
})
}
export function action_update_workplace(workplace) {
store.dispatch(update_workplace(workplace))
return request.put(`workplaces/${workplace.id}`, {workplace})
}