Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: update production deploy with implemented features from [sprint_4] #334

Merged
merged 29 commits into from
Jun 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
1d57940
chore(RSS-ECOMM-4_00): update sprint number (#309)
stardustmeg May 25, 2024
275ba40
refactor(RSS-ECOMM-4_30): update styles (#311)
stardustmeg May 25, 2024
b8e23ec
feat(RSS-ECOMM-4_99): add navigate and languages to footer (#312)
YulikK May 26, 2024
20ec774
feat(RSS-ECOMM-4_31): adaptive (#314)
Kleostro May 26, 2024
43da852
feat(RSS-ECOMM-4_98): add level to product (#313)
YulikK May 26, 2024
cfd3da8
feat(RSS-ECOMM-4_97): add address actions (#315)
YulikK May 26, 2024
5a0e33a
feat(RSS-ECOMM-4_96): add total count for products (#316)
YulikK May 26, 2024
7cfd176
feat(RSS-ECOMM-4_03): implement effecting loading products (#318)
Kleostro May 27, 2024
2435860
feat(RSS-ECOMM-4_32): display difficultyPlants (#319)
Kleostro May 27, 2024
7b6e156
feat(RSS-ECOMM-3_18): implement addresses management (#317)
stardustmeg May 28, 2024
5c48af6
fix(RSS-ECOMM-4_33): reloading product page (#320)
Kleostro May 28, 2024
b6c685f
feat(RSS-ECOMM-4_10)/cart (#321)
YulikK May 29, 2024
20fedc3
feat(RSS-ECOMM-4_97): filter range (#323)
YulikK May 29, 2024
5677dfe
feat(RSS-ECOMM-4_33): implement editing address (#322)
stardustmeg May 29, 2024
014986d
fix(RSS-ECOMM-4_34): catalog (#324)
Kleostro May 31, 2024
77232bf
feat(RSS-ECOMM-4_35): update address editing (#325)
stardustmeg May 31, 2024
8811d8d
fix(RSS-ECOMM-4_36): user addresses (#326)
Kleostro May 31, 2024
44d3edf
feat(RSS-ECOMM-4_37): display product discount (#327)
Kleostro Jun 2, 2024
9f8a8a7
fix(RSS-ECOMM-4_96): cart blog footer (#328)
YulikK Jun 2, 2024
c1e9264
feat(RSS-ECOMM-4_37): update app themes (#329)
stardustmeg Jun 2, 2024
1b45d94
feat(RSS-ECOMM-4_38): scroll to top button (#330)
stardustmeg Jun 3, 2024
39d0992
refactor(RSS-ECOMM-4_39): search params (#331)
Kleostro Jun 3, 2024
334dd1b
feat(RSS-ECOMM-4_95): add confirm and link (#333)
YulikK Jun 3, 2024
2040aa7
refactor(RSS-ECOMM-4_40): update password edit form (#332)
stardustmeg Jun 3, 2024
dfaf7ce
Merge branch 'develop' into sprint-4
stardustmeg Jun 3, 2024
70ecbb2
chore: solve conflicts
stardustmeg Jun 3, 2024
4f6f691
fix: after merge develop
stardustmeg Jun 3, 2024
d75d40e
fix: footer input not required
stardustmeg Jun 3, 2024
27c217c
fix: validation params
stardustmeg Jun 3, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/labeler.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,6 @@ sprint3:

sprint4:
- head-branch: 'ECOMM-4'

sprint5:
- head-branch: 'ECOMM-5'
4 changes: 2 additions & 2 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
πŸ“ conforms with the following format:

- [ ] prefix (following the [convention](https://www.conventionalcommits.org/en/v1.0.0-beta.2/): `feat`, `fix`, `hotfix`, `chore`, `refactor`, `revert`, `docs`, `style`, `test`)
- [ ] sprint and issue number (e.g. `RSS-ECOMM-3_01`, where `3` - is the sprint number and `01` - is the issue number)
- [ ] sprint and issue number (e.g. `RSS-ECOMM-5_01`, where `5` - is the sprint number and `01` - is the issue number)
- [ ] short description

πŸ‘€ Example: `feat(RSS-ECOMM-3_01): description`
πŸ‘€ Example: `feat(RSS-ECOMM-5_01): description`

## PR Description πŸ§™β€β™‚οΈ

Expand Down
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ on:
- sprint-2
- sprint-3
- sprint-4
- sprint-5

jobs:
format:
Expand Down
6 changes: 5 additions & 1 deletion .validate-branch-namerc.cjs
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
module.exports = {
pattern: /^(feat|fix|hotfix|chore|refactor|revert|docs|style|test|)\(RSS-ECOMM-\d_\d{2}\)\/[a-z]+[a-zA-Z0-9]*$/,
pattern:
/^sprint-4|^(feat|fix|hotfix|chore|refactor|revert|docs|style|test|)\(RSS-ECOMM-\d_\d{2}\)\/[a-z]+[a-zA-Z0-9]*$/,
errorMsg: 'Please use correct branch name',
};

// Branch Name Examples:

// "feat(RSS-ECOMM-1_01)/addNewProduct" // where 1 is the sprint number and 01 is the issue number
// "fix(RSS-ECOMM-2_15)/addCorrectProduct" // where 2 is the sprint number and 15 is the issue number
// "chore(RSS-ECOMM-3_01)/addNewProduct" // where 3 is the sprint number and 01 is the issue number
// "refactor(RSS-ECOMM-4_01)/addNewProduct" // where 4 is the sprint number and 01 is the issue number
// "revert(RSS-ECOMM-5_01)/addNewProduct" // where 5 is the sprint number and 01 is the issue number
4 changes: 4 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,11 @@
"@commercetools/sdk-client-v2": "^2.5.0",
"@commercetools/sdk-middleware-auth": "^7.0.1",
"@commercetools/sdk-middleware-http": "^7.0.4",
"@types/hammerjs": "^2.0.45",
"@types/js-cookie": "^3.0.6",
"@types/uuid": "^9.0.8",
"autoprefixer": "^10.4.19",
"hammerjs": "^2.0.8",
"isomorphic-fetch": "^3.0.0",
"js-cookie": "^3.0.5",
"materialize-css": "^1.0.0-rc.2",
Expand All @@ -75,6 +78,7 @@
"postcode-validator": "^3.8.20",
"sharp": "^0.33.3",
"swiper": "^11.1.3",
"uuid": "^9.0.1",
"vite-plugin-checker": "^0.6.4",
"vite-plugin-image-optimizer": "^1.1.7",
"vite-plugin-svg-spriter": "^1.0.0",
Expand Down
Binary file modified public/img/png/instagram.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/img/png/instagram_.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified public/img/png/linkedin.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified public/img/png/meta.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/img/png/pay-ae.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/img/png/pay-mc.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/img/png/pay-pp.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/img/png/pay-visa.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified public/img/png/twitterx.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified public/img/png/union.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 5 additions & 3 deletions src/app/App/model/AppModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import type { Page, PageParams, PagesType } from '@/shared/types/page.ts';

import RouterModel from '@/app/Router/model/RouterModel.ts';
import modal from '@/shared/Modal/model/ModalModel.ts';
import ScrollToTopModel from '@/shared/ScrollToTop/model/ScrollToTopModel.ts';
import { PAGE_ID } from '@/shared/constants/pages.ts';
import FooterModel from '@/widgets/Footer/model/FooterModel.ts';
import HeaderModel from '@/widgets/Header/model/HeaderModel.ts';
Expand Down Expand Up @@ -32,9 +33,9 @@ class AppModel {
const { default: CartPageModel } = await import('@/pages/CartPage/model/CartPageModel.ts');
return new CartPageModel(this.appView.getHTML());
},
[PAGE_ID.CATALOG_PAGE]: async (params: PageParams): Promise<Page> => {
[PAGE_ID.CATALOG_PAGE]: async (): Promise<Page> => {
const { default: CatalogPageModel } = await import('@/pages/CatalogPage/model/CatalogPageModel.ts');
return new CatalogPageModel(this.appView.getHTML(), params);
return new CatalogPageModel(this.appView.getHTML());
},
[PAGE_ID.DEFAULT_PAGE]: async (): Promise<Page> => {
const { default: MainPageModel } = await import('@/pages/MainPage/model/MainPageModel.ts');
Expand Down Expand Up @@ -77,7 +78,8 @@ class AppModel {
private async initialize(): Promise<RouterModel> {
const routes = await this.createRoutes();
const router = new RouterModel(routes);
document.body.append(this.appView.getHTML());
const scrollToTop = new ScrollToTopModel();
document.body.append(this.appView.getHTML(), scrollToTop.getHTML().getHTML());
this.appView.getHTML().insertAdjacentElement('beforebegin', new HeaderModel(this.appView.getHTML()).getHTML());
this.appView.getHTML().insertAdjacentElement('afterend', new FooterModel().getHTML());
this.appView.getHTML().insertAdjacentElement('afterend', modal.getHTML());
Expand Down
78 changes: 53 additions & 25 deletions src/app/Router/model/RouterModel.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import type { PageParams, PagesType } from '@/shared/types/page';

import getStore from '@/shared/Store/Store.ts';
import observeStore, { selectCurrentLanguage } from '@/shared/Store/observer.ts';
import { PAGE_ID } from '@/shared/constants/pages.ts';
import { isValidPath, isValidState } from '@/shared/types/validation/paths.ts';
import formattedText from '@/shared/utils/formattedText.ts';
import setPageTitle from '@/shared/utils/setPageTitle.ts';
import showErrorMessage from '@/shared/utils/userMessage.ts';

const PROJECT_TITLE = import.meta.env.VITE_APP_PROJECT_TITLE;
const DEFAULT_SEGMENT = import.meta.env.VITE_APP_DEFAULT_SEGMENT;
const NEXT_SEGMENT = import.meta.env.VITE_APP_NEXT_SEGMENT;
const PATH_SEGMENTS_TO_KEEP = import.meta.env.VITE_APP_PATH_SEGMENTS_TO_KEEP;
Expand All @@ -23,17 +24,19 @@ class RouterModel {

this.routes = routes;
document.addEventListener('DOMContentLoaded', () => {
const currentPath = window.location.pathname.slice(NEXT_SEGMENT).split(DEFAULT_SEGMENT) || PAGE_ID.DEFAULT_PAGE;
const currentPath =
(window.location.pathname + window.location.search).slice(NEXT_SEGMENT).split(DEFAULT_SEGMENT) ||
PAGE_ID.DEFAULT_PAGE;
this.navigateTo(currentPath.join(DEFAULT_SEGMENT));
});

window.addEventListener('popstate', (event) => {
const currentState: unknown = event.state;
let currentPage = '';
let [currentPage] = '';
let currentPath = '';

if (isValidState(currentState)) {
currentPage = currentState.path.split(DEFAULT_SEGMENT)[PATH_SEGMENTS_TO_KEEP] + DEFAULT_SEGMENT;
[currentPage] = currentState.path.split(DEFAULT_SEGMENT)[PATH_SEGMENTS_TO_KEEP].split(SEARCH_SEGMENT);
currentPath = currentState.path;
}

Expand All @@ -46,20 +49,51 @@ class RouterModel {
});
}

public static appendSearchParams(key: string, value: string): void {
const url = new URL(decodeURIComponent(window.location.href));
url.searchParams.append(key, value);
const path = url.pathname + url.search.toString();
window.history.pushState({ path: path.slice(NEXT_SEGMENT) }, '', path);
}

public static clearSearchParams(): void {
const url = new URL(decodeURIComponent(window.location.href));
const path = `${DEFAULT_SEGMENT}${url.pathname.split(DEFAULT_SEGMENT)[NEXT_SEGMENT]}${DEFAULT_SEGMENT}`;
window.history.pushState({ path: path.slice(NEXT_SEGMENT) }, '', path);
}

public static deleteSearchParams(key: string): void {
const url = new URL(decodeURIComponent(window.location.href));
url.searchParams.delete(key);
const path = url.pathname + url.search.toString();
window.history.pushState({ path: path.slice(NEXT_SEGMENT) }, '', path);
}

public static getInstance(): RouterModel {
return RouterModel.router;
}

public static getSearchParams(): URLSearchParams {
return new URL(decodeURIComponent(window.location.href)).searchParams;
}

public static setSearchParams(key: string, value: string): void {
const url = new URL(decodeURIComponent(window.location.href));
url.searchParams.delete(key);
url.searchParams.set(key, value);
const path = url.pathname + url.search.toString();
window.history.pushState({ path: path.slice(NEXT_SEGMENT) }, '', path);
}

private async checkPageAndParams(
currentPage: string,
path: string,
): Promise<{ hasRoute: boolean; params: PageParams } | null> {
const hasRoute = this.routes.has(currentPage);
const decodePath = decodeURIComponent(path);
const id = decodePath.split(DEFAULT_SEGMENT).slice(PATH_SEGMENTS_TO_KEEP, -NEXT_SEGMENT)[NEXT_SEGMENT];
const searchParams = decodeURIComponent(decodePath).split(SEARCH_SEGMENT)[NEXT_SEGMENT];
const title = `${PROJECT_TITLE} | ${hasRoute ? formattedText(currentPage === PAGE_ID.DEFAULT_PAGE ? PAGE_ID.MAIN_PAGE.slice(PATH_SEGMENTS_TO_KEEP, -NEXT_SEGMENT) : currentPage.slice(PATH_SEGMENTS_TO_KEEP, -NEXT_SEGMENT)) : PAGE_ID.NOT_FOUND_PAGE.slice(PATH_SEGMENTS_TO_KEEP, -NEXT_SEGMENT)}`;
document.title = title;
const id = path.split(DEFAULT_SEGMENT)[NEXT_SEGMENT]?.split(SEARCH_SEGMENT)[PATH_SEGMENTS_TO_KEEP] || null;

setPageTitle(currentPage, hasRoute);
observeStore(selectCurrentLanguage, () => this.checkPageAndParams(currentPage, path));

if (!hasRoute) {
await this.routes.get(PAGE_ID.NOT_FOUND_PAGE)?.({});
Expand All @@ -68,12 +102,7 @@ class RouterModel {

return {
hasRoute,
params: {
[currentPage.slice(PATH_SEGMENTS_TO_KEEP, -NEXT_SEGMENT)]: {
id: id ?? null,
searchParams: searchParams ?? null,
},
},
params: { [currentPage.slice(PATH_SEGMENTS_TO_KEEP)]: { id } },
};
}

Expand All @@ -88,15 +117,14 @@ class RouterModel {
}

public navigateTo(path: string): void {
const currentPage = path.split(DEFAULT_SEGMENT)[PATH_SEGMENTS_TO_KEEP] + DEFAULT_SEGMENT || PAGE_ID.DEFAULT_PAGE;
this.checkPageAndParams(currentPage, path)
.then((check) => {
if (check) {
this.routes.get(currentPage)?.(check.params).catch(showErrorMessage);
history.pushState({ path }, '', `/${path}`);
}
})
.catch(showErrorMessage);
const currentPage =
path.split(DEFAULT_SEGMENT)[PATH_SEGMENTS_TO_KEEP].split(SEARCH_SEGMENT)[PATH_SEGMENTS_TO_KEEP] ||
PAGE_ID.DEFAULT_PAGE;

if (currentPage !== getStore().getState().currentPage || currentPage === PAGE_ID.DEFAULT_PAGE) {
this.handleRequest(currentPage, path);
}
history.pushState({ path }, '', `/${path}`);
}
}

Expand Down
Loading