Skip to content

Redux toolkit#132

Open
coderIvanTS wants to merge 11 commits into
spirit-drive:mainfrom
coderIvanTS:ReduxToolkit
Open

Redux toolkit#132
coderIvanTS wants to merge 11 commits into
spirit-drive:mainfrom
coderIvanTS:ReduxToolkit

Conversation

@coderIvanTS
Copy link
Copy Markdown

Добавлено хранилище Redux Toolkit в котором сохраняется токен, инициация приложения, профиль, список товаров, корзина, защищенный роутинг

Иван Лайер added 11 commits June 19, 2024 21:56
import vars from './common.scss';
Вот эта конструкция после импорта не работает
vars.light_accent
Cannot read properties of undefined (reading 'light_accent')
в
… окно использует CreatePortal, в списке заполняются key.
…е в него подчиненные компоненты. Использован useLayoutEffect, addEventListener 'transitionend'
…ция приложения, профиль, список товаров, корзина, защищенный роутинг
<ProductInCart key={p} productName={p} onDeleteFromCart={handleOnDeleteFromCart}
/>
);
{productInCart && productInCart.length == 0 ?
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Давай те напишем чуть чище

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  const { productList } = useSelector((state) => state.productInCartSlice);
  const dispatch = useDispatch();

  const handleOnDeleteFromCart = (id: string) => {
    dispatch(dellFromCart(id));
  };

  if (!productList || productList.length === 0) {
    return (
      <Layout>
        <div>В корзине пусто</div>
      </Layout>
    );
  }

  return (
    <Layout>
      <div>
        {productList.map((product) => (
          <ProductInCart
            key={product.id}
            product={product}
            onDeleteFromCart={handleOnDeleteFromCart}
          />
        ))}
        <button type="button">Купить</button>
      </div>
    </Layout>
  );
};```

}

export const RoutePrivateAdmin = ({ children }: IRoutePrivateProps) => {
const token = useAppSelector(state => state.authAndProfile.auth.token)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

А токен для чего?)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants