Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
121 commits
Select commit Hold shift + click to select a range
347bca0
refactor: add refactor API request
Golosova76 Jun 9, 2024
21d6d2d
refactor: add refactor API request
Golosova76 Jun 9, 2024
20c2bc1
feat: add button add cart
Golosova76 Jun 9, 2024
597f6a7
feat: add create cart user
Jun 10, 2024
64225e6
feat(main page): add card component
dashaborzova Jun 11, 2024
52d0ba7
refactor(card component): change input value argument
dashaborzova Jun 11, 2024
c269044
refactor(card component): modify card compomemt for further use, make…
dashaborzova Jun 11, 2024
bd43244
feat: add anonym cart products
Golosova76 Jun 11, 2024
02f9922
refactor: add special view for page, refactor catalog page
Friday-13 Jun 11, 2024
ee29b1e
feat: add register cart products
Golosova76 Jun 12, 2024
e70f198
feat: add simple layout scheme for basket page
Friday-13 Jun 12, 2024
5684975
feat: add register cart products
Golosova76 Jun 12, 2024
43dab2f
Merge pull request #204 from Friday-13/feat/RSS-ECOMM-4_07
Golosova76 Jun 12, 2024
561807e
Merge pull request #205 from Friday-13/feat/add-remove-product-cart
Golosova76 Jun 12, 2024
8715d65
fix: add id's for inputs in sign up page
Friday-13 Jun 12, 2024
7b22c97
Merge pull request #206 from Friday-13/feat/RSS-ECOMM-4_10
Friday-13 Jun 12, 2024
80cdab6
refactor(card component): divide card component structure into basic …
dashaborzova Jun 12, 2024
49690f1
Merge branch 'release/basket-about_us' of github.com:Friday-13/eComme…
Friday-13 Jun 12, 2024
968ce55
Merge pull request #203 from Friday-13/RSS-ECOMM-4_16
InStageTwo Jun 12, 2024
3b9bfa3
feat(header): implement about us and cart page icon
dashaborzova Jun 12, 2024
b520c80
fix(header): change header.test to pass
dashaborzova Jun 12, 2024
2e2913b
fix(header): header.test fix
dashaborzova Jun 12, 2024
a47ff0c
fix(header): changed about us string into group
dashaborzova Jun 12, 2024
c7bd328
fix(header): changed cart into shopping cart to pass
dashaborzova Jun 12, 2024
2056539
Merge pull request #207 from Friday-13/RSS-ECOMM-4_23
InStageTwo Jun 14, 2024
7acec88
feat: add draft realization of separate flow work
Friday-13 Jun 14, 2024
865ad6b
feat(about us page): add draft member cards
dashaborzova Jun 14, 2024
fe1bfda
feat: add one entery point for every root for different flow
Friday-13 Jun 15, 2024
2895a6b
refactor: remove unused files
Friday-13 Jun 15, 2024
cbf3a76
fix: add removing token and user name from local storage on logout
Friday-13 Jun 15, 2024
37fe978
Merge branch 'release/basket-about_us' of github.com:Friday-13/eComme…
Friday-13 Jun 15, 2024
3a4217e
feat: add interface cart
Golosova76 Jun 15, 2024
af61950
Merge pull request #208 from Friday-13/feat/token-authorization
Friday-13 Jun 15, 2024
3433a0b
feat: add cart in page
Golosova76 Jun 16, 2024
17cb821
feat: add cart in page
Golosova76 Jun 16, 2024
2c029bd
feat: add pagination view, config pagination layout
Friday-13 Jun 16, 2024
18ddb39
feat: add styles cart page
Golosova76 Jun 16, 2024
ad89208
feat(about us): add collaboration and contribution sections
dashaborzova Jun 16, 2024
2bcbaa2
feat: add pagination feature
Friday-13 Jun 16, 2024
a7a85d9
refactor: refactor api work
Golosova76 Jun 17, 2024
d449bc9
feat(about us page): add rsschool logo
dashaborzova Jun 17, 2024
dc5ce62
Merge branch 'release/basket-about_us' of https://github.com/Friday-1…
dashaborzova Jun 17, 2024
4263f6a
feat(about us page): add bio item
dashaborzova Jun 17, 2024
ebb1833
Merge pull request #209 from Friday-13/feat/RSS-ECOMM-4_03
Friday-13 Jun 17, 2024
b4e3192
feat: add block button add to cart
Jun 17, 2024
b6be0ef
feat: add styles cart page
Jun 17, 2024
f52381d
feat: add add to cart button into product card
Friday-13 Jun 17, 2024
91a4ec4
feat(about us page): add contributions, change images
dashaborzova Jun 17, 2024
b7764ba
feat(about us page): add contributions, change images
dashaborzova Jun 17, 2024
3b48233
Merge pull request #210 from Friday-13/RSS-ECOMM-4_19
InStageTwo Jun 17, 2024
2b002b4
Merge branch 'release/basket-about_us' of github.com:Friday-13/eComme…
Friday-13 Jun 17, 2024
bbd542b
Merge branch 'release/basket-about_us' of github.com:Friday-13/eComme…
Friday-13 Jun 17, 2024
3459062
Merge branch 'feat/add-remove-product-cart' of github.com:Friday-13/e…
Friday-13 Jun 17, 2024
982e258
feat: add empty cart message with link to catalog page
Friday-13 Jun 17, 2024
dd57412
Merge pull request #212 from Friday-13/feat/RSS-ECOMM-4_14
Friday-13 Jun 17, 2024
0e2fa90
Merge branch 'release/basket-about_us' of github.com:Friday-13/eComme…
Friday-13 Jun 17, 2024
60aff53
Merge branch 'feat/catalog-page' of github.com:Friday-13/eCommerce-Ap…
Friday-13 Jun 17, 2024
844cfe9
feat: add update total price method
Friday-13 Jun 17, 2024
3b88a77
feat: show discounted price only when discount applyed
Friday-13 Jun 18, 2024
0c031cc
feat: add fetching actual promocodes to main
Friday-13 Jun 18, 2024
a8a49e9
feat: add register user
Jun 18, 2024
5586435
Merge pull request #213 from Friday-13/feat/RSS-ECOMM-4_16
Friday-13 Jun 18, 2024
3f8b300
Merge branch 'feat/basket-page' of github.com:Friday-13/eCommerce-App…
Jun 18, 2024
fe5d817
Merge pull request #214 from Friday-13/feat/add-remove-product-cart
Golosova76 Jun 18, 2024
1c48691
feat: add delete product
Jun 18, 2024
c1f0ef4
feat: add delete product
Golosova76 Jun 18, 2024
c303856
Merge branch 'feat/add-remove-product-cart' of github.com:Friday-13/e…
Friday-13 Jun 18, 2024
8ce09a7
feat: add updating anonymus cart, add creating anonymus cart
Friday-13 Jun 18, 2024
f1a81a7
feat: add removing product from anonymus cart
Friday-13 Jun 18, 2024
f2f3379
feat: add creating castomer cart
Friday-13 Jun 19, 2024
8474c24
feat: add cart merging
Friday-13 Jun 19, 2024
17719b3
refactor: refactor style about us page
Jun 19, 2024
29c2660
feat: add adaptive page about
Jun 19, 2024
afc6719
refactor: refactor basket api on packet content
Friday-13 Jun 19, 2024
bd0ac6d
feat: add count digits
Jun 19, 2024
3d82ae4
feat: add jest test cookie
Jun 19, 2024
0bffbbd
feat: add promocodes applying
Friday-13 Jun 19, 2024
7d9ce37
fix: load basket only after cart creating
Friday-13 Jun 19, 2024
ae81290
feat: add updating summary on removing
Friday-13 Jun 19, 2024
780a529
refactor: make cartdata optional
Friday-13 Jun 19, 2024
7fe6092
refactor: return Cartdata value
Friday-13 Jun 19, 2024
d0ee88f
feat: change product per page number
Friday-13 Jun 19, 2024
80a3624
Merge branch 'feat/catalog-page' of github.com:Friday-13/eCommerce-Ap…
Friday-13 Jun 19, 2024
210e224
Merge pull request #215 from Friday-13/feat/RSS-ECOMM-4_01
Friday-13 Jun 19, 2024
b077303
Merge pull request #216 from Friday-13/feat/catalog-page
Friday-13 Jun 19, 2024
b7f6d81
Merge branch 'release/basket-about_us' of github.com:Friday-13/eComme…
Friday-13 Jun 19, 2024
62b08c6
Merge pull request #217 from Friday-13/fix/basket-configuration
Friday-13 Jun 19, 2024
de9094b
Merge branch 'feat/add-remove-product-cart' of github.com:Friday-13/e…
Friday-13 Jun 19, 2024
683e41e
feat: add adding product from catalog
Friday-13 Jun 19, 2024
2c0a0fd
feat: add checking if current product is already inside the cart
Friday-13 Jun 19, 2024
927e75c
feat: add adding/removing product quantity
Friday-13 Jun 19, 2024
cdb23cd
refactor: rewrire product page with current-cart implementation
Friday-13 Jun 19, 2024
87705a6
feat: add clear cart layout
Friday-13 Jun 19, 2024
45bf9fb
feat: add removing cart and creatin new
Friday-13 Jun 19, 2024
407ecab
fix: fix export error
Friday-13 Jun 19, 2024
6c919e6
feat: add hiding/showing submit block on summary
Friday-13 Jun 19, 2024
8e5646a
feat: add updating cart view after delating products
Friday-13 Jun 19, 2024
469f9e9
Merge pull request #218 from Friday-13/feat/basket-page
Golosova76 Jun 19, 2024
8dfae6f
feat(profile): add editing personal info via api
dashaborzova Jun 24, 2024
4325f77
feat: add delete button product
Golosova76 Jun 25, 2024
2780e2a
feat: add parallax effect to main page, add section with store name a…
Friday-13 Jun 25, 2024
f749a19
refactor: apply prettier to styles
Friday-13 Jun 25, 2024
295817b
test: fix cookie test
Friday-13 Jun 25, 2024
7aa8d1c
Merge pull request #219 from Friday-13/feat/delete-button-page-product
Friday-13 Jun 25, 2024
a47b45a
feat: add remove product from cart functionality to product page
Friday-13 Jun 25, 2024
3d83156
Merge pull request #221 from Friday-13/feat/main-enhancement
Friday-13 Jun 25, 2024
9bba9e7
fix: fix locking body after checkout between pages
Friday-13 Jun 25, 2024
570ce23
fix: add updating empty cart message for anonymus cart
Friday-13 Jun 25, 2024
8c21666
feat(profile): password change
dashaborzova Jun 25, 2024
7573cb1
fix: fix total price calculating, add quantity influence
Friday-13 Jun 25, 2024
60fa278
fix: remove the entire quantity of a product from the product page
Friday-13 Jun 25, 2024
45f8dc4
Merge branch 'release/basket-about_us' of github.com:Friday-13/eComme…
Friday-13 Jun 25, 2024
b473efc
fix: add relogin after changing password
Friday-13 Jun 26, 2024
56e7f99
feat: turn off client logger
Friday-13 Jun 26, 2024
041ab38
feat(profile): add password change
dashaborzova Jun 26, 2024
4c1e2e4
Merge pull request #222 from Friday-13/fix/basket-page
Friday-13 Jun 26, 2024
ca2fde6
Merge branch 'release/basket-about_us' of https://github.com/Friday-1…
dashaborzova Jun 26, 2024
edd27fc
Merge pull request #223 from Friday-13/profile/refactor
InStageTwo Jun 26, 2024
e693bac
feat: add card style to product-page
Friday-13 Jun 26, 2024
0ee0b17
docs(readme): add lego in description and materilize
dashaborzova Jun 27, 2024
27993d9
Merge pull request #224 from Friday-13/final-readme
Friday-13 Jun 27, 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
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
# eCommerce Application

Welcome to eCommerce application🛍️! This platform replicates real-world shopping experiences in a digital environment.
The project is a part of the final task of the course [JavaScript/Front-end 2023Q4](https://rs.school/courses/javascript-mentoring-program) from the [RS School](https://rs.school/).
The project is a part of the final task of the course [JavaScript/Front-end 2023Q4](https://rs.school/courses/javascript-mentoring-program) from the [RS School](https://rs.school/). It features the implementation of an online store for LEGO products, offering a diverse range of items.

## Deploy

[codecraft-lego](https://codecraft-lego.netlify.app/)

## Key pages in the application include:

Expand All @@ -22,6 +26,7 @@ The project is a part of the final task of the course [JavaScript/Front-end 2023
- Jest [docs](https://jestjs.io/docs/getting-started)
- SCSS [docs](https://sass-lang.com/documentation/)
- CommerceTools API [docs](https://docs.commercetools.com/api/general-concepts)
- Materialize [dosc](https://materializecss.com/getting-started.html)
- Teamwork tools:
- Prettier [docs](https://prettier.io/docs/en/)
- Husky [docs](https://typicode.github.io/husky/)
Expand Down
41 changes: 34 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
"dependencies": {
"@commercetools/platform-sdk": "^7.8.0",
"@commercetools/sdk-client-v2": "^2.5.0",
"@commercetools/sdk-middleware-auth": "^7.0.1",
"@types/node-fetch": "^2.6.11",
"dotenv": "^16.4.5",
"isomorphic-fetch": "^3.0.0",
Expand Down
29 changes: 27 additions & 2 deletions src/app/app.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import currentCart from '@services/current-cart';
import isPageAccessable from '@utils/access-control';
import CookieManager from '@utils/cookie';

import {
Error404,
MainPageView,
Expand All @@ -10,6 +13,9 @@ import {
MainView,
FooterView,
ProductPageView,
BasketPageView,
AboutUsView,
PasswordChangeView,
} from '@views/index';

type Page =
Expand All @@ -18,7 +24,9 @@ type Page =
| RegistrationView
| LoginView
| ProfileView
| CatalogPageView;
| CatalogPageView
| AboutUsView
| PasswordChangeView;

class App {
private headerView: HeaderView;
Expand All @@ -35,6 +43,9 @@ class App {

window.addEventListener('hashchange', this.route);
window.addEventListener('load', this.route);

const userId = CookieManager.getUserId();
currentCart.initCurrentCart(userId);
}

private addHeader(): void {
Expand Down Expand Up @@ -73,6 +84,7 @@ class App {

if (route === 'product' && productId) {
this.hideFooterHeader = false;

this.mainView.page = new ProductPageView(productId);
} else {
switch (window.location.hash) {
Expand All @@ -98,11 +110,24 @@ class App {
this.mainView.page = new ProfileView();
}
break;
case '#change':
if (isPageAccessable('authorized')) {
this.hideFooterHeader = false;
this.mainView.page = new PasswordChangeView();
}
break;
case '#catalog':
this.hideFooterHeader = false;
this.mainView.page = new CatalogPageView();
break;

case '#cart':
this.hideFooterHeader = false;
this.mainView.page = new BasketPageView();
break;
case '#about-us':
this.hideFooterHeader = false;
this.mainView.page = new AboutUsView();
break;
case '#error':
this.hideFooterHeader = true;
this.mainView.page = new Error404();
Expand Down
38 changes: 38 additions & 0 deletions src/app/components/card-component.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import { BaseComponent } from './base-component';

export interface ICardAttributes {
imageSrc?: string;
title?: string;
description?: string;
inputValue?: string;
href?: string;
bio?: string;
}

export class CardComponent extends BaseComponent {
protected card: BaseComponent;

constructor(data: Partial<ICardAttributes> = {}) {
const { description = '' } = data;

super({ tag: 'div', classList: ['col', 's12', 'm4', 'center-align'] });

const card = new BaseComponent({ tag: 'div', classList: ['card'] });
this.card = card;
this.appendChild(this.card);

if (description !== '') {
const cardContent = new BaseComponent({
tag: 'div',
classList: ['card-content'],
});
card.appendChild(cardContent);

const contentParagraph = new BaseComponent({
tag: 'p',
content: description,
});
cardContent.appendChild(contentParagraph);
}
}
}
1 change: 1 addition & 0 deletions src/app/components/input-component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export class InputComponent extends BaseComponent<HTMLInputElement> {
mergedAttrs.type = attrs.type ? attrs.type : 'text';
if (mergedAttrs.id) {
this.node.id = mergedAttrs.id;
this.node.autocomplete = 'on';
}

if (mergedAttrs.required) {
Expand Down
76 changes: 76 additions & 0 deletions src/app/models/cart.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
export interface ICartData {
id: string;
version: number;
createdBy: {
anonymousId: string;
};
customerId?: string;
customerEmail?: string;
anonymousId?: string;
lineItems: ILineItem[];
totalLineItemQuantity?: number;
totalPrice: ITotalPrice;
cartState: 'Active' | 'Merged' | 'Ordered';
discountCodes: IDiscountCode[];
discountOnTotalPrice?: IDiscountOnTotalPrice;
}

export interface ILineItem {
id: string;
productId: string;
name: string;
variant: IVariant;
price: IPrice;
quantity: number;
totalPrice: IMoney;
discountedPricePerQuantity: IDiscountedLineItemPriceForQuantity[];
}

export interface IVariant {
id: number;
sku?: string;
prices: IPrices[];
images: { url: string }[];
}

export interface IPrice {
value: IMoney;
}

export interface IPrices {
value: IMoney;
discounted?: IDiscounted | null;
}

export interface IMoney {
currencyCode: string;
centAmount: number;
fractionDigits: number;
}

export interface IDiscounted {
value: IMoney;
}

export interface ITotalPrice {
currencyCode: string;
centAmount: number;
fractionDigits: number;
}

export interface IDiscountedLineItemPriceForQuantity {
quantity: number;
discountedPrice: {
value: IMoney;
};
}

interface IDiscountCode {
id: string;
code: string;
}

interface IDiscountOnTotalPrice {
discount: IPrice;
discountedAmount: IPrice;
}
4 changes: 2 additions & 2 deletions src/app/models/customer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export interface ICustomerBase {
lastName?: string;
}

const CUSTOMER_KEY = 'codecraftCustomer';
const CUSTOMER_KEY = 'codecraft-customer';

export const saveCustomerToken = (customer: ICustomerBase) => {
localStorage.setItem(CUSTOMER_KEY, JSON.stringify(customer));
Expand Down Expand Up @@ -40,6 +40,6 @@ export const customerTokenResponse = (
return customerToken;
};

export const customerClear = () => {
export const clearCustomer = () => {
localStorage.removeItem(CUSTOMER_KEY);
};
3 changes: 1 addition & 2 deletions src/app/models/products.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,11 @@ export interface IAttributeProducts {
value: string | number;
}

interface ILocalizedString {
export interface ILocalizedString {
[key: string]: string;
}

export interface ICurrent {
id: string;
name: ILocalizedString;
description?: ILocalizedString;
masterVariant: {
Expand Down
38 changes: 38 additions & 0 deletions src/app/services/add-product-cart.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import { ClientResponse, Cart } from '@commercetools/platform-sdk';
import ApiRoot from './api-root';

// Отправляет запрос на добавление товара в корзину
// При успешном добавлении товара вызывает successCallback с обновленными данными корзины
// eslint-disable-next-line import/prefer-default-export
export const addProductToCart = (
cartId: string,
cartVersion: number,
productId: string,
quantity: number,
successCallback: (cartData: Cart) => void,
errorCallback: (message: string) => void
): void => {
ApiRoot.root
.carts()
.withId({ ID: cartId })
.post({
body: {
version: cartVersion,
actions: [
{
action: 'addLineItem',
productId,
quantity,
},
],
},
})
.execute()
.then((response: ClientResponse<Cart>) => {
const cartData: Cart = response.body;
successCallback(cartData);
})
.catch((error: ClientResponse<{ message: string }>) => {
errorCallback(error.body.message);
});
};
Loading