Skip to content

Commit

Permalink
fix compilation problems
Browse files Browse the repository at this point in the history
  • Loading branch information
levalleux-ludo committed Dec 19, 2024
1 parent fe810a1 commit 11073fb
Show file tree
Hide file tree
Showing 23 changed files with 97 additions and 80 deletions.
2 changes: 1 addition & 1 deletion src/components/form/Upload/WithUploadToIpfs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ export function WithUploadToIpfs<P extends WithUploadToIpfsProps>(
return false;
}

const ipfsArray = [];
const ipfsArray: FileProps[] = [];
for (let i = 0; i < filesArray.length; i++) {
const file = filesArray[i];
const cid = await saveFile(file);
Expand Down
21 changes: 13 additions & 8 deletions src/components/modal/components/Profile/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,14 @@ export function buildProfileFromMetadata(
(img) => img.tag === "cover"
);
const isLens = useLens && lensProfile;
let lensCoverPicture = null,
lensProfileImage = null;
let lensCoverPicture: {
url: string;
type: string;
} | null = null;
let lensProfileImage: {
url: string;
type: string;
} | null = null;
if (isLens) {
const lensCoverPictureUrl = getLensCoverPictureUrl(lensProfile);
const lensCoverPictureType = lensCoverPictureUrl
Expand Down Expand Up @@ -68,17 +74,16 @@ export function buildProfileFromMetadata(
{
...coverPicture,
src: coverPicture.url,
fit: "fit" in coverPicture ? coverPicture.fit : undefined,
fit:
"fit" in coverPicture ? (coverPicture.fit as string) : undefined,
position:
"position" in coverPicture
? coverPicture.position ?? undefined
? (coverPicture.position as string) || undefined
: undefined
}
] ?? []
: [],
logo: profileImage
? [{ ...profileImage, src: profileImage.url }] ?? []
]
: [],
logo: profileImage ? [{ ...profileImage, src: profileImage.url }] : [],
contactPreference:
OPTIONS_CHANNEL_COMMUNICATIONS_PREFERENCE.find(
(obj) => obj.value === metadata?.contactPreference
Expand Down
2 changes: 1 addition & 1 deletion src/components/product/ProductImages.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ const getProductImageError = (
typeof Object.values(errors.productImages)?.[0] === "string"
? Object.values(errors.productImages)?.[0]
: null;
return error;
return String(error);
};
export default function ProductImages({ onChangeOneSetOfImages }: Props) {
const { nextIsDisabled, values, errors } = useForm();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import { Warning } from "phosphor-react";
import { useMemo } from "react";
import styled from "styled-components";

import { FileProps } from "../../form/Upload/types";
import { SectionTitle } from "../Product.styles";
import { getBundleItemName } from "../productDigital/getBundleItemName";
import {
Expand Down Expand Up @@ -310,12 +311,12 @@ export default function ConfirmProductDetails({
([name, images]) => {
if (
!images ||
!images.length ||
!images?.[0]?.src
!(images as FileProps[]).length ||
!(images as FileProps[])?.[0]?.src
) {
return null;
}
const [img] = images;
const [img] = images as FileProps[];
const imgSrc = img.src;
return (
<VariantImage src={imgSrc} key={name} />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,11 @@ export const ConfirmProductDigital: React.FC = () => {
<BundleItemWrapper>
<li>
<span>Type: </span>
{bi.type.label}
{bi.type?.label}
</li>
<li>
<span>NFT type: </span>
{bi.newNftType.label}
{bi.newNftType?.label}
</li>
<li>
<span>Name: </span>
Expand All @@ -78,7 +78,7 @@ export const ConfirmProductDigital: React.FC = () => {
</li>
<li>
<span>Buyer information required for transfer:</span>{" "}
{bi.newNftBuyerTransferInfo.label}
{bi.newNftBuyerTransferInfo?.label}
</li>
</BundleItemWrapper>
</div>
Expand All @@ -91,11 +91,11 @@ export const ConfirmProductDigital: React.FC = () => {
<BundleItemWrapper>
<li>
<span>Type: </span>
{bi.type.label}
{bi.type?.label}
</li>
<li>
<span>NFT type: </span>
{bi.mintedNftType.label}
{bi.mintedNftType?.label}
</li>
<li>
<span>ContractAddress:</span>{" "}
Expand All @@ -117,7 +117,7 @@ export const ConfirmProductDigital: React.FC = () => {
</li>
<li>
<span>Buyer information required for transfer:</span>{" "}
{bi.mintedNftBuyerTransferInfo.label}
{bi.mintedNftBuyerTransferInfo?.label}
</li>
</BundleItemWrapper>
</div>
Expand All @@ -130,7 +130,7 @@ export const ConfirmProductDigital: React.FC = () => {
<BundleItemWrapper>
<li>
<span>Type: </span>
{bi.type.label}
{bi.type?.label}
</li>
<li>
<span>Name:</span> {bi.digitalFileName}
Expand All @@ -150,7 +150,7 @@ export const ConfirmProductDigital: React.FC = () => {
</li>
<li>
<span>Buyer information required for transfer:</span>{" "}
{bi.digitalFileBuyerTransferInfo.label}
{bi.digitalFileBuyerTransferInfo?.label}
</li>
</BundleItemWrapper>
</div>
Expand All @@ -163,7 +163,7 @@ export const ConfirmProductDigital: React.FC = () => {
<BundleItemWrapper>
<li>
<span>Type: </span>
{bi.type.label}
{bi.type?.label}
</li>
<li>
<span>Name:</span> {bi.experientialName}
Expand All @@ -180,7 +180,7 @@ export const ConfirmProductDigital: React.FC = () => {
</li>
<li>
<span>Buyer information required for transfer:</span>{" "}
{bi.experientialBuyerTransferInfo.label}
{bi.experientialBuyerTransferInfo?.label}
</li>
</BundleItemWrapper>
</div>
Expand Down
7 changes: 4 additions & 3 deletions src/components/product/utils/initialValues.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
OPTIONS_PERIOD,
OPTIONS_UNIT,
OPTIONS_WEIGHT,
ProductTypeTypeValues,
TOKEN_CRITERIA,
TOKEN_TYPES
} from "./const";
Expand Down Expand Up @@ -36,9 +37,9 @@ export const createYourProfileInitialValues: CreateYourProfile = {

export const productTypeInitialValues = {
productType: {
productType: "",
productType: "" as ProductTypeTypeValues,
productVariant: "",
tokenGatedOffer: ""
tokenGatedOffer: "false"
}
} as const;

Expand Down Expand Up @@ -176,7 +177,7 @@ export const shippingInfoInitialValues = {

export const imagesSpecificOrAllInitialValues = {
imagesSpecificOrAll: {
value: "all",
value: "all" as NonNullable<"all" | "specific" | undefined>,
label: "All"
}
};
Expand Down
53 changes: 27 additions & 26 deletions src/components/product/utils/validationSchema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ import {
import { Dayjs } from "dayjs";
import { ethers } from "ethers";
import { checkValidUrl, notUrlErrorMessage } from "lib/validation/regex/url";
import { ValidationError } from "yup";
import { AnyObject } from "yup/lib/types";
import { AnyObject, ValidationError } from "yup";

import { validationMessage } from "../../../lib/constants/validationMessage";
import { fixformattedString } from "../../../lib/utils/number";
Expand Down Expand Up @@ -118,7 +117,7 @@ const getBundleItemsMedia = ({
Yup.object({
image: validationOfIpfsImage(),
video: validationOfIpfsImage()
}).nullable(true)
}).nullable()
).test(
"invalidBundleItemsMedia",
"Please add an image for new NFTs",
Expand Down Expand Up @@ -347,7 +346,7 @@ const transferCriteria = Yup.string().required(validationMessage.required);
const transferTime = Yup.number()
.min(0, "It cannot be negative")
.required(validationMessage.required)
.nullable(true);
.nullable();
const transferTimeUnit = Yup.object({
value: Yup.string(),
label: Yup.string()
Expand All @@ -362,7 +361,7 @@ const buyerTransferInfo = Yup.object({
label: Yup.string()
})
.required(validationMessage.required)
.nullable(true);
.nullable();
const testTokenAddress = async function ({
tokenType,
coreSDK,
Expand Down Expand Up @@ -472,7 +471,7 @@ const commonFieldsBundleItem = {
label: Yup.string()
})
.required(validationMessage.required)
.nullable(true)
.nullable()
.default(undefined),
isNftMintedAlready: Yup.object({
value: Yup.string().oneOf(
Expand All @@ -488,7 +487,7 @@ const commonFieldsBundleItem = {
otherwise: (schema) => schema
})
.default(undefined)
.nullable(true)
.nullable()
};
const nftType = Yup.object({
value: Yup.string()
Expand All @@ -497,7 +496,7 @@ const nftType = Yup.object({
label: Yup.string()
})
.required(validationMessage.required)
.nullable(true);
.nullable();
const getExistingNftSchema = ({ coreSDK }: { coreSDK: CoreSDK }) =>
Yup.object({
...commonFieldsBundleItem,
Expand All @@ -511,7 +510,7 @@ const getExistingNftSchema = ({ coreSDK }: { coreSDK: CoreSDK }) =>
label: Yup.string()
})
.required(validationMessage.required)
.nullable(true)
.nullable()
.default([{ value: "", label: "" }]),
mintedNftContractAddress: Yup.string()
.required(validationMessage.required)
Expand Down Expand Up @@ -690,30 +689,32 @@ export const commonCoreTermsOfSaleValidationSchema = {
offerValidityPeriod: Yup.mixed<Dayjs | Dayjs[]>()
.when("infiniteExpirationOffers", {
is: true,
then: Yup.mixed<Dayjs>()
.required(validationMessage.required)
.defined(validationMessage.required),
otherwise: Yup.mixed<Dayjs[]>()
.required(validationMessage.required)
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
.isOfferValidityDatesValid()
then: (schema) =>
schema
.required(validationMessage.required)
.defined(validationMessage.required),
otherwise: (schema) =>
schema
.required(validationMessage.required)
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
.isOfferValidityDatesValid()
})
.required(validationMessage.required),
redemptionPeriod: Yup.mixed<Dayjs | Dayjs[]>().when(
"infiniteExpirationOffers",
{
is: true,
then: Yup.mixed<Dayjs>().optional(),
then: (schema) => schema.optional(),
// .required(validationMessage.required)
// .defined(validationMessage.required),
otherwise: Yup.mixed<Dayjs[]>()
// Yup.array<Dayjs>()
.required(validationMessage.required)
// .min(2, validationMessage.required)
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
.isRedemptionDatesValid()
otherwise: (schema) =>
schema
.required(validationMessage.required)
// .min(2, validationMessage.required)
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
.isRedemptionDatesValid()
}
),
voucherValidDurationInDays: Yup.number().when("infiniteExpirationOffers", {
Expand All @@ -723,7 +724,7 @@ export const commonCoreTermsOfSaleValidationSchema = {
.required(validationMessage.required)
.min(1, "It has to be 1 at least");
},
otherwise: Yup.number().min(0, "It must be 0").max(0, "It must be 0")
otherwise: (schema) => schema.min(0, "It must be 0").max(0, "It must be 0")
})
};

Expand Down
4 changes: 2 additions & 2 deletions src/components/searchModal/CurrencySearchModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import Modal from "components/modal/Modal";
import TokenSafety from "components/tokenSafety";
import { useLast } from "lib/utils/hooks/useLast";
import { useWindowSize } from "lib/utils/hooks/useWindowSize";
import { memo, useCallback, useEffect, useState } from "react";
import { memo, ReactElement, useCallback, useEffect, useState } from "react";
import { useUserAddedTokens } from "state/user/hooks";
import styled from "styled-components";

Expand Down Expand Up @@ -84,7 +84,7 @@ export default memo(function CurrencySearchModal({
const { height: windowHeight } = useWindowSize();
// change min height if not searching
let modalHeight: number | undefined = 80;
let content = null;
let content: ReactElement | null = null;
switch (modalView) {
case CurrencyModalView.search:
if (windowHeight) {
Expand Down
5 changes: 3 additions & 2 deletions src/components/tokenSafety/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import { ExplorerDataType, getExplorerLink } from "lib/utils/getExplorerLink";
import { useToken } from "lib/utils/hooks/Tokens";
import { ArrowSquareOut as LinkIconFeather, Copy } from "phosphor-react";
import { lighten } from "polished";
import { ReactElement } from "react-markdown/lib/react-markdown";
import { useAddUserToken } from "state/user/hooks";
import styled from "styled-components";

Expand Down Expand Up @@ -230,8 +231,8 @@ export default function TokenSafety({
onBlocked,
showCancel
}: TokenSafetyProps) {
const logos = [];
const urls = [];
const logos: ReactElement[] = [];
const urls: ReactElement[] = [];

const token1Warning = tokenAddress ? checkWarning(tokenAddress) : null;
const token1 = useToken(tokenAddress);
Expand Down
5 changes: 3 additions & 2 deletions src/lib/constants/tokenSafety.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { constants } from "ethers";
import { ReactElement } from "react";

import { NATIVE_CHAIN_ID } from "./tokens";
import tokenSafetyLookup, { TOKEN_LIST_TYPES } from "./tokenSafetyLookup";
Expand All @@ -13,8 +14,8 @@ export enum WARNING_LEVEL {
}

export function getWarningCopy(warning: Warning | null, plural = false) {
let heading = null,
description = null;
let heading: ReactElement | null = null,
description: ReactElement | null = null;
if (warning) {
switch (warning.level) {
case WARNING_LEVEL.MEDIUM:
Expand Down
2 changes: 1 addition & 1 deletion src/lib/utils/files.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ export type FileWithEncodedData = File & { encodedData: string };
export const getFilesWithEncodedData = async (
files: File[]
): Promise<FileWithEncodedData[]> => {
const promises = [];
const promises: Array<Promise<FileWithEncodedData>> = [];
for (const file of files as FileWithEncodedData[]) {
promises.push(
new Promise<FileWithEncodedData>((resolve, reject) => {
Expand Down
Loading

0 comments on commit 11073fb

Please sign in to comment.