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

feat: add sales channels page in seller center and modal in products page in seller center #670

Merged
merged 45 commits into from
Jun 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
176eadf
feat: custom store changes
albertfolch-redeemeum May 26, 2023
53eb0d9
fix: additional footer links
albertfolch-redeemeum May 29, 2023
8d3f2a2
wip
albertfolch-redeemeum May 30, 2023
c1be93b
Merge branch 'main' into sell-everywhere
albertfolch-redeemeum May 30, 2023
216348f
feat: token gating screen
albertfolch-redeemeum May 30, 2023
f8c0281
feat: add sales channels page in seller center
albertfolch-redeemeum May 30, 2023
24825cf
Merge branch 'main' into sell-everywhere
albertfolch-redeemeum May 30, 2023
0587248
feat: improve sales channels cards
albertfolch-redeemeum May 30, 2023
08bed72
Merge branch 'main' into sell-everywhere
albertfolch-redeemeum May 31, 2023
ac6659d
feat: congratulations page
albertfolch-redeemeum May 31, 2023
f3516b9
fix: footer styles
albertfolch-redeemeum Jun 1, 2023
8a32972
feat: build more pages
albertfolch-redeemeum Jun 2, 2023
a36229f
feat: products
albertfolch-redeemeum Jun 2, 2023
b1b8446
wip
albertfolch-redeemeum Jun 2, 2023
cd3e601
wip
albertfolch-redeemeum Jun 6, 2023
cc67f58
fix: bug crash
albertfolch-redeemeum Jun 6, 2023
7fcbe17
wip
albertfolch-redeemeum Jun 7, 2023
921cc06
wip
albertfolch-redeemeum Jun 7, 2023
f52e3f9
wip
albertfolch-redeemeum Jun 8, 2023
39a0f62
wip
albertfolch-redeemeum Jun 8, 2023
a0bf635
help section
albertfolch-redeemeum Jun 9, 2023
18d3c85
fix sales channels column and fetching
albertfolch-redeemeum Jun 9, 2023
5595cc3
copies and images
albertfolch-redeemeum Jun 9, 2023
b796529
font changes create product
albertfolch-redeemeum Jun 12, 2023
e7e0d7b
support for non-meta tx
albertfolch-redeemeum Jun 12, 2023
ba420d4
fix layout
albertfolch-redeemeum Jun 12, 2023
d0c2ca2
fix spinner sales channels
albertfolch-redeemeum Jun 12, 2023
691e09d
attempt to fix owner query for nonexisten token
albertfolch-redeemeum Jun 12, 2023
3b5685d
sales channels with products
albertfolch-redeemeum Jun 12, 2023
03994fa
Merge branch 'main' into sell-everywhere
albertfolch-redeemeum Jun 12, 2023
a673007
lastupdated divided by 1000
albertfolch-redeemeum Jun 12, 2023
f75f00f
wip
albertfolch-redeemeum Jun 12, 2023
23a3a28
works
albertfolch-redeemeum Jun 12, 2023
f204343
wip
albertfolch-redeemeum Jun 12, 2023
d800864
fix
albertfolch-redeemeum Jun 13, 2023
037a660
fix
albertfolch-redeemeum Jun 13, 2023
848ce6b
spinner
albertfolch-redeemeum Jun 13, 2023
122435d
reload button in products page
albertfolch-redeemeum Jun 13, 2023
e764539
stop propagation
albertfolch-redeemeum Jun 13, 2023
4f42299
some fixes
albertfolch-redeemeum Jun 13, 2023
973a1f7
token gating
albertfolch-redeemeum Jun 13, 2023
36bb412
token gating
albertfolch-redeemeum Jun 13, 2023
bfdcc19
carousel loading
albertfolch-redeemeum Jun 13, 2023
121e12b
carousel swipeable
albertfolch-redeemeum Jun 13, 2023
6879837
redesign token gating form
albertfolch-redeemeum Jun 15, 2023
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
1,677 changes: 1,602 additions & 75 deletions package-lock.json

Large diffs are not rendered by default.

6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,15 @@
},
"dependencies": {
"@bosonprotocol/chat-sdk": "^1.3.1-alpha.1",
"@bosonprotocol/react-kit": "^0.17.3",
"@bosonprotocol/react-kit": "^0.17.4-alpha.2",
"@davatar/react": "^1.10.4",
"@ethersproject/address": "^5.6.1",
"@ethersproject/units": "^5.6.1",
"@glidejs/glide": "^3.5.2",
"@graphql-codegen/fragment-matcher": "^3.3.1",
"@popperjs/core": "^2.11.5",
"@radix-ui/react-dropdown-menu": "^2.0.5",
"@radix-ui/react-icons": "^1.3.0",
"@radix-ui/react-progress": "^1.0.0",
"@radix-ui/react-switch": "^1.0.2",
"@radix-ui/react-toast": "^1.0.0",
Expand Down Expand Up @@ -105,7 +107,7 @@
"react-router-dom": "^6.4.0",
"react-scripts": "^5.0.1",
"react-select": "^5.4.0",
"react-swipeable": "^7.0.0",
"react-swipeable": "^7.0.1",
"react-table": "^7.8.0",
"react-uuid": "^1.0.3",
"rehype-raw": "^6.1.1",
Expand Down
41 changes: 0 additions & 41 deletions src/components/Layout.tsx

This file was deleted.

28 changes: 24 additions & 4 deletions src/components/app/index.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import { IconContext } from "phosphor-react";
import { Fragment } from "react";
import { Fragment, ReactNode, useMemo } from "react";
import styled, { ThemeProvider } from "styled-components";

import Layout from "../../components/Layout";
import ModalProvider from "../../components/modal/ModalProvider";
import GlobalStyle from "../../lib/styles/GlobalStyle";
import ChatProvider from "../../pages/chat/ChatProvider/ChatProvider";
Expand All @@ -11,6 +10,7 @@ import theme from "../../theme";
import CookieBanner from "../cookie/CookieBanner";
import Footer from "../footer/Footer";
import Header from "../header/Header";
import Layout, { LayoutProps } from "../layout/Layout";

const Container = styled.div`
width: 100%;
Expand All @@ -25,12 +25,29 @@ const Container = styled.div`

interface Props {
children: JSX.Element;
withHeader?: boolean;
withLayout?: boolean;
withFullLayout?: boolean;
withFooter?: boolean;
fluidHeader?: boolean;
withBosonStyles?: boolean;
}

const getLayoutWrapper =
(fullWidth: LayoutProps["fullWidth"]) =>
({ children }: { children: ReactNode }) =>
(
<Layout
style={{ display: "flex", flex: "1", flexDirection: "column" }}
fullWidth={fullWidth}
>
{children}
</Layout>
);

export default function App({
withHeader = true,
withFullLayout = false,
withLayout = true,
withFooter = true,
fluidHeader = false,
Expand All @@ -50,7 +67,10 @@ export default function App({
const fontFamily = useCustomStoreQueryParameter("fontFamily");
const buttonBgColor = useCustomStoreQueryParameter("buttonBgColor");
const buttonTextColor = useCustomStoreQueryParameter("buttonTextColor");
const Wrapper = withLayout ? Layout : Fragment;
const LayoutWrapper = useMemo(() => {
return getLayoutWrapper(withFullLayout);
}, [withFullLayout]);
const Wrapper = withLayout ? LayoutWrapper : Fragment;

return (
<ThemeProvider theme={theme}>
Expand Down Expand Up @@ -78,7 +98,7 @@ export default function App({
$buttonBgColor={buttonBgColor}
$buttonTextColor={buttonTextColor}
/>
<Header fluidHeader={fluidHeader} />
{withHeader && <Header fluidHeader={fluidHeader} />}
<Wrapper>{children}</Wrapper>
<Footer withFooter={withFooter} />
</Container>
Expand Down
2 changes: 1 addition & 1 deletion src/components/footer/Footer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import SocialLogo, {
import { useCustomStoreQueryParameter } from "../../pages/custom-store/useCustomStoreQueryParameter";
import useUserRoles from "../../router/useUserRoles";
import { LinkWithQuery } from "../customNavigation/LinkWithQuery";
import Layout from "../Layout";
import Layout from "../layout/Layout";
import Grid from "../ui/Grid";
import GridContainer from "../ui/GridContainer";
import Typography from "../ui/Typography";
Expand Down
6 changes: 2 additions & 4 deletions src/components/footer/routes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import {
import { isTruthy } from "../../lib/types/helpers";
import { UserRoles } from "../../router/routes";
import { checkIfUserHaveRole } from "../../router/useUserRoles";
import { DEFAULT_SELLER_PAGE } from "../seller/SellerPages";
import { getSellerCenterPath } from "../seller/paths";
import ViewTxButton from "../transactions/ViewTxButton";

export const SOCIAL_ROUTES = [
Expand Down Expand Up @@ -138,9 +138,7 @@ export const getSellRoutes = ({
) {
productRoutes.push({
name: "Seller Center",
url: generatePath(SellerCenterRoutes.SellerCenter, {
[UrlParameters.sellerPage]: DEFAULT_SELLER_PAGE
})
url: getSellerCenterPath("Dashboard")
});
}
if (
Expand Down
87 changes: 74 additions & 13 deletions src/components/form/Select.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
/* eslint @typescript-eslint/no-explicit-any: "off" */
import { useField } from "formik";
import Select from "react-select";
import Select, {
ActionMeta,
MultiValue,
SingleValue,
StylesConfig
} from "react-select";
import styled from "styled-components";

import { colors } from "../../lib/styles/colors";
Expand All @@ -13,9 +18,12 @@ const StyledSelect = styled(Select)`
* {
font-size: 13.33px;
}
[class*="-indicatorContainer"] {
padding: 6.92px; // to make selects less tall but as tall as inputs
}
` as Select;

const customStyles = (error: any) => ({
const customStyles = (error: any): StylesConfig<any, true> => ({
// eslint-disable-next-line @typescript-eslint/no-unused-vars
singleValue: (provided: any, state: any) => {
return {
Expand Down Expand Up @@ -55,7 +63,8 @@ const customStyles = (error: any) => ({
...provided,
zIndex: state.isFocused ? zIndex.Select + 1 : zIndex.Select,
position: "relative",
width: "100%"
width: "100%",
height: "25px"
}),
option: (provided: any, state: any) => ({
...provided,
Expand All @@ -72,7 +81,20 @@ const customStyles = (error: any) => ({
}),
indicatorSeparator: () => ({
display: "none"
})
}),
multiValue: (base, state) => {
return (state.data as Record<string, any>).isFixed
? { ...base, backgroundColor: colors.darkGrey }
: base;
},
multiValueLabel: (base, state) => {
return state.data.isFixed
? { ...base, fontWeight: "bold", color: colors.white, paddingRight: 6 }
: base;
},
multiValueRemove: (base, state) => {
return state.data.isFixed ? { ...base, display: "none" } : base;
}
});

export default function SelectComponent({
Expand All @@ -85,7 +107,7 @@ export default function SelectComponent({
errorMessage,
onChange,
...props
}: SelectProps) {
}: SelectProps<boolean>) {
const [field, meta, helpers] = useField(name);
const displayErrorMessage =
meta.error && meta.touched && !errorMessage
Expand All @@ -98,13 +120,50 @@ export default function SelectComponent({
typeof displayErrorMessage === typeof "string" &&
displayErrorMessage !== "";

const handleChange = (option: SelectDataProps<string>) => {
if (!meta.touched) {
helpers.setTouched(true);
}
helpers.setValue(option);
onChange?.(option);
};
let handleChange:
| ((
newValue: MultiValue<SelectDataProps<string>> | null,
actionMeta: ActionMeta<SelectDataProps<string>>
) => void)
| ((newValue: SingleValue<SelectDataProps<string> | null>) => void);
if (props.isMulti) {
handleChange = (
newValue: MultiValue<SelectDataProps<string>> | null,
actionMeta: ActionMeta<SelectDataProps<string>>
) => {
let newValueTemp: typeof newValue = newValue;
if (!meta.touched) {
helpers.setTouched(true);
}
switch (actionMeta.action) {
case "remove-value":
case "pop-value":
if (actionMeta.removedValue.isFixed) {
return;
}
break;
case "clear":
if (Array.isArray(field.value)) {
newValueTemp = (field.value as any[]).filter((v) => v.isFixed);
}
break;
}

helpers.setValue(newValueTemp);
onChange?.(newValueTemp);
};
} else {
handleChange = (newValue: SingleValue<SelectDataProps<string> | null>) => {
const newValueTemp: typeof newValue = newValue;
if (!meta.touched) {
helpers.setTouched(true);
}

helpers.setValue(newValueTemp);
onChange?.(newValueTemp);
};
}

const handleBlur = () => {
if (!meta.touched) {
helpers.setTouched(true);
Expand All @@ -120,12 +179,14 @@ export default function SelectComponent({
placeholder={placeholder}
options={options}
value={field.value}
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
onChange={handleChange}
onBlur={handleBlur}
isSearchable={isSearchable}
isClearable={isClearable}
isDisabled={disabled}
isOptionDisabled={(option) => option.disabled}
isOptionDisabled={(option) => !!option.disabled}
/>
<Error display={displayError} message={displayErrorMessage} />{" "}
</>
Expand Down
13 changes: 9 additions & 4 deletions src/components/form/types.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Dayjs } from "dayjs";
import { CSSProperties, ReactNode } from "react";
import { SingleValue } from "react-select";
import { MultiValue, SingleValue } from "react-select";

import { UploadFileType } from "./Upload/types";

Expand Down Expand Up @@ -64,6 +64,7 @@ export interface SelectDataProps<Value extends string = string> {
label: string;
value: Value;
disabled?: boolean;
isFixed?: boolean;
[others: string]: unknown;
}

Expand All @@ -80,14 +81,18 @@ export interface BaseSelectProps {
onChange?: OnChange;
}

export interface SelectProps extends BaseProps {
isMulti?: boolean;
export interface SelectProps<IsMulti extends boolean> extends BaseProps {
isMulti?: IsMulti;
disabled?: boolean;
isClearable?: boolean;
isSearchable?: boolean;
options: Array<SelectDataProps> | Readonly<Array<SelectDataProps>>;
errorMessage?: string;
onChange?: (option: SelectDataProps<string>) => void;
onChange?: (
option: IsMulti extends true
? MultiValue<SelectDataProps<string>>
: SingleValue<SelectDataProps<string>>
) => void;
label?: string;
className?: string;
classNamePrefix?: string;
Expand Down
2 changes: 1 addition & 1 deletion src/components/header/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import { useKeepQueryParamsNavigate } from "../../lib/utils/hooks/useKeepQueryPa
import { useCustomStoreQueryParameter } from "../../pages/custom-store/useCustomStoreQueryParameter";
import useUserRoles from "../../router/useUserRoles";
import { LinkWithQuery } from "../customNavigation/LinkWithQuery";
import Layout from "../Layout";
import Layout from "../layout/Layout";
import { Spinner } from "../loading/Spinner";
import { DEFAULT_SELLER_PAGE } from "../seller/SellerPages";
import BosonButton from "../ui/BosonButton";
Expand Down
11 changes: 11 additions & 0 deletions src/components/layout/Context.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { createContext, Dispatch, SetStateAction, useContext } from "react";

export const LayoutContext = createContext<{
fullWidth: boolean;
setFullWidth: Dispatch<SetStateAction<boolean>>;
}>({
fullWidth: false,
setFullWidth: () => null
});

export const useLayoutContext = () => useContext(LayoutContext);
Loading