File: /var/www/vhosts/uyarreklam.com.tr/httpdocs/subtotal.tar
index.tsx 0000644 00000002041 15156014454 0006415 0 ustar 00 /**
* External dependencies
*/
import { __ } from '@wordpress/i18n';
import { getSetting } from '@woocommerce/settings';
import type { Currency } from '@woocommerce/price-format';
import type { ReactElement } from 'react';
/**
* Internal dependencies
*/
import TotalsItem from '../item';
interface Values {
total_items: string;
total_items_tax: string;
}
export interface SubtotalProps {
className?: string;
currency: Currency;
values: Values | Record< string, never >;
}
const Subtotal = ( {
currency,
values,
className,
}: SubtotalProps ): ReactElement => {
const { total_items: totalItems, total_items_tax: totalItemsTax } = values;
const itemsValue = parseInt( totalItems, 10 );
const itemsTaxValue = parseInt( totalItemsTax, 10 );
return (
<TotalsItem
className={ className }
currency={ currency }
label={ __( 'Subtotal', 'woo-gutenberg-products-block' ) }
value={
getSetting( 'displayCartPricesIncludingTax', false )
? itemsValue + itemsTaxValue
: itemsValue
}
/>
);
};
export default Subtotal;
stories/index.tsx 0000644 00000001722 15156014454 0010112 0 ustar 00 /**
* External dependencies
*/
import type { Story, Meta } from '@storybook/react';
import { currencies, currencyControl } from '@woocommerce/storybook-controls';
/**
* Internal dependencies
*/
import Subtotal, { SubtotalProps } from '..';
export default {
title: 'WooCommerce Blocks/Checkout Blocks/totals/Subtotal',
component: Subtotal,
argTypes: {
currency: currencyControl,
},
args: {
values: {
total_items: '1000',
total_items_tax: '200',
},
},
} as Meta< SubtotalProps >;
type StorybookSubtotalProps = SubtotalProps & { total_items: string };
const Template: Story< StorybookSubtotalProps > = ( args ) => {
const totalItems = args.total_items;
const values = {
total_items: totalItems,
total_items_tax: args.values.total_items_tax,
};
return (
<Subtotal { ...args } currency={ args.currency } values={ values } />
);
};
export const Default = Template.bind( {} );
Default.args = {
currency: currencies.USD,
total_items: '1000',
};