fix create application

Signed-off-by: Andrey Platov <andrey@hardcoreeng.com>
This commit is contained in:
Andrey Platov 2021-09-06 13:28:30 +02:00
parent d034094829
commit e9f12766c1
No known key found for this signature in database
GPG Key ID: C8787EFEB4B64AF0

View File

@ -38,11 +38,14 @@
const client = getClient() const client = getClient()
async function createCandidate() { async function createApplication() {
const state = client.findOne(core.class.State, { space }) const state = await client.findOne(core.class.State, { space })
if (state === undefined) {
throw new Error('create application: state not found')
}
await client.createDoc(recruit.class.Applicant, space, { await client.createDoc(recruit.class.Applicant, space, {
candidate, candidate,
state state: state._id
}) })
dispatch('close') dispatch('close')
} }
@ -51,7 +54,7 @@
<Card label={'Create Application'} <Card label={'Create Application'}
okLabel={'Save'} okLabel={'Save'}
okAction={createCandidate} okAction={createApplication}
on:close={() => { dispatch('close') }}> on:close={() => { dispatch('close') }}>
<Grid column={1} rowGap={1.75}> <Grid column={1} rowGap={1.75}>
<UserBox _class={recruit.class.Candidate} title='Candidate' caption='Candidates' bind:value={candidate} /> <UserBox _class={recruit.class.Candidate} title='Candidate' caption='Candidates' bind:value={candidate} />