2019-05-27 11:37:05 +03:00
|
|
|
import faker from 'faker';
|
2019-01-22 20:18:44 +03:00
|
|
|
import moment from 'moment';
|
2022-03-08 14:32:01 +03:00
|
|
|
import {Factory, trait} from 'miragejs';
|
2019-01-22 20:18:44 +03:00
|
|
|
|
|
|
|
let randomDate = function randomDate(start = moment().subtract(30, 'days').toDate(), end = new Date()) {
|
|
|
|
return new Date(start.getTime() + Math.random() * (end.getTime() - start.getTime()));
|
|
|
|
};
|
|
|
|
|
|
|
|
export default Factory.extend({
|
|
|
|
name() { return `${faker.name.firstName()} ${faker.name.lastName()}`; },
|
|
|
|
email: faker.internet.email,
|
2021-04-08 14:06:27 +03:00
|
|
|
status: 'free',
|
2022-02-16 00:38:47 +03:00
|
|
|
createdAt() { return moment(randomDate()).format('YYYY-MM-DD HH:mm:ss'); },
|
2021-04-08 14:06:27 +03:00
|
|
|
|
|
|
|
free: trait({
|
|
|
|
status: 'free'
|
|
|
|
}),
|
|
|
|
|
|
|
|
paid: trait({
|
|
|
|
status: 'paid'
|
|
|
|
}),
|
|
|
|
|
|
|
|
comped: trait({
|
|
|
|
status: 'comped'
|
2022-05-30 21:44:43 +03:00
|
|
|
}),
|
|
|
|
|
|
|
|
afterCreate(member, server) {
|
|
|
|
const newslettersToSignup = server.schema.newsletters.where({subscribeOnSignup: true});
|
|
|
|
|
|
|
|
member.newsletters = newslettersToSignup;
|
|
|
|
member.save();
|
|
|
|
}
|
2019-01-22 20:18:44 +03:00
|
|
|
});
|