Collection model

This commit is contained in:
Jori Lallo
2017-05-23 00:45:15 -07:00
parent 07ff5b6ae5
commit 6b566a568f
6 changed files with 116 additions and 16 deletions

View File

@@ -2,7 +2,7 @@
import { observable, action, computed } from 'mobx';
import invariant from 'invariant';
import { client } from 'utils/ApiClient';
import type { Collection } from 'types';
import Collection from 'models/Collection';
const store = new class AtlasStore {
@observable collection: ?(Collection & { recentDocuments?: Object[] });
@@ -25,7 +25,7 @@ const store = new class AtlasStore {
const res = await client.get('/collections.info', { id });
invariant(res && res.data, 'Data should be available');
const { data } = res;
this.collection = data;
this.collection = new Collection(data);
successCallback(data);
} catch (e) {
console.error('Something went wrong');