From c48de3e09a2868e524f3410b83e31196fd59d183 Mon Sep 17 00:00:00 2001 From: Roman Timashev Date: Tue, 15 Oct 2019 00:47:57 +0300 Subject: [PATCH] Teacher model moved to typescript. Page can be loaded but looks ugly due to broken styled jsx --- src/core/{Teacher.js => Teacher.ts} | 27 +++++++++++++++++++-------- src/core/db.ts | 2 +- 2 files changed, 20 insertions(+), 9 deletions(-) rename src/core/{Teacher.js => Teacher.ts} (75%) diff --git a/src/core/Teacher.js b/src/core/Teacher.ts similarity index 75% rename from src/core/Teacher.js rename to src/core/Teacher.ts index db6c66a3..b02fe967 100644 --- a/src/core/Teacher.js +++ b/src/core/Teacher.ts @@ -1,12 +1,12 @@ -const Data = require('./Data') -const Image = require('./Image') -const { find, findOne } = require('../lib/store') +import Data from './Data' +import Image from './Image' +import { find, findOne } from '../lib/store' -const store = () => Data.getStore(Teacher) +const store = () => Data.getStore('Teacher') -class Teacher { +export default class Teacher { static async find(query, options = {}) { - const items = await find(store(), query, options) + const items = await find(store(), query, options as any) return Promise.all(items.map(processProfile)) } @@ -18,6 +18,19 @@ class Teacher { return processProfile(data) } + public id: any + public post: any + public file: any + public edu: any + public picture: any + public preview: any + public diploma: any + public position: any + public name: any + public status: any + public hash: any + public url: any + constructor(data) { this.id = data.id this.post = data.post @@ -72,5 +85,3 @@ const processProfile = async profile => { preview, }) } - -module.exports = Teacher diff --git a/src/core/db.ts b/src/core/db.ts index b3da9561..55321851 100644 --- a/src/core/db.ts +++ b/src/core/db.ts @@ -40,7 +40,7 @@ function init(db) { Data.setStore('Article', db.collection('articles')) Data.setStore(Album, db.collection('albums')) Data.setStore('Image', db.collection('images')) - Data.setStore(Teacher, db.collection('collective')) + Data.setStore('Teacher', db.collection('collective')) Data.setStore(Document, db.collection('documents')) Data.setStore('Settings', db.collection('settings'))