Skip to content

Commit

Permalink
refactor: remove unused constants
Browse files Browse the repository at this point in the history
  • Loading branch information
stardustmeg committed Jun 14, 2024
1 parent 1c8767c commit 2b7a8c1
Show file tree
Hide file tree
Showing 81 changed files with 380 additions and 585 deletions.
6 changes: 3 additions & 3 deletions src/entities/AboutFullCard/view/AboutFullCardView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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());
Expand Down
16 changes: 8 additions & 8 deletions src/entities/AboutShortCard/view/AboutShortCardView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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],
});
Expand Down Expand Up @@ -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, () => {
Expand All @@ -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,
Expand Down Expand Up @@ -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, () => {
Expand Down
8 changes: 4 additions & 4 deletions src/entities/Address/model/AddressModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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();
Expand All @@ -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:
Expand Down
32 changes: 16 additions & 16 deletions src/entities/Address/view/AddressView.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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,
Expand All @@ -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',
Expand All @@ -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({
Expand All @@ -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,
});
Expand All @@ -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);
Expand All @@ -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,
Expand All @@ -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',
});
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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;
Expand Down
6 changes: 3 additions & 3 deletions src/entities/Credentials/view/CredentialsView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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;
}
Expand Down
14 changes: 7 additions & 7 deletions src/entities/Navigation/view/NavigationView.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/entities/Post/view/PostView.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down
10 changes: 5 additions & 5 deletions src/entities/ProductCard/view/ProductCardView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
10 changes: 5 additions & 5 deletions src/entities/ProductModalSlider/view/ProductModalSliderView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down Expand Up @@ -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;
}
Expand All @@ -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;
}
Expand Down
6 changes: 3 additions & 3 deletions src/entities/PromocodeSlider/view/PromoCodeSliderView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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
Expand Down
Loading

0 comments on commit 2b7a8c1

Please sign in to comment.