const calculateDistance = (firstPoint, secondPoint) => {
const deltaX = secondPoint.x - firstPoint.x;
const deltaY = secondPoint.y - firstPoint.y;
return Math.sqrt(deltaX * deltaX + deltaY * deltaY);
};
/** @module Helpers */
/**
* @typedef {Object} Point
* @property {number} x - Координата X.
* @property {number} y - Координата Y.
*/
/**
* Рассчитывает расстояние между двумя точками.
*
* @param {Point} firstPoint - Первая точка.
* @param {Point} secondPoint - Вторая точка.
* @returns {number} Расстояние между точками.
*
* @example
* const firstPoint = { x: 0, y: 0 };
* const secondPoint = { x: 3, y: 4 };
* calculateDistance(firstPoint, secondPoint); // Возвращает 5
*/
const calculateDistance = (firstPoint, secondPoint) => {
const deltaX = secondPoint.x - firstPoint.x;
const deltaY = secondPoint.y - firstPoint.y;
return Math.sqrt(deltaX * deltaX + deltaY * deltaY);
};
npm install jsdoc --save-dev
"jsdoc index.js -d docs"
"source": {
"includePattern": ".+\\.js(doc|x)?$",
"excludePattern": "(^|\\/|\\\\)_"
},
config.module.rules.push({
test: /\.svg$/,
use: ['@svgr/webpack'],
});
const ThemeDecoratorProvider = ({ theme, children }: ThemeDecoratorComponentProps) => {
useEffect(() => {
if (theme) {
document.documentElement.setAttribute('data-theme', theme);
return () => {
document.documentElement.removeAttribute('data-theme');
};
}
return undefined;
}, [theme]);
return children;
};
export const ThemeDecorator = (theme?: Theme) => (StoryComponent: StoryFn) => (
<ThemeDecoratorProvider theme={theme}>
<StoryComponent />
</ThemeDecoratorProvider>
);
export const StoreProvider = (props: StoreProviderProps) => {
const { children, initialState } = props;
const store = makeStore(initialState as StateSchema);
return <Provider store={store}>{children}</Provider>;
};
export default {
title: 'pages/BidsPage',
component: BidsPage,
parameters: {
layout: 'centered',
},
argTypes: {},
} satisfies Meta<typeof BidsPage>;
const Template: StoryFn = () => <BidsPage />;
const state: DeepPartial<StateSchema> = {
bids: {
entities: {
1: {...данные заявки},
},
page: 0,
isNextPage: false,
isInitialLoading: false,
isRefetchCache: false,
pageSize: 9,
isLoadingMore: false,
ids: [1],
},
folders: {
currentFolder: 'actual',
folders: [
{...данные папки},
],
isFoldersError: false,
isFoldersInitialLoading: false,
},
sellerBids: {
entities: {
1: {...данные заявки},
},
page: 0,
isNextPage: false,
isInitialLoading: false,
isRefetchCache: false,
pageSize: 9,
isLoadingMore: false,
ids: [1],
},
subscriptions: {
subscriptions: [
{...данные подборки},
],
currentSubscription: 'actual',
isSubscriptionsInitialLoading: false,
isSubscriptionsError: false,
},
};
export const BidsPageCustomer = Template.bind({});
BidsPageCustomer.decorators = [ThemeDecorator(Theme.CUSTOMER), AppLayoutDecorator(state)];
export const BidsPageSeller = Template.bind({});
BidsPageSeller.decorators = [ThemeDecorator(Theme.SELLER), AppLayoutDecorator(state)];