From 2ee9138a8eba2f2746b7e1bf03bb168ea25b9a92 Mon Sep 17 00:00:00 2001 From: Bello Babakolo Date: Tue, 20 Aug 2024 11:23:50 +0100 Subject: [PATCH] chore: clean up unused code --- .../forms/product-creation-form.component.ts | 211 ------------------ .../forms/product-price-form.component.ts | 38 ---- .../forms/product-variant-form.component.ts | 65 ------ .../product-image.jss-form-fields.ts | 73 ++++++ .../lib/jss-forms/product-variant.jss-form.ts | 138 +++++++++--- .../product/src/lib/modules-product.module.ts | 6 - 6 files changed, 175 insertions(+), 356 deletions(-) delete mode 100644 packages/modules/product/src/lib/components/forms/product-creation-form.component.ts delete mode 100644 packages/modules/product/src/lib/components/forms/product-price-form.component.ts delete mode 100644 packages/modules/product/src/lib/components/forms/product-variant-form.component.ts create mode 100644 packages/modules/product/src/lib/jss-forms/product-image.jss-form-fields.ts diff --git a/packages/modules/product/src/lib/components/forms/product-creation-form.component.ts b/packages/modules/product/src/lib/components/forms/product-creation-form.component.ts deleted file mode 100644 index 254e1add..00000000 --- a/packages/modules/product/src/lib/components/forms/product-creation-form.component.ts +++ /dev/null @@ -1,211 +0,0 @@ -import { ChangeDetectionStrategy, Component } from '@angular/core'; -import { FormControl, FormGroup } from '@angular/forms'; - -import { ModeType } from '@console-core/graphql'; -import { ProductFacade } from '@console-core/state'; -@Component({ - template: ` -
- - Name - - - - - - - Description - - - - - - - Manufacturer - - - - - Manufacturer A - - - Manufacturer B - - - Manufacturer C - - - - - - - Origin country - - - - - German - - France - - - - - - Taric code - - - - - - - Prototype - - - - - Prototype A - - - Prototype B - - - - - - - Category - - - - - Category A - - - Category B - - - - - - - - Tax Id - - - - - - - Global trade item number - - - - - - - Offerings - - - - Physical - - - Virtual - - - Service - - - - - -
-
- - - -
-
-
- `, - selector: 'app-module-product-creation-form', - changeDetection: ChangeDetectionStrategy.OnPush, -}) -export class ProductCreationFormComponent { - productForm = new FormGroup({ - name: new FormControl('Juju toys bello'), - description: new FormControl( - 'A simple toy that you can say to what you want' - ), - manufacturerId: new FormControl('manu-b'), - originCountryId: new FormControl('germany'), - taricCode: new FormControl('12345678901'), - prototypeId: new FormControl('proto-b'), - categoryId: new FormControl('cat-b'), - gtin: new FormControl('01234567890123'), - // taxIds: new FormControl('germany-standard-rate'), // TODO This would eventually be an array. - }); - - constructor(private readonly productFacade: ProductFacade) {} - - onSubmit() { - if (this.productForm.valid) { - this.productFacade.create({ - mode: ModeType.Create, - items: [ - { - product: this.productForm.value, - meta: { - owners: [ - { - id: 'urn:restorecommerce:acs:names:ownerIndicatoryEntity', - value: - 'urn:restorecommerce:acs:model:organization.Organization', - attributes: [ - { - id: 'urn:restorecommerce:acs:names:ownerInstance', - value: 'nfuse-shop-000-organization', - }, - ], - }, - ], - }, - }, - ], - }); - } - } -} diff --git a/packages/modules/product/src/lib/components/forms/product-price-form.component.ts b/packages/modules/product/src/lib/components/forms/product-price-form.component.ts deleted file mode 100644 index 25b2caa3..00000000 --- a/packages/modules/product/src/lib/components/forms/product-price-form.component.ts +++ /dev/null @@ -1,38 +0,0 @@ -import { ChangeDetectionStrategy, Component, HostBinding } from '@angular/core'; - -@Component({ - template: ` - - Currency - - - USD - EURO - - - - - - Regular Price - - - - - - - Sale Price - - - - - - - Sale ? - - `, - selector: 'app-module-product-price-form', - changeDetection: ChangeDetectionStrategy.OnPush, -}) -export class ProductPriceFormComponent { - @HostBinding('class') className = 'w-100p'; -} diff --git a/packages/modules/product/src/lib/components/forms/product-variant-form.component.ts b/packages/modules/product/src/lib/components/forms/product-variant-form.component.ts deleted file mode 100644 index 58efcccc..00000000 --- a/packages/modules/product/src/lib/components/forms/product-variant-form.component.ts +++ /dev/null @@ -1,65 +0,0 @@ -import { ChangeDetectionStrategy, Component, HostBinding } from '@angular/core'; - -@Component({ - template: ` - - Parent variant - - - Variant 1 - - - - - - Name - - - - - - - Description - - - - - - - Stock Level - - - - - - - Stock Keeping Unit - - - - - - - - - - - Tax Id - - - - - `, - selector: 'app-module-product-variant-form', - changeDetection: ChangeDetectionStrategy.OnPush, -}) -export class ProductVariantFormComponent { - @HostBinding('class') className = 'w-100p'; -} diff --git a/packages/modules/product/src/lib/jss-forms/product-image.jss-form-fields.ts b/packages/modules/product/src/lib/jss-forms/product-image.jss-form-fields.ts new file mode 100644 index 00000000..9da0ff41 --- /dev/null +++ b/packages/modules/product/src/lib/jss-forms/product-image.jss-form-fields.ts @@ -0,0 +1,73 @@ +import { Validators } from '@angular/forms'; + +import { VCLFormFieldControlSchema, VCLFormFieldSchemas } from '@vcl/ng-vcl'; + +export const buildProductPriceFields: VCLFormFieldSchemas[] = + [ + { + name: 'currencyId', + label: 'Currency', + type: 'select', + // disabled: true, + defaultValue: '', + validators: [Validators.required], + params: { + placeholder: 'Select currency', + selectionMode: 'single', + clearable: false, + search: false, + options: [ + { + label: 'USD', + value: 'USD', + }, + { + label: 'EURO', + value: 'EUR', + }, + ], + }, + hints: [ + { + type: 'error', + error: 'required', + message: 'This field is required.', + }, + ], + }, + { + name: 'regularPrice', + label: 'Regular price', + type: 'input', + validators: [Validators.required], + defaultValue: '', + params: {}, + hints: [ + { + type: 'error', + error: 'required', + message: 'This field is required.', + }, + ], + }, + { + name: 'salePrice', + label: 'Sale price', + type: 'input', + validators: [Validators.required], + defaultValue: '', + params: {}, + hints: [ + { + type: 'error', + error: 'required', + message: 'This field is required.', + }, + ], + }, + { + type: 'checkbox', + name: 'sales', + label: 'On sales', + }, + ]; diff --git a/packages/modules/product/src/lib/jss-forms/product-variant.jss-form.ts b/packages/modules/product/src/lib/jss-forms/product-variant.jss-form.ts index a5df5dcf..c823f843 100644 --- a/packages/modules/product/src/lib/jss-forms/product-variant.jss-form.ts +++ b/packages/modules/product/src/lib/jss-forms/product-variant.jss-form.ts @@ -23,7 +23,41 @@ export const buildProductVariantSchema = ( // ], // }, - + { + name: 'offerings', + label: 'Offerings', + type: 'select', + // disabled: true, + defaultValue: '', + validators: [Validators.required], + params: { + placeholder: 'Select offering', + selectionMode: 'single', + clearable: false, + search: false, + options: [ + { + label: 'Physical', + value: 'physical', + }, + { + label: 'Virtual', + value: 'virtual', + }, + { + label: 'Service', + value: 'service', + }, + ], + }, + hints: [ + { + type: 'error', + error: 'required', + message: 'This field is required.', + }, + ], + }, { name: 'name', label: 'Name', @@ -132,41 +166,73 @@ export const buildProductVariantSchema = ( }, ], }, - // { - // name: 'offerings', - // label: 'Offerings', - // type: 'select', - // // disabled: true, - // defaultValue: '', - // validators: [Validators.required], - // params: { - // placeholder: 'Select offering', - // selectionMode: 'single', - // clearable: false, - // search: false, - // options: [ - // { - // label: 'Physical', - // value: 'physical', - // }, - // { - // label: 'Virtual', - // value: 'virtual', - // }, - // { - // label: 'Service', - // value: 'service' - // } - // ], - // }, - // hints: [ - // { - // type: 'error', - // error: 'required', - // message: 'This field is required.', - // }, - // ], - // }, + // Price **** + { + name: 'currencyId', + label: 'Currency', + type: 'select', + // disabled: true, + defaultValue: '', + validators: [Validators.required], + params: { + placeholder: 'Select currency', + selectionMode: 'single', + clearable: false, + search: false, + options: [ + { + label: 'USD', + value: 'USD', + }, + { + label: 'EURO', + value: 'EUR', + }, + ], + }, + hints: [ + { + type: 'error', + error: 'required', + message: 'This field is required.', + }, + ], + }, + { + name: 'regularPrice', + label: 'Regular price', + type: 'input', + validators: [Validators.required], + defaultValue: '', + params: {}, + hints: [ + { + type: 'error', + error: 'required', + message: 'This field is required.', + }, + ], + }, + { + name: 'salePrice', + label: 'Sale price', + type: 'input', + validators: [Validators.required], + defaultValue: '', + params: {}, + hints: [ + { + type: 'error', + error: 'required', + message: 'This field is required.', + }, + ], + }, + { + type: 'checkbox', + name: 'sales', + label: 'On sales', + }, { type: 'buttons', buttons: [ diff --git a/packages/modules/product/src/lib/modules-product.module.ts b/packages/modules/product/src/lib/modules-product.module.ts index e51b01e5..a1cdc647 100644 --- a/packages/modules/product/src/lib/modules-product.module.ts +++ b/packages/modules/product/src/lib/modules-product.module.ts @@ -3,13 +3,10 @@ import { RouterModule } from '@angular/router'; import { ModulesUiModule } from '@console-modules/ui'; -import { ProductCreationFormComponent } from './components/forms/product-creation-form.component'; import { ProductFileFormComponent } from './components/forms/product-files-form.component'; import { ProductImageFormComponent } from './components/forms/product-image-form.component'; import { ProductPackageFormComponent } from './components/forms/product-package-form.component'; -import { ProductPriceFormComponent } from './components/forms/product-price-form.component'; import { ProductPropertyFormComponent } from './components/forms/product-property-form.component'; -import { ProductVariantFormComponent } from './components/forms/product-variant-form.component'; import { ProductCreateComponent } from './components/product-create.component'; import { ProductEditComponent } from './components/product-edit.component'; import { ProductIndexComponent } from './components/product-index.component'; @@ -25,9 +22,6 @@ import { modulesProductRoutes } from './lib.routes'; ProductCreateComponent, ProductEditComponent, ProductViewComponent, - ProductCreationFormComponent, - ProductVariantFormComponent, - ProductPriceFormComponent, ProductImageFormComponent, ProductPropertyFormComponent, ProductFileFormComponent,