Skip to content

Commit

Permalink
chore(launchpad): Clean TSX
Browse files Browse the repository at this point in the history
  • Loading branch information
WaDadidou committed Jan 7, 2025
1 parent 8f25d69 commit ce9dd57
Show file tree
Hide file tree
Showing 28 changed files with 110 additions and 158 deletions.
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import React, { FC } from "react";
import { FC } from "react";
import { TouchableOpacity, Image, StyleProp, ViewStyle } from "react-native";

import { neutral77, secondaryColor } from "../../../utils/style/colors";
import { fontSemibold11, fontSemibold13 } from "../../../utils/style/fonts";
import { layout } from "../../../utils/style/layout";
import { BrandText } from "../../BrandText";
import { PrimaryBox } from "../../boxes/PrimaryBox";

import { neutral77, secondaryColor } from "@/utils/style/colors";
import { fontSemibold11, fontSemibold13 } from "@/utils/style/fonts";
import { layout } from "@/utils/style/layout";

export const itemSize = 120;
export const ItemView: FC<{
label: string;
Expand Down Expand Up @@ -47,10 +48,8 @@ export const ItemView: FC<{

<PrimaryBox
style={{
// borderRadius: 32,
paddingHorizontal: layout.spacing_x1,
paddingVertical: layout.spacing_x0_5,
// height: 34,
width: itemSize - 10,
bottom: -20,
alignItems: "center",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from "react";
import { FC } from "react";
import { View } from "react-native";

import { itemSize, ItemView } from "./ItemView";
Expand All @@ -12,7 +12,7 @@ import { fontSemibold20 } from "@/utils/style/fonts";
import { layout } from "@/utils/style/layout";
import { LocalFileData } from "@/utils/types/files";

export const SelectedFilesPreview: React.FC<{
export const SelectedFilesPreview: FC<{
files: LocalFileData[];
onPressItem: (file: LocalFileData, itemIndex: number) => void;
onPressDeleteItem: (itemIndex: number) => void;
Expand Down
20 changes: 10 additions & 10 deletions packages/components/NetworkSelector/NetworkSelectorWithLabel.tsx
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
import React, { useState } from "react";
import { FC, useState } from "react";
import { StyleProp, View, ViewStyle } from "react-native";

import { NetworkSelectorMenu } from "./NetworkSelectorMenu";
import chevronDownSVG from "../../../assets/icons/chevron-down.svg";
import chevronUpSVG from "../../../assets/icons/chevron-up.svg";
import { useDropdowns } from "../../hooks/useDropdowns";
import { useSelectedNetworkInfo } from "../../hooks/useSelectedNetwork";
import { NetworkFeature, NetworkKind } from "../../networks";
import { neutral17, neutral77, secondaryColor } from "../../utils/style/colors";
import { fontSemibold14 } from "../../utils/style/fonts";
import { layout } from "../../utils/style/layout";
import { BrandText } from "../BrandText";
import { SVG } from "../SVG";
import { TertiaryBox } from "../boxes/TertiaryBox";
import { Label } from "../inputs/TextInputCustom";

import chevronDownSVG from "@/assets/icons/chevron-down.svg";
import chevronUpSVG from "@/assets/icons/chevron-up.svg";
import { NetworkIcon } from "@/components/NetworkIcon";
import { CustomPressable } from "@/components/buttons/CustomPressable";
import { SpacerRow } from "@/components/spacer";
import { useDropdowns } from "@/hooks/useDropdowns";
import { useSelectedNetworkInfo } from "@/hooks/useSelectedNetwork";
import { NetworkFeature, NetworkKind } from "@/networks";
import { neutral17, neutral77, secondaryColor } from "@/utils/style/colors";
import { fontSemibold14 } from "@/utils/style/fonts";
import { layout } from "@/utils/style/layout";

export const NetworkSelectorWithLabel: React.FC<{
export const NetworkSelectorWithLabel: FC<{
label: string;
style?: StyleProp<ViewStyle>;
forceNetworkId?: string;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
import React from "react";
import { Linking, TextStyle, View } from "react-native";

import {
LargeBoxButton,
LargeBoxButtonProps,
} from "../../../components/buttons/LargeBoxButton";

import LaunchpadBannerImage from "@/assets/banners/launchpad.jpg";
import { BrandText } from "@/components/BrandText";
import { ImageBackgroundLogoText } from "@/components/ImageBackgroundLogoText";
import { OmniLink } from "@/components/OmniLink";
import { ScreenContainer } from "@/components/ScreenContainer";
import { CustomPressable } from "@/components/buttons/CustomPressable";
import {
LargeBoxButton,
LargeBoxButtonProps,
} from "@/components/buttons/LargeBoxButton";
import { SpacerColumn } from "@/components/spacer";
import { useMaxResolution } from "@/hooks/useMaxResolution";
import { ScreenFC } from "@/utils/navigation";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { zodResolver } from "@hookform/resolvers/zod";
import React, { useMemo, useState } from "react";
import { useMemo, useState } from "react";
import { FormProvider, useForm } from "react-hook-form";
import { View } from "react-native";
import { useSelector } from "react-redux";
Expand Down Expand Up @@ -80,9 +80,6 @@ export const LaunchpadCreateScreen: ScreenFC<"LaunchpadCreate"> = () => {
}, [selectedStepKey]);

const onValid = async () => {
// TODO: Remove console.log when ready to merge
console.log("==== collectionForm.getValues()", collectionForm.getValues());

setLoading(true);
setLoadingFullScreen(true);
try {
Expand All @@ -100,10 +97,6 @@ export const LaunchpadCreateScreen: ScreenFC<"LaunchpadCreate"> = () => {
};

const onInvalid = () => {
// TODO: Remove console.log when ready to merge
console.log("==== collectionForm.getValues()", collectionForm.getValues());
console.log("xxxxx collectionForm.formState", collectionForm.formState);

setToast({
mode: "normal",
type: "error",
Expand Down Expand Up @@ -174,12 +167,7 @@ export const LaunchpadCreateScreen: ScreenFC<"LaunchpadCreate"> = () => {
text="Submit Collection"
loader
isLoading={isLoading}
disabled={
isLoading ||
// TODO: Remove this condition when useCompleteCollection and MyCollections frontend are merged
!collectionForm.getValues().assetsMetadatas?.assetsMetadatas
?.length
}
disabled={isLoading}
onPress={onPressSubmit}
/>
) : (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { Dispatch, FC, useRef } from "react";
import { Dispatch, FC, SetStateAction, useRef } from "react";
import { useFormContext } from "react-hook-form";
import {
LayoutChangeEvent,
Expand Down Expand Up @@ -28,7 +28,7 @@ export type LaunchpadCreateStepKey = number;

interface LaunchpadStepperProps {
selectedStepKey: LaunchpadCreateStepKey;
setSelectedStepKey: Dispatch<React.SetStateAction<LaunchpadCreateStepKey>>;
setSelectedStepKey: Dispatch<SetStateAction<LaunchpadCreateStepKey>>;
}

interface LaunchpadCreateStep {
Expand Down Expand Up @@ -175,15 +175,13 @@ export const LaunchpadStepper: FC<LaunchpadStepperProps> = ({
if (isSelected) onSelectedItemLayout(e);
}}
onPress={() => setSelectedStepKey(step.key)}
style={[
{
flexDirection: "row",
alignItems: "center",
justifyContent: "center",
paddingHorizontal: layout.spacing_x2,
paddingVertical: layout.spacing_x1,
},
]}
style={{
flexDirection: "row",
alignItems: "center",
justifyContent: "center",
paddingHorizontal: layout.spacing_x2,
paddingVertical: layout.spacing_x1,
}}
>
<View
style={{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import React, { FC } from "react";
import { FC } from "react";
import { Controller, useFormContext } from "react-hook-form";
import { View } from "react-native";

import { SelectInputLaunchpad } from "../../../components/inputs/selectInputs/SelectInputLaunchpad";

import { BrandText } from "@/components/BrandText";
import { ErrorText } from "@/components/ErrorText";
import { SpacerColumn } from "@/components/spacer";
import { TextInputLaunchpad } from "@/screens/Launchpad/LaunchpadApply/components/inputs/TextInputLaunchpad";
import { SelectInputLaunchpad } from "@/screens/Launchpad/LaunchpadApply/components/inputs/selectInputs/SelectInputLaunchpad";
import { neutral55, neutral77 } from "@/utils/style/colors";
import {
fontSemibold13,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from "react";
import { FC } from "react";
import { useFormContext } from "react-hook-form";
import { View } from "react-native";

Expand Down Expand Up @@ -29,7 +29,7 @@ import {
CollectionAssetsMetadatasFormValues,
} from "@/utils/types/launchpad";

export const AssetModal: React.FC<{
export const AssetModal: FC<{
onClose: () => void;
isVisible: boolean;
elem: CollectionAssetsMetadataFormValues;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { parse } from "papaparse";
import pluralize from "pluralize";
import React, { FC, useEffect, useRef, useState } from "react";
import { FC, useEffect, useRef, useState } from "react";
import { useFieldArray, useFormContext } from "react-hook-form";
import { SafeAreaView, TouchableOpacity, View } from "react-native";

Expand Down Expand Up @@ -136,13 +136,13 @@ export const AssetsTab: React.FC = () => {
}, [fields.length]);

// On upload attributes CSV mapping file
const onUploadAttributesMapingFile = async (files: LocalFileData[]) => {
const onUploadAttributesMapingFile = (files: LocalFileData[]) => {
resetAllIssues();
setAssetsMappingDataRows([]);
assetsMetadatasForm.setValue("assetsMetadatas", []);

try {
await parse<string[]>(files[0].file, {
parse<string[]>(files[0].file, {
complete: (parseResults) => {
const attributesDataRows = parseResults.data;

Expand Down Expand Up @@ -176,7 +176,7 @@ export const AssetsTab: React.FC = () => {
const wrongIdRows: string[][] = [];
const rowsIndexesToRemove: number[] = [];

// Controling attributes
// Controlling attributes
cleanDataRows(attributesDataRows).forEach((dataRow, dataRowIndex) => {
const hasNoId = !dataRow[idColIndex]?.trim();
const hasNoValue = !dataRow[valueColIndex]?.trim();
Expand Down Expand Up @@ -329,7 +329,7 @@ export const AssetsTab: React.FC = () => {
const wrongUrlsRowsInAssets: string[][] = [];
const rowsIndexesToRemove: number[] = [];

// Controling assets and attributes
// Controlling assets and attributes
cleanDataRows(assetsDataRows).forEach(
(assetDataRow, assetDataRowIndex) => {
const hasNoName = !assetDataRow[nameColIndex]?.trim();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { zodResolver } from "@hookform/resolvers/zod";
import React, { FC, useEffect, useState } from "react";
import { FC, useEffect, useState } from "react";
import { FormProvider, useForm, useFormContext } from "react-hook-form";
import { View } from "react-native";

Expand Down Expand Up @@ -36,7 +36,7 @@ export const LaunchpadAssetsAndMetadata: FC = () => {
const collectionAssetsMetadatas = watch("assetsMetadatas");
const assetsMetadatasForm = useForm<CollectionAssetsMetadatasFormValues>({
mode: "all",
defaultValues: collectionAssetsMetadatas, // Retreive assetsMetadatas from collectionForm
defaultValues: collectionAssetsMetadatas, // Retrieve assetsMetadatas from collectionForm
resolver: zodResolver(ZodCollectionAssetsMetadatasFormValues),
});
const assetsMetadatas = assetsMetadatasForm.watch("assetsMetadatas");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from "react";
import { FC } from "react";
import { useFormContext } from "react-hook-form";
import { View } from "react-native";

Expand All @@ -10,7 +10,7 @@ import { fontSemibold14 } from "@/utils/style/fonts";
import { layout } from "@/utils/style/layout";
import { CollectionFormValues } from "@/utils/types/launchpad";

export const UriTab: React.FC = () => {
export const UriTab: FC = () => {
const collectionForm = useFormContext<CollectionFormValues>();

return (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { FC } from "react";
import { FC } from "react";
import { Controller, useFormContext } from "react-hook-form";
import { View } from "react-native";

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { FC } from "react";
import { FC } from "react";
import { Controller, useFormContext } from "react-hook-form";
import { View } from "react-native";

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from "react";
import { FC } from "react";
import { useFormContext } from "react-hook-form";
import { View } from "react-native";

Expand All @@ -13,7 +13,7 @@ import {
} from "@/utils/style/fonts";
import { CollectionFormValues } from "@/utils/types/launchpad";

export const ConfigureRoyaltyDetails: React.FC = () => {
export const ConfigureRoyaltyDetails: FC = () => {
const collectionForm = useFormContext<CollectionFormValues>();

return (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { FC } from "react";
import { FC } from "react";
import { UseFieldArrayRemove, UseFieldArrayUpdate } from "react-hook-form";

import { LaunchpadMintPeriodAccordionBottom } from "./LaunchpadMintPeriodAccordionBottom";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { FC } from "react";
import { FC } from "react";
import {
Controller,
UseFieldArrayRemove,
Expand Down Expand Up @@ -55,7 +55,7 @@ export const LaunchpadMintPeriodAccordionBottom: FC<{
return (
<View
style={{
marginHorizontal: 8,
marginHorizontal: layout.spacing_x1,
marginTop: layout.spacing_x2,
paddingHorizontal: layout.spacing_x1,
paddingBottom: layout.spacing_x1,
Expand Down Expand Up @@ -195,12 +195,7 @@ export const LaunchpadMintPeriodAccordionBottom: FC<{
>
<SVG source={trashSVG} width={16} height={16} />
<SpacerRow size={1} />
<BrandText
style={[
fontSemibold14,
{ color: errorColor, lineHeight: layout.spacing_x2 },
]}
>
<BrandText style={[fontSemibold14, { color: errorColor }]}>
Remove Mint Period
</BrandText>
</TouchableOpacity>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { FC } from "react";
import { FC } from "react";
import { UseFieldArrayUpdate } from "react-hook-form";
import { TouchableOpacity, View } from "react-native";

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { FC, Fragment, useCallback } from "react";
import { FC, Fragment, useCallback } from "react";
import { useFieldArray, useFormContext } from "react-hook-form";
import { TouchableOpacity, View } from "react-native";

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { FC } from "react";
import { FC } from "react";
import { Controller, useFormContext } from "react-hook-form";
import { View } from "react-native";

Expand Down
Loading

0 comments on commit ce9dd57

Please sign in to comment.