saleor-dashboard/src/components/Shop/index.tsx
Dawid Tarasiuk 4880093f63
Use Auth SDK (#1474)
* Use Auth SDK

* Update auth provider hook

* Update sdk module mapping

* Update setting password

* Fix no user details on first login

* Update auth tests

* Cleanups

* Update SDK

Update SDK

Update SDK

Update test recordings

Update SDK

* Implement SDK External Auth

Update new password view

Hnalde external logout

Update SDK

Fix logout external redirect

* Fix login page style

* Update SDK

* Auth Provider cleanups

Update and refactor auth

Auth types cleanups and refactor

* Update channel context provider

* Fix login error handling

* Logout immidiatelly non-staff user

* Update test snapshots

* Trigger CI

* Update to SDK v0.4, remove duplicated UserContext hook

* Handle server errors during login

* Fix wrong login page form submition handling

* Update login error messages

Co-authored-by: Jakub Majorek <majorek.jakub@gmail.com>
2021-12-17 12:10:54 +01:00

43 lines
1.4 KiB
TypeScript

import appleTouchIcon from "@assets/favicons/apple-touch-icon.png";
import favicon16 from "@assets/favicons/favicon-16x16.png";
import favicon32 from "@assets/favicons/favicon-32x32.png";
import safariPinnedTab from "@assets/favicons/safari-pinned-tab.svg";
import { useUser } from "@saleor/auth";
import React from "react";
import Helmet from "react-helmet";
import { TypedShopInfoQuery } from "./query";
import { ShopInfo_shop } from "./types/ShopInfo";
type ShopContext = ShopInfo_shop;
export const ShopContext = React.createContext<ShopContext>(undefined);
export const ShopProvider: React.FC = ({ children }) => {
const { authenticated } = useUser();
return (
<TypedShopInfoQuery skip={!authenticated}>
{({ data }) => (
<>
<Helmet>
<link
rel="apple-touch-icon"
sizes="180x180"
href={appleTouchIcon}
/>
<link rel="icon" type="image/png" sizes="32x32" href={favicon32} />
<link rel="icon" type="image/png" sizes="16x16" href={favicon16} />
<link rel="mask-icon" href={safariPinnedTab} />
</Helmet>
<ShopContext.Provider value={data ? data.shop : undefined}>
{children}
</ShopContext.Provider>
</>
)}
</TypedShopInfoQuery>
);
};
export const Shop = ShopContext.Consumer;
export default Shop;