Skip to content

Commit

Permalink
Fixed the solution for simple events definition
Browse files Browse the repository at this point in the history
  • Loading branch information
oskardudycz committed Dec 9, 2024
1 parent 99b210e commit a813241
Showing 1 changed file with 36 additions and 46 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,53 +17,43 @@ export type PricedProductItem = ProductItem & {
unitPrice: number;
};

export type ShoppingCartOpened = Event<
'ShoppingCartOpened',
{
shoppingCartId: string;
clientId: string;
openedAt: Date;
}
>;

export type ProductItemAddedToShoppingCart = Event<
'ProductItemAddedToShoppingCart',
{
shoppingCartId: string;
productItem: PricedProductItem;
}
>;

export type ProductItemRemovedFromShoppingCart = Event<
'ProductItemRemovedFromShoppingCart',
{
shoppingCartId: string;
productItem: PricedProductItem;
}
>;

export type ShoppingCartConfirmed = Event<
'ShoppingCartConfirmed',
{
shoppingCartId: string;
confirmedAt: Date;
}
>;

export type ShoppingCartCanceled = Event<
'ShoppingCartCanceled',
{
shoppingCartId: string;
canceledAt: Date;
}
>;

export type ShoppingCartEvent =
| ShoppingCartOpened
| ProductItemAddedToShoppingCart
| ProductItemRemovedFromShoppingCart
| ShoppingCartConfirmed
| ShoppingCartCanceled;
| {
type: 'ShoppingCartOpened';
data: {
shoppingCartId: string;
clientId: string;
openedAt: Date;
};
}
| {
type: 'ProductItemAddedToShoppingCart';
data: {
shoppingCartId: string;
productItem: PricedProductItem;
};
}
| {
type: 'ProductItemRemovedFromShoppingCart';
data: {
shoppingCartId: string;
productItem: PricedProductItem;
};
}
| {
type: 'ShoppingCartConfirmed';
data: {
shoppingCartId: string;
confirmedAt: Date;
};
}
| {
type: 'ShoppingCartCanceled';
data: {
shoppingCartId: string;
canceledAt: Date;
};
};

enum ShoppingCartStatus {
Pending = 'Pending',
Expand Down

0 comments on commit a813241

Please sign in to comment.