diff --git a/src/entities/AboutFullCard/view/AboutFullCardView.ts b/src/entities/AboutFullCard/view/AboutFullCardView.ts index 534647d8..5eeaf4f7 100644 --- a/src/entities/AboutFullCard/view/AboutFullCardView.ts +++ b/src/entities/AboutFullCard/view/AboutFullCardView.ts @@ -5,7 +5,7 @@ import LinkModel from '@/shared/Link/model/LinkModel.ts'; import getStore from '@/shared/Store/Store.ts'; import observeStore, { selectCurrentLanguage, selectCurrentTheme } from '@/shared/Store/observer.ts'; import ABOUT_TEXT from '@/shared/constants/about.ts'; -import { LINK_DETAILS } from '@/shared/constants/links.ts'; +import { LINK_DETAIL } from '@/shared/constants/links.ts'; import changeColor from '@/shared/utils/changeColor.ts'; import createBaseElement from '@/shared/utils/createBaseElement.ts'; import hexToRgba from '@/shared/utils/hexToRgba.ts'; @@ -83,12 +83,12 @@ class AboutFullCardView extends AboutShortCardView { const href = `https://github.com/${item.from}`; const background = `url(${`/img/png/${item.from}Avatar.png`})`; const from = new LinkModel({ - attrs: { href, target: LINK_DETAILS.BLANK }, + attrs: { href, target: LINK_DETAIL.BLANK }, classes: [styles.from], text: item.from, }); - const avatar = new LinkModel({ attrs: { href, target: LINK_DETAILS.BLANK }, classes: [styles.avatar] }); + const avatar = new LinkModel({ attrs: { href, target: LINK_DETAIL.BLANK }, classes: [styles.avatar] }); avatar.getHTML().style.backgroundImage = background; from.getHTML().append(avatar.getHTML()); diff --git a/src/entities/AboutShortCard/view/AboutShortCardView.ts b/src/entities/AboutShortCard/view/AboutShortCardView.ts index ae183e1f..ed43eef0 100644 --- a/src/entities/AboutShortCard/view/AboutShortCardView.ts +++ b/src/entities/AboutShortCard/view/AboutShortCardView.ts @@ -3,8 +3,8 @@ import type { AboutData, AboutLabel } from '@/shared/types/validation/aboutData' import LinkModel from '@/shared/Link/model/LinkModel.ts'; import getStore from '@/shared/Store/Store.ts'; import observeStore, { selectCurrentLanguage, selectCurrentTheme } from '@/shared/Store/observer.ts'; -import { LINK_DETAILS } from '@/shared/constants/links.ts'; -import SVG_DETAILS from '@/shared/constants/svg.ts'; +import { LINK_DETAIL } from '@/shared/constants/links.ts'; +import SVG_DETAIL from '@/shared/constants/svg.ts'; import changeColor from '@/shared/utils/changeColor.ts'; import createBaseElement from '@/shared/utils/createBaseElement.ts'; import createSVGUse, { changeFill, changeStroke } from '@/shared/utils/createSVGUse.ts'; @@ -25,7 +25,7 @@ class AboutShortCardView { const avatar = new LinkModel({ attrs: { href: this.params.github.link, - target: LINK_DETAILS.BLANK, + target: LINK_DETAIL.BLANK, }, classes: [styles.avatar], }); @@ -57,8 +57,8 @@ class AboutShortCardView { tag: 'span', }); - const svg = document.createElementNS(SVG_DETAILS.SVG_URL, 'svg'); - svg.append(createSVGUse(SVG_DETAILS.PROFILE)); + const svg = document.createElementNS(SVG_DETAIL.SVG_URL, 'svg'); + svg.append(createSVGUse(SVG_DETAIL.PROFILE)); changeStroke(svg, this.params.coverColor[getStore().getState().isAppThemeLight ? 'true' : 'false'].color); observeStore(selectCurrentTheme, () => { @@ -79,7 +79,7 @@ class AboutShortCardView { const githubName = new LinkModel({ attrs: { href: this.params.github.link, - target: LINK_DETAILS.BLANK, + target: LINK_DETAIL.BLANK, }, classes: [styles.githubName], text: this.params.github.name, @@ -181,8 +181,8 @@ class AboutShortCardView { tag: 'span', }); - const svg = document.createElementNS(SVG_DETAILS.SVG_URL, 'svg'); - svg.append(createSVGUse(SVG_DETAILS.STAR)); + const svg = document.createElementNS(SVG_DETAIL.SVG_URL, 'svg'); + svg.append(createSVGUse(SVG_DETAIL.STAR)); changeFill(svg, this.params.coverColor[getStore().getState().isAppThemeLight ? 'true' : 'false'].color); observeStore(selectCurrentTheme, () => { diff --git a/src/entities/Address/model/AddressModel.ts b/src/entities/Address/model/AddressModel.ts index 4e161abc..4efca226 100644 --- a/src/entities/Address/model/AddressModel.ts +++ b/src/entities/Address/model/AddressModel.ts @@ -3,7 +3,7 @@ import type { Address, PersonalData } from '@/shared/types/user.ts'; import CountryChoiceModel from '@/features/CountryChoice/model/CountryChoiceModel.ts'; import getStore from '@/shared/Store/Store.ts'; -import { ADDRESS_TYPE } from '@/shared/types/address.ts'; +import { ADDRESS } from '@/shared/types/address.ts'; import formattedText from '@/shared/utils/formattedText.ts'; import AddressView from '../view/AddressView.ts'; @@ -13,7 +13,7 @@ class AddressModel { private view: AddressView; - constructor(options: AddressOptions, addressType: AddressType = ADDRESS_TYPE.GENERAL) { + constructor(options: AddressOptions, addressType: AddressType = ADDRESS.GENERAL) { this.addressType = addressType; this.view = new AddressView(addressType, options); this.init(); @@ -29,10 +29,10 @@ class AddressModel { let country: string; switch (this.addressType) { - case ADDRESS_TYPE.BILLING: + case ADDRESS.BILLING: country = store.billingCountry; break; - case ADDRESS_TYPE.SHIPPING: + case ADDRESS.SHIPPING: country = store.shippingCountry; break; default: diff --git a/src/entities/Address/view/AddressView.ts b/src/entities/Address/view/AddressView.ts index 41d2f489..90e2eb96 100644 --- a/src/entities/Address/view/AddressView.ts +++ b/src/entities/Address/view/AddressView.ts @@ -1,10 +1,10 @@ import InputFieldModel from '@/entities/InputField/model/InputFieldModel.ts'; import InputModel from '@/shared/Input/model/InputModel.ts'; -import { FORM_TEXT, FORM_TEXT_KEYS, INPUT_TYPE } from '@/shared/constants/forms.ts'; +import { FORM_TEXT, FORM_TEXT_KEY, INPUT_TYPE } from '@/shared/constants/forms.ts'; import * as FORM_FIELDS from '@/shared/constants/forms/fieldParams.ts'; import { TITLE_TEXT, TITLE_TEXT_KEYS } from '@/shared/constants/forms/text.ts'; import * as FORM_VALIDATION from '@/shared/constants/forms/validationParams.ts'; -import { ADDRESS_TYPE, type AddressOptions, type AddressType, SINGLE_ADDRESS } from '@/shared/types/address.ts'; +import { ADDRESS, type AddressOptions, type AddressType, SINGLE_ADDRESS } from '@/shared/types/address.ts'; import createBaseElement from '@/shared/utils/createBaseElement.ts'; import getCurrentLanguage from '@/shared/utils/getCurrentLanguage.ts'; import observeCurrentLanguage from '@/shared/utils/observeCurrentLanguage.ts'; @@ -70,7 +70,7 @@ class AddressView { innerContent: FORM_TEXT[getCurrentLanguage()].SINGLE_ADDRESS, tag: 'span', }); - observeCurrentLanguage(checkBoxText, FORM_TEXT, FORM_TEXT_KEYS.SINGLE_ADDRESS); + observeCurrentLanguage(checkBoxText, FORM_TEXT, FORM_TEXT_KEY.SINGLE_ADDRESS); this.addressAsBillingCheckBox = new InputModel({ autocomplete: FORM_FIELDS.CHECKBOX.AUTOCOMPLETE, @@ -87,7 +87,7 @@ class AddressView { private createAddressByDefaultCheckbox(): HTMLLabelElement { const checkboxLabel = createBaseElement({ attributes: { - for: this.addressType === ADDRESS_TYPE.SHIPPING ? ADDRESS_TYPE.SHIPPING : ADDRESS_TYPE.BILLING, + for: this.addressType === ADDRESS.SHIPPING ? ADDRESS.SHIPPING : ADDRESS.BILLING, }, cssClasses: [styles.checkboxLabel], tag: 'label', @@ -96,7 +96,7 @@ class AddressView { const currentLanguage = getCurrentLanguage(); const textContent = - this.addressType === ADDRESS_TYPE.SHIPPING + this.addressType === ADDRESS.SHIPPING ? FORM_TEXT[currentLanguage].DEFAULT_SHIPPING_ADDRESS : FORM_TEXT[currentLanguage].DEFAULT_BILLING_ADDRESS; const checkBoxText = createBaseElement({ @@ -107,14 +107,14 @@ class AddressView { observeCurrentLanguage( checkBoxText, FORM_TEXT, - this.addressType === ADDRESS_TYPE.SHIPPING - ? FORM_TEXT_KEYS.DEFAULT_SHIPPING_ADDRESS - : FORM_TEXT_KEYS.DEFAULT_BILLING_ADDRESS, + this.addressType === ADDRESS.SHIPPING + ? FORM_TEXT_KEY.DEFAULT_SHIPPING_ADDRESS + : FORM_TEXT_KEY.DEFAULT_BILLING_ADDRESS, ); this.addressByDefaultCheckBox = new InputModel({ autocomplete: FORM_FIELDS.CHECKBOX.AUTOCOMPLETE, - id: this.addressType === ADDRESS_TYPE.SHIPPING ? ADDRESS_TYPE.SHIPPING : ADDRESS_TYPE.BILLING, + id: this.addressType === ADDRESS.SHIPPING ? ADDRESS.SHIPPING : ADDRESS.BILLING, placeholder: '', type: INPUT_TYPE.CHECK_BOX, }); @@ -125,7 +125,7 @@ class AddressView { } private createCityField(): InputFieldModel { - if (this.addressType === ADDRESS_TYPE.SHIPPING) { + if (this.addressType === ADDRESS.SHIPPING) { this.cityField = new InputFieldModel(FORM_FIELDS.SHIPPING_ADDRESS_CITY, FORM_VALIDATION.ADDRESS_CITY_VALIDATE); } else { this.cityField = new InputFieldModel(FORM_FIELDS.BILLING_ADDRESS_CITY, FORM_VALIDATION.ADDRESS_CITY_VALIDATE); @@ -137,7 +137,7 @@ class AddressView { } private createCountryField(): InputFieldModel { - if (this.addressType === ADDRESS_TYPE.SHIPPING) { + if (this.addressType === ADDRESS.SHIPPING) { this.countryField = new InputFieldModel( FORM_FIELDS.SHIPPING_ADDRESS_COUNTRY, FORM_VALIDATION.ADDRESS_COUNTRY_VALIDATE, @@ -158,7 +158,7 @@ class AddressView { this.address = createBaseElement({ cssClasses: [ styles.address, - this.addressType === ADDRESS_TYPE.SHIPPING ? styles.shippingAddressWrapper : styles.billingAddressWrapper, + this.addressType === ADDRESS.SHIPPING ? styles.shippingAddressWrapper : styles.billingAddressWrapper, ], tag: 'div', }); @@ -178,7 +178,7 @@ class AddressView { } private createPostalCodeField(): InputFieldModel { - if (this.addressType === ADDRESS_TYPE.SHIPPING) { + if (this.addressType === ADDRESS.SHIPPING) { this.postalCodeField = new InputFieldModel( FORM_FIELDS.SHIPPING_ADDRESS_POSTAL_CODE, FORM_VALIDATION.ADDRESS_POSTAL_CODE_VALIDATE, @@ -196,7 +196,7 @@ class AddressView { } private createStreetField(): InputFieldModel { - if (this.addressType === ADDRESS_TYPE.SHIPPING) { + if (this.addressType === ADDRESS.SHIPPING) { this.streetField = new InputFieldModel( FORM_FIELDS.SHIPPING_ADDRESS_STREET, FORM_VALIDATION.ADDRESS_STREET_VALIDATE, @@ -220,11 +220,11 @@ class AddressView { const currentLanguage = getCurrentLanguage(); switch (this.addressType) { - case ADDRESS_TYPE.BILLING: + case ADDRESS.BILLING: titleText = TITLE_TEXT[currentLanguage].BILLING_ADDRESS; key = TITLE_TEXT_KEYS.BILLING_ADDRESS; break; - case ADDRESS_TYPE.SHIPPING: + case ADDRESS.SHIPPING: titleText = TITLE_TEXT[currentLanguage].SHIPPING_ADDRESS; key = TITLE_TEXT_KEYS.SHIPPING_ADDRESS; break; diff --git a/src/entities/Credentials/view/CredentialsView.ts b/src/entities/Credentials/view/CredentialsView.ts index 6d2e0b82..00596f82 100644 --- a/src/entities/Credentials/view/CredentialsView.ts +++ b/src/entities/Credentials/view/CredentialsView.ts @@ -4,7 +4,7 @@ import { INPUT_TYPE } from '@/shared/constants/forms.ts'; import * as FORM_FIELDS from '@/shared/constants/forms/fieldParams.ts'; import * as FORM_CONSTANT from '@/shared/constants/forms/text.ts'; import * as FORM_VALIDATION from '@/shared/constants/forms/validationParams.ts'; -import SVG_DETAILS from '@/shared/constants/svg.ts'; +import SVG_DETAIL from '@/shared/constants/svg.ts'; import createBaseElement from '@/shared/utils/createBaseElement.ts'; import createSVGUse from '@/shared/utils/createSVGUse.ts'; import getCurrentLanguage from '@/shared/utils/getCurrentLanguage.ts'; @@ -115,9 +115,9 @@ class CredentialsView { } public switchPasswordElementSVG(type: string): SVGSVGElement { - const svg = document.createElementNS(SVG_DETAILS.SVG_URL, 'svg'); + const svg = document.createElementNS(SVG_DETAIL.SVG_URL, 'svg'); this.showPasswordElement.innerHTML = ''; - svg.append(createSVGUse(type === INPUT_TYPE.PASSWORD ? SVG_DETAILS.CLOSE_EYE : SVG_DETAILS.OPEN_EYE)); + svg.append(createSVGUse(type === INPUT_TYPE.PASSWORD ? SVG_DETAIL.CLOSE_EYE : SVG_DETAIL.OPEN_EYE)); this.showPasswordElement.append(svg); return svg; } diff --git a/src/entities/Navigation/view/NavigationView.ts b/src/entities/Navigation/view/NavigationView.ts index 2c510629..42a7b43c 100644 --- a/src/entities/Navigation/view/NavigationView.ts +++ b/src/entities/Navigation/view/NavigationView.ts @@ -1,5 +1,5 @@ import LinkModel from '@/shared/Link/model/LinkModel.ts'; -import { PAGE_LINK_TEXT, PAGE_LINK_TEXT_KEYS } from '@/shared/constants/links.ts'; +import { PAGE_LINK_TEXT, PAGE_LINK_TEXT_KEY } from '@/shared/constants/links.ts'; import { PAGE_ID } from '@/shared/constants/pages.ts'; import createBaseElement from '@/shared/utils/createBaseElement.ts'; import getCurrentLanguage from '@/shared/utils/getCurrentLanguage.ts'; @@ -59,7 +59,7 @@ class NavigationView { text: PAGE_LINK_TEXT[getCurrentLanguage()].ABOUT, }); - observeCurrentLanguage(this.toAboutLink.getHTML(), PAGE_LINK_TEXT, PAGE_LINK_TEXT_KEYS.ABOUT); + observeCurrentLanguage(this.toAboutLink.getHTML(), PAGE_LINK_TEXT, PAGE_LINK_TEXT_KEY.ABOUT); this.navigationLinks.set(PAGE_ID.ABOUT_US_PAGE, this.toAboutLink); return this.toAboutLink; @@ -74,7 +74,7 @@ class NavigationView { text: PAGE_LINK_TEXT[getCurrentLanguage()].BLOG, }); - observeCurrentLanguage(this.toBlogLink.getHTML(), PAGE_LINK_TEXT, PAGE_LINK_TEXT_KEYS.BLOG); + observeCurrentLanguage(this.toBlogLink.getHTML(), PAGE_LINK_TEXT, PAGE_LINK_TEXT_KEY.BLOG); this.navigationLinks.set(PAGE_ID.BLOG, this.toBlogLink); return this.toBlogLink; @@ -89,7 +89,7 @@ class NavigationView { text: PAGE_LINK_TEXT[getCurrentLanguage()].CATALOG, }); - observeCurrentLanguage(this.toCatalogLink.getHTML(), PAGE_LINK_TEXT, PAGE_LINK_TEXT_KEYS.CATALOG); + observeCurrentLanguage(this.toCatalogLink.getHTML(), PAGE_LINK_TEXT, PAGE_LINK_TEXT_KEY.CATALOG); this.navigationLinks.set(PAGE_ID.CATALOG_PAGE, this.toCatalogLink); return this.toCatalogLink; @@ -104,7 +104,7 @@ class NavigationView { text: PAGE_LINK_TEXT[getCurrentLanguage()].LOGIN, }); - observeCurrentLanguage(this.toLoginLink.getHTML(), PAGE_LINK_TEXT, PAGE_LINK_TEXT_KEYS.LOGIN); + observeCurrentLanguage(this.toLoginLink.getHTML(), PAGE_LINK_TEXT, PAGE_LINK_TEXT_KEY.LOGIN); this.navigationLinks.set(PAGE_ID.LOGIN_PAGE, this.toLoginLink); return this.toLoginLink; @@ -119,7 +119,7 @@ class NavigationView { text: PAGE_LINK_TEXT[getCurrentLanguage()].MAIN, }); - observeCurrentLanguage(this.toMainLink.getHTML(), PAGE_LINK_TEXT, PAGE_LINK_TEXT_KEYS.MAIN); + observeCurrentLanguage(this.toMainLink.getHTML(), PAGE_LINK_TEXT, PAGE_LINK_TEXT_KEY.MAIN); this.navigationLinks.set(PAGE_ID.MAIN_PAGE, this.toMainLink); return this.toMainLink; @@ -134,7 +134,7 @@ class NavigationView { text: PAGE_LINK_TEXT[getCurrentLanguage()].REGISTRATION, }); - observeCurrentLanguage(this.toRegisterLink.getHTML(), PAGE_LINK_TEXT, PAGE_LINK_TEXT_KEYS.REGISTRATION); + observeCurrentLanguage(this.toRegisterLink.getHTML(), PAGE_LINK_TEXT, PAGE_LINK_TEXT_KEY.REGISTRATION); this.navigationLinks.set(PAGE_ID.REGISTRATION_PAGE, this.toRegisterLink); return this.toRegisterLink; diff --git a/src/entities/Post/view/PostView.ts b/src/entities/Post/view/PostView.ts index 272e1a5d..6c350a13 100644 --- a/src/entities/Post/view/PostView.ts +++ b/src/entities/Post/view/PostView.ts @@ -1,4 +1,4 @@ -import type { Post } from '@/shared/constants/blog'; +import type { Post } from '@/shared/types/blog'; import observeStore, { selectCurrentLanguage } from '@/shared/Store/observer.ts'; import { LANGUAGE_CHOICE } from '@/shared/constants/common.ts'; diff --git a/src/entities/ProductCard/view/ProductCardView.ts b/src/entities/ProductCard/view/ProductCardView.ts index 74b8652d..e159bdad 100644 --- a/src/entities/ProductCard/view/ProductCardView.ts +++ b/src/entities/ProductCard/view/ProductCardView.ts @@ -7,7 +7,7 @@ import observeStore, { selectCurrentLanguage } from '@/shared/Store/observer.ts' import { MORE_TEXT } from '@/shared/constants/buttons.ts'; import { LANGUAGE_CHOICE } from '@/shared/constants/common.ts'; import { LOADER_SIZE } from '@/shared/constants/sizes.ts'; -import SVG_DETAILS from '@/shared/constants/svg.ts'; +import SVG_DETAIL from '@/shared/constants/svg.ts'; import * as buildPath from '@/shared/utils/buildPathname.ts'; import createBaseElement from '@/shared/utils/createBaseElement.ts'; import createSVGUse from '@/shared/utils/createSVGUse.ts'; @@ -72,8 +72,8 @@ class ProductCardView { classes: [styles.addToCartButton], }); - const svg = document.createElementNS(SVG_DETAILS.SVG_URL, 'svg'); - svg.append(createSVGUse(SVG_DETAILS.CART)); + const svg = document.createElementNS(SVG_DETAIL.SVG_URL, 'svg'); + svg.append(createSVGUse(SVG_DETAIL.CART)); this.addToCartButton.getHTML().append(svg); return this.addToCartButton; @@ -142,8 +142,8 @@ class ProductCardView { classes: [styles.goDetailsPageLink], }); - const svg = document.createElementNS(SVG_DETAILS.SVG_URL, 'svg'); - svg.append(createSVGUse(SVG_DETAILS.GO_DETAILS)); + const svg = document.createElementNS(SVG_DETAIL.SVG_URL, 'svg'); + svg.append(createSVGUse(SVG_DETAIL.GO_DETAILS)); this.goDetailsPageLink.getHTML().append(svg); return this.goDetailsPageLink; diff --git a/src/entities/ProductModalSlider/view/ProductModalSliderView.ts b/src/entities/ProductModalSlider/view/ProductModalSliderView.ts index 2f01776b..1dfa42ea 100644 --- a/src/entities/ProductModalSlider/view/ProductModalSliderView.ts +++ b/src/entities/ProductModalSlider/view/ProductModalSliderView.ts @@ -4,7 +4,7 @@ import ButtonModel from '@/shared/Button/model/ButtonModel.ts'; import LoaderModel from '@/shared/Loader/model/LoaderModel.ts'; import modal from '@/shared/Modal/model/ModalModel.ts'; import { LOADER_SIZE } from '@/shared/constants/sizes.ts'; -import SVG_DETAILS from '@/shared/constants/svg.ts'; +import SVG_DETAIL from '@/shared/constants/svg.ts'; import createBaseElement from '@/shared/utils/createBaseElement.ts'; import createSVGUse from '@/shared/utils/createSVGUse.ts'; @@ -128,8 +128,8 @@ class ProductModalSliderView { classes: [styles.nextSlideButton], }); - const svg = document.createElementNS(SVG_DETAILS.SVG_URL, 'svg'); - svg.append(createSVGUse(SVG_DETAILS.ARROW_UP)); + const svg = document.createElementNS(SVG_DETAIL.SVG_URL, 'svg'); + svg.append(createSVGUse(SVG_DETAIL.ARROW_UP)); this.nextSlideButton.getHTML().append(svg); return this.nextSlideButton; } @@ -138,8 +138,8 @@ class ProductModalSliderView { this.prevSlideButton = new ButtonModel({ classes: [styles.prevSlideButton], }); - const svg = document.createElementNS(SVG_DETAILS.SVG_URL, 'svg'); - svg.append(createSVGUse(SVG_DETAILS.ARROW_UP)); + const svg = document.createElementNS(SVG_DETAIL.SVG_URL, 'svg'); + svg.append(createSVGUse(SVG_DETAIL.ARROW_UP)); this.prevSlideButton.getHTML().append(svg); return this.prevSlideButton; } diff --git a/src/entities/PromocodeSlider/view/PromoCodeSliderView.ts b/src/entities/PromocodeSlider/view/PromoCodeSliderView.ts index 83d50c38..711aadbc 100644 --- a/src/entities/PromocodeSlider/view/PromoCodeSliderView.ts +++ b/src/entities/PromocodeSlider/view/PromoCodeSliderView.ts @@ -5,7 +5,7 @@ import InputModel from '@/shared/Input/model/InputModel.ts'; import getStore from '@/shared/Store/Store.ts'; import observeStore, { selectCurrentLanguage } from '@/shared/Store/observer.ts'; import PROMO_SLIDER_CONTENT from '@/shared/constants/promo.ts'; -import SVG_DETAILS from '@/shared/constants/svg.ts'; +import SVG_DETAIL from '@/shared/constants/svg.ts'; import calcUserBirthDayRange from '@/shared/utils/calcUserBirthDayRange.ts'; import createBaseElement from '@/shared/utils/createBaseElement.ts'; import createSVGUse from '@/shared/utils/createSVGUse.ts'; @@ -93,8 +93,8 @@ class PromoCodeSliderView { currentPromoCode.getHTML().classList.add(styles.currentPromoCode); - const svg = document.createElementNS(SVG_DETAILS.SVG_URL, 'svg'); - svg.append(createSVGUse(SVG_DETAILS.COPY)); + const svg = document.createElementNS(SVG_DETAIL.SVG_URL, 'svg'); + svg.append(createSVGUse(SVG_DETAIL.COPY)); svg.addEventListener('click', () => { window.navigator.clipboard diff --git a/src/entities/UserAddress/model/UserAddressModel.ts b/src/entities/UserAddress/model/UserAddressModel.ts index 9bd80bb7..e1effc88 100644 --- a/src/entities/UserAddress/model/UserAddressModel.ts +++ b/src/entities/UserAddress/model/UserAddressModel.ts @@ -8,10 +8,10 @@ import LoaderModel from '@/shared/Loader/model/LoaderModel.ts'; import modal from '@/shared/Modal/model/ModalModel.ts'; import getStore from '@/shared/Store/Store.ts'; import { setBillingCountry } from '@/shared/Store/actions.ts'; -import { USER_MESSAGE } from '@/shared/constants/confirmUserMessage.ts'; +import USER_MESSAGE from '@/shared/constants/confirmUserMessage.ts'; import MEDIATOR_EVENT from '@/shared/constants/events.ts'; -import { ADDRESS_TYPE, type AddressTypeType } from '@/shared/constants/forms.ts'; -import { SERVER_MESSAGE_KEYS } from '@/shared/constants/messages.ts'; +import { ADDRESS, type AddressType } from '@/shared/constants/forms.ts'; +import { SERVER_MESSAGE_KEY } from '@/shared/constants/messages.ts'; import { LOADER_SIZE } from '@/shared/constants/sizes.ts'; import getCurrentLanguage from '@/shared/utils/getCurrentLanguage.ts'; import { showErrorMessage, showSuccessMessage } from '@/shared/utils/userMessage.ts'; @@ -21,11 +21,11 @@ import UserAddressView from '../view/UserAddressView.ts'; class UserAddressModel { private currentAddress: Address; - private labels: Map; + private labels: Map; private view: UserAddressView; - constructor(address: Address, activeTypes: AddressTypeType[], inactiveTypes?: AddressTypeType[]) { + constructor(address: Address, activeTypes: AddressType[], inactiveTypes?: AddressType[]) { this.currentAddress = address; this.view = new UserAddressView(address, activeTypes, inactiveTypes); this.labels = this.view.getLabels(); @@ -41,7 +41,7 @@ class UserAddressModel { try { await getCustomerModel().editCustomer([CustomerModel.actionRemoveAddress(address)], user); EventMediatorModel.getInstance().notify(MEDIATOR_EVENT.REDRAW_USER_ADDRESSES, ''); - showSuccessMessage(SERVER_MESSAGE_KEYS.ADDRESS_DELETED); + showSuccessMessage(SERVER_MESSAGE_KEY.ADDRESS_DELETED); } catch (error) { showErrorMessage(error); } @@ -51,20 +51,20 @@ class UserAddressModel { } } - private async handleAddressType(user: User, activeType: AddressTypeType, inactive: boolean): Promise { + private async handleAddressType(user: User, activeType: AddressType, inactive: boolean): Promise { const customerModel = getCustomerModel(); const actions = { - [ADDRESS_TYPE.BILLING]: inactive + [ADDRESS.BILLING]: inactive ? CustomerModel.actionAddBillingAddress(this.currentAddress.id) : CustomerModel.actionRemoveBillingAddress(this.currentAddress), - [ADDRESS_TYPE.DEFAULT_BILLING]: inactive + [ADDRESS.DEFAULT_BILLING]: inactive ? CustomerModel.actionEditDefaultBillingAddress(this.currentAddress.id) : CustomerModel.actionEditDefaultBillingAddress(), - [ADDRESS_TYPE.DEFAULT_SHIPPING]: inactive + [ADDRESS.DEFAULT_SHIPPING]: inactive ? CustomerModel.actionEditDefaultShippingAddress(this.currentAddress.id) : CustomerModel.actionEditDefaultShippingAddress(), - [ADDRESS_TYPE.SHIPPING]: inactive + [ADDRESS.SHIPPING]: inactive ? CustomerModel.actionAddShippingAddress(this.currentAddress.id) : CustomerModel.actionRemoveShippingAddress(this.currentAddress), }; @@ -76,7 +76,7 @@ class UserAddressModel { } } - private async labelClickHandler(activeType: AddressTypeType, inactive?: boolean): Promise { + private async labelClickHandler(activeType: AddressType, inactive?: boolean): Promise { const loader = new LoaderModel(LOADER_SIZE.MEDIUM); loader.setAbsolutePosition(); this.view.toggleState(true); @@ -86,7 +86,7 @@ class UserAddressModel { if (user) { await this.handleAddressType(user, activeType, inactive ?? false); EventMediatorModel.getInstance().notify(MEDIATOR_EVENT.REDRAW_USER_ADDRESSES, ''); - showSuccessMessage(SERVER_MESSAGE_KEYS.ADDRESS_STATUS_CHANGED); + showSuccessMessage(SERVER_MESSAGE_KEY.ADDRESS_STATUS_CHANGED); } } catch (error) { showErrorMessage(error); @@ -132,7 +132,7 @@ class UserAddressModel { } private setLabelClickHandler(): void { - this.labels.forEach((value: { inactive?: boolean; type: AddressTypeType }, label: HTMLDivElement) => { + this.labels.forEach((value: { inactive?: boolean; type: AddressType }, label: HTMLDivElement) => { label.addEventListener('click', async () => { await this.labelClickHandler(value.type, value.inactive); }); diff --git a/src/entities/UserAddress/view/UserAddressView.ts b/src/entities/UserAddress/view/UserAddressView.ts index 0896413e..2282b959 100644 --- a/src/entities/UserAddress/view/UserAddressView.ts +++ b/src/entities/UserAddress/view/UserAddressView.ts @@ -1,12 +1,12 @@ -import type { TooltipTextKeysType } from '@/shared/constants/tooltip.ts'; +import type { TooltipTextKeyType } from '@/shared/constants/tooltip.ts'; import type { Address } from '@/shared/types/user'; import ButtonModel from '@/shared/Button/model/ButtonModel.ts'; import observeStore, { selectCurrentLanguage } from '@/shared/Store/observer.ts'; import COUNTRIES_LIST from '@/shared/constants/countriesList.ts'; -import { ADDRESS_TEXT, ADDRESS_TYPE, type AddressTypeType } from '@/shared/constants/forms.ts'; -import SVG_DETAILS from '@/shared/constants/svg.ts'; -import TOOLTIP_TEXT, { TOOLTIP_TEXT_KEYS } from '@/shared/constants/tooltip.ts'; +import { ADDRESS, ADDRESS_TEXT, type AddressType } from '@/shared/constants/forms.ts'; +import SVG_DETAIL from '@/shared/constants/svg.ts'; +import TOOLTIP_TEXT, { TOOLTIP_TEXT_KEY } from '@/shared/constants/tooltip.ts'; import createBaseElement from '@/shared/utils/createBaseElement.ts'; import createSVGUse from '@/shared/utils/createSVGUse.ts'; import findKeyByValue from '@/shared/utils/findKeyByValue.ts'; @@ -25,7 +25,7 @@ class UserAddressView { private editButton: ButtonModel; - private labels: Map = new Map(); + private labels: Map = new Map(); private labelsWrapper: HTMLDivElement; @@ -35,7 +35,7 @@ class UserAddressView { private view: HTMLLIElement; - constructor(address: Address, types: AddressTypeType[], inactiveTypes?: AddressTypeType[]) { + constructor(address: Address, types: AddressType[], inactiveTypes?: AddressType[]) { this.currentAddress = address; this.deleteButton = this.createDeleteButton(); this.editButton = this.createEditButton(); @@ -106,8 +106,8 @@ class UserAddressView { title: TOOLTIP_TEXT[getCurrentLanguage()].DELETE_ADDRESS, }); - const svg = document.createElementNS(SVG_DETAILS.SVG_URL, 'svg'); - svg.append(createSVGUse(SVG_DETAILS.DELETE)); + const svg = document.createElementNS(SVG_DETAIL.SVG_URL, 'svg'); + svg.append(createSVGUse(SVG_DETAIL.DELETE)); this.deleteButton.getHTML().append(svg); observeStore(selectCurrentLanguage, () => { @@ -123,8 +123,8 @@ class UserAddressView { title: TOOLTIP_TEXT[getCurrentLanguage()].EDIT_ADDRESS, }); - const svg = document.createElementNS(SVG_DETAILS.SVG_URL, 'svg'); - svg.append(createSVGUse(SVG_DETAILS.EDIT)); + const svg = document.createElementNS(SVG_DETAIL.SVG_URL, 'svg'); + svg.append(createSVGUse(SVG_DETAIL.EDIT)); this.editButton.getHTML().append(svg); observeStore(selectCurrentLanguage, () => { @@ -134,7 +134,7 @@ class UserAddressView { return this.editButton; } - private createHTML(activeTypes: AddressTypeType[], inactiveTypes?: AddressTypeType[]): HTMLLIElement { + private createHTML(activeTypes: AddressType[], inactiveTypes?: AddressType[]): HTMLLIElement { this.view = createBaseElement({ cssClasses: [styles.addressItem], tag: 'li', @@ -167,7 +167,7 @@ class UserAddressView { return this.view; } - private createLabel(text: string, additionalStyles: string[], titleKey: TooltipTextKeysType): HTMLDivElement { + private createLabel(text: string, additionalStyles: string[], titleKey: TooltipTextKeyType): HTMLDivElement { const label = createBaseElement({ cssClasses: [styles.addressType, ...additionalStyles], innerContent: text, @@ -240,33 +240,33 @@ class UserAddressView { return this.streetNameSpan; } - private setActiveAddressLabel(ActiveType: AddressTypeType, inactive?: boolean): void { + private setActiveAddressLabel(ActiveType: AddressType, inactive?: boolean): void { let addressType = null; switch (ActiveType) { - case ADDRESS_TYPE.BILLING: - addressType = this.createLabel(ActiveType, [styles.billing], TOOLTIP_TEXT_KEYS.SWITCH_BILLING_ADDRESS); + case ADDRESS.BILLING: + addressType = this.createLabel(ActiveType, [styles.billing], TOOLTIP_TEXT_KEY.SWITCH_BILLING_ADDRESS); this.labelsWrapper.append(addressType); break; - case ADDRESS_TYPE.SHIPPING: - addressType = this.createLabel(ActiveType, [styles.shipping], TOOLTIP_TEXT_KEYS.SWITCH_SHIPPING_ADDRESS); + case ADDRESS.SHIPPING: + addressType = this.createLabel(ActiveType, [styles.shipping], TOOLTIP_TEXT_KEY.SWITCH_SHIPPING_ADDRESS); this.labelsWrapper.append(addressType); break; - case ADDRESS_TYPE.DEFAULT_BILLING: + case ADDRESS.DEFAULT_BILLING: addressType = this.createLabel( ActiveType, [styles.defaultBilling], - TOOLTIP_TEXT_KEYS.SWITCH_DEFAULT_BILLING_ADDRESS, + TOOLTIP_TEXT_KEY.SWITCH_DEFAULT_BILLING_ADDRESS, ); this.labelsWrapper.append(addressType); break; - case ADDRESS_TYPE.DEFAULT_SHIPPING: + case ADDRESS.DEFAULT_SHIPPING: addressType = this.createLabel( ActiveType, [styles.defaultShipping], - TOOLTIP_TEXT_KEYS.SWITCH_DEFAULT_SHIPPING_ADDRESS, + TOOLTIP_TEXT_KEY.SWITCH_DEFAULT_SHIPPING_ADDRESS, ); this.labelsWrapper.append(addressType); break; @@ -302,7 +302,7 @@ class UserAddressView { return this.view; } - public getLabels(): Map { + public getLabels(): Map { return this.labels; } diff --git a/src/features/AddressAdd/model/AddressAddModel.ts b/src/features/AddressAdd/model/AddressAddModel.ts index e55691d9..b7e73108 100644 --- a/src/features/AddressAdd/model/AddressAddModel.ts +++ b/src/features/AddressAdd/model/AddressAddModel.ts @@ -10,9 +10,9 @@ import LoaderModel from '@/shared/Loader/model/LoaderModel.ts'; import modal from '@/shared/Modal/model/ModalModel.ts'; import getStore from '@/shared/Store/Store.ts'; import MEDIATOR_EVENT from '@/shared/constants/events.ts'; -import { SERVER_MESSAGE_KEYS } from '@/shared/constants/messages.ts'; +import { SERVER_MESSAGE_KEY } from '@/shared/constants/messages.ts'; import { LOADER_SIZE } from '@/shared/constants/sizes.ts'; -import { ADDRESS_TYPE } from '@/shared/types/address.ts'; +import { ADDRESS } from '@/shared/types/address.ts'; import formattedText from '@/shared/utils/formattedText.ts'; import { showErrorMessage, showSuccessMessage } from '@/shared/utils/userMessage.ts'; @@ -59,7 +59,7 @@ class AddressAddModel { const { city, postalCode, streetName } = this.getFormAddressData(); return { city, - country: this.addressType === ADDRESS_TYPE.BILLING ? store.billingCountry : store.shippingCountry, + country: this.addressType === ADDRESS.BILLING ? store.billingCountry : store.shippingCountry, email, firstName, id: '', @@ -91,7 +91,7 @@ class AddressAddModel { private getAddressActions(addressId: string): MyCustomerUpdateAction[] { const addAddressAction = - this.addressType === ADDRESS_TYPE.BILLING + this.addressType === ADDRESS.BILLING ? CustomerModel.actionAddBillingAddress(addressId) : CustomerModel.actionAddShippingAddress(addressId); @@ -99,7 +99,7 @@ class AddressAddModel { } private getDefaultAddressAction(addressId: string): MyCustomerUpdateAction { - return this.addressType === ADDRESS_TYPE.BILLING + return this.addressType === ADDRESS.BILLING ? CustomerModel.actionEditDefaultBillingAddress(addressId) : CustomerModel.actionEditDefaultShippingAddress(addressId); } @@ -119,7 +119,7 @@ class AddressAddModel { private handleSuccess(): void { EventMediatorModel.getInstance().notify(MEDIATOR_EVENT.REDRAW_USER_ADDRESSES, ''); - showSuccessMessage(SERVER_MESSAGE_KEYS.ADDRESS_ADDED); + showSuccessMessage(SERVER_MESSAGE_KEY.ADDRESS_ADDED); modal.hide(); } diff --git a/src/features/AddressEdit/model/AddressEditModel.ts b/src/features/AddressEdit/model/AddressEditModel.ts index ca5217b0..6677cfbb 100644 --- a/src/features/AddressEdit/model/AddressEditModel.ts +++ b/src/features/AddressEdit/model/AddressEditModel.ts @@ -8,7 +8,7 @@ import LoaderModel from '@/shared/Loader/model/LoaderModel.ts'; import modal from '@/shared/Modal/model/ModalModel.ts'; import COUNTRIES_LIST from '@/shared/constants/countriesList.ts'; import MEDIATOR_EVENT from '@/shared/constants/events.ts'; -import { SERVER_MESSAGE_KEYS } from '@/shared/constants/messages.ts'; +import { SERVER_MESSAGE_KEY } from '@/shared/constants/messages.ts'; import { LOADER_SIZE } from '@/shared/constants/sizes.ts'; import findKeyByValue from '@/shared/utils/findKeyByValue.ts'; import formattedText from '@/shared/utils/formattedText.ts'; @@ -60,7 +60,7 @@ class AddressEditModel { if (user) { await getCustomerModel().editCustomer([CustomerModel.actionEditAddress(this.createAddress(user))], user); modal.hide(); - showSuccessMessage(SERVER_MESSAGE_KEYS.ADDRESS_CHANGED); + showSuccessMessage(SERVER_MESSAGE_KEY.ADDRESS_CHANGED); EventMediatorModel.getInstance().notify(MEDIATOR_EVENT.REDRAW_USER_ADDRESSES, ''); } } catch (error) { diff --git a/src/features/CountryChoice/model/CountryChoiceModel.ts b/src/features/CountryChoice/model/CountryChoiceModel.ts index 6aec65bc..35bd65a2 100644 --- a/src/features/CountryChoice/model/CountryChoiceModel.ts +++ b/src/features/CountryChoice/model/CountryChoiceModel.ts @@ -1,9 +1,9 @@ import getStore from '@/shared/Store/Store.ts'; import { setBillingCountry, setDefaultCountry, setShippingCountry } from '@/shared/Store/actions.ts'; import observeStore, { selectCurrentLanguage } from '@/shared/Store/observer.ts'; -import { DATA_KEYS } from '@/shared/constants/common.ts'; +import { DATA_KEY } from '@/shared/constants/common.ts'; import COUNTRIES_LIST from '@/shared/constants/countriesList.ts'; -import { USER_ADDRESS_TYPE } from '@/shared/constants/forms.ts'; +import { USER_ADDRESS } from '@/shared/constants/forms.ts'; import formattedText from '@/shared/utils/formattedText.ts'; import getCountryIndex from '@/shared/utils/getCountryIndex.ts'; import getCurrentLanguage from '@/shared/utils/getCurrentLanguage.ts'; @@ -40,7 +40,7 @@ class CountryChoiceModel { currentItem.addEventListener('click', () => { if (currentItem.textContent) { inputHTML.value = currentItem.textContent; - this.setCountryToStore(currentItem, inputHTML.getAttribute(DATA_KEYS.ADDRESS_TYPE) ?? ''); + this.setCountryToStore(currentItem, inputHTML.getAttribute(DATA_KEY.ADDRESS) ?? ''); const event = new Event('input'); input.dispatchEvent(event); this.view.hideCountryChoice(); @@ -58,10 +58,10 @@ class CountryChoiceModel { let action; switch (key) { - case USER_ADDRESS_TYPE.BILLING: + case USER_ADDRESS.BILLING: action = setBillingCountry; break; - case USER_ADDRESS_TYPE.SHIPPING: + case USER_ADDRESS.SHIPPING: action = setShippingCountry; break; default: @@ -77,7 +77,7 @@ class CountryChoiceModel { input.addEventListener('focus', () => this.view.showCountryChoice()); input.addEventListener('input', () => { this.view.switchVisibilityCountryItems(input); - this.setCountryToStore(input, input.getAttribute(DATA_KEYS.ADDRESS_TYPE) ?? ''); + this.setCountryToStore(input, input.getAttribute(DATA_KEY.ADDRESS) ?? ''); }); return true; } diff --git a/src/features/CountryChoice/view/CountryChoiceView.ts b/src/features/CountryChoice/view/CountryChoiceView.ts index 1eb5e43f..672d411a 100644 --- a/src/features/CountryChoice/view/CountryChoiceView.ts +++ b/src/features/CountryChoice/view/CountryChoiceView.ts @@ -1,5 +1,5 @@ import COUNTRIES_LIST from '@/shared/constants/countriesList.ts'; -import { KEYBOARD_KEYS } from '@/shared/constants/keyboard.ts'; +import KEYBOARD_KEY from '@/shared/constants/keyboard.ts'; import createBaseElement from '@/shared/utils/createBaseElement.ts'; import getCurrentLanguage from '@/shared/utils/getCurrentLanguage.ts'; @@ -25,7 +25,7 @@ class CountryChoiceView { }); document.addEventListener('keydown', (event) => { - if (event.key === KEYBOARD_KEYS.TAB && !this.getHTML().classList.contains(styles.hidden)) { + if (event.key === KEYBOARD_KEY.TAB && !this.getHTML().classList.contains(styles.hidden)) { this.hideCountryChoice(); } }); diff --git a/src/features/InputFieldValidator/validators/validators.ts b/src/features/InputFieldValidator/validators/validators.ts index 9abad95f..a5d96a1a 100644 --- a/src/features/InputFieldValidator/validators/validators.ts +++ b/src/features/InputFieldValidator/validators/validators.ts @@ -3,7 +3,7 @@ import type { InputFieldParams, InputFieldValidatorParams } from '@/shared/types import getStore from '@/shared/Store/Store.ts'; import observeStore, { selectCurrentLanguage } from '@/shared/Store/observer.ts'; import COUNTRIES_LIST from '@/shared/constants/countriesList.ts'; -import { USER_ADDRESS_TYPE } from '@/shared/constants/forms.ts'; +import { USER_ADDRESS } from '@/shared/constants/forms.ts'; import { ERROR_MESSAGE } from '@/shared/constants/messages.ts'; import { checkInputLanguage } from '@/shared/utils/getCountryIndex.ts'; import getCurrentLanguage from '@/shared/utils/getCurrentLanguage.ts'; @@ -101,7 +101,7 @@ export const checkValidPostalCode = ( if (validParams.validPostalCode && inputParams.inputParams.data) { const { billingCountry, shippingCountry } = getStore().getState(); const currentCountry = - inputParams.inputParams.data.addressType === USER_ADDRESS_TYPE.SHIPPING ? shippingCountry : billingCountry; + inputParams.inputParams.data.addressType === USER_ADDRESS.SHIPPING ? shippingCountry : billingCountry; try { const result = postcodeValidator(value, currentCountry); if (!result) { diff --git a/src/features/PasswordEdit/model/PasswordEditModel.ts b/src/features/PasswordEdit/model/PasswordEditModel.ts index 17f6fded..fc878af2 100644 --- a/src/features/PasswordEdit/model/PasswordEditModel.ts +++ b/src/features/PasswordEdit/model/PasswordEditModel.ts @@ -4,7 +4,7 @@ import getCustomerModel from '@/shared/API/customer/model/CustomerModel.ts'; import LoaderModel from '@/shared/Loader/model/LoaderModel.ts'; import modal from '@/shared/Modal/model/ModalModel.ts'; import { INPUT_TYPE, PASSWORD_TEXT } from '@/shared/constants/forms.ts'; -import { SERVER_MESSAGE_KEYS } from '@/shared/constants/messages.ts'; +import { SERVER_MESSAGE_KEY } from '@/shared/constants/messages.ts'; import { LOADER_SIZE } from '@/shared/constants/sizes.ts'; import { showErrorMessage, showSuccessMessage } from '@/shared/utils/userMessage.ts'; @@ -40,10 +40,10 @@ class PasswordEditModel { this.view.getOldPasswordField().getView().getValue(), this.view.getNewPasswordField().getView().getValue(), ); - showSuccessMessage(SERVER_MESSAGE_KEYS.PASSWORD_CHANGED); + showSuccessMessage(SERVER_MESSAGE_KEY.PASSWORD_CHANGED); modal.hide(); } catch { - showErrorMessage(SERVER_MESSAGE_KEYS.PASSWORD_NOT_CHANGED); + showErrorMessage(SERVER_MESSAGE_KEY.PASSWORD_NOT_CHANGED); } } }); diff --git a/src/features/PasswordEdit/view/PasswordEditView.ts b/src/features/PasswordEdit/view/PasswordEditView.ts index 148975f3..613d4c06 100644 --- a/src/features/PasswordEdit/view/PasswordEditView.ts +++ b/src/features/PasswordEdit/view/PasswordEditView.ts @@ -5,7 +5,7 @@ import { BUTTON_TEXT } from '@/shared/constants/buttons.ts'; import { INPUT_TYPE } from '@/shared/constants/forms.ts'; import * as FORM_FIELDS from '@/shared/constants/forms/fieldParams.ts'; import * as FORM_VALIDATION from '@/shared/constants/forms/validationParams.ts'; -import SVG_DETAILS from '@/shared/constants/svg.ts'; +import SVG_DETAIL from '@/shared/constants/svg.ts'; import createBaseElement from '@/shared/utils/createBaseElement.ts'; import createSVGUse from '@/shared/utils/createSVGUse.ts'; import getCurrentLanguage from '@/shared/utils/getCurrentLanguage.ts'; @@ -150,9 +150,9 @@ class PasswordEditView { public switchPasswordElementSVG(type: string, el: HTMLDivElement): SVGSVGElement { const element = el; - const svg = document.createElementNS(SVG_DETAILS.SVG_URL, 'svg'); + const svg = document.createElementNS(SVG_DETAIL.SVG_URL, 'svg'); element.innerHTML = ''; - svg.append(createSVGUse(type === INPUT_TYPE.PASSWORD ? SVG_DETAILS.CLOSE_EYE : SVG_DETAILS.OPEN_EYE)); + svg.append(createSVGUse(type === INPUT_TYPE.PASSWORD ? SVG_DETAIL.CLOSE_EYE : SVG_DETAIL.OPEN_EYE)); element.append(svg); return svg; } diff --git a/src/features/PersonalInfoEdit/model/PersonalInfoEditModel.ts b/src/features/PersonalInfoEdit/model/PersonalInfoEditModel.ts index 27fe6c2a..83d4fcd9 100644 --- a/src/features/PersonalInfoEdit/model/PersonalInfoEditModel.ts +++ b/src/features/PersonalInfoEdit/model/PersonalInfoEditModel.ts @@ -7,7 +7,7 @@ import EventMediatorModel from '@/shared/EventMediator/model/EventMediatorModel. import LoaderModel from '@/shared/Loader/model/LoaderModel.ts'; import modal from '@/shared/Modal/model/ModalModel.ts'; import MEDIATOR_EVENT from '@/shared/constants/events.ts'; -import { SERVER_MESSAGE_KEYS } from '@/shared/constants/messages.ts'; +import { SERVER_MESSAGE_KEY } from '@/shared/constants/messages.ts'; import { LOADER_SIZE } from '@/shared/constants/sizes.ts'; import formattedText from '@/shared/utils/formattedText.ts'; import { showErrorMessage, showSuccessMessage } from '@/shared/utils/userMessage.ts'; @@ -47,7 +47,7 @@ class PersonalInfoEditModel { ); modal.hide(); EventMediatorModel.getInstance().notify(MEDIATOR_EVENT.REDRAW_USER_INFO, ''); - showSuccessMessage(SERVER_MESSAGE_KEYS.PERSONAL_INFO_CHANGED); + showSuccessMessage(SERVER_MESSAGE_KEY.PERSONAL_INFO_CHANGED); } } catch (error) { showErrorMessage(error); diff --git a/src/features/ProductFilters/view/ProductFiltersView.ts b/src/features/ProductFilters/view/ProductFiltersView.ts index 6ddcd793..7e0921d1 100644 --- a/src/features/ProductFilters/view/ProductFiltersView.ts +++ b/src/features/ProductFilters/view/ProductFiltersView.ts @@ -12,7 +12,7 @@ import observeStore, { selectCurrentLanguage } from '@/shared/Store/observer.ts' import { BUTTON_TEXT } from '@/shared/constants/buttons.ts'; import { AUTOCOMPLETE_OPTION, LANGUAGE_CHOICE } from '@/shared/constants/common.ts'; import MEDIATOR_EVENT from '@/shared/constants/events.ts'; -import { META_FILTERS, META_FILTERS_ID, PRICE_RANGE_LABEL, TITLE } from '@/shared/constants/filters.ts'; +import { META_FILTER, META_FILTER_ID, PRICE_RANGE_LABEL, TITLE } from '@/shared/constants/filters.ts'; import { INPUT_TYPE } from '@/shared/constants/forms.ts'; import { PAGE_ID } from '@/shared/constants/pages.ts'; import { SEARCH_PARAMS_FIELD } from '@/shared/constants/product.ts'; @@ -230,28 +230,24 @@ class ProductFiltersView { const currentLanguage = getCurrentLanguage(); const allProductsLink = this.createMetaLink( - META_FILTERS[currentLanguage].ALL_PRODUCTS, - META_FILTERS_ID.ALL_PRODUCTS, - META_FILTERS.en.ALL_PRODUCTS, + META_FILTER[currentLanguage].ALL_PRODUCTS, + META_FILTER_ID.ALL_PRODUCTS, + META_FILTER.en.ALL_PRODUCTS, ); const newArrivalsLink = this.createMetaLink( - META_FILTERS[currentLanguage].NEW_ARRIVALS, - META_FILTERS_ID.NEW_ARRIVALS, - META_FILTERS.en.NEW_ARRIVALS, - ); - const saleLink = this.createMetaLink( - META_FILTERS[currentLanguage].SALE, - META_FILTERS_ID.SALE, - META_FILTERS.en.SALE, + META_FILTER[currentLanguage].NEW_ARRIVALS, + META_FILTER_ID.NEW_ARRIVALS, + META_FILTER.en.NEW_ARRIVALS, ); + const saleLink = this.createMetaLink(META_FILTER[currentLanguage].SALE, META_FILTER_ID.SALE, META_FILTER.en.SALE); allProductsLink.getHTML().classList.add(styles.activeLink); this.metaFilters.append(allProductsLink.getHTML(), newArrivalsLink.getHTML(), saleLink.getHTML()); observeStore(selectCurrentLanguage, () => { const currentLanguage = getCurrentLanguage(); - allProductsLink.getHTML().textContent = META_FILTERS[currentLanguage].ALL_PRODUCTS; - newArrivalsLink.getHTML().textContent = META_FILTERS[currentLanguage].NEW_ARRIVALS; - saleLink.getHTML().textContent = META_FILTERS[currentLanguage].SALE; + allProductsLink.getHTML().textContent = META_FILTER[currentLanguage].ALL_PRODUCTS; + newArrivalsLink.getHTML().textContent = META_FILTER[currentLanguage].NEW_ARRIVALS; + saleLink.getHTML().textContent = META_FILTER[currentLanguage].SALE; }); return this.metaFilters; @@ -405,7 +401,7 @@ class ProductFiltersView { this.categoryLinks.forEach((link) => this.switchSelectedFilter(link, false)); this.metaLinks.forEach((link) => { this.switchSelectedFilter(link, false); - if (link.getHTML().id === META_FILTERS.en.ALL_PRODUCTS) { + if (link.getHTML().id === META_FILTER.en.ALL_PRODUCTS) { this.switchSelectedFilter(link, true); } }); diff --git a/src/features/ProductSearch/view/ProductSearchView.ts b/src/features/ProductSearch/view/ProductSearchView.ts index 156c2786..37db8380 100644 --- a/src/features/ProductSearch/view/ProductSearchView.ts +++ b/src/features/ProductSearch/view/ProductSearchView.ts @@ -3,7 +3,7 @@ import InputModel from '@/shared/Input/model/InputModel.ts'; import observeStore, { selectCurrentLanguage } from '@/shared/Store/observer.ts'; import { INPUT_TYPE } from '@/shared/constants/forms.ts'; import { SEARCH_PARAMS_FIELD } from '@/shared/constants/product.ts'; -import { TEXT } from '@/shared/constants/sorting.ts'; +import { SORTING_TEXT } from '@/shared/constants/sorting.ts'; import createBaseElement from '@/shared/utils/createBaseElement.ts'; import getCurrentLanguage from '@/shared/utils/getCurrentLanguage.ts'; @@ -31,7 +31,7 @@ class ProductSearchView { private createSearchField(): InputModel { this.searchField = new InputModel({ - placeholder: TEXT[getCurrentLanguage()].SEARCH, + placeholder: SORTING_TEXT[getCurrentLanguage()].SEARCH, type: INPUT_TYPE.SEARCH, }); @@ -41,7 +41,7 @@ class ProductSearchView { } observeStore(selectCurrentLanguage, () => { - this.searchField.getHTML().placeholder = TEXT[getCurrentLanguage()].SEARCH; + this.searchField.getHTML().placeholder = SORTING_TEXT[getCurrentLanguage()].SEARCH; }); this.searchField.getHTML().classList.add(styles.searchField); diff --git a/src/features/ProductSorts/view/ProductSortsView.ts b/src/features/ProductSorts/view/ProductSortsView.ts index ee748260..32877fe7 100644 --- a/src/features/ProductSorts/view/ProductSortsView.ts +++ b/src/features/ProductSorts/view/ProductSortsView.ts @@ -3,9 +3,9 @@ import RouterModel from '@/app/Router/model/RouterModel.ts'; import { SortDirection } from '@/shared/API/types/type.ts'; import LinkModel from '@/shared/Link/model/LinkModel.ts'; import observeStore, { selectCurrentLanguage } from '@/shared/Store/observer.ts'; -import { DATA_KEYS } from '@/shared/constants/common.ts'; +import { DATA_KEY } from '@/shared/constants/common.ts'; import { SEARCH_PARAMS_FIELD } from '@/shared/constants/product.ts'; -import { SORTING_ID, TEXT, TEXT_KEYS } from '@/shared/constants/sorting.ts'; +import { SORTING_ID, SORTING_TEXT, SORTING_TEXT_KEY } from '@/shared/constants/sorting.ts'; import createBaseElement from '@/shared/utils/createBaseElement.ts'; import getCurrentLanguage from '@/shared/utils/getCurrentLanguage.ts'; @@ -51,9 +51,9 @@ class ProductSortsView { this.currentSortingSpan = createBaseElement({ cssClasses: [styles.currentSortingSpan], innerContent: - selectedSorting && selectedSorting in TEXT - ? TEXT[currentLanguage][selectedSorting.toUpperCase()] - : TEXT[currentLanguage].DEFAULT.toUpperCase(), + selectedSorting && selectedSorting in SORTING_TEXT + ? SORTING_TEXT[currentLanguage][selectedSorting.toUpperCase()] + : SORTING_TEXT[currentLanguage].DEFAULT.toUpperCase(), tag: 'span', }); @@ -62,9 +62,9 @@ class ProductSortsView { const currentLanguage = getCurrentLanguage(); this.currentSortingSpan.innerText = - selectedSorting && selectedSorting in TEXT - ? TEXT[currentLanguage][selectedSorting.toUpperCase()] - : TEXT[currentLanguage].DEFAULT.toUpperCase(); + selectedSorting && selectedSorting in SORTING_TEXT + ? SORTING_TEXT[currentLanguage][selectedSorting.toUpperCase()] + : SORTING_TEXT[currentLanguage].DEFAULT.toUpperCase(); }); return this.currentSortingSpan; @@ -83,12 +83,12 @@ class ProductSortsView { private createSortingLink(href: string, key: string, id: string): LinkModel { const link = new LinkModel({ attrs: { - [DATA_KEYS.DIRECTION]: SortDirection.ASC, + [DATA_KEY.DIRECTION]: SortDirection.ASC, href, id, }, classes: [styles.sortingLink], - text: TEXT[getCurrentLanguage()][key], + text: SORTING_TEXT[getCurrentLanguage()][key], }); link.getHTML().classList.add(styles.hight); @@ -103,10 +103,10 @@ class ProductSortsView { this.sortingListLinks.forEach((link) => link.getHTML().classList.remove(styles.activeLink)); link.getHTML().classList.add(styles.activeLink); - this.currentSortingSpan.innerText = TEXT[getCurrentLanguage()][key]; + this.currentSortingSpan.innerText = SORTING_TEXT[getCurrentLanguage()][key]; RouterModel.changeSearchParams((url) => { set(url, SEARCH_PARAMS_FIELD.FIELD, link.getHTML().id); - set(url, SEARCH_PARAMS_FIELD.DIRECTION, String(link.getHTML().getAttribute(DATA_KEYS.DIRECTION))); + set(url, SEARCH_PARAMS_FIELD.DIRECTION, String(link.getHTML().getAttribute(DATA_KEY.DIRECTION))); }); this.callback(); }); @@ -122,9 +122,9 @@ class ProductSortsView { tag: 'ul', }); - const defaultSortingLink = this.createSortingLink('', TEXT_KEYS.DEFAULT, SORTING_ID.DEFAULT); - const priceLink = this.createSortingLink('', TEXT_KEYS.PRICE, SORTING_ID.PRICE); - const nameLink = this.createSortingLink('', TEXT_KEYS.NAME, SORTING_ID.NAME); + const defaultSortingLink = this.createSortingLink('', SORTING_TEXT_KEY.DEFAULT, SORTING_ID.DEFAULT); + const priceLink = this.createSortingLink('', SORTING_TEXT_KEY.PRICE, SORTING_ID.PRICE); + const nameLink = this.createSortingLink('', SORTING_TEXT_KEY.NAME, SORTING_ID.NAME); const initialField = RouterModel.getSearchParams().get(SEARCH_PARAMS_FIELD.FIELD); const initialDirection = RouterModel.getSearchParams().get(SEARCH_PARAMS_FIELD.DIRECTION); @@ -140,9 +140,9 @@ class ProductSortsView { observeStore(selectCurrentLanguage, () => { const currentLanguage = getCurrentLanguage(); - defaultSortingLink.getHTML().innerText = TEXT[currentLanguage].DEFAULT; - priceLink.getHTML().innerText = TEXT[currentLanguage].PRICE; - nameLink.getHTML().innerText = TEXT[currentLanguage].NAME; + defaultSortingLink.getHTML().innerText = SORTING_TEXT[currentLanguage].DEFAULT; + priceLink.getHTML().innerText = SORTING_TEXT[currentLanguage].PRICE; + nameLink.getHTML().innerText = SORTING_TEXT[currentLanguage].NAME; }); this.sortingList.append(defaultSortingLink.getHTML(), priceLink.getHTML(), nameLink.getHTML()); @@ -158,12 +158,12 @@ class ProductSortsView { const span = createBaseElement({ cssClasses: [styles.sortingListTitleSpan], - innerContent: TEXT[getCurrentLanguage()].SORT_BY, + innerContent: SORTING_TEXT[getCurrentLanguage()].SORT_BY, tag: 'span', }); observeStore(selectCurrentLanguage, () => { - span.innerText = TEXT[getCurrentLanguage()].SORT_BY; + span.innerText = SORTING_TEXT[getCurrentLanguage()].SORT_BY; }); this.sortingListTitle.addEventListener('click', () => { diff --git a/src/features/WishlistButton/view/WishlistButtonView.ts b/src/features/WishlistButton/view/WishlistButtonView.ts index d711321c..e9f6a04a 100644 --- a/src/features/WishlistButton/view/WishlistButtonView.ts +++ b/src/features/WishlistButton/view/WishlistButtonView.ts @@ -1,5 +1,5 @@ import ButtonModel from '@/shared/Button/model/ButtonModel.ts'; -import SVG_DETAILS from '@/shared/constants/svg.ts'; +import SVG_DETAIL from '@/shared/constants/svg.ts'; import createSVGUse from '@/shared/utils/createSVGUse.ts'; import styles from './wishlistButtonView.module.scss'; @@ -16,8 +16,8 @@ class WishlistButtonView { classes: [styles.switchToWishListButton], }); - const svg = document.createElementNS(SVG_DETAILS.SVG_URL, 'svg'); - svg.append(createSVGUse(SVG_DETAILS.HEART)); + const svg = document.createElementNS(SVG_DETAIL.SVG_URL, 'svg'); + svg.append(createSVGUse(SVG_DETAIL.HEART)); this.switchToWishListButton.getHTML().append(svg); return this.switchToWishListButton; diff --git a/src/pages/BlogPage/model/BlogPageModel.ts b/src/pages/BlogPage/model/BlogPageModel.ts index 967baf52..94e79474 100644 --- a/src/pages/BlogPage/model/BlogPageModel.ts +++ b/src/pages/BlogPage/model/BlogPageModel.ts @@ -1,4 +1,4 @@ -import type { Post } from '@/shared/constants/blog.ts'; +import type { Post } from '@/shared/types/blog.ts'; import type { Page } from '@/shared/types/page.ts'; import PostView from '@/entities/Post/view/PostView.ts'; diff --git a/src/pages/CartPage/model/CartPageModel.ts b/src/pages/CartPage/model/CartPageModel.ts index 29b57dac..4bfc757a 100644 --- a/src/pages/CartPage/model/CartPageModel.ts +++ b/src/pages/CartPage/model/CartPageModel.ts @@ -8,7 +8,7 @@ import LoaderModel from '@/shared/Loader/model/LoaderModel.ts'; import getStore from '@/shared/Store/Store.ts'; import { setCurrentPage } from '@/shared/Store/actions.ts'; import observeStore, { selectCurrentLanguage } from '@/shared/Store/observer.ts'; -import { SERVER_MESSAGE_KEYS } from '@/shared/constants/messages.ts'; +import { SERVER_MESSAGE_KEY } from '@/shared/constants/messages.ts'; import { PAGE_ID } from '@/shared/constants/pages.ts'; import { LOADER_SIZE } from '@/shared/constants/sizes.ts'; import { CartActive } from '@/shared/types/cart.ts'; @@ -101,7 +101,7 @@ class CartPageModel implements Page { private async checkBirthday(): Promise { if (!getStore().getState().isUserLoggedIn) { - throw showErrorMessage(SERVER_MESSAGE_KEYS.COUPON_NEED_LOGIN); + throw showErrorMessage(SERVER_MESSAGE_KEY.COUPON_NEED_LOGIN); } const customer = await getCustomerModel().getCurrentUser(); if (customer?.birthDate) { @@ -119,7 +119,7 @@ class CartPageModel implements Page { if (currentDate >= startBirthdayPeriod && currentDate <= endBirthdayPeriod) { return; } - throw showErrorMessage(SERVER_MESSAGE_KEYS.COUPON_WRONG_DATE); + throw showErrorMessage(SERVER_MESSAGE_KEY.COUPON_WRONG_DATE); } } } @@ -129,7 +129,7 @@ class CartPageModel implements Page { .clearCart() .then((cart) => { this.cart = cart; - showSuccessMessage(SERVER_MESSAGE_KEYS.SUCCESSFUL_CLEAR_CART); + showSuccessMessage(SERVER_MESSAGE_KEY.SUCCESSFUL_CLEAR_CART); this.productsItem = this.productsItem.filter((productItem) => { const searchEl = this.cart?.products.find((item) => item.lineItemId === productItem.getProduct().lineItemId); if (!searchEl) { diff --git a/src/pages/CartPage/view/CartPageView.ts b/src/pages/CartPage/view/CartPageView.ts index 21d8cb2f..f6975149 100644 --- a/src/pages/CartPage/view/CartPageView.ts +++ b/src/pages/CartPage/view/CartPageView.ts @@ -10,7 +10,7 @@ import ConfirmModel from '@/shared/Confirm/model/ConfirmModel.ts'; import InputModel from '@/shared/Input/model/InputModel.ts'; import LinkModel from '@/shared/Link/model/LinkModel.ts'; import modal from '@/shared/Modal/model/ModalModel.ts'; -import { USER_MESSAGE } from '@/shared/constants/confirmUserMessage.ts'; +import USER_MESSAGE from '@/shared/constants/confirmUserMessage.ts'; import { PAGE_ID } from '@/shared/constants/pages.ts'; import createBaseElement from '@/shared/utils/createBaseElement.ts'; import getCurrentLanguage from '@/shared/utils/getCurrentLanguage.ts'; diff --git a/src/pages/LoginPage/model/LoginPageModel.ts b/src/pages/LoginPage/model/LoginPageModel.ts index 96ef500f..1a235e41 100644 --- a/src/pages/LoginPage/model/LoginPageModel.ts +++ b/src/pages/LoginPage/model/LoginPageModel.ts @@ -4,7 +4,7 @@ import RouterModel from '@/app/Router/model/RouterModel.ts'; import getStore from '@/shared/Store/Store.ts'; import { setCurrentPage } from '@/shared/Store/actions.ts'; import observeStore, { selectIsUserLoggedIn } from '@/shared/Store/observer.ts'; -import { PAGE_LINK_TEXT, PAGE_LINK_TEXT_KEYS } from '@/shared/constants/links.ts'; +import { PAGE_LINK_TEXT, PAGE_LINK_TEXT_KEY } from '@/shared/constants/links.ts'; import { PAGE_ID } from '@/shared/constants/pages.ts'; import observeCurrentLanguage from '@/shared/utils/observeCurrentLanguage.ts'; import LoginFormModel from '@/widgets/LoginForm/model/LoginFormModel.ts'; @@ -53,7 +53,7 @@ class LoginPageModel implements Page { const registerLink = this.view.getRegisterLink().getHTML(); const registerLinkCopy = registerLink.cloneNode(true); - observeCurrentLanguage(registerLinkCopy, PAGE_LINK_TEXT, PAGE_LINK_TEXT_KEYS.REGISTRATION); + observeCurrentLanguage(registerLinkCopy, PAGE_LINK_TEXT, PAGE_LINK_TEXT_KEY.REGISTRATION); registerLink.addEventListener('click', (event) => this.registerLinkHandler(event)); registerLinkCopy.addEventListener('click', (event) => this.registerLinkHandler(event)); diff --git a/src/pages/LoginPage/view/LoginPageView.ts b/src/pages/LoginPage/view/LoginPageView.ts index a69d937a..0d02d74c 100644 --- a/src/pages/LoginPage/view/LoginPageView.ts +++ b/src/pages/LoginPage/view/LoginPageView.ts @@ -1,10 +1,10 @@ import LinkModel from '@/shared/Link/model/LinkModel.ts'; -import { PAGE_LINK_TEXT, PAGE_LINK_TEXT_KEYS } from '@/shared/constants/links.ts'; +import { PAGE_LINK_TEXT, PAGE_LINK_TEXT_KEY } from '@/shared/constants/links.ts'; import { PAGE_ANSWER, - PAGE_ANSWER_KEYS, + PAGE_ANSWER_KEY, PAGE_DESCRIPTION, - PAGE_DESCRIPTION_KEYS, + PAGE_DESCRIPTION_KEY, PAGE_ID, } from '@/shared/constants/pages.ts'; import createBaseElement from '@/shared/utils/createBaseElement.ts'; @@ -52,7 +52,7 @@ class LoginPageView { innerContent: PAGE_DESCRIPTION[getCurrentLanguage()].LOGIN, tag: 'h3', }); - observeCurrentLanguage(this.authDescription, PAGE_DESCRIPTION, PAGE_DESCRIPTION_KEYS.LOGIN); + observeCurrentLanguage(this.authDescription, PAGE_DESCRIPTION, PAGE_DESCRIPTION_KEY.LOGIN); return this.authDescription; } @@ -103,7 +103,7 @@ class LoginPageView { tag: 'span', }); - observeCurrentLanguage(this.loginSpan, PAGE_LINK_TEXT, PAGE_LINK_TEXT_KEYS.LOGIN); + observeCurrentLanguage(this.loginSpan, PAGE_LINK_TEXT, PAGE_LINK_TEXT_KEY.LOGIN); return this.loginSpan; } @@ -117,7 +117,7 @@ class LoginPageView { text: PAGE_LINK_TEXT[getCurrentLanguage()].REGISTRATION, }); - observeCurrentLanguage(this.registerLink.getHTML(), PAGE_LINK_TEXT, PAGE_LINK_TEXT_KEYS.REGISTRATION); + observeCurrentLanguage(this.registerLink.getHTML(), PAGE_LINK_TEXT, PAGE_LINK_TEXT_KEY.REGISTRATION); return this.registerLink; } @@ -129,7 +129,7 @@ class LoginPageView { tag: 'span', }); - observeCurrentLanguage(this.toRegisterPageWrapper, PAGE_ANSWER, PAGE_ANSWER_KEYS.LOGIN); + observeCurrentLanguage(this.toRegisterPageWrapper, PAGE_ANSWER, PAGE_ANSWER_KEY.LOGIN); return this.toRegisterPageWrapper; } diff --git a/src/pages/MainPage/model/MainPageModel.ts b/src/pages/MainPage/model/MainPageModel.ts index e4e48121..a5be9484 100644 --- a/src/pages/MainPage/model/MainPageModel.ts +++ b/src/pages/MainPage/model/MainPageModel.ts @@ -4,7 +4,7 @@ import PromoCodeSliderModel from '@/entities/PromocodeSlider/model/PromoCodeSlid import getStore from '@/shared/Store/Store.ts'; import { setCurrentPage } from '@/shared/Store/actions.ts'; import { PAGE_ID } from '@/shared/constants/pages.ts'; -import BlogWidgetModel from '@/widgets/Blog/model/BogWidgetModel.ts'; +import BlogWidgetModel from '@/widgets/Blog/model/BlogWidgetModel.ts'; import MainPageView from '../view/MainPageView.ts'; diff --git a/src/pages/NotFoundPage/view/NotFoundPageView.ts b/src/pages/NotFoundPage/view/NotFoundPageView.ts index 1b56f654..2bae8a2a 100644 --- a/src/pages/NotFoundPage/view/NotFoundPageView.ts +++ b/src/pages/NotFoundPage/view/NotFoundPageView.ts @@ -1,7 +1,7 @@ import ButtonModel from '@/shared/Button/model/ButtonModel.ts'; -import { BUTTON_TEXT, BUTTON_TEXT_KEYS } from '@/shared/constants/buttons.ts'; -import { PAGE_DESCRIPTION, PAGE_DESCRIPTION_KEYS } from '@/shared/constants/pages.ts'; -import SVG_DETAILS from '@/shared/constants/svg.ts'; +import { BUTTON_TEXT, BUTTON_TEXT_KEY } from '@/shared/constants/buttons.ts'; +import { PAGE_DESCRIPTION, PAGE_DESCRIPTION_KEY } from '@/shared/constants/pages.ts'; +import SVG_DETAIL from '@/shared/constants/svg.ts'; import createBaseElement from '@/shared/utils/createBaseElement.ts'; import createSVGUse from '@/shared/utils/createSVGUse.ts'; import getCurrentLanguage from '@/shared/utils/getCurrentLanguage.ts'; @@ -52,15 +52,15 @@ class NotFoundPageView { tag: 'p', }); - observeCurrentLanguage(this.description, PAGE_DESCRIPTION, PAGE_DESCRIPTION_KEYS[404]); + observeCurrentLanguage(this.description, PAGE_DESCRIPTION, PAGE_DESCRIPTION_KEY[404]); return this.description; } private createPageLogo(): HTMLDivElement { this.logo = createBaseElement({ cssClasses: [styles.pageLogo], tag: 'div' }); - const svg = document.createElementNS(SVG_DETAILS.SVG_URL, 'svg'); - svg.append(createSVGUse(SVG_DETAILS.NOT_FOUND)); + const svg = document.createElementNS(SVG_DETAIL.SVG_URL, 'svg'); + svg.append(createSVGUse(SVG_DETAIL.NOT_FOUND)); this.logo.append(svg); return this.logo; } @@ -68,7 +68,7 @@ class NotFoundPageView { private createPageTitle(): HTMLHeadingElement { this.title = createBaseElement({ cssClasses: [styles.pageTitle], - innerContent: PAGE_DESCRIPTION_KEYS[404], + innerContent: PAGE_DESCRIPTION_KEY[404], tag: 'h1', }); return this.title; @@ -79,7 +79,7 @@ class NotFoundPageView { classes: [styles.toMainButton], text: BUTTON_TEXT[getCurrentLanguage()].BACK_TO_MAIN, }); - observeCurrentLanguage(this.toMainButton.getHTML(), BUTTON_TEXT, BUTTON_TEXT_KEYS.BACK_TO_MAIN); + observeCurrentLanguage(this.toMainButton.getHTML(), BUTTON_TEXT, BUTTON_TEXT_KEY.BACK_TO_MAIN); return this.toMainButton; } diff --git a/src/pages/RegistrationPage/model/RegistrationPageModel.ts b/src/pages/RegistrationPage/model/RegistrationPageModel.ts index a9239305..01909812 100644 --- a/src/pages/RegistrationPage/model/RegistrationPageModel.ts +++ b/src/pages/RegistrationPage/model/RegistrationPageModel.ts @@ -4,7 +4,7 @@ import RouterModel from '@/app/Router/model/RouterModel.ts'; import getStore from '@/shared/Store/Store.ts'; import { setCurrentPage } from '@/shared/Store/actions.ts'; import observeStore, { selectIsUserLoggedIn } from '@/shared/Store/observer.ts'; -import { PAGE_LINK_TEXT, PAGE_LINK_TEXT_KEYS } from '@/shared/constants/links.ts'; +import { PAGE_LINK_TEXT, PAGE_LINK_TEXT_KEY } from '@/shared/constants/links.ts'; import { PAGE_ID } from '@/shared/constants/pages.ts'; import observeCurrentLanguage from '@/shared/utils/observeCurrentLanguage.ts'; import RegisterFormModel from '@/widgets/RegistrationForm/model/RegistrationFormModel.ts'; @@ -39,7 +39,7 @@ class RegistrationPageModel implements Page { const loginLink = this.view.getLoginLink().getHTML(); const loginLinkCopy = loginLink.cloneNode(true); - observeCurrentLanguage(loginLinkCopy, PAGE_LINK_TEXT, PAGE_LINK_TEXT_KEYS.LOGIN); + observeCurrentLanguage(loginLinkCopy, PAGE_LINK_TEXT, PAGE_LINK_TEXT_KEY.LOGIN); loginLink.addEventListener('click', (event) => this.loginLinkHandler(event)); loginLinkCopy.addEventListener('click', (event) => this.loginLinkHandler(event)); diff --git a/src/pages/RegistrationPage/view/RegistrationPageView.ts b/src/pages/RegistrationPage/view/RegistrationPageView.ts index 49cc07aa..ab1e2287 100644 --- a/src/pages/RegistrationPage/view/RegistrationPageView.ts +++ b/src/pages/RegistrationPage/view/RegistrationPageView.ts @@ -1,10 +1,10 @@ import LinkModel from '@/shared/Link/model/LinkModel.ts'; -import { PAGE_LINK_TEXT, PAGE_LINK_TEXT_KEYS } from '@/shared/constants/links.ts'; +import { PAGE_LINK_TEXT, PAGE_LINK_TEXT_KEY } from '@/shared/constants/links.ts'; import { PAGE_ANSWER, - PAGE_ANSWER_KEYS, + PAGE_ANSWER_KEY, PAGE_DESCRIPTION, - PAGE_DESCRIPTION_KEYS, + PAGE_DESCRIPTION_KEY, PAGE_ID, } from '@/shared/constants/pages.ts'; import createBaseElement from '@/shared/utils/createBaseElement.ts'; @@ -53,7 +53,7 @@ class RegistrationPageView { tag: 'h3', }); - observeCurrentLanguage(this.authDescription, PAGE_DESCRIPTION, PAGE_DESCRIPTION_KEYS.REGISTRATION); + observeCurrentLanguage(this.authDescription, PAGE_DESCRIPTION, PAGE_DESCRIPTION_KEY.REGISTRATION); return this.authDescription; } @@ -107,7 +107,7 @@ class RegistrationPageView { text: PAGE_LINK_TEXT[getCurrentLanguage()].LOGIN, }); - observeCurrentLanguage(this.loginLink.getHTML(), PAGE_LINK_TEXT, PAGE_LINK_TEXT_KEYS.LOGIN); + observeCurrentLanguage(this.loginLink.getHTML(), PAGE_LINK_TEXT, PAGE_LINK_TEXT_KEY.LOGIN); return this.loginLink; } @@ -119,7 +119,7 @@ class RegistrationPageView { tag: 'span', }); - observeCurrentLanguage(this.registerSpan, PAGE_LINK_TEXT, PAGE_LINK_TEXT_KEYS.REGISTRATION); + observeCurrentLanguage(this.registerSpan, PAGE_LINK_TEXT, PAGE_LINK_TEXT_KEY.REGISTRATION); return this.registerSpan; } @@ -131,7 +131,7 @@ class RegistrationPageView { tag: 'span', }); - observeCurrentLanguage(this.toLoginPageWrapper, PAGE_ANSWER, PAGE_ANSWER_KEYS.REGISTRATION); + observeCurrentLanguage(this.toLoginPageWrapper, PAGE_ANSWER, PAGE_ANSWER_KEY.REGISTRATION); return this.toLoginPageWrapper; } diff --git a/src/pages/UserAddressesPage/model/UserAddressesPageModel.ts b/src/pages/UserAddressesPage/model/UserAddressesPageModel.ts index 4e0be40d..cef7a57c 100644 --- a/src/pages/UserAddressesPage/model/UserAddressesPageModel.ts +++ b/src/pages/UserAddressesPage/model/UserAddressesPageModel.ts @@ -4,7 +4,7 @@ import RouterModel from '@/app/Router/model/RouterModel.ts'; import getCustomerModel from '@/shared/API/customer/model/CustomerModel.ts'; import getStore from '@/shared/Store/Store.ts'; import { setCurrentPage } from '@/shared/Store/actions.ts'; -import { SERVER_MESSAGE_KEYS } from '@/shared/constants/messages.ts'; +import { SERVER_MESSAGE_KEY } from '@/shared/constants/messages.ts'; import { PAGE_ID } from '@/shared/constants/pages.ts'; import createBaseElement from '@/shared/utils/createBaseElement.ts'; import { showErrorMessage } from '@/shared/utils/userMessage.ts'; @@ -21,7 +21,7 @@ class UserAddressesPageModel implements Page { const { isUserLoggedIn } = getStore().getState(); if (!isUserLoggedIn) { RouterModel.getInstance().navigateTo(PAGE_ID.LOGIN_PAGE); - showErrorMessage(SERVER_MESSAGE_KEYS.NEED_LOGIN); + showErrorMessage(SERVER_MESSAGE_KEY.NEED_LOGIN); } else { this.view = new UserAddressesPageView(parent); this.init().catch(showErrorMessage); @@ -37,7 +37,7 @@ class UserAddressesPageModel implements Page { getStore().dispatch(setCurrentPage(PAGE_ID.USER_ADDRESSES_PAGE)); } } catch (error) { - showErrorMessage(SERVER_MESSAGE_KEYS.NEED_LOGIN); + showErrorMessage(SERVER_MESSAGE_KEY.NEED_LOGIN); } } diff --git a/src/pages/UserProfilePage/model/UserProfilePageModel.ts b/src/pages/UserProfilePage/model/UserProfilePageModel.ts index 2e1dac6b..a6e09ee9 100644 --- a/src/pages/UserProfilePage/model/UserProfilePageModel.ts +++ b/src/pages/UserProfilePage/model/UserProfilePageModel.ts @@ -4,7 +4,7 @@ import RouterModel from '@/app/Router/model/RouterModel.ts'; import getCustomerModel from '@/shared/API/customer/model/CustomerModel.ts'; import getStore from '@/shared/Store/Store.ts'; import { setCurrentPage } from '@/shared/Store/actions.ts'; -import { SERVER_MESSAGE_KEYS } from '@/shared/constants/messages.ts'; +import { SERVER_MESSAGE_KEY } from '@/shared/constants/messages.ts'; import { PAGE_ID } from '@/shared/constants/pages.ts'; import createBaseElement from '@/shared/utils/createBaseElement.ts'; import { showErrorMessage } from '@/shared/utils/userMessage.ts'; @@ -21,7 +21,7 @@ class UserProfilePageModel implements Page { const { isUserLoggedIn } = getStore().getState(); if (!isUserLoggedIn) { RouterModel.getInstance().navigateTo(PAGE_ID.LOGIN_PAGE); - showErrorMessage(SERVER_MESSAGE_KEYS.NEED_LOGIN); + showErrorMessage(SERVER_MESSAGE_KEY.NEED_LOGIN); } else { this.view = new UserProfilePageView(parent); this.init().catch(showErrorMessage); @@ -37,7 +37,7 @@ class UserProfilePageModel implements Page { getStore().dispatch(setCurrentPage(PAGE_ID.USER_PROFILE_PAGE)); } } catch (error) { - showErrorMessage(SERVER_MESSAGE_KEYS.NEED_LOGIN); + showErrorMessage(SERVER_MESSAGE_KEY.NEED_LOGIN); } } diff --git a/src/shared/API/sdk/token-cache/token-cache.ts b/src/shared/API/sdk/token-cache/token-cache.ts index 2601a08e..e419c879 100644 --- a/src/shared/API/sdk/token-cache/token-cache.ts +++ b/src/shared/API/sdk/token-cache/token-cache.ts @@ -1,7 +1,7 @@ import type { TokenCache, TokenStore } from '@commercetools/sdk-client-v2'; import getStore from '@/shared/Store/Store.ts'; -import { setAnonymToken, setAuthToken } from '@/shared/Store/actions.ts'; +import { setAuthToken, setanonymousToken } from '@/shared/Store/actions.ts'; import type { TokenTypeType } from '../../types/type.ts'; @@ -19,8 +19,8 @@ export class MyTokenCache implements TokenCache { constructor(name: string) { this.name = name; const soreData = getStore().getState(); - if (this.name === TokenType.ANONYM && soreData.anonymToken) { - this.myCache = soreData.anonymToken; + if (this.name === TokenType.ANONYM && soreData.anonymousToken) { + this.myCache = soreData.anonymousToken; } else if (this.name === TokenType.AUTH && soreData.authToken) { this.myCache = soreData.authToken; } @@ -29,7 +29,7 @@ export class MyTokenCache implements TokenCache { private saveToken(): void { if (this.myCache.token) { if (this.name === TokenType.ANONYM) { - getStore().dispatch(setAnonymToken(this.myCache)); + getStore().dispatch(setanonymousToken(this.myCache)); } else if (this.name === TokenType.AUTH) { getStore().dispatch(setAuthToken(this.myCache)); } @@ -43,7 +43,7 @@ export class MyTokenCache implements TokenCache { token: '', }; if (this.name === TokenType.ANONYM) { - getStore().dispatch(setAnonymToken(null)); + getStore().dispatch(setanonymousToken(null)); } else if (this.name === TokenType.AUTH) { getStore().dispatch(setAuthToken(null)); } @@ -65,9 +65,9 @@ export class MyTokenCache implements TokenCache { const createTokenCache = (name: string): MyTokenCache => new MyTokenCache(name); -const anonymTokenCache = createTokenCache(TokenType.ANONYM); +const anonymousTokenCache = createTokenCache(TokenType.ANONYM); const authTokenCache = createTokenCache(TokenType.AUTH); export default function getTokenCache(tokenType?: TokenTypeType): MyTokenCache { - return tokenType === TokenType.AUTH ? authTokenCache : anonymTokenCache; + return tokenType === TokenType.AUTH ? authTokenCache : anonymousTokenCache; } diff --git a/src/shared/Confirm/view/ConfirmView.ts b/src/shared/Confirm/view/ConfirmView.ts index 80ae2382..eb848e01 100644 --- a/src/shared/Confirm/view/ConfirmView.ts +++ b/src/shared/Confirm/view/ConfirmView.ts @@ -1,5 +1,5 @@ import ButtonModel from '@/shared/Button/model/ButtonModel.ts'; -import { BUTTON_TEXT, BUTTON_TEXT_KEYS } from '@/shared/constants/buttons.ts'; +import { BUTTON_TEXT, BUTTON_TEXT_KEY } from '@/shared/constants/buttons.ts'; import createBaseElement from '@/shared/utils/createBaseElement.ts'; import getCurrentLanguage from '@/shared/utils/getCurrentLanguage.ts'; import observeCurrentLanguage from '@/shared/utils/observeCurrentLanguage.ts'; @@ -28,7 +28,7 @@ class ConfirmView { text: BUTTON_TEXT[getCurrentLanguage()].CANCEL, }); - observeCurrentLanguage(this.cancelButton.getHTML(), BUTTON_TEXT, BUTTON_TEXT_KEYS.CANCEL); + observeCurrentLanguage(this.cancelButton.getHTML(), BUTTON_TEXT, BUTTON_TEXT_KEY.CANCEL); return this.cancelButton; } @@ -39,7 +39,7 @@ class ConfirmView { text: BUTTON_TEXT[getCurrentLanguage()].CONFIRM, }); - observeCurrentLanguage(this.confirmButton.getHTML(), BUTTON_TEXT, BUTTON_TEXT_KEYS.CONFIRM); + observeCurrentLanguage(this.confirmButton.getHTML(), BUTTON_TEXT, BUTTON_TEXT_KEY.CONFIRM); return this.confirmButton; } diff --git a/src/shared/Posts/posts.ts b/src/shared/Posts/posts.ts index 32a8e289..44689dde 100644 --- a/src/shared/Posts/posts.ts +++ b/src/shared/Posts/posts.ts @@ -1,4 +1,4 @@ -import type { Post } from '@/shared/constants/blog'; +import type { Post } from '../types/blog'; const postsData: Post[] = [ { diff --git a/src/shared/ScrollToTop/view/ScrollToTopView.ts b/src/shared/ScrollToTop/view/ScrollToTopView.ts index 0c1c45df..5d04eb99 100644 --- a/src/shared/ScrollToTop/view/ScrollToTopView.ts +++ b/src/shared/ScrollToTop/view/ScrollToTopView.ts @@ -1,7 +1,7 @@ import ButtonModel from '@/shared/Button/model/ButtonModel.ts'; import observeStore, { selectCurrentLanguage } from '@/shared/Store/observer.ts'; import { SCROLL_TO_TOP_THRESHOLD } from '@/shared/constants/common.ts'; -import SVG_DETAILS from '@/shared/constants/svg.ts'; +import SVG_DETAIL from '@/shared/constants/svg.ts'; import TOOLTIP_TEXT from '@/shared/constants/tooltip.ts'; import createSVGUse from '@/shared/utils/createSVGUse.ts'; import getCurrentLanguage from '@/shared/utils/getCurrentLanguage.ts'; @@ -21,8 +21,8 @@ class ScrollToTopView { title: TOOLTIP_TEXT[getCurrentLanguage()].SCROLL_TO_TOP, }); - const svg = document.createElementNS(SVG_DETAILS.SVG_URL, 'svg'); - svg.append(createSVGUse(SVG_DETAILS.ARROW_UP)); + const svg = document.createElementNS(SVG_DETAIL.SVG_URL, 'svg'); + svg.append(createSVGUse(SVG_DETAIL.ARROW_UP)); this.button.getHTML().append(svg); observeStore(selectCurrentLanguage, () => { diff --git a/src/shared/ServerMessage/view/ServerMessageView.ts b/src/shared/ServerMessage/view/ServerMessageView.ts index c750c296..c09b23df 100644 --- a/src/shared/ServerMessage/view/ServerMessageView.ts +++ b/src/shared/ServerMessage/view/ServerMessageView.ts @@ -1,4 +1,4 @@ -import type { MessageStatusType, ServerMessageKeysType } from '@/shared/constants/messages.ts'; +import type { MessageStatusType, ServerMessageKeyType } from '@/shared/constants/messages.ts'; import SERVER_MESSAGE_ANIMATE_DETAILS, { SERVER_MESSAGE_PROGRESS_BAR_ANIMATE_DETAILS_END, @@ -78,7 +78,7 @@ class ServerMessageView { return this.serverWrapper; } - public setServerMessage(status: MessageStatusType, keyOrMessage?: ServerMessageKeysType, message?: string): boolean { + public setServerMessage(status: MessageStatusType, keyOrMessage?: ServerMessageKeyType, message?: string): boolean { const currentLanguage = getCurrentLanguage(); this.serverWrapper.classList.toggle(styles.error, status === MESSAGE_STATUS.ERROR); diff --git a/src/shared/ServerMessage/view/serverMessageView.module.scss b/src/shared/ServerMessage/view/serverMessageView.module.scss index 2e6d2669..acad31b8 100644 --- a/src/shared/ServerMessage/view/serverMessageView.module.scss +++ b/src/shared/ServerMessage/view/serverMessageView.module.scss @@ -1,6 +1,6 @@ .serverMessageWrapper { position: fixed; - right: 0; + left: 0; top: 20%; z-index: 15; border: var(--two) solid var(--steam-green-800); @@ -13,7 +13,7 @@ word-break: break-word; text-align: center; background-color: var(--white); - transform: translate(110%, -80%); + transform: translateX(-110%); } .progressBar { diff --git a/src/shared/Store/actions.ts b/src/shared/Store/actions.ts index 7407d431..2d392e32 100644 --- a/src/shared/Store/actions.ts +++ b/src/shared/Store/actions.ts @@ -4,7 +4,7 @@ import type { LanguageChoiceType } from '../constants/common.ts'; import type { PageIdType } from '../constants/pages.ts'; const ACTION = { - SET_ANONYM_TOKEN: 'setAnonymToken', + SET_ANONYM_TOKEN: 'setanonymousToken', SET_ANONYMOUS_CART_ID: 'setAnonymousCartId', SET_ANONYMOUS_ID: 'setAnonymousId', SET_ANONYMOUS_SHOP_LIST_ID: 'setAnonymousShopListId', @@ -36,7 +36,7 @@ export const setAnonymousShopListId = ( type: ACTION.SET_ANONYMOUS_SHOP_LIST_ID, }); -export const setAnonymToken = ( +export const setanonymousToken = ( value: TokenStore | null, ): ActionWithPayload => ({ payload: value, diff --git a/src/shared/Store/reducer.ts b/src/shared/Store/reducer.ts index 6fa55541..eece617b 100644 --- a/src/shared/Store/reducer.ts +++ b/src/shared/Store/reducer.ts @@ -7,10 +7,10 @@ import type * as actions from './actions.ts'; import type { Reducer } from './types.ts'; export interface State { - anonymToken: TokenStore | null; anonymousCartId: null | string; anonymousId: null | string; anonymousShopListId: null | string; + anonymousToken: TokenStore | null; authToken: TokenStore | null; billingCountry: string; currentLanguage: LanguageChoiceType; @@ -26,10 +26,10 @@ type InferValueTypes = T extends { [key: string]: infer U } ? U : never; export type Action = ReturnType>; export const rootReducer: Reducer = (state: State, action: Action): State => { switch (action.type) { - case 'setAnonymToken': + case 'setanonymousToken': return { ...state, - anonymToken: action.payload, + anonymousToken: action.payload, }; case 'setAuthToken': return { diff --git a/src/shared/Store/test.spec.ts b/src/shared/Store/test.spec.ts index b174d754..0945a75e 100644 --- a/src/shared/Store/test.spec.ts +++ b/src/shared/Store/test.spec.ts @@ -54,10 +54,10 @@ vi.mock('./Store.ts', async (importOriginal) => { return { ...actual, getState: (): State => ({ - anonymToken: null, anonymousCartId: null, anonymousId: null, anonymousShopListId: null, + anonymousToken: null, authToken: null, billingCountry: '', currentLanguage: 'en', @@ -171,10 +171,10 @@ describe('rootReducer', () => { beforeEach(() => { initialState = { - anonymToken: null, anonymousCartId: null, anonymousId: null, anonymousShopListId: null, + anonymousToken: null, authToken: null, billingCountry: '', currentLanguage: 'en', diff --git a/src/shared/constants/animations.ts b/src/shared/constants/animations.ts index 704fcd0c..03c18477 100644 --- a/src/shared/constants/animations.ts +++ b/src/shared/constants/animations.ts @@ -1,9 +1,9 @@ const SERVER_MESSAGE_ANIMATE_PARAMS = [ - { transform: 'translateX(110%)' }, - { transform: 'translateX(-10%)' }, - { transform: 'translateX(-10%)' }, - { opacity: 1, transform: 'translateX(-10%)' }, - { opacity: 0, transform: 'translate(-10%, -110%)' }, + { transform: 'translateX(-120%)' }, + { transform: 'translateX(10%)' }, + { transform: 'translateX(10%)' }, + { opacity: 1, transform: 'translateX(10%)' }, + { opacity: 0, transform: 'translate(10%, -100%)' }, ]; const SERVER_MESSAGE_ANIMATE_DETAILS = { diff --git a/src/shared/constants/buttons.ts b/src/shared/constants/buttons.ts index f17587d8..53fc77da 100644 --- a/src/shared/constants/buttons.ts +++ b/src/shared/constants/buttons.ts @@ -1,6 +1,4 @@ export const BUTTON_TYPE = { - BUTTON: 'button', - RESET: 'reset', SUBMIT: 'submit', } as const; @@ -35,7 +33,7 @@ export const BUTTON_TEXT = { }, } as const; -export const BUTTON_TEXT_KEYS = { +export const BUTTON_TEXT_KEY = { ADD_ADDRESS: 'ADD_ADDRESS', ADD_PRODUCT: 'ADD_PRODUCT', BACK_TO_MAIN: 'BACK_TO_MAIN', @@ -50,8 +48,6 @@ export const BUTTON_TEXT_KEYS = { SAVE_CHANGES: 'SAVE_CHANGES', } as const; -export type ButtonTextKeysType = (typeof BUTTON_TEXT_KEYS)[keyof typeof BUTTON_TEXT_KEYS]; - export const IS_DISABLED = { DISABLED: true, ENABLED: false, @@ -60,11 +56,9 @@ export const IS_DISABLED = { export const MORE_TEXT = { en: { HIDE: 'Hide', MORE: 'More' }, ru: { HIDE: 'Скрыть', MORE: 'Подробнее' }, -}; +} as const; -export const MORE_TEXT_KEYS = { +export const MORE_TEXT_KEY = { HIDE: 'HIDE', MORE: 'MORE', -}; - -export type MoreTextKeysType = (typeof MORE_TEXT_KEYS)[keyof typeof MORE_TEXT_KEYS]; +} as const; diff --git a/src/shared/constants/common.ts b/src/shared/constants/common.ts index f3e7f2a6..1fe8cd13 100644 --- a/src/shared/constants/common.ts +++ b/src/shared/constants/common.ts @@ -8,13 +8,13 @@ export const LANGUAGE_CHOICE = { RU: 'ru', } as const; -export const DATA_KEYS = { - ADDRESS_TYPE: 'data-addressType', +export type LanguageChoiceType = (typeof LANGUAGE_CHOICE)[keyof typeof LANGUAGE_CHOICE]; + +export const DATA_KEY = { + ADDRESS: 'data-addressType', DIRECTION: 'data-direction', } as const; export const TABLET_WIDTH = 768; export const SCROLL_TO_TOP_THRESHOLD = 200; - -export type LanguageChoiceType = (typeof LANGUAGE_CHOICE)[keyof typeof LANGUAGE_CHOICE]; diff --git a/src/shared/constants/confirmUserMessage.ts b/src/shared/constants/confirmUserMessage.ts index 75b40b4f..8b87d47b 100644 --- a/src/shared/constants/confirmUserMessage.ts +++ b/src/shared/constants/confirmUserMessage.ts @@ -1,4 +1,4 @@ -export const USER_MESSAGE = { +const USER_MESSAGE = { en: { CLEAR_CART: 'Are you sure you want to clear the cart?', CONFIRM: 'Are you sure you want to proceed?', @@ -11,9 +11,4 @@ export const USER_MESSAGE = { }, } as const; -export const USER_MESSAGE_KEYS = { - CONFIRM: 'CONFIRM', - DELETE_ADDRESS: 'DELETE_ADDRESS', -}; - -export type UserMessageKeysType = (typeof USER_MESSAGE_KEYS)[keyof typeof USER_MESSAGE_KEYS]; +export default USER_MESSAGE; diff --git a/src/shared/constants/filters.ts b/src/shared/constants/filters.ts index 202b697d..d5e23023 100644 --- a/src/shared/constants/filters.ts +++ b/src/shared/constants/filters.ts @@ -22,7 +22,7 @@ export const PRICE_RANGE_LABEL = { }, } as const; -export const META_FILTERS = { +export const META_FILTER = { en: { ALL_PRODUCTS: 'all', NEW_ARRIVALS: 'new', @@ -35,15 +35,15 @@ export const META_FILTERS = { }, } as const; -export const META_FILTERS_KEY = { +const META_FILTER_KEY = { ALL_PRODUCTS: 'ALL_PRODUCTS', NEW_ARRIVALS: 'NEW_ARRIVALS', SALE: 'SALE', }; -export type MetaFiltersType = (typeof META_FILTERS_KEY)[keyof typeof META_FILTERS_KEY]; +export type MetaFilterKeyType = (typeof META_FILTER_KEY)[keyof typeof META_FILTER_KEY]; -export const META_FILTERS_ID = { +export const META_FILTER_ID = { ALL_PRODUCTS: 'all-products', NEW_ARRIVALS: 'new-arrivals', SALE: 'sale', diff --git a/src/shared/constants/forms.ts b/src/shared/constants/forms.ts index 744b16f5..27b9d959 100644 --- a/src/shared/constants/forms.ts +++ b/src/shared/constants/forms.ts @@ -23,7 +23,7 @@ export const FORM_TEXT = { }, } as const; -export const FORM_TEXT_KEYS = { +export const FORM_TEXT_KEY = { DEFAULT_BILLING_ADDRESS: 'DEFAULT_BILLING_ADDRESS', DEFAULT_SHIPPING_ADDRESS: 'DEFAULT_SHIPPING_ADDRESS', SINGLE_ADDRESS: 'SINGLE_ADDRESS', @@ -33,45 +33,19 @@ export const DEFAULT_ADDRESS = { setDefault: true, }; -export type FormTextKeysType = (typeof FORM_TEXT_KEYS)[keyof typeof FORM_TEXT_KEYS]; - -export const USER_COUNTRY_ADDRESS = { +export const USER_ADDRESS = { BILLING: 'billing', SHIPPING: 'shipping', } as const; -export const USER_ADDRESS_TYPE = { - BILLING: 'billing', - SHIPPING: 'shipping', -} as const; - -export type UserAddressType = (typeof USER_ADDRESS_TYPE)[keyof typeof USER_ADDRESS_TYPE]; - -export const ADDRESS_TYPE = { +export const ADDRESS = { BILLING: 'billing', DEFAULT_BILLING: 'default billing', DEFAULT_SHIPPING: 'default shipping', SHIPPING: 'shipping', } as const; -export type AddressTypeType = (typeof ADDRESS_TYPE)[keyof typeof ADDRESS_TYPE]; - -export const LABEL_TYPE = { - en: { - BILLING: 'billing', - DEFAULT_BILLING: 'default billing', - DEFAULT_SHIPPING: 'default shipping', - SHIPPING: 'shipping', - }, - ru: { - BILLING: 'Выставление счетов', - DEFAULT_BILLING: 'По умолчанию для выставления счетов', - DEFAULT_SHIPPING: 'По умолчанию для доставки', - SHIPPING: 'Доставка', - }, -} as const; - -export type LabelTypeType = (typeof LABEL_TYPE)[keyof typeof LABEL_TYPE]; +export type AddressType = (typeof ADDRESS)[keyof typeof ADDRESS]; export const USER_POSTAL_CODE = { BILLING_POSTAL_CODE: 'billing_PostalCode', diff --git a/src/shared/constants/forms/fieldParams.ts b/src/shared/constants/forms/fieldParams.ts index b06396e2..e6b9f23c 100644 --- a/src/shared/constants/forms/fieldParams.ts +++ b/src/shared/constants/forms/fieldParams.ts @@ -1,4 +1,4 @@ -import { USER_ADDRESS_TYPE } from '../forms.ts'; +import { USER_ADDRESS } from '../forms.ts'; export const EMAIL = { inputParams: { @@ -145,7 +145,7 @@ export const SHIPPING_ADDRESS_COUNTRY = { inputParams: { autocomplete: 'off', data: { - addressType: USER_ADDRESS_TYPE.SHIPPING, + addressType: USER_ADDRESS.SHIPPING, }, placeholder: 'Canada', type: 'text', @@ -162,7 +162,7 @@ export const SHIPPING_ADDRESS_POSTAL_CODE = { inputParams: { autocomplete: 'off', data: { - addressType: USER_ADDRESS_TYPE.SHIPPING, + addressType: USER_ADDRESS.SHIPPING, }, placeholder: 'A1B 2C3', type: 'text', @@ -207,7 +207,7 @@ export const BILLING_ADDRESS_COUNTRY = { inputParams: { autocomplete: 'off', data: { - addressType: USER_ADDRESS_TYPE.BILLING, + addressType: USER_ADDRESS.BILLING, }, placeholder: 'Canada', type: 'text', @@ -224,7 +224,7 @@ export const BILLING_ADDRESS_POSTAL_CODE = { inputParams: { autocomplete: 'off', data: { - addressType: USER_ADDRESS_TYPE.BILLING, + addressType: USER_ADDRESS.BILLING, }, placeholder: 'A1B 2C3', type: 'text', @@ -237,23 +237,6 @@ export const BILLING_ADDRESS_POSTAL_CODE = { }, } as const; -export const INPUT = [ - EMAIL, - EMAIL_NOT_LABEL_TEXT, - PASSWORD, - FIRST_NAME, - LAST_NAME, - BIRTHDAY, - SHIPPING_ADDRESS_STREET, - SHIPPING_ADDRESS_CITY, - SHIPPING_ADDRESS_COUNTRY, - SHIPPING_ADDRESS_POSTAL_CODE, - BILLING_ADDRESS_STREET, - BILLING_ADDRESS_CITY, - BILLING_ADDRESS_COUNTRY, - BILLING_ADDRESS_POSTAL_CODE, -]; - export const CHECKBOX = { AUTOCOMPLETE: 'off', BILLING_ID: 'billingDefault', diff --git a/src/shared/constants/forms/validationParams.ts b/src/shared/constants/forms/validationParams.ts index 6055295d..03e8817f 100644 --- a/src/shared/constants/forms/validationParams.ts +++ b/src/shared/constants/forms/validationParams.ts @@ -108,15 +108,3 @@ export const ADDRESS_POSTAL_CODE_VALIDATE = { required: true, validPostalCode: true, }; - -export const INPUT_VALIDATION = [ - EMAIL_VALIDATE, - PASSWORD_VALIDATE, - FIRST_NAME_VALIDATE, - LAST_NAME_VALIDATE, - BIRTHDAY_VALIDATE, - ADDRESS_STREET_VALIDATE, - ADDRESS_CITY_VALIDATE, - ADDRESS_COUNTRY_VALIDATE, - ADDRESS_POSTAL_CODE_VALIDATE, -]; diff --git a/src/shared/constants/initialState.ts b/src/shared/constants/initialState.ts index 889c3655..6c047033 100644 --- a/src/shared/constants/initialState.ts +++ b/src/shared/constants/initialState.ts @@ -1,15 +1,16 @@ import type { State } from '../Store/reducer'; +import { LANGUAGE_CHOICE } from './common.ts'; import { PAGE_ID } from './pages.ts'; const initialState: State = { - anonymToken: null, anonymousCartId: null, anonymousId: null, anonymousShopListId: null, + anonymousToken: null, authToken: null, billingCountry: '', - currentLanguage: 'en', + currentLanguage: LANGUAGE_CHOICE.EN, currentPage: PAGE_ID.DEFAULT_PAGE, defaultCountry: '', isAppThemeLight: true, diff --git a/src/shared/constants/keyboard.ts b/src/shared/constants/keyboard.ts index 5af32cb0..c87fc14a 100644 --- a/src/shared/constants/keyboard.ts +++ b/src/shared/constants/keyboard.ts @@ -1,7 +1,7 @@ -export const KEYBOARD_KEYS = { +const KEYBOARD_KEY = { ENTER: 'Enter', ESC: 'Escape', TAB: 'Tab', } as const; -export type KeyboardKeysType = (typeof KEYBOARD_KEYS)[keyof typeof KEYBOARD_KEYS]; +export default KEYBOARD_KEY; diff --git a/src/shared/constants/links.ts b/src/shared/constants/links.ts index 86a3744b..6173f1c2 100644 --- a/src/shared/constants/links.ts +++ b/src/shared/constants/links.ts @@ -1,13 +1,4 @@ -/* eslint-disable import/prefer-default-export */ -export const USER_PROFILE_MENU_LINK = { - ADDRESSES: '#addresses', - ORDERS: '#orders', - PERSONAL_INFO: '#personal-info', - SUPPORT: '#support', - WISHLIST: '#wishlist', -} as const; - -export const LINK_DETAILS = { +export const LINK_DETAIL = { BLANK: '_blank', } as const; @@ -30,7 +21,7 @@ export const PAGE_LINK_TEXT = { }, } as const; -export const PAGE_LINK_TEXT_KEYS = { +export const PAGE_LINK_TEXT_KEY = { ABOUT: 'ABOUT', BLOG: 'BLOG', CATALOG: 'CATALOG', diff --git a/src/shared/constants/messages.ts b/src/shared/constants/messages.ts index e7356a9d..d709a25f 100644 --- a/src/shared/constants/messages.ts +++ b/src/shared/constants/messages.ts @@ -7,13 +7,6 @@ export const MESSAGE_STATUS = { export type MessageStatusType = (typeof MESSAGE_STATUS)[keyof typeof MESSAGE_STATUS]; -export const MESSAGE_STATUS_KEYS = { - ERROR: 'ERROR', - SUCCESS: 'SUCCESS', -} as const; - -export type MessageStatusKeysType = (typeof MESSAGE_STATUS_KEYS)[keyof typeof MESSAGE_STATUS_KEYS]; - export const SERVER_MESSAGE: Record> = { en: { ADDRESS_ADDED: 'Address has been added successfully', @@ -77,7 +70,7 @@ export const SERVER_MESSAGE: Record> }, } as const; -export const SERVER_MESSAGE_KEYS: Record = { +export const SERVER_MESSAGE_KEY: Record = { ADDRESS_ADDED: 'ADDRESS_ADDED', ADDRESS_CHANGED: 'ADDRESS_CHANGED', ADDRESS_DELETED: 'ADDRESS_DELETED', @@ -108,7 +101,7 @@ export const SERVER_MESSAGE_KEYS: Record = { USER_EXISTS: 'USER_EXISTS', } as const; -export type ServerMessageKeysType = (typeof SERVER_MESSAGE_KEYS)[keyof typeof SERVER_MESSAGE_KEYS]; +export type ServerMessageKeyType = (typeof SERVER_MESSAGE_KEY)[keyof typeof SERVER_MESSAGE_KEY]; export const ERROR_MESSAGE = { en: { @@ -124,10 +117,3 @@ export const ERROR_MESSAGE = { WRONG_REGION: 'Извините, но мы еще не доставляем в ваш регион', }, } as const; - -export const ERROR_MESSAGE_KEYS = { - INVALID_COUNTRY: 'INVALID_COUNTRY', - INVALID_POSTAL_CODE: 'INVALID_POSTAL_CODE', - REQUIRED_FIELD: 'REQUIRED_FIELD', - WRONG_REGION: 'WRONG_REGION', -} as const; diff --git a/src/shared/constants/pages.ts b/src/shared/constants/pages.ts index 6ad1d8a3..6c14fb96 100644 --- a/src/shared/constants/pages.ts +++ b/src/shared/constants/pages.ts @@ -4,7 +4,7 @@ export const PAGE_TITLE: Record> = { en: { 404: '404', about: 'About us', - address: 'Address', + addresses: 'Addresses', blog: 'Blog', cart: 'Cart', catalog: 'Catalog', @@ -19,7 +19,7 @@ export const PAGE_TITLE: Record> = { ru: { 404: '404', about: 'О нас', - address: 'Адрес', + addresses: 'Адреса', blog: 'Блог', cart: 'Корзина', catalog: 'Каталог', @@ -38,7 +38,6 @@ export const PAGE_DESCRIPTION = { 404: 'This is not the page you are looking for. Please go back to the main page.', ABOUT: 'Mad Wizards Team 🧙🏻🪄✨', BLOG: 'Blog', - GREETING: 'Hi, ', LOGIN: 'Enter your email and password to login.', REGISTRATION: 'Enter your information to register.', }, @@ -46,7 +45,6 @@ export const PAGE_DESCRIPTION = { 404: 'Это не та страница, которую вы ищете. Пожалуйста, вернитесь на главную страницу.', ABOUT: 'Команда Бешеных Магов 🧙🏻🪄✨', BLOG: 'Блог', - GREETING: 'Привет, ', LOGIN: 'Введите свой адрес электронной почты и пароль для входа.', REGISTRATION: 'Введите свои данные для регистрации.', }, @@ -69,7 +67,7 @@ export const BLOG_DESCRIPTION = { }, } as const; -export const PAGE_DESCRIPTION_KEYS = { +export const PAGE_DESCRIPTION_KEY = { 404: '404', BLOG: 'BLOG', GREETING: 'GREETING', @@ -77,27 +75,24 @@ export const PAGE_DESCRIPTION_KEYS = { REGISTRATION: 'REGISTRATION', } as const; -export type PageDescriptionKeysType = (typeof PAGE_DESCRIPTION_KEYS)[keyof typeof PAGE_DESCRIPTION_KEYS]; - export const PAGE_ANSWER = { en: { - LOGIN: `Don't have an account yet?`, - REGISTRATION: `Already have an account?`, + LOGIN: "Don't have an account yet?", + REGISTRATION: 'Already have an account?', }, ru: { - LOGIN: `Ещё нет аккаунта?`, - REGISTRATION: `Уже есть аккаунт?`, + LOGIN: 'Ещё нет аккаунта?', + REGISTRATION: 'Уже есть аккаунт?', }, } as const; -export const PAGE_ANSWER_KEYS = { +export const PAGE_ANSWER_KEY = { LOGIN: 'LOGIN', REGISTRATION: 'REGISTRATION', } as const; export const PAGE_ID = { ABOUT_US_PAGE: 'about', - ADDRESS: 'address', BLOG: 'blog', CART_PAGE: 'cart', CATALOG_PAGE: 'catalog', @@ -113,67 +108,19 @@ export const PAGE_ID = { WISHLIST_PAGE: 'wishlist', } as const; +export type PageIdType = (typeof PAGE_ID)[keyof typeof PAGE_ID]; + export const USER_INFO_TEXT = { en: { - BILLING: ' (billing)', DATE_OF_BIRTH: 'Date of Birth: ', - DEFAULT_BILLING_ADDRESS: ' (default billing)', - DEFAULT_SHIPPING_ADDRESS: ' (default shipping)', EMAIL: 'Email: ', LAST_NAME: 'Last Name: ', NAME: 'First Name: ', - SHIPPING: ' (shipping)', }, ru: { - BILLING: ' (оплата)', DATE_OF_BIRTH: 'Дата рождения: ', - DEFAULT_BILLING_ADDRESS: ' (по умолчанию - для оплаты)', - DEFAULT_SHIPPING_ADDRESS: ' (по умолчанию - для доставки)', EMAIL: 'Электронная почта: ', LAST_NAME: 'Фамилия: ', NAME: 'Имя: ', - SHIPPING: ' (доставка)', }, } as const; - -export const USER_INFO_TEXT_KEYS = { - BILLING: 'BILLING', - DATE_OF_BIRTH: 'DATE_OF_BIRTH', - DEFAULT_BILLING_ADDRESS: 'DEFAULT_BILLING_ADDRESS', - DEFAULT_SHIPPING_ADDRESS: 'DEFAULT_SHIPPING_ADDRESS', - EMAIL: 'EMAIL', - LAST_NAME: 'LAST_NAME', - NAME: 'NAME', - SHIPPING: 'SHIPPING', -} as const; - -export type UserInfoTextKeysType = (typeof USER_INFO_TEXT_KEYS)[keyof typeof USER_INFO_TEXT_KEYS]; - -export const USER_INFO_MENU_LINK = { - en: { - ADDRESSES: 'Addresses', - ORDERS: 'Orders', - PERSONAL_INFO: 'Personal Info', - SUPPORT: 'Support', - WISHLIST: 'Wishlist', - }, - ru: { - ADDRESSES: 'Адреса', - ORDERS: 'Заказы', - PERSONAL_INFO: 'Персональные данные', - SUPPORT: 'Поддержка', - WISHLIST: 'Избранное', - }, -} as const; - -export const USER_INFO_MENU_LINK_KEYS = { - ADDRESSES: 'ADDRESSES', - ORDERS: 'ORDERS', - PERSONAL_INFO: 'PERSONAL_INFO', - SUPPORT: 'SUPPORT', - WISHLIST: 'WISHLIST', -} as const; - -export type UserInfoMenuLinkKeysType = (typeof USER_INFO_MENU_LINK_KEYS)[keyof typeof USER_INFO_MENU_LINK_KEYS]; - -export type PageIdType = (typeof PAGE_ID)[keyof typeof PAGE_ID]; diff --git a/src/shared/constants/product.ts b/src/shared/constants/product.ts index 2423899b..26d1e9d6 100644 --- a/src/shared/constants/product.ts +++ b/src/shared/constants/product.ts @@ -47,7 +47,7 @@ export const PRODUCT_INFO_TEXT = { }, } as const; -export const PRODUCT_INFO_TEXT_KEYS = { +export const PRODUCT_INFO_TEXT_KEY = { CATEGORY: 'CATEGORY', DIFFICULTY: 'DIFFICULTY', DISCOUNT_LABEL: 'DISCOUNT_LABEL', @@ -55,10 +55,3 @@ export const PRODUCT_INFO_TEXT_KEYS = { SHORT_DESCRIPTION: 'SHORT_DESCRIPTION', SIZE: 'SIZE', } as const; - -export const PRODUCT_LIST = { - CART: 'cart', - SHOPPING_LIST: 'shoppingList', -} as const; - -export type ProductListType = (typeof PRODUCT_LIST)[keyof typeof PRODUCT_LIST]; diff --git a/src/shared/constants/sorting.ts b/src/shared/constants/sorting.ts index db0ca4e0..73c57e5b 100644 --- a/src/shared/constants/sorting.ts +++ b/src/shared/constants/sorting.ts @@ -1,4 +1,4 @@ -export const TEXT: Record> = { +export const SORTING_TEXT: Record> = { en: { DEFAULT: 'Default', NAME: 'Name', @@ -15,7 +15,7 @@ export const TEXT: Record> = { }, } as const; -export const TEXT_KEYS: Record = { +export const SORTING_TEXT_KEY: Record = { DEFAULT: 'DEFAULT', NAME: 'NAME', PRICE: 'PRICE', @@ -23,8 +23,6 @@ export const TEXT_KEYS: Record = { SORT_BY: 'SORT_BY', } as const; -export type TextKeysType = (typeof TEXT_KEYS)[keyof typeof TEXT_KEYS]; - export const SORTING_ID = { DEFAULT: 'default', NAME: 'name', diff --git a/src/shared/constants/svg.ts b/src/shared/constants/svg.ts index a01d2a65..3b921243 100644 --- a/src/shared/constants/svg.ts +++ b/src/shared/constants/svg.ts @@ -1,4 +1,4 @@ -const SVG_DETAILS = { +const SVG_DETAIL = { ARROW_UP: 'arrowUp', BILL: 'bill', CART: 'cart', @@ -21,11 +21,10 @@ const SVG_DETAILS = { PROFILE: 'userCircle', STAR: 'star', SVG_URL: 'http://www.w3.org/2000/svg', - SWITCH_LANGUAGE: { en: 'en', ru: 'ru', }, } as const; -export default SVG_DETAILS; +export default SVG_DETAIL; diff --git a/src/shared/constants/tooltip.ts b/src/shared/constants/tooltip.ts index 4e6ef6f6..f10b5100 100644 --- a/src/shared/constants/tooltip.ts +++ b/src/shared/constants/tooltip.ts @@ -28,7 +28,7 @@ const TOOLTIP_TEXT: Record> = { }, } as const; -export const TOOLTIP_TEXT_KEYS = { +export const TOOLTIP_TEXT_KEY = { ADD_BILLING_ADDRESS: 'ADD_BILLING_ADDRESS', ADD_SHIPPING_ADDRESS: 'ADD_SHIPPING_ADDRESS', DELETE_ADDRESS: 'DELETE_ADDRESS', @@ -42,6 +42,6 @@ export const TOOLTIP_TEXT_KEYS = { SWITCH_SHIPPING_ADDRESS: 'SWITCH_SHIPPING_ADDRESS', }; -export type TooltipTextKeysType = (typeof TOOLTIP_TEXT_KEYS)[keyof typeof TOOLTIP_TEXT_KEYS]; +export type TooltipTextKeyType = (typeof TOOLTIP_TEXT_KEY)[keyof typeof TOOLTIP_TEXT_KEY]; export default TOOLTIP_TEXT; diff --git a/src/shared/types/address.ts b/src/shared/types/address.ts index dbb0d38d..99d00ed9 100644 --- a/src/shared/types/address.ts +++ b/src/shared/types/address.ts @@ -1,10 +1,10 @@ -export const ADDRESS_TYPE = { +export const ADDRESS = { BILLING: 'billing', GENERAL: 'general', SHIPPING: 'shipping', } as const; -export type AddressType = (typeof ADDRESS_TYPE)[keyof typeof ADDRESS_TYPE]; +export type AddressType = (typeof ADDRESS)[keyof typeof ADDRESS]; export const SINGLE_ADDRESS = 'asBilling'; diff --git a/src/shared/constants/blog.ts b/src/shared/types/blog.ts similarity index 100% rename from src/shared/constants/blog.ts rename to src/shared/types/blog.ts diff --git a/src/shared/types/productFilters.ts b/src/shared/types/productFilters.ts index 233e3e25..acda1681 100644 --- a/src/shared/types/productFilters.ts +++ b/src/shared/types/productFilters.ts @@ -1,5 +1,5 @@ import type { PriceRange, SizeProductCount } from '../API/types/type.ts'; -import type { MetaFiltersType } from '../constants/filters.ts'; +import type { MetaFilterKeyType } from '../constants/filters.ts'; import type { Category, Product } from './product.ts'; interface ProductFiltersParams { @@ -17,7 +17,7 @@ interface ProductFiltersParams { export interface SelectedFilters { category: Set; - metaFilter: MetaFiltersType; + metaFilter: MetaFilterKeyType; price: { max: number; min: number; diff --git a/src/shared/types/userMessage.ts b/src/shared/types/userMessage.ts index 46a8e7c1..43c0f3c7 100644 --- a/src/shared/types/userMessage.ts +++ b/src/shared/types/userMessage.ts @@ -1,7 +1,7 @@ -import type { MessageStatusType, ServerMessageKeysType } from '../constants/messages'; +import type { MessageStatusType, ServerMessageKeyType } from '../constants/messages'; interface UserMessage { - key?: ServerMessageKeysType; + key?: ServerMessageKeyType; message?: string; status: MessageStatusType; } diff --git a/src/shared/utils/determineNewAddress.ts b/src/shared/utils/determineNewAddress.ts index 8f686b30..09fbf3c3 100644 --- a/src/shared/utils/determineNewAddress.ts +++ b/src/shared/utils/determineNewAddress.ts @@ -3,13 +3,13 @@ import type UserAddressModel from '@/entities/UserAddress/model/UserAddressModel import type { Address, User } from '../types/user'; -import { ADDRESS_TYPE, type AddressTypeType } from '../constants/forms.ts'; +import { ADDRESS, type AddressType } from '../constants/forms.ts'; const determineNewAddress = ( addressesContainsID: (array: Address[]) => boolean, defaultContainsID: (defaultAddress: Address | null) => boolean, user: User, - createAddress: (activeTypes: AddressTypeType[], inactiveTypes?: AddressTypeType[]) => UserAddressModel, + createAddress: (activeTypes: AddressType[], inactiveTypes?: AddressType[]) => UserAddressModel, ): UserAddressModel => { const { billingAddress, defaultBillingAddressId, defaultShippingAddressId, shippingAddress } = user; switch (true) { @@ -17,110 +17,60 @@ const determineNewAddress = ( defaultContainsID(defaultShippingAddressId) && addressesContainsID(billingAddress) && addressesContainsID(shippingAddress): // billing, shipping, defaultBilling, defaultShipping - return createAddress([ - ADDRESS_TYPE.SHIPPING, - ADDRESS_TYPE.BILLING, - ADDRESS_TYPE.DEFAULT_BILLING, - ADDRESS_TYPE.DEFAULT_SHIPPING, - ]); + return createAddress([ADDRESS.SHIPPING, ADDRESS.BILLING, ADDRESS.DEFAULT_BILLING, ADDRESS.DEFAULT_SHIPPING]); case addressesContainsID(billingAddress) && defaultContainsID(defaultBillingAddressId) && defaultContainsID(defaultShippingAddressId): // billing, defaultBilling, defaultShipping - return createAddress( - [ADDRESS_TYPE.BILLING, ADDRESS_TYPE.DEFAULT_BILLING, ADDRESS_TYPE.DEFAULT_SHIPPING], - [ADDRESS_TYPE.SHIPPING], - ); + return createAddress([ADDRESS.BILLING, ADDRESS.DEFAULT_BILLING, ADDRESS.DEFAULT_SHIPPING], [ADDRESS.SHIPPING]); case addressesContainsID(shippingAddress) && defaultContainsID(defaultBillingAddressId) && defaultContainsID(defaultShippingAddressId): // shipping, defaultBilling, defaultShipping - return createAddress( - [ADDRESS_TYPE.SHIPPING, ADDRESS_TYPE.DEFAULT_BILLING, ADDRESS_TYPE.DEFAULT_SHIPPING], - [ADDRESS_TYPE.BILLING], - ); + return createAddress([ADDRESS.SHIPPING, ADDRESS.DEFAULT_BILLING, ADDRESS.DEFAULT_SHIPPING], [ADDRESS.BILLING]); case addressesContainsID(shippingAddress) && addressesContainsID(billingAddress) && defaultContainsID(defaultBillingAddressId): // billing, shipping, defaultBilling - return createAddress( - [ADDRESS_TYPE.BILLING, ADDRESS_TYPE.SHIPPING, ADDRESS_TYPE.DEFAULT_BILLING], - [ADDRESS_TYPE.DEFAULT_SHIPPING], - ); + return createAddress([ADDRESS.BILLING, ADDRESS.SHIPPING, ADDRESS.DEFAULT_BILLING], [ADDRESS.DEFAULT_SHIPPING]); case addressesContainsID(billingAddress) && defaultContainsID(defaultShippingAddressId) && addressesContainsID(shippingAddress): // billing, shipping, defaultShipping - return createAddress( - [ADDRESS_TYPE.BILLING, ADDRESS_TYPE.SHIPPING, ADDRESS_TYPE.DEFAULT_SHIPPING], - [ADDRESS_TYPE.DEFAULT_BILLING], - ); + return createAddress([ADDRESS.BILLING, ADDRESS.SHIPPING, ADDRESS.DEFAULT_SHIPPING], [ADDRESS.DEFAULT_BILLING]); case defaultContainsID(defaultBillingAddressId) && defaultContainsID(defaultShippingAddressId): // defaultBilling, defaultShipping - return createAddress( - [ADDRESS_TYPE.DEFAULT_BILLING, ADDRESS_TYPE.DEFAULT_SHIPPING], - [ADDRESS_TYPE.BILLING, ADDRESS_TYPE.SHIPPING], - ); + return createAddress([ADDRESS.DEFAULT_BILLING, ADDRESS.DEFAULT_SHIPPING], [ADDRESS.BILLING, ADDRESS.SHIPPING]); case addressesContainsID(billingAddress) && addressesContainsID(shippingAddress): // billing, shipping - return createAddress( - [ADDRESS_TYPE.BILLING, ADDRESS_TYPE.SHIPPING], - [ADDRESS_TYPE.DEFAULT_BILLING, ADDRESS_TYPE.DEFAULT_SHIPPING], - ); + return createAddress([ADDRESS.BILLING, ADDRESS.SHIPPING], [ADDRESS.DEFAULT_BILLING, ADDRESS.DEFAULT_SHIPPING]); case addressesContainsID(billingAddress) && defaultContainsID(defaultBillingAddressId): // billing, defaultBilling - return createAddress( - [ADDRESS_TYPE.BILLING, ADDRESS_TYPE.DEFAULT_BILLING], - [ADDRESS_TYPE.SHIPPING, ADDRESS_TYPE.DEFAULT_SHIPPING], - ); + return createAddress([ADDRESS.BILLING, ADDRESS.DEFAULT_BILLING], [ADDRESS.SHIPPING, ADDRESS.DEFAULT_SHIPPING]); case addressesContainsID(billingAddress) && defaultContainsID(defaultShippingAddressId): // billing, defaultShipping - return createAddress( - [ADDRESS_TYPE.BILLING, ADDRESS_TYPE.DEFAULT_BILLING], - [ADDRESS_TYPE.SHIPPING, ADDRESS_TYPE.DEFAULT_SHIPPING], - ); + return createAddress([ADDRESS.BILLING, ADDRESS.DEFAULT_BILLING], [ADDRESS.SHIPPING, ADDRESS.DEFAULT_SHIPPING]); case addressesContainsID(shippingAddress) && defaultContainsID(defaultShippingAddressId): // shipping, defaultShipping - return createAddress( - [ADDRESS_TYPE.SHIPPING, ADDRESS_TYPE.DEFAULT_SHIPPING], - [ADDRESS_TYPE.BILLING, ADDRESS_TYPE.DEFAULT_BILLING], - ); + return createAddress([ADDRESS.SHIPPING, ADDRESS.DEFAULT_SHIPPING], [ADDRESS.BILLING, ADDRESS.DEFAULT_BILLING]); case addressesContainsID(shippingAddress) && defaultContainsID(defaultBillingAddressId): // shipping, defaultBilling - return createAddress( - [ADDRESS_TYPE.SHIPPING, ADDRESS_TYPE.DEFAULT_SHIPPING], - [ADDRESS_TYPE.BILLING, ADDRESS_TYPE.DEFAULT_BILLING], - ); + return createAddress([ADDRESS.SHIPPING, ADDRESS.DEFAULT_SHIPPING], [ADDRESS.BILLING, ADDRESS.DEFAULT_BILLING]); case addressesContainsID(billingAddress): // billing - return createAddress( - [ADDRESS_TYPE.BILLING], - [ADDRESS_TYPE.DEFAULT_SHIPPING, ADDRESS_TYPE.SHIPPING, ADDRESS_TYPE.DEFAULT_BILLING], - ); + return createAddress([ADDRESS.BILLING], [ADDRESS.DEFAULT_SHIPPING, ADDRESS.SHIPPING, ADDRESS.DEFAULT_BILLING]); case addressesContainsID(shippingAddress): // shipping - return createAddress( - [ADDRESS_TYPE.SHIPPING], - [ADDRESS_TYPE.DEFAULT_SHIPPING, ADDRESS_TYPE.BILLING, ADDRESS_TYPE.DEFAULT_BILLING], - ); + return createAddress([ADDRESS.SHIPPING], [ADDRESS.DEFAULT_SHIPPING, ADDRESS.BILLING, ADDRESS.DEFAULT_BILLING]); case defaultContainsID(defaultBillingAddressId): // defaultBilling - return createAddress( - [ADDRESS_TYPE.DEFAULT_BILLING], - [ADDRESS_TYPE.SHIPPING, ADDRESS_TYPE.BILLING, ADDRESS_TYPE.DEFAULT_SHIPPING], - ); + return createAddress([ADDRESS.DEFAULT_BILLING], [ADDRESS.SHIPPING, ADDRESS.BILLING, ADDRESS.DEFAULT_SHIPPING]); case defaultContainsID(defaultShippingAddressId): // defaultShipping - return createAddress( - [ADDRESS_TYPE.DEFAULT_SHIPPING], - [ADDRESS_TYPE.SHIPPING, ADDRESS_TYPE.BILLING, ADDRESS_TYPE.DEFAULT_BILLING], - ); + return createAddress([ADDRESS.DEFAULT_SHIPPING], [ADDRESS.SHIPPING, ADDRESS.BILLING, ADDRESS.DEFAULT_BILLING]); default: // None - return createAddress( - [], - [ADDRESS_TYPE.SHIPPING, ADDRESS_TYPE.BILLING, ADDRESS_TYPE.DEFAULT_BILLING, ADDRESS_TYPE.DEFAULT_SHIPPING], - ); + return createAddress([], [ADDRESS.SHIPPING, ADDRESS.BILLING, ADDRESS.DEFAULT_BILLING, ADDRESS.DEFAULT_SHIPPING]); } }; diff --git a/src/shared/utils/userMessage.ts b/src/shared/utils/userMessage.ts index 59b5a0d6..90e0948b 100644 --- a/src/shared/utils/userMessage.ts +++ b/src/shared/utils/userMessage.ts @@ -1,16 +1,16 @@ import serverMessageModel from '../ServerMessage/model/ServerMessageModel.ts'; -import { MESSAGE_STATUS, SERVER_MESSAGE_KEYS } from '../constants/messages.ts'; +import { MESSAGE_STATUS, SERVER_MESSAGE_KEY } from '../constants/messages.ts'; export const showErrorMessage = (param: unknown): boolean => { if (param instanceof Error) { return serverMessageModel.showServerMessage({ - key: SERVER_MESSAGE_KEYS.BAD_REQUEST, + key: SERVER_MESSAGE_KEY.BAD_REQUEST, message: param.message, status: MESSAGE_STATUS.ERROR, }); } - if (typeof param === 'string' && param in SERVER_MESSAGE_KEYS) { + if (typeof param === 'string' && param in SERVER_MESSAGE_KEY) { return serverMessageModel.showServerMessage({ key: param, status: MESSAGE_STATUS.ERROR, @@ -19,20 +19,20 @@ export const showErrorMessage = (param: unknown): boolean => { if (typeof param === 'string') { return serverMessageModel.showServerMessage({ - key: SERVER_MESSAGE_KEYS.BAD_REQUEST, + key: SERVER_MESSAGE_KEY.BAD_REQUEST, message: param, status: MESSAGE_STATUS.ERROR, }); } return serverMessageModel.showServerMessage({ - key: SERVER_MESSAGE_KEYS.BAD_REQUEST, + key: SERVER_MESSAGE_KEY.BAD_REQUEST, status: MESSAGE_STATUS.ERROR, }); }; export const showSuccessMessage = (param: unknown): boolean => { - if (typeof param === 'string' && param in SERVER_MESSAGE_KEYS) { + if (typeof param === 'string' && param in SERVER_MESSAGE_KEY) { return serverMessageModel.showServerMessage({ key: param, status: MESSAGE_STATUS.SUCCESS, diff --git a/src/widgets/Blog/model/BogWidgetModel.ts b/src/widgets/Blog/model/BlogWidgetModel.ts similarity index 100% rename from src/widgets/Blog/model/BogWidgetModel.ts rename to src/widgets/Blog/model/BlogWidgetModel.ts diff --git a/src/widgets/Catalog/model/CatalogModel.ts b/src/widgets/Catalog/model/CatalogModel.ts index dc16747c..1edaa7f5 100644 --- a/src/widgets/Catalog/model/CatalogModel.ts +++ b/src/widgets/Catalog/model/CatalogModel.ts @@ -19,7 +19,7 @@ import EventMediatorModel from '@/shared/EventMediator/model/EventMediatorModel. import LoaderModel from '@/shared/Loader/model/LoaderModel.ts'; import modal from '@/shared/Modal/model/ModalModel.ts'; import MEDIATOR_EVENT from '@/shared/constants/events.ts'; -import { META_FILTERS } from '@/shared/constants/filters.ts'; +import { META_FILTER } from '@/shared/constants/filters.ts'; import { DEFAULT_PAGE, PRODUCT_LIMIT, SEARCH_PARAMS_FIELD } from '@/shared/constants/product.ts'; import { LOADER_SIZE } from '@/shared/constants/sizes.ts'; import { SORTING_ID } from '@/shared/constants/sorting.ts'; @@ -53,10 +53,10 @@ class CatalogModel { private addCurrentMetaFilter(filter: FilterProduct, metaFilter: string): FilterProduct { switch (metaFilter) { - case META_FILTERS.en.NEW_ARRIVALS: + case META_FILTER.en.NEW_ARRIVALS: filter.addFilter(FilterFields.NEW_ARRIVAL); return filter; - case META_FILTERS.en.SALE: + case META_FILTER.en.SALE: filter.addFilter(FilterFields.SALE); return filter; default: @@ -80,7 +80,7 @@ class CatalogModel { const categories = await getProductModel().getCategories(); const categorySetWithID: Set = this.replaceCategoryKeyWithID(categories, categorySetWithKey); - const metaFilter = searchParams.get(SEARCH_PARAMS_FIELD.META) ?? META_FILTERS.en.ALL_PRODUCTS; + const metaFilter = searchParams.get(SEARCH_PARAMS_FIELD.META) ?? META_FILTER.en.ALL_PRODUCTS; const size = searchParams.get(SEARCH_PARAMS_FIELD.SIZE) ?? null; const price = { max: parseFloat(searchParams.get(SEARCH_PARAMS_FIELD.MAX_PRICE) ?? '0'), @@ -168,7 +168,7 @@ class CatalogModel { filter.addFilter(FilterFields.SIZE, params.selectedFilters.size); } - this.addCurrentMetaFilter(filter, params.selectedFilters.metaFilter ?? META_FILTERS.en.ALL_PRODUCTS); + this.addCurrentMetaFilter(filter, params.selectedFilters.metaFilter ?? META_FILTER.en.ALL_PRODUCTS); const currentSort = this.getSelectedSorting(params.selectedSorting ?? null); if (currentSort) { diff --git a/src/widgets/Footer/view/FooterView.ts b/src/widgets/Footer/view/FooterView.ts index 6c015ca0..d77eb01e 100644 --- a/src/widgets/Footer/view/FooterView.ts +++ b/src/widgets/Footer/view/FooterView.ts @@ -10,7 +10,7 @@ import LinkModel from '@/shared/Link/model/LinkModel.ts'; import MEDIATOR_EVENT from '@/shared/constants/events.ts'; import * as FORM_FIELDS from '@/shared/constants/forms/fieldParams.ts'; import * as FORM_VALIDATION from '@/shared/constants/forms/validationParams.ts'; -import { SERVER_MESSAGE_KEYS } from '@/shared/constants/messages.ts'; +import { SERVER_MESSAGE_KEY } from '@/shared/constants/messages.ts'; import createBaseElement from '@/shared/utils/createBaseElement.ts'; import getCurrentLanguage from '@/shared/utils/getCurrentLanguage.ts'; import { showSuccessMessage } from '@/shared/utils/userMessage.ts'; @@ -530,7 +530,7 @@ class FooterView { submit.getHTML().addEventListener('click', () => { email.getView().getInput().clear(); - showSuccessMessage(SERVER_MESSAGE_KEYS.SUCCESSFUL_SUBSCRIBE); + showSuccessMessage(SERVER_MESSAGE_KEY.SUCCESSFUL_SUBSCRIBE); submit.setDisabled(); }); diff --git a/src/widgets/Header/model/HeaderModel.ts b/src/widgets/Header/model/HeaderModel.ts index 86594e7a..e41c88a5 100644 --- a/src/widgets/Header/model/HeaderModel.ts +++ b/src/widgets/Header/model/HeaderModel.ts @@ -11,7 +11,7 @@ import getStore from '@/shared/Store/Store.ts'; import { setAuthToken, setCurrentLanguage, switchIsUserLoggedIn } from '@/shared/Store/actions.ts'; import observeStore, { selectIsUserLoggedIn } from '@/shared/Store/observer.ts'; import { LANGUAGE_CHOICE } from '@/shared/constants/common.ts'; -import { SERVER_MESSAGE_KEYS } from '@/shared/constants/messages.ts'; +import { SERVER_MESSAGE_KEY } from '@/shared/constants/messages.ts'; import { PAGE_ID } from '@/shared/constants/pages.ts'; import { showErrorMessage, showSuccessMessage } from '@/shared/utils/userMessage.ts'; @@ -105,14 +105,14 @@ class HeaderModel { if (user) { await getCustomerModel().editCustomer([CustomerModel.actionSetLocale(newLanguage)], user); getStore().dispatch(setCurrentLanguage(newLanguage)); - showSuccessMessage(SERVER_MESSAGE_KEYS.LANGUAGE_CHANGED); + showSuccessMessage(SERVER_MESSAGE_KEY.LANGUAGE_CHANGED); } } catch (error) { showErrorMessage(error); } } else { getStore().dispatch(setCurrentLanguage(newLanguage)); - showSuccessMessage(SERVER_MESSAGE_KEYS.LANGUAGE_CHANGED); + showSuccessMessage(SERVER_MESSAGE_KEY.LANGUAGE_CHANGED); } }); } diff --git a/src/widgets/Header/view/HeaderView.ts b/src/widgets/Header/view/HeaderView.ts index 7a611fe7..002e0440 100644 --- a/src/widgets/Header/view/HeaderView.ts +++ b/src/widgets/Header/view/HeaderView.ts @@ -8,12 +8,12 @@ import LinkModel from '@/shared/Link/model/LinkModel.ts'; import getStore from '@/shared/Store/Store.ts'; import { switchAppTheme } from '@/shared/Store/actions.ts'; import observeStore, { selectCurrentPage, selectIsUserLoggedIn } from '@/shared/Store/observer.ts'; -import { BUTTON_TEXT, BUTTON_TEXT_KEYS } from '@/shared/constants/buttons.ts'; +import { BUTTON_TEXT, BUTTON_TEXT_KEY } from '@/shared/constants/buttons.ts'; import { LANGUAGE_CHOICE } from '@/shared/constants/common.ts'; import { INPUT_TYPE } from '@/shared/constants/forms.ts'; import { PAGE_ID } from '@/shared/constants/pages.ts'; import APP_THEME from '@/shared/constants/styles.ts'; -import SVG_DETAILS from '@/shared/constants/svg.ts'; +import SVG_DETAIL from '@/shared/constants/svg.ts'; import createBaseElement from '@/shared/utils/createBaseElement.ts'; import createSVGUse from '@/shared/utils/createSVGUse.ts'; import getCurrentLanguage from '@/shared/utils/getCurrentLanguage.ts'; @@ -115,7 +115,7 @@ class HeaderView { } private createLanguageSVG(lang: LanguageChoiceType): SVGSVGElement { - const svg = document.createElementNS(SVG_DETAILS.SVG_URL, 'svg'); + const svg = document.createElementNS(SVG_DETAIL.SVG_URL, 'svg'); svg.append(createSVGUse(lang)); return svg; } @@ -128,8 +128,8 @@ class HeaderView { classes: [styles.logo], }); - const svg = document.createElementNS(SVG_DETAILS.SVG_URL, 'svg'); - svg.append(createSVGUse(SVG_DETAILS.LOGO)); + const svg = document.createElementNS(SVG_DETAIL.SVG_URL, 'svg'); + svg.append(createSVGUse(SVG_DETAIL.LOGO)); this.linkLogo.getHTML().append(svg); return this.linkLogo; } @@ -140,7 +140,7 @@ class HeaderView { text: BUTTON_TEXT[getCurrentLanguage()].LOG_OUT, }); - observeCurrentLanguage(this.logoutButton.getHTML(), BUTTON_TEXT, BUTTON_TEXT_KEYS.LOG_OUT); + observeCurrentLanguage(this.logoutButton.getHTML(), BUTTON_TEXT, BUTTON_TEXT_KEY.LOG_OUT); return this.logoutButton; } @@ -221,12 +221,12 @@ class HeaderView { cssClasses: [styles.switchThemeLabelSpan], tag: 'span', }); - const darkSVG = document.createElementNS(SVG_DETAILS.SVG_URL, 'svg'); + const darkSVG = document.createElementNS(SVG_DETAIL.SVG_URL, 'svg'); darkSVG.classList.add(styles.darkSVG); - const lightSVG = document.createElementNS(SVG_DETAILS.SVG_URL, 'svg'); + const lightSVG = document.createElementNS(SVG_DETAIL.SVG_URL, 'svg'); lightSVG.classList.add(styles.lightSVG); - darkSVG.append(createSVGUse(SVG_DETAILS.DARK)); - lightSVG.append(createSVGUse(SVG_DETAILS.LIGHT)); + darkSVG.append(createSVGUse(SVG_DETAIL.DARK)); + lightSVG.append(createSVGUse(SVG_DETAIL.LIGHT)); label.append(darkSVG, lightSVG, this.switchThemeCheckbox.getHTML(), span); return label; @@ -240,8 +240,8 @@ class HeaderView { classes: [styles.addressesLink], }); - const svg = document.createElementNS(SVG_DETAILS.SVG_URL, 'svg'); - svg.append(createSVGUse(SVG_DETAILS.HOUSE)); + const svg = document.createElementNS(SVG_DETAIL.SVG_URL, 'svg'); + svg.append(createSVGUse(SVG_DETAIL.HOUSE)); this.toAddressesLink.getHTML().append(svg); if (!getStore().getState().isUserLoggedIn) { @@ -273,8 +273,8 @@ class HeaderView { classes: [styles.cartLink], }); - const svg = document.createElementNS(SVG_DETAILS.SVG_URL, 'svg'); - svg.append(createSVGUse(SVG_DETAILS.CART)); + const svg = document.createElementNS(SVG_DETAIL.SVG_URL, 'svg'); + svg.append(createSVGUse(SVG_DETAIL.CART)); this.toCartLink.getHTML().append(svg); @@ -299,8 +299,8 @@ class HeaderView { classes: [styles.profileLink], }); - const svg = document.createElementNS(SVG_DETAILS.SVG_URL, 'svg'); - svg.append(createSVGUse(SVG_DETAILS.PROFILE)); + const svg = document.createElementNS(SVG_DETAIL.SVG_URL, 'svg'); + svg.append(createSVGUse(SVG_DETAIL.PROFILE)); this.toProfileLink.getHTML().append(svg); if (!getStore().getState().isUserLoggedIn) { @@ -332,8 +332,8 @@ class HeaderView { classes: [styles.wishListLink], }); - const svg = document.createElementNS(SVG_DETAILS.SVG_URL, 'svg'); - svg.append(createSVGUse(SVG_DETAILS.HEART)); + const svg = document.createElementNS(SVG_DETAIL.SVG_URL, 'svg'); + svg.append(createSVGUse(SVG_DETAIL.HEART)); this.toWishlistLink.getHTML().append(svg); diff --git a/src/widgets/LoginForm/model/LoginFormModel.ts b/src/widgets/LoginForm/model/LoginFormModel.ts index 1625306a..000e300f 100644 --- a/src/widgets/LoginForm/model/LoginFormModel.ts +++ b/src/widgets/LoginForm/model/LoginFormModel.ts @@ -6,7 +6,7 @@ import getCustomerModel from '@/shared/API/customer/model/CustomerModel.ts'; import LoaderModel from '@/shared/Loader/model/LoaderModel.ts'; import getStore from '@/shared/Store/Store.ts'; import { setCurrentLanguage, switchIsUserLoggedIn } from '@/shared/Store/actions.ts'; -import { SERVER_MESSAGE_KEYS } from '@/shared/constants/messages.ts'; +import { SERVER_MESSAGE_KEY } from '@/shared/constants/messages.ts'; import { LOADER_SIZE } from '@/shared/constants/sizes.ts'; import isLanguageChoiceType from '@/shared/types/validation/language.ts'; import { createGreetingMessage } from '@/shared/utils/messageTemplates.ts'; @@ -42,7 +42,7 @@ class LoginFormModel { if (response) { this.loginUserHandler(userLoginData); } else { - showErrorMessage(SERVER_MESSAGE_KEYS.INVALID_EMAIL); + showErrorMessage(SERVER_MESSAGE_KEY.INVALID_EMAIL); } }) .catch((error) => showErrorMessage(error)) @@ -64,7 +64,7 @@ class LoginFormModel { } }) .catch(() => { - showErrorMessage(SERVER_MESSAGE_KEYS.INCORRECT_PASSWORD); + showErrorMessage(SERVER_MESSAGE_KEY.INCORRECT_PASSWORD); }) .finally(() => loader.remove()); } diff --git a/src/widgets/LoginForm/view/LoginFormView.ts b/src/widgets/LoginForm/view/LoginFormView.ts index c10b2bca..181091ba 100644 --- a/src/widgets/LoginForm/view/LoginFormView.ts +++ b/src/widgets/LoginForm/view/LoginFormView.ts @@ -1,5 +1,5 @@ import ButtonModel from '@/shared/Button/model/ButtonModel.ts'; -import { BUTTON_TEXT, BUTTON_TEXT_KEYS, BUTTON_TYPE } from '@/shared/constants/buttons.ts'; +import { BUTTON_TEXT, BUTTON_TEXT_KEY, BUTTON_TYPE } from '@/shared/constants/buttons.ts'; import createBaseElement from '@/shared/utils/createBaseElement.ts'; import getCurrentLanguage from '@/shared/utils/getCurrentLanguage.ts'; import observeCurrentLanguage from '@/shared/utils/observeCurrentLanguage.ts'; @@ -35,7 +35,7 @@ class LoginFormView { text: BUTTON_TEXT[getCurrentLanguage()].LOGIN, }); - observeCurrentLanguage(this.submitFormButton.getHTML(), BUTTON_TEXT, BUTTON_TEXT_KEYS.LOGIN); + observeCurrentLanguage(this.submitFormButton.getHTML(), BUTTON_TEXT, BUTTON_TEXT_KEY.LOGIN); this.submitFormButton.setDisabled(); diff --git a/src/widgets/ProductInfo/view/ProductInfoView.ts b/src/widgets/ProductInfo/view/ProductInfoView.ts index 6d5e9ae3..fc10ec7a 100644 --- a/src/widgets/ProductInfo/view/ProductInfoView.ts +++ b/src/widgets/ProductInfo/view/ProductInfoView.ts @@ -7,9 +7,9 @@ import LoaderModel from '@/shared/Loader/model/LoaderModel.ts'; import observeStore, { selectCurrentLanguage } from '@/shared/Store/observer.ts'; import { BUTTON_TEXT } from '@/shared/constants/buttons.ts'; import { LANGUAGE_CHOICE } from '@/shared/constants/common.ts'; -import { PRODUCT_INFO_TEXT, PRODUCT_INFO_TEXT_KEYS } from '@/shared/constants/product.ts'; +import { PRODUCT_INFO_TEXT, PRODUCT_INFO_TEXT_KEY } from '@/shared/constants/product.ts'; import { LOADER_SIZE } from '@/shared/constants/sizes.ts'; -import SVG_DETAILS from '@/shared/constants/svg.ts'; +import SVG_DETAIL from '@/shared/constants/svg.ts'; import createBaseElement from '@/shared/utils/createBaseElement.ts'; import createSVGUse from '@/shared/utils/createSVGUse.ts'; import getCurrentLanguage from '@/shared/utils/getCurrentLanguage.ts'; @@ -84,7 +84,7 @@ class ProductInfoView { tag: 'span', }); - observeCurrentLanguage(this.categoriesSpan, PRODUCT_INFO_TEXT, PRODUCT_INFO_TEXT_KEYS.CATEGORY); + observeCurrentLanguage(this.categoriesSpan, PRODUCT_INFO_TEXT, PRODUCT_INFO_TEXT_KEY.CATEGORY); const category = this.params.category[0].parent?.name[Number(currentLanguage === LANGUAGE_CHOICE.RU)].value; const subcategory = this.params.category[0].name[Number(currentLanguage === LANGUAGE_CHOICE.RU)].value; @@ -116,8 +116,8 @@ class ProductInfoView { tag: 'span', }); - const svg = document.createElementNS(SVG_DETAILS.SVG_URL, 'svg'); - svg.append(createSVGUse(SVG_DETAILS.LEAVES)); + const svg = document.createElementNS(SVG_DETAIL.SVG_URL, 'svg'); + svg.append(createSVGUse(SVG_DETAIL.LEAVES)); difficultyPoint.append(svg); difficultyPoints.push(difficultyPoint); @@ -161,8 +161,8 @@ class ProductInfoView { classes: ['nextSlideButton'], }); - const svg = document.createElementNS(SVG_DETAILS.SVG_URL, 'svg'); - svg.append(createSVGUse(SVG_DETAILS.ARROW_UP)); + const svg = document.createElementNS(SVG_DETAIL.SVG_URL, 'svg'); + svg.append(createSVGUse(SVG_DETAIL.ARROW_UP)); this.nextSlideButton.getHTML().append(svg); return this.nextSlideButton; } @@ -171,8 +171,8 @@ class ProductInfoView { this.prevSlideButton = new ButtonModel({ classes: ['prevSlideButton'], }); - const svg = document.createElementNS(SVG_DETAILS.SVG_URL, 'svg'); - svg.append(createSVGUse(SVG_DETAILS.ARROW_UP)); + const svg = document.createElementNS(SVG_DETAIL.SVG_URL, 'svg'); + svg.append(createSVGUse(SVG_DETAIL.ARROW_UP)); this.prevSlideButton.getHTML().append(svg); return this.prevSlideButton; } @@ -221,7 +221,7 @@ class ProductInfoView { tag: 'span', }); - observeCurrentLanguage(difficultySpan, PRODUCT_INFO_TEXT, PRODUCT_INFO_TEXT_KEYS.DIFFICULTY); + observeCurrentLanguage(difficultySpan, PRODUCT_INFO_TEXT, PRODUCT_INFO_TEXT_KEY.DIFFICULTY); difficultySpan.append(...this.createDifficultyPoints()); this.rightWrapper.append(difficultySpan); @@ -249,8 +249,8 @@ class ProductInfoView { currentSKU.getHTML().classList.add('currentSKU'); - const svg = document.createElementNS(SVG_DETAILS.SVG_URL, 'svg'); - svg.append(createSVGUse(SVG_DETAILS.COPY)); + const svg = document.createElementNS(SVG_DETAIL.SVG_URL, 'svg'); + svg.append(createSVGUse(SVG_DETAIL.COPY)); svg.addEventListener('click', () => { window.navigator.clipboard diff --git a/src/widgets/ProductOrder/view/ProductOrderView.ts b/src/widgets/ProductOrder/view/ProductOrderView.ts index e56f6b08..e8be8a20 100644 --- a/src/widgets/ProductOrder/view/ProductOrderView.ts +++ b/src/widgets/ProductOrder/view/ProductOrderView.ts @@ -5,7 +5,7 @@ import type { languageVariants } from '@/shared/types/common'; import LinkModel from '@/shared/Link/model/LinkModel.ts'; import { LANGUAGE_CHOICE, TABLET_WIDTH } from '@/shared/constants/common.ts'; -import SVG_DETAILS from '@/shared/constants/svg.ts'; +import SVG_DETAIL from '@/shared/constants/svg.ts'; import { CartActive } from '@/shared/types/cart.ts'; import * as buildPath from '@/shared/utils/buildPathname.ts'; import createBaseElement from '@/shared/utils/createBaseElement.ts'; @@ -79,8 +79,8 @@ class ProductOrderView { const tdDelete = createBaseElement({ cssClasses: [styles.td, styles.deleteCell, styles.hide], tag: 'td' }); this.deleteButton.addEventListener('click', () => this.callback(CartActive.DELETE)); tdDelete.append(this.deleteButton); - const svg = document.createElementNS(SVG_DETAILS.SVG_URL, 'svg'); - svg.append(createSVGUse(SVG_DETAILS.DELETE)); + const svg = document.createElementNS(SVG_DETAIL.SVG_URL, 'svg'); + svg.append(createSVGUse(SVG_DETAIL.DELETE)); this.deleteButton.append(svg); return tdDelete; } diff --git a/src/widgets/RegistrationForm/model/RegistrationFormModel.ts b/src/widgets/RegistrationForm/model/RegistrationFormModel.ts index 2237796f..6a95c729 100644 --- a/src/widgets/RegistrationForm/model/RegistrationFormModel.ts +++ b/src/widgets/RegistrationForm/model/RegistrationFormModel.ts @@ -9,28 +9,28 @@ import getCustomerModel from '@/shared/API/customer/model/CustomerModel.ts'; import LoaderModel from '@/shared/Loader/model/LoaderModel.ts'; import getStore from '@/shared/Store/Store.ts'; import { setBillingCountry, switchIsUserLoggedIn } from '@/shared/Store/actions.ts'; -import { SERVER_MESSAGE_KEYS } from '@/shared/constants/messages.ts'; +import { SERVER_MESSAGE_KEY } from '@/shared/constants/messages.ts'; import { LOADER_SIZE } from '@/shared/constants/sizes.ts'; -import { ADDRESS_TYPE } from '@/shared/types/address.ts'; +import { ADDRESS } from '@/shared/types/address.ts'; import getCurrentLanguage from '@/shared/utils/getCurrentLanguage.ts'; import { showErrorMessage, showSuccessMessage } from '@/shared/utils/userMessage.ts'; import RegistrationFormView from '../view/RegistrationFormView.ts'; class RegisterFormModel { - private addressWrappers: Record, AddressModel> = { - [ADDRESS_TYPE.BILLING]: new AddressModel( + private addressWrappers: Record, AddressModel> = { + [ADDRESS.BILLING]: new AddressModel( { setDefault: true, }, - ADDRESS_TYPE.BILLING, + ADDRESS.BILLING, ), - [ADDRESS_TYPE.SHIPPING]: new AddressModel( + [ADDRESS.SHIPPING]: new AddressModel( { setAsBilling: true, setDefault: true, }, - ADDRESS_TYPE.SHIPPING, + ADDRESS.SHIPPING, ), }; @@ -97,7 +97,7 @@ class RegisterFormModel { this.inputFields.forEach((inputField) => this.setInputFieldHandlers(inputField)); this.setPreventDefaultToForm(); this.setSubmitFormHandler(); - const checkboxSingleAddress = this.addressWrappers[ADDRESS_TYPE.SHIPPING] + const checkboxSingleAddress = this.addressWrappers[ADDRESS.SHIPPING] .getView() .getAddressAsBillingCheckBox() ?.getHTML(); @@ -121,11 +121,11 @@ class RegisterFormModel { if (newUserData) { getStore().dispatch(switchIsUserLoggedIn(false)); getStore().dispatch(switchIsUserLoggedIn(true)); - showSuccessMessage(SERVER_MESSAGE_KEYS.SUCCESSFUL_REGISTRATION); + showSuccessMessage(SERVER_MESSAGE_KEY.SUCCESSFUL_REGISTRATION); } }) .catch(() => { - showErrorMessage(SERVER_MESSAGE_KEYS.USER_EXISTS); + showErrorMessage(SERVER_MESSAGE_KEY.USER_EXISTS); }) .finally(() => loader.remove()); } @@ -158,8 +158,8 @@ class RegisterFormModel { }); } - const billingAddressView = this.addressWrappers[ADDRESS_TYPE.BILLING].getView(); - const shippingAddress = this.addressWrappers[ADDRESS_TYPE.SHIPPING]; + const billingAddressView = this.addressWrappers[ADDRESS.BILLING].getView(); + const shippingAddress = this.addressWrappers[ADDRESS.SHIPPING]; shippingAddress .getView() .getInputFields() diff --git a/src/widgets/RegistrationForm/view/RegistrationFormView.ts b/src/widgets/RegistrationForm/view/RegistrationFormView.ts index 4bd70eb2..a0da8e43 100644 --- a/src/widgets/RegistrationForm/view/RegistrationFormView.ts +++ b/src/widgets/RegistrationForm/view/RegistrationFormView.ts @@ -1,5 +1,5 @@ import ButtonModel from '@/shared/Button/model/ButtonModel.ts'; -import { BUTTON_TEXT, BUTTON_TEXT_KEYS, BUTTON_TYPE } from '@/shared/constants/buttons.ts'; +import { BUTTON_TEXT, BUTTON_TEXT_KEY, BUTTON_TYPE } from '@/shared/constants/buttons.ts'; import createBaseElement from '@/shared/utils/createBaseElement.ts'; import getCurrentLanguage from '@/shared/utils/getCurrentLanguage.ts'; import observeCurrentLanguage from '@/shared/utils/observeCurrentLanguage.ts'; @@ -34,7 +34,7 @@ class RegistrationFormView { classes: [styles.submitFormButton], text: BUTTON_TEXT[getCurrentLanguage()].REGISTRATION, }); - observeCurrentLanguage(this.submitFormButton.getHTML(), BUTTON_TEXT, BUTTON_TEXT_KEYS.REGISTRATION); + observeCurrentLanguage(this.submitFormButton.getHTML(), BUTTON_TEXT, BUTTON_TEXT_KEY.REGISTRATION); this.submitFormButton.setDisabled(); return this.submitFormButton; diff --git a/src/widgets/UserAddresses/model/UserAddressesModel.ts b/src/widgets/UserAddresses/model/UserAddressesModel.ts index e8fe3f5c..ba24f2d7 100644 --- a/src/widgets/UserAddresses/model/UserAddressesModel.ts +++ b/src/widgets/UserAddresses/model/UserAddressesModel.ts @@ -1,4 +1,4 @@ -import type { AddressTypeType } from '@/shared/constants/forms.ts'; +import type { AddressType } from '@/shared/constants/forms.ts'; import type { Address, User } from '@/shared/types/user.ts'; import UserAddressModel from '@/entities/UserAddress/model/UserAddressModel.ts'; @@ -7,7 +7,7 @@ import getCustomerModel from '@/shared/API/customer/model/CustomerModel.ts'; import EventMediatorModel from '@/shared/EventMediator/model/EventMediatorModel.ts'; import modal from '@/shared/Modal/model/ModalModel.ts'; import MEDIATOR_EVENT from '@/shared/constants/events.ts'; -import { ADDRESS_TYPE, DEFAULT_ADDRESS } from '@/shared/constants/forms.ts'; +import { ADDRESS, DEFAULT_ADDRESS } from '@/shared/constants/forms.ts'; import clearOutElement from '@/shared/utils/clearOutElement.ts'; import determineNewAddress from '@/shared/utils/determineNewAddress.ts'; import { arrayContainsObjectWithValue, objectHasPropertyValue } from '@/shared/utils/hasValue.ts'; @@ -36,7 +36,7 @@ class UserAddressesModel { return objectHasPropertyValue(defaultAddress, KEY_TO_FIND, address.id); }; - const createAddress = (activeTypes: AddressTypeType[], inactiveTypes?: AddressTypeType[]): UserAddressModel => + const createAddress = (activeTypes: AddressType[], inactiveTypes?: AddressType[]): UserAddressModel => new UserAddressModel(address, activeTypes, inactiveTypes); const newAddress = determineNewAddress(addressesContainsID, defaultContainsID, user, createAddress); @@ -75,7 +75,7 @@ class UserAddressesModel { .getCreateBillingAddressButton() .getHTML() .addEventListener('click', () => { - const newAddressForm = new AddressAddModel(ADDRESS_TYPE.BILLING, DEFAULT_ADDRESS).getHTML(); + const newAddressForm = new AddressAddModel(ADDRESS.BILLING, DEFAULT_ADDRESS).getHTML(); modal.show(); modal.setContent(newAddressForm); }); @@ -86,7 +86,7 @@ class UserAddressesModel { .getCreateShippingAddressButton() .getHTML() .addEventListener('click', () => { - const newAddressForm = new AddressAddModel(ADDRESS_TYPE.SHIPPING, DEFAULT_ADDRESS).getHTML(); + const newAddressForm = new AddressAddModel(ADDRESS.SHIPPING, DEFAULT_ADDRESS).getHTML(); modal.show(); modal.setContent(newAddressForm); }); diff --git a/src/widgets/UserAddresses/view/UserAddressesView.ts b/src/widgets/UserAddresses/view/UserAddressesView.ts index 1bbcfa27..19d540b8 100644 --- a/src/widgets/UserAddresses/view/UserAddressesView.ts +++ b/src/widgets/UserAddresses/view/UserAddressesView.ts @@ -1,6 +1,6 @@ import ButtonModel from '@/shared/Button/model/ButtonModel.ts'; import observeStore, { selectCurrentLanguage } from '@/shared/Store/observer.ts'; -import SVG_DETAILS from '@/shared/constants/svg.ts'; +import SVG_DETAIL from '@/shared/constants/svg.ts'; import TOOLTIP_TEXT from '@/shared/constants/tooltip.ts'; import createBaseElement from '@/shared/utils/createBaseElement.ts'; import createSVGUse from '@/shared/utils/createSVGUse.ts'; @@ -40,8 +40,8 @@ class UserAddressView { private createBillingLogo(): HTMLDivElement { this.billingLogo = createBaseElement({ cssClasses: [styles.billingLogo], tag: 'div' }); - const svg = document.createElementNS(SVG_DETAILS.SVG_URL, 'svg'); - svg.append(createSVGUse(SVG_DETAILS.BILL)); + const svg = document.createElementNS(SVG_DETAIL.SVG_URL, 'svg'); + svg.append(createSVGUse(SVG_DETAIL.BILL)); this.billingLogo.append(svg); return this.billingLogo; } @@ -91,8 +91,8 @@ class UserAddressView { private createShippingLogo(): HTMLDivElement { this.shippingLogo = createBaseElement({ cssClasses: [styles.shippingLogo], tag: 'div' }); - const svg = document.createElementNS(SVG_DETAILS.SVG_URL, 'svg'); - svg.append(createSVGUse(SVG_DETAILS.DELIVERY)); + const svg = document.createElementNS(SVG_DETAIL.SVG_URL, 'svg'); + svg.append(createSVGUse(SVG_DETAIL.DELIVERY)); this.shippingLogo.append(svg); return this.shippingLogo; } diff --git a/src/widgets/UserInfo/view/UserInfoView.ts b/src/widgets/UserInfo/view/UserInfoView.ts index 08541e71..0e27e466 100644 --- a/src/widgets/UserInfo/view/UserInfoView.ts +++ b/src/widgets/UserInfo/view/UserInfoView.ts @@ -2,8 +2,8 @@ import type { User } from '@/shared/types/user'; import ButtonModel from '@/shared/Button/model/ButtonModel.ts'; import observeStore, { selectCurrentLanguage } from '@/shared/Store/observer.ts'; -import { BUTTON_TEXT, BUTTON_TEXT_KEYS } from '@/shared/constants/buttons.ts'; -import SVG_DETAILS from '@/shared/constants/svg.ts'; +import { BUTTON_TEXT, BUTTON_TEXT_KEY } from '@/shared/constants/buttons.ts'; +import SVG_DETAIL from '@/shared/constants/svg.ts'; import TOOLTIP_TEXT from '@/shared/constants/tooltip.ts'; import createBaseElement from '@/shared/utils/createBaseElement.ts'; import createSVGUse from '@/shared/utils/createSVGUse.ts'; @@ -63,7 +63,7 @@ class UserInfoView { text: BUTTON_TEXT[getCurrentLanguage()].EDIT_INFO, }); - observeCurrentLanguage(this.editInfoButton.getHTML(), BUTTON_TEXT, BUTTON_TEXT_KEYS.EDIT_INFO); + observeCurrentLanguage(this.editInfoButton.getHTML(), BUTTON_TEXT, BUTTON_TEXT_KEY.EDIT_INFO); return this.editInfoButton; } @@ -124,8 +124,8 @@ class UserInfoView { private createLogo(): HTMLDivElement { this.logo = createBaseElement({ cssClasses: [styles.keyLogo], tag: 'div' }); - const svg = document.createElementNS(SVG_DETAILS.SVG_URL, 'svg'); - svg.append(createSVGUse(SVG_DETAILS.KEY)); + const svg = document.createElementNS(SVG_DETAIL.SVG_URL, 'svg'); + svg.append(createSVGUse(SVG_DETAIL.KEY)); this.logo.append(svg); return this.logo; }