Skip to content

Commit

Permalink
fix: #841/refactor product categories seed
Browse files Browse the repository at this point in the history
  • Loading branch information
tsvetelina-e-y committed May 28, 2020
1 parent f7ab42d commit 64d4b65
Show file tree
Hide file tree
Showing 16 changed files with 65 additions and 77 deletions.
11 changes: 8 additions & 3 deletions apps/api/src/app/product-category/product-category.seed.ts
@@ -1,7 +1,8 @@
import { Connection } from 'typeorm';
import { Organization } from '@gauzy/models';
import { ProductCategory } from './product-category.entity';
import { environment as env } from '@env-api/environment';
import * as seed from './product-types.seed.json';
import * as faker from 'faker';

export const createDefaultProductCategories = async (
connection: Connection,
Expand All @@ -10,11 +11,15 @@ export const createDefaultProductCategories = async (
const seedProductCategories = [];

organizations.forEach(async (organization) => {
env.defaultProductCategories.forEach((seedProductCatery) => {
let image = faker.image.abstract();
seed.forEach(async (seedProductCatery) => {
const newCategory = new ProductCategory();
image =
faker.image[seedProductCatery.fakerImageCategory]() ||
faker.image.abstract();
newCategory.name = seedProductCatery.name;
newCategory.description = seedProductCatery.description;
newCategory.imageUrl = seedProductCatery.imageUrl;
newCategory.imageUrl = image;
newCategory.organization = organization;
seedProductCategories.push(newCategory);
});
Expand Down
57 changes: 57 additions & 0 deletions apps/api/src/app/product-category/product-types.seed.json
@@ -0,0 +1,57 @@
[
{
"name": "Software",
"description": "a collection of data or computer instructions that tell the computer how to work",
"fakerImageCategory": "technics"
},
{
"name": "Food",
"description": "Any substance consumed to provide nutritional support for an organism",
"fakerImageCategory": "food"
},
{
"name": "Transport",
"description": "The movement of people or goods from one place to another",
"fakerImageCategory": "assets/images/products/transport.png"
},
{
"name": "Education",
"description": "Aquisition of knowledge, skills, values, beliefs, and habits",
"fakerImageCategory": "transport"
},
{
"name": "Clothing",
"description": "Items worn on the body",
"fakerImageCategory": "fashion"
},
{
"name": "Office",
"description": "A place for commercial, professional, or bureaucratic work.",
"fakerImageCategory": "business"
},
{
"name": "Advertisement",
"description": "How a company encourages people to buy their products, services or ideas",
"fakerImageCategory": "business"
},
{
"name": "Health",
"description": "State of complete physical, mental, and social well-being",
"fakerImageCategory": "nature"
},
{
"name": "Sport",
"description": "An activity involving physical exertion and skill",
"fakerImageCategory": "sports"
},
{
"name": "Furniture",
"description": "Used to make a room or building suitable for living or working in",
"fakerImageCategory": "abstract"
},
{
"name": "Pets",
"description": "An animal kept primarily for a person's company or entertainment rather than as a working animal",
"fakerImageCategory": "cats"
}
]
66 changes: 0 additions & 66 deletions apps/api/src/environments/environment.ts
Expand Up @@ -485,72 +485,6 @@ export const environment: IEnvironment = {
icon: ProductTypesIconsEnum.HEART,
},
],
defaultProductCategories: [
{
name: 'Software',
description:
'a collection of data or computer instructions that tell the computer how to work',
imageUrl: 'assets/images/products/software.png',
},
{
name: 'Food',
description:
'Any substance consumed to provide nutritional support for an organism',
imageUrl: 'assets/images/products/food.png',
},
{
name: 'Transport',
description:
'The movement of people or goods from one place to another',
imageUrl: 'assets/images/products/transport.png',
},
{
name: 'Education',
description:
'Aquisition of knowledge, skills, values, beliefs, and habits',
imageUrl: 'assets/images/products/education.png',
},
{
name: 'Clothing',
description: 'Items worn on the body',
imageUrl: 'assets/images/products/clothing.png',
},
{
name: 'Office',
description:
'A place for commercial, professional, or bureaucratic work.',
imageUrl: 'assets/images/products/office.png',
},
{
name: 'Advertisement',
description:
'How a company encourages people to buy their products, services or ideas',
imageUrl: 'assets/images/products/advertisement.png',
},
{
name: 'Health',
description:
'State of complete physical, mental, and social well-being',
imageUrl: 'assets/images/products/health.png',
},
{
name: 'Sport',
description: 'An activity involving physical exertion and skill',
imageUrl: 'assets/images/products/sport.png',
},
{
name: 'Furniture',
description:
'Used to make a room or building suitable for living or working in',
imageUrl: 'assets/images/products/furniture.png',
},
{
name: 'Pets',
description:
"An animal kept primarily for a person's company or entertainment rather than as a working animal",
imageUrl: 'assets/images/products/dog.png',
},
],
sentry: {
dns: 'https://19293d39eaa14d03aac4d3c156c4d30e@sentry.io/4397292',
},
Expand Down
2 changes: 0 additions & 2 deletions apps/api/src/environments/ienvironment.ts
Expand Up @@ -9,7 +9,6 @@ import {
IDefaultCandidate,
IDefaultEmployee,
IDefaultProductType,
IDefaultProductCategory,
} from '@gauzy/models';
import { IFacebookConfig } from './IFacebookConfig';
import { IGoogleConfig } from './IGoogleConfig';
Expand Down Expand Up @@ -54,7 +53,6 @@ export interface IEnvironment {
defaultOrganizations?: IDefaultOrganization[];

defaultProductTypes?: IDefaultProductType[];
defaultProductCategories?: IDefaultProductCategory[];

defaultTeams?: {
name: string;
Expand Down
Binary file not shown.
Binary file removed apps/gauzy/src/assets/images/products/clothing.png
Binary file not shown.
Binary file removed apps/gauzy/src/assets/images/products/dog.png
Binary file not shown.
Binary file removed apps/gauzy/src/assets/images/products/education.png
Binary file not shown.
Binary file removed apps/gauzy/src/assets/images/products/food.png
Binary file not shown.
Binary file removed apps/gauzy/src/assets/images/products/furniture.png
Binary file not shown.
Binary file removed apps/gauzy/src/assets/images/products/health.png
Binary file not shown.
Binary file removed apps/gauzy/src/assets/images/products/office.png
Binary file not shown.
Binary file removed apps/gauzy/src/assets/images/products/software.png
Binary file not shown.
Binary file removed apps/gauzy/src/assets/images/products/sport.png
Binary file not shown.
Binary file removed apps/gauzy/src/assets/images/products/transport.png
Binary file not shown.
6 changes: 0 additions & 6 deletions libs/models/src/lib/seed.model.ts
Expand Up @@ -40,9 +40,3 @@ export interface IDefaultProductType {
description: string;
icon: string;
}

export interface IDefaultProductCategory {
name: string;
description: string;
imageUrl: string;
}

0 comments on commit 64d4b65

Please sign in to comment.