Skip to content

Commit

Permalink
fix(admin-ui): Make sku optional in create-product-variant-dialog (#3007
Browse files Browse the repository at this point in the history
)

Closes #2999
  • Loading branch information
Dominic-Preap authored Aug 11, 2024
1 parent 1538a05 commit 13fe069
Showing 1 changed file with 4 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import { ChangeDetectionStrategy, Component, OnInit } from '@angular/core';
import { FormBuilder, FormControl, FormGroup, FormRecord, Validators } from '@angular/forms';
import { FormBuilder, FormControl, FormRecord, Validators } from '@angular/forms';
import {
CreateProductVariantInput,
CurrencyCode,
Dialog,
GetProductVariantOptionsQuery,
} from '@vendure/admin-ui/core';
import { notNullOrUndefined } from '@vendure/common/lib/shared-utils';
import { combineLatest } from 'rxjs';

@Component({
selector: 'vdr-create-product-variant-dialog',
Expand All @@ -20,7 +19,7 @@ export class CreateProductVariantDialogComponent implements Dialog<CreateProduct
product: NonNullable<GetProductVariantOptionsQuery['product']>;
form = this.formBuilder.group({
name: ['', Validators.required],
sku: ['', Validators.required],
sku: [''],
price: [''],
options: this.formBuilder.record<string>({}),
});
Expand Down Expand Up @@ -67,14 +66,14 @@ export class CreateProductVariantDialogComponent implements Dialog<CreateProduct

confirm() {
const { name, sku, options, price } = this.form.value;
if (!name || !sku || !options || price == null) {
if (!name || !options || price == null) {
return;
}

const optionIds = Object.values(options).filter(notNullOrUndefined);
this.resolveWith({
productId: this.product.id,
sku,
sku: sku || '',
price: Number(price),
optionIds,
translations: [
Expand Down

0 comments on commit 13fe069

Please sign in to comment.