From e9f75a40f861b84983d4f2a4c19284b68112dc83 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?B=C3=A1lint=20Ferenczy?= <40574454+FBalint@users.noreply.github.com> Date: Mon, 24 Jun 2024 11:01:04 +0200 Subject: [PATCH 01/41] refactor: create flows (#1283) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * refactor: EditRole (#1275) * refactor(EditRole): decomposing * refactor(useEditRole): remove reward handling * refactor(EditRolePlatforms): handleAdd * fix: EditRoleHeader spacing * refactor(EditRoleHeader): handleVisibilitySave * handle availability change * handle visibility change * reward update indicator * refactor(EditRolePlatforms): move reward adding logic to hook * refactor(EditRole): handle remove * refactor: unifying crud hooks * refactor: local mutate visibilty * refactor: local mutate availability * fixing warnings * fix(EditRoleHeader): add back drawer close button on mobile * cleanup: remove now unnecessary logic from RolePlatforms * fix(add reward mutation): object to array * copy(add reward toast): "updated" to "added" * refactor: generic to ExistingRolePlatformCard, RemovePlatformButton to abstract hook * add comment about useAddReward & useAddRewardWithExistingGP * refactor: extract local role platform mutate to hook (useLocalMutateRolePlatform) * fix: add missing 'revalidate: false' * fix: set default reward visibility to role's visibility * prepare mutateGateables on useRemoveRewards * refactor: preparations for add role flow * refactor(AddRoleDrawer): decompose into hooks and components * cleanup useLocalMutateRolePlatform --------- Co-authored-by: valid * refactor(AddRoleDrawer): handle dynamic rewards in state (#1284) * refactor: RequirementHandlerContext to handle dynamic rewards in state * refactor: wrap DynamicTag with ApiRequirementHandlerProvider * perf(DynamicTag): remove provider wrapper, use requirements conditionally --------- Co-authored-by: valid * refactor: add reward flow (#1289) * refactor: RequirementHandlerContext to handle dynamic rewards in state * draft: submit order test * refactor: structuring & error handling * fix: mutate after role creation * fix: warning * fix: readd auto scroll to role * refactor(AddReward): submit hook DRAFT * typings * refactor(useSubmitEverything): modularization, break into smaller hooks * fix: save as draft * fix: warning when deleting provider requirement * refactor: useSubmitEverything in AddRole flow * fix warnings * refactor(useSubmitEverything): mutates added * fix(useMutateAdditionsToRoles): mutate `guildPlatforms` too & add types * refactor: rename creation hook to useCreateRRR * refactor: renamings & fixing edit role mutations * fix(useMutateCreatedRole): set createdGuildPlatforms * fix(EditRolePlatforms): set roleId in rolePlatform so that deletion is possible * fix: subtler add animation * add posthog error events * changeDataToDraft: save only role as hidden if provided & move out of component * fix(useMutateAdditionsToRoles): don't mutate role counts in explorer * cleanup * refactor: edit rewards (#1300) * fix: quick add reward setup steps * refactor(NewRolePlatformCard): edit button added * refactor(ExistingRolePlatformCard): add placeholder edit functionality * review fixes * cleanup * refactor(EditRolePlatformModal): add type --------- Co-authored-by: valid * fix(useCreateRequirement): posthog hook placement --------- Co-authored-by: BrickheadJohnny Co-authored-by: valid * fix: done button on edit role drawer * fix(AddRewardButton): reset to default when canceling a reward creation * fix(EditRolePlatforms): copy - 'adding reward' instead of 'loading' --------- Co-authored-by: valid Co-authored-by: BrickheadJohnny --- .../components/AddRoleDrawer.tsx | 129 +++------ .../components/AddRoleDrawerHeader.tsx | 41 +++ .../components/NewRolePlatformCard.tsx | 183 +++++++++++++ .../AddAndOrderRoles/hooks/useAddRoleForm.ts | 34 +++ .../AddRewardButton/AddRewardButton.tsx | 65 +++-- .../AddRewardButton/SelectRolePanel.tsx | 34 ++- .../components/AvailabilitySetup.tsx | 7 +- .../AddRewardButton/hooks/useAddReward.ts | 6 + .../hooks/useCreateRequirements.ts | 66 +++++ .../hooks/useCreateRolePlatforms.ts | 62 +++++ .../hooks/useMutateAdditionsToRoles.ts | 128 +++++++++ .../hooks/useMutateCreatedRole.ts | 57 ++++ .../[guild]/EditGuild/EditGuildDrawer.tsx | 2 +- .../[guild]/RequirementHandlerContext.tsx | 76 ++++++ .../components/DynamicReward/DynamicTag.tsx | 6 +- .../RoleCard/components/EditRole/EditRole.tsx | 256 +++--------------- .../EditRole/components/EditRoleFooter.tsx | 58 ++++ .../EditRole/components/EditRoleHeader.tsx | 79 ++++++ .../EditRole/components/EditRolePlatforms.tsx | 92 +++++++ .../components/ExistingRolePlatformCard.tsx | 182 +++++++++++++ .../EditRole/components/RoleGroupSelect.tsx | 2 +- .../EditRole/hooks/useAddRolePlatform.ts | 57 ++++ .../components/EditRole/hooks/useEditRole.ts | 109 +------- .../EditRole/hooks/useEditRoleForm.ts | 62 +++++ .../hooks/useLocalMutateRolePlatform.ts | 39 +++ .../EditRole/hooks/useSubmitEditRole.ts | 56 ++++ .../useUpdateRolePlatformAvailability.ts | 57 ++++ .../hooks/useUpdateRolePlatformVisibility.ts | 51 ++++ .../[guild]/RoleCard/components/Reward.tsx | 7 +- .../RolePlatforms/AddRolePlatforms.tsx | 76 ++++++ .../[guild]/RolePlatforms/RolePlatforms.tsx | 251 ----------------- .../AddRoleRewardModal/AddRoleRewardModal.tsx | 30 +- .../DefaultAddRewardPanelWrapper.tsx | 4 +- .../AddPointsPanel/AddPointsPanel.tsx | 4 +- .../SetPointsAmount/SetPointsAmount.tsx | 4 +- .../components/DynamicPointsAmountForm.tsx | 3 - .../components/PointsAmountTypeSelector.tsx | 22 +- .../DynamicSetup/BaseValueModal.tsx | 36 +-- .../DynamicSetup/DynamicRewardSetup.tsx | 8 +- .../components/SelectExistingPlatform.tsx | 77 +++--- .../components/EditRolePlatformButton.tsx | 84 ------ .../components/EditRolePlatformModal.tsx | 72 +++++ src/components/[guild]/RolePlatforms/index.ts | 2 +- .../Requirements/SetRequirements.tsx | 71 ++--- .../components/RequirementEditModal.tsx | 4 +- .../hooks/useHandleRequirementState.ts | 38 +++ .../create-guild/hooks/useCreateRole.tsx | 39 ++- src/hooks/useCreateRRR.tsx | 167 ++++++++++++ .../DiscordCardSettings.tsx | 4 +- src/platforms/Google/GoogleCardSettings.tsx | 6 +- src/platforms/Points/PointsCardSettings.tsx | 3 +- .../Token/EditDynamicRewardModal.tsx | 1 - .../SelectRoleOrSetRequirements.tsx | 22 +- src/platforms/rewards.ts | 23 +- .../mapRealRequirementIdToRolePlatform.ts | 76 ++++++ 55 files changed, 2137 insertions(+), 993 deletions(-) create mode 100644 src/components/[guild]/AddAndOrderRoles/components/AddRoleDrawerHeader.tsx create mode 100644 src/components/[guild]/AddAndOrderRoles/components/NewRolePlatformCard.tsx create mode 100644 src/components/[guild]/AddAndOrderRoles/hooks/useAddRoleForm.ts create mode 100644 src/components/[guild]/AddRewardButton/hooks/useCreateRequirements.ts create mode 100644 src/components/[guild]/AddRewardButton/hooks/useCreateRolePlatforms.ts create mode 100644 src/components/[guild]/AddRewardButton/hooks/useMutateAdditionsToRoles.ts create mode 100644 src/components/[guild]/AddRewardButton/hooks/useMutateCreatedRole.ts create mode 100644 src/components/[guild]/RequirementHandlerContext.tsx create mode 100644 src/components/[guild]/RoleCard/components/EditRole/components/EditRoleFooter.tsx create mode 100644 src/components/[guild]/RoleCard/components/EditRole/components/EditRoleHeader.tsx create mode 100644 src/components/[guild]/RoleCard/components/EditRole/components/EditRolePlatforms.tsx create mode 100644 src/components/[guild]/RoleCard/components/EditRole/components/ExistingRolePlatformCard.tsx create mode 100644 src/components/[guild]/RoleCard/components/EditRole/hooks/useAddRolePlatform.ts create mode 100644 src/components/[guild]/RoleCard/components/EditRole/hooks/useEditRoleForm.ts create mode 100644 src/components/[guild]/RoleCard/components/EditRole/hooks/useLocalMutateRolePlatform.ts create mode 100644 src/components/[guild]/RoleCard/components/EditRole/hooks/useSubmitEditRole.ts create mode 100644 src/components/[guild]/RoleCard/components/EditRole/hooks/useUpdateRolePlatformAvailability.ts create mode 100644 src/components/[guild]/RoleCard/components/EditRole/hooks/useUpdateRolePlatformVisibility.ts create mode 100644 src/components/[guild]/RolePlatforms/AddRolePlatforms.tsx delete mode 100644 src/components/[guild]/RolePlatforms/RolePlatforms.tsx delete mode 100644 src/components/[guild]/RolePlatforms/components/EditRolePlatformButton.tsx create mode 100644 src/components/[guild]/RolePlatforms/components/EditRolePlatformModal.tsx create mode 100644 src/components/create-guild/Requirements/hooks/useHandleRequirementState.ts create mode 100644 src/hooks/useCreateRRR.tsx create mode 100644 src/utils/mapRealRequirementIdToRolePlatform.ts diff --git a/src/components/[guild]/AddAndOrderRoles/components/AddRoleDrawer.tsx b/src/components/[guild]/AddAndOrderRoles/components/AddRoleDrawer.tsx index cc616e339c..4f67f18c04 100644 --- a/src/components/[guild]/AddAndOrderRoles/components/AddRoleDrawer.tsx +++ b/src/components/[guild]/AddAndOrderRoles/components/AddRoleDrawer.tsx @@ -10,67 +10,27 @@ import { useDisclosure, VStack, } from "@chakra-ui/react" -import useGuild from "components/[guild]/hooks/useGuild" -import useVisibilityModalProps from "components/[guild]/SetVisibility/hooks/useVisibilityModalProps" +import { ClientStateRequirementHandlerProvider } from "components/[guild]/RequirementHandlerContext" +import AddRolePlatforms from "components/[guild]/RolePlatforms/AddRolePlatforms" import Button from "components/common/Button" import DiscardAlert from "components/common/DiscardAlert" -import DrawerHeader from "components/common/DrawerHeader" import Section from "components/common/Section" import Description from "components/create-guild/Description" import DynamicDevTool from "components/create-guild/DynamicDevTool" -import useCreateRole, { - RoleToCreate, -} from "components/create-guild/hooks/useCreateRole" import IconSelector from "components/create-guild/IconSelector" import Name from "components/create-guild/Name" import SetRequirements from "components/create-guild/Requirements" +import useCreateRRR from "hooks/useCreateRRR" import usePinata from "hooks/usePinata" import useSubmitWithUpload from "hooks/useSubmitWithUpload" -import useToast from "hooks/useToast" import useWarnIfUnsavedChanges from "hooks/useWarnIfUnsavedChanges" import { useRef } from "react" -import { FormProvider, useForm } from "react-hook-form" -import { RoleFormType, Visibility } from "types" -import getRandomInt from "utils/getRandomInt" -import RolePlatforms from "../../RolePlatforms" -import SetVisibility from "../../SetVisibility" +import { FormProvider } from "react-hook-form" +import useAddRoleForm from "../hooks/useAddRoleForm" +import AddRoleDrawerHeader from "./AddRoleDrawerHeader" const AddRoleDrawer = ({ isOpen, onClose, finalFocusRef }): JSX.Element => { - const { id } = useGuild() - - const toast = useToast() - - const { onSubmit, isLoading, isSigning, signLoadingText } = useCreateRole({ - onSuccess: () => { - toast({ - title: "Role successfully created", - status: "success", - }) - onClose() - methods.reset(defaultValues) - }, - }) - - const defaultValues: RoleToCreate = { - guildId: id, - name: "", - description: "", - logic: "AND", - requirements: [ - { - type: "FREE", - }, - ], - roleType: "NEW", - imageUrl: `/guildLogos/${getRandomInt(286)}.svg`, - visibility: Visibility.PUBLIC, - rolePlatforms: [], - } - - const methods = useForm({ - mode: "all", - defaultValues, - }) + const methods = useAddRoleForm() /** * TODO: for some reason, isDirty was true & dirtyFields was an empty object and I @@ -87,7 +47,7 @@ const AddRoleDrawer = ({ isOpen, onClose, finalFocusRef }): JSX.Element => { } = useDisclosure() const onCloseAndClear = () => { - methods.reset(defaultValues) + methods.reset(methods.defaultValues) onAlertClose() onClose() } @@ -100,6 +60,13 @@ const AddRoleDrawer = ({ isOpen, onClose, finalFocusRef }): JSX.Element => { const drawerBodyRef = useRef() + const { onSubmit, isLoading, loadingText } = useCreateRRR({ + onSuccess: () => { + methods.reset(methods.defaultValues) + onClose() + }, + }) + const { handleSubmit, isUploadingShown, uploadLoadingText } = useSubmitWithUpload( methods.handleSubmit(onSubmit, (formErrors) => { if (formErrors.requirements && drawerBodyRef.current) { @@ -112,10 +79,6 @@ const AddRoleDrawer = ({ isOpen, onClose, finalFocusRef }): JSX.Element => { iconUploader.isUploading ) - const loadingText = signLoadingText || uploadLoadingText || "Saving data" - - const setVisibilityModalProps = useVisibilityModalProps() - return ( <> { - - - { - methods.setValue("visibility", visibility) - methods.setValue("visibilityRoleId", visibilityRoleId) - setVisibilityModalProps.onClose() - }} - {...setVisibilityModalProps} - /> - - - - - - -
- - Choose a logo and name for your role - - - - - - -
- - -
+ + + + + +
+ + Choose a logo and name for your role + + + + + + +
+ + +
+
@@ -176,9 +119,9 @@ const AddRoleDrawer = ({ isOpen, onClose, finalFocusRef }): JSX.Element => { Cancel + { + setValue( + `rolePlatforms.${rolePlatform.id}`, + { + ...rolePlatformData, + ...data, + }, + { shouldDirty: true } + ) + onEditClose() + }} + /> + + ) + } + contentRow={ + <> + {CAPACITY_TIME_PLATFORMS.includes(type) || isLegacyContractCallReward ? ( + { + setValue(`rolePlatforms.${rolePlatform.id}.capacity`, capacity, { + shouldDirty: true, + }) + setValue(`rolePlatforms.${rolePlatform.id}.startTime`, startTime, { + shouldDirty: true, + }) + setValue(`rolePlatforms.${rolePlatform.id}.endTime`, endTime, { + shouldDirty: true, + }) + }} + /> + ) : type === "CONTRACT_CALL" ? ( + + ) : null} + {!!rolePlatform.dynamicAmount && ( + + )} + + } + /> + + ) +} + +export default NewRolePlatformCard diff --git a/src/components/[guild]/AddAndOrderRoles/hooks/useAddRoleForm.ts b/src/components/[guild]/AddAndOrderRoles/hooks/useAddRoleForm.ts new file mode 100644 index 0000000000..22a3f59c8f --- /dev/null +++ b/src/components/[guild]/AddAndOrderRoles/hooks/useAddRoleForm.ts @@ -0,0 +1,34 @@ +import useGuild from "components/[guild]/hooks/useGuild" +import { RoleToCreate } from "components/create-guild/hooks/useCreateRole" +import { useForm } from "react-hook-form" +import { RoleFormType, Visibility } from "types" +import getRandomInt from "utils/getRandomInt" + +const useAddRoleForm = () => { + const { id } = useGuild() + + const defaultValues: RoleToCreate = { + guildId: id, + name: "", + description: "", + logic: "AND", + requirements: [ + { + type: "FREE", + }, + ], + roleType: "NEW", + imageUrl: `/guildLogos/${getRandomInt(286)}.svg`, + visibility: Visibility.PUBLIC, + rolePlatforms: [], + } + + const methods = useForm({ + mode: "all", + defaultValues, + }) + + return { ...methods, defaultValues } +} + +export default useAddRoleForm diff --git a/src/components/[guild]/AddRewardButton/AddRewardButton.tsx b/src/components/[guild]/AddRewardButton/AddRewardButton.tsx index 292250568d..2acbb35c0d 100644 --- a/src/components/[guild]/AddRewardButton/AddRewardButton.tsx +++ b/src/components/[guild]/AddRewardButton/AddRewardButton.tsx @@ -9,6 +9,7 @@ import rewards, { modalSizeForPlatform } from "platforms/rewards" import { FormProvider, useForm, useWatch } from "react-hook-form" import { Requirement, RoleFormType, Visibility } from "types" import { AddRewardProvider, useAddRewardContext } from "../AddRewardContext" +import { ClientStateRequirementHandlerProvider } from "../RequirementHandlerContext" import SelectRewardPanel from "../RolePlatforms/components/AddRoleRewardModal/SelectRewardPanel" import { useIsTabsStuck } from "../Tabs" import { useThemeContext } from "../ThemeContext" @@ -80,6 +81,12 @@ const AddRewardButton = (): JSX.Element => { } } + const closeAndClear = () => { + methods.reset(defaultValues) + onAddRewardModalClose() + setIsAddRewardPanelDirty(false) + } + return ( <> - - - )} - +
diff --git a/src/components/[guild]/RoleCard/components/EditRole/components/EditRoleFooter.tsx b/src/components/[guild]/RoleCard/components/EditRole/components/EditRoleFooter.tsx new file mode 100644 index 0000000000..9b17ea526c --- /dev/null +++ b/src/components/[guild]/RoleCard/components/EditRole/components/EditRoleFooter.tsx @@ -0,0 +1,58 @@ +import { DrawerFooter, Icon } from "@chakra-ui/react" +import Button from "components/common/Button" +import { AnimatePresence, motion } from "framer-motion" +import { Check } from "phosphor-react" + +const MotionDrawerFooter = motion(DrawerFooter) +const FOOTER_OFFSET = 76 // Footer is 76px high + +const EditRoleFooter = ({ + onClose, + onSubmit, + isLoading, + loadingText, + isDirty, +}: { + onClose: () => void + onSubmit: (event: any) => void + isLoading: boolean + loadingText: string + isDirty: boolean +}) => ( + + + {isDirty ? ( + <> + + + + ) : ( + + )} + + +) + +export default EditRoleFooter diff --git a/src/components/[guild]/RoleCard/components/EditRole/components/EditRoleHeader.tsx b/src/components/[guild]/RoleCard/components/EditRole/components/EditRoleHeader.tsx new file mode 100644 index 0000000000..263f22bc60 --- /dev/null +++ b/src/components/[guild]/RoleCard/components/EditRole/components/EditRoleHeader.tsx @@ -0,0 +1,79 @@ +import { HStack, Icon, IconButton } from "@chakra-ui/react" +import SetVisibility, { SetVisibilityForm } from "components/[guild]/SetVisibility" +import useVisibilityModalProps from "components/[guild]/SetVisibility/hooks/useVisibilityModalProps" +import useGuild from "components/[guild]/hooks/useGuild" +import DrawerHeader from "components/common/DrawerHeader" +import { ArrowLeft } from "phosphor-react" +import { useFormContext, useWatch } from "react-hook-form" +import { RoleEditFormData } from "../hooks/useEditRoleForm" +import DeleteRoleButton from "./DeleteRoleButton" + +const EditRoleHeader = ({ + roleId, + onClose, +}: { + roleId: number + onClose: () => void +}) => { + const setVisibilityModalProps = useVisibilityModalProps() + const { roles } = useGuild() + + const visibility = useWatch({ name: "visibility" }) + const visibilityRoleId = useWatch({ name: "visibilityRoleId" }) + + const { setValue } = useFormContext() + + const handleVisibilitySave = ({ + visibility: newVisibility, + visibilityRoleId: newVisibilityRoleId, + }: SetVisibilityForm) => { + setValue("visibility", newVisibility, { + shouldDirty: true, + }) + setValue("visibilityRoleId", newVisibilityRoleId, { + shouldDirty: true, + }) + setVisibilityModalProps.onClose() + } + + return ( + } + variant="ghost" + display={{ base: "flex", md: "none" }} + borderRadius="full" + maxW={10} + maxH={10} + onClick={onClose} + > + Cancel + + } + > + + + {roles?.length > 1 && ( + + )} + + + ) +} + +export default EditRoleHeader diff --git a/src/components/[guild]/RoleCard/components/EditRole/components/EditRolePlatforms.tsx b/src/components/[guild]/RoleCard/components/EditRole/components/EditRolePlatforms.tsx new file mode 100644 index 0000000000..0c26d2ccc1 --- /dev/null +++ b/src/components/[guild]/RoleCard/components/EditRole/components/EditRolePlatforms.tsx @@ -0,0 +1,92 @@ +import { Box, Collapse, Spacer, Spinner, Stack, Tag } from "@chakra-ui/react" +import { + AddRewardProvider, + useAddRewardContext, +} from "components/[guild]/AddRewardContext" +import AddRoleRewardModal from "components/[guild]/RolePlatforms/components/AddRoleRewardModal" +import TransitioningPlatformIcons from "components/[guild]/RolePlatforms/components/TransitioningPlatformIcons" +import useGuild from "components/[guild]/hooks/useGuild" +import useRole from "components/[guild]/hooks/useRole" +import AddCard from "components/common/AddCard" +import Button from "components/common/Button" +import Section from "components/common/Section" +import { atom } from "jotai" +import { Plus } from "phosphor-react" +import useAddRolePlatform from "../hooks/useAddRolePlatform" +import ExistingRolePlatformCard from "./ExistingRolePlatformCard" + +type Props = { + roleId?: number +} + +export const openRewardSettingsGuildPlatformIdAtom = atom(0) + +const EditRolePlatforms = ({ roleId }: Props) => { + const { onOpen } = useAddRewardContext() + const { id: guildId } = useGuild() + const { rolePlatforms } = useRole(guildId, roleId) + + const { + onSubmit: handleAddWithExistingGuildPlatform, + isLoading: addWithExistingIsLoading, + } = useAddRolePlatform(roleId) + + return ( +
+ + + + } + > + + {!rolePlatforms || rolePlatforms?.length <= 0 ? ( + + ) : ( + rolePlatforms.map((rolePlatform) => ( + + )) + )} + + + + + Adding reward... + + + + + + +
+ ) +} + +const EditRolePlatformsWrapper = (props: Props): JSX.Element => ( + + + +) + +export default EditRolePlatformsWrapper diff --git a/src/components/[guild]/RoleCard/components/EditRole/components/ExistingRolePlatformCard.tsx b/src/components/[guild]/RoleCard/components/EditRole/components/ExistingRolePlatformCard.tsx new file mode 100644 index 0000000000..15ec3bb291 --- /dev/null +++ b/src/components/[guild]/RoleCard/components/EditRole/components/ExistingRolePlatformCard.tsx @@ -0,0 +1,182 @@ +import { useColorModeValue, useDisclosure } from "@chakra-ui/react" +import useEditRolePlatform from "components/[guild]/AccessHub/hooks/useEditRolePlatform" +import AvailabilitySetup from "components/[guild]/AddRewardButton/components/AvailabilitySetup" +import { ContractCallFunction } from "components/[guild]/RolePlatforms/components/AddRoleRewardModal/components/AddContractCallPanel/components/CreateNftForm/hooks/useCreateNft" +import EditRolePlatformModal from "components/[guild]/RolePlatforms/components/EditRolePlatformModal" +import PlatformCard from "components/[guild]/RolePlatforms/components/PlatformCard" +import RemovePlatformButton from "components/[guild]/RolePlatforms/components/RemovePlatformButton" +import { RolePlatformProvider } from "components/[guild]/RolePlatforms/components/RolePlatformProvider" +import SetVisibility from "components/[guild]/SetVisibility" +import useVisibilityModalProps from "components/[guild]/SetVisibility/hooks/useVisibilityModalProps" +import useGuild from "components/[guild]/hooks/useGuild" +import Button from "components/common/Button" +import NftAvailabilityTags from "platforms/ContractCall/components/NftAvailabilityTags" +import rewards, { CAPACITY_TIME_PLATFORMS } from "platforms/rewards" +import { + GuildPlatformWithOptionalId, + PlatformName, + PlatformType, + RolePlatform, +} from "types" +import DynamicTag from "../../DynamicReward/DynamicTag" +import useUpdateRolePlatformAvailability from "../hooks/useUpdateRolePlatformAvailability" +import useUpdateRolePlatformVisibility from "../hooks/useUpdateRolePlatformVisibility" + +type Props = { + rolePlatform: RolePlatform +} + +// TODO: needs backend support +const EDIT_SUPPORTED = false + +const ExistingRolePlatformCard = ({ rolePlatform }: Props) => { + const { guildPlatforms } = useGuild() + const setVisibilityModalProps = useVisibilityModalProps() + const removeButtonColor = useColorModeValue("gray.700", "gray.400") + + let guildPlatform: GuildPlatformWithOptionalId, type: PlatformName + if (rolePlatform.guildPlatformId) { + guildPlatform = guildPlatforms.find( + (platform) => platform.id === rolePlatform.guildPlatformId + ) + type = PlatformType[guildPlatform?.platformId] as PlatformName + } else { + guildPlatform = rolePlatform.guildPlatform + type = guildPlatform?.platformName + } + + const { onSubmit: onAvailabilityChange, isLoading: isAvailabilityLoading } = + useUpdateRolePlatformAvailability() + const { onSubmit: onVisibilityChange, isLoading: isVisibilityLoading } = + useUpdateRolePlatformVisibility() + + const { onSubmit: onEdit } = useEditRolePlatform({ + rolePlatformId: rolePlatform.id, + }) + + const { + isOpen: isEditOpen, + onClose: onEditClose, + onOpen: onEditOpen, + } = useDisclosure() + + if (!type) return null + + const isLegacyContractCallReward = + type === "CONTRACT_CALL" && + guildPlatform.platformGuildData.function === + ContractCallFunction.DEPRECATED_SIMPLE_CLAIM + + const { + cardPropsHook: useCardProps, + isPlatform, + cardSettingsComponent, + } = rewards[type] + + return ( + + { + await onVisibilityChange({ + rolePlatform, + visibility, + visibilityRoleId, + }) + setVisibilityModalProps.onClose() + }} + isLoading={isVisibilityLoading} + {...setVisibilityModalProps} + /> + } + cornerButton={ + + } + actionRow={ + EDIT_SUPPORTED ? ( + cardSettingsComponent && ( + <> + + { + onEdit({ ...rolePlatform, ...updateData }) + onEditClose() + }} + /> + + ) + ) : ( + <> + ) + } + contentRow={ + <> + {CAPACITY_TIME_PLATFORMS.includes(type) || isLegacyContractCallReward ? ( + + onAvailabilityChange({ + rolePlatform, + capacity, + startTime, + endTime, + }) + } + isLoading={isAvailabilityLoading} + /> + ) : type === "CONTRACT_CALL" ? ( + + ) : null} + {!!rolePlatform.dynamicAmount && ( + + )} + + } + /> + + ) +} + +export default ExistingRolePlatformCard diff --git a/src/components/[guild]/RoleCard/components/EditRole/components/RoleGroupSelect.tsx b/src/components/[guild]/RoleCard/components/EditRole/components/RoleGroupSelect.tsx index 0a1b2cd317..d34a3bd063 100644 --- a/src/components/[guild]/RoleCard/components/EditRole/components/RoleGroupSelect.tsx +++ b/src/components/[guild]/RoleCard/components/EditRole/components/RoleGroupSelect.tsx @@ -1,7 +1,7 @@ import { FormControl, FormLabel, Select } from "@chakra-ui/react" import useGuild from "components/[guild]/hooks/useGuild" import { useController } from "react-hook-form" -import { RoleEditFormData } from "../EditRole" +import { RoleEditFormData } from "../hooks/useEditRoleForm" const RoleGroupSelect = () => { const { groups } = useGuild() diff --git a/src/components/[guild]/RoleCard/components/EditRole/hooks/useAddRolePlatform.ts b/src/components/[guild]/RoleCard/components/EditRole/hooks/useAddRolePlatform.ts new file mode 100644 index 0000000000..8112659932 --- /dev/null +++ b/src/components/[guild]/RoleCard/components/EditRole/hooks/useAddRolePlatform.ts @@ -0,0 +1,57 @@ +import useGuild from "components/[guild]/hooks/useGuild" +import useShowErrorToast from "hooks/useShowErrorToast" +import useSubmit from "hooks/useSubmit" +import useToast from "hooks/useToast" +import { RolePlatform } from "types" +import { useFetcherWithSign } from "utils/fetcher" + +const useAddRolePlatform = (roleId: number) => { + const { id, mutateGuild } = useGuild() + const fetcherWithSign = useFetcherWithSign() + const toast = useToast() + const showErrorToast = useShowErrorToast() + + const submit = async (rolePlatform: RolePlatform) => + fetcherWithSign([ + `/v2/guilds/${id}/roles/${roleId}/role-platforms`, + { method: "POST", body: rolePlatform }, + ]) + + return useSubmit(submit, { + onSuccess: (response) => { + toast({ + title: "Reward added!", + status: "success", + }) + + mutateGuild( + (prevGuild) => { + const data = { + ...prevGuild, + guildPlatforms: response?.createdGuildPlatform + ? [...prevGuild.guildPlatforms, response?.createdGuildPlatform] + : prevGuild.guildPlatforms, + roles: prevGuild.roles.map((role) => { + if (role.id === roleId) { + return { + ...role, + rolePlatforms: [ + ...role.rolePlatforms, + { ...response, roleId: roleId }, + ], + } + } + return role + }), + } + + return data + }, + { revalidate: false } + ) + }, + onError: (error) => showErrorToast(error), + }) +} + +export default useAddRolePlatform diff --git a/src/components/[guild]/RoleCard/components/EditRole/hooks/useEditRole.ts b/src/components/[guild]/RoleCard/components/EditRole/hooks/useEditRole.ts index af8e9d1449..2c2f0d2e5e 100644 --- a/src/components/[guild]/RoleCard/components/EditRole/hooks/useEditRole.ts +++ b/src/components/[guild]/RoleCard/components/EditRole/hooks/useEditRole.ts @@ -1,15 +1,11 @@ import useMembershipUpdate from "components/[guild]/JoinModal/hooks/useMembershipUpdate" import useGuild from "components/[guild]/hooks/useGuild" -import useCustomPosthogEvents from "hooks/useCustomPosthogEvents" import useShowErrorToast from "hooks/useShowErrorToast" import useSubmit from "hooks/useSubmit/useSubmit" import { OneOf } from "types" import { useFetcherWithSign } from "utils/fetcher" import replacer from "utils/guildJsonReplacer" -import { RoleEditFormData } from "../EditRole" - -const mapToObject = (array: T[], by: keyof T = "id") => - Object.fromEntries(array.map((item) => [item[by], item])) +import { RoleEditFormData } from "./useEditRoleForm" const useEditRole = (roleId: number, onSuccess?: () => void) => { const { id, mutateGuild } = useGuild() @@ -18,11 +14,9 @@ const useEditRole = (roleId: number, onSuccess?: () => void) => { const errorToast = useShowErrorToast() const showErrorToast = useShowErrorToast() const fetcherWithSign = useFetcherWithSign() - const { rewardCreated } = useCustomPosthogEvents() const submit = async (data: RoleEditFormData) => { const { - rolePlatforms, // eslint-disable-next-line @typescript-eslint/naming-convention, @typescript-eslint/no-unused-vars id: _id, ...baseRoleData @@ -41,75 +35,13 @@ const useEditRole = (roleId: number, onSuccess?: () => void) => { ]).catch((error) => error) : new Promise((resolve) => resolve(undefined)) - const rolePlatformUpdates = Promise.all( - (rolePlatforms ?? []) - .filter((rolePlatform) => "id" in rolePlatform) - .map((rolePlatform) => - fetcherWithSign([ - `/v2/guilds/${id}/roles/${roleId}/role-platforms/${rolePlatform.id}`, - { method: "PUT", body: rolePlatform }, - ]).catch((error) => error) - ) - ) - - const rolePlatformsToCreate = (rolePlatforms ?? []).filter( - (rolePlatform) => !("id" in rolePlatform) - ) - - const rolePlatformCreations = Promise.all( - rolePlatformsToCreate.map((rolePlatform) => - fetcherWithSign([ - `/v2/guilds/${id}/roles/${roleId}/role-platforms`, - { method: "POST", body: rolePlatform }, - ]).catch((error) => error) - ) - ) - - const [updatedRole, updatedRolePlatforms, createdRolePlatforms] = - await Promise.all([roleUpdate, rolePlatformUpdates, rolePlatformCreations]) - - return { - updatedRole, - updatedRolePlatforms, - createdRolePlatforms, - } + const updatedRole = await roleUpdate + return updatedRole } const useSubmitResponse = useSubmit(submit, { - onSuccess: (result) => { - const { updatedRole, updatedRolePlatforms, createdRolePlatforms } = result - - if (createdRolePlatforms?.length > 0) { - createdRolePlatforms.forEach((rolePlatform) => { - if (rolePlatform?.createdGuildPlatform) { - rewardCreated(rolePlatform.createdGuildPlatform.platformId) - } - }) - } - - const [failedRolePlatformUpdatesCount, failedRolePlatformCreationsCount] = [ - updatedRolePlatforms.filter((req) => !!req.error).length, - createdRolePlatforms.filter((req) => !!req.error).length, - ] - - const [successfulRolePlatformUpdates, successfulRolePlatformCreations] = [ - updatedRolePlatforms.filter((res) => !res.error), - createdRolePlatforms.filter((res) => !res.error), - ] - - const [ - failedRolePlatformUpdatesCorrelationId, - failedRolePlatformCreationsCorrelationId, - ] = [ - updatedRolePlatforms.filter((req) => !!req.error)[0]?.correlationId, - createdRolePlatforms.filter((req) => !!req.error)[0]?.correlationId, - ] - - if ( - !updatedRole?.error && - failedRolePlatformUpdatesCount <= 0 && - failedRolePlatformCreationsCount <= 0 - ) { + onSuccess: (updatedRole) => { + if (!updatedRole?.error) { onSuccess?.() } else { if (updatedRole?.error) { @@ -118,47 +50,18 @@ const useEditRole = (roleId: number, onSuccess?: () => void) => { correlationId: updatedRole.correlationId, }) } - if (failedRolePlatformUpdatesCount > 0) { - errorToast({ - error: "Failed to update some rewards", - correlationId: failedRolePlatformUpdatesCorrelationId, - }) - } - if (failedRolePlatformCreationsCount > 0) { - errorToast({ - error: "Failed to create some rewards", - correlationId: failedRolePlatformCreationsCorrelationId, - }) - } } - const updatedRolePlatformsById = mapToObject(successfulRolePlatformUpdates) - - const createdRolePlatformsToMutate = successfulRolePlatformCreations.map( - ({ createdGuildPlatform: _, ...rest }) => ({ roleId: roleId, ...rest }) - ) - - const createdGuildPlatforms = successfulRolePlatformCreations - .map(({ createdGuildPlatform }) => createdGuildPlatform) - .filter(Boolean) - mutateGuild( (prevGuild) => ({ ...prevGuild, - guildPlatforms: [...prevGuild.guildPlatforms, ...createdGuildPlatforms], + guildPlatforms: [...prevGuild.guildPlatforms], roles: prevGuild.roles?.map((prevRole) => prevRole.id === roleId ? { ...prevRole, ...(updatedRole ?? {}), - rolePlatforms: [ - ...(prevRole.rolePlatforms?.map((prevRolePlatform) => ({ - ...prevRolePlatform, - ...(updatedRolePlatformsById[prevRolePlatform.id] ?? {}), - })) ?? []), - ...createdRolePlatformsToMutate, - ], } : prevRole ) ?? [], diff --git a/src/components/[guild]/RoleCard/components/EditRole/hooks/useEditRoleForm.ts b/src/components/[guild]/RoleCard/components/EditRole/hooks/useEditRoleForm.ts new file mode 100644 index 0000000000..89dc2e4323 --- /dev/null +++ b/src/components/[guild]/RoleCard/components/EditRole/hooks/useEditRoleForm.ts @@ -0,0 +1,62 @@ +import useGuild from "components/[guild]/hooks/useGuild" +import { useEffect } from "react" +import { useForm } from "react-hook-form" +import { Logic, Visibility } from "types" + +export type RoleEditFormData = { + id: number + name: string + description: string + imageUrl: string + logic: Logic + visibility: Visibility + visibilityRoleId?: number + anyOfNum?: number + groupId?: number +} + +const useEditRoleForm = (roleId: number) => { + const { roles } = useGuild() + const { + id, + name, + description, + imageUrl, + logic, + anyOfNum, + visibility, + visibilityRoleId, + groupId, + } = roles?.find((role) => role.id === roleId) ?? {} + + const defaultValues: RoleEditFormData = { + id, + name, + description, + imageUrl, + logic, + anyOfNum: anyOfNum ?? 1, + visibility, + visibilityRoleId, + groupId, + } + + const methods = useForm({ + mode: "all", + defaultValues, + }) + + useEffect(() => { + const role = roles?.find((r) => r.id === roleId) + if (!role) return + + methods.reset({ + ...role, + anyOfNum: role.anyOfNum ?? 1, + }) + }, [roles, roleId, methods]) + + return { ...methods, defaultValues } +} + +export default useEditRoleForm diff --git a/src/components/[guild]/RoleCard/components/EditRole/hooks/useLocalMutateRolePlatform.ts b/src/components/[guild]/RoleCard/components/EditRole/hooks/useLocalMutateRolePlatform.ts new file mode 100644 index 0000000000..185f66a5d9 --- /dev/null +++ b/src/components/[guild]/RoleCard/components/EditRole/hooks/useLocalMutateRolePlatform.ts @@ -0,0 +1,39 @@ +import useGuild from "components/[guild]/hooks/useGuild" +import { RolePlatform } from "types" + +const useLocalMutateRolePlatform = () => { + const { mutateGuild } = useGuild() + + const mutateRolePlatform = ( + rolePlatformId: number, + rolePlatformData: Partial + ) => { + mutateGuild( + (prevGuild) => ({ + ...prevGuild, + roles: prevGuild.roles.map((role) => { + if (role.rolePlatforms.some((rp) => rp.id === rolePlatformId)) { + return { + ...role, + rolePlatforms: role.rolePlatforms.map((rp) => { + if (rp.id === rolePlatformId) { + return { + ...rp, + ...rolePlatformData, + } + } + return rp + }), + } + } + return role + }), + }), + { revalidate: false } + ) + } + + return mutateRolePlatform +} + +export default useLocalMutateRolePlatform diff --git a/src/components/[guild]/RoleCard/components/EditRole/hooks/useSubmitEditRole.ts b/src/components/[guild]/RoleCard/components/EditRole/hooks/useSubmitEditRole.ts new file mode 100644 index 0000000000..c57a3d77bc --- /dev/null +++ b/src/components/[guild]/RoleCard/components/EditRole/hooks/useSubmitEditRole.ts @@ -0,0 +1,56 @@ +import usePinata from "hooks/usePinata" +import useSubmitWithUpload from "hooks/useSubmitWithUpload" +import useToast from "hooks/useToast" +import { UseFormReturn } from "react-hook-form" +import handleSubmitDirty from "utils/handleSubmitDirty" +import useEditRole from "./useEditRole" +import { RoleEditFormData } from "./useEditRoleForm" + +const useSubmitEditRole = ({ + roleId, + methods, + onSuccess, +}: { + roleId: number + methods: UseFormReturn + onSuccess: () => void +}) => { + const { control, reset } = methods + const toast = useToast() + + const iconUploader = usePinata({ + fieldToSetOnSuccess: "imageUrl", + fieldToSetOnError: "imageUrl", + control, + }) + + const handleSuccess = () => { + toast({ + title: `Role successfully updated!`, + status: "success", + }) + reset(undefined, { keepValues: true }) + onSuccess?.() + } + + const { onSubmit, isLoading, isSigning, signLoadingText } = useEditRole( + roleId, + handleSuccess + ) + + const { handleSubmit, isUploadingShown, uploadLoadingText } = useSubmitWithUpload( + handleSubmitDirty(methods)(onSubmit), + iconUploader.isUploading + ) + + const loadingText = signLoadingText || uploadLoadingText || "Saving data" + + return { + onSubmit: handleSubmit, + loadingText, + isLoading: isLoading || isSigning || isUploadingShown, + iconUploader, + } +} + +export default useSubmitEditRole diff --git a/src/components/[guild]/RoleCard/components/EditRole/hooks/useUpdateRolePlatformAvailability.ts b/src/components/[guild]/RoleCard/components/EditRole/hooks/useUpdateRolePlatformAvailability.ts new file mode 100644 index 0000000000..5fb2aa5d69 --- /dev/null +++ b/src/components/[guild]/RoleCard/components/EditRole/hooks/useUpdateRolePlatformAvailability.ts @@ -0,0 +1,57 @@ +import useGuild from "components/[guild]/hooks/useGuild" +import useShowErrorToast from "hooks/useShowErrorToast" +import useSubmit from "hooks/useSubmit" +import useToast from "hooks/useToast" +import { RolePlatform } from "types" +import { useFetcherWithSign } from "utils/fetcher" +import useLocalMutateRolePlatform from "./useLocalMutateRolePlatform" + +type Props = { + rolePlatform: RolePlatform + capacity?: number + startTime?: string + endTime?: string +} + +type MutateProps = { + id: number + capacity: number + startTime?: string + endTime?: string +} + +const useUpdateRolePlatformAvailability = () => { + const { id: guildId } = useGuild() + const toast = useToast() + const showErrorToast = useShowErrorToast() + const fetcherWithSign = useFetcherWithSign() + const mutateRolePlatform = useLocalMutateRolePlatform() + + const submit = async (data: Props) => { + const { rolePlatform, capacity, startTime, endTime } = data + const updatedRolePlatform = { + ...rolePlatform, + capacity, + startTime, + endTime, + } + + return fetcherWithSign([ + `/v2/guilds/${guildId}/roles/${rolePlatform.roleId}/role-platforms/${rolePlatform.id}`, + { method: "PUT", body: updatedRolePlatform }, + ]) + } + + return useSubmit(submit, { + onSuccess: (response) => { + toast({ + title: "Reward updated!", + status: "success", + }) + const { id, ...rolePlatformData } = response + mutateRolePlatform(id, rolePlatformData) + }, + onError: (error) => showErrorToast(error), + }) +} +export default useUpdateRolePlatformAvailability diff --git a/src/components/[guild]/RoleCard/components/EditRole/hooks/useUpdateRolePlatformVisibility.ts b/src/components/[guild]/RoleCard/components/EditRole/hooks/useUpdateRolePlatformVisibility.ts new file mode 100644 index 0000000000..424440c476 --- /dev/null +++ b/src/components/[guild]/RoleCard/components/EditRole/hooks/useUpdateRolePlatformVisibility.ts @@ -0,0 +1,51 @@ +import useGuild from "components/[guild]/hooks/useGuild" +import useShowErrorToast from "hooks/useShowErrorToast" +import useSubmit from "hooks/useSubmit" +import useToast from "hooks/useToast" +import { RolePlatform, Visibility } from "types" +import { useFetcherWithSign } from "utils/fetcher" +import useLocalMutateRolePlatform from "./useLocalMutateRolePlatform" + +type Props = { + rolePlatform: RolePlatform + visibility: Visibility + visibilityRoleId: number +} + +type MutateProps = { id: number; visibility: Visibility; visibilityRoleId: number } + +const useUpdateRolePlatformVisibility = () => { + const { id: guildId } = useGuild() + const showErrorToast = useShowErrorToast() + const fetcherWithSign = useFetcherWithSign() + const mutateRolePlatform = useLocalMutateRolePlatform() + const toast = useToast() + + const submit = async (data: Props) => { + const { rolePlatform, visibility, visibilityRoleId } = data + const updatedRolePlatform = { + ...rolePlatform, + visibility, + visibilityRoleId, + } + + return fetcherWithSign([ + `/v2/guilds/${guildId}/roles/${rolePlatform.roleId}/role-platforms/${rolePlatform.id}`, + { method: "PUT", body: updatedRolePlatform }, + ]) + } + + return useSubmit(submit, { + onSuccess: (response) => { + toast({ + title: "Reward updated!", + status: "success", + }) + const { id, ...rolePlatformData } = response + mutateRolePlatform(id, rolePlatformData) + }, + onError: (error) => showErrorToast(error), + }) +} + +export default useUpdateRolePlatformVisibility diff --git a/src/components/[guild]/RoleCard/components/Reward.tsx b/src/components/[guild]/RoleCard/components/Reward.tsx index e5f0f7d1b4..a276299c65 100644 --- a/src/components/[guild]/RoleCard/components/Reward.tsx +++ b/src/components/[guild]/RoleCard/components/Reward.tsx @@ -13,6 +13,7 @@ import { } from "@chakra-ui/react" import usePlatformAccessButton from "components/[guild]/AccessHub/components/usePlatformAccessButton" import { useOpenJoinModal } from "components/[guild]/JoinModal/JoinModalProvider" +import { ApiRequirementHandlerProvider } from "components/[guild]/RequirementHandlerContext" import Visibility from "components/[guild]/Visibility" import useGuild from "components/[guild]/hooks/useGuild" import Button from "components/common/Button" @@ -260,7 +261,11 @@ const RewardWrapper = ({ platform, ...props }: RewardProps) => { const Component = rewards[PlatformType[guildPlatform?.platformId]].RoleCardComponent ?? Reward - return + return ( + + + + ) } export { Reward, RewardDisplay, RewardIcon, getRewardLabel } diff --git a/src/components/[guild]/RolePlatforms/AddRolePlatforms.tsx b/src/components/[guild]/RolePlatforms/AddRolePlatforms.tsx new file mode 100644 index 0000000000..11dbd6feeb --- /dev/null +++ b/src/components/[guild]/RolePlatforms/AddRolePlatforms.tsx @@ -0,0 +1,76 @@ +import { SimpleGrid, Spacer } from "@chakra-ui/react" +import TransitioningPlatformIcons from "components/[guild]/RolePlatforms/components/TransitioningPlatformIcons" +import AddCard from "components/common/AddCard" +import Button from "components/common/Button" +import Section from "components/common/Section" +import { atom } from "jotai" +import { Plus } from "phosphor-react" +import { useFieldArray, useFormContext } from "react-hook-form" +import { RoleFormType, RolePlatform } from "types" +import NewRolePlatformCard from "../AddAndOrderRoles/components/NewRolePlatformCard" +import { AddRewardProvider, useAddRewardContext } from "../AddRewardContext" +import AddRoleRewardModal from "./components/AddRoleRewardModal" + +export const openRewardSettingsGuildPlatformIdAtom = atom(0) + +const AddRolePlatforms = () => { + const { onOpen } = useAddRewardContext() + + const { watch } = useFormContext() + const { fields, append, remove } = useFieldArray< + RoleFormType, + "rolePlatforms", + "fieldId" + >({ + name: "rolePlatforms", + keyName: "fieldId", + }) + const watchFieldArray = watch("rolePlatforms") + const controlledFields = fields.map((field, index) => ({ + ...field, + ...watchFieldArray[index], + })) + + return ( +
+ + + + } + > + + {!controlledFields || controlledFields?.length <= 0 ? ( + + ) : ( + controlledFields.map((rolePlatform, index) => ( + remove(index)} + /> + )) + )} + + +
+ ) +} + +const AddRolePlatformsWrapper = (): JSX.Element => ( + + + +) + +export default AddRolePlatformsWrapper diff --git a/src/components/[guild]/RolePlatforms/RolePlatforms.tsx b/src/components/[guild]/RolePlatforms/RolePlatforms.tsx deleted file mode 100644 index 225d7bc623..0000000000 --- a/src/components/[guild]/RolePlatforms/RolePlatforms.tsx +++ /dev/null @@ -1,251 +0,0 @@ -import { CloseButton, SimpleGrid, Spacer, useColorModeValue } from "@chakra-ui/react" -import TransitioningPlatformIcons from "components/[guild]/RolePlatforms/components/TransitioningPlatformIcons" -import AddCard from "components/common/AddCard" -import Button from "components/common/Button" -import Section from "components/common/Section" -import { atom } from "jotai" -import { Plus } from "phosphor-react" -import NftAvailabilityTags from "platforms/ContractCall/components/NftAvailabilityTags" -import rewards, { CAPACITY_TIME_PLATFORMS } from "platforms/rewards" -import { useFieldArray, useFormContext } from "react-hook-form" -import { - GuildPlatformWithOptionalId, - PlatformName, - PlatformType, - RoleFormType, - RolePlatform, -} from "types" -import AvailabilitySetup from "../AddRewardButton/components/AvailabilitySetup" -import { AddRewardProvider, useAddRewardContext } from "../AddRewardContext" -import DynamicTag from "../RoleCard/components/DynamicReward/DynamicTag" -import SetVisibility from "../SetVisibility" -import useVisibilityModalProps from "../SetVisibility/hooks/useVisibilityModalProps" -import useGuild from "../hooks/useGuild" -import AddRoleRewardModal from "./components/AddRoleRewardModal" -import { ContractCallFunction } from "./components/AddRoleRewardModal/components/AddContractCallPanel/components/CreateNftForm/hooks/useCreateNft" -import EditRolePlatformButton from "./components/EditRolePlatformButton" -import PlatformCard from "./components/PlatformCard" -import RemovePlatformButton from "./components/RemovePlatformButton" -import { RolePlatformProvider } from "./components/RolePlatformProvider" - -type Props = { - roleId?: number -} - -export const openRewardSettingsGuildPlatformIdAtom = atom(0) - -const RolePlatforms = ({ roleId }: Props) => { - const { onOpen } = useAddRewardContext() - - const { watch } = useFormContext() - - const { fields, append, remove } = useFieldArray< - RoleFormType, - "rolePlatforms", - "fieldId" - >({ - name: "rolePlatforms", - keyName: "fieldId", - }) - const watchFieldArray = watch("rolePlatforms") - const controlledFields = fields.map((field, index) => ({ - ...field, - ...watchFieldArray[index], - })) - - return ( -
- - - - } - > - - {!controlledFields || controlledFields?.length <= 0 ? ( - - ) : ( - controlledFields.map((rolePlatform, index) => ( - remove(index)} - /> - )) - )} - - - -
- ) -} - -const RolePlatformsWrapper = (props: Props): JSX.Element => ( - - - -) - -type RolePlatformCardProps = { - roleId?: number - rolePlatform: RoleFormType["rolePlatforms"][number] & { fieldId: string } - index: number - remove: () => void -} - -const RolePlatformCard = ({ - roleId, - rolePlatform, - index, - remove, -}: RolePlatformCardProps) => { - const { guildPlatforms } = useGuild() - const { setValue } = useFormContext() - - const setVisibilityModalProps = useVisibilityModalProps() - - const removeButtonColor = useColorModeValue("gray.700", "gray.400") - - let guildPlatform: GuildPlatformWithOptionalId, type: PlatformName - if (rolePlatform.guildPlatformId) { - guildPlatform = guildPlatforms.find( - (platform) => platform.id === rolePlatform.guildPlatformId - ) - type = PlatformType[guildPlatform?.platformId] as PlatformName - } else { - guildPlatform = rolePlatform.guildPlatform - type = guildPlatform?.platformName - } - - if (!type) return null - - const isLegacyContractCallReward = - type === "CONTRACT_CALL" && - guildPlatform.platformGuildData.function === - ContractCallFunction.DEPRECATED_SIMPLE_CLAIM - - const { - cardPropsHook: useCardProps, - cardSettingsComponent, - isPlatform, - } = rewards[type] - - return ( - - { - setValue(`rolePlatforms.${index}.visibility`, visibility, { - shouldDirty: true, - }) - setValue(`rolePlatforms.${index}.visibilityRoleId`, visibilityRoleId, { - shouldDirty: true, - }) - setVisibilityModalProps.onClose() - }} - {...setVisibilityModalProps} - /> - } - cornerButton={ - !rolePlatform.isNew ? ( - - ) : ( - remove()} - /> - ) - } - actionRow={ - cardSettingsComponent && - rolePlatform.isNew && ( - - ) - } - contentRow={ - <> - {CAPACITY_TIME_PLATFORMS.includes(type) || isLegacyContractCallReward ? ( - { - setValue(`rolePlatforms.${index}.capacity`, capacity, { - shouldDirty: true, - }) - setValue(`rolePlatforms.${index}.startTime`, startTime, { - shouldDirty: true, - }) - setValue(`rolePlatforms.${index}.endTime`, endTime, { - shouldDirty: true, - }) - }} - /> - ) : type === "CONTRACT_CALL" ? ( - - ) : null} - {!!rolePlatform.dynamicAmount && ( - - )} - - } - /> - - ) -} - -export default RolePlatformsWrapper diff --git a/src/components/[guild]/RolePlatforms/components/AddRoleRewardModal/AddRoleRewardModal.tsx b/src/components/[guild]/RolePlatforms/components/AddRoleRewardModal/AddRoleRewardModal.tsx index 7e0dff5eca..b0bddc9dcc 100644 --- a/src/components/[guild]/RolePlatforms/components/AddRoleRewardModal/AddRoleRewardModal.tsx +++ b/src/components/[guild]/RolePlatforms/components/AddRoleRewardModal/AddRoleRewardModal.tsx @@ -1,7 +1,6 @@ import { ModalOverlay, Text, useDisclosure } from "@chakra-ui/react" import { useAddRewardDiscardAlert } from "components/[guild]/AddRewardButton/hooks/useAddRewardDiscardAlert" import { useAddRewardContext } from "components/[guild]/AddRewardContext" -import useGuild from "components/[guild]/hooks/useGuild" import DiscardAlert from "components/common/DiscardAlert" import { Modal } from "components/common/Modal" import rewards, { @@ -14,12 +13,11 @@ import SelectRewardPanel from "./SelectRewardPanel" import SelectExistingPlatform from "./components/SelectExistingPlatform" type Props = { - append: AddRewardPanelProps["onAdd"] + onAdd: AddRewardPanelProps["onAdd"] } -const AddRoleRewardModal = ({ append }: Props) => { - const { selection, step, isOpen, onClose, targetRoleId } = useAddRewardContext() - const { guildPlatforms } = useGuild() +const AddRoleRewardModal = ({ onAdd }: Props) => { + const { selection, step, isOpen, onClose } = useAddRewardContext() const { isOpen: isDiscardAlertOpen, @@ -35,21 +33,8 @@ const AddRoleRewardModal = ({ append }: Props) => { const isRewardSetupStep = selection && step !== "HOME" && step !== "SELECT_ROLE" const handleAddReward = (data: any) => { - const rolePlatformWithGuildPlatform = { ...data, visibility: roleVisibility } - - const existingGuildPlatform = guildPlatforms?.find( - (gp) => - gp.platformId === data.guildPlatform?.platformId && - gp.platformGuildId === data.guildPlatform?.platformGuildId - ) - - if (existingGuildPlatform) { - rolePlatformWithGuildPlatform.guildPlatform = existingGuildPlatform - rolePlatformWithGuildPlatform.roleId = targetRoleId - rolePlatformWithGuildPlatform.guildPlatformId = existingGuildPlatform.id - } - - append(rolePlatformWithGuildPlatform) + const rolePlatformWithVisibility = { ...data, visibility: roleVisibility } + onAdd(rolePlatformWithVisibility) onClose() } @@ -89,10 +74,7 @@ const AddRoleRewardModal = ({ append }: Props) => { ERC20: `Token rewards cannot be added to existing roles. Please use the "Add reward" button in the top right corner of the Guild page to create the reward with a new role.`, }} > - append?.(selectedRolePlatform)} - /> + Add new reward diff --git a/src/components/[guild]/RolePlatforms/components/AddRoleRewardModal/DefaultAddRewardPanelWrapper.tsx b/src/components/[guild]/RolePlatforms/components/AddRoleRewardModal/DefaultAddRewardPanelWrapper.tsx index da534d4ce5..54222aadcf 100644 --- a/src/components/[guild]/RolePlatforms/components/AddRoleRewardModal/DefaultAddRewardPanelWrapper.tsx +++ b/src/components/[guild]/RolePlatforms/components/AddRoleRewardModal/DefaultAddRewardPanelWrapper.tsx @@ -14,8 +14,10 @@ import { ReactNode } from "react" export const DefaultAddRewardPanelWrapper = ({ children, + onCancel, }: { children: ReactNode + onCancel?: () => void }) => { const { modalRef, selection, setStep } = useAddRewardContext() @@ -31,7 +33,7 @@ export const DefaultAddRewardPanelWrapper = ({ mb="-3px" icon={} variant="ghost" - onClick={() => setStep("HOME")} + onClick={onCancel ? onCancel : () => setStep("HOME")} /> {`Add ${rewards[selection]?.name} reward`} diff --git a/src/components/[guild]/RolePlatforms/components/AddRoleRewardModal/components/AddPointsPanel/AddPointsPanel.tsx b/src/components/[guild]/RolePlatforms/components/AddRoleRewardModal/components/AddPointsPanel/AddPointsPanel.tsx index 5c41ce707d..d72f8cbba8 100644 --- a/src/components/[guild]/RolePlatforms/components/AddRoleRewardModal/components/AddPointsPanel/AddPointsPanel.tsx +++ b/src/components/[guild]/RolePlatforms/components/AddRoleRewardModal/components/AddPointsPanel/AddPointsPanel.tsx @@ -24,7 +24,7 @@ export type AddPointsFormType = { } } -const AddPointsPanel = ({ onAdd }: AddRewardPanelProps) => { +const AddPointsPanel = ({ onAdd, onCancel }: AddRewardPanelProps) => { const { id, guildPlatforms } = useGuild() const { targetRoleId } = useAddRewardContext() @@ -103,7 +103,7 @@ const AddPointsPanel = ({ onAdd }: AddRewardPanelProps) => { return ( - + Gamify your guild with a score system, so users can collect points / XP / your custom branded score, and compete on a leaderboard. You’ll also be diff --git a/src/components/[guild]/RolePlatforms/components/AddRoleRewardModal/components/AddPointsPanel/components/SetPointsAmount/SetPointsAmount.tsx b/src/components/[guild]/RolePlatforms/components/AddRoleRewardModal/components/AddPointsPanel/components/SetPointsAmount/SetPointsAmount.tsx index 91aed74c39..1f5c2715ec 100644 --- a/src/components/[guild]/RolePlatforms/components/AddRoleRewardModal/components/AddPointsPanel/components/SetPointsAmount/SetPointsAmount.tsx +++ b/src/components/[guild]/RolePlatforms/components/AddRoleRewardModal/components/AddPointsPanel/components/SetPointsAmount/SetPointsAmount.tsx @@ -9,12 +9,12 @@ import StaticPointsAmountForm from "./components/StaticPointsAmountForm" const SetPointsAmount = ({ imageUrl, name, - baseFieldPath, + baseFieldPath = "", defaultDynamicAmount = false, }) => { const [type, setType] = useState(defaultDynamicAmount ? "dynamic" : "static") - const { setValue, unregister } = useFormContext() + const { setValue } = useFormContext() const { targetRoleId } = useAddRewardContext() const handleTypeChange = (newType: "dynamic" | "static") => { diff --git a/src/components/[guild]/RolePlatforms/components/AddRoleRewardModal/components/AddPointsPanel/components/SetPointsAmount/components/DynamicPointsAmountForm.tsx b/src/components/[guild]/RolePlatforms/components/AddRoleRewardModal/components/AddPointsPanel/components/SetPointsAmount/components/DynamicPointsAmountForm.tsx index 9237649e03..15a029d8c5 100644 --- a/src/components/[guild]/RolePlatforms/components/AddRoleRewardModal/components/AddPointsPanel/components/SetPointsAmount/components/DynamicPointsAmountForm.tsx +++ b/src/components/[guild]/RolePlatforms/components/AddRoleRewardModal/components/AddPointsPanel/components/SetPointsAmount/components/DynamicPointsAmountForm.tsx @@ -1,5 +1,4 @@ import { Icon, Text, useColorModeValue, useDisclosure } from "@chakra-ui/react" -import { useAddRewardContext } from "components/[guild]/AddRewardContext" import DynamicRewardSetup from "components/[guild]/RolePlatforms/components/AddRoleRewardModal/components/DynamicSetup/DynamicRewardSetup" import Button from "components/common/Button" import OptionImage from "components/common/StyledSelect/components/CustomSelectOption/components/OptionImage" @@ -8,7 +7,6 @@ import type { ReactNode } from "react" import InformationModal from "../../../../DynamicSetup/InformationModal" const DynamicPointsAmountForm = ({ imageUrl, baseFieldPath }) => { - const { targetRoleId } = useAddRewardContext() const { isOpen, onClose, onOpen } = useDisclosure() const learnMoreOpacity = useColorModeValue(1, 0.7) @@ -35,7 +33,6 @@ const DynamicPointsAmountForm = ({ imageUrl, baseFieldPath }) => { { - const { targetRoleId } = useAddRewardContext() - const options = [ { label: "Static", @@ -40,9 +36,6 @@ const PointsAmountTypeSelector = ({ type, setType }) => { description: "User points will be calculated based on a dynamic value, e.g. token balance", value: "dynamic", - disabled: - !targetRoleId && - "You can set up Dynamic points by editing an existing role, as they depend on the role's requirements", }, ] @@ -74,18 +67,11 @@ const PointsAmountTypeSelector = ({ type, setType }) => { value={option.value} py="2.5" borderBottomWidth={i !== options.length - 1 && 1} - isDisabled={!!option.disabled} > - - - {option.label} - {option.description} - - + + {option.label} + {option.description} + ))} diff --git a/src/components/[guild]/RolePlatforms/components/AddRoleRewardModal/components/DynamicSetup/BaseValueModal.tsx b/src/components/[guild]/RolePlatforms/components/AddRoleRewardModal/components/DynamicSetup/BaseValueModal.tsx index fff9883457..c62cc081e4 100644 --- a/src/components/[guild]/RolePlatforms/components/AddRoleRewardModal/components/DynamicSetup/BaseValueModal.tsx +++ b/src/components/[guild]/RolePlatforms/components/AddRoleRewardModal/components/DynamicSetup/BaseValueModal.tsx @@ -9,43 +9,31 @@ import { VStack, } from "@chakra-ui/react" import LogicDivider from "components/[guild]/LogicDivider" +import { useRequirementHandlerContext } from "components/[guild]/RequirementHandlerContext" import RequirementDisplayComponent from "components/[guild]/Requirements/components/RequirementDisplayComponent" -import useRequirements from "components/[guild]/hooks/useRequirements" import DisplayCard from "components/common/DisplayCard" import { Modal } from "components/common/Modal" import AddRequirement from "components/create-guild/Requirements/components/AddRequirement" -import useCreateRequirement from "components/create-guild/Requirements/hooks/useCreateRequirement" import { CaretRight } from "phosphor-react" import { REQUIREMENT_PROVIDED_VALUES } from "requirements/requirements" -import { Requirement } from "types" type Props = { - roleId: number isOpen: boolean onClose: () => void onSelect: (reqId: number) => void } -const BaseValueModal = ({ roleId, isOpen, onClose, onSelect }: Props) => { - const { data: requirements, mutate, isLoading } = useRequirements(roleId) +const BaseValueModal = ({ isOpen, onClose, onSelect }: Props) => { + const { + requirements, + requirementsLoading, + addRequirementLoading, + onAddRequirement, + } = useRequirementHandlerContext() const dynamicRequirements = requirements?.filter((req) => !!REQUIREMENT_PROVIDED_VALUES[req.type]) || [] - const { - onSubmit: onCreateRequirementSubmit, - isLoading: isCreateRequirementLoading, - } = useCreateRequirement(roleId, { - onSuccess: () => { - mutate() - }, - onError: () => {}, - }) - - const addRequirement = (req: Requirement) => { - onCreateRequirementSubmit(req) - } - const Loader = () => ( @@ -75,7 +63,7 @@ const BaseValueModal = ({ roleId, isOpen, onClose, onSelect }: Props) => { Choose a base value provided by a requirement on this role. - {isLoading || isCreateRequirementLoading ? ( + {addRequirementLoading || requirementsLoading ? ( ) : ( <> @@ -99,7 +87,7 @@ const BaseValueModal = ({ roleId, isOpen, onClose, onSelect }: Props) => { - + ) : ( <> @@ -107,10 +95,10 @@ const BaseValueModal = ({ roleId, isOpen, onClose, onSelect }: Props) => { You need to set up a requirement on this role first, to provide a base value for your dynamic reward. - {isLoading || isCreateRequirementLoading ? ( + {addRequirementLoading || requirementsLoading ? ( ) : ( - + )} )} diff --git a/src/components/[guild]/RolePlatforms/components/AddRoleRewardModal/components/DynamicSetup/DynamicRewardSetup.tsx b/src/components/[guild]/RolePlatforms/components/AddRoleRewardModal/components/DynamicSetup/DynamicRewardSetup.tsx index 4a2cdbd451..a27623586d 100644 --- a/src/components/[guild]/RolePlatforms/components/AddRoleRewardModal/components/DynamicSetup/DynamicRewardSetup.tsx +++ b/src/components/[guild]/RolePlatforms/components/AddRoleRewardModal/components/DynamicSetup/DynamicRewardSetup.tsx @@ -8,8 +8,8 @@ import { Text, useDisclosure, } from "@chakra-ui/react" +import { useRequirementHandlerContext } from "components/[guild]/RequirementHandlerContext" import RequirementDisplayComponent from "components/[guild]/Requirements/components/RequirementDisplayComponent" -import useRequirements from "components/[guild]/hooks/useRequirements" import AddCard from "components/common/AddCard" import Button from "components/common/Button" import Card from "components/common/Card" @@ -20,23 +20,20 @@ import BaseValueModal from "./BaseValueModal" const DynamicRewardSetup = ({ toImage, - roleId, requirementFieldName, multiplierFieldName, shouldFloor, }: { toImage: JSX.Element fieldName?: string - roleId: number requirementFieldName: string multiplierFieldName: string shouldFloor?: boolean }) => { const { control, setValue } = useFormContext() + const { requirements } = useRequirementHandlerContext() const requirementId = useWatch({ name: requirementFieldName, control }) - - const { data: requirements } = useRequirements(roleId) const selectedRequirement = requirements?.find((req) => req.id === requirementId) const multiplier = useWatch({ name: multiplierFieldName, control }) @@ -97,7 +94,6 @@ const DynamicRewardSetup = ({ { diff --git a/src/components/[guild]/RolePlatforms/components/AddRoleRewardModal/components/SelectExistingPlatform.tsx b/src/components/[guild]/RolePlatforms/components/AddRoleRewardModal/components/SelectExistingPlatform.tsx index 787fac3a34..c1cd7647c6 100644 --- a/src/components/[guild]/RolePlatforms/components/AddRoleRewardModal/components/SelectExistingPlatform.tsx +++ b/src/components/[guild]/RolePlatforms/components/AddRoleRewardModal/components/SelectExistingPlatform.tsx @@ -1,13 +1,12 @@ -import { SimpleGrid, Text } from "@chakra-ui/react" +import { SimpleGrid, Text, useDisclosure } from "@chakra-ui/react" import { useAddRewardContext } from "components/[guild]/AddRewardContext" import LogicDivider from "components/[guild]/LogicDivider" -import { openRewardSettingsGuildPlatformIdAtom } from "components/[guild]/RolePlatforms/RolePlatforms" import useGuild from "components/[guild]/hooks/useGuild" import { DISPLAY_CARD_INTERACTIVITY_STYLES } from "components/common/DisplayCard" -import { useSetAtom } from "jotai" import rewards, { PlatformAsRewardRestrictions } from "platforms/rewards" import { useWatch } from "react-hook-form" import { PlatformType, Requirement, RoleFormType, Visibility } from "types" +import EditRolePlatformModal from "../../EditRolePlatformModal" import PlatformCard from "../../PlatformCard" type Props = { @@ -20,9 +19,6 @@ type Props = { } const SelectExistingPlatform = ({ onClose, onSelect }: Props) => { - const setOpenGuildPlatformSettingsId = useSetAtom( - openRewardSettingsGuildPlatformIdAtom - ) const { guildPlatforms, roles } = useGuild() const alreadyUsedRolePlatforms = roles ?.flatMap((role) => role.rolePlatforms) @@ -47,6 +43,7 @@ const SelectExistingPlatform = ({ onClose, onSelect }: Props) => { ) const { targetRoleId } = useAddRewardContext() + const { onOpen, onClose: settingsOnClose, isOpen } = useDisclosure() if (!filteredPlatforms.length) return null @@ -68,33 +65,49 @@ const SelectExistingPlatform = ({ onClose, onSelect }: Props) => { platform.platformGuildData?.mimeType === "application/vnd.google-apps.form" + const rolePlatformData = { + guildPlatformId: platform.id, + guildPlatform: platform, + isNew: true, + roleId: targetRoleId, + ...(isGoogleReward && { + platformRoleId: isForm ? "writer" : "reader", + }), + visibility: roleVisibility, + } + return ( - { - onSelect({ - guildPlatformId: platform.id, - guildPlatform: platform, - isNew: true, - roleId: targetRoleId, - platformRoleId: isGoogleReward - ? isForm - ? "writer" - : "reader" - : null, - visibility: roleVisibility, - }) - if (cardSettingsComponent) - setOpenGuildPlatformSettingsId(platform.id) - - onClose() - }} - description={null} - {...DISPLAY_CARD_INTERACTIVITY_STYLES} - > + <> + { + if (!!cardSettingsComponent) { + onOpen() + return + } + onSelect(rolePlatformData) + onClose() + }} + description={null} + {...DISPLAY_CARD_INTERACTIVITY_STYLES} + /> + + {cardSettingsComponent && ( + { + onSelect({ ...rolePlatformData, ...data }) + onClose() + }} + onClose={settingsOnClose} + /> + )} + ) })} diff --git a/src/components/[guild]/RolePlatforms/components/EditRolePlatformButton.tsx b/src/components/[guild]/RolePlatforms/components/EditRolePlatformButton.tsx deleted file mode 100644 index aa61849d09..0000000000 --- a/src/components/[guild]/RolePlatforms/components/EditRolePlatformButton.tsx +++ /dev/null @@ -1,84 +0,0 @@ -import { - ModalBody, - ModalContent, - ModalFooter, - ModalHeader, - ModalOverlay, - VStack, -} from "@chakra-ui/react" -import Button from "components/common/Button" -import { Modal } from "components/common/Modal" -import { useAtom } from "jotai" -import rewards, { CardSettingsComponent } from "platforms/rewards" -import { useRef } from "react" -import { useFormState } from "react-hook-form" -import { PlatformType, RoleFormType } from "types" -import { openRewardSettingsGuildPlatformIdAtom } from "../RolePlatforms" -import { useRolePlatform } from "./RolePlatformProvider" - -type Props = { - SettingsComponent: CardSettingsComponent - rolePlatform: RoleFormType["rolePlatforms"][number] -} - -const EditRolePlatformButton = ({ SettingsComponent, rolePlatform }: Props) => { - const [openGuildPlatformSettingsId, setOpenGuildPlatformSettingsId] = useAtom( - openRewardSettingsGuildPlatformIdAtom - ) - const isOpen = openGuildPlatformSettingsId === rolePlatform.guildPlatformId - const onOpen = () => setOpenGuildPlatformSettingsId(rolePlatform.guildPlatformId) - const onClose = () => setOpenGuildPlatformSettingsId(null) - - const modalContentRef = useRef() - const { - index, - guildPlatform: { platformId }, - } = useRolePlatform() - - const { errors } = useFormState() - const hasError = !!errors?.rolePlatforms?.[index] - - const rewardName = - rolePlatform.guildPlatform?.platformGuildName ?? - rewards[PlatformType[platformId]].name - - return ( - <> - - - - - {`${rewardName} reward settings`} - - - - - - - - - - - - - ) -} - -export default EditRolePlatformButton diff --git a/src/components/[guild]/RolePlatforms/components/EditRolePlatformModal.tsx b/src/components/[guild]/RolePlatforms/components/EditRolePlatformModal.tsx new file mode 100644 index 0000000000..ea1b522963 --- /dev/null +++ b/src/components/[guild]/RolePlatforms/components/EditRolePlatformModal.tsx @@ -0,0 +1,72 @@ +import { + ModalBody, + ModalContent, + ModalFooter, + ModalHeader, + ModalOverlay, + VStack, +} from "@chakra-ui/react" +import Button from "components/common/Button" +import { Modal } from "components/common/Modal" +import rewards, { CardSettingsComponent } from "platforms/rewards" +import { useRef } from "react" +import { FormProvider, useForm } from "react-hook-form" +import { PlatformType, RoleFormType, RolePlatform } from "types" +import { RolePlatformProvider } from "./RolePlatformProvider" + +type Props = { + settingsComponent: CardSettingsComponent + rolePlatform: RoleFormType["rolePlatforms"][number] + onSubmit: (data: Partial) => void + onClose: () => void + isOpen: boolean +} + +const EditRolePlatformModal = ({ + settingsComponent: SettingsComponent, + rolePlatform, + onClose, + isOpen, + onSubmit, +}: Props) => { + const methods = useForm() + + const modalContentRef = useRef() + + const rewardName = + rolePlatform.guildPlatform?.platformGuildName ?? + rewards[PlatformType[rolePlatform.guildPlatform.platformId]].name + + return ( + + + + {`${rewardName} reward settings`} + + + + + + + + + + + + + + + + ) +} + +export default EditRolePlatformModal diff --git a/src/components/[guild]/RolePlatforms/index.ts b/src/components/[guild]/RolePlatforms/index.ts index 571e82cdb3..026085e1b0 100644 --- a/src/components/[guild]/RolePlatforms/index.ts +++ b/src/components/[guild]/RolePlatforms/index.ts @@ -1 +1 @@ -export { default } from "./RolePlatforms" +export { default } from "./AddRolePlatforms" diff --git a/src/components/create-guild/Requirements/SetRequirements.tsx b/src/components/create-guild/Requirements/SetRequirements.tsx index 581e98d06b..d2c812ed76 100644 --- a/src/components/create-guild/Requirements/SetRequirements.tsx +++ b/src/components/create-guild/Requirements/SetRequirements.tsx @@ -4,61 +4,39 @@ import CardMotionWrapper from "components/common/CardMotionWrapper" import { SectionTitle } from "components/common/Section" import { AnimatePresence } from "framer-motion" import useToast from "hooks/useToast" -import { useFieldArray, useFormContext, useWatch } from "react-hook-form" +import { useFormContext, useWatch } from "react-hook-form" import { RequirementType } from "requirements" import FreeRequirement from "requirements/Free/FreeRequirement" -import { GuildFormType, Requirement } from "types" +import { GuildFormType, Requirement, RolePlatform } from "types" import AddRequirement from "./components/AddRequirement" import BalancyCounterWithPopover from "./components/BalancyCounter" import LogicFormControl from "./components/LogicFormControl" import RequirementBaseCard from "./components/RequirementBaseCard" import RequirementEditableCard from "./components/RequirementEditableCard" +import useHandleRequirementState from "./hooks/useHandleRequirementState" type Props = { titleSize?: ChakraProps["fontSize"] } const SetRequirements = ({ titleSize = undefined }: Props): JSX.Element => { - const { getValues, watch } = useFormContext() - + const methods = useFormContext() + const { getValues } = methods const logic = useWatch({ name: "logic" }) + const { requirements, append, remove, update, freeEntry } = + useHandleRequirementState(methods) - const { - fields, - append: appendToFieldArray, - update, - remove, - } = useFieldArray({ - name: "requirements", - keyName: "formFieldId", - }) - - // Watching the nested fields too, so we can properly update the list - const watchFieldArray = watch("requirements") - const controlledFields = fields.map((field, index) => ({ - ...field, - ...watchFieldArray?.[index], - })) - const freeEntry = !!getValues("requirements")?.some(({ type }) => type === "FREE") - - const removeReq = (index: number) => { - if (controlledFields.length === 1) { - remove(0) - appendToFieldArray({ type: "FREE" }) - } else { - remove(index) - } - } + const rolePlatforms: RolePlatform[] = useWatch({ name: "rolePlatforms" }) - const append = (req: Requirement) => { - if (freeEntry) { - remove(0) - } + const toast = useToast() - appendToFieldArray(req) - } + const isProviderReq = (req: Requirement) => + rolePlatforms.some((rp) => { + if (!rp.dynamicAmount) return false - const toast = useToast() + const input: any = rp.dynamicAmount.operation.input + return input.requirementId === req.id + }) return ( @@ -85,32 +63,25 @@ const SetRequirements = ({ titleSize = undefined }: Props): JSX.Element => { ) : ( - controlledFields.map((field, i) => { + requirements.map((req, i) => { const type: RequirementType = getValues(`requirements.${i}.type`) return ( - + { - /** - * TODO: check if the role has an ERC20 reward & only show this - * toast in that case. - * - * We decided to leave it as is for now, because we can only - * add this requirement type for ERC20 requirements. - */ - if (type === "GUILD_SNAPSHOT") { + if (isProviderReq(req)) { toast({ status: "info", title: - "The snapshot requirement is necessary for dynamic token rewards, therefore cannot be removed.", + "The requirement is necessary for dynamic token rewards, therefore cannot be removed.", }) return } - removeReq(idx) + remove(idx) }} updateRequirement={update} isEditDisabled={type === "PAYMENT" || type === "GUILD_SNAPSHOT"} diff --git a/src/components/create-guild/Requirements/components/RequirementEditModal.tsx b/src/components/create-guild/Requirements/components/RequirementEditModal.tsx index f6df4d2b6f..a86bed7312 100644 --- a/src/components/create-guild/Requirements/components/RequirementEditModal.tsx +++ b/src/components/create-guild/Requirements/components/RequirementEditModal.tsx @@ -70,7 +70,9 @@ const RequirementEditModal = ({ {REQUIREMENTS[requirementField.type].isNegatable && ( )} - + {!!FormComponent && ( + + )} {footer} diff --git a/src/components/create-guild/Requirements/hooks/useHandleRequirementState.ts b/src/components/create-guild/Requirements/hooks/useHandleRequirementState.ts new file mode 100644 index 0000000000..672ef57e06 --- /dev/null +++ b/src/components/create-guild/Requirements/hooks/useHandleRequirementState.ts @@ -0,0 +1,38 @@ +import { useFieldArray } from "react-hook-form" +import { Requirement, RoleFormType } from "types" + +const useHandleRequirementState = (methods) => { + const requirements = methods.watch("requirements") + const { + append: addRequirement, + remove, + update, + } = useFieldArray({ + name: "requirements", + control: methods.control, + }) + const freeEntry = !!methods + .getValues("requirements") + ?.some(({ type }) => type === "FREE") + + const removeReq = (index: number) => { + if (requirements.length === 1) { + remove(0) + addRequirement({ type: "FREE" }) + } else { + remove(index) + } + } + + const append = (req: Requirement) => { + const reqToAdd = { id: Date.now(), ...req } + if (freeEntry) { + remove(0) + } + addRequirement(reqToAdd) + } + + return { requirements, append, remove: removeReq, update, freeEntry } +} + +export default useHandleRequirementState diff --git a/src/components/create-guild/hooks/useCreateRole.tsx b/src/components/create-guild/hooks/useCreateRole.tsx index 801b943634..5c57b88f36 100644 --- a/src/components/create-guild/hooks/useCreateRole.tsx +++ b/src/components/create-guild/hooks/useCreateRole.tsx @@ -1,6 +1,7 @@ import processConnectorError from "components/[guild]/JoinModal/utils/processConnectorError" import useGuild from "components/[guild]/hooks/useGuild" import useRoleGroup from "components/[guild]/hooks/useRoleGroup" +import { usePostHogContext } from "components/_app/PostHogProvider" import useJsConfetti from "components/create-guild/hooks/useJsConfetti" import { useYourGuilds } from "components/explorer/YourGuilds" import useCustomPosthogEvents from "hooks/useCustomPosthogEvents" @@ -29,9 +30,11 @@ type CreateRoleResponse = Role & { const useCreateRole = ({ onSuccess, onError, + skipMutate, }: { onSuccess?: (res?: CreateRoleResponse) => void onError?: (error: any) => void + skipMutate?: boolean }) => { const { id, mutateGuild } = useGuild() const group = useRoleGroup() @@ -43,6 +46,11 @@ const useCreateRole = ({ const showErrorToast = useShowErrorToast() const triggerConfetti = useJsConfetti() + const { captureEvent } = usePostHogContext() + const postHogOptions = { + hook: "useCreateRole", + } + const fetchData = async ( signedValidation: SignedValidation ): Promise => @@ -54,6 +62,7 @@ const useCreateRole = ({ error: processConnectorError(error_.error) ?? error_.error, correlationId: error_.correlationId, }) + captureEvent("Failed to create role", { ...postHogOptions, error_ }) onError?.(error_) }, onSuccess: async (response_) => { @@ -65,19 +74,21 @@ const useCreateRole = ({ }) } - mutateYourGuilds((prev) => mutateGuildsCache(prev, id), { - revalidate: false, - }) - matchMutate( - /\/guilds\?order/, - (prev) => mutateGuildsCache(prev, id), - { revalidate: false } - ) - - mutateGuild((curr) => ({ - ...curr, - roles: [...curr.roles, response_], - })) + if (!skipMutate) { + mutateYourGuilds((prev) => mutateGuildsCache(prev, id), { + revalidate: false, + }) + matchMutate( + /\/guilds\?order/, + (prev) => mutateGuildsCache(prev, id), + { revalidate: false } + ) + + mutateGuild((curr) => ({ + ...curr, + roles: [...curr.roles, response_], + })) + } window.location.hash = `role-${response_.id}` onSuccess?.(response_) @@ -99,7 +110,7 @@ const useCreateRole = ({ } } -const mutateGuildsCache = (prev: GuildBase[], guildId: number) => +export const mutateGuildsCache = (prev: GuildBase[], guildId: number) => prev?.map((guild) => { if (guild.id !== guildId) return guild return { diff --git a/src/hooks/useCreateRRR.tsx b/src/hooks/useCreateRRR.tsx new file mode 100644 index 0000000000..fc19102bd1 --- /dev/null +++ b/src/hooks/useCreateRRR.tsx @@ -0,0 +1,167 @@ +import useCreateRequirements from "components/[guild]/AddRewardButton/hooks/useCreateRequirements" +import useCreateRolePlatforms from "components/[guild]/AddRewardButton/hooks/useCreateRolePlatforms" +import useMutateAdditionsToRoles from "components/[guild]/AddRewardButton/hooks/useMutateAdditionsToRoles" +import useMutateCreatedRole from "components/[guild]/AddRewardButton/hooks/useMutateCreatedRole" +import { usePostHogContext } from "components/_app/PostHogProvider" +import useCreateRole, { + RoleToCreate, +} from "components/create-guild/hooks/useCreateRole" +import useShowErrorToast from "hooks/useShowErrorToast" +import useSubmit from "hooks/useSubmit" +import useToast from "hooks/useToast" +import { Requirement } from "types" +import { mapRealRequirementIdsToRolePlatforms } from "utils/mapRealRequirementIdToRolePlatform" + +export type SubmitData = + /** + * If RoleToCreate is provided and `roleIds` is empty, a new role will be created + * with the associated rolePlatforms and requirements. + */ + Partial & { + /** + * Array of role IDs. If provided, rolePlatforms and requirements will be added + * to all specified roles. If not provided, RoleToCreate will be used to create a + * new role and associate them with it. + */ + roleIds?: number[] + + /** + * Array of requirements. If referenced in a rolePlatform, the requirement should + * have a temporal `id` generated with Date.now() A requirementIdMap will be + * created to match each temporalId-roleId pair with the actual backend-created + * ID after creation. + */ + requirements: RoleToCreate["requirements"] + + /** + * Array of rolePlatforms. These are created last, and their `roleId` fields will + * be filled based on the `roleIds` array or the new role ID if a new role was + * created. + */ + rolePlatforms: RoleToCreate["rolePlatforms"] + } + +/** + * A map to keep track of the real requirement IDs after creation. + * + * During dynamic reward setup, requirements are referenced by a temporary ID + * (`tempRequirementId`). + * + * After the requirements are created, these references need to be updated with the + * real IDs of the created requirements. + * + * On the UI, we provide the option to add a reward (with its referenced + * requirements) to multiple roles. Because of this, after creation, each requirement + * will have multiple real IDs, one for each role it was assigned to. + * + * This map is structured to support this double indexing: + * + * - The outer object is indexed by the temporary requirement ID. + * - Each entry contains another object where the keys are role IDs. + * - The values in the innermost object are the real requirement IDs assigned by the + * backend. + */ +export type RequirementIdMap = { + [tempRequirementId: number]: { + [roleId: number]: number // real requirement ID assigned by the backend + } +} + +const useCreateRRR = ({ onSuccess }: { onSuccess: (res) => void }) => { + const toast = useToast() + const showErrorToast = useShowErrorToast() + const { captureEvent } = usePostHogContext() + const postHogOptions = { + hook: "useCreateRRR", + } + + const mutateCreatedRole = useMutateCreatedRole() + const mutateAdditionsToRoles = useMutateAdditionsToRoles() + + const { + onSubmit: createRole, + isSigning, + signLoadingText, + } = useCreateRole({ + skipMutate: true, + }) + const { createRequirements } = useCreateRequirements() + const { createRolePlatforms } = useCreateRolePlatforms() + + const submit = async (data: SubmitData) => { + const { requirements, rolePlatforms, roleIds: rawRoleIds = [], ...role } = data + const roleIds = rawRoleIds.map(Number) + + // If no roleIds are set, that means a new role needs to be created + let createdRole = null + if (roleIds.length == 0) { + const emptyRole = { + ...(role as RoleToCreate), + requirements: [{ type: "FREE" } as Requirement], + rolePlatforms: [], + } + + try { + createdRole = await createRole(emptyRole) + } catch (error) { + showErrorToast("Failed to create role") + return + } + + roleIds.push(createdRole.id) + } + + // Create the requirements, and the tempId - realId mapping (`requirementIdMap`) + const { createdRequirements, requirementIdMap } = await createRequirements( + requirements, + roleIds + ) + + // Update the requirement references according to the requirementIdMap + const transformedRolePlatforms = mapRealRequirementIdsToRolePlatforms({ + roleIds, + rolePlatforms, + requirementIdMap, + onMissingId: () => + showErrorToast( + `Skipping a reward creation, as its referenced requirement was not successfully created` + ), + }) + + const createdRolePlatforms = await createRolePlatforms(transformedRolePlatforms) + return { roleIds, createdRole, createdRequirements, createdRolePlatforms } + } + + const { onSubmit: submitWrapper, isLoading } = useSubmit(submit, { + onSuccess: (res) => { + const { roleIds, createdRole, createdRequirements, createdRolePlatforms } = res + + toast({ + title: "Role successfully created", + status: "success", + }) + + if (!!createdRole) + mutateCreatedRole(createdRole, createdRequirements, createdRolePlatforms) + if (!createdRole) + mutateAdditionsToRoles(roleIds, createdRequirements, createdRolePlatforms) + + onSuccess?.(res) + }, + onError: (error) => { + showErrorToast("An unexpected error happened while saving your changes") + captureEvent("Failed to create RRR", { ...postHogOptions, error }) + console.error(error) + }, + }) + + const loadingText = signLoadingText || "Saving data" + + return { + onSubmit: submitWrapper, + loadingText, + isLoading: isLoading || isSigning, + } +} + +export default useCreateRRR diff --git a/src/platforms/Discord/DiscordCardSettings/DiscordCardSettings.tsx b/src/platforms/Discord/DiscordCardSettings/DiscordCardSettings.tsx index 0d2753b7a6..ca66976dd7 100644 --- a/src/platforms/Discord/DiscordCardSettings/DiscordCardSettings.tsx +++ b/src/platforms/Discord/DiscordCardSettings/DiscordCardSettings.tsx @@ -1,5 +1,4 @@ import { FormControl, FormErrorMessage, FormLabel } from "@chakra-ui/react" -import { useRolePlatform } from "components/[guild]/RolePlatforms/components/RolePlatformProvider" import RadioSelect from "components/common/RadioSelect" import { ShieldCheck, Sparkle } from "phosphor-react" import { useController, useFormContext, useFormState } from "react-hook-form" @@ -22,7 +21,6 @@ const roleOptions = [ const DiscordCardSettings = (): JSX.Element => { const { errors } = useFormState() const { setValue } = useFormContext() - const { index } = useRolePlatform() const { field } = useController({ name: "roleType", @@ -31,7 +29,7 @@ const DiscordCardSettings = (): JSX.Element => { const handleChange = (value) => { field.onChange(value) - if (value === "NEW") setValue(`rolePlatforms.${index}.platformRoleId`, null) + if (value === "NEW") setValue(`platformRoleId`, null) } return ( diff --git a/src/platforms/Google/GoogleCardSettings.tsx b/src/platforms/Google/GoogleCardSettings.tsx index fd5c25e47f..7387a2b094 100644 --- a/src/platforms/Google/GoogleCardSettings.tsx +++ b/src/platforms/Google/GoogleCardSettings.tsx @@ -3,10 +3,10 @@ import PermissionSelection from "components/common/GoogleGuildSetup/components/P import { useController } from "react-hook-form" const GoogleCardSettings = () => { - const { guildPlatform, index } = useRolePlatform() + const { guildPlatform } = useRolePlatform() useController({ - name: `rolePlatforms.${index}.platformRoleId`, + name: `platformRoleId`, rules: { value: guildPlatform?.platformGuildData?.mimeType === @@ -18,7 +18,7 @@ const GoogleCardSettings = () => { return ( ) diff --git a/src/platforms/Points/PointsCardSettings.tsx b/src/platforms/Points/PointsCardSettings.tsx index 2e2f75a8de..fc987cacd4 100644 --- a/src/platforms/Points/PointsCardSettings.tsx +++ b/src/platforms/Points/PointsCardSettings.tsx @@ -2,13 +2,12 @@ import SetPointsAmount from "components/[guild]/RolePlatforms/components/AddRole import { useRolePlatform } from "components/[guild]/RolePlatforms/components/RolePlatformProvider" const PointsCardSettings = () => { - const { guildPlatform, index, dynamicAmount } = useRolePlatform() + const { guildPlatform, dynamicAmount } = useRolePlatform() const { name, imageUrl } = guildPlatform.platformGuildData return ( ) diff --git a/src/platforms/Token/EditDynamicRewardModal.tsx b/src/platforms/Token/EditDynamicRewardModal.tsx index 6c2407a528..054186a8be 100644 --- a/src/platforms/Token/EditDynamicRewardModal.tsx +++ b/src/platforms/Token/EditDynamicRewardModal.tsx @@ -86,7 +86,6 @@ const EditDynamicRewardModal = ({ { ? availableRoles.filter((role) => role.groupId === group.id) : availableRoles.filter((role) => !role.groupId) - const { register, unregister, setValue } = useFormContext() + const { unregister, setValue } = useFormContext() const { selection, activeTab, setActiveTab } = useAddRewardContext() const erc20Type: "REQUIREMENT_AMOUNT" | "STATIC" | null = selection === "ERC20" ? data?.dynamicAmount.operation.input.type : null const handleChange = (value: RoleTypeToAddTo) => { - /** - * This custom ERC20 condition might not be needed cause we've disabled the - * switcher since then, but maybe it will be in the future so leaving it now - */ - if (erc20Type !== "REQUIREMENT_AMOUNT") { - if (value === RoleTypeToAddTo.EXISTING_ROLE) { - unregister("requirements") - } else { - register("requirements", { value: [{ type: "FREE" }] }) - unregister("roleIds") - } + if (value === RoleTypeToAddTo.NEW_ROLE) { + unregister("roleIds") + setValue("name", data?.roleName || `New ${rewards[selection].name} role`) + setValue("imageUrl", data?.imageUrl || `/guildLogos/${getRandomInt(286)}.svg`) + setValue("roleVisibility", Visibility.PUBLIC) } + setActiveTab(value) } diff --git a/src/platforms/rewards.ts b/src/platforms/rewards.ts index 5ed2694cc1..845265f0db 100644 --- a/src/platforms/rewards.ts +++ b/src/platforms/rewards.ts @@ -1,18 +1,18 @@ -import twitterRewardV1, { twitterReward } from "platforms/Twitter" +import contractCallReward from "platforms/ContractCall" +import discordReward from "platforms/Discord" import emailReward from "platforms/Email" -import telegramReward from "platforms/Telegram" -import tokenReward from "platforms/Token" -import gatherTownReward from "platforms/Gather" import formReward from "platforms/Forms" +import gatherTownReward from "platforms/Gather" +import githubReward from "platforms/Github" +import googleReward from "platforms/Google" +import poapReward from "platforms/Poap" import pointsReward from "platforms/Points" import polygonIdReward from "platforms/PolygonID" -import uniqueTextReward from "platforms/UniqueText" import textReward from "platforms/SecretText" -import contractCallReward from "platforms/ContractCall" -import googleReward from "platforms/Google" -import discordReward from "platforms/Discord" -import githubReward from "platforms/Github" -import poapReward from "platforms/Poap" +import telegramReward from "platforms/Telegram" +import tokenReward from "platforms/Token" +import twitterRewardV1, { twitterReward } from "platforms/Twitter" +import uniqueTextReward from "platforms/UniqueText" export default { TWITTER_V1: twitterRewardV1, @@ -49,7 +49,6 @@ export const CAPACITY_TIME_PLATFORMS: PlatformName[] = [ "ERC20", ] as const -import type { GuildPlatformWithOptionalId, RoleFormType } from "types" import type { ThemingProps } from "@chakra-ui/react" import type { RewardProps } from "components/[guild]/RoleCard/components/Reward" import type { IconProps } from "phosphor-react" @@ -59,6 +58,7 @@ import type { PropsWithChildren, RefAttributes, } from "react" +import type { GuildPlatformWithOptionalId, RoleFormType } from "types" export type CardSettingsComponent = () => JSX.Element @@ -112,6 +112,7 @@ export type AddRewardPanelProps = { roleName?: string } ) => void + onCancel?: () => void skipSettings?: boolean } diff --git a/src/utils/mapRealRequirementIdToRolePlatform.ts b/src/utils/mapRealRequirementIdToRolePlatform.ts new file mode 100644 index 0000000000..2ee13434bc --- /dev/null +++ b/src/utils/mapRealRequirementIdToRolePlatform.ts @@ -0,0 +1,76 @@ +import { RequirementIdMap } from "hooks/useCreateRRR" +import { RolePlatform } from "types" + +type Props = { + rolePlatform: RolePlatform + requirementIdMap: RequirementIdMap + roleId: number + onMissingId: () => void +} + +export const mapRealRequirementIdToRolePlatform = ({ + rolePlatform, + requirementIdMap, + roleId, + onMissingId, +}: Props) => { + if (!rolePlatform.dynamicAmount) return { ...rolePlatform, roleId: roleId } + + const input: any = rolePlatform.dynamicAmount.operation.input + const requirementId = requirementIdMap[input.requirementId][roleId] + + if (!requirementId) { + onMissingId?.() + return null + } + + return { + ...rolePlatform, + roleId: roleId, + dynamicAmount: { + ...rolePlatform.dynamicAmount, + operation: { + ...rolePlatform.dynamicAmount.operation, + input: { + ...input, + requirementId, + roleId, + }, + }, + }, + } +} + +/** + * During dynamic reward setup, requirements are referenced by a temporary ID + * (`tempRequirementId`). + * + * After the requirements are created, these references need to be updated with the + * real IDs of the created requirements. + * + * This function updates these references according to the `requirementIdMap`, that + * keeps track of the temporary ID - real ID pairs. + */ +export const mapRealRequirementIdsToRolePlatforms = ({ + roleIds, + rolePlatforms, + requirementIdMap, + onMissingId, +}: { + roleIds: number[] + rolePlatforms: RolePlatform[] + requirementIdMap: RequirementIdMap + onMissingId?: () => void +}) => + roleIds.flatMap((roleId) => + rolePlatforms + .map((rolePlatform) => + mapRealRequirementIdToRolePlatform({ + rolePlatform, + requirementIdMap, + roleId, + onMissingId, + }) + ) + .filter((rp) => rp !== null) + ) From 189c9dcf997d5132f564fa4db1742902fff85781 Mon Sep 17 00:00:00 2001 From: Dominik Stumpf <122315398+dominik-stumpf@users.noreply.github.com> Date: Mon, 24 Jun 2024 14:31:06 +0200 Subject: [PATCH 02/41] Show "+ Add reward" button instead of "+ Add role" (#1315) * fix: prevent error, add types * Revert "fix: prevent error, add types" This reverts commit 874d7145124587b8042242cd3d19f88e149d40f4. * fix: disable add role change * chore: remove unused comment, import --- src/pages/[guild]/index.tsx | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/pages/[guild]/index.tsx b/src/pages/[guild]/index.tsx index c53c23f787..801de5dd6e 100644 --- a/src/pages/[guild]/index.tsx +++ b/src/pages/[guild]/index.tsx @@ -45,7 +45,7 @@ import Head from "next/head" import ErrorPage from "pages/_error" import { Info, Users } from "phosphor-react" import { MintPolygonIDProofProvider } from "platforms/PolygonID/components/MintPolygonIDProofProvider" -import { useEffect, useState } from "react" +import { useEffect } from "react" import { SWRConfig } from "swr" import { Guild, SocialLinkKey } from "types" import fetcher from "utils/fetcher" @@ -107,7 +107,6 @@ const GuildPage = (): JSX.Element => { ) const { textColor, localThemeColor, localBackgroundImage } = useThemeContext() - const [isAddRoleStuck, setIsAddRoleStuck] = useState(false) const showOnboarding = isAdmin && !onboardingComplete const accessedGuildPlatforms = useAccessedGuildPlatforms() @@ -193,8 +192,6 @@ const GuildPage = (): JSX.Element => { ) : !isAdmin ? ( - ) : isAddRoleStuck ? ( - ) : ( )} @@ -212,7 +209,7 @@ const GuildPage = (): JSX.Element => { titleRightElement={ isAdmin && ( - + ) } @@ -360,8 +357,8 @@ const getStaticPaths: GetStaticPaths = async () => { const mapToPaths = (_: Guild[]) => Array.isArray(_) ? _.map(({ urlName: guild }) => ({ - params: { guild }, - })) + params: { guild }, + })) : [] const paths = await fetcher(`/v2/guilds`).then(mapToPaths) From cbe98fb48904516e8620679873654edde59c191c Mon Sep 17 00:00:00 2001 From: BrickheadJohnny Date: Mon, 24 Jun 2024 15:34:48 +0200 Subject: [PATCH 03/41] fix(NFT setup): don't disable number inputs next to segmented controls --- .../components/CreateNftForm/components/MintPerAddressInput.tsx | 1 - .../components/CreateNftForm/components/SupplyInput.tsx | 1 - 2 files changed, 2 deletions(-) diff --git a/src/components/[guild]/RolePlatforms/components/AddRoleRewardModal/components/AddContractCallPanel/components/CreateNftForm/components/MintPerAddressInput.tsx b/src/components/[guild]/RolePlatforms/components/AddRoleRewardModal/components/AddContractCallPanel/components/CreateNftForm/components/MintPerAddressInput.tsx index 5e116a76d6..171a81cd04 100644 --- a/src/components/[guild]/RolePlatforms/components/AddRoleRewardModal/components/AddContractCallPanel/components/CreateNftForm/components/MintPerAddressInput.tsx +++ b/src/components/[guild]/RolePlatforms/components/AddRoleRewardModal/components/AddContractCallPanel/components/CreateNftForm/components/MintPerAddressInput.tsx @@ -59,7 +59,6 @@ const MintPerAddressInput = () => { { as={FormControl} colSpan={{ base: 3, md: 1 }} isInvalid={!!errors.maxSupply} - isDisabled={supplyType === "UNLIMITED"} > Max Date: Mon, 24 Jun 2024 15:53:45 +0200 Subject: [PATCH 04/41] Copy improvements (#1310) * feat(DiscordCardMenu): update customize invite link copy * fix: update `TWITTER_NAME` label * fix(requirements): "Poap" to "POAP" * fix(NftForm): update NFT address input copy * fix(FreeRequirement): update copy * fix(WalletActivity): update copy * feat(requirements): rename "Uniswap" to "Uniswap Liquidity" * feat: rename "Transaction count" to "Transactions" * fix(LeaveButton): update alert copy * fix(DiscordBotPermissionsChecker): update role position toast copy * fix(NftDataForm): better tooltip copy on the disabled button * fix: update wallet activity copy --- .../0-manage-roles.spec.ts | 4 ++-- .../[guild]/DiscordBotPermissionsChecker.tsx | 6 ++++-- .../[guild]/LeaveButton/LeaveButton.tsx | 4 ++-- .../CreateNftForm/components/NftDataForm.tsx | 4 +--- .../DiscordCardMenu/DiscordCardMenu.tsx | 6 +++--- .../components/DiscordRewardSettings.tsx.tsx | 2 +- src/requirements/Free/FreeRequirement.tsx | 10 ++++++--- src/requirements/Nft/NftForm.tsx | 7 +++++-- src/requirements/Twitter/TwitterForm.tsx | 2 +- .../WalletActivity/WalletActivityForm.tsx | 8 +++---- .../WalletActivityRequirement.tsx | 21 +++++++++++-------- .../components/CovalentFirstTx.tsx | 19 ++++++----------- .../components/CovalentFirstTxRelative.tsx | 18 ++++++---------- src/requirements/requirements.ts | 7 ++++--- 14 files changed, 58 insertions(+), 60 deletions(-) diff --git a/cypress/e2e/1-roles-requirements-rewards/0-manage-roles.spec.ts b/cypress/e2e/1-roles-requirements-rewards/0-manage-roles.spec.ts index 374f47f59e..f28519766a 100644 --- a/cypress/e2e/1-roles-requirements-rewards/0-manage-roles.spec.ts +++ b/cypress/e2e/1-roles-requirements-rewards/0-manage-roles.spec.ts @@ -46,7 +46,7 @@ describe("roles", () => { "input[name='name'] ~ .chakra-collapse .chakra-form__error-message" ).should("not.exist") - cy.contains("Connect your Ethereum wallet").should("exist") + cy.contains("Open access").should("exist") cy.getByDataTest("save-role-button").click() @@ -119,7 +119,7 @@ describe("roles", () => { .should("eq", 201) }) - cy.contains("Connect your Ethereum wallet").should("not.exist") + cy.contains("Open access").should("not.exist") }) it("can edit requirements list", () => { diff --git a/src/components/[guild]/DiscordBotPermissionsChecker.tsx b/src/components/[guild]/DiscordBotPermissionsChecker.tsx index 1b072e2d7b..9de18c9225 100644 --- a/src/components/[guild]/DiscordBotPermissionsChecker.tsx +++ b/src/components/[guild]/DiscordBotPermissionsChecker.tsx @@ -218,9 +218,11 @@ const DiscordBotPermissionsChecker = () => { if (rolesWithInvalidPosition.length > 0) { toastIdRef.current = toastWithButton({ title: "Guild.xyz Discord bot is misconfigured", - description: `Our bot won't be able to assign the following roles to your members on the ${serverName} Discord server, since they're above the Guild.xyz bot role: ${rolesWithInvalidPosition + description: `${rolesWithInvalidPosition .map((r) => r.roleName) - .join(", ")}`, + .join(", ")} ${ + rolesWithInvalidPosition.length > 1 ? "roles" : "role" + } will not be assigned to your members on the ${serverName} Discord server, since they are above the Guild.xyz bot role.`, ...toastOptions, }) setErrorType("ROLE_ORDER") diff --git a/src/components/[guild]/LeaveButton/LeaveButton.tsx b/src/components/[guild]/LeaveButton/LeaveButton.tsx index f1a06b124c..5a59df6ebe 100644 --- a/src/components/[guild]/LeaveButton/LeaveButton.tsx +++ b/src/components/[guild]/LeaveButton/LeaveButton.tsx @@ -55,8 +55,8 @@ const LeaveButton = ({ disableColoring = false }) => { Leave guild - Are you sure? You'll be able to join again as long as you satisfy the - requirements of at least one role in it. + Are you sure? You'll lose all your roles and can only get them back if + you still meet all the requirements. { Edit { const roleVisibility: Visibility = useWatch({ name: ".visibility" }) - const filteredPlatforms = guildPlatforms.filter( - (guildPlatform) => - (rewards[PlatformType[guildPlatform.platformId]].asRewardRestriction === - PlatformAsRewardRestrictions.MULTIPLE_ROLES || - !alreadyUsedRolePlatforms?.includes(guildPlatform.id)) && - // not added to the role yet - !rolePlatforms.find( - (rolePlatform: any) => rolePlatform.guildPlatformId === guildPlatform.id + const filteredPlatforms = guildPlatforms + ? guildPlatforms.filter( + (guildPlatform) => + (rewards[PlatformType[guildPlatform.platformId]].asRewardRestriction === + PlatformAsRewardRestrictions.MULTIPLE_ROLES || + !alreadyUsedRolePlatforms?.includes(guildPlatform.id)) && + // not added to the role yet + !!rolePlatforms && + !rolePlatforms.find( + (rolePlatform: any) => rolePlatform.guildPlatformId === guildPlatform.id + ) ) - ) + : [] const { targetRoleId } = useAddRewardContext() const { onOpen, onClose: settingsOnClose, isOpen } = useDisclosure() + const [selectedRolePlatform, setSelectedRolePlatform] = useState< + Partial | undefined + >() + + const handleClick = (rolePlatformData?: Partial) => { + const platformId = rolePlatformData?.guildPlatform?.platformId + const { cardSettingsComponent = null } = platformId + ? rewards[PlatformType[platformId]] + : {} + + if (cardSettingsComponent) { + setSelectedRolePlatform(rolePlatformData) + onOpen() + } else { + onSelect(rolePlatformData) + onClose() + } + } + if (!filteredPlatforms.length) return null return ( @@ -58,7 +87,7 @@ const SelectExistingPlatform = ({ onClose, onSelect }: Props) => { const platformData = rewards[PlatformType[platform.platformId]] if (!platformData) return null - const { cardPropsHook, cardSettingsComponent } = platformData + const { cardPropsHook } = platformData const isGoogleReward = platform.platformId === PlatformType.GOOGLE const isForm = @@ -79,39 +108,33 @@ const SelectExistingPlatform = ({ onClose, onSelect }: Props) => { return ( <> { - if (!!cardSettingsComponent) { - onOpen() - return - } - onSelect(rolePlatformData) - onClose() + handleClick(rolePlatformData) }} description={null} {...DISPLAY_CARD_INTERACTIVITY_STYLES} /> - - {cardSettingsComponent && ( - { - onSelect({ ...rolePlatformData, ...data }) - onClose() - }} - onClose={settingsOnClose} - /> - )} ) })} + {selectedRolePlatform && ( + { + onSelect({ ...selectedRolePlatform, ...data }) + onClose() + }} + onClose={settingsOnClose} + /> + )} + ) diff --git a/src/components/[guild]/RolePlatforms/components/EditRolePlatformModal.tsx b/src/components/[guild]/RolePlatforms/components/EditRolePlatformModal.tsx index ea1b522963..c318c80e23 100644 --- a/src/components/[guild]/RolePlatforms/components/EditRolePlatformModal.tsx +++ b/src/components/[guild]/RolePlatforms/components/EditRolePlatformModal.tsx @@ -8,14 +8,13 @@ import { } from "@chakra-ui/react" import Button from "components/common/Button" import { Modal } from "components/common/Modal" -import rewards, { CardSettingsComponent } from "platforms/rewards" +import rewards from "platforms/rewards" import { useRef } from "react" import { FormProvider, useForm } from "react-hook-form" import { PlatformType, RoleFormType, RolePlatform } from "types" import { RolePlatformProvider } from "./RolePlatformProvider" type Props = { - settingsComponent: CardSettingsComponent rolePlatform: RoleFormType["rolePlatforms"][number] onSubmit: (data: Partial) => void onClose: () => void @@ -23,7 +22,6 @@ type Props = { } const EditRolePlatformModal = ({ - settingsComponent: SettingsComponent, rolePlatform, onClose, isOpen, @@ -37,6 +35,9 @@ const EditRolePlatformModal = ({ rolePlatform.guildPlatform?.platformGuildName ?? rewards[PlatformType[rolePlatform.guildPlatform.platformId]].name + const { cardSettingsComponent: SettingsComponent } = + rewards[PlatformType[rolePlatform?.guildPlatform?.platformId]] + return ( Date: Mon, 24 Jun 2024 18:22:05 +0200 Subject: [PATCH 07/41] fix(DynamicPointsAmountForm): disable save btn if provider req is not selected --- .../components/DynamicPointsAmountForm.tsx | 19 ++++++++++++- .../components/EditRolePlatformModal.tsx | 27 ++++++++++++++----- 2 files changed, 39 insertions(+), 7 deletions(-) diff --git a/src/components/[guild]/RolePlatforms/components/AddRoleRewardModal/components/AddPointsPanel/components/SetPointsAmount/components/DynamicPointsAmountForm.tsx b/src/components/[guild]/RolePlatforms/components/AddRoleRewardModal/components/AddPointsPanel/components/SetPointsAmount/components/DynamicPointsAmountForm.tsx index 15a029d8c5..07e8b6d373 100644 --- a/src/components/[guild]/RolePlatforms/components/AddRoleRewardModal/components/AddPointsPanel/components/SetPointsAmount/components/DynamicPointsAmountForm.tsx +++ b/src/components/[guild]/RolePlatforms/components/AddRoleRewardModal/components/AddPointsPanel/components/SetPointsAmount/components/DynamicPointsAmountForm.tsx @@ -1,9 +1,11 @@ import { Icon, Text, useColorModeValue, useDisclosure } from "@chakra-ui/react" import DynamicRewardSetup from "components/[guild]/RolePlatforms/components/AddRoleRewardModal/components/DynamicSetup/DynamicRewardSetup" +import { useEditRolePlatformContext } from "components/[guild]/RolePlatforms/components/EditRolePlatformModal" import Button from "components/common/Button" import OptionImage from "components/common/StyledSelect/components/CustomSelectOption/components/OptionImage" import { ArrowSquareOut, Star } from "phosphor-react" -import type { ReactNode } from "react" +import { useEffect, type ReactNode } from "react" +import { useWatch } from "react-hook-form" import InformationModal from "../../../../DynamicSetup/InformationModal" const DynamicPointsAmountForm = ({ imageUrl, baseFieldPath }) => { @@ -16,6 +18,21 @@ const DynamicPointsAmountForm = ({ imageUrl, baseFieldPath }) => { ) + const requirementId = useWatch({ + name: `${ + baseFieldPath ? baseFieldPath + "." : "" + }dynamicAmount.operation.input.requirementId`, + }) + + const { setIsSubmitDisabled = null } = useEditRolePlatformContext() || {} + + useEffect(() => { + setIsSubmitDisabled?.(!requirementId) + return () => { + setIsSubmitDisabled?.(false) + } + }, [requirementId]) + return ( <> diff --git a/src/components/[guild]/RolePlatforms/components/EditRolePlatformModal.tsx b/src/components/[guild]/RolePlatforms/components/EditRolePlatformModal.tsx index c318c80e23..bf3503b98b 100644 --- a/src/components/[guild]/RolePlatforms/components/EditRolePlatformModal.tsx +++ b/src/components/[guild]/RolePlatforms/components/EditRolePlatformModal.tsx @@ -9,7 +9,7 @@ import { import Button from "components/common/Button" import { Modal } from "components/common/Modal" import rewards from "platforms/rewards" -import { useRef } from "react" +import { createContext, useContext, useRef, useState } from "react" import { FormProvider, useForm } from "react-hook-form" import { PlatformType, RoleFormType, RolePlatform } from "types" import { RolePlatformProvider } from "./RolePlatformProvider" @@ -21,14 +21,21 @@ type Props = { isOpen: boolean } +const EditRolePlatformContext = createContext<{ + isSubmitDisabled: boolean + setIsSubmitDisabled: (value: boolean) => void +}>(undefined) + +export const useEditRolePlatformContext = () => useContext(EditRolePlatformContext) + const EditRolePlatformModal = ({ rolePlatform, onClose, isOpen, onSubmit, }: Props) => { + const [isSubmitDisabled, setIsSubmitDisabled] = useState(false) const methods = useForm() - const modalContentRef = useRef() const rewardName = @@ -53,15 +60,23 @@ const EditRolePlatformModal = ({ - - - + + + + + - From d7b0c0c3b80b1639771b39f4e5b3a0e29e3c441b Mon Sep 17 00:00:00 2001 From: BrickheadJohnny Date: Mon, 24 Jun 2024 22:40:46 +0200 Subject: [PATCH 08/41] Revert "analytics: temporarily remove total count" This reverts commit b31d3873c605b27cf26f9121e95fe5b9b5d7ae76. --- src/components/analytics/MembersChart/MembersChart.tsx | 5 ++--- .../MembersChart/components/MembersChartLinesPanel.tsx | 5 ++--- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/components/analytics/MembersChart/MembersChart.tsx b/src/components/analytics/MembersChart/MembersChart.tsx index 09dddbf890..d0f642594c 100644 --- a/src/components/analytics/MembersChart/MembersChart.tsx +++ b/src/components/analytics/MembersChart/MembersChart.tsx @@ -200,8 +200,7 @@ const MembersChart = () => { textAnchor: "start", })} /> - {/* temporarily removed until we get accurate member counts from BE */} - {/* {data?.total && shownLines?.includes("total") && ( + {data?.total && shownLines?.includes("total") && ( { curve={curveMonotoneX} {...accessors} /> - )} */} + )} {shownRoles?.map(({ roleId, memberCounts }) => ( - {/* temporarily removed until we get accurate member counts from BE */} - {/* Total - */} + {sortedRoles?.map((role) => ( Date: Tue, 25 Jun 2024 02:03:55 +0200 Subject: [PATCH 09/41] feat(forms): answer requirements (#1279) --- .../components/Display/Choice.tsx | 2 +- .../[guild]/CreateFormModal/formConfig.tsx | 26 ++++++ src/components/common/RadioButtonGroup.tsx | 23 ++--- src/requirements/Form/FormForm.tsx | 52 +++-------- src/requirements/Form/FormRequirement.tsx | 4 +- .../components/AddExpectedAnswerModal.tsx | 70 +++++++++++++++ .../Form/{ => components}/AddFormButton.tsx | 14 ++- .../Form/{ => components}/CreateFormModal.tsx | 0 .../Form/components/ExpectedAnswerCard.tsx | 72 ++++++++++++++++ .../ExpectedMultipleChoice.tsx | 86 +++++++++++++++++++ .../ExpectedNumber.tsx | 40 +++++++++ .../ExpectedRate.tsx | 62 +++++++++++++ .../ExpectedSingleChoice.tsx | 24 ++++++ .../ExpectedString.tsx | 24 ++++++ .../Form/components/FormSelector.tsx | 55 ++++++++++++ .../Form/components/QuestionSelector.tsx | 44 ++++++++++ .../Form/components/SetExpectedAnswers.tsx | 60 +++++++++++++ 17 files changed, 604 insertions(+), 54 deletions(-) create mode 100644 src/requirements/Form/components/AddExpectedAnswerModal.tsx rename src/requirements/Form/{ => components}/AddFormButton.tsx (89%) rename src/requirements/Form/{ => components}/CreateFormModal.tsx (100%) create mode 100644 src/requirements/Form/components/ExpectedAnswerCard.tsx create mode 100644 src/requirements/Form/components/ExpectedAnswerRequirements/ExpectedMultipleChoice.tsx create mode 100644 src/requirements/Form/components/ExpectedAnswerRequirements/ExpectedNumber.tsx create mode 100644 src/requirements/Form/components/ExpectedAnswerRequirements/ExpectedRate.tsx create mode 100644 src/requirements/Form/components/ExpectedAnswerRequirements/ExpectedSingleChoice.tsx create mode 100644 src/requirements/Form/components/ExpectedAnswerRequirements/ExpectedString.tsx create mode 100644 src/requirements/Form/components/FormSelector.tsx create mode 100644 src/requirements/Form/components/QuestionSelector.tsx create mode 100644 src/requirements/Form/components/SetExpectedAnswers.tsx diff --git a/src/components/[guild]/CreateFormModal/components/Display/Choice.tsx b/src/components/[guild]/CreateFormModal/components/Display/Choice.tsx index 907440c4c9..e031f53348 100644 --- a/src/components/[guild]/CreateFormModal/components/Display/Choice.tsx +++ b/src/components/[guild]/CreateFormModal/components/Display/Choice.tsx @@ -17,7 +17,7 @@ type Props = { field: Schemas["Field"] | CreateForm["fields"][number] } -const SingleChoice = forwardRef( +const SingleChoice = forwardRef, "div">( ({ field, value, onChange, ...props }, _ref) => { // We probably won't run into this case, but needed to add this line to get valid intellisense if (field.type !== "SINGLE_CHOICE") return null diff --git a/src/components/[guild]/CreateFormModal/formConfig.tsx b/src/components/[guild]/CreateFormModal/formConfig.tsx index 3e33845190..7628806ed5 100644 --- a/src/components/[guild]/CreateFormModal/formConfig.tsx +++ b/src/components/[guild]/CreateFormModal/formConfig.tsx @@ -8,6 +8,17 @@ import { Textbox, } from "phosphor-react" import { ComponentType, ReactNode } from "react" +import { + ExpectedFieldDataProps, + ExpectedMultipleChoiceDisplay, + ExpectedRateDisplay, + ExpectedStringDisplay, +} from "requirements/Form/components/ExpectedAnswerCard" +import { ExpectedMultipleChoice } from "requirements/Form/components/ExpectedAnswerRequirements/ExpectedMultipleChoice" +import ExpectedNumber from "requirements/Form/components/ExpectedAnswerRequirements/ExpectedNumber" +import ExpectedRate from "requirements/Form/components/ExpectedAnswerRequirements/ExpectedRate" +import ExpectedSingleChoice from "requirements/Form/components/ExpectedAnswerRequirements/ExpectedSingleChoice" +import ExpectedString from "../../../requirements/Form/components/ExpectedAnswerRequirements/ExpectedString" import { CreateForm } from "../RolePlatforms/components/AddRoleRewardModal/components/AddFormPanel" import { MultipleChoice, SingleChoice } from "./components/Display/Choice" import LongText from "./components/Display/LongText" @@ -17,6 +28,7 @@ import ShortText from "./components/Display/ShortText" import ChoiceSetup from "./components/Setup/ChoiceSetup" import RateSetup from "./components/Setup/RateSetup" +// TODO: use dynamic imports so end users don't have to download the setup components const fieldTypes: { label: string value: Schemas["Field"]["type"] @@ -29,24 +41,32 @@ const fieldTypes: { isDisabled?: boolean value?: any }> + ExpectedAnswerComponent?: ComponentType<{ field: Schemas["Field"] }> + ExpectedAnswerDisplayComponent?: ComponentType }[] = [ { label: "Short text", value: "SHORT_TEXT", img: , DisplayComponent: ShortText, + ExpectedAnswerComponent: ExpectedString, + ExpectedAnswerDisplayComponent: ExpectedStringDisplay, }, { label: "Long text", value: "LONG_TEXT", img: , DisplayComponent: LongText, + ExpectedAnswerComponent: ExpectedString, + ExpectedAnswerDisplayComponent: ExpectedStringDisplay, }, { label: "Number", value: "NUMBER", img: , DisplayComponent: Number, + ExpectedAnswerComponent: ExpectedNumber, + ExpectedAnswerDisplayComponent: ExpectedStringDisplay, }, { label: "Single choice", @@ -54,6 +74,8 @@ const fieldTypes: { img: , SetupComponent: ChoiceSetup, DisplayComponent: SingleChoice, + ExpectedAnswerComponent: ExpectedSingleChoice, + ExpectedAnswerDisplayComponent: ExpectedStringDisplay, }, { label: "Multiple choice", @@ -61,6 +83,8 @@ const fieldTypes: { img: , SetupComponent: ChoiceSetup, DisplayComponent: MultipleChoice, + ExpectedAnswerComponent: ExpectedMultipleChoice, + ExpectedAnswerDisplayComponent: ExpectedMultipleChoiceDisplay, }, { label: "Rate", @@ -68,6 +92,8 @@ const fieldTypes: { img: , SetupComponent: RateSetup, DisplayComponent: Rate, + ExpectedAnswerComponent: ExpectedRate, + ExpectedAnswerDisplayComponent: ExpectedRateDisplay, }, ] diff --git a/src/components/common/RadioButtonGroup.tsx b/src/components/common/RadioButtonGroup.tsx index c685b9a18f..d52843c7f4 100644 --- a/src/components/common/RadioButtonGroup.tsx +++ b/src/components/common/RadioButtonGroup.tsx @@ -12,10 +12,12 @@ import { import Button from "./Button" interface RadioButtonOptionProps { - label?: string - icon?: React.ElementType value: string - disabled?: string + label?: string | JSX.Element + icon?: React.ElementType + colorScheme?: string + tooltipLabel?: string + isDisabled?: boolean } type RadioButtonGroupProps = { @@ -56,11 +58,11 @@ const RadioButtonGroup = ({ const radioProps = getRadioProps({ value: option.value }) return ( {} })} - colorScheme={chakraStyles?.colorScheme} + {...(!!option.isDisabled && { onChange: () => {} })} borderRadius={buttonBorderRadius} /> ) @@ -75,7 +77,7 @@ type RadioButtonProps = { } & RadioButtonOptionProps & UseRadioProps -export const RadioButton = (props: RadioButtonProps & { disabled?: string }) => { +export const RadioButton = (props: RadioButtonProps & { isDisabled?: boolean }) => { const { getInputProps, getCheckboxProps } = useRadio(props) const input = getInputProps() @@ -85,13 +87,14 @@ export const RadioButton = (props: RadioButtonProps & { disabled?: string }) => label, icon, isChecked, + tooltipLabel, colorScheme = "indigo", borderRadius, - disabled, + isDisabled, } = props return ( - + + + + + + ) +} + +export default AddExpectedAnswerModal diff --git a/src/requirements/Form/AddFormButton.tsx b/src/requirements/Form/components/AddFormButton.tsx similarity index 89% rename from src/requirements/Form/AddFormButton.tsx rename to src/requirements/Form/components/AddFormButton.tsx index 9aca3abc17..54f46f2d1c 100644 --- a/src/requirements/Form/AddFormButton.tsx +++ b/src/requirements/Form/components/AddFormButton.tsx @@ -11,7 +11,7 @@ import { import { FormProvider, useForm, useFormContext, useWatch } from "react-hook-form" import CreateFormModal from "./CreateFormModal" -const AddFormButton = ({ baseFieldPath }: { baseFieldPath: string }) => { +const AddFormButton = ({ baseFieldPath, isDisabled }) => { const { setSelection, step, setStep, isOpen, onOpen, onClose } = useAddRewardContext() @@ -44,7 +44,13 @@ const AddFormButton = ({ baseFieldPath }: { baseFieldPath: string }) => { return ( - @@ -87,9 +93,9 @@ const AddFormButton = ({ baseFieldPath }: { baseFieldPath: string }) => { ) } -const AddFormButtonWrapper = ({ baseFieldPath }: { baseFieldPath: string }) => ( +const AddFormButtonWrapper = (props) => ( - + ) diff --git a/src/requirements/Form/CreateFormModal.tsx b/src/requirements/Form/components/CreateFormModal.tsx similarity index 100% rename from src/requirements/Form/CreateFormModal.tsx rename to src/requirements/Form/components/CreateFormModal.tsx diff --git a/src/requirements/Form/components/ExpectedAnswerCard.tsx b/src/requirements/Form/components/ExpectedAnswerCard.tsx new file mode 100644 index 0000000000..47f545939b --- /dev/null +++ b/src/requirements/Form/components/ExpectedAnswerCard.tsx @@ -0,0 +1,72 @@ +import { HStack, Tag, Text, Tooltip, Wrap } from "@chakra-ui/react" +import { Schemas } from "@guildxyz/types" +import { fieldTypes } from "components/[guild]/CreateFormModal/formConfig" +import Card from "components/common/Card" +import RemoveRequirementButton from "components/create-guild/Requirements/components/RemoveRequirementButton" + +// couldn't do type based props so just having all props here as optional, works well enough +export type ExpectedFieldDataProps = { + value?: string + minAmount?: number + maxAmount?: number + acceptedAnswers?: string[] + rejectedAnswers?: string[] +} + +type Props = { + field: Schemas["Form"]["fields"][0] + onRemove: () => void +} & ExpectedFieldDataProps + +const ExpectedAnswerCard = ({ field, onRemove, ...data }: Props) => { + if (!field) return null + + const selectedFieldType = fieldTypes.find((ft) => ft.value === field?.type) + + return ( + + {field.question} + + + + ) +} + +export const ExpectedStringDisplay = ({ value }: ExpectedFieldDataProps) => ( + {`"${value}"`} +) + +export const ExpectedRateDisplay = ({ + minAmount, + maxAmount, +}: ExpectedFieldDataProps) => ( + + {minAmount} + - + {maxAmount} + +) + +export const ExpectedMultipleChoiceDisplay = ({ + acceptedAnswers, + rejectedAnswers, +}: ExpectedFieldDataProps) => ( + + {acceptedAnswers.map((value) => ( + + + {value} + + + ))} + {rejectedAnswers.map((value) => ( + + + {value} + + + ))} + +) + +export default ExpectedAnswerCard diff --git a/src/requirements/Form/components/ExpectedAnswerRequirements/ExpectedMultipleChoice.tsx b/src/requirements/Form/components/ExpectedAnswerRequirements/ExpectedMultipleChoice.tsx new file mode 100644 index 0000000000..97b135fd51 --- /dev/null +++ b/src/requirements/Form/components/ExpectedAnswerRequirements/ExpectedMultipleChoice.tsx @@ -0,0 +1,86 @@ +import { FormControl, FormLabel, HStack, Stack, Text } from "@chakra-ui/react" +import FormErrorMessage from "components/common/FormErrorMessage" +import RadioButtonGroup from "components/common/RadioButtonGroup" +import { Check, Minus, X } from "phosphor-react" +import { useFieldArray, useFormContext, useFormState } from "react-hook-form" + +export const ExpectedMultipleChoice = ({ field }) => { + const { getValues } = useFormContext() + const { errors } = useFormState() + + const acceptedAnswers = useFieldArray({ name: `acceptedAnswers` }) + const rejectedAnswers = useFieldArray({ name: `rejectedAnswers` }) + + // using getValues because using just fields from the useFieldArrays above doesn't work + const findIndexInArray = (fieldName, option) => + getValues(fieldName)?.findIndex((f) => f === option.toString()) + + const onChange = (option, newValue: "include" | "exclude" | "ignore") => { + const acceptedIndex = findIndexInArray("acceptedAnswers", option) + const rejectedIndex = findIndexInArray("rejectedAnswers", option) + if (acceptedIndex > -1) acceptedAnswers.remove(acceptedIndex) + if (rejectedIndex > -1) rejectedAnswers.remove(rejectedIndex) + + if (newValue === "include") acceptedAnswers.append(option) + if (newValue === "exclude") rejectedAnswers.append(option) + } + + return ( + + Options to select + + + {field?.options?.map((option) => ( + -1 + ? "include" + : findIndexInArray("rejectedAnswers", option) > -1 + ? "exclude" + : "ignore" + } + onChange={(newValue) => onChange(option, newValue)} + /> + ))} + + + + {errors?.acceptedAnswers?.root?.message as string} + + + ) +} + +const options = [ + { + label: , + value: "include", + colorScheme: "green", + tooltipLabel: "Must be selected", + }, + { + label: , + value: "ignore", + tooltipLabel: "Doesn't matter if selected or not", + }, + { + label: , + value: "exclude", + colorScheme: "red", + tooltipLabel: "Must not be selected", + }, +] + +const ExpectedChoiceOption = ({ option, value, onChange }) => ( + + + {option} + +) diff --git a/src/requirements/Form/components/ExpectedAnswerRequirements/ExpectedNumber.tsx b/src/requirements/Form/components/ExpectedAnswerRequirements/ExpectedNumber.tsx new file mode 100644 index 0000000000..f325c2378d --- /dev/null +++ b/src/requirements/Form/components/ExpectedAnswerRequirements/ExpectedNumber.tsx @@ -0,0 +1,40 @@ +import { + FormControl, + FormErrorMessage, + FormLabel, + NumberDecrementStepper, + NumberIncrementStepper, + NumberInput, + NumberInputField, + NumberInputStepper, +} from "@chakra-ui/react" +import { useFormContext, useFormState } from "react-hook-form" + +const ExpectedNumber = () => { + const { register } = useFormContext() + const { errors } = useFormState() + + return ( + + Answer should be equal to + + + + + + + + + + {errors?.value?.message as string} + + ) +} + +export default ExpectedNumber diff --git a/src/requirements/Form/components/ExpectedAnswerRequirements/ExpectedRate.tsx b/src/requirements/Form/components/ExpectedAnswerRequirements/ExpectedRate.tsx new file mode 100644 index 0000000000..a23eee2310 --- /dev/null +++ b/src/requirements/Form/components/ExpectedAnswerRequirements/ExpectedRate.tsx @@ -0,0 +1,62 @@ +import { + FormControl, + FormErrorMessage, + FormLabel, + HStack, + NumberDecrementStepper, + NumberIncrementStepper, + NumberInput, + NumberInputField, + NumberInputStepper, +} from "@chakra-ui/react" +import { useFormContext, useFormState } from "react-hook-form" + +const ExpectedRate = ({ field }) => { + const { register } = useFormContext() + const { errors } = useFormState() + + const minValue = field.options[0] + const maxValue = field.options.at(-1) + + const inputRules = { + required: "This field is required", + min: { value: minValue, message: `Minimum value is ${minValue}` }, + max: { value: maxValue, message: `Maximum value is ${maxValue}` }, + shouldUnregister: true, + } + + return ( + + + Min rating + + + + + + + + {errors?.minAmount?.message as string} + + + Max rating + + + + + + + + {errors?.maxAmount?.message as string} + + + ) +} + +export default ExpectedRate diff --git a/src/requirements/Form/components/ExpectedAnswerRequirements/ExpectedSingleChoice.tsx b/src/requirements/Form/components/ExpectedAnswerRequirements/ExpectedSingleChoice.tsx new file mode 100644 index 0000000000..a4aca3f906 --- /dev/null +++ b/src/requirements/Form/components/ExpectedAnswerRequirements/ExpectedSingleChoice.tsx @@ -0,0 +1,24 @@ +import { FormControl, FormLabel } from "@chakra-ui/react" +import { SingleChoice } from "components/[guild]/CreateFormModal/components/Display/Choice" +import FormErrorMessage from "components/common/FormErrorMessage" +import { useController, useFormState } from "react-hook-form" + +const ExpectedSingleChoice = ({ field }) => { + const { errors } = useFormState() + const { field: controllerField } = useController({ + name: "value", + rules: { required: "This field is required" }, + }) + + return ( + + Option to select + + + + {errors?.value?.message as string} + + ) +} + +export default ExpectedSingleChoice diff --git a/src/requirements/Form/components/ExpectedAnswerRequirements/ExpectedString.tsx b/src/requirements/Form/components/ExpectedAnswerRequirements/ExpectedString.tsx new file mode 100644 index 0000000000..b340ec6cfe --- /dev/null +++ b/src/requirements/Form/components/ExpectedAnswerRequirements/ExpectedString.tsx @@ -0,0 +1,24 @@ +import { FormControl, FormErrorMessage, FormLabel, Input } from "@chakra-ui/react" +import { Controller, useFormContext, useFormState } from "react-hook-form" + +const ExpectedString = () => { + const { control } = useFormContext() + const { errors } = useFormState() + + return ( + + Answer should be equal to + + } + /> + + {errors?.value?.message as string} + + ) +} + +export default ExpectedString diff --git a/src/requirements/Form/components/FormSelector.tsx b/src/requirements/Form/components/FormSelector.tsx new file mode 100644 index 0000000000..aed1f54e9e --- /dev/null +++ b/src/requirements/Form/components/FormSelector.tsx @@ -0,0 +1,55 @@ +import { FormControl, FormLabel, HStack } from "@chakra-ui/react" +import useGuild from "components/[guild]/hooks/useGuild" +import useGuildForms from "components/[guild]/hooks/useGuildForms" +import ControlledSelect from "components/common/ControlledSelect" +import FormErrorMessage from "components/common/FormErrorMessage" +import { useFormState } from "react-hook-form" +import { RequirementFormProps } from "requirements" +import { PlatformType, SelectOption } from "types" +import parseFromObject from "utils/parseFromObject" +import AddFormButton from "./AddFormButton" + +const FormSelector = ({ + baseFieldPath, + isDisabled, +}: RequirementFormProps & { isDisabled?: boolean }) => { + const { errors } = useFormState() + const { guildPlatforms } = useGuild() + const formRewardIds = + guildPlatforms + ?.filter((gp) => gp.platformId === PlatformType.FORM) + .map((gp) => gp.platformGuildData.formId) ?? [] + const { data: forms, isLoading, isValidating } = useGuildForms() + + const formOptions: SelectOption[] = + forms + ?.filter((form) => formRewardIds.includes(form.id)) + .map((form) => ({ + label: form.name, + value: form.id, + })) ?? [] + + return ( + + + Fill form + + + + + + {parseFromObject(errors, baseFieldPath)?.data?.id?.message} + + + ) +} + +export default FormSelector diff --git a/src/requirements/Form/components/QuestionSelector.tsx b/src/requirements/Form/components/QuestionSelector.tsx new file mode 100644 index 0000000000..b48eb7725e --- /dev/null +++ b/src/requirements/Form/components/QuestionSelector.tsx @@ -0,0 +1,44 @@ +import { FormControl, FormLabel, HStack } from "@chakra-ui/react" +import { useGuildForm } from "components/[guild]/hooks/useGuildForms" +import ControlledSelect from "components/common/ControlledSelect" +import FormErrorMessage from "components/common/FormErrorMessage" +import { useFormState } from "react-hook-form" +import { SelectOption } from "types" + +const QuestionSelector = ({ + formId, + disabledQuestions, +}: { + formId: number + disabledQuestions: string[] +}) => { + const { errors } = useFormState() + const { form, isLoading, isValidating } = useGuildForm(formId) + + if (!formId) return null + + const questionOptions: SelectOption[] = + form.fields?.map((field) => ({ + label: field.question, + value: field.id, + isDisabled: disabledQuestions.includes(field.id), + })) ?? [] + + return ( + + + Select question + + + + {errors?.fieldId?.message as string} + + ) +} + +export default QuestionSelector diff --git a/src/requirements/Form/components/SetExpectedAnswers.tsx b/src/requirements/Form/components/SetExpectedAnswers.tsx new file mode 100644 index 0000000000..92b2bdf5cd --- /dev/null +++ b/src/requirements/Form/components/SetExpectedAnswers.tsx @@ -0,0 +1,60 @@ +import { Box, Stack, Text, useDisclosure } from "@chakra-ui/react" +import { useGuildForm } from "components/[guild]/hooks/useGuildForms" +import AddCard from "components/common/AddCard" +import CardMotionWrapper from "components/common/CardMotionWrapper" +import { AnimatePresence } from "framer-motion" +import { useFieldArray } from "react-hook-form" +import AddExpectedAnswerModal from "./AddExpectedAnswerModal" +import ExpectedAnswerCard, { ExpectedFieldDataProps } from "./ExpectedAnswerCard" + +type FieldData = { + id: string + fieldId: string +} & ExpectedFieldDataProps + +const SetExpectedAnswers = ({ isDisabled, formId, baseFieldPath }) => { + const { isOpen, onOpen, onClose } = useDisclosure() + + const { form } = useGuildForm(formId) + + const { fields, append, remove } = useFieldArray({ + name: `${baseFieldPath}.data.answers`, + }) + + const alreadyAddedFields = fields.map((f: any) => f.fieldId) + + return ( + + + {`Set expected answers `} + + (optional) + + + + + {fields?.map((field: FieldData, index) => ( + + f.id === field.fieldId)} + {...field} + onRemove={() => remove(index)} + /> + + ))} + {(!formId || fields.length < form?.fields?.length) && ( + + + + )} + + + + + ) +} + +export default SetExpectedAnswers From a0013f0ca2760ab9c81ef303a75bf125fc7b7500 Mon Sep 17 00:00:00 2001 From: BrickheadJohnny Date: Tue, 25 Jun 2024 07:44:47 +0200 Subject: [PATCH 10/41] fix(AccessHub): "No rewards yet" message for simple users --- src/components/[guild]/AccessHub/AccessHub.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/components/[guild]/AccessHub/AccessHub.tsx b/src/components/[guild]/AccessHub/AccessHub.tsx index 9ca70f03f2..d82b79c2ec 100644 --- a/src/components/[guild]/AccessHub/AccessHub.tsx +++ b/src/components/[guild]/AccessHub/AccessHub.tsx @@ -137,9 +137,9 @@ const AccessHub = (): JSX.Element => { {!group ? "No accessed reward" : "No rewards yet"} - {!group - ? "You're a member of the guild, but your roles don't give you any auto-managed rewards. The owner might add some in the future or reward you another way!" - : "This page doesn’t have any auto-managed rewards yet. Add some roles below so their rewards will appear here!"} + {!!group && isAdmin + ? "This page doesn’t have any auto-managed rewards yet. Add some roles below so their rewards will appear here!" + : "You're a member of the guild, but your roles don't give you any auto-managed rewards. The owner might add some in the future or reward you another way!"} From 494d5a27285167bbc08789f9af59fa2551dc973f Mon Sep 17 00:00:00 2001 From: cs-balazs <44908417+cs-balazs@users.noreply.github.com> Date: Tue, 25 Jun 2024 09:58:02 +0200 Subject: [PATCH 11/41] feat: Farcaster as identity (#1301) * add Farcaster identity type & config * Farcaster logic * changes to satisfy tsc * move magic numbers to top-level constants * posthog events * dev env * bump @guildxyz/types * Revert "dev env" This reverts commit 493e6f8395dd08f0973e0d3f2205eb9e869713f0. * bump @guildxyz/types * Reapply "dev env" This reverts commit caf759a3ffb4d8d4beaa1d958b251e8899e09831. * add FARCASTER color scheme * requirement connect button * small changes on the modal * changes for mobile view * change imageUrl * Revert "Reapply "dev env"" This reverts commit 4f18d925d2afe96e364e8ac2a0e9d67506b6bedb. * refactor: FarcasterIcon as SVG import * revert tsc changes in MultiPlatfotmSelectButton * fix: typo * fix(FarcasterProfile): wrap Text * revert useCountdownSeconds changes & use usehooks-ts --- package-lock.json | 23 +- package.json | 3 +- .../ConnectRequirementPlatformButton.tsx | 11 +- .../components/AccountConnections.tsx | 21 +- .../SocialAccount/FarcasterProfile.tsx | 325 ++++++++++++++++++ .../components/MultiPlatformSelectButton.tsx | 1 + src/platforms/Farcaster/index.ts | 12 + src/platforms/rewards.ts | 2 + .../Farcaster/FarcasterRequirement.tsx | 32 +- src/static/socialIcons/farcaster.svg | 1 + src/theme/colors.ts | 12 + src/types.ts | 5 +- 12 files changed, 428 insertions(+), 20 deletions(-) create mode 100644 src/components/common/Layout/components/Account/components/AccountModal/components/SocialAccount/FarcasterProfile.tsx create mode 100644 src/platforms/Farcaster/index.ts create mode 100644 src/static/socialIcons/farcaster.svg diff --git a/package-lock.json b/package-lock.json index 0f99688700..3fd7a712f7 100644 --- a/package-lock.json +++ b/package-lock.json @@ -19,7 +19,7 @@ "@emotion/styled": "^11.11.0", "@fuels/connectors": "^0.5.0", "@fuels/react": "^0.20.0", - "@guildxyz/types": "1.9.5", + "@guildxyz/types": "1.9.21", "@hcaptcha/react-hcaptcha": "^1.4.4", "@hookform/resolvers": "^3.3.4", "@lexical/code": "^0.12.0", @@ -74,6 +74,7 @@ "remark-gfm": "^4.0.0", "slugify": "^1.6.5", "swr": "^2.2.4", + "usehooks-ts": "^3.1.0", "uuidv7": "^0.6.3", "viem": "^2.15.1", "wagmi": "^2.10.2", @@ -5189,9 +5190,9 @@ } }, "node_modules/@guildxyz/types": { - "version": "1.9.5", - "resolved": "https://registry.npmjs.org/@guildxyz/types/-/types-1.9.5.tgz", - "integrity": "sha512-RpiFbAogIOYOrQkSZTUqj6FHeAqEteqaQrUjZrv1cORHykBRGn8syE9KTiyoC/sfcIwd1VipWyX2WHPnRVeH/w==", + "version": "1.9.21", + "resolved": "https://registry.npmjs.org/@guildxyz/types/-/types-1.9.21.tgz", + "integrity": "sha512-kmKv5RIMwwQn8ka4D4UwkZLsVcyENBk+/gfyYMm4gx2ywGqlTduENACgk1bd1E2sE1UX4vmyOHQdvZNSf+WgwQ==", "dependencies": { "zod": "^3.22.4" } @@ -32201,6 +32202,20 @@ "react": "^16.8.0 || ^17.0.0 || ^18.0.0" } }, + "node_modules/usehooks-ts": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/usehooks-ts/-/usehooks-ts-3.1.0.tgz", + "integrity": "sha512-bBIa7yUyPhE1BCc0GmR96VU/15l/9gP1Ch5mYdLcFBaFGQsdmXkvjV0TtOqW1yUd6VjIwDunm+flSciCQXujiw==", + "dependencies": { + "lodash.debounce": "^4.0.8" + }, + "engines": { + "node": ">=16.15.0" + }, + "peerDependencies": { + "react": "^16.8.0 || ^17 || ^18" + } + }, "node_modules/utf-8-validate": { "version": "6.0.3", "resolved": "https://registry.npmjs.org/utf-8-validate/-/utf-8-validate-6.0.3.tgz", diff --git a/package.json b/package.json index 6750cba2a5..95c068b18b 100644 --- a/package.json +++ b/package.json @@ -29,7 +29,7 @@ "@emotion/styled": "^11.11.0", "@fuels/connectors": "^0.5.0", "@fuels/react": "^0.20.0", - "@guildxyz/types": "1.9.5", + "@guildxyz/types": "1.9.21", "@hcaptcha/react-hcaptcha": "^1.4.4", "@hookform/resolvers": "^3.3.4", "@lexical/code": "^0.12.0", @@ -84,6 +84,7 @@ "remark-gfm": "^4.0.0", "slugify": "^1.6.5", "swr": "^2.2.4", + "usehooks-ts": "^3.1.0", "uuidv7": "^0.6.3", "viem": "^2.15.1", "wagmi": "^2.10.2", diff --git a/src/components/[guild]/Requirements/components/ConnectRequirementPlatformButton.tsx b/src/components/[guild]/Requirements/components/ConnectRequirementPlatformButton.tsx index e8d4229791..23f6671599 100644 --- a/src/components/[guild]/Requirements/components/ConnectRequirementPlatformButton.tsx +++ b/src/components/[guild]/Requirements/components/ConnectRequirementPlatformButton.tsx @@ -4,6 +4,7 @@ import useMembershipUpdate from "components/[guild]/JoinModal/hooks/useMembershi import useUser from "components/[guild]/hooks/useUser" import Button from "components/common/Button" import { ConnectEmailButton } from "components/common/Layout/components/Account/components/AccountModal/components/SocialAccount/EmailAddress" +import { ConnectFarcasterButton } from "components/common/Layout/components/Account/components/AccountModal/components/SocialAccount/FarcasterProfile" import { useRoleMembership } from "components/explorer/hooks/useMembership" import useToast from "hooks/useToast" import rewards from "platforms/rewards" @@ -18,7 +19,7 @@ function requirementTypeToPlatformName(type: RequirementType): PlatformName { } const RequirementConnectButton = (props: ButtonProps) => { - const { platformUsers, emails } = useUser() + const { platformUsers, emails, farcasterProfiles } = useUser() const { type, roleId, id } = useRequirementContext() const platform = requirementTypeToPlatformName(type) @@ -38,6 +39,8 @@ const RequirementConnectButton = (props: ButtonProps) => { if ( platform === "EMAIL" ? !emails?.pending && emails?.emailAddress + : platform === "FARCASTER" + ? !farcasterProfiles || !!farcasterProfiles?.[0] : !isReconnection && (!platformUsers || platformFromDb) ) return null @@ -52,7 +55,11 @@ const RequirementConnectButton = (props: ButtonProps) => { } const ButtonComponent = - platform === "EMAIL" ? ConnectEmailButton : ConnectRequirementPlatformButton + platform === "EMAIL" + ? ConnectEmailButton + : platform === "FARCASTER" + ? ConnectFarcasterButton + : ConnectRequirementPlatformButton return ( { const { isLoading, addresses, platformUsers, sharedSocials } = useUser() @@ -37,7 +39,7 @@ const AccountConnections = () => { ?.filter((platformUser) => rewards[platformUser.platformName]?.isPlatform) ?.map((platformUser) => platformUser.platformName as string) ?? [] const notConnectedPlatforms = Object.keys(rewards).filter( - (platform: PlatformName) => + (platform) => rewards[platform].isPlatform && !connectedPlatforms?.includes(platform) ) return [...connectedPlatforms, ...notConnectedPlatforms] as PlatformName[] @@ -47,12 +49,14 @@ const AccountConnections = () => { <> } + titleRightElement={sharedSocials?.length > 0 ? : undefined} /> }> {orderedSocials.map((platform) => platform === "EMAIL" ? ( + ) : platform === "FARCASTER" ? ( + ) : ( ) @@ -62,7 +66,7 @@ const AccountConnections = () => { 1 && ( + addresses?.length > 1 ? ( <> @@ -78,7 +82,7 @@ const AccountConnections = () => { - ) + ) : undefined } spacing={3} pt="4" @@ -113,7 +117,7 @@ const AccountConnections = () => { )) .concat( - vaults?.length ? : null + vaults?.length > 0 ? : [] ) )} @@ -121,7 +125,10 @@ const AccountConnections = () => { ) } -export const AccountSection = ({ children, ...rest }) => { +export const AccountSection = ({ + children, + ...rest +}: PropsWithChildren) => { const bg = useColorModeValue("gray.50", "blackAlpha.200") return ( diff --git a/src/components/common/Layout/components/Account/components/AccountModal/components/SocialAccount/FarcasterProfile.tsx b/src/components/common/Layout/components/Account/components/AccountModal/components/SocialAccount/FarcasterProfile.tsx new file mode 100644 index 0000000000..e56bc1094b --- /dev/null +++ b/src/components/common/Layout/components/Account/components/AccountModal/components/SocialAccount/FarcasterProfile.tsx @@ -0,0 +1,325 @@ +import { + Accordion, + AccordionButton, + AccordionIcon, + AccordionItem, + AccordionPanel, + Box, + ButtonProps, + HStack, + Icon, + IconButton, + ModalBody, + ModalCloseButton, + ModalContent, + ModalFooter, + ModalHeader, + ModalOverlay, + Skeleton, + Text, + Tooltip, + VStack, + useBreakpointValue, + useDisclosure, +} from "@chakra-ui/react" +import useUser from "components/[guild]/hooks/useUser" +import { usePostHogContext } from "components/_app/PostHogProvider" +import Button from "components/common/Button" +import { Modal } from "components/common/Modal" +import useSubmit, { SignedValidation, useSubmitWithSign } from "hooks/useSubmit" +import useToast from "hooks/useToast" +import { ArrowCounterClockwise, DeviceMobileCamera } from "phosphor-react" +import rewards from "platforms/rewards" +import { QRCodeSVG } from "qrcode.react" +import { useCallback, useEffect, useState } from "react" +import { isMobile } from "react-device-detect" +import { useCountdown } from "usehooks-ts" +import fetcher, { useFetcherWithSign } from "utils/fetcher" +import DisconnectAccountButton from "./components/DisconnectAccountButton" +import SocialAccountUI from "./components/SocialAccountUI" + +// Polling will only start after this much time +const APPROVAL_POLL_INITIAL_DELAY_MS = 15_000 +// Delay between polls +const APPROVAL_POLL_INTERVAL_MS = 5000 +// Enable the manual QR regeneration button, when less than this much seconds is left +const ENABLE_REGENERATE_BUTTON_AT_SEC = 10 * 60 + +const FarcasterProfile = () => { + const { farcasterProfiles } = useUser() + const isConnected = farcasterProfiles?.length > 0 + + return ( + + {isConnected ? : } + + ) +} + +const ConnectFarcasterButton = ({ + onSuccess, + isReconnection: _, + ...props +}: ButtonProps & { onSuccess?: () => void; isReconnection?: boolean }) => { + const { captureEvent } = usePostHogContext() + const { farcasterProfiles, id: userId, mutate } = useUser() + const { isOpen, onOpen, onClose } = useDisclosure() + const fetcherWithSign = useFetcherWithSign() + const toast = useToast() + const [pollInterval, setPollInterval] = useState() + + const onApprove = () => { + captureEvent("[farcaster] request approved") + onClose() + toast({ + status: "success", + description: "Farcaster profile connected", + }) + onSuccess?.() + } + + const submitSignedKeyRequest = ( + signedPayload: SignedValidation + ): Promise<{ url: string; deadline: number; deadlineRelative: number }> => + fetcher(`/v2/users/${userId}/farcaster-signed-keys`, signedPayload) + + const [seconds, { startCountdown, resetCountdown }] = useCountdown({ + countStart: 11 * 60 - 1, // -1 Just so we don't show "11 minutes" for a second at start + }) + + const shouldEnableRegenerateButton = seconds < ENABLE_REGENERATE_BUTTON_AT_SEC + + const signedKeyRequest = useSubmitWithSign(submitSignedKeyRequest, { + onSuccess: ({ deadlineRelative }) => { + const deadline = Date.now() + deadlineRelative + startCountdown() + + if (pollInterval) { + clearInterval(pollInterval) + } + + setTimeout(() => { + const interval = setInterval(() => { + if (Date.now() > deadline) { + clearInterval(interval) + } + + fetcherWithSign([ + `/v2/users/${userId}/farcaster-profiles`, + { method: "GET" }, + ]) + .then((profiles) => { + if (profiles?.length > 0) { + mutate( + (prev) => (prev ? { ...prev, farcasterProfiles: profiles } : prev), + { + revalidate: false, + } + ).then(() => { + onApprove() + clearInterval(interval) + }) + } + }) + .catch(() => {}) + }, APPROVAL_POLL_INTERVAL_MS) + + setPollInterval(interval) + }, APPROVAL_POLL_INITIAL_DELAY_MS) + + onOpen() + }, + }) + + const onRegenerate = useCallback(() => { + resetCountdown() + signedKeyRequest.onSubmit() + }, [signedKeyRequest, resetCountdown]) + + useEffect(() => { + if (seconds > 0) return + + captureEvent("[farcaster] deadline hit") + onRegenerate() + }, [seconds, resetCountdown, captureEvent, onRegenerate]) + + const handleOnClose = () => { + captureEvent("[farcaster] connect modal closed") + stop() + signedKeyRequest.reset() + if (pollInterval) { + clearInterval(pollInterval) + } + onClose() + } + + const qrSize = useBreakpointValue({ base: 300, md: 400 }) + + return ( + <> + + + + + + + {isMobile ? ( + "Connect Farcaster" + ) : ( + <> + + Scan With your phone + + )} + + + + + {!isMobile && signedKeyRequest.response?.url && ( + + + + )} + + + + {isMobile + ? "The link is active for " + : "The QR code will be regenerated in "} + {seconds > 60 + ? `${Math.floor(seconds / 60)} minutes` + : `${seconds} seconds`} + + + + } + isLoading={signedKeyRequest.isLoading} + aria-label="Regenerate Farcaster QR code" + onClick={() => { + captureEvent("[farcaster] manual qr regeneration") + onRegenerate() + }} + /> + + + + + One Farcaster account can only be connected to{" "} + one Guild account at a time + + + + + + + + Why does Guild request write access? + + + + + + Guild is a Farcaster client. You can perform Farcaster actions, + like follow, or recast to satisfy requirements. You can also + perform these actions in external Farcaster clients, like + Warpcast, but it will take some time for Guild to grant access + based on actions in external clients + + + + + + {isMobile && ( + + + + )} + + + + ) +} + +const DisconnectFarcasterButton = () => { + const { captureEvent } = usePostHogContext() + const disclosure = useDisclosure() + const { farcasterProfiles, id, mutate } = useUser() + const fetcherWithSign = useFetcherWithSign() + const toast = useToast() + + const { onSubmit, isLoading } = useSubmit( + async (fid?: number) => { + if (!fid) { + throw new Error("Failed to disconnect Farcaster profile. FID unknown") + } + + await fetcherWithSign([ + `/v2/users/${id}/farcaster-profiles/${fid}`, + { method: "DELETE" }, + ]) + + await mutate((prev) => (prev ? { ...prev, farcasterProfiles: [] } : prev), { + revalidate: false, + }) + }, + { + onSuccess: () => { + toast({ + status: "success", + description: "Farcaster profile disconnected", + }) + disclosure.onClose() + }, + } + ) + const onConfirm = () => { + captureEvent("[farcaster] disconnect button clicked") + onSubmit(farcasterProfiles?.[0]?.fid) + } + + return ( + + ) +} + +export { ConnectFarcasterButton } +export default FarcasterProfile diff --git a/src/components/create-guild/MultiPlatformGrid/components/MultiPlatformSelectButton.tsx b/src/components/create-guild/MultiPlatformGrid/components/MultiPlatformSelectButton.tsx index ffafc7c483..8a11f6a1e8 100644 --- a/src/components/create-guild/MultiPlatformGrid/components/MultiPlatformSelectButton.tsx +++ b/src/components/create-guild/MultiPlatformGrid/components/MultiPlatformSelectButton.tsx @@ -55,6 +55,7 @@ const createGuildPlatformComponents: Record< | "FORM" | "GATHER_TOWN" | "ERC20" + | "FARCASTER" >, (props: { isOpen: boolean; onClose: () => void }) => JSX.Element > = { diff --git a/src/platforms/Farcaster/index.ts b/src/platforms/Farcaster/index.ts new file mode 100644 index 0000000000..0b7126afe1 --- /dev/null +++ b/src/platforms/Farcaster/index.ts @@ -0,0 +1,12 @@ +import { PlatformAsRewardRestrictions, RewardData } from "platforms/types" +import FarcasterIcon from "static/socialIcons/farcaster.svg" + +export default { + icon: FarcasterIcon, + imageUrl: "/requirementLogos/farcaster.png", + name: "Farcaster", + colorScheme: "FARCASTER", + gatedEntity: "farcaster", + isPlatform: true, + asRewardRestriction: PlatformAsRewardRestrictions.NOT_APPLICABLE, +} as const satisfies RewardData diff --git a/src/platforms/rewards.ts b/src/platforms/rewards.ts index 845265f0db..02e4039dc0 100644 --- a/src/platforms/rewards.ts +++ b/src/platforms/rewards.ts @@ -1,6 +1,7 @@ import contractCallReward from "platforms/ContractCall" import discordReward from "platforms/Discord" import emailReward from "platforms/Email" +import farcasterReward from "platforms/Farcaster" import formReward from "platforms/Forms" import gatherTownReward from "platforms/Gather" import githubReward from "platforms/Github" @@ -31,6 +32,7 @@ export default { DISCORD: discordReward, GITHUB: githubReward, POAP: poapReward, + FARCASTER: farcasterReward, } as const satisfies Partial // TODO: resolve duplication by renaming rewards.ts to index.ts and updating imports diff --git a/src/requirements/Farcaster/FarcasterRequirement.tsx b/src/requirements/Farcaster/FarcasterRequirement.tsx index cd27415a04..27d48c8e5f 100644 --- a/src/requirements/Farcaster/FarcasterRequirement.tsx +++ b/src/requirements/Farcaster/FarcasterRequirement.tsx @@ -1,4 +1,5 @@ import { Icon, Link, Skeleton, Text } from "@chakra-ui/react" +import RequirementConnectButton from "components/[guild]/Requirements/components/ConnectRequirementPlatformButton" import Requirement, { RequirementProps, } from "components/[guild]/Requirements/components/Requirement" @@ -12,7 +13,11 @@ import { useFarcasterChannel } from "./hooks/useFarcasterChannels" import { useFarcasterUser } from "./hooks/useFarcasterUsers" const FarcasterProfile = (props: RequirementProps) => ( - + } + {...props} + > Have a Farcaster profile ) @@ -28,6 +33,7 @@ const FarcasterFollowUser = (props: RequirementProps) => { return ( } image={farcasterUser?.pfp_url || "/requirementLogos/farcaster.png"} {...props} > @@ -51,7 +57,11 @@ const FarcasterTotalFollowers = (props: RequirementProps) => { const { data } = useRequirementContext() return ( - + } + image={REQUIREMENTS.FARCASTER.icon.toString()} + {...props} + > {`Have at least ${data?.min ?? "-"} followers on Farcaster`} ) @@ -67,7 +77,11 @@ const FarcasterLikeRecast = (props: RequirementProps) => { } = useFarcasterCast(data?.hash) return ( - + } + image={REQUIREMENTS.FARCASTER.icon.toString()} + {...props} + > {type === "FARCASTER_LIKE" ? "Like" : "Recast"} <> {" this cast: "} @@ -89,7 +103,11 @@ const FarcasterFollowChannel = (props: RequirementProps) => { const { data: farcasterChannel } = useFarcasterChannel(data?.id) return ( - + } + image={REQUIREMENTS.FARCASTER.icon.toString()} + {...props} + > {"Follow the "} { const { type, data } = useRequirementContext() return ( - + } + image={REQUIREMENTS.FARCASTER.icon.toString()} + {...props} + > {"Have "} diff --git a/src/static/socialIcons/farcaster.svg b/src/static/socialIcons/farcaster.svg new file mode 100644 index 0000000000..fcdea6b315 --- /dev/null +++ b/src/static/socialIcons/farcaster.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/theme/colors.ts b/src/theme/colors.ts index 9d9416409b..c1a4ef440a 100644 --- a/src/theme/colors.ts +++ b/src/theme/colors.ts @@ -220,6 +220,18 @@ const colors = { 800: "#4d0025", 900: "#1a000c", }, + FARCASTER: { + 50: "#f3f3fd", + 100: "#dadafa", + 200: "#c1c2f6", + 300: "#a8aaf3", + 400: "#8f91ef", + 500: "#7679ec", + 600: "#5e61e8", + 700: "#4548e5", + 800: "#2c30e1", + 900: "#1e22d3", + }, } export default colors diff --git a/src/types.ts b/src/types.ts index fa90c468be..4cf89b8bbc 100644 --- a/src/types.ts +++ b/src/types.ts @@ -1,4 +1,4 @@ -import { Schemas } from "@guildxyz/types" +import { FarcasterProfile, Schemas } from "@guildxyz/types" import { FeatureFlag } from "components/[guild]/EditGuild/components/FeatureFlags" import { ContractCallFunction } from "components/[guild]/RolePlatforms/components/AddRoleRewardModal/components/AddContractCallPanel/components/CreateNftForm/hooks/useCreateNft" import { RequirementType } from "requirements" @@ -94,6 +94,7 @@ type PlatformName = | "FORM" | "GATHER_TOWN" | "ERC20" + | "FARCASTER" type PlatformUserData = { acessToken?: string @@ -142,6 +143,8 @@ type User = { pending: boolean createdAt: Date } + + farcasterProfiles: FarcasterProfile[] } type BaseUser = { From 0c1ce996e30c0ab3b0422f6792f5fcea5a3fcccc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Csete=20Bal=C3=A1zs?= Date: Tue, 25 Jun 2024 14:35:30 +0200 Subject: [PATCH 12/41] hotfix(FarcasterProfile): remove manual regeneration button --- .../components/SocialAccount/FarcasterProfile.tsx | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/components/common/Layout/components/Account/components/AccountModal/components/SocialAccount/FarcasterProfile.tsx b/src/components/common/Layout/components/Account/components/AccountModal/components/SocialAccount/FarcasterProfile.tsx index e56bc1094b..6702fb3966 100644 --- a/src/components/common/Layout/components/Account/components/AccountModal/components/SocialAccount/FarcasterProfile.tsx +++ b/src/components/common/Layout/components/Account/components/AccountModal/components/SocialAccount/FarcasterProfile.tsx @@ -8,7 +8,6 @@ import { ButtonProps, HStack, Icon, - IconButton, ModalBody, ModalCloseButton, ModalContent, @@ -17,7 +16,6 @@ import { ModalOverlay, Skeleton, Text, - Tooltip, VStack, useBreakpointValue, useDisclosure, @@ -28,7 +26,7 @@ import Button from "components/common/Button" import { Modal } from "components/common/Modal" import useSubmit, { SignedValidation, useSubmitWithSign } from "hooks/useSubmit" import useToast from "hooks/useToast" -import { ArrowCounterClockwise, DeviceMobileCamera } from "phosphor-react" +import { DeviceMobileCamera } from "phosphor-react" import rewards from "platforms/rewards" import { QRCodeSVG } from "qrcode.react" import { useCallback, useEffect, useState } from "react" @@ -213,7 +211,7 @@ const ConnectFarcasterButton = ({ : `${seconds} seconds`} - + {/* - + */} From 9f5bc224845df91c6d2088c9faf52ef45fc3f133 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Csete=20Bal=C3=A1zs?= Date: Tue, 25 Jun 2024 14:48:01 +0200 Subject: [PATCH 13/41] Revert "hotfix(FarcasterProfile): remove manual regeneration button" This reverts commit 0c1ce996e30c0ab3b0422f6792f5fcea5a3fcccc. --- .../components/SocialAccount/FarcasterProfile.tsx | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/components/common/Layout/components/Account/components/AccountModal/components/SocialAccount/FarcasterProfile.tsx b/src/components/common/Layout/components/Account/components/AccountModal/components/SocialAccount/FarcasterProfile.tsx index 6702fb3966..e56bc1094b 100644 --- a/src/components/common/Layout/components/Account/components/AccountModal/components/SocialAccount/FarcasterProfile.tsx +++ b/src/components/common/Layout/components/Account/components/AccountModal/components/SocialAccount/FarcasterProfile.tsx @@ -8,6 +8,7 @@ import { ButtonProps, HStack, Icon, + IconButton, ModalBody, ModalCloseButton, ModalContent, @@ -16,6 +17,7 @@ import { ModalOverlay, Skeleton, Text, + Tooltip, VStack, useBreakpointValue, useDisclosure, @@ -26,7 +28,7 @@ import Button from "components/common/Button" import { Modal } from "components/common/Modal" import useSubmit, { SignedValidation, useSubmitWithSign } from "hooks/useSubmit" import useToast from "hooks/useToast" -import { DeviceMobileCamera } from "phosphor-react" +import { ArrowCounterClockwise, DeviceMobileCamera } from "phosphor-react" import rewards from "platforms/rewards" import { QRCodeSVG } from "qrcode.react" import { useCallback, useEffect, useState } from "react" @@ -211,7 +213,7 @@ const ConnectFarcasterButton = ({ : `${seconds} seconds`} - {/* + - */} + From 2c3940d373ca01cb9f4ef2f96b0aba6a8454a81e Mon Sep 17 00:00:00 2001 From: Dominik Stumpf <122315398+dominik-stumpf@users.noreply.github.com> Date: Tue, 25 Jun 2024 15:10:40 +0200 Subject: [PATCH 14/41] chore: add env variable validation (#1297) * chore: add env variable validation * chore: use new env export instead of process * chore: add missed replacements * chore: remove unused imports * chore: update env.js validation * chore: add .env.example * docs: update project setup * cleanup(env): remove unnecessary variables & add comments (#1299) * chore: remove warnings --------- Co-authored-by: BrickheadJohnny <92519134+BrickheadJohnny@users.noreply.github.com> --- .env.example | 39 +++++ README.md | 2 +- package-lock.json | 32 ++++ package.json | 1 + src/bugsnag.ts | 3 +- .../useSetRoleImageAndNameFromPlatformData.ts | 3 +- .../[guild]/DiscordBotPermissionsChecker.tsx | 3 +- .../JoinModal/hooks/useConnectPlatform.ts | 3 +- .../Fuel/hooks/useMintFuelGuildPin.ts | 3 +- .../components/ActivateGuildPinForm.tsx | 3 +- .../components/GuildPinImage.tsx | 3 +- .../components/GuildPinReward.tsx | 3 +- .../GuildCheckout/hooks/useMintGuildPin.tsx | 6 +- .../components/RequirementImageEditor.tsx | 3 +- .../CreateNftForm/hooks/useCreateNft.ts | 3 +- src/components/_app/PostHogProvider.tsx | 3 +- .../GoogleLoginButton/hooks/useDriveOAuth.ts | 3 +- .../ServerSetupCard/ServerSetupCard.tsx | 3 +- .../GoogleGuildSetup/GoogleGuildSetup.tsx | 3 +- .../components/Web3Inbox/Web3Inbox.tsx | 3 +- .../Requirements/hooks/useBalancy.ts | 18 +-- .../TelegramGroup/TelegramGroup.tsx | 3 +- .../leaderboard/PinLeaderboardUserCard.tsx | 5 +- src/env.js | 137 ++++++++++++++++++ src/hooks/usePinata/usePinata.ts | 5 +- .../[guild]/collect/[chain]/[address].tsx | 16 +- src/pages/[guild]/index.tsx | 4 +- src/pages/_app.tsx | 3 +- src/pages/api/fetchPrice.ts | 3 +- src/pages/api/leaderboard/revalidate.ts | 3 +- .../api/linkpreview/[timestamp]/[guild].tsx | 13 +- .../api/linkpreview/[timestamp]/index.tsx | 3 +- .../api/nft/collectors/[chain]/[address].ts | 13 +- src/pages/api/pinata-key.ts | 32 ++-- src/pages/api/sound/sound-artist-by-handle.ts | 3 +- src/pages/api/sound/sound-artists.ts | 3 +- src/pages/api/sound/sound-songs.ts | 3 +- .../PolygonID/components/ConnectDIDModal.tsx | 5 +- .../PolygonID/components/MintableRole.tsx | 3 +- .../components/PolygonIDQRCodeModal.tsx | 3 +- .../PolygonID/hooks/useClaimedRoles.ts | 3 +- .../PolygonID/hooks/useConnectedDID.ts | 5 +- .../components/AllowlistFormInputs.tsx | 3 +- src/requirements/Nft/NftRequirement.tsx | 3 +- src/utils/fetcher.ts | 5 +- src/utils/ipfsToGuildGateway.ts | 3 +- src/wagmiConfig/index.ts | 3 +- tsconfig.json | 2 +- 48 files changed, 331 insertions(+), 99 deletions(-) create mode 100644 .env.example create mode 100644 src/env.js diff --git a/.env.example b/.env.example new file mode 100644 index 0000000000..44f1329665 --- /dev/null +++ b/.env.example @@ -0,0 +1,39 @@ +ALCHEMY_KEY="" +ARBITRUM_ALCHEMY_KEY="" +BALANCY_TOKEN="" +BASE_ALCHEMY_KEY="" +COINBASE_PAY_API_KEY="" +CYPRESS_RECORD_KEY="" +EDGE_CONFIG="" +GOERLI_ALCHEMY_KEY="" +GUILD_API_KEY="" +IPFS_GATEWAY="" +KV_REST_API_READ_ONLY_TOKEN="" +KV_REST_API_TOKEN="" +KV_REST_API_URL="" +KV_URL="" +LEADERBOARD_REVALIDATION_SECRET="" +MAINNET_ALCHEMY_KEY="" +NACL_PUBLIC="" +NETWORK_NAME="" +NOOX_KEY="" +OPENSEA_API_KEY="" +OPTIMISM_ALCHEMY_KEY="" +PINATA_ADMIN_JWT="" +PINATA_ADMIN_KEY="" +PINATA_ADMIN_SECRET="" +POLYGON_ALCHEMY_KEY="" +POLYGON_MUMBAI_ALCHEMY_KEY="" +POSTGRES_DATABASE="" +POSTGRES_HOST="" +POSTGRES_PASSWORD="" +POSTGRES_PRISMA_URL="" +POSTGRES_URL="" +POSTGRES_URL_NON_POOLING="" +POSTGRES_USER="" +SECRET_WORDS="" +SEPOLIA_ALCHEMY_KEY="" +SOUND_API_KEY="" +WAAS_VIEM_URL="" +WAAS_WEB_URL="" +ZEROX_API_KEY="" diff --git a/README.md b/README.md index 45f6d6e47b..3925d2395a 100644 --- a/README.md +++ b/README.md @@ -35,7 +35,7 @@ Open source interface for Guild.xyz -- a tool for platformless membership manage 1. `npm i` 2. `npm run dev` -3. If you don't have the `WAAS_WEB_URL` and `WAAS_VIEM_URL` variables defined in `.env.local`, you need to run `node mockWaas.js` after `npm i`. The Google login functionality won't be available in this case +3. If you don't have the secret environment variables, copy the `.env.examples` as `.env.local`. After that you need to run `node mockWaas.js` after `npm i`. The Google login functionality won't be available in this case Open [http://localhost:3000](http://localhost:3000) in your browser to see the result. diff --git a/package-lock.json b/package-lock.json index 3fd7a712f7..fca2078231 100644 --- a/package-lock.json +++ b/package-lock.json @@ -32,6 +32,7 @@ "@lexical/utils": "^0.12.0", "@nouns/assets": "^0.4.2", "@snyk/protect": "latest", + "@t3-oss/env-nextjs": "^0.10.1", "@tanstack/react-query": "^5.26.3", "@tanstack/react-table": "^8.13.2", "@tanstack/react-virtual": "^3.5.0", @@ -10255,6 +10256,37 @@ "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.6.3.tgz", "integrity": "sha512-xNvxJEOUiWPGhUuUdQgAJPKOOJfGnIyKySOc09XkKsgdUV/3E2zvwZYdejjmRgPCgcym1juLH3226yA7sEFJKQ==" }, + "node_modules/@t3-oss/env-core": { + "version": "0.10.1", + "resolved": "https://registry.npmjs.org/@t3-oss/env-core/-/env-core-0.10.1.tgz", + "integrity": "sha512-GcKZiCfWks5CTxhezn9k5zWX3sMDIYf6Kaxy2Gx9YEQftFcz8hDRN56hcbylyAO3t4jQnQ5ifLawINsNgCDpOg==", + "peerDependencies": { + "typescript": ">=5.0.0", + "zod": "^3.0.0" + }, + "peerDependenciesMeta": { + "typescript": { + "optional": true + } + } + }, + "node_modules/@t3-oss/env-nextjs": { + "version": "0.10.1", + "resolved": "https://registry.npmjs.org/@t3-oss/env-nextjs/-/env-nextjs-0.10.1.tgz", + "integrity": "sha512-iy2qqJLnFh1RjEWno2ZeyTu0ufomkXruUsOZludzDIroUabVvHsrSjtkHqwHp1/pgPUzN3yBRHMILW162X7x2Q==", + "dependencies": { + "@t3-oss/env-core": "0.10.1" + }, + "peerDependencies": { + "typescript": ">=5.0.0", + "zod": "^3.0.0" + }, + "peerDependenciesMeta": { + "typescript": { + "optional": true + } + } + }, "node_modules/@tanstack/query-core": { "version": "5.45.0", "resolved": "https://registry.npmjs.org/@tanstack/query-core/-/query-core-5.45.0.tgz", diff --git a/package.json b/package.json index 95c068b18b..41af189f03 100644 --- a/package.json +++ b/package.json @@ -42,6 +42,7 @@ "@lexical/utils": "^0.12.0", "@nouns/assets": "^0.4.2", "@snyk/protect": "latest", + "@t3-oss/env-nextjs": "^0.10.1", "@tanstack/react-query": "^5.26.3", "@tanstack/react-table": "^8.13.2", "@tanstack/react-virtual": "^3.5.0", diff --git a/src/bugsnag.ts b/src/bugsnag.ts index f90e50bc10..3b126b35f9 100644 --- a/src/bugsnag.ts +++ b/src/bugsnag.ts @@ -1,3 +1,4 @@ +import { env } from "env" import Bugsnag from "@bugsnag/js" export const bugsnagStart = () => { @@ -9,7 +10,7 @@ export const bugsnagStart = () => { return Bugsnag.start({ - apiKey: process.env.NEXT_PUBLIC_BUGSNAG_KEY, + apiKey: env.NEXT_PUBLIC_BUGSNAG_KEY, plugins: [], endpoints: { notify: "/api/bugsnag/notify", diff --git a/src/components/[guild]/AddRewardButton/hooks/useSetRoleImageAndNameFromPlatformData.ts b/src/components/[guild]/AddRewardButton/hooks/useSetRoleImageAndNameFromPlatformData.ts index df641c1b5e..1f9bfcc588 100644 --- a/src/components/[guild]/AddRewardButton/hooks/useSetRoleImageAndNameFromPlatformData.ts +++ b/src/components/[guild]/AddRewardButton/hooks/useSetRoleImageAndNameFromPlatformData.ts @@ -1,3 +1,4 @@ +import { env } from "env" import { RoleTypeToAddTo, useAddRewardContext, @@ -35,7 +36,7 @@ const useSetRoleImageAndNameFromPlatformData = ( setAlreadyUploaded(true) - if (platformImage?.startsWith(process.env.NEXT_PUBLIC_IPFS_GATEWAY)) { + if (platformImage?.startsWith(env.NEXT_PUBLIC_IPFS_GATEWAY)) { setValue("imageUrl", platformImage) return } diff --git a/src/components/[guild]/DiscordBotPermissionsChecker.tsx b/src/components/[guild]/DiscordBotPermissionsChecker.tsx index 9de18c9225..2a9fccacb8 100644 --- a/src/components/[guild]/DiscordBotPermissionsChecker.tsx +++ b/src/components/[guild]/DiscordBotPermissionsChecker.tsx @@ -1,3 +1,4 @@ +import { env } from "env" import { ListItem, ModalBody, @@ -242,7 +243,7 @@ const DiscordBotPermissionsChecker = () => { rightIcon: , onClick: () => window.open( - `https://discord.com/api/oauth2/authorize?client_id=${process.env.NEXT_PUBLIC_DISCORD_CLIENT_ID}&permissions=268716145&scope=bot%20applications.commands` + `https://discord.com/api/oauth2/authorize?client_id=${env.NEXT_PUBLIC_DISCORD_CLIENT_ID}&permissions=268716145&scope=bot%20applications.commands` ), }, secondButtonProps: { diff --git a/src/components/[guild]/JoinModal/hooks/useConnectPlatform.ts b/src/components/[guild]/JoinModal/hooks/useConnectPlatform.ts index 3521e1fa63..0969bc37f4 100644 --- a/src/components/[guild]/JoinModal/hooks/useConnectPlatform.ts +++ b/src/components/[guild]/JoinModal/hooks/useConnectPlatform.ts @@ -1,3 +1,4 @@ +import { env } from "env" import useUser from "components/[guild]/hooks/useUser" import { usePostHogContext } from "components/_app/PostHogProvider" import { platformMergeAlertAtom } from "components/_app/Web3ConnectionManager/components/PlatformMergeErrorAlert" @@ -53,7 +54,7 @@ function getOAuthURL( scope?: AuthLevel, force?: boolean ) { - const url = new URL(`../v2/oauth/${platformName}`, process.env.NEXT_PUBLIC_API) + const url = new URL(`../v2/oauth/${platformName}`, env.NEXT_PUBLIC_API) url.searchParams.set("path", window.location.pathname) url.searchParams.set("token", authToken) if (scope) { diff --git a/src/components/[guild]/Requirements/components/GuildCheckout/MintGuildPin/Fuel/hooks/useMintFuelGuildPin.ts b/src/components/[guild]/Requirements/components/GuildCheckout/MintGuildPin/Fuel/hooks/useMintFuelGuildPin.ts index 569efd30dc..577b73dec2 100644 --- a/src/components/[guild]/Requirements/components/GuildCheckout/MintGuildPin/Fuel/hooks/useMintFuelGuildPin.ts +++ b/src/components/[guild]/Requirements/components/GuildCheckout/MintGuildPin/Fuel/hooks/useMintFuelGuildPin.ts @@ -1,3 +1,4 @@ +import { env } from "env" /* eslint-disable @typescript-eslint/naming-convention */ import { useAccount, useProvider, useWallet } from "@fuels/react" import useGuild from "components/[guild]/hooks/useGuild" @@ -132,7 +133,7 @@ const useMintFuelGuildPin = () => { // ...metadata, // image: metadata.image.replace( // "ipfs://", - // process.env.NEXT_PUBLIC_IPFS_GATEWAY + // env.NEXT_PUBLIC_IPFS_GATEWAY // ), // }, // ]) diff --git a/src/components/[guild]/Requirements/components/GuildCheckout/MintGuildPin/components/ActivateGuildPinForm.tsx b/src/components/[guild]/Requirements/components/GuildCheckout/MintGuildPin/components/ActivateGuildPinForm.tsx index 783a55317f..8b096ed8d1 100644 --- a/src/components/[guild]/Requirements/components/GuildCheckout/MintGuildPin/components/ActivateGuildPinForm.tsx +++ b/src/components/[guild]/Requirements/components/GuildCheckout/MintGuildPin/components/ActivateGuildPinForm.tsx @@ -1,3 +1,4 @@ +import { env } from "env" import { Checkbox, Stack, useColorModeValue } from "@chakra-ui/react" import useEditGuild from "components/[guild]/EditGuild/hooks/useEditGuild" import useGuild from "components/[guild]/hooks/useGuild" @@ -55,7 +56,7 @@ const ActivateGuildPinForm = (): JSX.Element => { ? () => { onCreateRoleSubmit({ guildId, - imageUrl: `${process.env.NEXT_PUBLIC_IPFS_GATEWAY}${pinImage}`, + imageUrl: `${env.NEXT_PUBLIC_IPFS_GATEWAY}${pinImage}`, name: "Pin Holder", logic: "AND", requirements: [ diff --git a/src/components/[guild]/Requirements/components/GuildCheckout/components/GuildPinImage.tsx b/src/components/[guild]/Requirements/components/GuildCheckout/components/GuildPinImage.tsx index 77a85ac8eb..af904c88b7 100644 --- a/src/components/[guild]/Requirements/components/GuildCheckout/components/GuildPinImage.tsx +++ b/src/components/[guild]/Requirements/components/GuildCheckout/components/GuildPinImage.tsx @@ -1,3 +1,4 @@ +import { env } from "env" import { AspectRatio, Box, @@ -36,7 +37,7 @@ const GuildPinImage = (): JSX.Element => { [GuildAction.IS_ADMIN]: `This is an onchain proof that you're an admin of ${name} on Guild.xyz.`, } - const pinUrl = `${process.env.NEXT_PUBLIC_IPFS_GATEWAY}${pinImage}` + const pinUrl = `${env.NEXT_PUBLIC_IPFS_GATEWAY}${pinImage}` return ( <> diff --git a/src/components/[guild]/Requirements/components/GuildCheckout/components/GuildPinReward.tsx b/src/components/[guild]/Requirements/components/GuildCheckout/components/GuildPinReward.tsx index 54fefe93fb..1ff0c37e76 100644 --- a/src/components/[guild]/Requirements/components/GuildCheckout/components/GuildPinReward.tsx +++ b/src/components/[guild]/Requirements/components/GuildCheckout/components/GuildPinReward.tsx @@ -1,3 +1,4 @@ +import { env } from "env" import { Img, Text } from "@chakra-ui/react" import useGuild from "components/[guild]/hooks/useGuild" import { RewardDisplay } from "components/[guild]/RoleCard/components/Reward" @@ -19,7 +20,7 @@ const GuildPinReward = (): JSX.Element => { Guild Pin image { chainId, tokenId, ...metadata, - image: metadata.image.replace( - "ipfs://", - process.env.NEXT_PUBLIC_IPFS_GATEWAY - ), + image: metadata.image.replace("ipfs://", env.NEXT_PUBLIC_IPFS_GATEWAY), } const updatedPins = prevData?.usersPins diff --git a/src/components/[guild]/Requirements/components/RequirementImageEditor.tsx b/src/components/[guild]/Requirements/components/RequirementImageEditor.tsx index 0a5c9d15bb..e5f3017a6a 100644 --- a/src/components/[guild]/Requirements/components/RequirementImageEditor.tsx +++ b/src/components/[guild]/Requirements/components/RequirementImageEditor.tsx @@ -1,3 +1,4 @@ +import { env } from "env" import { Circle, Icon, Spinner, Text } from "@chakra-ui/react" import usePinata from "hooks/usePinata" import useShowErrorToast from "hooks/useShowErrorToast" @@ -26,7 +27,7 @@ const RequirementImageEditor = ({ const showErrorToast = useShowErrorToast() const onSuccess = useCallback( - ({ IpfsHash }) => onSave(`${process.env.NEXT_PUBLIC_IPFS_GATEWAY}${IpfsHash}`), + ({ IpfsHash }) => onSave(`${env.NEXT_PUBLIC_IPFS_GATEWAY}${IpfsHash}`), [onSave] ) diff --git a/src/components/[guild]/RolePlatforms/components/AddRoleRewardModal/components/AddContractCallPanel/components/CreateNftForm/hooks/useCreateNft.ts b/src/components/[guild]/RolePlatforms/components/AddRoleRewardModal/components/AddContractCallPanel/components/CreateNftForm/hooks/useCreateNft.ts index 4966c5e43a..ae527a5feb 100644 --- a/src/components/[guild]/RolePlatforms/components/AddRoleRewardModal/components/AddContractCallPanel/components/CreateNftForm/hooks/useCreateNft.ts +++ b/src/components/[guild]/RolePlatforms/components/AddRoleRewardModal/components/AddContractCallPanel/components/CreateNftForm/hooks/useCreateNft.ts @@ -1,3 +1,4 @@ +import { env } from "env" import { datetimeLocalToIsoString } from "components/[guild]/RolePlatforms/components/EditRewardAvailabilityModal/components/StartEndTimeForm" import { guildNftRewardMetadataSchema } from "components/[guild]/collect/hooks/useNftDetails" import useGuild from "components/[guild]/hooks/useGuild" @@ -72,7 +73,7 @@ export type CreateNFTResponse = { export const generateGuildRewardNFTMetadata = ( data: Pick ) => { - const image = data.image?.replace(process.env.NEXT_PUBLIC_IPFS_GATEWAY, "ipfs://") + const image = data.image?.replace(env.NEXT_PUBLIC_IPFS_GATEWAY, "ipfs://") return guildNftRewardMetadataSchema.parse({ name: data.name, diff --git a/src/components/_app/PostHogProvider.tsx b/src/components/_app/PostHogProvider.tsx index eceb376dd3..ea3d700fe2 100644 --- a/src/components/_app/PostHogProvider.tsx +++ b/src/components/_app/PostHogProvider.tsx @@ -1,3 +1,4 @@ +import { env } from "env" import { useUserPublic } from "components/[guild]/hooks/useUser" import { useRouter } from "next/router" import { posthog } from "posthog-js" @@ -26,7 +27,7 @@ export const isUserRejectedError = (errorMessage: any) => : false if (typeof window !== "undefined") { - posthog.init(process.env.NEXT_PUBLIC_POSTHOG_KEY, { + posthog.init(env.NEXT_PUBLIC_POSTHOG_KEY, { api_host: "/api/posthog", // Capture custom events only autocapture: false, diff --git a/src/components/_app/Web3ConnectionManager/components/WalletSelectorModal/components/GoogleLoginButton/hooks/useDriveOAuth.ts b/src/components/_app/Web3ConnectionManager/components/WalletSelectorModal/components/GoogleLoginButton/hooks/useDriveOAuth.ts index b950819c25..587e2d6ae6 100644 --- a/src/components/_app/Web3ConnectionManager/components/WalletSelectorModal/components/GoogleLoginButton/hooks/useDriveOAuth.ts +++ b/src/components/_app/Web3ConnectionManager/components/WalletSelectorModal/components/GoogleLoginButton/hooks/useDriveOAuth.ts @@ -1,3 +1,4 @@ +import { env } from "env" import useOauthPopupWindow from "components/[guild]/JoinModal/hooks/useOauthPopupWindow" const useDriveOAuth = () => @@ -7,7 +8,7 @@ const useDriveOAuth = () => { scope: `openid email profile https://www.googleapis.com/auth/drive.file`, response_type: "token", - client_id: process.env.NEXT_PUBLIC_GOOGLE_CLIENT_ID, + client_id: env.NEXT_PUBLIC_GOOGLE_CLIENT_ID, } ) diff --git a/src/components/common/DiscordGuildSetup/components/ServerSetupCard/ServerSetupCard.tsx b/src/components/common/DiscordGuildSetup/components/ServerSetupCard/ServerSetupCard.tsx index 6f5d66a488..c7ba84b3a8 100644 --- a/src/components/common/DiscordGuildSetup/components/ServerSetupCard/ServerSetupCard.tsx +++ b/src/components/common/DiscordGuildSetup/components/ServerSetupCard/ServerSetupCard.tsx @@ -1,3 +1,4 @@ +import { env } from "env" import { Img, Skeleton, Stack, Text, VStack } from "@chakra-ui/react" import { usePostHogContext } from "components/_app/PostHogProvider" import Button from "components/common/Button" @@ -32,7 +33,7 @@ const ServerSetupCard = ({ onSubmit, serverId }: Props): JSX.Element => { ) const { onOpen: openAddBotPopup, windowInstance } = usePopupWindow( - `https://discord.com/api/oauth2/authorize?client_id=${process.env.NEXT_PUBLIC_DISCORD_CLIENT_ID}&guild_id=${serverId}&permissions=268716145&scope=bot%20applications.commands`, + `https://discord.com/api/oauth2/authorize?client_id=${env.NEXT_PUBLIC_DISCORD_CLIENT_ID}&guild_id=${serverId}&permissions=268716145&scope=bot%20applications.commands`, undefined, () => revalidatePermissions.onSubmit() ) diff --git a/src/components/common/GoogleGuildSetup/GoogleGuildSetup.tsx b/src/components/common/GoogleGuildSetup/GoogleGuildSetup.tsx index 67d14388fd..620a87f2df 100644 --- a/src/components/common/GoogleGuildSetup/GoogleGuildSetup.tsx +++ b/src/components/common/GoogleGuildSetup/GoogleGuildSetup.tsx @@ -1,3 +1,4 @@ +import { env } from "env" import { ButtonGroup, GridItem, @@ -152,7 +153,7 @@ const GoogleGuildSetup = ({ ) } -const GUILD_EMAIL_ADDRESS = process.env.NEXT_PUBLIC_GOOGLE_SERVICE_ACCOUNT_EMAIL +const GUILD_EMAIL_ADDRESS = env.NEXT_PUBLIC_GOOGLE_SERVICE_ACCOUNT_EMAIL const AddDocumentModal = ({ isOpen, onClose = undefined }) => { const { platformUsers } = useUser() const googleAcc = platformUsers?.find( diff --git a/src/components/common/Layout/components/Account/components/Web3Inbox/Web3Inbox.tsx b/src/components/common/Layout/components/Account/components/Web3Inbox/Web3Inbox.tsx index a397d37980..40ab47095c 100644 --- a/src/components/common/Layout/components/Account/components/Web3Inbox/Web3Inbox.tsx +++ b/src/components/common/Layout/components/Account/components/Web3Inbox/Web3Inbox.tsx @@ -1,3 +1,4 @@ +import { env } from "env" import { Box, Center, @@ -39,7 +40,7 @@ import WebInboxSkeleton from "./WebInboxSkeleton" const DynamicWeb3InboxMessage = dynamic(() => import("./Web3InboxMessage")) const WEB3_INBOX_INIT_PARAMS = { - projectId: process.env.NEXT_PUBLIC_WALLETCONNECT_PROJECT_ID, + projectId: env.NEXT_PUBLIC_WALLETCONNECT_PROJECT_ID, domain: "guild.xyz", allApps: process.env.NODE_ENV !== "production", } diff --git a/src/components/create-guild/Requirements/hooks/useBalancy.ts b/src/components/create-guild/Requirements/hooks/useBalancy.ts index e41ae7dfb9..b9cb2ba713 100644 --- a/src/components/create-guild/Requirements/hooks/useBalancy.ts +++ b/src/components/create-guild/Requirements/hooks/useBalancy.ts @@ -1,3 +1,4 @@ +import { env } from "env" import useDebouncedState from "hooks/useDebouncedState" import { useEffect, useMemo, useState } from "react" import { useWatch } from "react-hook-form" @@ -43,16 +44,13 @@ const NUMBER_REGEX = /^([0-9]+\.)?[0-9]+$/ const fetchHolders = async ([_, logic, requirements]): Promise => { const holdersArrays = await Promise.all( Object.keys(requirements).map((chain) => - fetcher( - `${process.env.NEXT_PUBLIC_BALANCY_API}/xyzHolders?chain=${Chains[chain]}`, - { - body: { - logic, - requirements: requirements[chain], - limit: 0, - }, - } - ).then(({ addresses }) => addresses as string[]) + fetcher(`${env.NEXT_PUBLIC_BALANCY_API}/xyzHolders?chain=${Chains[chain]}`, { + body: { + logic, + requirements: requirements[chain], + limit: 0, + }, + }).then(({ addresses }) => addresses as string[]) ) ) diff --git a/src/components/create-guild/TelegramGroup/TelegramGroup.tsx b/src/components/create-guild/TelegramGroup/TelegramGroup.tsx index 2edafae0e5..5c9fb70009 100644 --- a/src/components/create-guild/TelegramGroup/TelegramGroup.tsx +++ b/src/components/create-guild/TelegramGroup/TelegramGroup.tsx @@ -1,3 +1,4 @@ +import { env } from "env" import { FormControl, FormLabel, HStack, Icon, Input, Stack } from "@chakra-ui/react" import Button from "components/common/Button" import FormErrorMessage from "components/common/FormErrorMessage" @@ -42,7 +43,7 @@ const TelegramGroup = ({ fieldName, children }: PropsWithChildren) => { w="full" as="a" h="var(--chakra-space-11)" - href={`https://t.me/${process.env.NEXT_PUBLIC_TG_BOT_USERNAME}?startgroup=true&admin=post_messages+restrict_members+invite_users`} + href={`https://t.me/${env.NEXT_PUBLIC_TG_BOT_USERNAME}?startgroup=true&admin=post_messages+restrict_members+invite_users`} target="_blank" rightIcon={} isLoading={isValidating} diff --git a/src/components/leaderboard/PinLeaderboardUserCard.tsx b/src/components/leaderboard/PinLeaderboardUserCard.tsx index e9cd5607a5..c5eea81985 100644 --- a/src/components/leaderboard/PinLeaderboardUserCard.tsx +++ b/src/components/leaderboard/PinLeaderboardUserCard.tsx @@ -1,3 +1,4 @@ +import { env } from "env" import { Link } from "@chakra-ui/next-js" import { Center, @@ -186,7 +187,7 @@ const PinLeaderboardUserCard = ({ {pinMetadata.name} @@ -244,7 +245,7 @@ const PinLeaderboardUserCard = ({ {pinMetadata.name}({ onSuccess?.(response) if (fieldToSetOnSuccess && successFieldOnChange) { - successFieldOnChange( - `${process.env.NEXT_PUBLIC_IPFS_GATEWAY}${response.IpfsHash}` - ) + successFieldOnChange(`${env.NEXT_PUBLIC_IPFS_GATEWAY}${response.IpfsHash}`) } }, [onSuccess, fieldToSetOnSuccess, successFieldOnChange] diff --git a/src/pages/[guild]/collect/[chain]/[address].tsx b/src/pages/[guild]/collect/[chain]/[address].tsx index a60078a653..e4397fe1ac 100644 --- a/src/pages/[guild]/collect/[chain]/[address].tsx +++ b/src/pages/[guild]/collect/[chain]/[address].tsx @@ -1,3 +1,4 @@ +import { env } from "env" import { Box, Divider, @@ -245,15 +246,12 @@ const getStaticProps = async ({ params }) => { try { ;[publicGuild, guild] = await Promise.all([ fetcher(guildPageEndpoint), - fetcher( - `${process.env.NEXT_PUBLIC_API.replace("/v1", "")}${guildPageEndpoint}`, - { - headers: { - "x-guild-service": "APP", - "x-guild-auth": process.env.GUILD_API_KEY, - }, - } - ), + fetcher(`${env.NEXT_PUBLIC_API.replace("/v1", "")}${guildPageEndpoint}`, { + headers: { + "x-guild-service": "APP", + "x-guild-auth": env.GUILD_API_KEY, + }, + }), ]) } catch { return { diff --git a/src/pages/[guild]/index.tsx b/src/pages/[guild]/index.tsx index 801de5dd6e..7197ba9903 100644 --- a/src/pages/[guild]/index.tsx +++ b/src/pages/[guild]/index.tsx @@ -357,8 +357,8 @@ const getStaticPaths: GetStaticPaths = async () => { const mapToPaths = (_: Guild[]) => Array.isArray(_) ? _.map(({ urlName: guild }) => ({ - params: { guild }, - })) + params: { guild }, + })) : [] const paths = await fetcher(`/v2/guilds`).then(mapToPaths) diff --git a/src/pages/_app.tsx b/src/pages/_app.tsx index a7c8378fee..a7873286db 100644 --- a/src/pages/_app.tsx +++ b/src/pages/_app.tsx @@ -1,3 +1,4 @@ +import { env } from "env" import { Box, Progress, Slide, useColorMode } from "@chakra-ui/react" import { FuelWalletConnector, FueletWalletConnector } from "@fuels/connectors" import { FuelProvider } from "@fuels/react" @@ -82,7 +83,7 @@ const App = ({ {shouldUseReCAPTCHA && ( )} diff --git a/src/pages/api/fetchPrice.ts b/src/pages/api/fetchPrice.ts index b4caf36c1e..6a6722d579 100644 --- a/src/pages/api/fetchPrice.ts +++ b/src/pages/api/fetchPrice.ts @@ -1,3 +1,4 @@ +import { env } from "env" import { kv } from "@vercel/kv" import { NextApiHandler, NextApiRequest, NextApiResponse } from "next" import { RequirementType } from "requirements" @@ -255,7 +256,7 @@ const handler: NextApiHandler = async ( `${ZEROX_API_URLS[chain]}/swap/v1/quote?${queryParams}`, { headers: { - "0x-api-key": process.env.ZEROX_API_KEY, + "0x-api-key": env.ZEROX_API_KEY, }, } ) diff --git a/src/pages/api/leaderboard/revalidate.ts b/src/pages/api/leaderboard/revalidate.ts index 041574e8c1..3590d66308 100644 --- a/src/pages/api/leaderboard/revalidate.ts +++ b/src/pages/api/leaderboard/revalidate.ts @@ -1,3 +1,4 @@ +import { env } from "env" import { NextApiHandler, NextApiRequest, NextApiResponse } from "next" const handler: NextApiHandler = async ( @@ -10,7 +11,7 @@ const handler: NextApiHandler = async ( return } - if (req.query.secret !== process.env.LEADERBOARD_REVALIDATION_SECRET) { + if (req.query.secret !== env.LEADERBOARD_REVALIDATION_SECRET) { return res.status(401).json({ message: "Invalid token" }) } diff --git a/src/pages/api/linkpreview/[timestamp]/[guild].tsx b/src/pages/api/linkpreview/[timestamp]/[guild].tsx index 7758f03263..bc329173cc 100644 --- a/src/pages/api/linkpreview/[timestamp]/[guild].tsx +++ b/src/pages/api/linkpreview/[timestamp]/[guild].tsx @@ -1,3 +1,4 @@ +import { env } from "env" import loadGoogleFont from "fonts/loadGoogleFont" import { ImageResponse } from "next/og" import { Guild } from "types" @@ -25,12 +26,12 @@ const handler = async (req, _) => { if (!urlName) return new ImageResponse(<>, { status: 404 }) const [guild, guildRoles]: [Guild, Guild["roles"]] = await Promise.all([ - fetch( - `${process.env.NEXT_PUBLIC_API.replace("v1", "v2")}/guilds/${urlName}` - ).then((res) => res.json()), - fetch( - `${process.env.NEXT_PUBLIC_API.replace("v1", "v2")}/guilds/${urlName}/roles` - ).then((res) => res.json()), + fetch(`${env.NEXT_PUBLIC_API.replace("v1", "v2")}/guilds/${urlName}`).then( + (res) => res.json() + ), + fetch(`${env.NEXT_PUBLIC_API.replace("v1", "v2")}/guilds/${urlName}/roles`).then( + (res) => res.json() + ), ]).catch(() => [null, null]) if (!guild?.id) diff --git a/src/pages/api/linkpreview/[timestamp]/index.tsx b/src/pages/api/linkpreview/[timestamp]/index.tsx index 74d8cd4f46..974a0d8da1 100644 --- a/src/pages/api/linkpreview/[timestamp]/index.tsx +++ b/src/pages/api/linkpreview/[timestamp]/index.tsx @@ -1,3 +1,4 @@ +import { env } from "env" import loadGoogleFont from "fonts/loadGoogleFont" import { ImageResponse } from "next/og" import { GuildBase } from "types" @@ -17,7 +18,7 @@ const handler = async (req, _) => { try { const [guilds, interFontData, dystopianFontData] = await Promise.all([ - fetch(`${process.env.NEXT_PUBLIC_API.replace("v1", "v2")}/guilds`) + fetch(`${env.NEXT_PUBLIC_API.replace("v1", "v2")}/guilds`) .then((res) => res.json()) .catch((_) => []), interFont, diff --git a/src/pages/api/nft/collectors/[chain]/[address].ts b/src/pages/api/nft/collectors/[chain]/[address].ts index 5dc571c309..0245e998d5 100644 --- a/src/pages/api/nft/collectors/[chain]/[address].ts +++ b/src/pages/api/nft/collectors/[chain]/[address].ts @@ -1,4 +1,5 @@ import { ContractCallSupportedChain } from "components/[guild]/RolePlatforms/components/AddRoleRewardModal/components/AddContractCallPanel/components/CreateNftForm/hooks/useCreateNft" +import { env } from "env" import { NextApiHandler } from "next" import { OneOf } from "types" import fetcher from "utils/fetcher" @@ -22,17 +23,17 @@ export type TopCollectorsResponse = OneOf< > export const alchemyApiUrl: Record = { - POLYGON: `https://polygon-mainnet.g.alchemy.com/nft/v3/${process.env.POLYGON_ALCHEMY_KEY}/getOwnersForContract`, - BASE_MAINNET: `https://base-mainnet.g.alchemy.com/nft/v3/${process.env.BASE_ALCHEMY_KEY}/getOwnersForContract`, - ETHEREUM: `https://eth-mainnet.g.alchemy.com/nft/v3/${process.env.MAINNET_ALCHEMY_KEY}/getOwnersForContract`, - OPTIMISM: `https://opt-mainnet.g.alchemy.com/nft/v3/${process.env.OPTIMISM_ALCHEMY_KEY}/getOwnersForContract`, + POLYGON: `https://polygon-mainnet.g.alchemy.com/nft/v3/${env.POLYGON_ALCHEMY_KEY}/getOwnersForContract`, + BASE_MAINNET: `https://base-mainnet.g.alchemy.com/nft/v3/${env.BASE_ALCHEMY_KEY}/getOwnersForContract`, + ETHEREUM: `https://eth-mainnet.g.alchemy.com/nft/v3/${env.MAINNET_ALCHEMY_KEY}/getOwnersForContract`, + OPTIMISM: `https://opt-mainnet.g.alchemy.com/nft/v3/${env.OPTIMISM_ALCHEMY_KEY}/getOwnersForContract`, BSC: "", CRONOS: "", MANTLE: "", ZKSYNC_ERA: "", LINEA: "", CYBER: "", - ARBITRUM: `https://arb-mainnet.g.alchemy.com/nft/v3/${process.env.ARBITRUM_ALCHEMY_KEY}/getOwnersForContract`, + ARBITRUM: `https://arb-mainnet.g.alchemy.com/nft/v3/${env.ARBITRUM_ALCHEMY_KEY}/getOwnersForContract`, SCROLL: "", TAIKO: "", BLAST_MAINNET: "", @@ -42,7 +43,7 @@ export const alchemyApiUrl: Record = { NEON_EVM: "", POLYGON_ZKEVM: "", ZETACHAIN: "", - SEPOLIA: `https://eth-sepolia.g.alchemy.com/nft/v3/${process.env.SEPOLIA_ALCHEMY_KEY}/getOwnersForContract`, + SEPOLIA: `https://eth-sepolia.g.alchemy.com/nft/v3/${env.SEPOLIA_ALCHEMY_KEY}/getOwnersForContract`, } export const validateNftChain = (value: string | string[]): Chain => { diff --git a/src/pages/api/pinata-key.ts b/src/pages/api/pinata-key.ts index dd563f1ec1..c44f264cad 100644 --- a/src/pages/api/pinata-key.ts +++ b/src/pages/api/pinata-key.ts @@ -1,3 +1,4 @@ +import { env } from "env" import { NextApiRequest, NextApiResponse } from "next" type PinataGenerateAPIKeyResponse = { @@ -8,11 +9,11 @@ type PinataGenerateAPIKeyResponse = { const generateApiKey = async (res: NextApiResponse) => { const response = await fetch( - `${process.env.NEXT_PUBLIC_PINATA_API}/users/generateApiKey`, + `${env.NEXT_PUBLIC_PINATA_API}/users/generateApiKey`, { method: "POST", headers: { - Authorization: `Bearer ${process.env.PINATA_ADMIN_JWT}`, + Authorization: `Bearer ${env.PINATA_ADMIN_JWT}`, "Content-Type": "application/json", }, body: JSON.stringify({ @@ -49,27 +50,22 @@ const revokeApiKey = async (req: NextApiRequest, res: NextApiResponse) => { const { key: apiKey } = req.body if ( - [ - process.env.PINATA_ADMIN_KEY, - process.env.PINATA_ADMIN_JWT, - process.env.PINATA_ADMIN_SECRET, - ].includes(apiKey) + [env.PINATA_ADMIN_KEY, env.PINATA_ADMIN_JWT, env.PINATA_ADMIN_SECRET].includes( + apiKey + ) ) { res.status(400).json({ message: "Can't revoke this API key" }) return } - const response = await fetch( - `${process.env.NEXT_PUBLIC_PINATA_API}/users/revokeApiKey`, - { - method: "PUT", - headers: { - Authorization: `Bearer ${process.env.PINATA_ADMIN_JWT}`, - "Content-Type": "application/json", - }, - body: JSON.stringify({ apiKey }), - } - ) + const response = await fetch(`${env.NEXT_PUBLIC_PINATA_API}/users/revokeApiKey`, { + method: "PUT", + headers: { + Authorization: `Bearer ${env.PINATA_ADMIN_JWT}`, + "Content-Type": "application/json", + }, + body: JSON.stringify({ apiKey }), + }) if (response.ok) { res.status(200).json(null) diff --git a/src/pages/api/sound/sound-artist-by-handle.ts b/src/pages/api/sound/sound-artist-by-handle.ts index 02845d7587..b67d255036 100644 --- a/src/pages/api/sound/sound-artist-by-handle.ts +++ b/src/pages/api/sound/sound-artist-by-handle.ts @@ -1,3 +1,4 @@ +import { env } from "env" import { NextApiHandler } from "next" import fetcher from "utils/fetcher" @@ -6,7 +7,7 @@ const fetchArtist = (artistId: string) => headers: { Accept: "application/json", "Content-Type": "application/json", - "X-Sound-Client-Key": process.env.SOUND_API_KEY, + "X-Sound-Client-Key": env.SOUND_API_KEY, }, body: { query: `{ diff --git a/src/pages/api/sound/sound-artists.ts b/src/pages/api/sound/sound-artists.ts index 2d9eec1804..7ef2b1e867 100644 --- a/src/pages/api/sound/sound-artists.ts +++ b/src/pages/api/sound/sound-artists.ts @@ -1,3 +1,4 @@ +import { env } from "env" import { NextApiHandler } from "next" import fetcher from "utils/fetcher" @@ -6,7 +7,7 @@ const fetchArtists = (searchQuery: string) => headers: { Accept: "application/json", "Content-Type": "application/json", - "X-Sound-Client-Key": process.env.SOUND_API_KEY, + "X-Sound-Client-Key": env.SOUND_API_KEY, }, body: { query: `{ diff --git a/src/pages/api/sound/sound-songs.ts b/src/pages/api/sound/sound-songs.ts index eabd1222b8..60d72cf0f2 100644 --- a/src/pages/api/sound/sound-songs.ts +++ b/src/pages/api/sound/sound-songs.ts @@ -1,3 +1,4 @@ +import { env } from "env" import { NextApiHandler } from "next" import fetcher from "utils/fetcher" @@ -6,7 +7,7 @@ const fetch51Songs = (id: string, after: string) => headers: { Accept: "application/json", "Content-Type": "application/json", - "X-Sound-Client-Key": process.env.SOUND_API_KEY, + "X-Sound-Client-Key": env.SOUND_API_KEY, }, body: { query: `{ diff --git a/src/platforms/PolygonID/components/ConnectDIDModal.tsx b/src/platforms/PolygonID/components/ConnectDIDModal.tsx index 776cab9914..a6469122fc 100644 --- a/src/platforms/PolygonID/components/ConnectDIDModal.tsx +++ b/src/platforms/PolygonID/components/ConnectDIDModal.tsx @@ -1,3 +1,4 @@ +import { env } from "env" import { Box, Center, @@ -45,7 +46,7 @@ const ConnectDIDModal = ({ isOpen, onClose }: Props) => { } = useSWRImmutable( isOpen ? [ - `${process.env.NEXT_PUBLIC_POLYGONID_API}/v1/users/${userId}/polygon-id/auth`, + `${env.NEXT_PUBLIC_POLYGONID_API}/v1/users/${userId}/polygon-id/auth`, { method: "GET", }, @@ -57,7 +58,7 @@ const ConnectDIDModal = ({ isOpen, onClose }: Props) => { const { mutate: mutateConnectedDID } = useConnectedDID() const { data: connectedDID } = useSWR( userId && isOpen && qrCode - ? `${process.env.NEXT_PUBLIC_POLYGONID_API}/v1/users/${userId}/polygon-id?poll=true` + ? `${env.NEXT_PUBLIC_POLYGONID_API}/v1/users/${userId}/polygon-id?poll=true` : null, { onErrorRetry: (_error, _key, _config, revalidate, _revalidateOps) => { diff --git a/src/platforms/PolygonID/components/MintableRole.tsx b/src/platforms/PolygonID/components/MintableRole.tsx index 3b6843d72a..1471038f8f 100644 --- a/src/platforms/PolygonID/components/MintableRole.tsx +++ b/src/platforms/PolygonID/components/MintableRole.tsx @@ -1,3 +1,4 @@ +import { env } from "env" import { Card, HStack, @@ -47,7 +48,7 @@ const MintableRole = ({ role }: Props) => { ?.roleIds.find((roleId) => roleId === role.id) const claim = async (signedValidation: SignedValidation) => - fetcher(`${process.env.NEXT_PUBLIC_POLYGONID_API}/v1/polygon-id/claim`, { + fetcher(`${env.NEXT_PUBLIC_POLYGONID_API}/v1/polygon-id/claim`, { method: "POST", ...signedValidation, }) diff --git a/src/platforms/PolygonID/components/PolygonIDQRCodeModal.tsx b/src/platforms/PolygonID/components/PolygonIDQRCodeModal.tsx index 806e003d28..bec23a387d 100644 --- a/src/platforms/PolygonID/components/PolygonIDQRCodeModal.tsx +++ b/src/platforms/PolygonID/components/PolygonIDQRCodeModal.tsx @@ -1,3 +1,4 @@ +import { env } from "env" import { Box, Center, @@ -38,7 +39,7 @@ const PolygonIDQRCodeModal = ({ role, isOpen, onClose }: Props) => { const { data, error, mutate } = useSWRImmutable( hasClaimed - ? `${process.env.NEXT_PUBLIC_POLYGONID_API}/v1/users/${userId}/polygon-id/claim/${guildId}:${role.id}/qrcode` + ? `${env.NEXT_PUBLIC_POLYGONID_API}/v1/users/${userId}/polygon-id/claim/${guildId}:${role.id}/qrcode` : null ) diff --git a/src/platforms/PolygonID/hooks/useClaimedRoles.ts b/src/platforms/PolygonID/hooks/useClaimedRoles.ts index e8e91fd13c..212ddd04d6 100644 --- a/src/platforms/PolygonID/hooks/useClaimedRoles.ts +++ b/src/platforms/PolygonID/hooks/useClaimedRoles.ts @@ -1,3 +1,4 @@ +import { env } from "env" import useGuild from "components/[guild]/hooks/useGuild" import useUser from "components/[guild]/hooks/useUser" import useSWRImmutable from "swr/immutable" @@ -13,7 +14,7 @@ const useClaimedRoles = () => { }[] >( !!userId && !!guildId - ? `${process.env.NEXT_PUBLIC_POLYGONID_API}/v1/users/${userId}/polygon-id/claims?format=role&guildId=${guildId}` + ? `${env.NEXT_PUBLIC_POLYGONID_API}/v1/users/${userId}/polygon-id/claims?format=role&guildId=${guildId}` : null ) } diff --git a/src/platforms/PolygonID/hooks/useConnectedDID.ts b/src/platforms/PolygonID/hooks/useConnectedDID.ts index 2c0df40ea6..b2439fcd66 100644 --- a/src/platforms/PolygonID/hooks/useConnectedDID.ts +++ b/src/platforms/PolygonID/hooks/useConnectedDID.ts @@ -1,3 +1,4 @@ +import { env } from "env" import useUser from "components/[guild]/hooks/useUser" import useSWRImmutable from "swr/immutable" @@ -5,9 +6,7 @@ const useConnectedDID = () => { const { id: userId } = useUser() return useSWRImmutable( - userId - ? `${process.env.NEXT_PUBLIC_POLYGONID_API}/v1/users/${userId}/polygon-id` - : null, + userId ? `${env.NEXT_PUBLIC_POLYGONID_API}/v1/users/${userId}/polygon-id` : null, { shouldRetryOnError: false, } diff --git a/src/requirements/Allowlist/components/AllowlistFormInputs.tsx b/src/requirements/Allowlist/components/AllowlistFormInputs.tsx index eb270dae37..613464f0e3 100644 --- a/src/requirements/Allowlist/components/AllowlistFormInputs.tsx +++ b/src/requirements/Allowlist/components/AllowlistFormInputs.tsx @@ -1,3 +1,4 @@ +import { env } from "env" import { Checkbox, Collapse, @@ -62,7 +63,7 @@ export default function AllowlistFormInputs({ const uploadFileToGcs = useSubmit(async (file: File) => { const [data, body] = await Promise.all([ fetcher( - `${process.env.NEXT_PUBLIC_API.replace( + `${env.NEXT_PUBLIC_API.replace( "/v1", "/v2" )}/third-party/google/signed-url?requirementType=${ diff --git a/src/requirements/Nft/NftRequirement.tsx b/src/requirements/Nft/NftRequirement.tsx index 1952d08070..a11b11e369 100644 --- a/src/requirements/Nft/NftRequirement.tsx +++ b/src/requirements/Nft/NftRequirement.tsx @@ -1,3 +1,4 @@ +import { env } from "env" import { HStack, Text, useDisclosure } from "@chakra-ui/react" import { ImageData } from "@nouns/assets" import BlockExplorerUrl from "components/[guild]/Requirements/components/BlockExplorerUrl" @@ -78,7 +79,7 @@ const NftRequirement = (props: RequirementProps) => { metadataWithTraits?.name || metadata?.name ) const nftImage = guildPinImageCID - ? `${process.env.NEXT_PUBLIC_IPFS_GATEWAY}${guildPinImageCID}` + ? `${env.NEXT_PUBLIC_IPFS_GATEWAY}${guildPinImageCID}` : metadataWithTraits?.image || metadata?.image const shouldRenderImage = diff --git a/src/utils/fetcher.ts b/src/utils/fetcher.ts index 24a60cf554..c54ad967b4 100644 --- a/src/utils/fetcher.ts +++ b/src/utils/fetcher.ts @@ -1,3 +1,4 @@ +import { env } from "env" import { useWallet } from "@fuels/react" import { useUserPublic } from "components/[guild]/hooks/useUser" import { pushToIntercomSetting } from "components/_app/IntercomProvider" @@ -17,7 +18,7 @@ const fetcher = async ( ) => { const isGuildApiCall = !resource.startsWith("http") && !resource.startsWith("/api") - const api = isGuildApiCall ? process.env.NEXT_PUBLIC_API : "" + const api = isGuildApiCall ? env.NEXT_PUBLIC_API : "" const options = { ...(body || signedPayload @@ -76,7 +77,7 @@ const fetcher = async ( location?.reload() } - if (isGuildApiCall || resource.includes(process.env.NEXT_PUBLIC_API)) { + if (isGuildApiCall || resource.includes(env.NEXT_PUBLIC_API)) { const error = res.errors?.[0] const errorMsg = error diff --git a/src/utils/ipfsToGuildGateway.ts b/src/utils/ipfsToGuildGateway.ts index 573cc6da65..b194dcd6a4 100644 --- a/src/utils/ipfsToGuildGateway.ts +++ b/src/utils/ipfsToGuildGateway.ts @@ -1,4 +1,5 @@ +import { env } from "env" const ipfsToGuildGateway = (url: string) => - url?.replace("ipfs://", process.env.NEXT_PUBLIC_IPFS_GATEWAY) + url?.replace("ipfs://", env.NEXT_PUBLIC_IPFS_GATEWAY) export default ipfsToGuildGateway diff --git a/src/wagmiConfig/index.ts b/src/wagmiConfig/index.ts index e12aac2101..091d62a6ca 100644 --- a/src/wagmiConfig/index.ts +++ b/src/wagmiConfig/index.ts @@ -1,3 +1,4 @@ +import { env } from "env" import { beraTestnet, bitfinityTestnet, @@ -201,7 +202,7 @@ export const wagmiConfig = createConfig({ version: "4", }), walletConnect({ - projectId: process.env.NEXT_PUBLIC_WALLETCONNECT_PROJECT_ID, + projectId: env.NEXT_PUBLIC_WALLETCONNECT_PROJECT_ID, showQrModal: true, qrModalOptions: { explorerRecommendedWalletIds: [ diff --git a/tsconfig.json b/tsconfig.json index f3a790b5f0..14531c72fc 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -9,7 +9,7 @@ "noEmit": true, "esModuleInterop": true, "module": "esnext", - "moduleResolution": "node", + "moduleResolution": "bundler", "resolveJsonModule": true, "isolatedModules": true, "downlevelIteration": true, From d58cf69a7737345d5669687e4c0b8a637a5dea70 Mon Sep 17 00:00:00 2001 From: BrickheadJohnny <92519134+BrickheadJohnny@users.noreply.github.com> Date: Tue, 25 Jun 2024 17:48:20 +0200 Subject: [PATCH 15/41] feat: simplify the create guild flow (#1309) * upgrade the `@guildxyz/types` package * feat: new create guild form * chore: remove onboarding related components * chore: remove the `GuildFormType` type & all unused components * feat: simplify the create guild page even more * feat: create guild page redesign * fix(CreateGuildForm): dynamic logo color * fix: move button under the card * fix: make the animated logo smaller * fix: wrap the whole page in `ClientOnly` * fix: show the wallet selector modal until the user isn't connected * simplify `CreateGuildForm` * one more redesign * feat: simplify & redesign the create guild page * cleanup: remove guild creation related e2e tests * feat(CreateGuildForm): autofill e-mail address if possible * fix(create-guild): better light mode design * cleanup: remove irrelevant posthog events * cleanup: remove `useSetImageAndNameFromPlatformData` * cleanup: move `getColorByImage` to a util * fix: make the background image smaller * feat: don't assign a default icon * feat: put everything on the card * fix(NavMenu): use black text color in light mode on the create-guild page * feat: try to follow the explorer page design with cover * match explorer layout better * UI(IconSelector): default unfilled in light mode * UI(CreateGuildForm): whitespace improvements * UI(create-guild): add layout pattern and change banner bg * new design impros * mobile impros * new grid pattern --------- Co-authored-by: valid --- cypress/e2e/0-guild/0-create-guild.spec.ts | 210 ------------- cypress/e2e/0-guild/1-edit-guild.spec.ts | 51 ---- cypress/e2e/0-guild/3-cleanup.spec.ts | 50 ---- package-lock.json | 39 ++- package.json | 1 + .../[guild]/AccessHub/AccessHub.tsx | 7 +- .../AddAndOrderRoles/AddAndOrderRoles.tsx | 33 +-- .../[guild]/EditGuild/EditGuildDrawer.tsx | 44 ++- .../components/Events/EventInput.tsx | 5 +- .../EditGuild/components/SocialLinks.tsx | 103 ++++--- .../[guild]/EditGuild/hooks/useEditGuild.ts | 12 +- .../[guild]/Onboarding/Onboarding.tsx | 46 --- .../SummonMembers/SummonMembers.tsx | 164 ---------- .../components/SendDiscordJoinButtonAlert.tsx | 81 ----- .../components/SendDiscordJoinButtonModal.tsx | 11 +- .../SummonMembers/hooks/useSendJoin.tsx | 4 +- .../components/SummonMembers/index.ts | 1 - src/components/[guild]/Onboarding/index.ts | 3 - .../RoleCard/components/EditRole/EditRole.tsx | 39 +-- .../common/Layout/components/Header.tsx | 2 + .../Layout/components/NavMenu/NavMenu.tsx | 14 +- src/components/common/OnboardingMarker.tsx | 39 --- .../common/StyledSelect/StyledSelect.tsx | 6 +- .../create-guild/BasicInfo/BasicInfo.tsx | 126 -------- .../BasicInfo/components/ContactInfo.tsx | 68 +++-- .../BasicInfo/components/TwitterUrlInput.tsx | 37 --- .../create-guild/BasicInfo/index.ts | 3 - .../ChooseTemplate/ChooseTemplate.tsx | 79 ----- .../components/TemplateCard.tsx | 280 ------------------ .../components/TemplateRequriements.tsx | 92 ------ .../create-guild/ChooseTemplate/index.ts | 3 - .../ChooseTemplate/useTemplate.tsx | 137 --------- .../create-guild/CreateGuildButton.tsx | 87 +++--- .../create-guild/CreateGuildContext.tsx | 89 ------ .../create-guild/CreateGuildForm.tsx | 115 +++++++ .../create-guild/CreateGuildIndex.tsx | 58 ---- .../create-guild/CreateGuildMainSection.tsx | 63 ---- .../create-guild/CreateGuildStepper.tsx | 228 -------------- src/components/create-guild/Description.tsx | 4 +- .../GuildCreationProgress.tsx | 60 ---- .../components/GuildLottieProgress.tsx | 80 ----- .../GuildCreationProgress/index.ts | 3 - .../IconSelector/IconSelector.tsx | 53 +++- .../IconSelector/components/PhotoUploader.tsx | 6 +- .../MultiPlatformGrid/MultiPlatformGrid.tsx | 59 ---- .../components/CreateGuildContractCall.tsx | 49 --- .../components/CreateGuildDiscord.tsx | 76 ----- .../components/CreateGuildGithub.tsx | 57 ---- .../components/CreateGuildGoogle.tsx | 110 ------- .../components/CreateGuildSecretText.tsx | 87 ------ .../components/CreateGuildTelegram.tsx | 92 ------ .../components/CreateGuildTwitter.tsx | 62 ---- .../components/CreateGuildUniqueText.tsx | 62 ---- .../components/MultiPlatformSelectButton.tsx | 243 --------------- .../create-guild/MultiPlatformGrid/index.ts | 3 - .../Requirements/SetRequirements.tsx | 12 +- .../Requirements/components/LogicPicker.tsx | 58 ---- .../create-guild/hooks/useCreateGuild.tsx | 46 +-- .../useSetImageAndNameFromPlatformData.ts | 68 ----- src/components/create-guild/templates.ts | 228 -------------- src/pages/[guild]/index.tsx | 39 +-- src/pages/create-guild.tsx | 138 +++++---- src/types.ts | 29 -- src/utils/getColorByImage.ts | 21 ++ 64 files changed, 550 insertions(+), 3625 deletions(-) delete mode 100644 cypress/e2e/0-guild/0-create-guild.spec.ts delete mode 100644 cypress/e2e/0-guild/1-edit-guild.spec.ts delete mode 100644 cypress/e2e/0-guild/3-cleanup.spec.ts delete mode 100644 src/components/[guild]/Onboarding/Onboarding.tsx delete mode 100644 src/components/[guild]/Onboarding/components/SummonMembers/SummonMembers.tsx delete mode 100644 src/components/[guild]/Onboarding/components/SummonMembers/components/SendDiscordJoinButtonAlert.tsx delete mode 100644 src/components/[guild]/Onboarding/components/SummonMembers/index.ts delete mode 100644 src/components/[guild]/Onboarding/index.ts delete mode 100644 src/components/common/OnboardingMarker.tsx delete mode 100644 src/components/create-guild/BasicInfo/BasicInfo.tsx delete mode 100644 src/components/create-guild/BasicInfo/components/TwitterUrlInput.tsx delete mode 100644 src/components/create-guild/BasicInfo/index.ts delete mode 100644 src/components/create-guild/ChooseTemplate/ChooseTemplate.tsx delete mode 100644 src/components/create-guild/ChooseTemplate/components/TemplateCard.tsx delete mode 100644 src/components/create-guild/ChooseTemplate/components/TemplateRequriements.tsx delete mode 100644 src/components/create-guild/ChooseTemplate/index.ts delete mode 100644 src/components/create-guild/ChooseTemplate/useTemplate.tsx delete mode 100644 src/components/create-guild/CreateGuildContext.tsx create mode 100644 src/components/create-guild/CreateGuildForm.tsx delete mode 100644 src/components/create-guild/CreateGuildIndex.tsx delete mode 100644 src/components/create-guild/CreateGuildMainSection.tsx delete mode 100644 src/components/create-guild/CreateGuildStepper.tsx delete mode 100644 src/components/create-guild/GuildCreationProgress/GuildCreationProgress.tsx delete mode 100644 src/components/create-guild/GuildCreationProgress/components/GuildLottieProgress.tsx delete mode 100644 src/components/create-guild/GuildCreationProgress/index.ts delete mode 100644 src/components/create-guild/MultiPlatformGrid/MultiPlatformGrid.tsx delete mode 100644 src/components/create-guild/MultiPlatformGrid/components/CreateGuildContractCall.tsx delete mode 100644 src/components/create-guild/MultiPlatformGrid/components/CreateGuildDiscord.tsx delete mode 100644 src/components/create-guild/MultiPlatformGrid/components/CreateGuildGithub.tsx delete mode 100644 src/components/create-guild/MultiPlatformGrid/components/CreateGuildGoogle.tsx delete mode 100644 src/components/create-guild/MultiPlatformGrid/components/CreateGuildSecretText.tsx delete mode 100644 src/components/create-guild/MultiPlatformGrid/components/CreateGuildTelegram.tsx delete mode 100644 src/components/create-guild/MultiPlatformGrid/components/CreateGuildTwitter.tsx delete mode 100644 src/components/create-guild/MultiPlatformGrid/components/CreateGuildUniqueText.tsx delete mode 100644 src/components/create-guild/MultiPlatformGrid/components/MultiPlatformSelectButton.tsx delete mode 100644 src/components/create-guild/MultiPlatformGrid/index.ts delete mode 100644 src/components/create-guild/Requirements/components/LogicPicker.tsx delete mode 100644 src/components/create-guild/hooks/useSetImageAndNameFromPlatformData.ts delete mode 100644 src/components/create-guild/templates.ts create mode 100644 src/utils/getColorByImage.ts diff --git a/cypress/e2e/0-guild/0-create-guild.spec.ts b/cypress/e2e/0-guild/0-create-guild.spec.ts deleted file mode 100644 index 1f63b69c8e..0000000000 --- a/cypress/e2e/0-guild/0-create-guild.spec.ts +++ /dev/null @@ -1,210 +0,0 @@ -before(() => { - cy.clearIndexedDB() -}) - -const getContinueBtn = () => cy.get('[type="button"]').contains("Continue") -const getRoles = () => cy.get('[data-test^="role-"]') - -const fillCustomizeGuildForm = ({ shouldContinue = true } = {}) => { - cy.contains("add rewards later").click() - getContinueBtn().click() - - cy.get("input[name='name']") - .should("be.visible") - .type(`${Cypress.env("platformlessGuildName")} ${Cypress.env("RUN_ID")}`) - cy.get("input[name='contacts.0.contact']") - .should("be.visible") - .type("username@example.com") - - if (shouldContinue) getContinueBtn().should("be.enabled").click() -} - -describe("create guild page - without wallet", () => { - beforeEach(() => { - cy.visit("/create-guild") - }) - - it("shows connect wallet modal", () => { - cy.getByDataTest("platforms-grid").within(() => { - cy.get("div[role='group']").first().click() - }) - cy.getByDataTest("wallet-selector-modal") - .should("exist") - .within(() => { - cy.get("button[aria-label='Close']").click() - }) - - getContinueBtn().should("be.disabled") - }) - - it("can customize guild without platform", () => { - cy.contains("add rewards later").click() - getContinueBtn().should("not.be.disabled") - getContinueBtn().click() - - // Name is required - getContinueBtn().should("be.disabled") - cy.get("input[name='name']") - cy.get("input[name='name']").focus().blur() - cy.get("input[name='name']") - .next(".chakra-collapse") - .should("exist") - .contains("This field is required") - cy.get("input[name='name']").type( - `${Cypress.env("platformlessGuildName")} ${Cypress.env("RUN_ID")}` - ) - - cy.get("input[name='urlName']").invoke("val").should("not.be.empty") - - // Email is required - getContinueBtn().should("be.disabled") - const emailInput = () => cy.get("input[name='contacts.0.contact']") - emailInput().focus().blur() - emailInput() - .parent() - .next(".chakra-collapse") - .should("exist") - .contains("This field is required") - - emailInput().type("username@example.com") - getContinueBtn().should("not.be.disabled") - }) - - it("cannot add empty additional contacts", () => { - fillCustomizeGuildForm({ shouldContinue: false }) - - cy.get("button.chakra-button") - .contains("Add contact") - .should("be.visible") - .click() - const extraContact = () => cy.get("input[name='contacts.1.contact']") - extraContact().should("be.visible").blur() - extraContact() - .parent() - .next(".chakra-collapse") - .should("exist") - .contains("This field is required") - getContinueBtn().should("be.disabled") - - extraContact().type("username@example.com") - getContinueBtn().should("not.be.disabled") - - cy.getByDataTest("remove-contact-btn").should("be.visible").click() - extraContact().should("not.exist") - - getContinueBtn().should("not.be.disabled") - }) - - it("requires wallet to access templates", () => { - fillCustomizeGuildForm() - - cy.getByDataTest("wallet-selector-modal") - .should("be.visible") - .within(() => { - cy.get("button[aria-label='Close']").click() - }) - - cy.getByDataTest("wallet-selector-modal").should("be.visible") - }) -}) - -describe("create guild page - with wallet", () => { - beforeEach(() => { - cy.clearIndexedDB() - cy.visit("/create-guild") - cy.connectWallet() - fillCustomizeGuildForm() - }) - - it("can select role templates", () => { - // Selecting the first role template - getContinueBtn().should("be.disabled") - cy.get('[data-test^="role-checkbox-"]').should("not.exist") - getRoles() - .first() - .click() - .invoke("attr", "data-test") - .then((dataTestAttr) => { - const checkboxSelector = `data-test=checked-${dataTestAttr}` - cy.get(`[${checkboxSelector}]`).should("exist") - }) - - getContinueBtn().should("not.be.disabled") - - // Deselecting the first role template - getRoles() - .first() - .click() - .invoke("attr", "data-test") - .then((dataTestAttr) => { - const checkboxSelector = `data-test=checked-${dataTestAttr}` - cy.get(`[${checkboxSelector}]`).should("not.exist") - }) - - getContinueBtn().should("be.disabled") - }) - - it("can add rewards only to selected role templates", () => { - // Selecting the first role template, check if visible on reward step - getRoles() - .first() - .click() - .invoke("attr", "data-test") - .then((roleName) => { - getContinueBtn().click() - cy.get(`[data-test=${roleName}]`).should("be.visible") - getRoles().filter(":visible").should("have.length", 1) - }) - - // Selecting the second role template in addition, check if both are visible on reward step - cy.contains("Go back and choose more templates").click() - - getRoles() - .eq(1) - .click() - .invoke("attr", "data-test") - .then((roleName) => { - getContinueBtn().click() - cy.get(`[data-test=${roleName}]`).should("be.visible") - getRoles().filter(":visible").should("have.length", 2) - }) - - // Deselecting the first template, check that it disappears from the reward step - cy.contains("Go back and choose more templates").click() - - getRoles() - .first() - .click() - .invoke("attr", "data-test") - .then((roleName) => { - getContinueBtn().click() - cy.get(`[data-test=${roleName}]`).should("not.be.visible") - getRoles().filter(":visible").should("have.length", 1) - }) - }) - - it("can create guild", () => { - getRoles().first().click() - - getContinueBtn().click() - - cy.getByDataTest("create-guild-button").should("not.be.disabled") - - cy.intercept("POST", `${Cypress.env("guildApiUrl")}/guilds`).as( - "createGuildRequest" - ) - - cy.getByDataTest("create-guild-button").click() - - cy.wait("@createGuildRequest").its("response.statusCode").should("eq", 201) - - // User is redirected to the guild page - cy.url().should("include", "/platformless-cypress-gang-localhost") - getContinueBtn().click() - - cy.contains("Guild 100% complete").should("be.visible") - cy.get("button").contains("Close").click() - - cy.getByDataTest("create-guild-stepper").should("not.exist") - }) -}) diff --git a/cypress/e2e/0-guild/1-edit-guild.spec.ts b/cypress/e2e/0-guild/1-edit-guild.spec.ts deleted file mode 100644 index a7990a342f..0000000000 --- a/cypress/e2e/0-guild/1-edit-guild.spec.ts +++ /dev/null @@ -1,51 +0,0 @@ -const CONTEXT = { - guild: undefined, -} - -const URL_NAME = `${Cypress.env("platformlessGuildUrlName")}-${Cypress.env( - "RUN_ID" -)}` - -describe("edit guild", () => { - beforeEach(() => { - cy.intercept( - "GET", - `${Cypress.env("guildApiUrl")}/guilds/guild-page/${URL_NAME}` - ).as("fetchGuild") - cy.visit(URL_NAME) - }) - - it("can fetch guild id", () => { - cy.wait("@fetchGuild") - .then((intercept) => { - CONTEXT.guild = intercept.response.body - return intercept - }) - .its("response.statusCode") - .should("eq", 200) - }) - - it("can't edit a guild as a guest", () => { - cy.get("button[aria-label='Edit Guild']").should("not.exist") - }) - - it("can edit general guild data as a guild admin", () => { - cy.intercept( - "PUT", - `${Cypress.env("guildApiUrl")}/guilds/${CONTEXT.guild.id}` - ).as("editGuildApiCall") - - cy.clearIndexedDB() - cy.connectWallet() - - cy.get("button[aria-label='Edit Guild']").click() - - cy.get("div[role='dialog'].chakra-slide").within(() => { - cy.get("input[name='name']").type(" (edited)") - cy.get("textarea[name='description']").type("Edit guild test") - - cy.getByDataTest("save-guild-button").click() - cy.wait("@editGuildApiCall").its("response.statusCode").should("eq", 200) - }) - }) -}) diff --git a/cypress/e2e/0-guild/3-cleanup.spec.ts b/cypress/e2e/0-guild/3-cleanup.spec.ts deleted file mode 100644 index 0c66a04e79..0000000000 --- a/cypress/e2e/0-guild/3-cleanup.spec.ts +++ /dev/null @@ -1,50 +0,0 @@ -before(() => { - cy.clearIndexedDB() -}) - -const URL_NAME = `${Cypress.env("platformlessGuildUrlName")}-${Cypress.env( - "RUN_ID" -)}` - -describe("post-test cleanup", () => { - before(() => { - cy.visit(URL_NAME, { - failOnStatusCode: false, - }) - }) - - it("cleans up test guild", () => { - cy.get("body").then(($body) => { - if ($body.find("h1").length > 0) { - cy.get("h1").then(($h1) => { - if ( - $h1.text().toString() !== "404" && - $h1.text().toString() !== "Client-side error" - ) { - cy.connectWallet() - - cy.intercept("DELETE", `${Cypress.env("guildApiUrl")}/guilds/*`).as( - "deleteGuild" - ) - - cy.get(".chakra-button[aria-label='Edit Guild']").click() - cy.get(".chakra-slide h2").should("contain.text", "Edit guild") - - cy.get(".chakra-button[aria-label='Delete guild']").click() - cy.getByDataTest("delete-confirmation-button").click() - - cy.wait("@deleteGuild") - } else { - cy.visit("/explorer") - } - }) - } else { - cy.visit("/explorer") - } - }) - - cy.get("h1").should("contain.text", "Guildhall") - }) -}) - -export {} diff --git a/package-lock.json b/package-lock.json index fca2078231..d7a9313401 100644 --- a/package-lock.json +++ b/package-lock.json @@ -54,6 +54,7 @@ "jotai": "^2.7.0", "js-confetti": "^0.11.0", "lexical": "^0.12.0", + "mini-svg-data-uri": "^1.4.4", "next": "14.0.1", "papaparse": "^5.4.1", "phosphor-react": "^1.4.1", @@ -11414,9 +11415,9 @@ } }, "node_modules/@walletconnect/core/node_modules/@upstash/redis": { - "version": "1.31.5", - "resolved": "https://registry.npmjs.org/@upstash/redis/-/redis-1.31.5.tgz", - "integrity": "sha512-2MatqeqftroSJ9Q+pqbyGAIwXX6KEPtUTUna2c/fq09h12ffwvltDTgfppeF+NzJo/SyZfHY8e1RoflduMbz1A==", + "version": "1.31.6", + "resolved": "https://registry.npmjs.org/@upstash/redis/-/redis-1.31.6.tgz", + "integrity": "sha512-7sDQQqvVnnV+2PUVGjocITa34CULGLoWhmfSY/LtpxNYv24EsgOk9VXhmGXIyzJBcXxB614wOF6ccEN0Lr7fqQ==", "optional": true, "peer": true, "dependencies": { @@ -11750,9 +11751,9 @@ } }, "node_modules/@walletconnect/notify-client/node_modules/@upstash/redis": { - "version": "1.31.5", - "resolved": "https://registry.npmjs.org/@upstash/redis/-/redis-1.31.5.tgz", - "integrity": "sha512-2MatqeqftroSJ9Q+pqbyGAIwXX6KEPtUTUna2c/fq09h12ffwvltDTgfppeF+NzJo/SyZfHY8e1RoflduMbz1A==", + "version": "1.31.6", + "resolved": "https://registry.npmjs.org/@upstash/redis/-/redis-1.31.6.tgz", + "integrity": "sha512-7sDQQqvVnnV+2PUVGjocITa34CULGLoWhmfSY/LtpxNYv24EsgOk9VXhmGXIyzJBcXxB614wOF6ccEN0Lr7fqQ==", "optional": true, "peer": true, "dependencies": { @@ -12042,9 +12043,9 @@ } }, "node_modules/@walletconnect/types/node_modules/@upstash/redis": { - "version": "1.31.5", - "resolved": "https://registry.npmjs.org/@upstash/redis/-/redis-1.31.5.tgz", - "integrity": "sha512-2MatqeqftroSJ9Q+pqbyGAIwXX6KEPtUTUna2c/fq09h12ffwvltDTgfppeF+NzJo/SyZfHY8e1RoflduMbz1A==", + "version": "1.31.6", + "resolved": "https://registry.npmjs.org/@upstash/redis/-/redis-1.31.6.tgz", + "integrity": "sha512-7sDQQqvVnnV+2PUVGjocITa34CULGLoWhmfSY/LtpxNYv24EsgOk9VXhmGXIyzJBcXxB614wOF6ccEN0Lr7fqQ==", "optional": true, "peer": true, "dependencies": { @@ -12215,9 +12216,9 @@ } }, "node_modules/@web3inbox/core/node_modules/@upstash/redis": { - "version": "1.31.5", - "resolved": "https://registry.npmjs.org/@upstash/redis/-/redis-1.31.5.tgz", - "integrity": "sha512-2MatqeqftroSJ9Q+pqbyGAIwXX6KEPtUTUna2c/fq09h12ffwvltDTgfppeF+NzJo/SyZfHY8e1RoflduMbz1A==", + "version": "1.31.6", + "resolved": "https://registry.npmjs.org/@upstash/redis/-/redis-1.31.6.tgz", + "integrity": "sha512-7sDQQqvVnnV+2PUVGjocITa34CULGLoWhmfSY/LtpxNYv24EsgOk9VXhmGXIyzJBcXxB614wOF6ccEN0Lr7fqQ==", "optional": true, "peer": true, "dependencies": { @@ -26252,6 +26253,14 @@ "node": ">=4" } }, + "node_modules/mini-svg-data-uri": { + "version": "1.4.4", + "resolved": "https://registry.npmjs.org/mini-svg-data-uri/-/mini-svg-data-uri-1.4.4.tgz", + "integrity": "sha512-r9deDe9p5FJUPZAk3A59wGH7Ii9YrjjWw0jmw/liSbHl2CHiyXj6FcDXDu2K3TjVAXqiJdaw3xxwlZZr9E6nHg==", + "bin": { + "mini-svg-data-uri": "cli.js" + } + }, "node_modules/minimalistic-assert": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/minimalistic-assert/-/minimalistic-assert-1.0.1.tgz", @@ -27705,9 +27714,9 @@ } }, "node_modules/posthog-js": { - "version": "1.139.3", - "resolved": "https://registry.npmjs.org/posthog-js/-/posthog-js-1.139.3.tgz", - "integrity": "sha512-NmPtOAXogxT/QSmeVCQJeIemBn8rEGfFPIXOynYKgXfntrw0KhzGXXvRXGLVjl5Zx6Nslf5NlmMnzmq1wjLZIA==", + "version": "1.139.5", + "resolved": "https://registry.npmjs.org/posthog-js/-/posthog-js-1.139.5.tgz", + "integrity": "sha512-awnIAefNa+x5GA481B8j8J6S2xLcvHQ7i5Osyzq1UK6QGtmAaM0ttGFU+oPjpKxo4yXeuF5R1aUo9YE67s4+vA==", "dependencies": { "fflate": "^0.4.8", "preact": "^10.19.3" diff --git a/package.json b/package.json index 41af189f03..c7f442419a 100644 --- a/package.json +++ b/package.json @@ -64,6 +64,7 @@ "jotai": "^2.7.0", "js-confetti": "^0.11.0", "lexical": "^0.12.0", + "mini-svg-data-uri": "^1.4.4", "next": "14.0.1", "papaparse": "^5.4.1", "phosphor-react": "^1.4.1", diff --git a/src/components/[guild]/AccessHub/AccessHub.tsx b/src/components/[guild]/AccessHub/AccessHub.tsx index d82b79c2ec..a16504a6cb 100644 --- a/src/components/[guild]/AccessHub/AccessHub.tsx +++ b/src/components/[guild]/AccessHub/AccessHub.tsx @@ -76,7 +76,7 @@ export const useAccessedGuildPlatforms = (groupId?: number) => { } const AccessHub = (): JSX.Element => { - const { featureFlags, guildPin, groups, roles, onboardingComplete } = useGuild() + const { featureFlags, guildPin, groups, roles } = useGuild() const group = useRoleGroup() const { isAdmin } = useGuildPermission() @@ -94,8 +94,9 @@ const AccessHub = (): JSX.Element => { const hasVisiblePages = !!groups?.length && roles?.some((role) => !!role.groupId) const showAccessHub = - (isAdmin ? !!onboardingComplete : isMember) || - (!!accessedGuildPlatforms?.length && !!onboardingComplete) || + isAdmin || + isMember || + !!accessedGuildPlatforms?.length || (hasVisiblePages && !group) return ( diff --git a/src/components/[guild]/AddAndOrderRoles/AddAndOrderRoles.tsx b/src/components/[guild]/AddAndOrderRoles/AddAndOrderRoles.tsx index 84f0627bed..0a4708886c 100644 --- a/src/components/[guild]/AddAndOrderRoles/AddAndOrderRoles.tsx +++ b/src/components/[guild]/AddAndOrderRoles/AddAndOrderRoles.tsx @@ -9,9 +9,7 @@ import { MenuList, useDisclosure, } from "@chakra-ui/react" -import { usePostHogContext } from "components/_app/PostHogProvider" import Button from "components/common/Button" -import OnboardingMarker from "components/common/OnboardingMarker" import useIsStuck from "hooks/useIsStuck" import { CaretDown, ListNumbers, Plus } from "phosphor-react" import { useEffect, useRef } from "react" @@ -20,8 +18,6 @@ import AddRoleDrawer from "./components/AddRoleDrawer" import OrderRolesModal from "./components/OrderRolesModal" const AddAndOrderRoles = ({ setIsStuck = null }): JSX.Element => { - const { captureEvent } = usePostHogContext() - const { isOpen: isAddDrawerOpen, onOpen: onAddDrawerOpen, @@ -42,29 +38,14 @@ const AddAndOrderRoles = ({ setIsStuck = null }): JSX.Element => { return ( <> - { - captureEvent("guild creation flow > Add role clicked (pulse marker)") - onAddDrawerOpen() - }} + - + Add role + import("./components/FeatureFlags")) +export type EditGuildForm = Schemas["GuildUpdatePayload"] & { + admins: { address: string }[] + contacts: (Omit & { id?: GuildContact["id"] })[] + guildPin?: { + chain: Chain | "FUEL" + isActive: boolean + } + // We can delete an event source by passing "null" to it, that's why we need this custom type here + eventSources?: Partial> + // Superadmin-only fields + featureFlags?: FeatureFlag[] + tags?: GuildTags[] +} + const EditGuildDrawer = ({ finalFocusRef, isOpen, @@ -95,20 +113,21 @@ const EditGuildDrawer = ({ } : {}, showMembers, - admins: admins ?? [], + admins: admins?.map(({ address }) => ({ address })) ?? [], urlName, hideFromExplorer, - contacts, + contacts: contacts || [], socialLinks, featureFlags: isSuperAdmin ? featureFlags : undefined, tags: savedTags, eventSources: { - EVENTBRITE: eventSources ? eventSources.EVENTBRITE : null, - LUMA: eventSources ? eventSources.LUMA : null, - LINK3: eventSources ? eventSources.LINK3 : null, + EVENTBRITE: eventSources?.EVENTBRITE || null, + LUMA: eventSources?.LUMA || null, + LINK3: eventSources?.LINK3 || null, }, - } - const methods = useForm({ + } satisfies EditGuildForm + + const methods = useForm({ mode: "all", defaultValues, }) @@ -183,8 +202,9 @@ const EditGuildDrawer = ({ const { handleSubmit, isUploadingShown, uploadLoadingText } = useSubmitWithUpload( () => { handleSubmitDirty(methods)((data) => { - onSubmit({ ...data, tags: undefined }) - if (data.tags) onTagsSubmit(data.tags) + const { tags, ...dataWithoutTags } = data + onSubmit(dataWithoutTags) + if (tags) onTagsSubmit(tags) })() }, backgroundUploader.isUploading || iconUploader.isUploading @@ -285,6 +305,10 @@ const EditGuildDrawer = ({
+ + Only visible to the Guild Team to reach you with support and + partnership initiatives if needed. +
diff --git a/src/components/[guild]/EditGuild/components/Events/EventInput.tsx b/src/components/[guild]/EditGuild/components/Events/EventInput.tsx index d7fb992de0..d050e0f1f9 100644 --- a/src/components/[guild]/EditGuild/components/Events/EventInput.tsx +++ b/src/components/[guild]/EditGuild/components/Events/EventInput.tsx @@ -10,7 +10,8 @@ import { InputRightElement, } from "@chakra-ui/react" import { useFormContext, useWatch } from "react-hook-form" -import { EventSourcesKey, GuildFormType } from "types" +import { EventSourcesKey } from "types" +import { EditGuildForm } from "../../EditGuildDrawer" type Props = { eventSource: EventSourcesKey @@ -50,7 +51,7 @@ const EventInput = ({ eventSource }: Props) => { register, setValue, formState: { errors }, - } = useFormContext() + } = useFormContext() const link = useWatch({ name: `eventSources.${eventSource}`, diff --git a/src/components/[guild]/EditGuild/components/SocialLinks.tsx b/src/components/[guild]/EditGuild/components/SocialLinks.tsx index 71a63dc21b..ecc06c8433 100644 --- a/src/components/[guild]/EditGuild/components/SocialLinks.tsx +++ b/src/components/[guild]/EditGuild/components/SocialLinks.tsx @@ -9,19 +9,16 @@ import { InputRightElement, SimpleGrid, } from "@chakra-ui/react" +import { SocialLinks as SocialLinksType } from "@guildxyz/types" import SocialIcon from "components/[guild]/SocialIcon" import FormErrorMessage from "components/common/FormErrorMessage" import StyledSelect from "components/common/StyledSelect" import { Plus } from "phosphor-react" import { useFormContext, useWatch } from "react-hook-form" -import { - GuildFormType, - SelectOption, - SocialLinkKey, - supportedSocialLinks, -} from "types" +import { SelectOption, SocialLinkKey, supportedSocialLinks } from "types" import capitalize from "utils/capitalize" import { z } from "zod" +import { EditGuildForm } from "../EditGuildDrawer" const socialLinkUserPaths = { TWITTER: "https://x.com/", @@ -29,13 +26,19 @@ const socialLinkUserPaths = { SPOTIFY: "https://open.spotify.com/user/", MEDIUM: "https://medium.com/", GITHUB: "https://github.com/", -} as const satisfies Partial> + LENS: "", + MIRROR: "", + SNAPSHOT: "", + SOUND: "", + SUBSTACK: "", + WEBSITE: "", +} as const satisfies Record -const socialLinkOptions: SelectOption[] = supportedSocialLinks.map((socialLink) => ({ +const socialLinkOptions = supportedSocialLinks.map((socialLink) => ({ label: capitalize(socialLink.toLowerCase()), value: socialLink, img: , -})) +})) satisfies SelectOption[] const SocialLinks = (): JSX.Element => { const { @@ -43,61 +46,65 @@ const SocialLinks = (): JSX.Element => { register, setValue, formState: { errors }, - } = useFormContext() + } = useFormContext() const definedSocialLinks = useWatch({ control, name: "socialLinks" }) - const validateUrl = (input: string) => { + const validateUrl = (input?: string) => { const { success } = z.string().url().safeParse(input) return success || "Invalid link format." } return ( - {Object.entries(definedSocialLinks ?? {}) + {( + Object.entries(definedSocialLinks ?? {}) as [keyof SocialLinksType, string][] + ) .filter(([, value]) => typeof value !== "undefined") - .map(([key]) => ( - - - - - {socialLinkOptions.find((sl) => sl.value === key).img} - - sl.value === key).label - } - /> - - - setValue(`socialLinks.${key}`, undefined, { - shouldDirty: true, - }) - } + .map(([key]) => { + const socialLinkOption = socialLinkOptions.find((sl) => sl.value === key) + + if (!socialLinkOption) return null + + return ( + + + + {socialLinkOption.img} + - - + + + setValue(`socialLinks.${key}`, undefined, { + shouldDirty: true, + }) + } + /> + + - - {errors?.socialLinks?.[key]?.message} - - - - ))} + + {errors?.socialLinks?.[key]?.message} + + + + ) + })} typeof definedSocialLinks?.[sl.value] === "undefined" )} - onChange={(newValue: SelectOption) => + onChange={(newValue: (typeof socialLinkOptions)[number]) => setValue( `socialLinks.${newValue.value}`, socialLinkUserPaths[newValue.value] ?? "" diff --git a/src/components/[guild]/EditGuild/hooks/useEditGuild.ts b/src/components/[guild]/EditGuild/hooks/useEditGuild.ts index 34f3b86ab9..ff8b97d369 100644 --- a/src/components/[guild]/EditGuild/hooks/useEditGuild.ts +++ b/src/components/[guild]/EditGuild/hooks/useEditGuild.ts @@ -4,9 +4,10 @@ import useMatchMutate from "hooks/useMatchMutate" import useShowErrorToast from "hooks/useShowErrorToast" import useSubmit from "hooks/useSubmit" import { useRouter } from "next/router" -import { GuildBase, GuildFormType } from "types" +import { GuildBase } from "types" import { useFetcherWithSign } from "utils/fetcher" import replacer from "utils/guildJsonReplacer" +import { EditGuildForm } from "../EditGuildDrawer" type Props = { onSuccess?: () => void @@ -34,7 +35,7 @@ const useEditGuild = ({ onSuccess, guildId }: Props = {}) => { const id = guildId ?? guild?.id - const submit = async (data: GuildFormType) => { + const submit = async (data: Partial) => { const existingFeatureFlags = guild?.featureFlags ?? [] const existingContacts = guild?.contacts ?? [] const existingAdmins = guild?.admins ?? [] @@ -249,7 +250,10 @@ const useEditGuild = ({ onSuccess, guildId }: Props = {}) => { } as const } - const useSubmitResponse = useSubmit(submit, { + const useSubmitResponse = useSubmit< + Partial, + Awaited> + >(submit, { onSuccess: ({ admin, contacts, featureFlags, guildUpdateResult }) => { // Show success / error toasts if ( @@ -397,7 +401,7 @@ const useEditGuild = ({ onSuccess, guildId }: Props = {}) => { return { ...useSubmitResponse, - onSubmit: (data) => + onSubmit: (data: Partial) => useSubmitResponse.onSubmit(JSON.parse(JSON.stringify(data, replacer))), } } diff --git a/src/components/[guild]/Onboarding/Onboarding.tsx b/src/components/[guild]/Onboarding/Onboarding.tsx deleted file mode 100644 index 1418775751..0000000000 --- a/src/components/[guild]/Onboarding/Onboarding.tsx +++ /dev/null @@ -1,46 +0,0 @@ -import { Collapse } from "@chakra-ui/react" -import { usePostHogContext } from "components/_app/PostHogProvider" -import CreateGuildStepper from "components/create-guild/CreateGuildStepper" -import GuildCreationProgress from "components/create-guild/GuildCreationProgress" -import { atom, useAtom } from "jotai" -import { useEffect } from "react" -import { useThemeContext } from "../ThemeContext" -import useGuild from "../hooks/useGuild" - -export const onboardingStepAtom = atom(0) - -const Onboarding = (): JSX.Element => { - const { onboardingComplete } = useGuild() - const { localThemeColor, textColor } = useThemeContext() - const [activeStep, setActiveStep] = useAtom(onboardingStepAtom) - const { captureEvent } = usePostHogContext() - - useEffect(() => { - setActiveStep(3) - }, [setActiveStep]) - - return ( - <> - - - - {activeStep === 3 && ( - { - captureEvent("guild creation flow > continue", { to: 5 }) - setActiveStep(4) - }} - /> - )} - - ) -} - -export default Onboarding diff --git a/src/components/[guild]/Onboarding/components/SummonMembers/SummonMembers.tsx b/src/components/[guild]/Onboarding/components/SummonMembers/SummonMembers.tsx deleted file mode 100644 index 837d004ea4..0000000000 --- a/src/components/[guild]/Onboarding/components/SummonMembers/SummonMembers.tsx +++ /dev/null @@ -1,164 +0,0 @@ -import { HStack, Text, useClipboard, useDisclosure, Wrap } from "@chakra-ui/react" -import { type DotLottieCommonPlayer, DotLottiePlayer } from "@dotlottie/react-player" -import useEditGuild from "components/[guild]/EditGuild/hooks/useEditGuild" -import useGuild from "components/[guild]/hooks/useGuild" -import { usePostHogContext } from "components/_app/PostHogProvider" -import Button from "components/common/Button" -import PulseMarker from "components/common/PulseMarker" -import { useRouter } from "next/router" -import { Check, Copy, DiscordLogo } from "phosphor-react" -import XLogo from "static/icons/x.svg" -import { useState } from "react" -import { PlatformType } from "types" -import SendDiscordJoinButtonAlert from "./components/SendDiscordJoinButtonAlert" -import SendDiscordJoinButtonModal from "./components/SendDiscordJoinButtonModal" - -export type SummonMembersForm = { - channelId: string - serverId: string - title: string - description: string - button: string -} - -const SummonMembers = () => { - const [, setPlayer] = useState() - const { asPath } = useRouter() - const { captureEvent } = usePostHogContext() - - const { isOpen, onOpen, onClose } = useDisclosure() - const { - isOpen: isAlertOpen, - onOpen: onAlertOpen, - onClose: onAlertClose, - } = useDisclosure() - const { guildPlatforms, urlName } = useGuild() - - const discordPlatform = guildPlatforms?.find( - (p) => p.platformId === PlatformType.DISCORD - ) - const hasJoinButton = !!discordPlatform?.platformGuildData?.joinButton - - const { onSubmit, isLoading, response } = useEditGuild() - const handleFinish = () => { - if (discordPlatform && !hasJoinButton) { - onAlertOpen() - return - } - - onSubmit({ onboardingComplete: true }) - } - const { onCopy, hasCopied } = useClipboard("guild.xyz" + asPath) - - return ( - <> - - If you're satisfied with everything, it's time to invite your community to - join! - - - - {discordPlatform && - (hasJoinButton ? ( - - ) : ( - - - - ))} - - - - - { - setPlayer(instance) - }} - /> - - Guild 100% complete - - - - - - {discordPlatform && ( - <> - - - { - onOpen() - onAlertClose() - }} - onContinue={() => { - onSubmit({ onboardingComplete: true }) - onAlertClose() - }} - /> - - )} - - ) -} - -export default SummonMembers diff --git a/src/components/[guild]/Onboarding/components/SummonMembers/components/SendDiscordJoinButtonAlert.tsx b/src/components/[guild]/Onboarding/components/SummonMembers/components/SendDiscordJoinButtonAlert.tsx deleted file mode 100644 index 30d024b8d1..0000000000 --- a/src/components/[guild]/Onboarding/components/SummonMembers/components/SendDiscordJoinButtonAlert.tsx +++ /dev/null @@ -1,81 +0,0 @@ -import { - AlertDialogBody, - AlertDialogContent, - AlertDialogFooter, - AlertDialogHeader, - AlertDialogOverlay, -} from "@chakra-ui/react" -import { usePostHogContext } from "components/_app/PostHogProvider" -import Button from "components/common/Button" -import { Alert } from "components/common/Modal" -import { ArrowRight } from "phosphor-react" -import { useRef } from "react" - -type Props = { - isOpen: boolean - onClose: () => void - onSendEmbed: () => void - onContinue: () => void -} - -const SendDiscordJoinButtonAlert = ({ - isOpen, - onClose, - onSendEmbed, - onContinue, -}: Props): JSX.Element => { - const cancelRef = useRef() - const { captureEvent } = usePostHogContext() - - return ( - - - - Are you sure? - - Sending a Discord join embed helps your community find their way into - your Guild and unlock new roles. - - - - - - - - - - ) -} - -export default SendDiscordJoinButtonAlert diff --git a/src/components/[guild]/Onboarding/components/SummonMembers/components/SendDiscordJoinButtonModal.tsx b/src/components/[guild]/Onboarding/components/SummonMembers/components/SendDiscordJoinButtonModal.tsx index a0da0f8fdb..96c355ca56 100644 --- a/src/components/[guild]/Onboarding/components/SummonMembers/components/SendDiscordJoinButtonModal.tsx +++ b/src/components/[guild]/Onboarding/components/SummonMembers/components/SendDiscordJoinButtonModal.tsx @@ -16,12 +16,19 @@ import FormErrorMessage from "components/common/FormErrorMessage" import { Modal } from "components/common/Modal" import useServerData from "hooks/useServerData" import { FormProvider, useForm } from "react-hook-form" -import { SummonMembersForm } from "../SummonMembers" import useSendJoin from "../hooks/useSendJoin" import EntryChannel from "./EntryChannel" import PanelBody from "./PanelBody" import PanelButton from "./PanelButton" +export type DiscordEmbedForm = { + channelId: string + serverId: string + title: string + description: string + button: string +} + const SendDiscordJoinButtonModal = ({ isOpen, onClose, @@ -40,7 +47,7 @@ const SendDiscordJoinButtonModal = ({ data: { channels }, } = useServerData(serverId) - const methods = useForm({ + const methods = useForm({ mode: "onSubmit", defaultValues: { title: "Verify your wallet", diff --git a/src/components/[guild]/Onboarding/components/SummonMembers/hooks/useSendJoin.tsx b/src/components/[guild]/Onboarding/components/SummonMembers/hooks/useSendJoin.tsx index 5999567f7d..b8775767fd 100644 --- a/src/components/[guild]/Onboarding/components/SummonMembers/hooks/useSendJoin.tsx +++ b/src/components/[guild]/Onboarding/components/SummonMembers/hooks/useSendJoin.tsx @@ -5,7 +5,7 @@ import useSubmit from "hooks/useSubmit" import useToast from "hooks/useToast" import { PlatformGuildData, PlatformType } from "types" import { useFetcherWithSign } from "utils/fetcher" -import { SummonMembersForm } from "../SummonMembers" +import { DiscordEmbedForm } from "../components/SendDiscordJoinButtonModal" const useSendJoin = (onSuccess?: () => void) => { const { mutateGuild } = useGuild() @@ -14,7 +14,7 @@ const useSendJoin = (onSuccess?: () => void) => { const showErrorToast = useShowErrorToast() const fetcerWithSign = useFetcherWithSign() - const sendJoin = ({ serverId, ...body }: SummonMembersForm) => + const sendJoin = ({ serverId, ...body }: DiscordEmbedForm) => fetcerWithSign([ `/v2/discord/servers/${serverId}/button`, { diff --git a/src/components/[guild]/Onboarding/components/SummonMembers/index.ts b/src/components/[guild]/Onboarding/components/SummonMembers/index.ts deleted file mode 100644 index 3ba0f4b60b..0000000000 --- a/src/components/[guild]/Onboarding/components/SummonMembers/index.ts +++ /dev/null @@ -1 +0,0 @@ -export { default } from "./SummonMembers" diff --git a/src/components/[guild]/Onboarding/index.ts b/src/components/[guild]/Onboarding/index.ts deleted file mode 100644 index 268097aa5e..0000000000 --- a/src/components/[guild]/Onboarding/index.ts +++ /dev/null @@ -1,3 +0,0 @@ -import Onboarding from "./Onboarding" - -export default Onboarding diff --git a/src/components/[guild]/RoleCard/components/EditRole/EditRole.tsx b/src/components/[guild]/RoleCard/components/EditRole/EditRole.tsx index dd3cc24609..3ffdd97a31 100644 --- a/src/components/[guild]/RoleCard/components/EditRole/EditRole.tsx +++ b/src/components/[guild]/RoleCard/components/EditRole/EditRole.tsx @@ -13,9 +13,7 @@ import { } from "@chakra-ui/react" import useGuild from "components/[guild]/hooks/useGuild" import { ApiRequirementHandlerProvider } from "components/[guild]/RequirementHandlerContext" -import { usePostHogContext } from "components/_app/PostHogProvider" import DiscardAlert from "components/common/DiscardAlert" -import OnboardingMarker from "components/common/OnboardingMarker" import Section from "components/common/Section" import Description from "components/create-guild/Description" import DynamicDevTool from "components/create-guild/DynamicDevTool" @@ -33,10 +31,11 @@ import RoleGroupSelect from "./components/RoleGroupSelect" import useEditRoleForm from "./hooks/useEditRoleForm" import useSubmitEditRole from "./hooks/useSubmitEditRole" -const EditRole = ({ roleId }: { roleId: number }): JSX.Element => { +type Props = { roleId: number } + +const EditRole = ({ roleId }: Props): JSX.Element => { const { isOpen, onOpen, onClose } = useDisclosure() const btnRef = useRef() - const { captureEvent } = usePostHogContext() const methods = useEditRoleForm(roleId) const { control, reset, formState, defaultValues } = methods @@ -71,22 +70,14 @@ const EditRole = ({ roleId }: { roleId: number }): JSX.Element => { return ( <> - { - captureEvent("guild creation flow > pulse marker: Edit role clicked") - onOpen() - }} - > - } - size="sm" - rounded="full" - aria-label="Edit role" - onClick={onOpen} - /> - + } + size="sm" + rounded="full" + aria-label="Edit role" + onClick={onOpen} + /> { ) } -const EditRoleWrapper = ({ roleId }) => { +const EditRoleWrapper = ({ roleId }: Props) => { const { isDetailed } = useGuild() if (!isDetailed) - return ( - - - - ) + return return } diff --git a/src/components/common/Layout/components/Header.tsx b/src/components/common/Layout/components/Header.tsx index 0c7658b393..b8bc8554c6 100644 --- a/src/components/common/Layout/components/Header.tsx +++ b/src/components/common/Layout/components/Header.tsx @@ -10,12 +10,14 @@ const Header = (): JSX.Element => { return ( { aria-label="Navigation menu" rightIcon={} iconSpacing="3" - fontFamily={"display"} + fontFamily="display" fontWeight="black" - borderRadius={"2xl"} + borderRadius="2xl" variant="ghost" > - + Guild @@ -68,8 +68,8 @@ const NavMenu = (): JSX.Element => { diff --git a/src/components/common/OnboardingMarker.tsx b/src/components/common/OnboardingMarker.tsx deleted file mode 100644 index 8b7855e556..0000000000 --- a/src/components/common/OnboardingMarker.tsx +++ /dev/null @@ -1,39 +0,0 @@ -import { ChakraProps } from "@chakra-ui/react" -import { onboardingStepAtom } from "components/[guild]/Onboarding/Onboarding" -import { useAtom } from "jotai" -import { PropsWithChildren, useState } from "react" -import PulseMarker from "./PulseMarker" - -type Props = { - step: number - onClick?: () => void -} & ChakraProps - -const OnboardingMarker = ({ - step, - onClick, - children, - ...rest -}: PropsWithChildren) => { - const [localStep] = useAtom(onboardingStepAtom) - const [hasClicked, setHasClicked] = useState(false) - const handleClick = () => { - setHasClicked(true) - onClick?.() - } - - const hidden = hasClicked || step !== localStep - - return ( - - ) -} - -export default OnboardingMarker diff --git a/src/components/common/StyledSelect/StyledSelect.tsx b/src/components/common/StyledSelect/StyledSelect.tsx index bf2c578e67..63ad74b51a 100644 --- a/src/components/common/StyledSelect/StyledSelect.tsx +++ b/src/components/common/StyledSelect/StyledSelect.tsx @@ -73,7 +73,11 @@ const StyledSelect = forwardRef( IndicatorSeparator: null, ...props.components, }} - menuPortalTarget={document?.getElementById("chakra-react-select-portal")} + menuPortalTarget={ + typeof document !== "undefined" + ? document.getElementById("chakra-react-select-portal") + : undefined + } menuShouldBlockScroll={true} menuShouldScrollIntoView={false} /> diff --git a/src/components/create-guild/BasicInfo/BasicInfo.tsx b/src/components/create-guild/BasicInfo/BasicInfo.tsx deleted file mode 100644 index 03bf8a3c77..0000000000 --- a/src/components/create-guild/BasicInfo/BasicInfo.tsx +++ /dev/null @@ -1,126 +0,0 @@ -import { - FormControl, - FormLabel, - HStack, - SimpleGrid, - Stack, - chakra, - useColorModeValue, -} from "@chakra-ui/react" -import BackgroundImageUploader from "components/[guild]/EditGuild/components/BackgroundImageUploader" -import ColorPicker from "components/[guild]/EditGuild/components/ColorPicker" -import UrlName from "components/[guild]/EditGuild/components/UrlName" -import { useThemeContext } from "components/[guild]/ThemeContext" -import Section from "components/common/Section" -import usePinata from "hooks/usePinata" -import { useSetAtom } from "jotai" -import { useCallback, useEffect } from "react" -import { useFormContext, useWatch } from "react-hook-form" -import { GuildFormType } from "types" -import slugify from "utils/slugify" -import { useCreateGuildContext } from "../CreateGuildContext" -import Description from "../Description" -import { ContinueBtnTooltipLabelAtom } from "../GuildCreationProgress/GuildCreationProgress" -import IconSelector from "../IconSelector" -import Name from "../Name" -import useSetImageAndNameFromPlatformData from "../hooks/useSetImageAndNameFromPlatformData" -import ContactInfo from "./components/ContactInfo" - -const BasicInfo = (): JSX.Element => { - const { setDisabled } = useCreateGuildContext() - const { setLocalBackgroundImage } = useThemeContext() - - const setContinueTooltipLabel = useSetAtom(ContinueBtnTooltipLabelAtom) - - const { - control, - setValue, - formState: { errors, dirtyFields }, - } = useFormContext() - - const requiredIndicatorColor = useColorModeValue("red.500", "red.300") - - const name = useWatch({ control, name: "name" }) - const contacts = useWatch({ control, name: "contacts" }) - const guildPlatforms = useWatch({ control, name: "guildPlatforms" }) - - useEffect(() => { - setDisabled(!name || !contacts[0].contact || !!Object.values(errors).length) - setContinueTooltipLabel( - !contacts[0].contact || errors.contacts ? "Contact email required!" : "" - ) - return () => setContinueTooltipLabel("") - }, [setDisabled, name, errors, contacts, errors.contacts, setContinueTooltipLabel]) - - const iconUploader = usePinata({ - fieldToSetOnSuccess: "imageUrl", - fieldToSetOnError: "imageUrl", - }) - - const discordPlatformData = guildPlatforms.find( - (platform) => platform.platformName === "DISCORD" - )?.platformGuildData - - const telegramPlatformData = guildPlatforms.find( - (platform) => platform.platformName === "TELEGRAM" - )?.platformGuildData - - useSetImageAndNameFromPlatformData( - discordPlatformData?.imageUrl ?? telegramPlatformData?.imageUrl, - discordPlatformData?.name ?? telegramPlatformData?.name, - iconUploader.onUpload - ) - - useEffect(() => { - if (name && !dirtyFields.urlName) - setValue("urlName", slugify(name), { shouldValidate: true }) - }, [name, dirtyFields, setValue]) - - const onBackgrondUploadError = useCallback(() => { - setLocalBackgroundImage(null) - }, [setLocalBackgroundImage]) - - const backgroundUploader = usePinata({ - fieldToSetOnSuccess: "theme.backgroundImage", - onError: onBackgrondUploadError, - }) - - return ( - - - - - Logo and name - - - - - - - - - - - - - -
- How could we contact you?{" "} - * - - } - spacing="4" - > - -
-
- ) -} - -export default BasicInfo diff --git a/src/components/create-guild/BasicInfo/components/ContactInfo.tsx b/src/components/create-guild/BasicInfo/components/ContactInfo.tsx index 582b499ad6..7902c526b5 100644 --- a/src/components/create-guild/BasicInfo/components/ContactInfo.tsx +++ b/src/components/create-guild/BasicInfo/components/ContactInfo.tsx @@ -12,11 +12,13 @@ import { Text, } from "@chakra-ui/react" import Button from "components/common/Button" +import ClientOnly from "components/common/ClientOnly" import FormErrorMessage from "components/common/FormErrorMessage" import StyledSelect from "components/common/StyledSelect" +import { CreateGuildFormType } from "components/create-guild/CreateGuildForm" import { ArrowSquareOut, Plus, TrashSimple } from "phosphor-react" import { Controller, useFieldArray, useFormContext } from "react-hook-form" -import { GuildFormType, SelectOption } from "types" +import { SelectOption } from "types" const contactTypeOptions: SelectOption[] = [ { value: "EMAIL", label: "E-mail" }, @@ -35,7 +37,7 @@ const ContactInfo = ({ showAddButton = true }: Props): JSX.Element => { getValues, resetField, formState: { errors }, - } = useFormContext() + } = useFormContext() const { fields, append, remove } = useFieldArray({ control, @@ -44,12 +46,8 @@ const ContactInfo = ({ showAddButton = true }: Props): JSX.Element => { }) return ( - <> - - Only visible to the Guild Team to reach you with support and partnership - initiatives if needed. - - + + {fields.map((contactField, index) => ( @@ -125,35 +123,35 @@ const ContactInfo = ({ showAddButton = true }: Props): JSX.Element => { ))} + - {showAddButton && ( - - )} + {showAddButton && ( + + )} - {!showAddButton && ( - - Or{" "} - - join our Discord - - - - )} - - + {!showAddButton && ( + + Or{" "} + + join our Discord + + + + )} + ) } diff --git a/src/components/create-guild/BasicInfo/components/TwitterUrlInput.tsx b/src/components/create-guild/BasicInfo/components/TwitterUrlInput.tsx deleted file mode 100644 index 1dd449d132..0000000000 --- a/src/components/create-guild/BasicInfo/components/TwitterUrlInput.tsx +++ /dev/null @@ -1,37 +0,0 @@ -import { FormControl, Input, InputGroup, InputLeftElement } from "@chakra-ui/react" -import SocialIcon from "components/[guild]/SocialIcon" -import FormErrorMessage from "components/common/FormErrorMessage" -import { useFormContext } from "react-hook-form" - -const TwitterUrlInput = (): JSX.Element => { - const { - register, - formState: { errors }, - } = useFormContext<{ twitterUrl: string }>() - - return ( - - - - - - - ((v.includes("twitter.com") || v.includes("x.com")) && - v.includes("/") && - !!v.split("/").slice(-1)[0]?.length) || - "Invalid X URL", - shouldUnregister: true, - })} - /> - - {errors?.twitterUrl?.message} - - ) -} - -export default TwitterUrlInput diff --git a/src/components/create-guild/BasicInfo/index.ts b/src/components/create-guild/BasicInfo/index.ts deleted file mode 100644 index 4b5899e24d..0000000000 --- a/src/components/create-guild/BasicInfo/index.ts +++ /dev/null @@ -1,3 +0,0 @@ -import BasicInfo from "./BasicInfo" - -export default BasicInfo diff --git a/src/components/create-guild/ChooseTemplate/ChooseTemplate.tsx b/src/components/create-guild/ChooseTemplate/ChooseTemplate.tsx deleted file mode 100644 index e526b1083c..0000000000 --- a/src/components/create-guild/ChooseTemplate/ChooseTemplate.tsx +++ /dev/null @@ -1,79 +0,0 @@ -import { Box, Button, Collapse } from "@chakra-ui/react" -import { walletSelectorModalAtom } from "components/_app/Web3ConnectionManager/components/WalletSelectorModal" -import useWeb3ConnectionManager from "components/_app/Web3ConnectionManager/hooks/useWeb3ConnectionManager" -import { useAtom } from "jotai" -import { ArrowLeft } from "phosphor-react" -import { useEffect } from "react" -import { useFormContext, useWatch } from "react-hook-form" -import { GuildFormType } from "types" -import { useCreateGuildContext } from "../CreateGuildContext" -import TemplateCard from "./components/TemplateCard" -import useTemplate from "./useTemplate" - -const ChooseTemplate = (): JSX.Element => { - const { isWeb3Connected } = useWeb3ConnectionManager() - const { buildTemplate, toggleReward, toggleTemplate } = useTemplate() - const [isWalletSelectorModalOpen, setIsWalletSelectorModalOpen] = useAtom( - walletSelectorModalAtom - ) - - useEffect(() => { - if (isWeb3Connected || isWalletSelectorModalOpen) return - setIsWalletSelectorModalOpen(true) - }, [isWeb3Connected, isWalletSelectorModalOpen, setIsWalletSelectorModalOpen]) - - const { setDisabled, stepPart, setPart } = useCreateGuildContext() - - const { control } = useFormContext() - - const roles = useWatch({ control, name: "roles" }) - - useEffect(() => { - setDisabled(!roles.length) - }, [setDisabled, roles.length]) - - return ( - <> - - {stepPart === 1 && ( - - )} - - {buildTemplate().map((role) => ( - r.name === role.name)) - } - style={{ width: "100%", padding: 1, margin: -1 }} - key={role.name} - > - r.name === role.name)} - {...role} - onClick={(templateName) => { - if (stepPart === 0) toggleTemplate(templateName) - }} - onCheckReward={(rewradIndex) => { - toggleReward(role.name, rewradIndex) - }} - /> - - ))} - - - ) -} - -export default ChooseTemplate diff --git a/src/components/create-guild/ChooseTemplate/components/TemplateCard.tsx b/src/components/create-guild/ChooseTemplate/components/TemplateCard.tsx deleted file mode 100644 index e536c716c6..0000000000 --- a/src/components/create-guild/ChooseTemplate/components/TemplateCard.tsx +++ /dev/null @@ -1,280 +0,0 @@ -import { - Box, - Checkbox, - Circle, - Collapse, - Flex, - HStack, - Icon, - SimpleGrid, - Text, - Tooltip, - useColorModeValue, - useDisclosure, -} from "@chakra-ui/react" -import HiddenRewards from "components/[guild]/RoleCard/components/HiddenRewards" -import { - RewardDisplay, - RewardIcon, -} from "components/[guild]/RoleCard/components/Reward" -import RoleHeader from "components/[guild]/RoleCard/components/RoleHeader" -import RoleRequirementsSection, { - RoleRequirementsSectionHeader, -} from "components/[guild]/RoleCard/components/RoleRequirementsSection" -import Card from "components/common/Card" -import { Check } from "phosphor-react" -import rewards, { PlatformAsRewardRestrictions } from "platforms/rewards" -import { KeyboardEvent } from "react" -import { useWatch } from "react-hook-form" -import { GuildFormType, GuildPlatform, PlatformType, RoleFormType } from "types" -import capitalize from "utils/capitalize" -import slugify from "utils/slugify" -import TemplateRequriements from "./TemplateRequriements" - -type Template = { - name: string - description?: string - role: RoleFormType -} - -type Props = Template & { - selected?: boolean - part: number - onClick: (templateName: string) => void - onCheckReward: (rewardIndex: number) => void -} - -const getRewardLabel = (platform: Partial) => { - switch (platform.platformId) { - case PlatformType.DISCORD: - return "Role in: " - - case PlatformType.GOOGLE: - return `${capitalize(platform.platformGuildData.role ?? "reader")} access to: ` - - default: - return "Access to: " - } -} - -const TemplateCard = ({ - name, - description, - role, - selected, - part, - onClick, - onCheckReward, -}: Props): JSX.Element => { - const roleRewardsBgColor = useColorModeValue("gray.50", "blackAlpha.300") - - const roles = useWatch({ name: "roles" }) - const guildPlatforms = useWatch({ - name: "guildPlatforms", - }) - - const { isOpen: isExpanded, onToggle: onToggleExpanded } = useDisclosure({ - defaultIsOpen: false, - }) - - return ( - onClick(name)} - onKeyDown={(e: KeyboardEvent) => { - if (e.key !== "Enter" && e.key !== " ") return - e.preventDefault() - onClick(name) - }} - position="relative" - mb={3} - borderRadius="2xl" - overflow="hidden" - _before={{ - content: `""`, - position: "absolute", - top: 0, - bottom: 0, - left: 0, - right: 0, - bg: "gray.300", - opacity: 0, - transition: "opacity 0.2s", - }} - _hover={{ - _before: { - opacity: part === 0 ? 0.1 : 0, - }, - }} - _active={{ - _before: { - opacity: part === 0 ? 0.17 : 0, - }, - }} - cursor={part === 0 ? "pointer" : "default"} - h="max-content" - w="full" - > - - - - - - - - {description} - - - - - - {guildPlatforms?.length ? ( - guildPlatforms.map((platform, i) => { - const isDisabled = - rewards[platform.platformName].asRewardRestriction === - PlatformAsRewardRestrictions.SINGLE_ROLE && - roles - .filter((r) => r.name !== name) - .some((r) => - r.rolePlatforms?.find( - (rolePlatform) => rolePlatform.guildPlatformIndex === i - ) - ) - - return ( - - { - e.preventDefault() - if (!isDisabled) onCheckReward(i) - }} - > - r.name === name) - ?.rolePlatforms?.find( - (rolePlatform) => - rolePlatform.guildPlatformIndex === i - ) - } - /> - - {getRewardLabel(platform)} - - {getValueToDisplay(platform)} - - - } - icon={ - - } - /> - - - ) - }) - ) : ( - - You haven't set any platforms that could be rewards in step 1. - You can go back and set some now, or add rewards later - - )} - {role.hiddenRewards && } - - - - - - - - - - {part === 0 && ( - - {selected ? ( - - - - ) : ( - - )} - - )} - - ) -} - -const getValueToDisplay = ( - platform: Partial & { - platformName: string - } -): string => - platform.platformGuildData.name ?? - `${rewards[platform.platformName].name} ${ - rewards[platform.platformName].gatedEntity - }` - -export default TemplateCard -export type { Template } diff --git a/src/components/create-guild/ChooseTemplate/components/TemplateRequriements.tsx b/src/components/create-guild/ChooseTemplate/components/TemplateRequriements.tsx deleted file mode 100644 index c1c675f3c6..0000000000 --- a/src/components/create-guild/ChooseTemplate/components/TemplateRequriements.tsx +++ /dev/null @@ -1,92 +0,0 @@ -import { Box, Collapse, VStack, useColorModeValue } from "@chakra-ui/react" -import LogicDivider from "components/[guild]/LogicDivider" -import AnyOfHeader from "components/[guild]/Requirements/components/AnyOfHeader" -import ExpandRequirementsButton from "components/[guild]/Requirements/components/ExpandRequirementsButton" -import RequirementDisplayComponent from "components/[guild]/Requirements/components/RequirementDisplayComponent" -import { RoleCardCollapseProps } from "components/[guild]/RoleCard" -import React, { memo } from "react" -import { Requirement, RoleFormType } from "types" - -type Props = { - role: RoleFormType - isExpanded: boolean - onToggleExpanded: () => void -} & RoleCardCollapseProps - -const TemplateRequirements = ({ role, isExpanded, onToggleExpanded }: Props) => { - const requirements = role.requirements - - const sliceIndex = (requirements?.length ?? 0) - 3 - const shownRequirements = (requirements ?? []).slice(0, 3) - const hiddenRequirements = - sliceIndex > 0 ? (requirements ?? []).slice(-sliceIndex) : [] - - const shadowColor = useColorModeValue( - "var(--chakra-colors-gray-300)", - "var(--chakra-colors-gray-900)" - ) - - return ( - - {role.logic === "ANY_OF" && } - - - {shownRequirements.map((requirement, i) => ( - <> - - {i < shownRequirements.length - 1 && ( - - )} - - ))} - - - {hiddenRequirements.map((requirement, i) => ( - - {i === 0 && } - - {i < hiddenRequirements.length - 1 && ( - - )} - - ))} - - {hiddenRequirements.length > 0 && ( - <> - { - e.stopPropagation() - onToggleExpanded() - }} - /> - - - )} - - - ) -} - -export default memo(TemplateRequirements) diff --git a/src/components/create-guild/ChooseTemplate/index.ts b/src/components/create-guild/ChooseTemplate/index.ts deleted file mode 100644 index f5ce45a1b3..0000000000 --- a/src/components/create-guild/ChooseTemplate/index.ts +++ /dev/null @@ -1,3 +0,0 @@ -import ChooseTemplate from "./ChooseTemplate" - -export default ChooseTemplate diff --git a/src/components/create-guild/ChooseTemplate/useTemplate.tsx b/src/components/create-guild/ChooseTemplate/useTemplate.tsx deleted file mode 100644 index 1f2801adac..0000000000 --- a/src/components/create-guild/ChooseTemplate/useTemplate.tsx +++ /dev/null @@ -1,137 +0,0 @@ -import { useFieldArray, useFormContext } from "react-hook-form" -import { GuildFormType, RoleFormType } from "types" -import { TEMPLATES } from "../templates" - -const ID_AFTER_DOMAIN_REGEX = /(?<=com\/).*$/ - -const useTemplate = () => { - const methods = useFormContext() - - const { append, remove } = useFieldArray({ - name: "roles", - control: methods.control, - }) - - const buildTemplate = () => { - const templatesCopy: Array = structuredClone(TEMPLATES) - - return templatesCopy - .map((template) => { - const twitterRequirementIndex = template.requirements.findIndex( - (requriement) => requriement.type === "TWITTER_FOLLOW" - ) - - if (twitterRequirementIndex > -1) - template.requirements[twitterRequirementIndex].data.id = - ID_AFTER_DOMAIN_REGEX.exec(methods.getValues("socialLinks.TWITTER")) - - const discordPlatfromIndex = methods - .getValues("guildPlatforms") - .findIndex((guildPlatform) => guildPlatform.platformName === "DISCORD") - - if (discordPlatfromIndex > -1) - template.rolePlatforms = [{ guildPlatformIndex: discordPlatfromIndex }] - - const joinDiscordServerRequirementIndex = template.requirements.findIndex( - (requriement) => requriement.type === "DISCORD_MEMBER_SINCE" - ) - - if (joinDiscordServerRequirementIndex > -1) - template.requirements[joinDiscordServerRequirementIndex].data.serverId = - methods - .getValues("guildPlatforms") - .find( - (guildPlatform) => guildPlatform.platformName === "DISCORD" - )?.platformGuildId - - return template - }) - .filter((template) => { - const twitterRequirementIndex = template.requirements.findIndex( - (requriement) => requriement.type === "TWITTER_FOLLOW" - ) - const hasTwitter = methods.getValues("socialLinks.TWITTER") - const twitterIsRequired = twitterRequirementIndex > -1 - - const discordRequirementIndex = template.requirements.findIndex( - (requriement) => requriement.type === "DISCORD_MEMBER_SINCE" - ) - const hasDiscord = methods - .getValues("guildPlatforms") - .find((guildPlatform) => guildPlatform.platformName === "DISCORD") - const discordIsRequired = discordRequirementIndex > -1 - - return !( - (twitterIsRequired && !hasTwitter) || - (discordIsRequired && !hasDiscord) - ) - }) - } - - const toggleTemplate = (roleTemplateName: string) => { - const roleIndex = methods - .getValues("roles") - .findIndex((role) => role.name === roleTemplateName) - - if (roleIndex > -1) { - remove(roleIndex) - } else { - const originalTemplate = buildTemplate().find( - (template) => template.name === roleTemplateName - ) - - const templateCopy = structuredClone(originalTemplate) - - templateCopy.description = undefined - - append(templateCopy) - } - } - - const toggleReward = (roleTemplateName: string, guildPlatformIndex: number) => { - const roleIndex = methods - .getValues("roles") - .findIndex((role) => role.name === roleTemplateName) - - const roleClicked: RoleFormType = methods.getValues("roles")[roleIndex] - - const reward = roleClicked.rolePlatforms?.find( - (rolePlatform) => rolePlatform.guildPlatformIndex === guildPlatformIndex - ) - - if (reward) { - methods.setValue( - `roles.${roleIndex}.rolePlatforms`, - roleClicked.rolePlatforms.filter( - (rolePlatform) => rolePlatform.guildPlatformIndex !== guildPlatformIndex - ) - ) - } else { - const guildPlatform = methods.getValues("guildPlatforms")[guildPlatformIndex] - const currentRolePlatforms = roleClicked.rolePlatforms - ? roleClicked.rolePlatforms - : [] - - const rolePlatforms = [ - { - guildPlatformIndex, - platformRoleId: - guildPlatform.platformName === "GOOGLE" - ? guildPlatform.platformGuildData.role - : undefined, - }, - ...currentRolePlatforms, - ] - - methods.setValue(`roles.${roleIndex}.rolePlatforms`, rolePlatforms) - } - } - - return { - buildTemplate, - toggleReward, - toggleTemplate, - } -} - -export default useTemplate diff --git a/src/components/create-guild/CreateGuildButton.tsx b/src/components/create-guild/CreateGuildButton.tsx index 76b8e3a027..a6d198697a 100644 --- a/src/components/create-guild/CreateGuildButton.tsx +++ b/src/components/create-guild/CreateGuildButton.tsx @@ -1,60 +1,45 @@ -import { usePostHogContext } from "components/_app/PostHogProvider" +import { Collapse, Stack } from "@chakra-ui/react" +import { walletSelectorModalAtom } from "components/_app/Web3ConnectionManager/components/WalletSelectorModal" +import useWeb3ConnectionManager from "components/_app/Web3ConnectionManager/hooks/useWeb3ConnectionManager" import Button from "components/common/Button" -import { useFormContext, useWatch } from "react-hook-form" -import { GuildFormType } from "types" +import { useSetAtom } from "jotai" +import { useFormContext } from "react-hook-form" +import { CreateGuildFormType } from "./CreateGuildForm" import useCreateGuild from "./hooks/useCreateGuild" -type Props = { - isDisabled?: boolean -} - -const CreateGuildButton = ({ isDisabled }: Props): JSX.Element => { - const { handleSubmit } = useFormContext() - const roles = useWatch({ name: "roles" }) - const guildPlatforms = useWatch({ name: "guildPlatforms" }) - const hasDiscordReward = guildPlatforms?.some( - (guildPlatform) => guildPlatform?.platformName === "DISCORD" - ) - const { captureEvent } = usePostHogContext() +const CreateGuildButton = () => { + const { handleSubmit } = useFormContext() + const { onSubmit, isLoading } = useCreateGuild() - const { onSubmit, isLoading, response, isSigning, signLoadingText } = - useCreateGuild({ - onSuccess: () => { - if (hasDiscordReward) { - captureEvent("[discord setup] guild creation successful") - } - }, - onError: (err) => { - captureEvent("[discord setup] guild creation failed", { error: err }) - }, - }) + const { isWeb3Connected } = useWeb3ConnectionManager() + const setIsWalletSelectorModalOpen = useSetAtom(walletSelectorModalAtom) return ( - + + + + + + ) } diff --git a/src/components/create-guild/CreateGuildContext.tsx b/src/components/create-guild/CreateGuildContext.tsx deleted file mode 100644 index 1f7f7d89ca..0000000000 --- a/src/components/create-guild/CreateGuildContext.tsx +++ /dev/null @@ -1,89 +0,0 @@ -import { useSteps } from "@chakra-ui/react" -import { - PropsWithChildren, - createContext, - useContext, - useEffect, - useState, -} from "react" -import { FormProvider, useForm } from "react-hook-form" -import { GuildFormType } from "types" - -const CreateGuildContext = createContext<{ - prevStep: () => void - nextStep: () => void - activeStep: number - setActiveStep: (index: number) => void - stepPart: number - setPart: (part: number) => void - nextStepIsDisabled: boolean - setDisabled: (value: boolean) => void -} | null>(null) - -const CreateGuildProvider = ({ - children, -}: PropsWithChildren): JSX.Element => { - const [stepPart, setPart] = useState(0) - const [nextStepIsDisabled, setDisabled] = useState(false) - - const methods = useForm({ - mode: "all", - defaultValues: { - guildPlatforms: [], - contacts: [{ type: "EMAIL", contact: "" }], - theme: { - color: "#71717a", - }, - roles: [], - }, - }) - - const { - goToPrevious: prevStep, - goToNext: nextStep, - activeStep, - setActiveStep, - } = useSteps({ - index: 0, - count: 5, - }) - - useEffect(() => { - if (typeof window !== "undefined") - window.scrollTo({ - top: 0, - behavior: "smooth", - }) - if (activeStep > 0) return - }, [activeStep]) - - return ( - { - prevStep() - setPart(0) - }, - nextStep: () => { - nextStep() - setPart(0) - }, - activeStep, - setActiveStep: (step) => { - setActiveStep(step) - setPart(0) - }, - setPart, - stepPart, - nextStepIsDisabled, - setDisabled, - }} - > - {children} - - ) -} - -const useCreateGuildContext = () => useContext(CreateGuildContext) - -export { CreateGuildProvider, useCreateGuildContext } diff --git a/src/components/create-guild/CreateGuildForm.tsx b/src/components/create-guild/CreateGuildForm.tsx new file mode 100644 index 0000000000..78fee1a47c --- /dev/null +++ b/src/components/create-guild/CreateGuildForm.tsx @@ -0,0 +1,115 @@ +import { + Center, + FormControl, + FormLabel, + Heading, + Input, + Stack, +} from "@chakra-ui/react" +import { Schemas } from "@guildxyz/types" +import useUser from "components/[guild]/hooks/useUser" +import Card from "components/common/Card" +import FormErrorMessage from "components/common/FormErrorMessage" +import usePinata from "hooks/usePinata" +import { useEffect } from "react" +import { useFormContext, useWatch } from "react-hook-form" +import getColorByImage from "utils/getColorByImage" +import CreateGuildButton from "./CreateGuildButton" +import IconSelector from "./IconSelector" +import Name from "./Name" + +export type CreateGuildFormType = Pick< + Schemas["GuildCreationPayload"], + "name" | "imageUrl" | "contacts" | "theme" +> + +const CreateGuildForm = () => { + const { + control, + register, + setValue, + formState: { errors, touchedFields }, + } = useFormContext() + + const iconUploader = usePinata({ + fieldToSetOnSuccess: "imageUrl", + fieldToSetOnError: "imageUrl", + control, + }) + + const { emails, platformUsers } = useUser() + + const providedEmail = useWatch({ control, name: "contacts.0.contact" }) + useEffect(() => { + if (!!providedEmail || touchedFields.contacts?.[0]?.contact) return + + const emailAddress = emails?.emailAddress + const googleEmailAddress = platformUsers?.find( + (pu) => pu.platformName === "GOOGLE" + )?.platformUserId + + if (!emailAddress && !googleEmailAddress) return + + setValue("contacts.0.contact", emailAddress ?? googleEmailAddress) + }, [touchedFields.contacts, emails, platformUsers, providedEmail, setValue]) + + return ( + + + + Begin your guild + + +
+ { + const generatedThemeColor = await getColorByImage(objectURL) + setValue("theme.color", generatedThemeColor) + }} + boxSize={28} + /> +
+ + + Guild name + + + + + Your email + + + {errors.contacts?.[0]?.contact?.message} + + + + +
+
+ ) +} + +export default CreateGuildForm diff --git a/src/components/create-guild/CreateGuildIndex.tsx b/src/components/create-guild/CreateGuildIndex.tsx deleted file mode 100644 index 291c07135d..0000000000 --- a/src/components/create-guild/CreateGuildIndex.tsx +++ /dev/null @@ -1,58 +0,0 @@ -import { Checkbox, HStack, Text } from "@chakra-ui/react" -import { usePostHogContext } from "components/_app/PostHogProvider" -import ClientOnly from "components/common/ClientOnly" -import { useEffect, useState } from "react" -import { useWatch } from "react-hook-form" -import { useCreateGuildContext } from "./CreateGuildContext" -import MultiPlatformsGrid from "./MultiPlatformGrid" - -const CreateGuildIndex = (): JSX.Element => { - const { setDisabled } = useCreateGuildContext() - const [whitoutPlatform, setWhitoutPlatform] = useState(false) - const { captureEvent, startSessionRecording } = usePostHogContext() - - const guildPlatforms = useWatch({ name: "guildPlatforms" }) - const twitter = useWatch({ name: "socialLinks.TWITTER" }) - - useEffect(() => { - setDisabled(!twitter && guildPlatforms.length === 0 && !whitoutPlatform) - }, [setDisabled, twitter, guildPlatforms.length, whitoutPlatform]) - - return ( - - { - if (platformName === "CONTRACT_CALL") startSessionRecording() - if (platformName === "DISCORD") - captureEvent("[discord setup] started through guild creation") - - setWhitoutPlatform(false) - }} - /> - - - - or - - { - if (guildPlatforms.length === 0) { - setWhitoutPlatform(e?.target?.checked) - if (e?.target?.checked) - captureEvent("guild creation flow > add platforms later") - } - }} - spacing={1.5} - > - - add rewards later - - - - - ) -} - -export default CreateGuildIndex diff --git a/src/components/create-guild/CreateGuildMainSection.tsx b/src/components/create-guild/CreateGuildMainSection.tsx deleted file mode 100644 index 35e0acea6d..0000000000 --- a/src/components/create-guild/CreateGuildMainSection.tsx +++ /dev/null @@ -1,63 +0,0 @@ -import { Stack } from "@chakra-ui/react" -import { useThemeContext } from "components/[guild]/ThemeContext" -import { usePostHogContext } from "components/_app/PostHogProvider" -import { Layout } from "components/common/Layout" -import CreateGuildButton from "components/create-guild/CreateGuildButton" -import { useCreateGuildContext } from "components/create-guild/CreateGuildContext" -import CreateGuildStepper, { - STEPS, -} from "components/create-guild/CreateGuildStepper" -import GuildCreationProgress from "components/create-guild/GuildCreationProgress" -import { useEffect } from "react" -import { useWatch } from "react-hook-form" - -export function CreateGuildMainSection() { - const { textColor, localThemeColor } = useThemeContext() - const { - activeStep, - setActiveStep, - stepPart, - nextStep, - nextStepIsDisabled, - setPart, - } = useCreateGuildContext() - const contacts = useWatch({ name: "contacts" }) - const { captureEvent } = usePostHogContext() - const themeColor = useWatch({ name: "theme.color" }) - const color = localThemeColor !== themeColor ? themeColor : localThemeColor - const isLastSubStep = STEPS[activeStep].progress.length === stepPart + 1 - - const nextWithPostHog = () => { - // +2 because, index starts with 0 and we jump to the step after the active one - captureEvent("guild creation flow > continue", { to: activeStep + 2 }) - - // email can be added in step 2 - if (activeStep === 1 && contacts[0].contact) - captureEvent("guild creation flow > contacts added") - - nextStep() - } - - useEffect(() => { - captureEvent("guild creation flow > start guild creation") - // eslint-disable-next-line react-hooks/exhaustive-deps - }, []) - - return ( - - - - {STEPS[activeStep].content} - - setPart(stepPart + 1)} - progress={STEPS[activeStep].progress[stepPart]} - isDisabled={nextStepIsDisabled} - > - {stepPart === 1 ? : null} - - - ) -} diff --git a/src/components/create-guild/CreateGuildStepper.tsx b/src/components/create-guild/CreateGuildStepper.tsx deleted file mode 100644 index 7062f75267..0000000000 --- a/src/components/create-guild/CreateGuildStepper.tsx +++ /dev/null @@ -1,228 +0,0 @@ -import { - Center, - Collapse, - Icon, - Stack, - Step, - StepIcon, - StepIndicator, - StepNumber, - StepSeparator, - StepStatus, - StepTitle, - Stepper, - StepperProps, - Text, - useBreakpointValue, - useColorModeValue, - useDisclosure, -} from "@chakra-ui/react" -import SummonMembers from "components/[guild]/Onboarding/components/SummonMembers" -import Card from "components/common/Card" -import { CaretDown } from "phosphor-react" -import { Fragment } from "react" -import BasicInfo from "./BasicInfo" -import ChooseTemplate from "./ChooseTemplate" -import CreateGuildIndex from "./CreateGuildIndex" - -export const STEPS: { - title: string - label?: string[] | JSX.Element[] - description?: string[] - content?: JSX.Element - progress?: number[] -}[] = [ - { - title: "Set rewards", - label: [ - "Connect platforms below that you build your community around. We’ll generate templates for your guild based on this", - ], - content: , - progress: [0], - }, - { - title: "Customize guild", - label: [], - progress: [25], - }, - { - title: "Choose template", - description: ["1/2", "2/2"], - label: [ - - Your guild consists of - - {` roles `} - - that the members can satisfy the - - {` requirements `} - - of to gain access to their - - {` rewards`} - - . Choose some defaults to get you started! - , - Choose rewards for the selected roles!, - ], - content: , - progress: [50, 66], - }, - { - title: "Edit roles", - label: [ - "Your guild is created, and you’re already in! Edit & add roles as you want", - ], - }, - { - title: "Finish", - label: [], - }, -] - -const CreateGuildStepper = ({ - color, - textColor, - activeStep, - stepPart, - setActiveStep, - enableGoingBack = true, - ...rest -}) => { - const { isOpen, onToggle } = useDisclosure() - - const cardBgColor = useColorModeValue("gray.50", "blackAlpha.300") - const orientation = useBreakpointValue({ - base: "vertical", - md: "horizontal", - }) - const StepWrapperComponent = useBreakpointValue({ - base: Collapse, - md: Fragment, - }) - const shouldPassCollapseProps = useBreakpointValue({ - base: true, - md: false, - }) - - return ( - - - {STEPS.map((step, index) => ( - - { - if (enableGoingBack && activeStep > index) { - setActiveStep(index) - } - }} - {...{ - cursor: - activeStep === index || (enableGoingBack && activeStep > index) - ? "pointer" - : "not-allowed", - alignItems: "center", - }} - > - index ? `${color} !important` : undefined, - borderColor: activeStep === index ? `${color} !important` : "none", - }} - > - } - incomplete={} - active={} - /> - - - - {step.title} - - {activeStep === index && ( - - {step.description?.[stepPart]} - - )} - - {activeStep === index && ( -
- -
- )} -
- - -
- ))} -
- {STEPS[activeStep].label && ( - - {STEPS[activeStep].label?.[stepPart]} - - )} -
- ) -} - -export default CreateGuildStepper diff --git a/src/components/create-guild/Description.tsx b/src/components/create-guild/Description.tsx index 1e647eba4a..71e7a6e553 100644 --- a/src/components/create-guild/Description.tsx +++ b/src/components/create-guild/Description.tsx @@ -1,9 +1,9 @@ import { FormControl, FormLabel, Textarea } from "@chakra-ui/react" +import { EditGuildForm } from "components/[guild]/EditGuild/EditGuildDrawer" import { useFormContext } from "react-hook-form" -import { GuildFormType } from "types" const Description = ({ isDisabled = false, ...rest }): JSX.Element => { - const { register } = useFormContext() + const { register } = useFormContext() return ( diff --git a/src/components/create-guild/GuildCreationProgress/GuildCreationProgress.tsx b/src/components/create-guild/GuildCreationProgress/GuildCreationProgress.tsx deleted file mode 100644 index f396de4865..0000000000 --- a/src/components/create-guild/GuildCreationProgress/GuildCreationProgress.tsx +++ /dev/null @@ -1,60 +0,0 @@ -import { Button, HStack, Progress, Text, Tooltip } from "@chakra-ui/react" -import FloatingFooter from "components/common/FloatingFooter" -import { atom, useAtomValue } from "jotai" -import { PropsWithChildren } from "react" -import GuildLottieProgress from "./components/GuildLottieProgress" - -type Props = { - next: () => void - prev?: () => void - progress: number - isDisabled?: boolean -} - -export const ContinueBtnTooltipLabelAtom = atom("") - -const GuildCreationProgress = ({ - next, - progress, - isDisabled, - children, -}: PropsWithChildren): JSX.Element => { - const progressText = `${progress}%` - - const continueBtnTooltipLabel = useAtomValue(ContinueBtnTooltipLabelAtom) - - return ( - - - - - - Guild {progressText} completed - - - {children ?? ( - - - - )} - - div": { - transitionProperty: "width", - }, - }} - /> - - ) -} - -export default GuildCreationProgress diff --git a/src/components/create-guild/GuildCreationProgress/components/GuildLottieProgress.tsx b/src/components/create-guild/GuildCreationProgress/components/GuildLottieProgress.tsx deleted file mode 100644 index c31604a32b..0000000000 --- a/src/components/create-guild/GuildCreationProgress/components/GuildLottieProgress.tsx +++ /dev/null @@ -1,80 +0,0 @@ -import { Box } from "@chakra-ui/react" -import { - DotLottiePlayer, - PlayerEvents, - type DotLottieCommonPlayer, -} from "@dotlottie/react-player" -import { memo, useEffect, useRef, useState } from "react" - -type Props = { - progress: number -} - -const progressToLottieState = (stepsProgress: number) => { - if (!stepsProgress) return 0 - if (stepsProgress <= 20) return 10 - if (stepsProgress <= 40) return 14 - if (stepsProgress <= 50) return 18 - if (stepsProgress <= 75) return 20 - else return 35 -} - -const GuildLottieProgress = memo(({ progress }: Props) => { - const lottiePlayerBg = useRef(null) - const [isLottiePlayerReady, setIsLottiePlayerReady] = useState(false) - const [player, setPlayer] = useState() - const prevProgress = useRef(null) - - const logoSize = 24 - - useEffect(() => { - if (!isLottiePlayerReady || !progress) return - - player.playSegments( - [ - progressToLottieState(prevProgress.current ?? 0), - progressToLottieState(progress), - ], - true - ) - prevProgress.current = progress - }, [isLottiePlayerReady, progress, player]) - - return ( - - - { - if (event === PlayerEvents.Ready) { - lottiePlayerBg.current.seek(52) - setIsLottiePlayerReady(true) - } - }} - src="/logo.lottie" - style={{ - marginBottom: 24, - height: logoSize, - width: logoSize, - }} - /> - - - { - setPlayer(instance) - }} - /> - - - ) -}) - -export default GuildLottieProgress diff --git a/src/components/create-guild/GuildCreationProgress/index.ts b/src/components/create-guild/GuildCreationProgress/index.ts deleted file mode 100644 index 4218758e30..0000000000 --- a/src/components/create-guild/GuildCreationProgress/index.ts +++ /dev/null @@ -1,3 +0,0 @@ -import GuildCreationProgress from "./GuildCreationProgress" - -export default GuildCreationProgress diff --git a/src/components/create-guild/IconSelector/IconSelector.tsx b/src/components/create-guild/IconSelector/IconSelector.tsx index d503cdc9dd..3c327438df 100644 --- a/src/components/create-guild/IconSelector/IconSelector.tsx +++ b/src/components/create-guild/IconSelector/IconSelector.tsx @@ -1,7 +1,9 @@ import { Box, + ChakraProps, FormControl, FormLabel, + Icon, IconButton, Img, ModalBody, @@ -16,6 +18,7 @@ import { TabPanels, Tabs, Text, + useColorMode, useColorModeValue, useDisclosure, useRadioGroup, @@ -24,9 +27,10 @@ import LogicDivider from "components/[guild]/LogicDivider" import GuildLogo from "components/common/GuildLogo" import { Modal } from "components/common/Modal" import { Uploader } from "hooks/usePinata/usePinata" -import React, { useEffect } from "react" +import { Image } from "phosphor-react" +import React, { ComponentProps, useEffect } from "react" import { useController, useFormContext } from "react-hook-form" -import { GuildFormType } from "types" +import { CreateGuildFormType } from "../CreateGuildForm" import PhotoUploader from "./components/PhotoUploader" import SelectorButton from "./components/SelectorButton" import icons from "./icons.json" @@ -36,11 +40,23 @@ type Props = { isDisabled?: boolean minW?: number minH?: number + onGeneratedBlobChange?: ComponentProps< + typeof PhotoUploader + >["onGeneratedBlobChange"] + boxSize?: ChakraProps["boxSize"] + iconSize?: ChakraProps["boxSize"] } -const IconSelector = ({ uploader, isDisabled, minW, minH }: Props) => { +const IconSelector = ({ + uploader, + isDisabled, + minW, + minH, + onGeneratedBlobChange, + boxSize = 12, +}: Props) => { const { isOpen, onOpen, onClose } = useDisclosure() - const { control } = useFormContext() + const { control } = useFormContext() const { field } = useController({ control, @@ -60,7 +76,7 @@ const IconSelector = ({ uploader, isDisabled, minW, minH }: Props) => { const group = getRootProps() useEffect(() => { - const svg = field.value?.split("/").pop().split(".")[0] + const svg = field.value?.split("/").pop()?.split(".")[0] icons.map((category, i) => { if (category.icons.includes(Number(svg))) { setTabIndex(i) @@ -68,12 +84,14 @@ const IconSelector = ({ uploader, isDisabled, minW, minH }: Props) => { }) }, [field.value]) + const { colorMode } = useColorMode() + const iconButtonBgColor = useColorModeValue("gray.700", "blackAlpha.300") const iconButtonHoverBgColor = useColorModeValue("gray.600", "blackAlpha.200") const iconButtonActiveBgColor = useColorModeValue("gray.500", "blackAlpha.100") const tabBgColor = useColorModeValue("gray.100", "gray.600") - const guildLogoSxProp = useColorModeValue({ filter: "invert(0.75)" }, null) + const guildLogoSxProp = useColorModeValue({ filter: "invert(0.75)" }, {}) return ( <> @@ -81,16 +99,26 @@ const IconSelector = ({ uploader, isDisabled, minW, minH }: Props) => { autoFocus onClick={onOpen} rounded="full" - boxSize={12} + boxSize={boxSize} flexShrink={0} colorScheme="gray" - icon={} + icon={ + field.value ? ( + + ) : ( + + ) + } aria-label="Guild logo" variant="outline" borderWidth={1} - bg={iconButtonBgColor} - _hover={{ bg: iconButtonHoverBgColor }} - _active={{ bg: iconButtonActiveBgColor }} + {...(field.value || colorMode === "dark" + ? { + bg: iconButtonBgColor, + _hover: { bg: iconButtonHoverBgColor }, + _active: { bg: iconButtonActiveBgColor }, + } + : {})} isDisabled={isDisabled} /> {!isDisabled && ( @@ -105,6 +133,7 @@ const IconSelector = ({ uploader, isDisabled, minW, minH }: Props) => { closeModal={onClose} minW={minW} minH={minH} + onGeneratedBlobChange={onGeneratedBlobChange} /> @@ -134,7 +163,7 @@ const IconSelector = ({ uploader, isDisabled, minW, minH }: Props) => { {icons.map((tab, index) => ( diff --git a/src/components/create-guild/IconSelector/components/PhotoUploader.tsx b/src/components/create-guild/IconSelector/components/PhotoUploader.tsx index c48d183965..bd3b46373c 100644 --- a/src/components/create-guild/IconSelector/components/PhotoUploader.tsx +++ b/src/components/create-guild/IconSelector/components/PhotoUploader.tsx @@ -13,6 +13,7 @@ type Props = { closeModal?: () => void minW?: number minH?: number + onGeneratedBlobChange?: (objectURL: string) => void } type FileWithWidthandHeight = File & { width: number; height: number } @@ -60,6 +61,7 @@ const PhotoUploader = ({ closeModal, minW, minH, + onGeneratedBlobChange, }: Props): JSX.Element => { const { setValue } = useFormContext() const imageUrl = useWatch({ name: "imageUrl" }) @@ -103,7 +105,9 @@ const PhotoUploader = ({ ), onDrop: (accepted) => { if (accepted.length > 0) { - setValue("imageUrl", URL.createObjectURL(accepted[0])) + const generatedBlob = URL.createObjectURL(accepted[0]) + onGeneratedBlobChange?.(generatedBlob) + setValue("imageUrl", generatedBlob) closeModal?.() onUpload({ data: [accepted[0]] }) } diff --git a/src/components/create-guild/MultiPlatformGrid/MultiPlatformGrid.tsx b/src/components/create-guild/MultiPlatformGrid/MultiPlatformGrid.tsx deleted file mode 100644 index dcaaf0722b..0000000000 --- a/src/components/create-guild/MultiPlatformGrid/MultiPlatformGrid.tsx +++ /dev/null @@ -1,59 +0,0 @@ -import { SimpleGrid, Stack } from "@chakra-ui/react" -import rewards from "platforms/rewards" -import { useFormContext, useWatch } from "react-hook-form" -import { GuildFormType, PlatformName } from "types" -import MultiPlatformSelectButton from "./components/MultiPlatformSelectButton" - -type Props = { - onSelection: (platform: PlatformName) => void -} - -const MultiPlatformsGrid = ({ onSelection }: Props) => { - const platformsData: Array = [ - "DISCORD", - "TWITTER", - "TELEGRAM", - "GOOGLE", - "GITHUB", - "CONTRACT_CALL", - ] - const { control } = useFormContext() - const guildPlatforms = useWatch({ - name: "guildPlatforms", - control, - }) - const twitterLink = useWatch({ - name: "socialLinks.TWITTER", - control, - }) - - return ( - - - {platformsData.map((platform) => ( - guildPlatform.platformName === platform - )?.platformGuildData.name - } - icon={rewards[platform].icon} - imageUrl={rewards[platform].imageUrl} - onSelection={onSelection} - /> - ))} - - - ) -} - -export default MultiPlatformsGrid diff --git a/src/components/create-guild/MultiPlatformGrid/components/CreateGuildContractCall.tsx b/src/components/create-guild/MultiPlatformGrid/components/CreateGuildContractCall.tsx deleted file mode 100644 index f7266de4ed..0000000000 --- a/src/components/create-guild/MultiPlatformGrid/components/CreateGuildContractCall.tsx +++ /dev/null @@ -1,49 +0,0 @@ -import { - Modal, - ModalBody, - ModalCloseButton, - ModalContent, - ModalHeader, - ModalOverlay, -} from "@chakra-ui/react" -import CreateNftForm from "components/[guild]/RolePlatforms/components/AddRoleRewardModal/components/AddContractCallPanel/components/CreateNftForm" -import { useFieldArray, useFormContext } from "react-hook-form" - -type Props = { - isOpen: boolean - onClose: () => void -} - -const CreateGuildContractCall = ({ isOpen, onClose }: Props): JSX.Element => { - const { control } = useFormContext() - const { append } = useFieldArray({ - control, - name: "guildPlatforms", - }) - - return ( - - - - Create NFT - - - { - append(newGuildPlatform.guildPlatform) - onClose() - }} - /> - - - - ) -} - -export default CreateGuildContractCall diff --git a/src/components/create-guild/MultiPlatformGrid/components/CreateGuildDiscord.tsx b/src/components/create-guild/MultiPlatformGrid/components/CreateGuildDiscord.tsx deleted file mode 100644 index 604cdff972..0000000000 --- a/src/components/create-guild/MultiPlatformGrid/components/CreateGuildDiscord.tsx +++ /dev/null @@ -1,76 +0,0 @@ -import { - Box, - Modal, - ModalBody, - ModalCloseButton, - ModalContent, - ModalHeader, - ModalOverlay, - Text, -} from "@chakra-ui/react" -import DiscordGuildSetup from "components/common/DiscordGuildSetup" -import PermissionAlert from "components/common/DiscordGuildSetup/components/PermissionAlert" -import { useFieldArray, useFormContext } from "react-hook-form" -import { GuildFormType, PlatformGuildData, PlatformType } from "types" - -type Props = { - isOpen: boolean - onClose: () => void -} - -const CreateGuildDiscord = ({ isOpen, onClose }: Props): JSX.Element => { - const { control } = useFormContext() - const { append } = useFieldArray({ - control, - name: "guildPlatforms", - }) - - return ( - - - - Connect to Discord - - - - Adding the bot and creating the Guild won't change anything on your - server - - - - { - append({ - platformName: "DISCORD", - platformGuildId: selected?.id, - platformId: PlatformType.DISCORD, - platformGuildData: { - name: selected?.name, - imageUrl: selected?.img, - } as PlatformGuildData["DISCORD"], - }) - onClose() - }} - /> - - - - - ) -} - -export default CreateGuildDiscord diff --git a/src/components/create-guild/MultiPlatformGrid/components/CreateGuildGithub.tsx b/src/components/create-guild/MultiPlatformGrid/components/CreateGuildGithub.tsx deleted file mode 100644 index 00c05d6cdf..0000000000 --- a/src/components/create-guild/MultiPlatformGrid/components/CreateGuildGithub.tsx +++ /dev/null @@ -1,57 +0,0 @@ -import { - Modal, - ModalBody, - ModalCloseButton, - ModalContent, - ModalHeader, - ModalOverlay, -} from "@chakra-ui/react" -import GitHubGuildSetup from "components/common/GitHubGuildSetup" -import { useFieldArray, useFormContext } from "react-hook-form" -import { GuildFormType, PlatformType } from "types" - -type Props = { - isOpen: boolean - onClose: () => void -} - -const CreateGuildGithub = ({ isOpen, onClose }: Props): JSX.Element => { - const { control } = useFormContext() - const { append } = useFieldArray({ - control, - name: "guildPlatforms", - }) - - return ( - - - - Add Repositories - - - { - append({ - platformName: "GITHUB", - platformGuildId: newSelectedRepo, - platformId: PlatformType.GITHUB, - platformGuildData: { - name: newSelectedRepo, - } as any, // TODO for later: define the PlatformGuildData types properly - }) - onClose() - }} - /> - - - - ) -} - -export default CreateGuildGithub diff --git a/src/components/create-guild/MultiPlatformGrid/components/CreateGuildGoogle.tsx b/src/components/create-guild/MultiPlatformGrid/components/CreateGuildGoogle.tsx deleted file mode 100644 index f2717de0dc..0000000000 --- a/src/components/create-guild/MultiPlatformGrid/components/CreateGuildGoogle.tsx +++ /dev/null @@ -1,110 +0,0 @@ -import { - Button, - Modal, - ModalBody, - ModalCloseButton, - ModalContent, - ModalFooter, - ModalHeader, - ModalOverlay, -} from "@chakra-ui/react" -import GoogleGuildSetup from "components/common/GoogleGuildSetup" -import { - FormProvider, - useFieldArray, - useForm, - useFormContext, - useWatch, -} from "react-hook-form" -import { GuildFormType, PlatformType } from "types" -import getRandomInt from "utils/getRandomInt" - -type Props = { - isOpen: boolean - onClose: () => void -} - -const CreateGuildGoogle = ({ isOpen, onClose }: Props): JSX.Element => { - const methods = useFormContext() - const googleMethods = useForm() - const { append } = useFieldArray({ - control: methods.control, - name: "guildPlatforms", - }) - - const permission = useWatch({ - control: googleMethods.control, - name: "permission", - }) - - const googleData = useWatch({ - control: googleMethods.control, - name: "googleData", - }) - - return ( - - - - Add Google files - - - - - - - - - - - - ) -} - -export default CreateGuildGoogle diff --git a/src/components/create-guild/MultiPlatformGrid/components/CreateGuildSecretText.tsx b/src/components/create-guild/MultiPlatformGrid/components/CreateGuildSecretText.tsx deleted file mode 100644 index e7343f706d..0000000000 --- a/src/components/create-guild/MultiPlatformGrid/components/CreateGuildSecretText.tsx +++ /dev/null @@ -1,87 +0,0 @@ -import { - Button, - Modal, - ModalBody, - ModalCloseButton, - ModalContent, - ModalFooter, - ModalHeader, - ModalOverlay, -} from "@chakra-ui/react" -import useUser from "components/[guild]/hooks/useUser" -import SecretTextDataForm, { - SecretTextRewardForm, -} from "platforms/SecretText/SecretTextDataForm" -import { - FormProvider, - useFieldArray, - useForm, - useFormContext, - useWatch, -} from "react-hook-form" -import { GuildFormType, PlatformType } from "types" - -type Props = { - isOpen: boolean - onClose: () => void -} - -const CreateGuildSecretText = ({ isOpen, onClose }: Props) => { - const { id: userId } = useUser() - - const { control } = useFormContext() - const { append } = useFieldArray({ - control, - name: "guildPlatforms", - }) - - const methods = useForm({ mode: "all" }) - - const name = useWatch({ control: methods.control, name: "name" }) - const text = useWatch({ control: methods.control, name: "text" }) - const imageUrl = useWatch({ control: methods.control, name: "imageUrl" }) - - return ( - - - - {" "} - Add Secret - - - - - - - - - - - - ) -} -export default CreateGuildSecretText diff --git a/src/components/create-guild/MultiPlatformGrid/components/CreateGuildTelegram.tsx b/src/components/create-guild/MultiPlatformGrid/components/CreateGuildTelegram.tsx deleted file mode 100644 index ffcc9f8359..0000000000 --- a/src/components/create-guild/MultiPlatformGrid/components/CreateGuildTelegram.tsx +++ /dev/null @@ -1,92 +0,0 @@ -import { - Button, - Modal, - ModalBody, - ModalCloseButton, - ModalContent, - ModalFooter, - ModalHeader, - ModalOverlay, -} from "@chakra-ui/react" -import DynamicDevTool from "components/create-guild/DynamicDevTool" -import TelegramGroup from "components/create-guild/TelegramGroup" -import useIsTGBotIn from "components/create-guild/TelegramGroup/hooks/useIsTGBotIn" -import { modalSizeForPlatform } from "platforms/rewards" -import { - FormProvider, - useFieldArray, - useForm, - useFormContext, - useWatch, -} from "react-hook-form" -import { GuildFormType, PlatformType } from "types" - -type Props = { - isOpen: boolean - onClose: () => void -} - -const CreateGuildTelegram = ({ isOpen, onClose }: Props): JSX.Element => { - const methods = useFormContext() - const telegramMethods = useForm({ - defaultValues: { telegramGroupId: "", name: "", imageUrl: undefined }, - }) - const { append } = useFieldArray({ - control: methods.control, - name: "guildPlatforms", - }) - - const guildPlatformId = useWatch({ - control: telegramMethods.control, - name: "telegramGroupId", - }) - - const { - data: { ok, groupName, groupIcon }, - } = useIsTGBotIn(guildPlatformId, { refreshInterval: 5000 }) - - return ( - - - - {" "} - Add Telegram - - - - - - - - - - - - - ) -} - -export default CreateGuildTelegram diff --git a/src/components/create-guild/MultiPlatformGrid/components/CreateGuildTwitter.tsx b/src/components/create-guild/MultiPlatformGrid/components/CreateGuildTwitter.tsx deleted file mode 100644 index c100bd91f1..0000000000 --- a/src/components/create-guild/MultiPlatformGrid/components/CreateGuildTwitter.tsx +++ /dev/null @@ -1,62 +0,0 @@ -import { - Button, - Modal, - ModalBody, - ModalCloseButton, - ModalContent, - ModalFooter, - ModalHeader, - ModalOverlay, -} from "@chakra-ui/react" -import TwitterUrlInput from "components/create-guild/BasicInfo/components/TwitterUrlInput" -import { FormProvider, useForm, useFormContext, useWatch } from "react-hook-form" -import { GuildFormType } from "types" - -type Props = { - isOpen: boolean - onClose: () => void -} - -const CreateGuildTwitter = ({ isOpen, onClose }: Props) => { - const methods = useFormContext() - const methodsTwitter = useForm<{ twitterUrl: string }>({ mode: "all" }) - - const link = useWatch({ - control: methodsTwitter.control, - name: "twitterUrl", - }) - - return ( - - - - Add X link - - - - - - - - - - - - ) -} - -export default CreateGuildTwitter diff --git a/src/components/create-guild/MultiPlatformGrid/components/CreateGuildUniqueText.tsx b/src/components/create-guild/MultiPlatformGrid/components/CreateGuildUniqueText.tsx deleted file mode 100644 index be6b7e12ae..0000000000 --- a/src/components/create-guild/MultiPlatformGrid/components/CreateGuildUniqueText.tsx +++ /dev/null @@ -1,62 +0,0 @@ -import { Button, Modal, ModalContent, ModalOverlay } from "@chakra-ui/react" -import useUser from "components/[guild]/hooks/useUser" -import { useCreateGuildContext } from "components/create-guild/CreateGuildContext" -import UniqueTextDataForm, { - UniqueTextRewardForm, -} from "platforms/UniqueText/UniqueTextDataForm" -import { FormProvider, useForm, useFormContext, useWatch } from "react-hook-form" -import { GuildFormType } from "types" - -type Props = { - isOpen: boolean - onClose: () => void -} - -const CreateGuildUniqueText = ({ isOpen, onClose }: Props) => { - const { id: userId } = useUser() - - const { nextStep } = useCreateGuildContext() - - const { setValue } = useFormContext() - const methods = useForm({ mode: "all" }) - - const name = useWatch({ control: methods.control, name: "name" }) - const texts = useWatch({ control: methods.control, name: "texts" }) - const imageUrl = useWatch({ control: methods.control, name: "imageUrl" }) - - return ( - - - - - - - - - - ) -} -export default CreateGuildUniqueText diff --git a/src/components/create-guild/MultiPlatformGrid/components/MultiPlatformSelectButton.tsx b/src/components/create-guild/MultiPlatformGrid/components/MultiPlatformSelectButton.tsx deleted file mode 100644 index 8a11f6a1e8..0000000000 --- a/src/components/create-guild/MultiPlatformGrid/components/MultiPlatformSelectButton.tsx +++ /dev/null @@ -1,243 +0,0 @@ -import { - Circle, - Heading, - HStack, - Icon, - Text, - Tooltip, - useColorModeValue, - useDisclosure, - VStack, -} from "@chakra-ui/react" -import useUser from "components/[guild]/hooks/useUser" -import useConnectPlatform from "components/[guild]/JoinModal/hooks/useConnectPlatform" -import { usePostHogContext } from "components/_app/PostHogProvider" -import { walletSelectorModalAtom } from "components/_app/Web3ConnectionManager/components/WalletSelectorModal" -import useWeb3ConnectionManager from "components/_app/Web3ConnectionManager/hooks/useWeb3ConnectionManager" -import DisplayCard from "components/common/DisplayCard" -import CreateGuildContractCall from "components/create-guild/MultiPlatformGrid/components/CreateGuildContractCall" -import CreateGuildDiscord from "components/create-guild/MultiPlatformGrid/components/CreateGuildDiscord" -import CreateGuildGithub from "components/create-guild/MultiPlatformGrid/components/CreateGuildGithub" -import CreateGuildGoogle from "components/create-guild/MultiPlatformGrid/components/CreateGuildGoogle" -import CreateGuildSecretText from "components/create-guild/MultiPlatformGrid/components/CreateGuildSecretText" -import CreateGuildTelegram from "components/create-guild/MultiPlatformGrid/components/CreateGuildTelegram" -import CreateGuildTwitter from "components/create-guild/MultiPlatformGrid/components/CreateGuildTwitter" -import CreateGuildUniqueText from "components/create-guild/MultiPlatformGrid/components/CreateGuildUniqueText" -import { useSetAtom } from "jotai" -import Image from "next/image" -import { CheckCircle, IconProps } from "phosphor-react" -import rewards from "platforms/rewards" -import { ComponentType, RefAttributes } from "react" -import { useFormContext, useWatch } from "react-hook-form" -import { GuildFormType, PlatformName, Rest } from "types" - -export type PlatformHookType = ({ - platform, - onSelection, -}: { - platform: PlatformName - onSelection: (platform: PlatformName) => void -}) => { - onClick: () => void - isLoading: boolean - loadingText: string - rightIcon: ComponentType> -} - -const createGuildPlatformComponents: Record< - Exclude< - PlatformName, - | "POAP" - | "TWITTER_V1" - | "EMAIL" - | "POLYGON_ID" - | "POINTS" - | "FORM" - | "GATHER_TOWN" - | "ERC20" - | "FARCASTER" - >, - (props: { isOpen: boolean; onClose: () => void }) => JSX.Element -> = { - DISCORD: CreateGuildDiscord, - TELEGRAM: CreateGuildTelegram, - GOOGLE: CreateGuildGoogle, - GITHUB: CreateGuildGithub, - CONTRACT_CALL: CreateGuildContractCall, - TEXT: CreateGuildSecretText, - TWITTER: CreateGuildTwitter, - UNIQUE_TEXT: CreateGuildUniqueText, -} - -type Props = { - platform: PlatformName - hook?: PlatformHookType - title: string - description?: string - imageUrl?: string - icon?: ComponentType> - onSelection: (platform: PlatformName) => void -} & Rest - -const MultiPlatformSelectButton = ({ - platform, - title, - description, - imageUrl, - icon, - onSelection, - ...rest -}: Props) => { - const { isWeb3Connected } = useWeb3ConnectionManager() - const setIsWalletSelectorModalOpen = useSetAtom(walletSelectorModalAtom) - const methods = useFormContext() - const { setValue } = useFormContext() - const { isOpen, onClose, onOpen } = useDisclosure() - const user = useUser() - const { captureEvent } = usePostHogContext() - - const { onConnect, isLoading, loadingText } = useConnectPlatform( - platform, - () => { - onOpen() - onSelection(platform) - }, - false, - "creation" - ) - - const guildPlatforms = useWatch({ name: "guildPlatforms" }) - const twitterLink = useWatch({ name: "socialLinks.TWITTER" }) - const socialLinks = useWatch({ name: "socialLinks" }) - - const removePlatform = (platformName: PlatformName) => { - methods.setValue( - "guildPlatforms", - guildPlatforms.filter( - (guildPlatform) => guildPlatform.platformName !== platformName - ) - ) - } - - const isTwitter = platform === "TWITTER" - const isPlatformConnected = - !rewards[platform].isPlatform || - user.platformUsers?.some( - ({ platformName, platformUserData }) => - platformName === platform && !platformUserData?.readonly - ) || - isTwitter - - const circleBgColor = useColorModeValue("gray.700", "gray.600") - - const isAdded = - (isTwitter && twitterLink) || - guildPlatforms.find((platfomAdded) => platform === platfomAdded.platformName) - - const PlatformModal = createGuildPlatformComponents[platform] - - return ( - <> - - setIsWalletSelectorModalOpen(true) - : isPlatformConnected - ? isAdded - ? () => { - if (isTwitter) { - // eslint-disable-next-line @typescript-eslint/no-unused-vars - const { TWITTER, ...socialsWithoutTwitter } = socialLinks - const hasNoSocialLinks = - Object.keys(socialsWithoutTwitter).length <= 0 - - setValue( - "socialLinks", - hasNoSocialLinks ? undefined : socialsWithoutTwitter - ) - } else { - removePlatform(platform) - if (platform === "DISCORD") { - captureEvent("[discord setup] remove selected server") - } - captureEvent("guild creation flow > platform removed", { - platform, - }) - } - } - : () => { - onOpen() - onSelection(platform) - } - : onConnect - } - h="auto" - py={6} - px={5} - {...rest} - data-test={`${platform}-select-button${ - isPlatformConnected ? "-connected" : "" - }`} - > - - {imageUrl ? ( - - Guild logo - - ) : ( - - - - )} - - - {title} - - {description && ( - - {(isLoading && `${loadingText}...`) || description} - - )} - - {isAdded && ( - - )} - - - - - { - onClose() - captureEvent("guild creation flow > platform added", { platform }) - }} - /> - - ) -} - -export default MultiPlatformSelectButton diff --git a/src/components/create-guild/MultiPlatformGrid/index.ts b/src/components/create-guild/MultiPlatformGrid/index.ts deleted file mode 100644 index a40e8f124f..0000000000 --- a/src/components/create-guild/MultiPlatformGrid/index.ts +++ /dev/null @@ -1,3 +0,0 @@ -import MultiPlatformsGrid from "./MultiPlatformGrid" - -export default MultiPlatformsGrid diff --git a/src/components/create-guild/Requirements/SetRequirements.tsx b/src/components/create-guild/Requirements/SetRequirements.tsx index d2c812ed76..113039d5ce 100644 --- a/src/components/create-guild/Requirements/SetRequirements.tsx +++ b/src/components/create-guild/Requirements/SetRequirements.tsx @@ -1,4 +1,5 @@ import { ChakraProps, Collapse, Stack, Wrap } from "@chakra-ui/react" +import { Schemas } from "@guildxyz/types" import LogicDivider from "components/[guild]/LogicDivider" import CardMotionWrapper from "components/common/CardMotionWrapper" import { SectionTitle } from "components/common/Section" @@ -7,7 +8,7 @@ import useToast from "hooks/useToast" import { useFormContext, useWatch } from "react-hook-form" import { RequirementType } from "requirements" import FreeRequirement from "requirements/Free/FreeRequirement" -import { GuildFormType, Requirement, RolePlatform } from "types" +import { Requirement, RolePlatform } from "types" import AddRequirement from "./components/AddRequirement" import BalancyCounterWithPopover from "./components/BalancyCounter" import LogicFormControl from "./components/LogicFormControl" @@ -20,7 +21,7 @@ type Props = { } const SetRequirements = ({ titleSize = undefined }: Props): JSX.Element => { - const methods = useFormContext() + const methods = useFormContext() const { getValues } = methods const logic = useWatch({ name: "logic" }) const { requirements, append, remove, update, freeEntry } = @@ -64,13 +65,14 @@ const SetRequirements = ({ titleSize = undefined }: Props): JSX.Element => { ) : ( requirements.map((req, i) => { - const type: RequirementType = getValues(`requirements.${i}.type`) + const type = getValues(`requirements.${i}.type`) return ( { if (isProviderReq(req)) { diff --git a/src/components/create-guild/Requirements/components/LogicPicker.tsx b/src/components/create-guild/Requirements/components/LogicPicker.tsx deleted file mode 100644 index ebdc9a268f..0000000000 --- a/src/components/create-guild/Requirements/components/LogicPicker.tsx +++ /dev/null @@ -1,58 +0,0 @@ -import { Divider, HStack, Select, useColorMode } from "@chakra-ui/react" -import { useController, useFormContext } from "react-hook-form" -import { GuildFormType } from "types" - -// size prop so the select width can be dynamic -const options = [ - { - value: "AND", - size: "68px", - }, - { - value: "OR", - size: "60px", - }, -] - -const LogicPicker = () => { - const { colorMode } = useColorMode() - const { control } = useFormContext() - - const { field } = useController({ - control, - name: "logic", - defaultValue: "OR", - }) - - return ( - - - - - - ) -} - -export default LogicPicker diff --git a/src/components/create-guild/hooks/useCreateGuild.tsx b/src/components/create-guild/hooks/useCreateGuild.tsx index 03a518bf20..41d32d2ad5 100644 --- a/src/components/create-guild/hooks/useCreateGuild.tsx +++ b/src/components/create-guild/hooks/useCreateGuild.tsx @@ -1,16 +1,18 @@ +import { Schemas } from "@guildxyz/types" import processConnectorError from "components/[guild]/JoinModal/utils/processConnectorError" import { usePostHogContext } from "components/_app/PostHogProvider" import useJsConfetti from "components/create-guild/hooks/useJsConfetti" import { useYourGuilds } from "components/explorer/YourGuilds" -import useCustomPosthogEvents from "hooks/useCustomPosthogEvents" import useMatchMutate from "hooks/useMatchMutate" import useShowErrorToast from "hooks/useShowErrorToast" import { SignedValidation, useSubmitWithSign } from "hooks/useSubmit" import useToast from "hooks/useToast" import { useRouter } from "next/router" -import { Guild, GuildBase, PlatformType } from "types" +import { Guild, GuildBase } from "types" import fetcher from "utils/fetcher" -import replacer from "utils/guildJsonReplacer" +import getRandomInt from "utils/getRandomInt" +import slugify from "utils/slugify" +import { CreateGuildFormType } from "../CreateGuildForm" const useCreateGuild = ({ onError, @@ -20,7 +22,6 @@ const useCreateGuild = ({ onSuccess?: () => void } = {}) => { const { captureEvent } = usePostHogContext() - const { rewardCreated } = useCustomPosthogEvents() const { mutate: mutateYourGuilds } = useYourGuilds() const matchMutate = useMatchMutate() @@ -44,24 +45,12 @@ const useCreateGuild = ({ onSuccess: (response_) => { triggerConfetti() - captureEvent("guild creation flow > guild successfully created", { + captureEvent("Created guild", { $set: { createdGuild: true, }, }) - if (response_.guildPlatforms?.length > 0) { - response_.guildPlatforms.forEach((guildPlatform) => { - rewardCreated(guildPlatform.platformId, response_?.urlName) - }) - } - - if (response_.guildPlatforms?.[0]?.platformId === PlatformType.CONTRACT_CALL) { - captureEvent("Created NFT reward", { - hook: "useCreateGuild", - }) - } - mutateYourGuilds((prev) => mutateGuildsCache(prev, response_), { revalidate: false, }) @@ -83,8 +72,27 @@ const useCreateGuild = ({ return { ...useSubmitResponse, - onSubmit: (data) => - useSubmitResponse.onSubmit(JSON.parse(JSON.stringify(data, replacer))), + /** + * Temporarily creating a default Member role, later the users will be able to + * pick from Guild Templates + */ + onSubmit: (data: CreateGuildFormType) => + useSubmitResponse.onSubmit({ + ...data, + urlName: slugify(data.name), + imageUrl: data.imageUrl || `/guildLogos/${getRandomInt(286)}.svg`, + roles: [ + { + name: "Member", + imageUrl: `/guildLogos/${getRandomInt(286)}.svg`, + requirements: [ + { + type: "FREE", + }, + ], + }, + ], + } satisfies Schemas["GuildCreationPayload"]), } } diff --git a/src/components/create-guild/hooks/useSetImageAndNameFromPlatformData.ts b/src/components/create-guild/hooks/useSetImageAndNameFromPlatformData.ts deleted file mode 100644 index 8ba75fb19d..0000000000 --- a/src/components/create-guild/hooks/useSetImageAndNameFromPlatformData.ts +++ /dev/null @@ -1,68 +0,0 @@ -import Color from "color" -import ColorThief from "colorthief/dist/color-thief.mjs" -import { Uploader } from "hooks/usePinata/usePinata" -import { useEffect } from "react" -import { useFormContext, useFormState } from "react-hook-form" -import getRandomInt from "utils/getRandomInt" -import slugify from "utils/slugify" - -const useSetImageAndNameFromPlatformData = ( - platformImage: string, - platformName: string, - onUpload?: Uploader["onUpload"] -) => { - const { setValue } = useFormContext() - const { touchedFields } = useFormState() - - useEffect(() => { - if (!(platformName?.length > 0) || !!touchedFields.name || !onUpload) return - - setValue("name", platformName) - setValue("urlName", slugify(platformName)) - - // TODO: check the usePinata hook, onUpload changed too many times and that's why this useEffect was buggy - // eslint-disable-next-line react-hooks/exhaustive-deps - }, [platformName, touchedFields.name, setValue]) - - useEffect(() => { - if (!onUpload) return - - if (!(platformImage?.length > 0)) { - setValue("imageUrl", `/guildLogos/${getRandomInt(286)}.svg`) - return - } - - setValue("imageUrl", platformImage) - ;(async () => setValue("theme.color", await getColorByImage(platformImage)))() - - fetch(platformImage) - .then((response) => response.blob()) - .then((blob) => - onUpload({ - data: [new File([blob], `${platformName}.png`, { type: "image/png" })], - }) - ) - - // TODO: check the usePinata hook, onUpload changed too many times and that's why this useEffect was buggy - // eslint-disable-next-line react-hooks/exhaustive-deps - }, [platformImage, setValue, platformName]) -} - -const getColorByImage = (imageUrl) => - new Promise((resolve, _) => { - const colorThief = new ColorThief() - - const imgEl = document.createElement("img") - imgEl.src = imageUrl - imgEl.width = 64 - imgEl.height = 64 - imgEl.crossOrigin = "anonymous" - - imgEl.addEventListener("load", () => { - const dominantRgbColor = colorThief.getColor(imgEl) - const dominantHexColor = Color.rgb(dominantRgbColor).hex() - resolve(dominantHexColor) - }) - }) - -export default useSetImageAndNameFromPlatformData diff --git a/src/components/create-guild/templates.ts b/src/components/create-guild/templates.ts deleted file mode 100644 index ecadc94d7d..0000000000 --- a/src/components/create-guild/templates.ts +++ /dev/null @@ -1,228 +0,0 @@ -import { RoleFormType, Visibility } from "types" -import getRandomInt from "utils/getRandomInt" - -export const TEMPLATES: Array = [ - { - name: "Member", - visibility: Visibility.PUBLIC, - - logic: "AND", - imageUrl: `/guildLogos/${getRandomInt(286)}.svg`, - requirements: [ - { - type: "FREE", - }, - ], - }, - { - name: "Not a robot", - visibility: Visibility.PUBLIC, - - logic: "AND", - imageUrl: `/guildLogos/${getRandomInt(286)}.svg`, - requirements: [ - { - type: "CAPTCHA", - data: {}, - }, - ], - }, - { - name: "Socialite", - description: "", - visibility: Visibility.PUBLIC, - logic: "OR", - imageUrl: `/guildLogos/${getRandomInt(286)}.svg`, - requirements: [ - { - type: "TWITTER_FOLLOWER_COUNT", - data: { - minAmount: 50, - }, - }, - { - type: "FARCASTER_TOTAL_FOLLOWERS", - data: { - min: 10, - }, - }, - { - type: "LENS_TOTAL_FOLLOWERS", - data: { - min: 10, - }, - }, - ], - }, - { - name: "Developer", - description: "", - visibility: Visibility.PUBLIC, - logic: "OR", - imageUrl: `/guildLogos/${getRandomInt(286)}.svg`, - requirements: [ - { - type: "COVALENT_CONTRACT_DEPLOY_RELATIVE", - chain: "ETHEREUM", - data: { - txCount: 1, - timestamps: { minAmount: 31536000000 }, - }, - }, - { - type: "COVALENT_CONTRACT_DEPLOY_RELATIVE", - chain: "BASE_MAINNET", - data: { - txCount: 1, - timestamps: { minAmount: 31536000000 }, - }, - }, - { - type: "COVALENT_CONTRACT_DEPLOY_RELATIVE", - chain: "OPTIMISM", - data: { - txCount: 1, - timestamps: { minAmount: 31536000000 }, - }, - }, - { - type: "COVALENT_CONTRACT_DEPLOY_RELATIVE", - chain: "ARBITRUM", - data: { - txCount: 1, - timestamps: { minAmount: 31536000000 }, - }, - }, - { - type: "COVALENT_CONTRACT_DEPLOY_RELATIVE", - chain: "POLYGON", - data: { - txCount: 1, - timestamps: { minAmount: 31536000000 }, - }, - }, - ], - }, - - { - name: "Onchain Citizen", - description: "", - visibility: Visibility.PUBLIC, - logic: "OR", - imageUrl: `/guildLogos/${getRandomInt(286)}.svg`, - requirements: [ - { - type: "COVALENT_TX_COUNT_RELATIVE", - chain: "ETHEREUM", - data: { - txCount: 1, - timestamps: { minAmount: 31536000000 }, - }, - }, - { - type: "COVALENT_TX_COUNT_RELATIVE", - chain: "BASE_MAINNET", - data: { - txCount: 3, - timestamps: { minAmount: 31536000000 }, - }, - }, - { - type: "COVALENT_TX_COUNT_RELATIVE", - chain: "OPTIMISM", - data: { - txCount: 3, - timestamps: { minAmount: 31536000000 }, - }, - }, - { - type: "COVALENT_TX_COUNT_RELATIVE", - chain: "ARBITRUM", - data: { - txCount: 3, - timestamps: { minAmount: 31536000000 }, - }, - }, - { - type: "COVALENT_TX_COUNT_RELATIVE", - chain: "POLYGON", - data: { - txCount: 3, - timestamps: { minAmount: 31536000000 }, - }, - }, - ], - }, - { - name: "Discord Fellow", - description: "", - visibility: Visibility.PUBLIC, - logic: "AND", - imageUrl: `/guildLogos/${getRandomInt(286)}.svg`, - requirements: [ - { - type: "DISCORD_JOIN_FROM_NOW", - data: { - memberSince: 15724800000, - }, - }, - ], - }, - { - name: "Sybil Resistant", - description: "", - visibility: Visibility.PUBLIC, - logic: "ANY_OF", - anyOfNum: 3, - imageUrl: `/guildLogos/${getRandomInt(286)}.svg`, - requirements: [ - { - type: "EMAIL_VERIFIED", - }, - { - data: { - schemaId: - "0xf8b05c79f090979bf4a80270aba232dff11a10d9ca55c4f88de95317970f0de9", - attester: "0x357458739F90461b99789350868CD7CF330Dd7EE", - }, - - type: "COINBASE_EAS_ATTESTED_BY", - chain: "BASE_MAINNET", - }, - { - data: { minAmount: 100 }, - type: "GUILD_ADMIN", - chain: "ETHEREUM", - }, - { - type: "GITCOIN_PASS", - chain: "ETHEREUM", - }, - { - data: { maxAmount: 2592000000, query: "" }, - type: "POLYGON_ID_BASIC", - chain: "POLYGON", - }, - { - type: "FARCASTER_PROFILE", - - chain: "ETHEREUM", - }, - { - data: { minAmount: 3 }, - - type: "SNAPSHOT_VOTES", - chain: "ETHEREUM", - }, - { - data: { minAmount: 10 }, - type: "YUP", - chain: "ETHEREUM", - }, - { - type: "SOUND_ARTIST", - chain: "ETHEREUM", - }, - ], - }, -] diff --git a/src/pages/[guild]/index.tsx b/src/pages/[guild]/index.tsx index 7197ba9903..e602d41dff 100644 --- a/src/pages/[guild]/index.tsx +++ b/src/pages/[guild]/index.tsx @@ -64,7 +64,6 @@ const DynamicAddRewardAndCampaign = dynamic( const DynamicMembersExporter = dynamic( () => import("components/[guild]/Members/components/MembersExporter") ) -const DynamicOnboarding = dynamic(() => import("components/[guild]/Onboarding")) const DynamicActiveStatusUpdates = dynamic( () => import("components/[guild]/ActiveStatusUpdates") ) @@ -89,7 +88,6 @@ const GuildPage = (): JSX.Element => { memberCount, roles, isLoading, - onboardingComplete, socialLinks, tags, featureFlags, @@ -108,7 +106,6 @@ const GuildPage = (): JSX.Element => { const { textColor, localThemeColor, localBackgroundImage } = useThemeContext() - const showOnboarding = isAdmin && !onboardingComplete const accessedGuildPlatforms = useAccessedGuildPlatforms() useStayConnectedToast(() => { @@ -175,30 +172,25 @@ const GuildPage = (): JSX.Element => { } imageUrl={imageUrl} background={localThemeColor} - backgroundOffset={showOnboarding ? 70 : undefined} backgroundImage={localBackgroundImage} action={isAdmin && isDetailed && } backButton={} > - {showOnboarding ? ( - - ) : ( - - {isMember && !isAdmin && } - {!isMember ? ( - - ) : !isAdmin ? ( - - ) : ( - - )} -
- } - /> - )} + + {isMember && !isAdmin && } + {!isMember ? ( + + ) : !isAdmin ? ( + + ) : ( + + )} + + } + /> @@ -217,7 +209,6 @@ const GuildPage = (): JSX.Element => { > - {/* we'll remove Members section completely, just keeping it for admins for now because of the Members exporter */} {isAdmin && ( <> diff --git a/src/pages/create-guild.tsx b/src/pages/create-guild.tsx index 3f36f70c57..ee74200dbf 100644 --- a/src/pages/create-guild.tsx +++ b/src/pages/create-guild.tsx @@ -1,79 +1,89 @@ +import { Box, useColorModeValue } from "@chakra-ui/react" import { ThemeProvider } from "components/[guild]/ThemeContext" +import ClientOnly from "components/common/ClientOnly" import { Layout } from "components/common/Layout" -import { CreateGuildProvider } from "components/create-guild/CreateGuildContext" -import { CreateGuildMainSection } from "components/create-guild/CreateGuildMainSection" -import { useWatch } from "react-hook-form" -import { useThemeContext } from "components/[guild]/ThemeContext" -import GuildLogo from "components/common/GuildLogo" +import CreateGuildForm, { + CreateGuildFormType, +} from "components/create-guild/CreateGuildForm" import DynamicDevTool from "components/create-guild/DynamicDevTool" -import { useFormContext } from "react-hook-form" -import { GuildFormType } from "types" +import svgToTinyDataUri from "mini-svg-data-uri" +import { FormProvider, useForm } from "react-hook-form" -function CreateGuildHead() { - const name = useWatch({ name: "name" }) - const imageUrl = useWatch({ name: "imageUrl" }) +const CreateGuildPage = (): JSX.Element => { + const methods = useForm({ + mode: "all", + defaultValues: { + name: "", + imageUrl: "", + contacts: [ + { + type: "EMAIL", + contact: "", + }, + ], + }, + }) - return -} - -function CreateGuildBackground() { - const { localThemeColor, localBackgroundImage } = useThemeContext() - const themeColor = useWatch({ name: "theme.color" }) - const color = localThemeColor !== themeColor ? themeColor : localThemeColor - - return ( - + const bgColor = useColorModeValue("var(--chakra-colors-gray-800)", "#1d1d1f") + const bgOpacity = useColorModeValue(0.06, 0.06) + const pageBgColor = useColorModeValue( + "var(--chakra-colors-gray-100)", + "var(--chakra-colors-gray-800)" ) -} - -function CreateGuildHeadline() { - const name = useWatch({ name: "name" }) - const { textColor } = useThemeContext() - const imageUrl = useWatch({ name: "imageUrl" }) + const bgPatternColor = useColorModeValue("#c5c5ca", "#52525b") return ( - - ) - } - /> + <> + + ` + )}")`} + bgPosition="top 16px left 0px" + minH="100vh" + > + + + + + + + + + + + + + + + + ) } -function CreateGuildDynamicDevTool() { - const { control } = useFormContext() - return -} - -const CreateGuildPage = (): JSX.Element => ( - <> - - - - - - - - - - - -) - const CreateGuildPageWrapper = (): JSX.Element => ( - - - - - + + + ) export default CreateGuildPageWrapper diff --git a/src/types.ts b/src/types.ts index 4cf89b8bbc..dbe663491c 100644 --- a/src/types.ts +++ b/src/types.ts @@ -648,34 +648,6 @@ type RoleFormType = Partial< } & { name: string } > -type GuildFormType = Partial< - Pick< - Guild, - | "id" - | "urlName" - | "name" - | "imageUrl" - | "description" - | "theme" - | "contacts" - | "featureFlags" - | "tags" - | "eventSources" - > -> & { - guildPlatforms?: (Partial & { platformName: string })[] - roles?: Array - logic?: Logic - requirements?: Requirement[] - socialLinks?: Record - admins?: Array<{ - address: string - id?: number - isOwner?: boolean - }> - eventSources?: Record -} - type Group = { id: number urlName: string @@ -833,7 +805,6 @@ export type { Guild, GuildAdmin, GuildBase, - GuildFormType, GuildPinMetadata, GuildPlatform, GuildPlatformWithOptionalId, diff --git a/src/utils/getColorByImage.ts b/src/utils/getColorByImage.ts new file mode 100644 index 0000000000..da0a6500b8 --- /dev/null +++ b/src/utils/getColorByImage.ts @@ -0,0 +1,21 @@ +import Color from "color" +import ColorThief from "colorthief/dist/color-thief.mjs" + +const getColorByImage = (imageUrl: string) => + new Promise((resolve, _) => { + const colorThief = new ColorThief() + + const imgEl = document.createElement("img") + imgEl.src = imageUrl + imgEl.width = 64 + imgEl.height = 64 + imgEl.crossOrigin = "anonymous" + + imgEl.addEventListener("load", () => { + const dominantRgbColor = colorThief.getColor(imgEl) + const dominantHexColor = Color.rgb(dominantRgbColor).hex() + resolve(dominantHexColor) + }) + }) + +export default getColorByImage From 9f7874afc512afce0bbf8c934c26a7c9f0c0265b Mon Sep 17 00:00:00 2001 From: BrickheadJohnny Date: Tue, 25 Jun 2024 17:55:53 +0200 Subject: [PATCH 16/41] fix(env): remove unused `COINBASE_PAY_API_KEY` env var --- .env.example | 1 - src/env.js | 2 -- 2 files changed, 3 deletions(-) diff --git a/.env.example b/.env.example index 44f1329665..9e2515f1d9 100644 --- a/.env.example +++ b/.env.example @@ -2,7 +2,6 @@ ALCHEMY_KEY="" ARBITRUM_ALCHEMY_KEY="" BALANCY_TOKEN="" BASE_ALCHEMY_KEY="" -COINBASE_PAY_API_KEY="" CYPRESS_RECORD_KEY="" EDGE_CONFIG="" GOERLI_ALCHEMY_KEY="" diff --git a/src/env.js b/src/env.js index cff3208db5..2fa8be8a43 100644 --- a/src/env.js +++ b/src/env.js @@ -35,7 +35,6 @@ export const env = createEnv({ PINATA_ADMIN_SECRET: z.string(), // Third-party - COINBASE_PAY_API_KEY: z.string(), NOOX_KEY: z.string(), OPENSEA_API_KEY: z.string(), SOUND_API_KEY: z.string(), @@ -125,7 +124,6 @@ export const env = createEnv({ PINATA_ADMIN_KEY: process.env.PINATA_ADMIN_KEY, PINATA_ADMIN_SECRET: process.env.PINATA_ADMIN_SECRET, - COINBASE_PAY_API_KEY: process.env.COINBASE_PAY_API_KEY, NOOX_KEY: process.env.NOOX_KEY, OPENSEA_API_KEY: process.env.OPENSEA_API_KEY, SOUND_API_KEY: process.env.SOUND_API_KEY, From ebf07afeeb21bdbcadcfd269d7b1ec7b9f20eb1d Mon Sep 17 00:00:00 2001 From: BrickheadJohnny Date: Tue, 25 Jun 2024 22:21:00 +0200 Subject: [PATCH 17/41] fix(Collect NFT): use env vars safely --- .../[guild]/collect/[chain]/[address].tsx | 17 +++++++++++--- .../api/nft/collectors/[chain]/[address].ts | 22 +++++-------------- 2 files changed, 19 insertions(+), 20 deletions(-) diff --git a/src/pages/[guild]/collect/[chain]/[address].tsx b/src/pages/[guild]/collect/[chain]/[address].tsx index e4397fe1ac..59c6894248 100644 --- a/src/pages/[guild]/collect/[chain]/[address].tsx +++ b/src/pages/[guild]/collect/[chain]/[address].tsx @@ -1,4 +1,3 @@ -import { env } from "env" import { Box, Divider, @@ -9,6 +8,7 @@ import { Stack, useBreakpointValue, } from "@chakra-ui/react" +import { ContractCallSupportedChain } from "components/[guild]/RolePlatforms/components/AddRoleRewardModal/components/AddContractCallPanel/components/CreateNftForm/hooks/useCreateNft" import { ThemeProvider } from "components/[guild]/ThemeContext" import CollectNft from "components/[guild]/collect/components/CollectNft" import { CollectNftProvider } from "components/[guild]/collect/components/CollectNftContext" @@ -30,11 +30,11 @@ import useGuildPlatform from "components/[guild]/hooks/useGuildPlatform" import useWeb3ConnectionManager from "components/_app/Web3ConnectionManager/hooks/useWeb3ConnectionManager" import Layout from "components/common/Layout" import LinkPreviewHead from "components/common/LinkPreviewHead" +import { env } from "env" import { AnimatePresence } from "framer-motion" import { GetStaticPaths } from "next" import dynamic from "next/dynamic" import { - alchemyApiUrl, validateNftAddress, validateNftChain, } from "pages/api/nft/collectors/[chain]/[address]" @@ -66,6 +66,15 @@ const DynamicEditNFTDescriptionModalButton = dynamic( { ssr: false } ) +export const topCollectorsSupportedChains = [ + "POLYGON", + "BASE_MAINNET", + "ETHEREUM", + "OPTIMISM", + "ARBITRUM", + "SEPOLIA", +] as const satisfies ContractCallSupportedChain[] + const CollectNftPageContent = ({ chain, address, @@ -165,7 +174,9 @@ const CollectNftPageContent = ({
- {!!alchemyApiUrl[chain] && ( + {!!topCollectorsSupportedChains.includes( + chain as (typeof topCollectorsSupportedChains)[number] + ) && ( <> diff --git a/src/pages/api/nft/collectors/[chain]/[address].ts b/src/pages/api/nft/collectors/[chain]/[address].ts index 0245e998d5..8b62e9993a 100644 --- a/src/pages/api/nft/collectors/[chain]/[address].ts +++ b/src/pages/api/nft/collectors/[chain]/[address].ts @@ -1,6 +1,6 @@ -import { ContractCallSupportedChain } from "components/[guild]/RolePlatforms/components/AddRoleRewardModal/components/AddContractCallPanel/components/CreateNftForm/hooks/useCreateNft" import { env } from "env" import { NextApiHandler } from "next" +import { topCollectorsSupportedChains } from "pages/[guild]/collect/[chain]/[address]" import { OneOf } from "types" import fetcher from "utils/fetcher" import { ADDRESS_REGEX } from "utils/guildCheckout/constants" @@ -22,27 +22,15 @@ export type TopCollectorsResponse = OneOf< { error: string } > -export const alchemyApiUrl: Record = { +export const alchemyApiUrl: Record< + (typeof topCollectorsSupportedChains)[number], + string +> = { POLYGON: `https://polygon-mainnet.g.alchemy.com/nft/v3/${env.POLYGON_ALCHEMY_KEY}/getOwnersForContract`, BASE_MAINNET: `https://base-mainnet.g.alchemy.com/nft/v3/${env.BASE_ALCHEMY_KEY}/getOwnersForContract`, ETHEREUM: `https://eth-mainnet.g.alchemy.com/nft/v3/${env.MAINNET_ALCHEMY_KEY}/getOwnersForContract`, OPTIMISM: `https://opt-mainnet.g.alchemy.com/nft/v3/${env.OPTIMISM_ALCHEMY_KEY}/getOwnersForContract`, - BSC: "", - CRONOS: "", - MANTLE: "", - ZKSYNC_ERA: "", - LINEA: "", - CYBER: "", ARBITRUM: `https://arb-mainnet.g.alchemy.com/nft/v3/${env.ARBITRUM_ALCHEMY_KEY}/getOwnersForContract`, - SCROLL: "", - TAIKO: "", - BLAST_MAINNET: "", - X1: "", - CORE_DAO: "", - METIS: "", - NEON_EVM: "", - POLYGON_ZKEVM: "", - ZETACHAIN: "", SEPOLIA: `https://eth-sepolia.g.alchemy.com/nft/v3/${env.SEPOLIA_ALCHEMY_KEY}/getOwnersForContract`, } From ee3a68219c2c4e643a68508125b26cd630b61875 Mon Sep 17 00:00:00 2001 From: valid Date: Wed, 26 Jun 2024 00:12:33 +0200 Subject: [PATCH 18/41] feat(forms): show responses count (#1319) * feat: show responses count in AccessHub form cards * feat: show responses count on responses page --- .../CreateFormModal/hooks/useCreateForm.ts | 2 +- src/components/[guild]/forms/FormTabs.tsx | 19 ++++++++++++++++--- src/components/[guild]/hooks/useGuildForms.ts | 2 +- .../[guild]/forms/[formId]/responses.tsx | 2 +- src/platforms/Forms/hooks/useEditForm.tsx | 5 +++-- src/platforms/Forms/useFormCardProps.tsx | 8 +++++++- 6 files changed, 29 insertions(+), 9 deletions(-) diff --git a/src/components/[guild]/CreateFormModal/hooks/useCreateForm.ts b/src/components/[guild]/CreateFormModal/hooks/useCreateForm.ts index 6ecdbe5dd0..28c2dbb9a2 100644 --- a/src/components/[guild]/CreateFormModal/hooks/useCreateForm.ts +++ b/src/components/[guild]/CreateFormModal/hooks/useCreateForm.ts @@ -13,7 +13,7 @@ const useCreateForm = (onSuccess?: (createdForm: Schemas["Form"]) => void) => { const toast = useToast() const showErrorToast = useShowErrorToast() - return useSubmitWithSign( + return useSubmitWithSign( (signedValidation: SignedValidation) => fetcher(`/v2/guilds/${id}/forms`, signedValidation), { diff --git a/src/components/[guild]/forms/FormTabs.tsx b/src/components/[guild]/forms/FormTabs.tsx index 2decf64fa7..a9a2d703bb 100644 --- a/src/components/[guild]/forms/FormTabs.tsx +++ b/src/components/[guild]/forms/FormTabs.tsx @@ -1,10 +1,23 @@ -import { Tooltip } from "@chakra-ui/react" +import { HStack, TabsProps, Tag, Text, Tooltip } from "@chakra-ui/react" import Tabs from "../Tabs" import TabButton from "../Tabs/components/TabButton" -const FormResponsesTabs = ({ ...rest }): JSX.Element => ( +type Props = { + submissionCount: number | undefined +} & Omit + +const FormResponsesTabs = ({ submissionCount, ...rest }: Props): JSX.Element => ( - Individual + + + Responses + + {new Intl.NumberFormat("en", { notation: "compact" }).format( + submissionCount ?? 0 + )} + + + Summary diff --git a/src/components/[guild]/hooks/useGuildForms.ts b/src/components/[guild]/hooks/useGuildForms.ts index 183bfcdfa2..9bf7e594f9 100644 --- a/src/components/[guild]/hooks/useGuildForms.ts +++ b/src/components/[guild]/hooks/useGuildForms.ts @@ -4,7 +4,7 @@ import useGuild from "./useGuild" const useGuildForms = () => { const { id } = useGuild() - return useSWRWithOptionalAuth( + return useSWRWithOptionalAuth<(Schemas["Form"] & { submissionCount: number })[]>( id ? `/v2/guilds/${id}/forms` : null, undefined, false, diff --git a/src/pages/[guild]/forms/[formId]/responses.tsx b/src/pages/[guild]/forms/[formId]/responses.tsx index 79196e9183..f2748a3ebf 100644 --- a/src/pages/[guild]/forms/[formId]/responses.tsx +++ b/src/pages/[guild]/forms/[formId]/responses.tsx @@ -38,7 +38,7 @@ const FormResponses = (): JSX.Element => { imageUrl={imageUrl} showFooter={false} > - + {isLoading ? ( diff --git a/src/platforms/Forms/hooks/useEditForm.tsx b/src/platforms/Forms/hooks/useEditForm.tsx index 07d7227ec0..adfc79e44c 100644 --- a/src/platforms/Forms/hooks/useEditForm.tsx +++ b/src/platforms/Forms/hooks/useEditForm.tsx @@ -23,7 +23,7 @@ const useEditForm = ({ ...signedValidation, }) - return useSubmitWithSign(editForm, { + return useSubmitWithSign(editForm, { onSuccess: (response) => { onSuccess?.() @@ -33,7 +33,8 @@ const useEditForm = ({ prevForms.map((form) => { if (form.id !== response.id) return form - return response + // the BE doesn't send submissionCount on the update endpoint, so we have to preserve that + return { ...response, submissionCount: form.submissionCount } }) }, { revalidate: false } diff --git a/src/platforms/Forms/useFormCardProps.tsx b/src/platforms/Forms/useFormCardProps.tsx index c15d1fd0af..1f20d57ca6 100644 --- a/src/platforms/Forms/useFormCardProps.tsx +++ b/src/platforms/Forms/useFormCardProps.tsx @@ -9,7 +9,7 @@ const useFormCardProps = (guildPlatform: GuildPlatformWithOptionalId) => { const { isAdmin } = useGuildPermission() const circleBgColor = useColorModeValue("gray.700", "blackAlpha.300") - const { form } = useGuildForm(guildPlatform.platformGuildData.formId) + const { form, isSigned } = useGuildForm(guildPlatform.platformGuildData.formId) const { userSubmission } = useUserFormSubmission(form) return { @@ -20,6 +20,12 @@ const useFormCardProps = (guildPlatform: GuildPlatformWithOptionalId) => { ), name: form?.name ?? rewards.FORM.name, + info: + isSigned && + isAdmin && + `${new Intl.NumberFormat("en", { notation: "compact" }).format( + form?.submissionCount ?? 0 + )} responses`, shouldHide: !isAdmin && !!userSubmission, } } From b8ecc8401f3740b4507b0637fbef4bb6d5acb1fa Mon Sep 17 00:00:00 2001 From: valid Date: Wed, 26 Jun 2024 00:27:29 +0200 Subject: [PATCH 19/41] chore(forms): remove custom submissionCount typing --- package-lock.json | 8 ++++---- package.json | 2 +- .../[guild]/CreateFormModal/hooks/useCreateForm.ts | 2 +- src/components/[guild]/hooks/useGuildForms.ts | 2 +- src/platforms/Forms/hooks/useEditForm.tsx | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/package-lock.json b/package-lock.json index d7a9313401..1b7e4c8233 100644 --- a/package-lock.json +++ b/package-lock.json @@ -19,7 +19,7 @@ "@emotion/styled": "^11.11.0", "@fuels/connectors": "^0.5.0", "@fuels/react": "^0.20.0", - "@guildxyz/types": "1.9.21", + "@guildxyz/types": "1.9.23", "@hcaptcha/react-hcaptcha": "^1.4.4", "@hookform/resolvers": "^3.3.4", "@lexical/code": "^0.12.0", @@ -5192,9 +5192,9 @@ } }, "node_modules/@guildxyz/types": { - "version": "1.9.21", - "resolved": "https://registry.npmjs.org/@guildxyz/types/-/types-1.9.21.tgz", - "integrity": "sha512-kmKv5RIMwwQn8ka4D4UwkZLsVcyENBk+/gfyYMm4gx2ywGqlTduENACgk1bd1E2sE1UX4vmyOHQdvZNSf+WgwQ==", + "version": "1.9.23", + "resolved": "https://registry.npmjs.org/@guildxyz/types/-/types-1.9.23.tgz", + "integrity": "sha512-fRCBcDaqr6YFpTZPY7imy8/q1I7MC8jjej3LGNkeN31wwcJmULjOAbQz43C6kff3AMizjUfX2aP2BZnSC7MXjA==", "dependencies": { "zod": "^3.22.4" } diff --git a/package.json b/package.json index c7f442419a..df80434981 100644 --- a/package.json +++ b/package.json @@ -29,7 +29,7 @@ "@emotion/styled": "^11.11.0", "@fuels/connectors": "^0.5.0", "@fuels/react": "^0.20.0", - "@guildxyz/types": "1.9.21", + "@guildxyz/types": "1.9.23", "@hcaptcha/react-hcaptcha": "^1.4.4", "@hookform/resolvers": "^3.3.4", "@lexical/code": "^0.12.0", diff --git a/src/components/[guild]/CreateFormModal/hooks/useCreateForm.ts b/src/components/[guild]/CreateFormModal/hooks/useCreateForm.ts index 28c2dbb9a2..6ecdbe5dd0 100644 --- a/src/components/[guild]/CreateFormModal/hooks/useCreateForm.ts +++ b/src/components/[guild]/CreateFormModal/hooks/useCreateForm.ts @@ -13,7 +13,7 @@ const useCreateForm = (onSuccess?: (createdForm: Schemas["Form"]) => void) => { const toast = useToast() const showErrorToast = useShowErrorToast() - return useSubmitWithSign( + return useSubmitWithSign( (signedValidation: SignedValidation) => fetcher(`/v2/guilds/${id}/forms`, signedValidation), { diff --git a/src/components/[guild]/hooks/useGuildForms.ts b/src/components/[guild]/hooks/useGuildForms.ts index 9bf7e594f9..183bfcdfa2 100644 --- a/src/components/[guild]/hooks/useGuildForms.ts +++ b/src/components/[guild]/hooks/useGuildForms.ts @@ -4,7 +4,7 @@ import useGuild from "./useGuild" const useGuildForms = () => { const { id } = useGuild() - return useSWRWithOptionalAuth<(Schemas["Form"] & { submissionCount: number })[]>( + return useSWRWithOptionalAuth( id ? `/v2/guilds/${id}/forms` : null, undefined, false, diff --git a/src/platforms/Forms/hooks/useEditForm.tsx b/src/platforms/Forms/hooks/useEditForm.tsx index adfc79e44c..7d7a7bb10b 100644 --- a/src/platforms/Forms/hooks/useEditForm.tsx +++ b/src/platforms/Forms/hooks/useEditForm.tsx @@ -23,7 +23,7 @@ const useEditForm = ({ ...signedValidation, }) - return useSubmitWithSign(editForm, { + return useSubmitWithSign(editForm, { onSuccess: (response) => { onSuccess?.() From 263eca4e2f7103effe17fdbfe2a17f4b959226c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?B=C3=A1lint=20Ferenczy?= <40574454+FBalint@users.noreply.github.com> Date: Wed, 26 Jun 2024 09:47:59 +0200 Subject: [PATCH 20/41] fix(AddDiscordPanel): remove unused platformRoleId (#1320) --- .../components/AddRoleRewardModal/components/AddDiscordPanel.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/src/components/[guild]/RolePlatforms/components/AddRoleRewardModal/components/AddDiscordPanel.tsx b/src/components/[guild]/RolePlatforms/components/AddRoleRewardModal/components/AddDiscordPanel.tsx index bfe6840197..c6602f19f0 100644 --- a/src/components/[guild]/RolePlatforms/components/AddRoleRewardModal/components/AddDiscordPanel.tsx +++ b/src/components/[guild]/RolePlatforms/components/AddRoleRewardModal/components/AddDiscordPanel.tsx @@ -24,7 +24,6 @@ const AddDiscordPanel = ({ onAdd }: AddRewardPanelProps) => { } as PlatformGuildData["DISCORD"], }, isNew: true, - platformRoleId: null, }) }} /> From e64706fc1d015a34ded26b747300a772cda6236d Mon Sep 17 00:00:00 2001 From: BrickheadJohnny Date: Wed, 26 Jun 2024 11:29:00 +0200 Subject: [PATCH 21/41] fix(GalaxyForm): define `fallbackValue` on the `ControlledSelect` component --- src/requirements/Galaxy/GalaxyForm.tsx | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/requirements/Galaxy/GalaxyForm.tsx b/src/requirements/Galaxy/GalaxyForm.tsx index fb9401437b..8088ba9a72 100644 --- a/src/requirements/Galaxy/GalaxyForm.tsx +++ b/src/requirements/Galaxy/GalaxyForm.tsx @@ -133,6 +133,9 @@ const GalaxyForm = ({ baseFieldPath, field }: RequirementFormProps): JSX.Element }} // We don't filter campaigns client side, since we already get back a filtered list from the API filterOption={() => true} + fallbackValue={mappedCampaigns.find( + (c) => c.galaxyId === selectedGalaxyId + )} noResultText={ !debouncedSearchText.length ? "Start typing..." : undefined } From 7fd80922a74be0bf73fab8e8aa2427c84b03246f Mon Sep 17 00:00:00 2001 From: BrickheadJohnny Date: Wed, 26 Jun 2024 11:41:58 +0200 Subject: [PATCH 22/41] fix(Collector): render rangeIcon conditionally --- .../components/TopCollectors/components/Collector.tsx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/components/[guild]/collect/components/TopCollectors/components/Collector.tsx b/src/components/[guild]/collect/components/TopCollectors/components/Collector.tsx index 206990423b..18b0be3ed5 100644 --- a/src/components/[guild]/collect/components/TopCollectors/components/Collector.tsx +++ b/src/components/[guild]/collect/components/TopCollectors/components/Collector.tsx @@ -39,7 +39,10 @@ const Collector = ({ address, balance }: Props): JSX.Element => { const CollectorBalance = ({ balance }) => { const ranges = useNftRanges() - const rangeIcon = ranges?.find((r) => r.min <= balance && r.max >= balance)?.icon + + const rangeIcon = + ranges?.at(-1)?.max >= 10 && + ranges?.find((r) => r.min <= balance && r.max >= balance)?.icon return ( Date: Wed, 26 Jun 2024 14:30:36 +0200 Subject: [PATCH 23/41] refactor: remove the custom `Requirement` type (#1318) * refactor: remove the custom `Requirement` type * bump the types package * add `0x${string}` casts where it's necessary * small cleanup * update package-lock * chore(AllowlistRequirement): add TODO comment about the schema * fix(SelectExistingPlatform): remove dot from visibility field name --- package-lock.json | 250 +++++++++--------- package.json | 2 +- .../components/OrderRolesModal.tsx | 3 +- .../AddAndOrderRoles/hooks/useAddRoleForm.ts | 6 +- .../AddRewardButton/AddRewardButton.tsx | 7 +- .../AddRewardButton/SelectRolePanel.tsx | 8 +- .../hooks/useCreateRequirements.ts | 10 +- .../hooks/useMutateAdditionsToRoles.ts | 39 +-- .../hooks/useSubmitAddReward.ts | 8 +- .../AddRewardButton/useCreateTokenReward.ts | 6 +- .../RequirementErrorConfigContext.tsx | 2 +- .../[guild]/Requirements/RoleRequirements.tsx | 2 +- .../components/ActivateGuildPinForm.tsx | 3 +- .../GuildCheckout/components/BuyTotal.tsx | 18 +- .../components/PaymentFeeCurrency.tsx | 4 +- .../components/PurchaseFeeAndTotal.tsx | 11 +- .../components/PurchasedRequirementInfo.tsx | 7 +- .../components/buttons/BuyAllowanceButton.tsx | 8 +- .../components/buttons/BuyButton.tsx | 12 +- .../buttons/PurchaseAllowanceButton.tsx | 8 +- .../GuildCheckout/hooks/usePayFee.ts | 12 +- .../GuildCheckout/hooks/usePurchaseAsset.ts | 2 +- .../Requirements/components/Requirement.tsx | 5 +- .../components/RequirementChainIndicator.tsx | 5 +- .../components/RequirementContext.tsx | 11 +- .../RequirementDisplayComponent.tsx | 2 +- src/components/[guild]/RoleCard/RoleCard.tsx | 7 +- .../EditRole/hooks/useEditRoleForm.ts | 5 +- .../hooks/useUpdateRolePlatformVisibility.ts | 3 +- .../components/SelectExistingPlatform.tsx | 10 +- src/components/[guild]/Roles.tsx | 9 +- .../[guild]/SetVisibility/SetVisibility.tsx | 4 +- .../components/VisibilityTag.tsx | 2 +- .../hooks/useVisibilityTooltipLabel.tsx | 6 +- .../[guild]/SetVisibility/visibilityData.tsx | 8 +- src/components/[guild]/Visibility.tsx | 4 +- .../crm/FilterByRoles/FilterByRoles.tsx | 6 +- .../components/AddHiddenRoleButton.tsx | 3 +- .../components/SetHiddenRoleRequirements.tsx | 3 +- src/components/[guild]/crm/RoleTags.tsx | 4 +- src/components/[guild]/crm/useMembers.tsx | 10 +- src/components/[guild]/messages/Message.tsx | 5 +- .../BasicInfo/components/ContactInfo.tsx | 4 +- .../components/AddRequirement.tsx | 31 +-- .../ExistingRequirementEditableCard.tsx | 10 +- .../components/RequirementEditableCard.tsx | 7 +- .../Requirements/hooks/useBalancy.ts | 3 +- .../hooks/useCreateRequirement.ts | 15 +- .../Requirements/hooks/useEditRequirement.ts | 29 +- .../hooks/useHandleRequirementState.ts | 2 +- .../create-guild/hooks/useCreateRole.tsx | 10 +- src/hooks/useSubmitTransaction.ts | 5 +- src/pages/[guild]/members.tsx | 3 +- .../SelectRoleOrSetRequirements.tsx | 4 +- .../Airdrop/AirdropRequirement.tsx | 6 +- .../Allowlist/AllowlistRequirement.tsx | 17 +- .../Farcaster/FarcasterRequirement.tsx | 12 +- src/requirements/Fuel/FuelRequirement.tsx | 13 +- src/requirements/Lens/LensRequirement.tsx | 4 +- src/requirements/Lens/hooks/useLensProfile.ts | 2 +- .../Lens/hooks/useLensProfiles.ts | 4 +- src/requirements/Mirror/MirrorRequirement.tsx | 11 +- src/requirements/Nft/NftRequirement.tsx | 17 +- .../providedValue/NftAmountProvidedValue.tsx | 16 +- .../Payment/PaymentRequirement.tsx | 4 +- .../WithdrawButton/WithdrawButton.tsx | 9 +- src/requirements/Token/TokenRequirement.tsx | 12 +- .../providedValue/TokenProvidedValue.tsx | 7 +- .../Uniswap/UniswapRequirement.tsx | 7 +- .../WalletActivityRequirement.tsx | 11 +- src/requirements/index.ts | 4 +- src/types.ts | 43 +-- src/utils/formatRelativeTimeFromNow.ts | 2 +- src/utils/mapRequirement.ts | 8 +- src/utils/preprocessRequirement.ts | 8 +- 75 files changed, 469 insertions(+), 411 deletions(-) diff --git a/package-lock.json b/package-lock.json index 1b7e4c8233..3037a660d3 100644 --- a/package-lock.json +++ b/package-lock.json @@ -19,7 +19,7 @@ "@emotion/styled": "^11.11.0", "@fuels/connectors": "^0.5.0", "@fuels/react": "^0.20.0", - "@guildxyz/types": "1.9.23", + "@guildxyz/types": "1.9.24", "@hcaptcha/react-hcaptcha": "^1.4.4", "@hookform/resolvers": "^3.3.4", "@lexical/code": "^0.12.0", @@ -4618,17 +4618,17 @@ } }, "node_modules/@floating-ui/core": { - "version": "1.6.2", - "resolved": "https://registry.npmjs.org/@floating-ui/core/-/core-1.6.2.tgz", - "integrity": "sha512-+2XpQV9LLZeanU4ZevzRnGFg2neDeKHgFLjP6YLW+tly0IvrhqT4u8enLGjLH3qeh85g19xY5rsAusfwTdn5lg==", + "version": "1.6.3", + "resolved": "https://registry.npmjs.org/@floating-ui/core/-/core-1.6.3.tgz", + "integrity": "sha512-1ZpCvYf788/ZXOhRQGFxnYQOVgeU+pi0i+d0Ow34La7qjIXETi6RNswGVKkA6KcDO8/+Ysu2E/CeUmmeEBDvTg==", "dependencies": { - "@floating-ui/utils": "^0.2.0" + "@floating-ui/utils": "^0.2.3" } }, "node_modules/@floating-ui/core/node_modules/@floating-ui/utils": { - "version": "0.2.2", - "resolved": "https://registry.npmjs.org/@floating-ui/utils/-/utils-0.2.2.tgz", - "integrity": "sha512-J4yDIIthosAsRZ5CPYP/jQvUAQtlZTTD/4suA08/FEnlxqW3sKS9iAhgsa9VYLZ6vDHn/ixJgIqRQPotoBjxIw==" + "version": "0.2.3", + "resolved": "https://registry.npmjs.org/@floating-ui/utils/-/utils-0.2.3.tgz", + "integrity": "sha512-XGndio0l5/Gvd6CLIABvsav9HHezgDFFhDfHk1bvLfr9ni8dojqLSvBbotJEjmIwNHL7vK4QzBJTdBRoB+c1ww==" }, "node_modules/@floating-ui/dom": { "version": "1.5.1", @@ -5192,9 +5192,9 @@ } }, "node_modules/@guildxyz/types": { - "version": "1.9.23", - "resolved": "https://registry.npmjs.org/@guildxyz/types/-/types-1.9.23.tgz", - "integrity": "sha512-fRCBcDaqr6YFpTZPY7imy8/q1I7MC8jjej3LGNkeN31wwcJmULjOAbQz43C6kff3AMizjUfX2aP2BZnSC7MXjA==", + "version": "1.9.24", + "resolved": "https://registry.npmjs.org/@guildxyz/types/-/types-1.9.24.tgz", + "integrity": "sha512-tNy2i/KqbXU+UwDGLijaWXEDXqGmbKeKpANpTCvQ93AVCazvrrEp+359JaDJCJVv94Mzc0mTQgow6xiHgHcLFQ==", "dependencies": { "zod": "^3.22.4" } @@ -6387,14 +6387,14 @@ } }, "node_modules/@metamask/sdk": { - "version": "0.20.5", - "resolved": "https://registry.npmjs.org/@metamask/sdk/-/sdk-0.20.5.tgz", - "integrity": "sha512-BEL3BKbb0O09QgOzvyPH5xUONl2uicS9WT1AYhZ8yR4ytz5fhyHWJzs8Q/cwgm1qIdn3eumnjXfgA6pKirWa3A==", + "version": "0.26.3", + "resolved": "https://registry.npmjs.org/@metamask/sdk/-/sdk-0.26.3.tgz", + "integrity": "sha512-DM4BFPr1BDAIhTz7/RWb3oWQRvX79TJVZH8EL/Ljp+CRY7IjCbaVwaLdyQjVd8Doyq1V7AL4N/JjXplpo2YyYg==", "dependencies": { "@metamask/onboarding": "^1.0.1", "@metamask/providers": "^15.0.0", - "@metamask/sdk-communication-layer": "0.20.5", - "@metamask/sdk-install-modal-web": "0.20.4", + "@metamask/sdk-communication-layer": "0.26.2", + "@metamask/sdk-install-modal-web": "0.26.0", "@types/dom-screen-wake-lock": "^1.0.0", "bowser": "^2.9.0", "cross-fetch": "^4.0.0", @@ -6428,9 +6428,9 @@ } }, "node_modules/@metamask/sdk-communication-layer": { - "version": "0.20.5", - "resolved": "https://registry.npmjs.org/@metamask/sdk-communication-layer/-/sdk-communication-layer-0.20.5.tgz", - "integrity": "sha512-Y3pzg1GBB7tDUCUsyhvlhxQ+h/pDrTjO2yUwjCJj2S8Nx5OtdRv/foRGfbDHkfYt6Z9ANRfivWU2U6El17B24A==", + "version": "0.26.2", + "resolved": "https://registry.npmjs.org/@metamask/sdk-communication-layer/-/sdk-communication-layer-0.26.2.tgz", + "integrity": "sha512-YMqwjhCZ4sXYAsEp1LxLrZZycBwpUeEsA4yIx48m1yW9sZ8pv3NGnbjM+F0zf29DLjyqLxJdxHJ7b5YkgtB26g==", "dependencies": { "bufferutil": "^4.0.8", "date-fns": "^2.29.3", @@ -6447,9 +6447,9 @@ } }, "node_modules/@metamask/sdk-install-modal-web": { - "version": "0.20.4", - "resolved": "https://registry.npmjs.org/@metamask/sdk-install-modal-web/-/sdk-install-modal-web-0.20.4.tgz", - "integrity": "sha512-AX3mTr0IDpS0ajV83okTaixG+2wIxTVbgvEuQgAj2Ed7PWAdiZ1aX93AVcaCgkOWhTf267z7mXCSuBDpBCje9g==", + "version": "0.26.0", + "resolved": "https://registry.npmjs.org/@metamask/sdk-install-modal-web/-/sdk-install-modal-web-0.26.0.tgz", + "integrity": "sha512-LyDQFIsWWyU0ZgZR3O9LzRqKzXcYUEGJRCNfb26IjFOquvmQosbhQV0jDNlVa8Tk2Fg4ykTPoaauANh6sVJYVQ==", "dependencies": { "qr-code-styling": "^1.6.0-rc.1" }, @@ -7513,9 +7513,9 @@ } }, "node_modules/@radix-ui/react-dialog": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/@radix-ui/react-dialog/-/react-dialog-1.1.0.tgz", - "integrity": "sha512-oiSJcsjbdC8JqbXrOuhOd7oaEaPp3x2L2zn6V7ie6SSpEjrAha/WabDX4po6laGwbhAu9DT0XxHL0DmcIXrR0A==", + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/@radix-ui/react-dialog/-/react-dialog-1.1.1.tgz", + "integrity": "sha512-zysS+iU4YP3STKNS6USvFVqI4qqx8EpiwmT5TuCApVEBca+eRCbONi4EgzfNSuVnOXvC5UPHHMjs8RXO6DH9Bg==", "dependencies": { "@radix-ui/primitive": "1.1.0", "@radix-ui/react-compose-refs": "1.1.0", @@ -7524,7 +7524,7 @@ "@radix-ui/react-focus-guards": "1.1.0", "@radix-ui/react-focus-scope": "1.1.0", "@radix-ui/react-id": "1.1.0", - "@radix-ui/react-portal": "1.1.0", + "@radix-ui/react-portal": "1.1.1", "@radix-ui/react-presence": "1.1.0", "@radix-ui/react-primitive": "2.0.0", "@radix-ui/react-slot": "1.1.0", @@ -7658,11 +7658,12 @@ } }, "node_modules/@radix-ui/react-portal": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/@radix-ui/react-portal/-/react-portal-1.1.0.tgz", - "integrity": "sha512-0tXZ5O6qAVvuN9SWP0X+zadHf9hzHiMf/vxOU+kXO+fbtS8lS57MXa6EmikDxk9s/Bmkk80+dcxgbvisIyeqxg==", + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/@radix-ui/react-portal/-/react-portal-1.1.1.tgz", + "integrity": "sha512-A3UtLk85UtqhzFqtoC8Q0KvR2GbXF3mtPgACSazajqq6A41mEQgo53iPzY4i6BwDxlIFqWIhiQ2G729n+2aw/g==", "dependencies": { - "@radix-ui/react-primitive": "2.0.0" + "@radix-ui/react-primitive": "2.0.0", + "@radix-ui/react-use-layout-effect": "1.1.0" }, "peerDependencies": { "@types/react": "*", @@ -9574,9 +9575,9 @@ } }, "node_modules/@rnx-kit/chromium-edge-launcher/node_modules/@types/node": { - "version": "18.19.37", - "resolved": "https://registry.npmjs.org/@types/node/-/node-18.19.37.tgz", - "integrity": "sha512-Pi53fdVMk7Ig5IfAMltQQMgtY7xLzHaEous8IQasYsdQbYK3v90FkxI3XYQCe/Qme58pqp14lXJIsFmGP8VoZQ==", + "version": "18.19.39", + "resolved": "https://registry.npmjs.org/@types/node/-/node-18.19.39.tgz", + "integrity": "sha512-nPwTRDKUctxw3di5b4TfT3I0sWDiWoPQCZjXhvdkINntwr8lcoVCKsTgnXeRubKIlfnV+eN/HYk6Jb40tbcEAQ==", "peer": true, "dependencies": { "undici-types": "~5.26.4" @@ -9740,9 +9741,9 @@ } }, "node_modules/@safe-global/safe-gateway-typescript-sdk": { - "version": "3.21.4", - "resolved": "https://registry.npmjs.org/@safe-global/safe-gateway-typescript-sdk/-/safe-gateway-typescript-sdk-3.21.4.tgz", - "integrity": "sha512-BCY+7RtCfjkGO8X6crBRqlXPqAGM/0Ki/k0PWLYxV3IGmwM6ah2qFGkpp1omWQsdILdiKWxsmIKiderAWOyLjA==", + "version": "3.21.6", + "resolved": "https://registry.npmjs.org/@safe-global/safe-gateway-typescript-sdk/-/safe-gateway-typescript-sdk-3.21.6.tgz", + "integrity": "sha512-S3OZ8Alya7N7Iie6KvVSbrp9Ev30cQZtpqvP4zkaWlWBG6W7XE3gYC/8GohmQ9E3BOYtYa1xfDupKRgSO9RfTw==", "engines": { "node": ">=16" } @@ -10289,20 +10290,20 @@ } }, "node_modules/@tanstack/query-core": { - "version": "5.45.0", - "resolved": "https://registry.npmjs.org/@tanstack/query-core/-/query-core-5.45.0.tgz", - "integrity": "sha512-RVfIZQmFUTdjhSAAblvueimfngYyfN6HlwaJUPK71PKd7yi43Vs1S/rdimmZedPWX/WGppcq/U1HOj7O7FwYxw==", + "version": "5.48.0", + "resolved": "https://registry.npmjs.org/@tanstack/query-core/-/query-core-5.48.0.tgz", + "integrity": "sha512-lZAfPPeVIqXCswE9SSbG33B6/91XOWt/Iq41bFeWb/mnHwQSIfFRbkS4bfs+WhIk9abRArF9Id2fp0Mgo+hq6Q==", "funding": { "type": "github", "url": "https://github.com/sponsors/tannerlinsley" } }, "node_modules/@tanstack/react-query": { - "version": "5.45.1", - "resolved": "https://registry.npmjs.org/@tanstack/react-query/-/react-query-5.45.1.tgz", - "integrity": "sha512-mYYfJujKg2kxmkRRjA6nn4YKG3ITsKuH22f1kteJ5IuVQqgKUgbaSQfYwVP0gBS05mhwxO03HVpD0t7BMN7WOA==", + "version": "5.48.0", + "resolved": "https://registry.npmjs.org/@tanstack/react-query/-/react-query-5.48.0.tgz", + "integrity": "sha512-GDExbjYWzvDokyRqMSWXdrPiYpp95Aig0oeMIrxTaruOJJgWiWfUP//OAaowm2RrRkGVsavSZdko/XmIrrV2Nw==", "dependencies": { - "@tanstack/query-core": "5.45.0" + "@tanstack/query-core": "5.48.0" }, "funding": { "type": "github", @@ -10332,11 +10333,11 @@ } }, "node_modules/@tanstack/react-virtual": { - "version": "3.5.1", - "resolved": "https://registry.npmjs.org/@tanstack/react-virtual/-/react-virtual-3.5.1.tgz", - "integrity": "sha512-jIsuhfgy8GqA67PdWqg73ZB2LFE+HD9hjWL1L6ifEIZVyZVAKpYmgUG4WsKQ005aEyImJmbuimPiEvc57IY0Aw==", + "version": "3.7.0", + "resolved": "https://registry.npmjs.org/@tanstack/react-virtual/-/react-virtual-3.7.0.tgz", + "integrity": "sha512-3RtOwEU1HKS4iFBoTcCrV3Szqt4KoERMhZr8v57dvnh5o70sR9GAdF+0aE/qhiOmePrKujGwAayFNJSr/8Dbqw==", "dependencies": { - "@tanstack/virtual-core": "3.5.1" + "@tanstack/virtual-core": "3.7.0" }, "funding": { "type": "github", @@ -10360,9 +10361,9 @@ } }, "node_modules/@tanstack/virtual-core": { - "version": "3.5.1", - "resolved": "https://registry.npmjs.org/@tanstack/virtual-core/-/virtual-core-3.5.1.tgz", - "integrity": "sha512-046+AUSiDru/V9pajE1du8WayvBKeCvJ2NmKPy/mR8/SbKKrqmSbj7LJBfXE+nSq4f5TBXvnCzu0kcYebI9WdQ==", + "version": "3.7.0", + "resolved": "https://registry.npmjs.org/@tanstack/virtual-core/-/virtual-core-3.7.0.tgz", + "integrity": "sha512-p0CWuqn+n8iZmsL7/l0Xg7kbyIKnHNqkEJkMDOkg4x3Ni3LohszmnJY8FPhTgG7Ad9ZFGcdKmn1R1mKUGEh9Xg==", "funding": { "type": "github", "url": "https://github.com/sponsors/tannerlinsley" @@ -10605,9 +10606,9 @@ "integrity": "sha512-nG96G3Wp6acyAgJqGasjODb+acrI7KltPiRxzHPXnP3NgI28bpQDRv53olbqGXbfcgF5aiiHmO3xpwEpS5Ld9g==" }, "node_modules/@types/node": { - "version": "20.14.6", - "resolved": "https://registry.npmjs.org/@types/node/-/node-20.14.6.tgz", - "integrity": "sha512-JbA0XIJPL1IiNnU7PFxDXyfAwcwVVrOoqyzzyQTyMeVhBzkJVMSkC1LlVsRQ2lpqiY4n6Bb9oCS6lzDKVQxbZw==", + "version": "20.14.9", + "resolved": "https://registry.npmjs.org/@types/node/-/node-20.14.9.tgz", + "integrity": "sha512-06OCtnTXtWOZBJlRApleWndH4JsRVs1pDCc8dLSQp+7PpUpX3ePdHyeNSFTeSe7FtKyQkrlPvHwJOW3SLd8Oyg==", "dependencies": { "undici-types": "~5.26.4" } @@ -11328,12 +11329,12 @@ } }, "node_modules/@wagmi/connectors": { - "version": "5.0.15", - "resolved": "https://registry.npmjs.org/@wagmi/connectors/-/connectors-5.0.15.tgz", - "integrity": "sha512-eQnsVfe1tX7g3pFPDg3sWjCdggTE+4C0z9g700h/pgUTNSJGnMRU+avTZqkewHFUkUkAhSk/tm1BZ4wfr6Wwfg==", + "version": "5.0.19", + "resolved": "https://registry.npmjs.org/@wagmi/connectors/-/connectors-5.0.19.tgz", + "integrity": "sha512-yd0pkM3I7sJuIZf1lIiwxDApaWg5ZSFiN3ociM50SkcoWDAWAKcCWWP0FbaCZ4KT+TZQJEIqBpfk6eZ9mBAddQ==", "dependencies": { "@coinbase/wallet-sdk": "4.0.3", - "@metamask/sdk": "0.20.5", + "@metamask/sdk": "0.26.3", "@safe-global/safe-apps-provider": "0.18.1", "@safe-global/safe-apps-sdk": "8.1.0", "@walletconnect/ethereum-provider": "2.13.0", @@ -11344,7 +11345,7 @@ "url": "https://github.com/sponsors/wevm" }, "peerDependencies": { - "@wagmi/core": "2.11.3", + "@wagmi/core": "2.11.5", "typescript": ">=5.0.4", "viem": "2.x" }, @@ -11355,9 +11356,9 @@ } }, "node_modules/@wagmi/core": { - "version": "2.11.3", - "resolved": "https://registry.npmjs.org/@wagmi/core/-/core-2.11.3.tgz", - "integrity": "sha512-RxjjyDDmUehAy1CBJgSGzbnsbAAbaOrGwemsTXR7ru5dak+4lQ3Swx4Ikm1aPlxjSZbNy6c/epyidnkun9qzMQ==", + "version": "2.11.5", + "resolved": "https://registry.npmjs.org/@wagmi/core/-/core-2.11.5.tgz", + "integrity": "sha512-RmtZQkNf/ozdngyDST33WLTdKQHny9SsiNmxln8G06pbnOuhO4dDhnXnfiJ8Lh9GVIfFsjlmtqzfAIo1/86dqg==", "dependencies": { "eventemitter3": "5.0.1", "mipd": "0.0.5", @@ -13030,10 +13031,9 @@ "integrity": "sha512-wjkjR4ItpkCKnlN0JNkhoLutRf1yHTaGV1qEy1Z9tzkyfJmP/2jqwcCR1cWWxM/+iFE2UJd7Ea7CNgCWwFnvFw==" }, "node_modules/abitype": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/abitype/-/abitype-1.0.3.tgz", - "integrity": "sha512-8EyPgBBHMtW56OslHWHJ4HEjU+2snjxibmwNjV2aBJp4oDfx1DcxO8sQ4jkxo/Iu6oQ79c6/ihsrBE2nBMlURg==", - "dev": true, + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/abitype/-/abitype-1.0.4.tgz", + "integrity": "sha512-UivtYZOGJGE8rsrM/N5vdRkUpqEZVmuTumfTuolm7m/6O09wprd958rx8kUBwVAAAhQDveGAgD0GJdBuR8s6tw==", "funding": { "url": "https://github.com/sponsors/wevm" }, @@ -14302,9 +14302,9 @@ } }, "node_modules/caniuse-lite": { - "version": "1.0.30001636", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001636.tgz", - "integrity": "sha512-bMg2vmr8XBsbL6Lr0UHXy/21m84FTxDLWn2FSqMd5PrlbMxwJlQnC2YWYxVgp66PZE+BBNF2jYQUBKCo1FDeZg==", + "version": "1.0.30001637", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001637.tgz", + "integrity": "sha512-1x0qRI1mD1o9e+7mBI7XtzFAP4XszbHaVWsMiGbSPLYekKTJF7K+FNk6AsXH4sUpc+qrsI3pVgf1Jdl/uGkuSQ==", "funding": [ { "type": "opencollective", @@ -16182,9 +16182,9 @@ "peer": true }, "node_modules/electron-to-chromium": { - "version": "1.4.807", - "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.807.tgz", - "integrity": "sha512-kSmJl2ZwhNf/bcIuCH/imtNOKlpkLDn2jqT5FJ+/0CXjhnFaOa9cOe9gHKKy71eM49izwuQjZhKk+lWQ1JxB7A==" + "version": "1.4.812", + "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.812.tgz", + "integrity": "sha512-7L8fC2Ey/b6SePDFKR2zHAy4mbdp1/38Yk5TsARO66W3hC5KEaeKMMHoxwtuH+jcu2AYLSn9QX04i95t6Fl1Hg==" }, "node_modules/elliptic": { "version": "6.5.4", @@ -16476,9 +16476,9 @@ } }, "node_modules/es-module-lexer": { - "version": "1.5.3", - "resolved": "https://registry.npmjs.org/es-module-lexer/-/es-module-lexer-1.5.3.tgz", - "integrity": "sha512-i1gCgmR9dCl6Vil6UKPI/trA69s08g/syhiDK9TG0Nf1RJjjFI+AzoWW7sPufzkgYAn861skuCwJa0pIIHYxvg==", + "version": "1.5.4", + "resolved": "https://registry.npmjs.org/es-module-lexer/-/es-module-lexer-1.5.4.tgz", + "integrity": "sha512-MVNK56NiMrOwitFB7cqDwq0CQutbw+0BvLshJSse0MUNU+y1FC3bUS/AQg7oUng+/wKrrki7JfmwtVHkVfPLlw==", "dev": true, "peer": true }, @@ -17722,9 +17722,9 @@ "peer": true }, "node_modules/flow-parser": { - "version": "0.238.0", - "resolved": "https://registry.npmjs.org/flow-parser/-/flow-parser-0.238.0.tgz", - "integrity": "sha512-VE7XSv1epljsIN2YeBnxCmGJihpNIAnLLu/pPOdA+Gkso7qDltJwUi6vfHjgxdBbjSdAuPGnhuOHJUQG+yYwIg==", + "version": "0.238.2", + "resolved": "https://registry.npmjs.org/flow-parser/-/flow-parser-0.238.2.tgz", + "integrity": "sha512-fs7FSnzzKF6oSzjk14JlBHt82DPchYHVsXtPi4Fkn+qrunVjWaBZY7nSO/mC9X4l9+wRah/R69DRd5NGDOrWqw==", "peer": true, "engines": { "node": ">=0.4.0" @@ -18242,9 +18242,9 @@ } }, "node_modules/glob/node_modules/minimatch": { - "version": "9.0.4", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.4.tgz", - "integrity": "sha512-KqWh+VchfxcMNRAJjj2tnsSJdNbHsVgnkBhTNrW7AjVo6OvLtxw8zfT9oLw1JSohlFzJ8jCoTgaoXvJ+kHt6fw==", + "version": "9.0.5", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.5.tgz", + "integrity": "sha512-G6T0ZX48xgozx7587koeX9Ys2NYy6Gmv//P89sEte9V9whIapMNF4idKxnW2QtCcLiTWlb/wfCabAtAFWhhBow==", "dependencies": { "brace-expansion": "^2.0.1" }, @@ -18337,9 +18337,9 @@ "dev": true }, "node_modules/graphql": { - "version": "16.8.2", - "resolved": "https://registry.npmjs.org/graphql/-/graphql-16.8.2.tgz", - "integrity": "sha512-cvVIBILwuoSyD54U4cF/UXDh5yAobhNV/tPygI4lZhgOIJQE/WLWC4waBRb4I6bDVYb3OVx3lfHbaQOEoUD5sg==", + "version": "16.9.0", + "resolved": "https://registry.npmjs.org/graphql/-/graphql-16.9.0.tgz", + "integrity": "sha512-GGTKBX4SD7Wdb8mqeDLni2oaRGYQWjWHGKPQ24ZMnUtKfcsVoiv4uX8+LJr1K6U5VW2Lu1BwJnj7uiori0YtRw==", "engines": { "node": "^12.22.0 || ^14.16.0 || ^16.0.0 || >=17.0.0" } @@ -19018,11 +19018,14 @@ } }, "node_modules/is-core-module": { - "version": "2.13.1", - "resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.13.1.tgz", - "integrity": "sha512-hHrIjvZsftOsvKSn2TRYl63zvxsgE0K+0mYMoH6gD4omR5IWB2KynivBQczo3+wF1cCkjzvptnI9Q0sPU66ilw==", + "version": "2.14.0", + "resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.14.0.tgz", + "integrity": "sha512-a5dFJih5ZLYlRtDc0dZWP7RiKr6xIKzmn/oAYCDvdLThadVgyJwlaoQPmRtMSpz+rk0OGAgIu+TcM9HUF0fk1A==", "dependencies": { - "hasown": "^2.0.0" + "hasown": "^2.0.2" + }, + "engines": { + "node": ">= 0.4" }, "funding": { "url": "https://github.com/sponsors/ljharb" @@ -26877,10 +26880,13 @@ } }, "node_modules/object-inspect": { - "version": "1.13.1", - "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.13.1.tgz", - "integrity": "sha512-5qoj1RUiKOMsCCNLV1CBiPYE10sziTsnmNxkAI/rZhiD63CF7IqdFGC/XzjWjpSgLf0LxXX3bDFIh0E18f6UhQ==", + "version": "1.13.2", + "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.13.2.tgz", + "integrity": "sha512-IRZSRuzJiynemAXPYtPe5BoI/RESNYR7TYm50MC5Mqbd3Jmw5y790sErYw3V6SryFJD64b74qQQs9wn5Bg/k3g==", "dev": true, + "engines": { + "node": ">= 0.4" + }, "funding": { "url": "https://github.com/sponsors/ljharb" } @@ -27714,12 +27720,13 @@ } }, "node_modules/posthog-js": { - "version": "1.139.5", - "resolved": "https://registry.npmjs.org/posthog-js/-/posthog-js-1.139.5.tgz", - "integrity": "sha512-awnIAefNa+x5GA481B8j8J6S2xLcvHQ7i5Osyzq1UK6QGtmAaM0ttGFU+oPjpKxo4yXeuF5R1aUo9YE67s4+vA==", + "version": "1.141.3", + "resolved": "https://registry.npmjs.org/posthog-js/-/posthog-js-1.141.3.tgz", + "integrity": "sha512-LZ+I6wJS82yX/SZVaK20V2WV4MEfB2G9fT2ZJoWlzwN5L3wsbpmjD9F2dVW818deBV3ms1w0Ho7rnlJtBGHx2g==", "dependencies": { "fflate": "^0.4.8", - "preact": "^10.19.3" + "preact": "^10.19.3", + "web-vitals": "^4.0.1" } }, "node_modules/posthog-js/node_modules/fflate": { @@ -28241,9 +28248,9 @@ } }, "node_modules/react-devtools-core": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/react-devtools-core/-/react-devtools-core-5.2.0.tgz", - "integrity": "sha512-vZK+/gvxxsieAoAyYaiRIVFxlajb7KXhgBDV7OsoMzaAE+IqGpoxusBjIgq5ibqA2IloKu0p9n7tE68z1xs18A==", + "version": "5.3.0", + "resolved": "https://registry.npmjs.org/react-devtools-core/-/react-devtools-core-5.3.0.tgz", + "integrity": "sha512-IG3T+azv48Oc5VLdHR4XdBNKNZIUOKRtx0sJMRvb++Zom/uqtx73j6u37JCsIBNIaq6vA7RPH5Bbcf/Wj53KXA==", "peer": true, "dependencies": { "shell-quote": "^1.6.1", @@ -31737,9 +31744,9 @@ "dev": true }, "node_modules/typescript": { - "version": "5.4.5", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.4.5.tgz", - "integrity": "sha512-vcI4UpRgg81oIRUFwR0WSIHKt11nJ7SAVlYNIu+QpqeyXP+gpQJy/Z4+F0aGxSE4MqwjyXvW/TzgkLAx2AGHwQ==", + "version": "5.5.2", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.5.2.tgz", + "integrity": "sha512-NcRtPEOsPFFWjobJEtfihkLCZCXZt/os3zf8nTxjVH3RvTSxjrCamJpbExGvYOF+tFHc3pA65qpdwPbzjohhew==", "devOptional": true, "bin": { "tsc": "bin/tsc", @@ -32448,9 +32455,9 @@ } }, "node_modules/viem": { - "version": "2.15.1", - "resolved": "https://registry.npmjs.org/viem/-/viem-2.15.1.tgz", - "integrity": "sha512-Vrveen3vDOJyPf8Q8TDyWePG2pTdK6IpSi4P6qlvAP+rXkAeqRvwYBy9AmGm+BeYpCETAyTT0SrCP6458XSt+w==", + "version": "2.16.2", + "resolved": "https://registry.npmjs.org/viem/-/viem-2.16.2.tgz", + "integrity": "sha512-qor3v1cJFR3jcPtcJxPbKfKURAH2agNf2IWZIaSReV6teNLERiu4Sr7kbqpkIeTAEpiDCVQwg336M+mub1m+pg==", "funding": [ { "type": "github", @@ -32463,7 +32470,7 @@ "@noble/hashes": "1.3.2", "@scure/bip32": "1.3.2", "@scure/bip39": "1.2.1", - "abitype": "1.0.0", + "abitype": "1.0.4", "isows": "1.0.4", "ws": "8.17.1" }, @@ -32523,26 +32530,6 @@ "url": "https://paulmillr.com/funding/" } }, - "node_modules/viem/node_modules/abitype": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/abitype/-/abitype-1.0.0.tgz", - "integrity": "sha512-NMeMah//6bJ56H5XRj8QCV4AwuW6hB6zqz2LnhhLdcWVQOsXki6/Pn3APeqxCma62nXIcmZWdu1DlHWS74umVQ==", - "funding": { - "url": "https://github.com/sponsors/wevm" - }, - "peerDependencies": { - "typescript": ">=5.0.4", - "zod": "^3 >=3.22.0" - }, - "peerDependenciesMeta": { - "typescript": { - "optional": true - }, - "zod": { - "optional": true - } - } - }, "node_modules/viem/node_modules/ws": { "version": "8.17.1", "resolved": "https://registry.npmjs.org/ws/-/ws-8.17.1.tgz", @@ -32579,12 +32566,12 @@ } }, "node_modules/wagmi": { - "version": "2.10.3", - "resolved": "https://registry.npmjs.org/wagmi/-/wagmi-2.10.3.tgz", - "integrity": "sha512-B1GTa2jzwStnDvunQr8LGc7BfzhC/IdZE679Lm3XlIGTfsrOua38ZnZGE627kqLu3z6WewDBytj+JjHs5GpmXQ==", + "version": "2.10.7", + "resolved": "https://registry.npmjs.org/wagmi/-/wagmi-2.10.7.tgz", + "integrity": "sha512-RYh45bpqaPbQDcRYbfaiS0b5iZrEKVCCpjyFTJx83qtbkxZBvpT6MXy1rQbfLookVCgZz0PA3aYEYX8HJPajLg==", "dependencies": { - "@wagmi/connectors": "5.0.15", - "@wagmi/core": "2.11.3", + "@wagmi/connectors": "5.0.19", + "@wagmi/core": "2.11.5", "use-sync-external-store": "1.2.0" }, "funding": { @@ -32657,6 +32644,11 @@ "defaults": "^1.0.3" } }, + "node_modules/web-vitals": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/web-vitals/-/web-vitals-4.2.0.tgz", + "integrity": "sha512-ohj72kbtVWCpKYMxcbJ+xaOBV3En76hW47j52dG+tEGG36LZQgfFw5yHl9xyjmosy3XUMn8d/GBUAy4YPM839w==" + }, "node_modules/webextension-polyfill": { "version": "0.10.0", "resolved": "https://registry.npmjs.org/webextension-polyfill/-/webextension-polyfill-0.10.0.tgz", diff --git a/package.json b/package.json index df80434981..ae3c3b66c9 100644 --- a/package.json +++ b/package.json @@ -29,7 +29,7 @@ "@emotion/styled": "^11.11.0", "@fuels/connectors": "^0.5.0", "@fuels/react": "^0.20.0", - "@guildxyz/types": "1.9.23", + "@guildxyz/types": "1.9.24", "@hcaptcha/react-hcaptcha": "^1.4.4", "@hookform/resolvers": "^3.3.4", "@lexical/code": "^0.12.0", diff --git a/src/components/[guild]/AddAndOrderRoles/components/OrderRolesModal.tsx b/src/components/[guild]/AddAndOrderRoles/components/OrderRolesModal.tsx index 088d1016af..1d98865b37 100644 --- a/src/components/[guild]/AddAndOrderRoles/components/OrderRolesModal.tsx +++ b/src/components/[guild]/AddAndOrderRoles/components/OrderRolesModal.tsx @@ -15,7 +15,6 @@ import DiscardAlert from "components/common/DiscardAlert" import { Modal } from "components/common/Modal" import { Reorder } from "framer-motion" import { useMemo, useState } from "react" -import { Visibility } from "types" import useReorderRoles from "../hooks/useReorderRoles" import DraggableRoleCard from "./DraggableRoleCard" @@ -51,7 +50,7 @@ const OrderRolesModal = ({ isOpen, onClose, finalFocusRef }): JSX.Element => { }, [relevantRoles]) const publicAndSecretRoles = sortedRoles.filter( - (role) => role.visibility !== Visibility.HIDDEN + (role) => role.visibility !== "HIDDEN" ) const defaultRoleIdsOrder = publicAndSecretRoles?.map((role) => role.id) diff --git a/src/components/[guild]/AddAndOrderRoles/hooks/useAddRoleForm.ts b/src/components/[guild]/AddAndOrderRoles/hooks/useAddRoleForm.ts index 22a3f59c8f..d7f953597b 100644 --- a/src/components/[guild]/AddAndOrderRoles/hooks/useAddRoleForm.ts +++ b/src/components/[guild]/AddAndOrderRoles/hooks/useAddRoleForm.ts @@ -1,14 +1,14 @@ import useGuild from "components/[guild]/hooks/useGuild" import { RoleToCreate } from "components/create-guild/hooks/useCreateRole" import { useForm } from "react-hook-form" -import { RoleFormType, Visibility } from "types" +import { RoleFormType } from "types" import getRandomInt from "utils/getRandomInt" const useAddRoleForm = () => { const { id } = useGuild() const defaultValues: RoleToCreate = { - guildId: id, + guildId: id as number, // Safe to cast here, since we'll have guildId by the time we call this hook name: "", description: "", logic: "AND", @@ -19,7 +19,7 @@ const useAddRoleForm = () => { ], roleType: "NEW", imageUrl: `/guildLogos/${getRandomInt(286)}.svg`, - visibility: Visibility.PUBLIC, + visibility: "PUBLIC", rolePlatforms: [], } diff --git a/src/components/[guild]/AddRewardButton/AddRewardButton.tsx b/src/components/[guild]/AddRewardButton/AddRewardButton.tsx index 2acbb35c0d..95db25146c 100644 --- a/src/components/[guild]/AddRewardButton/AddRewardButton.tsx +++ b/src/components/[guild]/AddRewardButton/AddRewardButton.tsx @@ -1,4 +1,5 @@ import { ModalOverlay, useDisclosure } from "@chakra-ui/react" +import { Schemas, Visibility } from "@guildxyz/types" import Button from "components/common/Button" import DiscardAlert from "components/common/DiscardAlert" import { Modal } from "components/common/Modal" @@ -7,7 +8,7 @@ import { atom, useAtomValue } from "jotai" import { Plus } from "phosphor-react" import rewards, { modalSizeForPlatform } from "platforms/rewards" import { FormProvider, useForm, useWatch } from "react-hook-form" -import { Requirement, RoleFormType, Visibility } from "types" +import { RoleFormType } from "types" import { AddRewardProvider, useAddRewardContext } from "../AddRewardContext" import { ClientStateRequirementHandlerProvider } from "../RequirementHandlerContext" import SelectRewardPanel from "../RolePlatforms/components/AddRoleRewardModal/SelectRewardPanel" @@ -20,7 +21,7 @@ export type AddRewardForm = { // TODO: we could simplify the form - we don't need a rolePlatforms array here, we only need one rolePlatform rolePlatforms: RoleFormType["rolePlatforms"][number][] // TODO: use proper types, e.g. name & symbol shouldn't be required on this type - requirements?: Omit[] + requirements?: Schemas["RequirementCreationPayload"][] roleIds?: number[] visibility: Visibility roleName?: string // Name for role, if new role is created with reward @@ -30,7 +31,7 @@ export const defaultValues: AddRewardForm = { rolePlatforms: [], requirements: [{ type: "FREE" }], roleIds: [], - visibility: Visibility.PUBLIC, + visibility: "PUBLIC", } export const canCloseAddRewardModalAtom = atom(true) diff --git a/src/components/[guild]/AddRewardButton/SelectRolePanel.tsx b/src/components/[guild]/AddRewardButton/SelectRolePanel.tsx index 968318bb98..22f0681810 100644 --- a/src/components/[guild]/AddRewardButton/SelectRolePanel.tsx +++ b/src/components/[guild]/AddRewardButton/SelectRolePanel.tsx @@ -11,6 +11,7 @@ import { Tooltip, useColorModeValue, } from "@chakra-ui/react" +import { Visibility } from "@guildxyz/types" import { usePostHogContext } from "components/_app/PostHogProvider" import Button from "components/common/Button" import useCreateRRR, { SubmitData } from "hooks/useCreateRRR" @@ -19,7 +20,6 @@ import SelectRoleOrSetRequirements from "platforms/components/SelectRoleOrSetReq import rewards, { CAPACITY_TIME_PLATFORMS } from "platforms/rewards" import { useState } from "react" import { useFormContext, useWatch } from "react-hook-form" -import { Visibility } from "types" import { RoleTypeToAddTo, useAddRewardContext } from "../AddRewardContext" import useGuild from "../hooks/useGuild" import { defaultValues } from "./AddRewardButton" @@ -171,17 +171,17 @@ const SelectRolePanel = ({ const changeDataToDraft = (data: SubmitData): SubmitData => { if (!data.roleIds?.length) { - return { ...data, visibility: Visibility.HIDDEN } + return { ...data, visibility: "HIDDEN" as Visibility } } const { rolePlatforms, requirements, roleIds } = data const hiddenRolePlatforms = rolePlatforms.map((rp) => ({ ...rp, - visibility: Visibility.HIDDEN, + visibility: "HIDDEN" as Visibility, })) const hiddenRequirements = requirements.map((req) => - req.type === "FREE" ? req : { ...req, visibility: Visibility.HIDDEN } + req.type === "FREE" ? req : { ...req, visibility: "HIDDEN" as Visibility } ) return { diff --git a/src/components/[guild]/AddRewardButton/hooks/useCreateRequirements.ts b/src/components/[guild]/AddRewardButton/hooks/useCreateRequirements.ts index 324d1b5043..3032eed2c8 100644 --- a/src/components/[guild]/AddRewardButton/hooks/useCreateRequirements.ts +++ b/src/components/[guild]/AddRewardButton/hooks/useCreateRequirements.ts @@ -2,8 +2,11 @@ import useGuild from "components/[guild]/hooks/useGuild" import { usePostHogContext } from "components/_app/PostHogProvider" import { RequirementIdMap } from "hooks/useCreateRRR" import useShowErrorToast from "hooks/useShowErrorToast" +import { + RequirementCreateResponseOutput, + RequirementCreationPayloadWithTempID, +} from "types" -import { Requirement } from "types" import { useFetcherWithSign } from "utils/fetcher" import preprocessRequirement from "utils/preprocessRequirement" @@ -17,7 +20,8 @@ const useCreateRequirements = () => { } const createRequirements = async ( - requirements: Partial[], + // We can assign generated IDs to requirements on our frontend, so it's safe to extend this type with an ID + requirements: RequirementCreationPayloadWithTempID[], roleIds: number[] ) => { const requirementIdMap: RequirementIdMap = {} @@ -31,7 +35,7 @@ const useCreateRequirements = () => { body: preprocessRequirement(req), }, ]) - .then((res) => { + .then((res: RequirementCreateResponseOutput) => { if (!requirementIdMap[req.id]) requirementIdMap[req.id] = {} requirementIdMap[req.id][roleId] = res.id return { status: "fulfilled", result: res } diff --git a/src/components/[guild]/AddRewardButton/hooks/useMutateAdditionsToRoles.ts b/src/components/[guild]/AddRewardButton/hooks/useMutateAdditionsToRoles.ts index 8ccb7e05a5..8c29d81555 100644 --- a/src/components/[guild]/AddRewardButton/hooks/useMutateAdditionsToRoles.ts +++ b/src/components/[guild]/AddRewardButton/hooks/useMutateAdditionsToRoles.ts @@ -1,13 +1,17 @@ -import { Schemas } from "@guildxyz/types" import useGuild from "components/[guild]/hooks/useGuild" import { unstable_serialize, useSWRConfig } from "swr" -import { GuildPlatform, Requirement, RolePlatform } from "types" +import { + Guild, + GuildPlatform, + RequirementCreateResponseOutput, + RolePlatform, +} from "types" import { CreateRolePlatformResponse } from "./useCreateRolePlatforms" const groupRequirementsByRoleId = ( roleIds: number[], - requirements: Schemas["RequirementCreateResponse"][] -): { [roleId: number]: Schemas["RequirementCreateResponse"][] } => + requirements: RequirementCreateResponseOutput[] +): { [roleId: number]: RequirementCreateResponseOutput[] } => roleIds.reduce((acc, roleId) => { acc[roleId] = requirements.filter((req) => req.roleId === roleId) return acc @@ -54,7 +58,7 @@ const useMutateAdditionsToRoles = () => { const mutateAdditionsInGuild = ( roleIds: number[], - createdRequirements: Schemas["RequirementCreateResponse"][], + createdRequirements: RequirementCreateResponseOutput[], // TODO: create a RoleRewardCreateResponse schema in our types package createdRolePlatforms: CreateRolePlatformResponse[] ) => { @@ -90,23 +94,24 @@ const useMutateAdditionsToRoles = () => { ...role, requirements: [ ...role.requirements.filter((req) => !reqIdsToDelete.includes(req.id)), - // TODO: we can remove the Requirement[] cast once we start using the Guild schema from our types package in the useGuild hook - ...(createdRequirementsOnRole as Requirement[]), + ...createdRequirementsOnRole, ], rolePlatforms: [...role.rolePlatforms, ...createdRolePlatformsOnRole], } }) // Return the updated data - return { - ...prev, - // TODO: we can remove the GuildPlatform[] cast once we start using the Guild schema from our types package in the useGuild hook - guildPlatforms: [ - ...prev.guildPlatforms, - ...(createdGuildPlatforms as GuildPlatform[]), - ], - roles: updatedRoles, - } + return !!prev + ? ({ + ...prev, + // TODO: we can remove the GuildPlatform[] cast once we start using the Guild schema from our types package in the useGuild hook + guildPlatforms: [ + ...(prev?.guildPlatforms ?? []), + ...(createdGuildPlatforms as GuildPlatform[]), + ], + roles: updatedRoles, + } satisfies Guild) + : undefined }, { revalidate: false } ) @@ -114,7 +119,7 @@ const useMutateAdditionsToRoles = () => { const mutateAdditionsToRoles = ( roleIds: number[], - createdRequirements: Schemas["RequirementCreateResponse"][], + createdRequirements: RequirementCreateResponseOutput[], // TODO: create a RoleRewardCreateResponse schema in our types package createdRolePlatforms: CreateRolePlatformResponse[] ) => { diff --git a/src/components/[guild]/AddRewardButton/hooks/useSubmitAddReward.ts b/src/components/[guild]/AddRewardButton/hooks/useSubmitAddReward.ts index 63234ac290..bf1e2486e9 100644 --- a/src/components/[guild]/AddRewardButton/hooks/useSubmitAddReward.ts +++ b/src/components/[guild]/AddRewardButton/hooks/useSubmitAddReward.ts @@ -1,3 +1,4 @@ +import { Visibility } from "@guildxyz/types" import { useAddRewardContext } from "components/[guild]/AddRewardContext" import useGuild from "components/[guild]/hooks/useGuild" import { usePostHogContext } from "components/_app/PostHogProvider" @@ -5,7 +6,7 @@ import useCreateRole from "components/create-guild/hooks/useCreateRole" import useToast from "hooks/useToast" import rewards from "platforms/rewards" import { useFormContext } from "react-hook-form" -import { PlatformType, Visibility } from "types" +import { PlatformType } from "types" import getRandomInt from "utils/getRandomInt" import { defaultValues } from "../AddRewardButton" import useCreateReqBasedTokenReward from "../useCreateTokenReward" @@ -135,8 +136,7 @@ const useSubmitAddReward = ({ } if (!data.roleIds || data?.roleIds.length === 0) { - const roleVisibility = - saveAs === "DRAFT" ? Visibility.HIDDEN : Visibility.PUBLIC + const roleVisibility: Visibility = saveAs === "DRAFT" ? "HIDDEN" : "PUBLIC" onCreateRoleSubmit({ ...data, name: data.roleName || `New ${rewards[selection].name} role`, @@ -168,7 +168,7 @@ const useSubmitAddReward = ({ ...data.rolePlatforms[0], visibility: saveAs === "DRAFT" - ? Visibility.HIDDEN + ? "HIDDEN" : roles.find((role) => role.id === +roleId).visibility, })), }) diff --git a/src/components/[guild]/AddRewardButton/useCreateTokenReward.ts b/src/components/[guild]/AddRewardButton/useCreateTokenReward.ts index a355297a2f..d32eb6e569 100644 --- a/src/components/[guild]/AddRewardButton/useCreateTokenReward.ts +++ b/src/components/[guild]/AddRewardButton/useCreateTokenReward.ts @@ -2,7 +2,7 @@ import { Schemas } from "@guildxyz/types" import { usePostHogContext } from "components/_app/PostHogProvider" import useCreateRole from "components/create-guild/hooks/useCreateRole" import useShowErrorToast from "hooks/useShowErrorToast" -import { PlatformType, Requirement, RolePlatform, Visibility } from "types" +import { PlatformType, Requirement, RolePlatform } from "types" import getRandomInt from "utils/getRandomInt" import useMembershipUpdate from "../JoinModal/hooks/useMembershipUpdate" import useGuild from "../hooks/useGuild" @@ -37,7 +37,7 @@ const getRewardSubmitData = ( platformRoleId: data.rolePlatforms[0].guildPlatform.platformGuildId || `${roleId}-${Date.now()}`, - visibility: saveAs === "DRAFT" ? Visibility.HIDDEN : Visibility.PUBLIC, + visibility: saveAs === "DRAFT" ? "HIDDEN" : "PUBLIC", }, ], }) @@ -96,7 +96,7 @@ const useCreateReqBasedTokenReward = ({ }) const createWithNewRole = async (data: CreateData, saveAs: "DRAFT" | "PUBLIC") => { - const roleVisibility = saveAs === "DRAFT" ? Visibility.HIDDEN : Visibility.PUBLIC + const roleVisibility = saveAs === "DRAFT" ? "HIDDEN" : "PUBLIC" const createdRole = await onCreateRoleSubmit({ ...data, diff --git a/src/components/[guild]/Requirements/RequirementErrorConfigContext.tsx b/src/components/[guild]/Requirements/RequirementErrorConfigContext.tsx index 4fa8b5fc5f..9dbf5128fc 100644 --- a/src/components/[guild]/Requirements/RequirementErrorConfigContext.tsx +++ b/src/components/[guild]/Requirements/RequirementErrorConfigContext.tsx @@ -5,7 +5,7 @@ type RequirementErrorConfig = Partial> const REQ_ERROR_CONFIG: RequirementErrorConfig = { GALAXY: "Galxe API error, please try again later", - TWITTER: "X API error, please try again later", + // TWITTER: "X API error, please try again later", } const RequirementErrorConfigContext = createContext({}) diff --git a/src/components/[guild]/Requirements/RoleRequirements.tsx b/src/components/[guild]/Requirements/RoleRequirements.tsx index 1d4a438c9a..feb2175cd5 100644 --- a/src/components/[guild]/Requirements/RoleRequirements.tsx +++ b/src/components/[guild]/Requirements/RoleRequirements.tsx @@ -43,7 +43,7 @@ const RoleRequirements = ({ const requirements = role.hiddenRequirements || data?.length === 0 - ? [...(data ?? []), { type: "HIDDEN", roleId: role.id } as Requirement] + ? [...(data ?? []), { roleId: role.id, visibility: "HIDDEN" } as Requirement] : data const isVirtualList = requirements?.length > VIRTUAL_LIST_REQUIREMENT_LIMIT diff --git a/src/components/[guild]/Requirements/components/GuildCheckout/MintGuildPin/components/ActivateGuildPinForm.tsx b/src/components/[guild]/Requirements/components/GuildCheckout/MintGuildPin/components/ActivateGuildPinForm.tsx index 8b096ed8d1..5bf19ecceb 100644 --- a/src/components/[guild]/Requirements/components/GuildCheckout/MintGuildPin/components/ActivateGuildPinForm.tsx +++ b/src/components/[guild]/Requirements/components/GuildCheckout/MintGuildPin/components/ActivateGuildPinForm.tsx @@ -8,7 +8,6 @@ import useToast from "hooks/useToast" import { FormProvider, useController, useForm, useWatch } from "react-hook-form" import { traitsSupportedChains } from "requirements/Nft/NftForm" import ChainPicker from "requirements/common/ChainPicker" -import { Visibility } from "types" import { GUILD_PIN_CONTRACTS } from "utils/guildCheckout/constants" import { Chain } from "wagmiConfig/chains" import { useMintGuildPinContext } from "../../MintGuildPinContext" @@ -76,7 +75,7 @@ const ActivateGuildPinForm = (): JSX.Element => { }, ], rolePlatforms: [], - visibility: Visibility.PUBLIC, + visibility: "PUBLIC", }) } : showSuccessToastAndCloseModal, diff --git a/src/components/[guild]/Requirements/components/GuildCheckout/components/BuyTotal.tsx b/src/components/[guild]/Requirements/components/GuildCheckout/components/BuyTotal.tsx index adc4580719..538981bfc0 100644 --- a/src/components/[guild]/Requirements/components/GuildCheckout/components/BuyTotal.tsx +++ b/src/components/[guild]/Requirements/components/GuildCheckout/components/BuyTotal.tsx @@ -3,7 +3,7 @@ import useTokenData from "hooks/useTokenData" import useVault from "requirements/Payment/hooks/useVault" import { NULL_ADDRESS } from "utils/guildCheckout/constants" import { formatUnits } from "viem" -import { CHAIN_CONFIG } from "wagmiConfig/chains" +import { Chain, CHAIN_CONFIG } from "wagmiConfig/chains" import { useRequirementContext } from "../../RequirementContext" import usePayFee from "../hooks/usePayFee" import FeesTable from "./FeesTable" @@ -14,13 +14,17 @@ const BuyTotal = (): JSX.Element => { const requirement = useRequirementContext() const { pickedCurrency } = useGuildCheckoutContext() + // TODO: we could remove the cast once we'll have schemas for "ERC..." requirements + const requirementChain = requirement.chain as Chain + const requirementAddress = requirement.address as `0x${string}` + const { token, fee, isLoading, error } = useVault( - requirement.address, + requirementAddress, requirement.data.id, - requirement.chain + requirementChain ) - const { data: tokenData } = useTokenData(requirement.chain, token) + const { data: tokenData } = useTokenData(requirementChain, token) const isNativeCurrency = pickedCurrency === NULL_ADDRESS @@ -31,7 +35,7 @@ const BuyTotal = (): JSX.Element => { ? parseFloat( formatUnits( estimatedGas, - CHAIN_CONFIG[requirement.chain].nativeCurrency.decimals + CHAIN_CONFIG[requirementChain].nativeCurrency.decimals ) ) : null @@ -39,7 +43,7 @@ const BuyTotal = (): JSX.Element => { const priceInSellToken = fee ? isNativeCurrency ? Number( - formatUnits(fee, CHAIN_CONFIG[requirement.chain].nativeCurrency.decimals) + formatUnits(fee, CHAIN_CONFIG[requirementChain].nativeCurrency.decimals) ) : tokenData?.decimals ? Number(formatUnits(fee, tokenData.decimals)) + @@ -97,7 +101,7 @@ const BuyTotal = (): JSX.Element => { {!estimatedGasInFloat ? "Couldn't estimate" : `${Number(estimatedGasInFloat.toFixed(8))} ${ - CHAIN_CONFIG[requirement.chain].nativeCurrency.symbol + CHAIN_CONFIG[requirementChain].nativeCurrency.symbol }`} diff --git a/src/components/[guild]/Requirements/components/GuildCheckout/components/PaymentFeeCurrency.tsx b/src/components/[guild]/Requirements/components/GuildCheckout/components/PaymentFeeCurrency.tsx index 0fc5a99d2d..a3b8b5a953 100644 --- a/src/components/[guild]/Requirements/components/GuildCheckout/components/PaymentFeeCurrency.tsx +++ b/src/components/[guild]/Requirements/components/GuildCheckout/components/PaymentFeeCurrency.tsx @@ -13,11 +13,11 @@ const PaymentFeeCurrency = (): JSX.Element => { const lightShade = useColorModeValue("white", "gray.700") const borderWidth = useColorModeValue(1, 0) - const requirement = useRequirementContext() + const requirement = useRequirementContext<"PAYMENT">() const { pickedCurrency, setPickedCurrency } = useGuildCheckoutContext() const { token, fee, error, isLoading } = useVault( - requirement?.address, + requirement?.address as `0x${string}`, requirement?.data?.id, requirement?.chain ) diff --git a/src/components/[guild]/Requirements/components/GuildCheckout/components/PurchaseFeeAndTotal.tsx b/src/components/[guild]/Requirements/components/GuildCheckout/components/PurchaseFeeAndTotal.tsx index 3cc8674d50..3fb50d274d 100644 --- a/src/components/[guild]/Requirements/components/GuildCheckout/components/PurchaseFeeAndTotal.tsx +++ b/src/components/[guild]/Requirements/components/GuildCheckout/components/PurchaseFeeAndTotal.tsx @@ -3,7 +3,7 @@ import useTokenData from "hooks/useTokenData" import { Info, Question } from "phosphor-react" import { GUILD_FEE_PERCENTAGE, NULL_ADDRESS } from "utils/guildCheckout/constants" import { formatUnits } from "viem" -import { CHAIN_CONFIG } from "wagmiConfig/chains" +import { Chain, CHAIN_CONFIG } from "wagmiConfig/chains" import { useRequirementContext } from "../../RequirementContext" import usePrice from "../hooks/usePrice" import usePurchaseAsset from "../hooks/usePurchaseAsset" @@ -15,9 +15,12 @@ const PurchaseFeeAndTotal = (): JSX.Element => { const requirement = useRequirementContext() const { pickedCurrency } = useGuildCheckoutContext() + // TODO: we could remove the cast once we'll have schemas for "ERC..." requirements + const requirementChain = requirement.chain as Chain + const { data: { symbol }, - } = useTokenData(requirement.chain, pickedCurrency) + } = useTokenData(requirementChain, pickedCurrency) const { data: { @@ -39,7 +42,7 @@ const PurchaseFeeAndTotal = (): JSX.Element => { ? parseFloat( formatUnits( estimatedGas, - CHAIN_CONFIG[requirement.chain].nativeCurrency.decimals + CHAIN_CONFIG[requirementChain].nativeCurrency.decimals ) ) : null @@ -168,7 +171,7 @@ const PurchaseFeeAndTotal = (): JSX.Element => { {!estimatedGasInFloat ? "Couldn't estimate" : `${estimatedGasInFloat.toFixed(8)} ${ - CHAIN_CONFIG[requirement.chain].nativeCurrency.symbol + CHAIN_CONFIG[requirementChain].nativeCurrency.symbol }`} diff --git a/src/components/[guild]/Requirements/components/GuildCheckout/components/PurchasedRequirementInfo.tsx b/src/components/[guild]/Requirements/components/GuildCheckout/components/PurchasedRequirementInfo.tsx index 5e49cb247c..eafb8a9740 100644 --- a/src/components/[guild]/Requirements/components/GuildCheckout/components/PurchasedRequirementInfo.tsx +++ b/src/components/[guild]/Requirements/components/GuildCheckout/components/PurchasedRequirementInfo.tsx @@ -8,6 +8,7 @@ import { VStack, } from "@chakra-ui/react" import useTokenData from "hooks/useTokenData" +import { Chain } from "wagmiConfig/chains" import { useRequirementContext } from "../../RequirementContext" type Props = { @@ -20,9 +21,13 @@ const PurchasedRequirementInfo = ({ rightElement, footer }: Props): JSX.Element const requirement = useRequirementContext() + // TODO: we could remove the cast once we'll have schemas for "ERC..." requirements + const requirementChain = requirement.chain as Chain + const requirementAddress = requirement.address as `0x${string}` + const { data: { symbol, logoURI }, - } = useTokenData(requirement?.chain, requirement?.address) + } = useTokenData(requirementChain, requirementAddress) return ( { const { captureEvent } = usePostHogContext() const { urlName } = useGuild() - const requirement = useRequirementContext() + const requirement = useRequirementContext<"PAYMENT">() + const requirementAddress = requirement.address as `0x${string}` + const requirementChainId = Chains[requirement.chain] const { pickedCurrency } = useGuildCheckoutContext() @@ -37,7 +39,7 @@ const BuyAllowanceButton = (): JSX.Element => { const tokenName = isNativeCurrencyPicked ? nativeCurrency.name : name const { fee, isLoading: isVaultLoading } = useVault( - requirement.address, + requirementAddress, requirement.data.id, requirement.chain ) @@ -48,7 +50,7 @@ const BuyAllowanceButton = (): JSX.Element => { isAllowing, allowanceError, allowSpendingTokens, - } = useAllowance(pickedCurrency, requirement.address) + } = useAllowance(pickedCurrency, requirementAddress) const isEnoughAllowance = typeof fee === "bigint" && typeof allowance === "bigint" diff --git a/src/components/[guild]/Requirements/components/GuildCheckout/components/buttons/BuyButton.tsx b/src/components/[guild]/Requirements/components/GuildCheckout/components/buttons/BuyButton.tsx index 78f3fd86cd..30cd19f432 100644 --- a/src/components/[guild]/Requirements/components/GuildCheckout/components/buttons/BuyButton.tsx +++ b/src/components/[guild]/Requirements/components/GuildCheckout/components/buttons/BuyButton.tsx @@ -18,7 +18,9 @@ const BuyButton = (): JSX.Element => { const { address, chainId } = useAccount() - const requirement = useRequirementContext() + const requirement = useRequirementContext<"PAYMENT">() + const requirementAddress = requirement.address as `0x${string}` + const { pickedCurrency, agreeWithTOS } = useGuildCheckoutContext() const { @@ -26,17 +28,17 @@ const BuyButton = (): JSX.Element => { multiplePayments, isLoading: isVaultLoading, error, - } = useVault(requirement.address, requirement.data.id, requirement.chain) + } = useVault(requirementAddress, requirement.data.id, requirement.chain) const { data: hasPaid, isLoading: isHasPaidLoading } = useHasPaid( - requirement.address, - requirement.data.id, + requirementAddress, + +requirement.data.id, requirement.chain ) const { allowance, isAllowanceLoading, allowanceError } = useAllowance( pickedCurrency, - requirement.address + requirementAddress ) const { diff --git a/src/components/[guild]/Requirements/components/GuildCheckout/components/buttons/PurchaseAllowanceButton.tsx b/src/components/[guild]/Requirements/components/GuildCheckout/components/buttons/PurchaseAllowanceButton.tsx index d55c02da00..f8bd607850 100644 --- a/src/components/[guild]/Requirements/components/GuildCheckout/components/buttons/PurchaseAllowanceButton.tsx +++ b/src/components/[guild]/Requirements/components/GuildCheckout/components/buttons/PurchaseAllowanceButton.tsx @@ -7,7 +7,7 @@ import useTokenData from "hooks/useTokenData" import { Check, Question, Warning } from "phosphor-react" import { NULL_ADDRESS, TOKEN_BUYER_CONTRACTS } from "utils/guildCheckout/constants" import { useChainId } from "wagmi" -import { CHAIN_CONFIG, Chains } from "wagmiConfig/chains" +import { Chain, CHAIN_CONFIG, Chains } from "wagmiConfig/chains" import { useRequirementContext } from "../../../RequirementContext" import usePrice from "../../hooks/usePrice" import { useGuildCheckoutContext } from "../GuildCheckoutContext" @@ -17,14 +17,16 @@ const PurchaseAllowanceButton = (): JSX.Element => { const { urlName } = useGuild() const requirement = useRequirementContext() - const requirementChainId = Chains[requirement.chain] + // TODO: remove typecast once we implement schemas for ERC20 requirements + const requirementChain = requirement.chain as Chain + const requirementChainId = Chains[requirementChain] const { pickedCurrency } = useGuildCheckoutContext() const chainId = useChainId() const { data: { symbol, name }, - } = useTokenData(requirement.chain, pickedCurrency) + } = useTokenData(requirementChain, pickedCurrency) const nativeCurrency = CHAIN_CONFIG[Chains[chainId]]?.nativeCurrency const isNativeCurrencyPicked = pickedCurrency === NULL_ADDRESS diff --git a/src/components/[guild]/Requirements/components/GuildCheckout/hooks/usePayFee.ts b/src/components/[guild]/Requirements/components/GuildCheckout/hooks/usePayFee.ts index e2a9c31069..f87a6dff99 100644 --- a/src/components/[guild]/Requirements/components/GuildCheckout/hooks/usePayFee.ts +++ b/src/components/[guild]/Requirements/components/GuildCheckout/hooks/usePayFee.ts @@ -22,7 +22,9 @@ const usePayFee = () => { const { address, chainId } = useAccount() - const requirement = useRequirementContext() + const requirement = useRequirementContext<"PAYMENT">() + const requirementAddress = requirement.address as `0x${string}` + const { pickedCurrency, onClose } = useGuildCheckoutContext() const showErrorToast = useShowErrorToast() @@ -33,11 +35,11 @@ const usePayFee = () => { multiplePayments, isLoading: isVaultLoading, refetch: refetchVault, - } = useVault(requirement.address, requirement.data.id, requirement.chain) + } = useVault(requirementAddress, requirement.data.id, requirement.chain) const { data: hasPaid, isLoading: isHasPaidLoading } = useHasPaid( - requirement.address, - requirement.data.id, + requirementAddress, + +requirement.data.id, requirement.chain ) @@ -60,7 +62,7 @@ const usePayFee = () => { ? coinBalanceData?.value >= fee : tokenBalanceData?.value >= fee) - const { allowance } = useAllowance(pickedCurrency, requirement.address) + const { allowance } = useAllowance(pickedCurrency, requirementAddress) const enabled = requirement?.chain === Chains[chainId] && diff --git a/src/components/[guild]/Requirements/components/GuildCheckout/hooks/usePurchaseAsset.ts b/src/components/[guild]/Requirements/components/GuildCheckout/hooks/usePurchaseAsset.ts index 157469b484..45e7a4fa33 100644 --- a/src/components/[guild]/Requirements/components/GuildCheckout/hooks/usePurchaseAsset.ts +++ b/src/components/[guild]/Requirements/components/GuildCheckout/hooks/usePurchaseAsset.ts @@ -62,7 +62,7 @@ const usePurchaseAsset = () => { }) const { data: purchasedTokenData } = useToken({ - address: requirement?.address, + address: requirement?.address as `0x${string}`, chainId: Chains[requirement?.chain], }) diff --git a/src/components/[guild]/Requirements/components/Requirement.tsx b/src/components/[guild]/Requirements/components/Requirement.tsx index 7417f50906..468f2e9f4f 100644 --- a/src/components/[guild]/Requirements/components/Requirement.tsx +++ b/src/components/[guild]/Requirements/components/Requirement.tsx @@ -12,7 +12,6 @@ import Visibility from "components/[guild]/Visibility" import dynamic from "next/dynamic" import React, { ComponentType, PropsWithChildren } from "react" import { useFormContext } from "react-hook-form" -import { Visibility as VisibilityType } from "types" import { useRequirementContext } from "./RequirementContext" import { RequirementImage, RequirementImageCircle } from "./RequirementImage" import ResetRequirementButton from "./ResetRequirementButton" @@ -77,8 +76,8 @@ const Requirement = ({ : requirement?.data?.customName || children} {!setValue ? ( ) : null} diff --git a/src/components/[guild]/Requirements/components/RequirementChainIndicator.tsx b/src/components/[guild]/Requirements/components/RequirementChainIndicator.tsx index 2aaee0a488..5afe8d54de 100644 --- a/src/components/[guild]/Requirements/components/RequirementChainIndicator.tsx +++ b/src/components/[guild]/Requirements/components/RequirementChainIndicator.tsx @@ -1,11 +1,12 @@ import { Img, Tag, TagLabel, TagProps, useColorModeValue } from "@chakra-ui/react" -import { CHAIN_CONFIG, Chain } from "wagmiConfig/chains" +import { Requirement } from "types" +import { CHAIN_CONFIG } from "wagmiConfig/chains" import { useRequirementContext } from "./RequirementContext" const RequirementChainIndicator = ({ chain: chainFromProp, ...rest -}: { chain?: Chain } & TagProps) => { +}: { chain?: Requirement["chain"] } & TagProps) => { const { chain: chainFromContext } = useRequirementContext() ?? {} const chain = chainFromProp ?? chainFromContext const bg = useColorModeValue("white", "blackAlpha.300") diff --git a/src/components/[guild]/Requirements/components/RequirementContext.tsx b/src/components/[guild]/Requirements/components/RequirementContext.tsx index ba7ba0d0c6..e9690ce12b 100644 --- a/src/components/[guild]/Requirements/components/RequirementContext.tsx +++ b/src/components/[guild]/Requirements/components/RequirementContext.tsx @@ -1,5 +1,7 @@ +import { schemas } from "@guildxyz/types" import { createContext, PropsWithChildren, useContext } from "react" import { Requirement } from "types" +import { z } from "zod" // It's safe to use undefine here as the default value, since we'll always have a default value in RequirementProvider const RequirementContext = createContext(undefined) @@ -22,6 +24,13 @@ const RequirementProvider = ({ ) } -const useRequirementContext = () => useContext(RequirementContext) +type ReqType = z.output["type"] +const useRequirementContext = () => { + const requirement = useContext(RequirementContext) + return requirement as unknown as Extract< + z.output, + { type: RequirementType } + > +} export { RequirementProvider, useRequirementContext } diff --git a/src/components/[guild]/Requirements/components/RequirementDisplayComponent.tsx b/src/components/[guild]/Requirements/components/RequirementDisplayComponent.tsx index d95c750eec..46bb5fc1c3 100644 --- a/src/components/[guild]/Requirements/components/RequirementDisplayComponent.tsx +++ b/src/components/[guild]/Requirements/components/RequirementDisplayComponent.tsx @@ -22,7 +22,7 @@ const RequirementDisplayComponent = ({ rightElement = , ...rest }: Props) => { - if (requirement.type === "HIDDEN") + if (requirement.visibility === "HIDDEN") return ( } diff --git a/src/components/[guild]/RoleCard/RoleCard.tsx b/src/components/[guild]/RoleCard/RoleCard.tsx index da4a619970..8f36dd5bee 100644 --- a/src/components/[guild]/RoleCard/RoleCard.tsx +++ b/src/components/[guild]/RoleCard/RoleCard.tsx @@ -17,7 +17,7 @@ import useMembership, { import dynamic from "next/dynamic" import rewards from "platforms/rewards" import { memo, useEffect, useRef } from "react" -import { PlatformType, Role, Visibility as VisibilityType } from "types" +import { PlatformType, Role } from "types" import RoleRequirements from "../Requirements" import useGuild from "../hooks/useGuild" import useGuildPermission from "../hooks/useGuildPermission" @@ -70,8 +70,7 @@ const RoleCard = memo(({ role }: Props) => { const isMobile = useBreakpointValue({ base: true, md: false }, { fallback: "md" }) - const collapsedHeight = - isMobile && role.visibility === VisibilityType.PUBLIC ? "90px" : "94px" + const collapsedHeight = isMobile && role.visibility === "PUBLIC" ? "90px" : "94px" return ( { onClick={() => { if (window.location.hash === `#role-${role.id}`) window.location.hash = "!" }} - {...(role.visibility === VisibilityType.HIDDEN + {...(role.visibility === "HIDDEN" ? { borderWidth: 2, borderStyle: "dashed", diff --git a/src/components/[guild]/RoleCard/components/EditRole/hooks/useEditRoleForm.ts b/src/components/[guild]/RoleCard/components/EditRole/hooks/useEditRoleForm.ts index 89dc2e4323..1d627f7d08 100644 --- a/src/components/[guild]/RoleCard/components/EditRole/hooks/useEditRoleForm.ts +++ b/src/components/[guild]/RoleCard/components/EditRole/hooks/useEditRoleForm.ts @@ -1,7 +1,8 @@ +import { Visibility } from "@guildxyz/types" import useGuild from "components/[guild]/hooks/useGuild" import { useEffect } from "react" import { useForm } from "react-hook-form" -import { Logic, Visibility } from "types" +import { Logic } from "types" export type RoleEditFormData = { id: number @@ -36,7 +37,7 @@ const useEditRoleForm = (roleId: number) => { imageUrl, logic, anyOfNum: anyOfNum ?? 1, - visibility, + visibility: visibility ?? "PUBLIC", visibilityRoleId, groupId, } diff --git a/src/components/[guild]/RoleCard/components/EditRole/hooks/useUpdateRolePlatformVisibility.ts b/src/components/[guild]/RoleCard/components/EditRole/hooks/useUpdateRolePlatformVisibility.ts index 424440c476..90ef9daf56 100644 --- a/src/components/[guild]/RoleCard/components/EditRole/hooks/useUpdateRolePlatformVisibility.ts +++ b/src/components/[guild]/RoleCard/components/EditRole/hooks/useUpdateRolePlatformVisibility.ts @@ -1,8 +1,9 @@ +import { Visibility } from "@guildxyz/types" import useGuild from "components/[guild]/hooks/useGuild" import useShowErrorToast from "hooks/useShowErrorToast" import useSubmit from "hooks/useSubmit" import useToast from "hooks/useToast" -import { RolePlatform, Visibility } from "types" +import { RolePlatform } from "types" import { useFetcherWithSign } from "utils/fetcher" import useLocalMutateRolePlatform from "./useLocalMutateRolePlatform" diff --git a/src/components/[guild]/RolePlatforms/components/AddRoleRewardModal/components/SelectExistingPlatform.tsx b/src/components/[guild]/RolePlatforms/components/AddRoleRewardModal/components/SelectExistingPlatform.tsx index 6928a27777..ae1d1248f2 100644 --- a/src/components/[guild]/RolePlatforms/components/AddRoleRewardModal/components/SelectExistingPlatform.tsx +++ b/src/components/[guild]/RolePlatforms/components/AddRoleRewardModal/components/SelectExistingPlatform.tsx @@ -6,13 +6,7 @@ import { DISPLAY_CARD_INTERACTIVITY_STYLES } from "components/common/DisplayCard import rewards, { PlatformAsRewardRestrictions } from "platforms/rewards" import { useState } from "react" import { useWatch } from "react-hook-form" -import { - PlatformType, - Requirement, - RoleFormType, - RolePlatform, - Visibility, -} from "types" +import { PlatformType, Requirement, RoleFormType, RolePlatform } from "types" import EditRolePlatformModal from "../../EditRolePlatformModal" import PlatformCard from "../../PlatformCard" @@ -36,7 +30,7 @@ const SelectExistingPlatform = ({ onClose, onSelect }: Props) => { name: "rolePlatforms", }) - const roleVisibility: Visibility = useWatch({ name: ".visibility" }) + const roleVisibility = useWatch({ name: "visibility" }) const filteredPlatforms = guildPlatforms ? guildPlatforms.filter( diff --git a/src/components/[guild]/Roles.tsx b/src/components/[guild]/Roles.tsx index c42572b9db..52371e6c4d 100644 --- a/src/components/[guild]/Roles.tsx +++ b/src/components/[guild]/Roles.tsx @@ -6,7 +6,6 @@ import useGuild from "components/[guild]/hooks/useGuild" import { useScrollBatchedRendering } from "hooks/useScrollBatchedRendering" import dynamic from "next/dynamic" import { useMemo, useState } from "react" -import { Visibility } from "types" import useGuildPermission from "./hooks/useGuildPermission" import useRoleGroup from "./hooks/useRoleGroup" @@ -44,12 +43,8 @@ const Roles = () => { ) }, [roles]) - const publicRoles = sortedRoles.filter( - (role) => role.visibility !== Visibility.HIDDEN - ) - const hiddenRoles = sortedRoles.filter( - (role) => role.visibility === Visibility.HIDDEN - ) + const publicRoles = sortedRoles.filter((role) => role.visibility !== "HIDDEN") + const hiddenRoles = sortedRoles.filter((role) => role.visibility === "HIDDEN") const [renderedRolesCount, setRenderedRolesCount] = useState(BATCH_SIZE) const rolesEl = useScrollBatchedRendering({ diff --git a/src/components/[guild]/SetVisibility/SetVisibility.tsx b/src/components/[guild]/SetVisibility/SetVisibility.tsx index c54c371415..ddd687166b 100644 --- a/src/components/[guild]/SetVisibility/SetVisibility.tsx +++ b/src/components/[guild]/SetVisibility/SetVisibility.tsx @@ -13,11 +13,11 @@ import { Tooltip, useColorModeValue, } from "@chakra-ui/react" +import { Visibility } from "@guildxyz/types" import Button from "components/common/Button" import RadioSelect from "components/common/RadioSelect" import { useRef } from "react" import { FormProvider, useController, useForm, useWatch } from "react-hook-form" -import { Visibility } from "types" import useVisibilityTooltipLabel from "./hooks/useVisibilityTooltipLabel" import { VISIBILITY_DATA } from "./visibilityData" @@ -35,7 +35,7 @@ const SetVisibility = ({ onSave, isLoading, defaultValues = { - visibility: Visibility.PUBLIC, + visibility: "PUBLIC", visibilityRoleId: undefined, }, ...buttonProps diff --git a/src/components/[guild]/SetVisibility/components/VisibilityTag.tsx b/src/components/[guild]/SetVisibility/components/VisibilityTag.tsx index 4497c6917d..3ec22dfaee 100644 --- a/src/components/[guild]/SetVisibility/components/VisibilityTag.tsx +++ b/src/components/[guild]/SetVisibility/components/VisibilityTag.tsx @@ -1,5 +1,5 @@ +import { Visibility } from "@guildxyz/types" import Button from "components/common/Button" -import { Visibility } from "types" import { VISIBILITY_DATA } from "../visibilityData" const VisibilityTag = ({ visibility }: { visibility: Visibility }) => { diff --git a/src/components/[guild]/SetVisibility/hooks/useVisibilityTooltipLabel.tsx b/src/components/[guild]/SetVisibility/hooks/useVisibilityTooltipLabel.tsx index 0f29851adb..6be6a64bc4 100644 --- a/src/components/[guild]/SetVisibility/hooks/useVisibilityTooltipLabel.tsx +++ b/src/components/[guild]/SetVisibility/hooks/useVisibilityTooltipLabel.tsx @@ -1,7 +1,7 @@ +import { Visibility } from "@guildxyz/types" import RoleTag from "components/[guild]/RoleTag" import useGuild from "components/[guild]/hooks/useGuild" import { ReactNode } from "react" -import { Visibility } from "types" import { VISIBILITY_DATA } from "../visibilityData" const useVisibilityTooltipLabel = ( @@ -10,12 +10,12 @@ const useVisibilityTooltipLabel = ( ): ReactNode => { const { roles } = useGuild() const role = - visibilityRoleId && visibility === Visibility.PRIVATE + visibilityRoleId && visibility === "PRIVATE" ? roles?.find(({ id }) => id === visibilityRoleId) : undefined const tooltipDescription = - visibility !== Visibility.PRIVATE ? ( + visibility !== "PRIVATE" ? ( VISIBILITY_DATA[visibility]?.description ?? VISIBILITY_DATA.PUBLIC.description ) : !visibilityRoleId ? ( "Only visible to role holders" diff --git a/src/components/[guild]/SetVisibility/visibilityData.tsx b/src/components/[guild]/SetVisibility/visibilityData.tsx index 8205cddedc..f754f7f14c 100644 --- a/src/components/[guild]/SetVisibility/visibilityData.tsx +++ b/src/components/[guild]/SetVisibility/visibilityData.tsx @@ -1,6 +1,6 @@ +import { Visibility } from "@guildxyz/types" import { Option } from "components/common/RadioSelect/RadioSelect" import { Detective, EyeSlash, GlobeHemisphereEast, IconProps } from "phosphor-react" -import { Visibility } from "types" import PrivateVisibilityOptions from "./components/PrivateVisibilityOptions" export const VISIBILITY_DATA: Record< @@ -13,18 +13,18 @@ export const VISIBILITY_DATA: Record< Child?: typeof PrivateVisibilityOptions } > = { - [Visibility.PUBLIC]: { + PUBLIC: { title: "Public", Icon: GlobeHemisphereEast, description: "Visible to everyone", }, - [Visibility.PRIVATE]: { + PRIVATE: { title: "Secret", Icon: Detective, description: "Only visible to users that satisfy...", Child: PrivateVisibilityOptions, }, - [Visibility.HIDDEN]: { + HIDDEN: { title: "Hidden", Icon: EyeSlash, description: "Only visible to admins", diff --git a/src/components/[guild]/Visibility.tsx b/src/components/[guild]/Visibility.tsx index 98a9a77cbc..621981204d 100644 --- a/src/components/[guild]/Visibility.tsx +++ b/src/components/[guild]/Visibility.tsx @@ -1,5 +1,5 @@ import { Tag, TagLabel, TagLeftIcon, TagProps, Tooltip } from "@chakra-ui/react" -import { Visibility as VisibilityType } from "types" +import { Visibility as VisibilityType } from "@guildxyz/types" import useVisibilityTooltipLabel from "./SetVisibility/hooks/useVisibilityTooltipLabel" import { VISIBILITY_DATA } from "./SetVisibility/visibilityData" @@ -19,7 +19,7 @@ const Visibility = ({ const label = useVisibilityTooltipLabel(entityVisibility, visibilityRoleId) - if (entityVisibility === VisibilityType.PUBLIC) return null + if (entityVisibility === "PUBLIC") return null return ( diff --git a/src/components/[guild]/crm/FilterByRoles/FilterByRoles.tsx b/src/components/[guild]/crm/FilterByRoles/FilterByRoles.tsx index f1e989a6a5..ef1e0c43da 100644 --- a/src/components/[guild]/crm/FilterByRoles/FilterByRoles.tsx +++ b/src/components/[guild]/crm/FilterByRoles/FilterByRoles.tsx @@ -22,7 +22,7 @@ import { import { MemberCountWithSyncIndicator } from "components/[guild]/RoleCard/components/MemberCount" import { Funnel } from "phosphor-react" import { memo, useState } from "react" -import { Role, Visibility } from "types" +import { Role } from "types" import useGuild from "../../hooks/useGuild" import FilterByRolesLogicSelector from "./FilterByRolesLogicSelector" import AddAndEditHiddenRoles from "./components/AddAndEditHiddenRoles" @@ -33,8 +33,8 @@ const FilterByRoles = ({ getFilterValue, setFilterValue }: any) => { const { roles } = useGuild() const [searchValue, setSearchValue] = useState("") - const publicRoles = roles?.filter((role) => role.visibility !== Visibility.HIDDEN) - const hiddenRoles = roles?.filter((role) => role.visibility === Visibility.HIDDEN) + const publicRoles = roles?.filter((role) => role.visibility !== "HIDDEN") + const hiddenRoles = roles?.filter((role) => role.visibility === "HIDDEN") const selectedRoleIds: number[] = getFilterValue()?.roleIds ?? [] const setSelectedRoleIds = (newValue: number[]) => { diff --git a/src/components/[guild]/crm/FilterByRoles/components/AddHiddenRoleButton.tsx b/src/components/[guild]/crm/FilterByRoles/components/AddHiddenRoleButton.tsx index 2ae80796e2..8ed2153506 100644 --- a/src/components/[guild]/crm/FilterByRoles/components/AddHiddenRoleButton.tsx +++ b/src/components/[guild]/crm/FilterByRoles/components/AddHiddenRoleButton.tsx @@ -20,7 +20,6 @@ import usePinata from "hooks/usePinata" import useSubmitWithUpload from "hooks/useSubmitWithUpload" import { Plus } from "phosphor-react" import { FormProvider, useForm, useWatch } from "react-hook-form" -import { Visibility } from "types" import getRandomInt from "utils/getRandomInt" import SetHiddenRoleRequirements from "./SetHiddenRoleRequirements" import useCreateHiddenRole from "./useCreateHiddenRole" @@ -42,7 +41,7 @@ const AddHiddenRoleButton = (buttonProps) => { requirements: [], roleType: "NEW", imageUrl: `/guildLogos/${getRandomInt(286)}.svg`, - visibility: Visibility.HIDDEN, + visibility: "HIDDEN", } const methods = useForm({ mode: "all", defaultValues }) diff --git a/src/components/[guild]/crm/FilterByRoles/components/SetHiddenRoleRequirements.tsx b/src/components/[guild]/crm/FilterByRoles/components/SetHiddenRoleRequirements.tsx index 36d1052ff0..8362f52b3f 100644 --- a/src/components/[guild]/crm/FilterByRoles/components/SetHiddenRoleRequirements.tsx +++ b/src/components/[guild]/crm/FilterByRoles/components/SetHiddenRoleRequirements.tsx @@ -17,7 +17,6 @@ const SetHiddenRoleRequirements = (): JSX.Element => { const { fields, append, update } = useFieldArray({ name: "requirements", control, - keyName: "formFieldId", }) // Watching the nested fields too, so we can properly update the list @@ -52,7 +51,7 @@ const SetHiddenRoleRequirements = (): JSX.Element => { const type: RequirementType = getValues(`requirements.${i}.type`) return ( - + diff --git a/src/components/[guild]/crm/useMembers.tsx b/src/components/[guild]/crm/useMembers.tsx index d28e1a3dd2..f85013d56a 100644 --- a/src/components/[guild]/crm/useMembers.tsx +++ b/src/components/[guild]/crm/useMembers.tsx @@ -1,7 +1,7 @@ import useActiveStatusUpdates from "hooks/useActiveStatusUpdates" import { useCallback, useMemo } from "react" import useSWRInfinite from "swr/infinite" -import { PlatformAccountDetails, Visibility } from "types" +import { PlatformAccountDetails } from "types" import { useFetcherWithSign } from "utils/fetcher" import useGuild from "../hooks/useGuild" import { useUserPublic } from "../hooks/useUser" @@ -60,12 +60,8 @@ const useMembers = (queryString: string) => { platformUsers: user.platformUsers.sort(sortAccounts), isShared: user.isShared === true || user.isShared === null, roles: { - hidden: user.roles.filter( - (role) => role.visibility === Visibility.HIDDEN - ), - public: user.roles.filter( - (role) => role.visibility !== Visibility.HIDDEN - ), + hidden: user.roles.filter((role) => role.visibility === "HIDDEN"), + public: user.roles.filter((role) => role.visibility !== "HIDDEN"), }, })) ), diff --git a/src/components/[guild]/messages/Message.tsx b/src/components/[guild]/messages/Message.tsx index 2732906cb5..da15098e93 100644 --- a/src/components/[guild]/messages/Message.tsx +++ b/src/components/[guild]/messages/Message.tsx @@ -28,7 +28,6 @@ import { import Card from "components/common/Card" import { Modal } from "components/common/Modal" import { Check, Question, Users } from "phosphor-react" -import { Visibility } from "types" import RoleTag from "../RoleTag" import useGuild from "../hooks/useGuild" import { Message as MessageType } from "./hooks/useGuildMessages" @@ -118,7 +117,7 @@ const Message = ({ key={role.id} name={role.name} imageUrl={role.imageUrl} - isHidden={role.visibility === Visibility.HIDDEN} + isHidden={role.visibility === "HIDDEN"} /> ))} {moreRolesCount > 0 && ( @@ -185,7 +184,7 @@ const Message = ({ key={role.id} name={role.name} imageUrl={role.imageUrl} - isHidden={role.visibility === Visibility.HIDDEN} + isHidden={role.visibility === "HIDDEN"} /> ))} diff --git a/src/components/create-guild/BasicInfo/components/ContactInfo.tsx b/src/components/create-guild/BasicInfo/components/ContactInfo.tsx index 7902c526b5..1c6adf60c8 100644 --- a/src/components/create-guild/BasicInfo/components/ContactInfo.tsx +++ b/src/components/create-guild/BasicInfo/components/ContactInfo.tsx @@ -40,16 +40,14 @@ const ContactInfo = ({ showAddButton = true }: Props): JSX.Element => { } = useFormContext() const { fields, append, remove } = useFieldArray({ - control, name: "contacts", - keyName: "formId", }) return ( {fields.map((contactField, index) => ( - + void + onAdd?: (req: Schemas["RequirementCreationPayload"]) => void handleClose: (forceClose?: boolean) => void selectedType?: RequirementType setOnCloseAttemptToast: Dispatch> @@ -204,10 +205,9 @@ const AddRequirementForm = forwardRef( ) => { const FormComponent = REQUIREMENTS[selectedType].formComponent - const methods = useForm({ mode: "all" }) + const methods = useForm({ mode: "all" }) - const roleVisibility: Visibility = useWatch({ name: ".visibility" }) - const roleId: number = useWatch({ name: ".id" }) + const roleId: number = useWatch({ name: "id" }) const [isPresent, safeToRemove] = usePresence() useEffect(() => { @@ -228,14 +228,13 @@ const AddRequirementForm = forwardRef( }, }) - const formType = useWatch({ name: ".type" as any, control: methods.control }) - const onSubmit = methods.handleSubmit((data) => { - const requirement: Requirement = { - type: selectedType, - visibility: roleVisibility, + if (!selectedType) return + + const requirement = schemas.RequirementCreationPayloadSchema.parse({ ...data, - } + type: selectedType, + }) if (!roleId) { onAdd?.(requirement) @@ -266,14 +265,16 @@ const AddRequirementForm = forwardRef( providerTypesOnly={providerTypesOnly} /> - {!!REQUIREMENT_PROVIDED_VALUES[formType ?? selectedType] && ( + {!!REQUIREMENT_PROVIDED_VALUES[selectedType] && ( <> {" "} + } /> )} diff --git a/src/components/create-guild/Requirements/components/ExistingRequirementEditableCard.tsx b/src/components/create-guild/Requirements/components/ExistingRequirementEditableCard.tsx index d5c8c434fc..dd83b83217 100644 --- a/src/components/create-guild/Requirements/components/ExistingRequirementEditableCard.tsx +++ b/src/components/create-guild/Requirements/components/ExistingRequirementEditableCard.tsx @@ -8,10 +8,10 @@ import RequirementImageEditor from "components/[guild]/Requirements/components/R import RequirementNameEditor from "components/[guild]/Requirements/components/RequirementNameEditor" import SetVisibility from "components/[guild]/SetVisibility" import useVisibilityModalProps from "components/[guild]/SetVisibility/hooks/useVisibilityModalProps" -import { PropsWithChildren, useRef } from "react" +import { ComponentProps, PropsWithChildren, useRef } from "react" import { FormProvider, useForm } from "react-hook-form" import REQUIREMENTS from "requirements" -import { Requirement as RequirementType } from "types" +import { Requirement, Requirement as RequirementType } from "types" import mapRequirement from "utils/mapRequirement" import useEditRequirement from "../hooks/useEditRequirement" import BalancyFooter from "./BalancyFooter" @@ -118,7 +118,7 @@ const ExistingRequirementEditModal = ({ onClose, finalFocusRef, }: Omit) => { - const methods = useForm({ mode: "all", defaultValues: requirement }) + const methods = useForm({ mode: "all", defaultValues: requirement }) const { onSubmit: onEditRequirementSubmit, isLoading: isEditRequirementLoading } = useEditRequirement(requirement.roleId, { @@ -201,7 +201,9 @@ const RequirementNameEditorWithSave = ({ children }: PropsWithChildren) onSuccess: () => setVisibilityModalProps.onClose(), }) - const onEditVisibilitySubmit = (visibilityData) => { + const onEditVisibilitySubmit: ComponentProps["onSave"] = ( + visibilityData + ) => { const editedData = { ...requirement, ...visibilityData, diff --git a/src/components/create-guild/Requirements/components/RequirementEditableCard.tsx b/src/components/create-guild/Requirements/components/RequirementEditableCard.tsx index c394fe8b1b..17546b5862 100644 --- a/src/components/create-guild/Requirements/components/RequirementEditableCard.tsx +++ b/src/components/create-guild/Requirements/components/RequirementEditableCard.tsx @@ -39,7 +39,10 @@ const RequirementEditableCard = ({ const editButtonRef = useRef() const { setValue } = useFormContext() - const methods = useForm({ mode: "all", defaultValues: field }) + const methods = useForm({ + mode: "all", + defaultValues: field, + }) const showViewOriginal = field?.data?.customName || field?.data?.customImage @@ -94,7 +97,7 @@ const RequirementEditableCard = ({ mt={-0.5} defaultValues={{ visibility: field.visibility, - visibilityRoleId: field.visibilityRoleId, + visibilityRoleId: field.visibilityRoleId ?? undefined, }} onSave={({ visibility, visibilityRoleId }) => { setValue(`requirements.${index}.visibility`, visibility, { diff --git a/src/components/create-guild/Requirements/hooks/useBalancy.ts b/src/components/create-guild/Requirements/hooks/useBalancy.ts index b9cb2ba713..c04435d327 100644 --- a/src/components/create-guild/Requirements/hooks/useBalancy.ts +++ b/src/components/create-guild/Requirements/hooks/useBalancy.ts @@ -3,7 +3,6 @@ import useDebouncedState from "hooks/useDebouncedState" import { useEffect, useMemo, useState } from "react" import { useWatch } from "react-hook-form" import useSWR from "swr" -import { Requirement } from "types" import fetcher from "utils/fetcher" import { parseUnits } from "viem" import { Chain, Chains } from "wagmiConfig/chains" @@ -97,7 +96,7 @@ const useBalancy = ( // Fixed logic for single requirement to avoid unnecessary refetch when changing logic const balancyLogic = baseFieldPath !== undefined ? "OR" : logic - const renderedRequirements = useMemo( + const renderedRequirements = useMemo( () => (baseFieldPath !== undefined ? debouncedRequirement diff --git a/src/components/create-guild/Requirements/hooks/useCreateRequirement.ts b/src/components/create-guild/Requirements/hooks/useCreateRequirement.ts index f5d5820ea5..fb585e126e 100644 --- a/src/components/create-guild/Requirements/hooks/useCreateRequirement.ts +++ b/src/components/create-guild/Requirements/hooks/useCreateRequirement.ts @@ -1,8 +1,9 @@ +import { Schemas } from "@guildxyz/types" import useGuild from "components/[guild]/hooks/useGuild" import useRequirements from "components/[guild]/hooks/useRequirements" import useShowErrorToast from "hooks/useShowErrorToast" import useSubmit from "hooks/useSubmit" -import { Requirement } from "types" +import { RequirementCreateResponseOutput } from "types" import { useFetcherWithSign } from "utils/fetcher" import preprocessRequirement from "utils/preprocessRequirement" @@ -15,7 +16,9 @@ const useCreateRequirement = ( const showErrorToast = useShowErrorToast() const fetcherWithSign = useFetcherWithSign() - const createRequirement = async (body: Requirement): Promise => + const createRequirement = async ( + body?: Schemas["RequirementCreationPayload"] + ): Promise => fetcherWithSign([ `/v2/guilds/${guildId}/roles/${roleId}/requirements`, { @@ -25,16 +28,16 @@ const useCreateRequirement = ( ]) return useSubmit< - Omit, - Requirement & { deletedRequirements?: number[] } + Schemas["RequirementCreationPayload"], + RequirementCreateResponseOutput >(createRequirement, { onSuccess: (response) => { if ( (response.type === "ALLOWLIST" || response.type === "ALLOWLIST_EMAIL") && response.data?.fileId ) { - response.data ??= {} - response.data.status = "IN-PROGRESS" + // TODO: add the "status" prop to the schema + ;(response.data as any).status = "IN-PROGRESS" } mutateRequirements( diff --git a/src/components/create-guild/Requirements/hooks/useEditRequirement.ts b/src/components/create-guild/Requirements/hooks/useEditRequirement.ts index bc4f42379f..18eb66aeb1 100644 --- a/src/components/create-guild/Requirements/hooks/useEditRequirement.ts +++ b/src/components/create-guild/Requirements/hooks/useEditRequirement.ts @@ -1,17 +1,18 @@ +import { Schemas } from "@guildxyz/types" import useGuild from "components/[guild]/hooks/useGuild" import useRequirements from "components/[guild]/hooks/useRequirements" import useShowErrorToast from "hooks/useShowErrorToast" import useSubmit from "hooks/useSubmit" import useToast from "hooks/useToast" -import { Requirement } from "types" +import { RequirementCreateResponseOutput } from "types" import { useFetcherWithSign } from "utils/fetcher" import preprocessRequirement from "utils/preprocessRequirement" -type EditedRequirement = Requirement & { deletedRequirements?: number[] } - const useEditRequirement = ( roleId: number, - config?: { onSuccess?: (editedRequirement: EditedRequirement) => void } + config?: { + onSuccess?: (editedRequirement: RequirementCreateResponseOutput) => void + } ) => { const { id: guildId } = useGuild() const { mutate: mutateRequirements } = useRequirements(roleId) @@ -20,27 +21,29 @@ const useEditRequirement = ( const showErrorToast = useShowErrorToast() const fetcherWithSign = useFetcherWithSign() - const editRequirement = async (data: Requirement): Promise => + const editRequirement = async ( + data?: Schemas["RequirementUpdatePayload"] & { id: number } + ): Promise => fetcherWithSign([ - `/v2/guilds/${guildId}/roles/${roleId}/requirements/${data.id}`, + `/v2/guilds/${guildId}/roles/${roleId}/requirements/${data?.id}`, { method: "PUT", - body: preprocessRequirement({ - ...data, - id: undefined, - }), + body: preprocessRequirement(data), }, ]) - return useSubmit(editRequirement, { + return useSubmit< + Schemas["RequirementUpdatePayload"] & { id: number }, + RequirementCreateResponseOutput + >(editRequirement, { onSuccess: (editedRequirement) => { if ( (editedRequirement.type === "ALLOWLIST" || editedRequirement.type === "ALLOWLIST_EMAIL") && editedRequirement.data?.fileId ) { - editedRequirement.data ??= {} - editedRequirement.data.status = "IN-PROGRESS" + // TODO: add the "status" prop to the schema + ;(editedRequirement.data as any).status = "IN-PROGRESS" } toast({ diff --git a/src/components/create-guild/Requirements/hooks/useHandleRequirementState.ts b/src/components/create-guild/Requirements/hooks/useHandleRequirementState.ts index 672ef57e06..aea2edd6d6 100644 --- a/src/components/create-guild/Requirements/hooks/useHandleRequirementState.ts +++ b/src/components/create-guild/Requirements/hooks/useHandleRequirementState.ts @@ -25,7 +25,7 @@ const useHandleRequirementState = (methods) => { } const append = (req: Requirement) => { - const reqToAdd = { id: Date.now(), ...req } + const reqToAdd = { ...req, id: Date.now() } if (freeEntry) { remove(0) } diff --git a/src/components/create-guild/hooks/useCreateRole.tsx b/src/components/create-guild/hooks/useCreateRole.tsx index 5c57b88f36..d5fb058bb8 100644 --- a/src/components/create-guild/hooks/useCreateRole.tsx +++ b/src/components/create-guild/hooks/useCreateRole.tsx @@ -8,7 +8,13 @@ import useCustomPosthogEvents from "hooks/useCustomPosthogEvents" import useMatchMutate from "hooks/useMatchMutate" import useShowErrorToast from "hooks/useShowErrorToast" import { SignedValidation, useSubmitWithSign } from "hooks/useSubmit" -import { GuildBase, GuildPlatform, Requirement, Role } from "types" +import { + GuildBase, + GuildPlatform, + Requirement, + RequirementCreationPayloadWithTempID, + Role, +} from "types" import fetcher from "utils/fetcher" import replacer from "utils/guildJsonReplacer" import preprocessRequirement from "utils/preprocessRequirement" @@ -19,7 +25,7 @@ export type RoleToCreate = Omit< > & { guildId: number roleType?: "NEW" - requirements: Omit[] + requirements: RequirementCreationPayloadWithTempID[] } type CreateRoleResponse = Role & { diff --git a/src/hooks/useSubmitTransaction.ts b/src/hooks/useSubmitTransaction.ts index 2865977fc5..a43ad3e46e 100644 --- a/src/hooks/useSubmitTransaction.ts +++ b/src/hooks/useSubmitTransaction.ts @@ -102,7 +102,10 @@ const useSubmitTransaction = ( functionName: contractCallConfig.functionName as ContractFunctionName, args: contractCallConfig.args as ContractFunctionArgs, value: contractCallConfig.value as bigint, - shouldFetch: contractCallConfig.query?.enabled ?? true, + shouldFetch: + typeof contractCallConfig.query?.enabled === "boolean" + ? contractCallConfig.query.enabled + : true, }) const { diff --git a/src/pages/[guild]/members.tsx b/src/pages/[guild]/members.tsx index c75d8f2ecf..bf39a78dec 100644 --- a/src/pages/[guild]/members.tsx +++ b/src/pages/[guild]/members.tsx @@ -30,7 +30,6 @@ import Head from "next/head" import { useRouter } from "next/router" import ErrorPage from "pages/_error" import { useEffect, useMemo, useRef, useState } from "react" -import { Visibility } from "types" const columnHelper = createColumnHelper() const getRowId = (row: Member) => `user_${row.userId}` @@ -160,7 +159,7 @@ const MembersPage = (): JSX.Element => { getRowId, }) - const hasHiddenRoles = roles?.some((role) => role.visibility === Visibility.HIDDEN) + const hasHiddenRoles = roles?.some((role) => role.visibility === "HIDDEN") useEffect(() => { const hiddenRolesColumn = table .getAllLeafColumns() diff --git a/src/platforms/components/SelectRoleOrSetRequirements.tsx b/src/platforms/components/SelectRoleOrSetRequirements.tsx index 56193ed3b3..1ab219483f 100644 --- a/src/platforms/components/SelectRoleOrSetRequirements.tsx +++ b/src/platforms/components/SelectRoleOrSetRequirements.tsx @@ -9,7 +9,7 @@ import useRoleGroup from "components/[guild]/hooks/useRoleGroup" import SetRequirements from "components/create-guild/Requirements" import rewards, { PlatformAsRewardRestrictions } from "platforms/rewards" import { useFormContext, useWatch } from "react-hook-form" -import { PlatformName, Visibility } from "types" +import { PlatformName } from "types" import getRandomInt from "utils/getRandomInt" type Props = { @@ -63,7 +63,7 @@ const SelectRoleOrSetRequirements = ({ isRoleSelectorDisabled }: Props) => { unregister("roleIds") setValue("name", data?.roleName || `New ${rewards[selection].name} role`) setValue("imageUrl", data?.imageUrl || `/guildLogos/${getRandomInt(286)}.svg`) - setValue("roleVisibility", Visibility.PUBLIC) + setValue("roleVisibility", "PUBLIC") } setActiveTab(value) diff --git a/src/requirements/Airdrop/AirdropRequirement.tsx b/src/requirements/Airdrop/AirdropRequirement.tsx index a25b44a57a..29da3c7808 100644 --- a/src/requirements/Airdrop/AirdropRequirement.tsx +++ b/src/requirements/Airdrop/AirdropRequirement.tsx @@ -1,5 +1,4 @@ import { Icon, Text, useDisclosure } from "@chakra-ui/react" -import { Schemas } from "@guildxyz/types" import Requirement, { RequirementProps, } from "components/[guild]/Requirements/components/Requirement" @@ -10,10 +9,7 @@ import { ArrowSquareIn } from "phosphor-react" import REQUIREMENTS from "requirements" const AirdropRequirement = ({ ...rest }: RequirementProps): JSX.Element => { - const requirement = useRequirementContext() as Extract< - Schemas["Requirement"], - { type: "GUILD_SNAPSHOT" } - > + const requirement = useRequirementContext<"GUILD_SNAPSHOT">() const { isHidden } = requirement?.data diff --git a/src/requirements/Allowlist/AllowlistRequirement.tsx b/src/requirements/Allowlist/AllowlistRequirement.tsx index f745842957..4d18cd8197 100644 --- a/src/requirements/Allowlist/AllowlistRequirement.tsx +++ b/src/requirements/Allowlist/AllowlistRequirement.tsx @@ -23,13 +23,14 @@ function HiddenAllowlistText({ isEmail }: { isEmail: boolean }) { } const AllowlistRequirement = ({ ...rest }: RequirementProps): JSX.Element => { - const requirement = useRequirementContext() as Extract< + const requirement = useRequirementContext<"ALLOWLIST" | "ALLOWLIST_EMAIL">() + // TODO: we should add addressCount to the schema, and remove the cast later on + const castedRequirement = requirement as unknown as Extract< Schemas["Requirement"], { type: "ALLOWLIST" | "ALLOWLIST_EMAIL" } > & { data: { // These are not included in the schemas, as these are appended on-the-fly by the BE, when sending the response - fileId?: string addressCount?: number } } @@ -42,12 +43,12 @@ const AllowlistRequirement = ({ ...rest }: RequirementProps): JSX.Element => { hideAllowlist, addressCount, fileId, - } = requirement.data + } = castedRequirement.data const willSearchAddresses = search !== debouncedSearch const { data: req, isValidating: isSearchingAddresses } = useRequirement( - requirement?.roleId, - requirement?.id, + castedRequirement?.roleId, + castedRequirement?.id, debouncedSearch ) @@ -60,12 +61,12 @@ const AllowlistRequirement = ({ ...rest }: RequirementProps): JSX.Element => { const { isOpen, onOpen, onClose } = useDisclosure() - const isEmail = requirement.type === "ALLOWLIST_EMAIL" + const isEmail = castedRequirement.type === "ALLOWLIST_EMAIL" - const { reqAccesses } = useRoleMembership(requirement.roleId) + const { reqAccesses } = useRoleMembership(castedRequirement.roleId) const hasAccess = reqAccesses?.find( - ({ requirementId }) => requirementId === requirement.id + ({ requirementId }) => requirementId === castedRequirement.id )?.access const shouldShowSearchHints = diff --git a/src/requirements/Farcaster/FarcasterRequirement.tsx b/src/requirements/Farcaster/FarcasterRequirement.tsx index 27d48c8e5f..e00b75f082 100644 --- a/src/requirements/Farcaster/FarcasterRequirement.tsx +++ b/src/requirements/Farcaster/FarcasterRequirement.tsx @@ -14,7 +14,7 @@ import { useFarcasterUser } from "./hooks/useFarcasterUsers" const FarcasterProfile = (props: RequirementProps) => ( } {...props} > @@ -59,7 +59,7 @@ const FarcasterTotalFollowers = (props: RequirementProps) => { return ( } - image={REQUIREMENTS.FARCASTER.icon.toString()} + image={REQUIREMENTS.FARCASTER_TOTAL_FOLLOWERS.icon.toString()} {...props} > {`Have at least ${data?.min ?? "-"} followers on Farcaster`} @@ -79,7 +79,7 @@ const FarcasterLikeRecast = (props: RequirementProps) => { return ( } - image={REQUIREMENTS.FARCASTER.icon.toString()} + image={REQUIREMENTS.FARCASTER_LIKE.icon.toString()} {...props} > {type === "FARCASTER_LIKE" ? "Like" : "Recast"} @@ -105,7 +105,7 @@ const FarcasterFollowChannel = (props: RequirementProps) => { return ( } - image={REQUIREMENTS.FARCASTER.icon.toString()} + image={REQUIREMENTS.FARCASTER_FOLLOW_CHANNEL.icon.toString()} {...props} > {"Follow the "} @@ -136,13 +136,13 @@ const FarcasterIncludeText = (props: RequirementProps) => { return ( } - image={REQUIREMENTS.FARCASTER.icon.toString()} + image={REQUIREMENTS.FARCASTER_BIO.icon.toString()} {...props} > {"Have "} - {` in your ${REQUIREMENTS.FARCASTER.name} ${PROFILE_TARGETS[type]}`} + {` in your ${REQUIREMENTS.FARCASTER_BIO.name} ${PROFILE_TARGETS[type]}`} ) diff --git a/src/requirements/Fuel/FuelRequirement.tsx b/src/requirements/Fuel/FuelRequirement.tsx index a9a8ec0422..db607a2a84 100644 --- a/src/requirements/Fuel/FuelRequirement.tsx +++ b/src/requirements/Fuel/FuelRequirement.tsx @@ -12,6 +12,11 @@ const NULL_FUEL_ADDRESS = const FuelRequirement = (props: RequirementProps) => { const { type, address, data } = useRequirementContext() + + // TODO: remove these once we implement the Fuel requirement schema + const requirementAddress = address as `0x${string}` + const requirementDataSymbol = data.symbol + const tagBg = useColorModeValue("white", "blackAlpha.300") return ( @@ -47,11 +52,11 @@ const FuelRequirement = (props: RequirementProps) => { } `} {address === NULL_FUEL_ADDRESS ? ( "ETH" - ) : data?.symbol ? ( - {data.symbol} + ) : requirementDataSymbol ? ( + {requirementDataSymbol} ) : ( - - {shortenHex(address)} + + {shortenHex(requirementAddress)} )} diff --git a/src/requirements/Lens/LensRequirement.tsx b/src/requirements/Lens/LensRequirement.tsx index 3f2d6a9a73..c224fe3ac4 100644 --- a/src/requirements/Lens/LensRequirement.tsx +++ b/src/requirements/Lens/LensRequirement.tsx @@ -51,7 +51,7 @@ const LensRequirement = (props: RequirementProps) => { return return ( - + {(() => { switch (requirement.type) { case "LENS_REACT": @@ -100,7 +100,7 @@ const LensFollowRequirement = (props: RequirementProps) => { return ( diff --git a/src/requirements/Lens/hooks/useLensProfile.ts b/src/requirements/Lens/hooks/useLensProfile.ts index de4649aed5..b1a5e53e58 100644 --- a/src/requirements/Lens/hooks/useLensProfile.ts +++ b/src/requirements/Lens/hooks/useLensProfile.ts @@ -45,7 +45,7 @@ const useLensProfile = (id: string) => { value: data.id, img: data.metadata?.picture?.optimized?.uri ?? - (REQUIREMENTS.LENS.icon as string), + (REQUIREMENTS.LENS_ACTION.icon as string), } : undefined, } diff --git a/src/requirements/Lens/hooks/useLensProfiles.ts b/src/requirements/Lens/hooks/useLensProfiles.ts index 9a17db47a7..c5521a90ec 100644 --- a/src/requirements/Lens/hooks/useLensProfiles.ts +++ b/src/requirements/Lens/hooks/useLensProfiles.ts @@ -66,7 +66,9 @@ const useLensProfiles = (searchQuery: string) => { handles: data?.map(({ id, handle: { localName }, metadata }) => ({ label: `${localName}.lens`, value: id, - img: metadata?.picture?.optimized?.uri ?? (REQUIREMENTS.LENS.icon as string), + img: + metadata?.picture?.optimized?.uri ?? + (REQUIREMENTS.LENS_ACTION.icon as string), })), isLoading, } diff --git a/src/requirements/Mirror/MirrorRequirement.tsx b/src/requirements/Mirror/MirrorRequirement.tsx index 66eb197955..abc3be01d5 100644 --- a/src/requirements/Mirror/MirrorRequirement.tsx +++ b/src/requirements/Mirror/MirrorRequirement.tsx @@ -6,14 +6,19 @@ import Requirement, { import { useRequirementContext } from "components/[guild]/Requirements/components/RequirementContext" import DataBlock from "components/common/DataBlock" import shortenHex from "utils/shortenHex" +import { Chain } from "wagmiConfig/chains" import useMirrorEdition from "./hooks/useMirrorEdition" const MirrorRequirement = (props: RequirementProps): JSX.Element => { const requirement = useRequirementContext() + // TODO: we could remove the cast once we'll have schemas for this requirement + const requirementChain = requirement.chain as Chain + const requirementAddress = requirement.address as `0x${string}` + const { isLoading, name, image, error } = useMirrorEdition( - requirement.address, - requirement.chain + requirementAddress, + requirementChain ) return ( @@ -34,7 +39,7 @@ const MirrorRequirement = (props: RequirementProps): JSX.Element => { isLoading={isLoading} error={error && "API error, please contact Mirror to report"} > - {name ?? shortenHex(requirement.address, 3)} + {name ?? shortenHex(requirementAddress, 3)} {` Mirror edition`} diff --git a/src/requirements/Nft/NftRequirement.tsx b/src/requirements/Nft/NftRequirement.tsx index a11b11e369..afa80692c4 100644 --- a/src/requirements/Nft/NftRequirement.tsx +++ b/src/requirements/Nft/NftRequirement.tsx @@ -19,6 +19,7 @@ import useSWRImmutable from "swr/immutable" import { Trait } from "types" import { GUILD_PIN_CONTRACTS } from "utils/guildCheckout/constants" import shortenHex from "utils/shortenHex" +import { Chain } from "wagmiConfig/chains" import useNftMetadata, { NOUNS_BACKGROUNDS, useNftMetadataWithTraits, @@ -42,9 +43,13 @@ const getNounsRequirementType = (trait: Trait) => const NftRequirement = (props: RequirementProps) => { const requirement = useRequirementContext() + // TODO: we could remove the cast once we'll have schemas for "ERC..." requirements + const requirementChain = requirement.chain as Chain + const requirementAddress = requirement.address as `0x${string}` + // This is a really basic solution, and it'll only handle the "Joined Guild" NFTs. We should probably think about a better solution in the future. const isGuildPin = - GUILD_PIN_CONTRACTS[requirement.chain] === requirement.address.toLowerCase() + GUILD_PIN_CONTRACTS[requirementChain] === requirementAddress.toLowerCase() const guildIdAttribute = isGuildPin && @@ -59,10 +64,10 @@ const NftRequirement = (props: RequirementProps) => { const { name: guildPinGuildName } = useGuild(guildIdAttribute ?? "") const { metadata: metadataWithTraits, isLoading: isMetadataWithTraitsLoading } = - useNftMetadata(requirement.chain, requirement.address, requirement.data?.id) + useNftMetadata(requirementChain, requirementAddress, requirement.data?.id) const { metadata, isLoading } = useNftMetadataWithTraits( - requirement.chain, - requirement.address + requirementChain, + requirementAddress ) const nftDataLoading = isLoading || isMetadataWithTraitsLoading @@ -83,7 +88,7 @@ const NftRequirement = (props: RequirementProps) => { : metadataWithTraits?.image || metadata?.image const shouldRenderImage = - ["ETHEREUM", "POLYGON"].includes(requirement.chain) && + ["ETHEREUM", "POLYGON"].includes(requirementChain) && (nftName || (requirement.name && requirement.name !== "-")) && (nftDataLoading || nftImage) @@ -129,7 +134,7 @@ const NftRequirement = (props: RequirementProps) => { {nftName || (!requirement.name || requirement.name === "-" ? metadata?.slug ?? ( - {shortenHex(requirement.address, 3)} + {shortenHex(requirementAddress, 3)} ) : requirement.name !== "-" && requirement.name)} diff --git a/src/requirements/Nft/providedValue/NftAmountProvidedValue.tsx b/src/requirements/Nft/providedValue/NftAmountProvidedValue.tsx index 75765f02fd..6a5c2f771f 100644 --- a/src/requirements/Nft/providedValue/NftAmountProvidedValue.tsx +++ b/src/requirements/Nft/providedValue/NftAmountProvidedValue.tsx @@ -4,6 +4,7 @@ import DataBlock from "components/common/DataBlock" import { ProvidedValueDisplayProps } from "requirements" import { GUILD_PIN_CONTRACTS } from "utils/guildCheckout/constants" import useNftMetadata, { useNftMetadataWithTraits } from "../hooks/useNftMetadata" +import { Chain } from "wagmiConfig/chains" export function hasOnlyTypeProperty(obj) { const keys = Object.keys(obj) @@ -11,8 +12,12 @@ export function hasOnlyTypeProperty(obj) { } const NftAmountProvidedValue = ({ requirement }: ProvidedValueDisplayProps) => { + // TODO: we could remove the cast once we'll have schemas for "ERC..." requirements + const requirementChain = requirement.chain as Chain + const requirementAddress = requirement.address as `0x${string}` + const isGuildPin = - GUILD_PIN_CONTRACTS[requirement.chain] === requirement?.address?.toLowerCase() + GUILD_PIN_CONTRACTS[requirementChain] === requirement?.address?.toLowerCase() const guildIdAttribute = isGuildPin && requirement.data?.attributes?.find((attr) => attr.trait_type === "guildId") @@ -21,14 +26,11 @@ const NftAmountProvidedValue = ({ requirement }: ProvidedValueDisplayProps) => { const { name: guildPinGuildName } = useGuild(guildIdAttribute ?? "") const { metadata: metadataWithTraits } = useNftMetadata( - requirement.chain, - requirement.address, + requirementChain, + requirementAddress, requirement.data?.id ) - const { metadata } = useNftMetadataWithTraits( - requirement.chain, - requirement.address - ) + const { metadata } = useNftMetadataWithTraits(requirementChain, requirementAddress) const nftName = isGuildPin ? ( <> diff --git a/src/requirements/Payment/PaymentRequirement.tsx b/src/requirements/Payment/PaymentRequirement.tsx index 035870beb4..2a75820173 100644 --- a/src/requirements/Payment/PaymentRequirement.tsx +++ b/src/requirements/Payment/PaymentRequirement.tsx @@ -27,14 +27,14 @@ const PaymentRequirement = (props: RequirementProps): JSX.Element => { chain, address, data: requirementData, - } = useRequirementContext() + } = useRequirementContext<"PAYMENT">() const { token, fee, multiplePayments, isLoading: isVaultLoading, error: vaultError, - } = useVault(address, requirementData?.id, chain) + } = useVault(address as `0x${string}`, requirementData?.id, chain) const isNativeCurrency = token === NULL_ADDRESS diff --git a/src/requirements/Payment/components/WithdrawButton/WithdrawButton.tsx b/src/requirements/Payment/components/WithdrawButton/WithdrawButton.tsx index e2abdc918f..d6a611224e 100644 --- a/src/requirements/Payment/components/WithdrawButton/WithdrawButton.tsx +++ b/src/requirements/Payment/components/WithdrawButton/WithdrawButton.tsx @@ -12,7 +12,12 @@ import { CHAIN_CONFIG, Chains } from "wagmiConfig/chains" import useWithdraw from "./hooks/useWithdraw" const WithdrawButton = (): JSX.Element => { - const { address: vaultAddress, chain, data } = useRequirementContext() + const { + address: vaultAddressAsString, + chain, + data, + } = useRequirementContext<"PAYMENT">() + const vaultAddress = vaultAddressAsString as `0x${string}` const { owner, token, balance } = useVault(vaultAddress, data?.id, chain) const { data: { symbol, decimals }, @@ -28,7 +33,7 @@ const WithdrawButton = (): JSX.Element => { const { onSubmitTransaction, isPreparing, isLoading, error } = useWithdraw( vaultAddress, - data?.id, + +data.id, chain ) diff --git a/src/requirements/Token/TokenRequirement.tsx b/src/requirements/Token/TokenRequirement.tsx index 70fa4a3d7c..b93b448101 100644 --- a/src/requirements/Token/TokenRequirement.tsx +++ b/src/requirements/Token/TokenRequirement.tsx @@ -9,20 +9,24 @@ import Requirement, { import RequirementChainIndicator from "components/[guild]/Requirements/components/RequirementChainIndicator" import { useRequirementContext } from "components/[guild]/Requirements/components/RequirementContext" import useTokenData from "hooks/useTokenData" -import { CHAIN_CONFIG } from "wagmiConfig/chains" +import { Chain, CHAIN_CONFIG } from "wagmiConfig/chains" type Props = RequirementProps const TokenRequirement = ({ ...rest }: Props) => { const requirement = useRequirementContext() - const { data, isValidating } = useTokenData(requirement.chain, requirement.address) + // TODO: we could remove the cast once we'll have schemas for "ERC..." requirements + const requirementChain = requirement.chain as Chain + const requirementAddress = requirement.address as `0x${string}` + + const { data, isValidating } = useTokenData(requirementChain, requirementAddress) return ( ERC20 @@ -53,7 +57,7 @@ const TokenRequirement = ({ ...rest }: Props) => { : "any amount of" } ${ requirement.type === "COIN" - ? CHAIN_CONFIG[requirement.chain].nativeCurrency.symbol + ? CHAIN_CONFIG[requirementChain].nativeCurrency.symbol : data?.symbol ?? requirement.symbol }`} diff --git a/src/requirements/Token/providedValue/TokenProvidedValue.tsx b/src/requirements/Token/providedValue/TokenProvidedValue.tsx index 8e339986d0..3443843b02 100644 --- a/src/requirements/Token/providedValue/TokenProvidedValue.tsx +++ b/src/requirements/Token/providedValue/TokenProvidedValue.tsx @@ -3,11 +3,16 @@ import RequirementChainIndicator from "components/[guild]/Requirements/component import useTokenData from "hooks/useTokenData" import { ProvidedValueDisplayProps } from "requirements" import { NULL_ADDRESS } from "utils/guildCheckout/constants" +import { Chain } from "wagmiConfig/chains" const TokenProvidedValue = ({ requirement }: ProvidedValueDisplayProps) => { + // TODO: we could remove the cast once we'll have schemas for "ERC..." requirements + const requirementChain = requirement.chain as Chain + const requirementAddress = requirement.address as `0x${string}` + const { data: { symbol }, - } = useTokenData(requirement?.chain, requirement?.address ?? NULL_ADDRESS) + } = useTokenData(requirementChain, requirementAddress ?? NULL_ADDRESS) const tagBg = useColorModeValue("blackAlpha.100", "blackAlpha.300") diff --git a/src/requirements/Uniswap/UniswapRequirement.tsx b/src/requirements/Uniswap/UniswapRequirement.tsx index 64c05b6b84..3087c4a47a 100644 --- a/src/requirements/Uniswap/UniswapRequirement.tsx +++ b/src/requirements/Uniswap/UniswapRequirement.tsx @@ -1,5 +1,5 @@ import { HStack, Skeleton } from "@chakra-ui/react" -import { Schemas, consts } from "@guildxyz/types" +import { consts } from "@guildxyz/types" import Requirement, { RequirementProps, } from "components/[guild]/Requirements/components/Requirement" @@ -40,10 +40,7 @@ const UniswapRequirement = ({ ...rest }: RequirementProps): JSX.Element => { }, roleId, id, - } = useRequirementContext() as Extract< - Schemas["Requirement"], - { type: "UNISWAP_V3_POSITIONS" } - > + } = useRequirementContext<"UNISWAP_V3_POSITIONS">() const { symbol0, symbol1 } = useSymbolsOfPair( Chains[chain], diff --git a/src/requirements/WalletActivity/WalletActivityRequirement.tsx b/src/requirements/WalletActivity/WalletActivityRequirement.tsx index 2b4b1824ed..6e249dc6d6 100644 --- a/src/requirements/WalletActivity/WalletActivityRequirement.tsx +++ b/src/requirements/WalletActivity/WalletActivityRequirement.tsx @@ -27,7 +27,16 @@ const requirementIcons: Record< } const WalletActivityRequirement = (props: RequirementProps): JSX.Element => { - const requirement = useRequirementContext() + const requirement = useRequirementContext< + | "COVALENT_FIRST_TX" + | "COVALENT_FIRST_TX_RELATIVE" + | "COVALENT_CONTRACT_DEPLOY" + | "COVALENT_CONTRACT_DEPLOY_RELATIVE" + | "COVALENT_TX_COUNT" + | "COVALENT_TX_COUNT_RELATIVE" + | "COVALENT_TX_VALUE" + | "COVALENT_TX_VALUE_RELATIVE" + >() const maxAmount = requirement.data?.timestamps?.maxAmount const minAmount = requirement.data?.timestamps?.minAmount diff --git a/src/requirements/index.ts b/src/requirements/index.ts index e065883810..2a46012186 100644 --- a/src/requirements/index.ts +++ b/src/requirements/index.ts @@ -1,3 +1,4 @@ +import { Schemas } from "@guildxyz/types" import { RequirementProps } from "components/[guild]/Requirements/components/Requirement" import { Icon } from "phosphor-react" import { ComponentType } from "react" @@ -16,8 +17,7 @@ export type ProvidedValueDisplayProps = { requirement: Partial } -const requirementTypes = REQUIREMENTS_DATA.flatMap((obj) => obj.types) -export type RequirementType = (typeof requirementTypes)[number] | "HIDDEN" +export type RequirementType = Schemas["Requirement"]["type"] export type RequirementFormProps = { baseFieldPath: string diff --git a/src/types.ts b/src/types.ts index dbe663491c..93af640e75 100644 --- a/src/types.ts +++ b/src/types.ts @@ -1,8 +1,9 @@ -import { FarcasterProfile, Schemas } from "@guildxyz/types" +import { FarcasterProfile, schemas, Schemas, Visibility } from "@guildxyz/types" import { FeatureFlag } from "components/[guild]/EditGuild/components/FeatureFlags" import { ContractCallFunction } from "components/[guild]/RolePlatforms/components/AddRoleRewardModal/components/AddContractCallPanel/components/CreateNftForm/hooks/useCreateNft" import { RequirementType } from "requirements" import type { Chain, Chains } from "wagmiConfig/chains" +import { z } from "zod" export const FUEL_ADDRESS_REGEX = /^0x[a-f0-9]{64}$/i @@ -491,26 +492,10 @@ type Trait = { } } -type Requirement = { - id: number - type: RequirementType - address?: `0x${string}` - chain?: Chain - data?: Record - roleId: number - name: string - symbol: string - decimals?: number - isNegated?: boolean - visibility?: Visibility - visibilityRoleId?: number | null - - // Props used inside the forms on the UI - formFieldId?: number - balancyDecimals?: number - createdAt?: string - updatedAt?: string -} +type Requirement = z.output +type RequirementCreateResponseOutput = z.output< + typeof schemas.RequirementCreateResponseSchema +> type RolePlatformStatus = "ALL_CLAIMED" | "NOT_STARTED" | "ENDED" | "ACTIVE" @@ -532,12 +517,6 @@ type RolePlatform = { dynamicAmount?: Schemas["DynamicAmount"] } -enum Visibility { - PUBLIC = "PUBLIC", - PRIVATE = "PRIVATE", - HIDDEN = "HIDDEN", -} - type SimpleRole = { id: number name: string @@ -636,9 +615,13 @@ type Guild = { parentRoles: number[] } +type RequirementCreationPayloadWithTempID = Schemas["RequirementCreationPayload"] & { + id?: number +} + type RoleFormType = Partial< Omit & { - requirements: Array> + requirements: Array> rolePlatforms: Array< Partial> & { guildPlatform?: GuildPlatformWithOptionalId @@ -791,7 +774,7 @@ type DetailedPinLeaderboardUserData = { pins: LeaderboardPinData[] } -export { ValidationMethod, Visibility, supportedEventSources, supportedSocialLinks } +export { supportedEventSources, supportedSocialLinks, ValidationMethod } export type { BaseUser, CoingeckoToken, @@ -819,6 +802,8 @@ export type { Poap, RequestMintLinksForm, Requirement, + RequirementCreateResponseOutput, + RequirementCreationPayloadWithTempID, RequirementType, Rest, Role, diff --git a/src/utils/formatRelativeTimeFromNow.ts b/src/utils/formatRelativeTimeFromNow.ts index a6a0860aea..2d2deb91c7 100644 --- a/src/utils/formatRelativeTimeFromNow.ts +++ b/src/utils/formatRelativeTimeFromNow.ts @@ -3,7 +3,7 @@ import pluralize from "./pluralize" export const DAY_IN_MS = 86400000 export const MINUTE_IN_MS = 60000 -const formatRelativeTimeFromNow = (since: number) => { +const formatRelativeTimeFromNow = (since?: number) => { if (!since) return undefined const sinceDays = since / DAY_IN_MS diff --git a/src/utils/mapRequirement.ts b/src/utils/mapRequirement.ts index be0b263b8a..2c5f55fc79 100644 --- a/src/utils/mapRequirement.ts +++ b/src/utils/mapRequirement.ts @@ -1,8 +1,10 @@ -import { Requirement } from "types" +import { Requirement, RequirementCreateResponseOutput } from "types" -const mapRequirement = (requirement?: Requirement) => { +const mapRequirement = ( + requirement?: Requirement | RequirementCreateResponseOutput +) => { // Using structuredClone so we don't modify the original requirement unintentionally - const newRequirement: Requirement = structuredClone(requirement) + const newRequirement = structuredClone(requirement) if (requirement.type === "COIN") newRequirement.address = "0x0000000000000000000000000000000000000000" diff --git a/src/utils/preprocessRequirement.ts b/src/utils/preprocessRequirement.ts index 2bc2fe9be8..58233fd31b 100644 --- a/src/utils/preprocessRequirement.ts +++ b/src/utils/preprocessRequirement.ts @@ -1,6 +1,12 @@ +import { Schemas } from "@guildxyz/types" import { Requirement } from "types" -const preprocessRequirement = (requirement: Partial): Requirement => { +const preprocessRequirement = ( + requirement?: + | Partial + | Partial + | Partial +): Requirement => { const processedRequirement: Requirement = structuredClone( requirement ) as Requirement From d3fc7c66dd16f0b0028caf4979688ed5458bea2c Mon Sep 17 00:00:00 2001 From: BrickheadJohnny Date: Wed, 26 Jun 2024 14:53:21 +0200 Subject: [PATCH 24/41] Revert "refactor: remove the custom `Requirement` type (#1318)" This reverts commit 6f603223a01b2376250cddf6f951f033a9993c25. --- package-lock.json | 250 +++++++++--------- package.json | 2 +- .../components/OrderRolesModal.tsx | 3 +- .../AddAndOrderRoles/hooks/useAddRoleForm.ts | 6 +- .../AddRewardButton/AddRewardButton.tsx | 7 +- .../AddRewardButton/SelectRolePanel.tsx | 8 +- .../hooks/useCreateRequirements.ts | 10 +- .../hooks/useMutateAdditionsToRoles.ts | 39 ++- .../hooks/useSubmitAddReward.ts | 8 +- .../AddRewardButton/useCreateTokenReward.ts | 6 +- .../RequirementErrorConfigContext.tsx | 2 +- .../[guild]/Requirements/RoleRequirements.tsx | 2 +- .../components/ActivateGuildPinForm.tsx | 3 +- .../GuildCheckout/components/BuyTotal.tsx | 18 +- .../components/PaymentFeeCurrency.tsx | 4 +- .../components/PurchaseFeeAndTotal.tsx | 11 +- .../components/PurchasedRequirementInfo.tsx | 7 +- .../components/buttons/BuyAllowanceButton.tsx | 8 +- .../components/buttons/BuyButton.tsx | 12 +- .../buttons/PurchaseAllowanceButton.tsx | 8 +- .../GuildCheckout/hooks/usePayFee.ts | 12 +- .../GuildCheckout/hooks/usePurchaseAsset.ts | 2 +- .../Requirements/components/Requirement.tsx | 5 +- .../components/RequirementChainIndicator.tsx | 5 +- .../components/RequirementContext.tsx | 11 +- .../RequirementDisplayComponent.tsx | 2 +- src/components/[guild]/RoleCard/RoleCard.tsx | 7 +- .../EditRole/hooks/useEditRoleForm.ts | 5 +- .../hooks/useUpdateRolePlatformVisibility.ts | 3 +- .../components/SelectExistingPlatform.tsx | 10 +- src/components/[guild]/Roles.tsx | 9 +- .../[guild]/SetVisibility/SetVisibility.tsx | 4 +- .../components/VisibilityTag.tsx | 2 +- .../hooks/useVisibilityTooltipLabel.tsx | 6 +- .../[guild]/SetVisibility/visibilityData.tsx | 8 +- src/components/[guild]/Visibility.tsx | 4 +- .../crm/FilterByRoles/FilterByRoles.tsx | 6 +- .../components/AddHiddenRoleButton.tsx | 3 +- .../components/SetHiddenRoleRequirements.tsx | 3 +- src/components/[guild]/crm/RoleTags.tsx | 4 +- src/components/[guild]/crm/useMembers.tsx | 10 +- src/components/[guild]/messages/Message.tsx | 5 +- .../BasicInfo/components/ContactInfo.tsx | 4 +- .../components/AddRequirement.tsx | 31 ++- .../ExistingRequirementEditableCard.tsx | 10 +- .../components/RequirementEditableCard.tsx | 7 +- .../Requirements/hooks/useBalancy.ts | 3 +- .../hooks/useCreateRequirement.ts | 15 +- .../Requirements/hooks/useEditRequirement.ts | 29 +- .../hooks/useHandleRequirementState.ts | 2 +- .../create-guild/hooks/useCreateRole.tsx | 10 +- src/hooks/useSubmitTransaction.ts | 5 +- src/pages/[guild]/members.tsx | 3 +- .../SelectRoleOrSetRequirements.tsx | 4 +- .../Airdrop/AirdropRequirement.tsx | 6 +- .../Allowlist/AllowlistRequirement.tsx | 17 +- .../Farcaster/FarcasterRequirement.tsx | 12 +- src/requirements/Fuel/FuelRequirement.tsx | 13 +- src/requirements/Lens/LensRequirement.tsx | 4 +- src/requirements/Lens/hooks/useLensProfile.ts | 2 +- .../Lens/hooks/useLensProfiles.ts | 4 +- src/requirements/Mirror/MirrorRequirement.tsx | 11 +- src/requirements/Nft/NftRequirement.tsx | 17 +- .../providedValue/NftAmountProvidedValue.tsx | 16 +- .../Payment/PaymentRequirement.tsx | 4 +- .../WithdrawButton/WithdrawButton.tsx | 9 +- src/requirements/Token/TokenRequirement.tsx | 12 +- .../providedValue/TokenProvidedValue.tsx | 7 +- .../Uniswap/UniswapRequirement.tsx | 7 +- .../WalletActivityRequirement.tsx | 11 +- src/requirements/index.ts | 4 +- src/types.ts | 43 ++- src/utils/formatRelativeTimeFromNow.ts | 2 +- src/utils/mapRequirement.ts | 8 +- src/utils/preprocessRequirement.ts | 8 +- 75 files changed, 411 insertions(+), 469 deletions(-) diff --git a/package-lock.json b/package-lock.json index 3037a660d3..1b7e4c8233 100644 --- a/package-lock.json +++ b/package-lock.json @@ -19,7 +19,7 @@ "@emotion/styled": "^11.11.0", "@fuels/connectors": "^0.5.0", "@fuels/react": "^0.20.0", - "@guildxyz/types": "1.9.24", + "@guildxyz/types": "1.9.23", "@hcaptcha/react-hcaptcha": "^1.4.4", "@hookform/resolvers": "^3.3.4", "@lexical/code": "^0.12.0", @@ -4618,17 +4618,17 @@ } }, "node_modules/@floating-ui/core": { - "version": "1.6.3", - "resolved": "https://registry.npmjs.org/@floating-ui/core/-/core-1.6.3.tgz", - "integrity": "sha512-1ZpCvYf788/ZXOhRQGFxnYQOVgeU+pi0i+d0Ow34La7qjIXETi6RNswGVKkA6KcDO8/+Ysu2E/CeUmmeEBDvTg==", + "version": "1.6.2", + "resolved": "https://registry.npmjs.org/@floating-ui/core/-/core-1.6.2.tgz", + "integrity": "sha512-+2XpQV9LLZeanU4ZevzRnGFg2neDeKHgFLjP6YLW+tly0IvrhqT4u8enLGjLH3qeh85g19xY5rsAusfwTdn5lg==", "dependencies": { - "@floating-ui/utils": "^0.2.3" + "@floating-ui/utils": "^0.2.0" } }, "node_modules/@floating-ui/core/node_modules/@floating-ui/utils": { - "version": "0.2.3", - "resolved": "https://registry.npmjs.org/@floating-ui/utils/-/utils-0.2.3.tgz", - "integrity": "sha512-XGndio0l5/Gvd6CLIABvsav9HHezgDFFhDfHk1bvLfr9ni8dojqLSvBbotJEjmIwNHL7vK4QzBJTdBRoB+c1ww==" + "version": "0.2.2", + "resolved": "https://registry.npmjs.org/@floating-ui/utils/-/utils-0.2.2.tgz", + "integrity": "sha512-J4yDIIthosAsRZ5CPYP/jQvUAQtlZTTD/4suA08/FEnlxqW3sKS9iAhgsa9VYLZ6vDHn/ixJgIqRQPotoBjxIw==" }, "node_modules/@floating-ui/dom": { "version": "1.5.1", @@ -5192,9 +5192,9 @@ } }, "node_modules/@guildxyz/types": { - "version": "1.9.24", - "resolved": "https://registry.npmjs.org/@guildxyz/types/-/types-1.9.24.tgz", - "integrity": "sha512-tNy2i/KqbXU+UwDGLijaWXEDXqGmbKeKpANpTCvQ93AVCazvrrEp+359JaDJCJVv94Mzc0mTQgow6xiHgHcLFQ==", + "version": "1.9.23", + "resolved": "https://registry.npmjs.org/@guildxyz/types/-/types-1.9.23.tgz", + "integrity": "sha512-fRCBcDaqr6YFpTZPY7imy8/q1I7MC8jjej3LGNkeN31wwcJmULjOAbQz43C6kff3AMizjUfX2aP2BZnSC7MXjA==", "dependencies": { "zod": "^3.22.4" } @@ -6387,14 +6387,14 @@ } }, "node_modules/@metamask/sdk": { - "version": "0.26.3", - "resolved": "https://registry.npmjs.org/@metamask/sdk/-/sdk-0.26.3.tgz", - "integrity": "sha512-DM4BFPr1BDAIhTz7/RWb3oWQRvX79TJVZH8EL/Ljp+CRY7IjCbaVwaLdyQjVd8Doyq1V7AL4N/JjXplpo2YyYg==", + "version": "0.20.5", + "resolved": "https://registry.npmjs.org/@metamask/sdk/-/sdk-0.20.5.tgz", + "integrity": "sha512-BEL3BKbb0O09QgOzvyPH5xUONl2uicS9WT1AYhZ8yR4ytz5fhyHWJzs8Q/cwgm1qIdn3eumnjXfgA6pKirWa3A==", "dependencies": { "@metamask/onboarding": "^1.0.1", "@metamask/providers": "^15.0.0", - "@metamask/sdk-communication-layer": "0.26.2", - "@metamask/sdk-install-modal-web": "0.26.0", + "@metamask/sdk-communication-layer": "0.20.5", + "@metamask/sdk-install-modal-web": "0.20.4", "@types/dom-screen-wake-lock": "^1.0.0", "bowser": "^2.9.0", "cross-fetch": "^4.0.0", @@ -6428,9 +6428,9 @@ } }, "node_modules/@metamask/sdk-communication-layer": { - "version": "0.26.2", - "resolved": "https://registry.npmjs.org/@metamask/sdk-communication-layer/-/sdk-communication-layer-0.26.2.tgz", - "integrity": "sha512-YMqwjhCZ4sXYAsEp1LxLrZZycBwpUeEsA4yIx48m1yW9sZ8pv3NGnbjM+F0zf29DLjyqLxJdxHJ7b5YkgtB26g==", + "version": "0.20.5", + "resolved": "https://registry.npmjs.org/@metamask/sdk-communication-layer/-/sdk-communication-layer-0.20.5.tgz", + "integrity": "sha512-Y3pzg1GBB7tDUCUsyhvlhxQ+h/pDrTjO2yUwjCJj2S8Nx5OtdRv/foRGfbDHkfYt6Z9ANRfivWU2U6El17B24A==", "dependencies": { "bufferutil": "^4.0.8", "date-fns": "^2.29.3", @@ -6447,9 +6447,9 @@ } }, "node_modules/@metamask/sdk-install-modal-web": { - "version": "0.26.0", - "resolved": "https://registry.npmjs.org/@metamask/sdk-install-modal-web/-/sdk-install-modal-web-0.26.0.tgz", - "integrity": "sha512-LyDQFIsWWyU0ZgZR3O9LzRqKzXcYUEGJRCNfb26IjFOquvmQosbhQV0jDNlVa8Tk2Fg4ykTPoaauANh6sVJYVQ==", + "version": "0.20.4", + "resolved": "https://registry.npmjs.org/@metamask/sdk-install-modal-web/-/sdk-install-modal-web-0.20.4.tgz", + "integrity": "sha512-AX3mTr0IDpS0ajV83okTaixG+2wIxTVbgvEuQgAj2Ed7PWAdiZ1aX93AVcaCgkOWhTf267z7mXCSuBDpBCje9g==", "dependencies": { "qr-code-styling": "^1.6.0-rc.1" }, @@ -7513,9 +7513,9 @@ } }, "node_modules/@radix-ui/react-dialog": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/@radix-ui/react-dialog/-/react-dialog-1.1.1.tgz", - "integrity": "sha512-zysS+iU4YP3STKNS6USvFVqI4qqx8EpiwmT5TuCApVEBca+eRCbONi4EgzfNSuVnOXvC5UPHHMjs8RXO6DH9Bg==", + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@radix-ui/react-dialog/-/react-dialog-1.1.0.tgz", + "integrity": "sha512-oiSJcsjbdC8JqbXrOuhOd7oaEaPp3x2L2zn6V7ie6SSpEjrAha/WabDX4po6laGwbhAu9DT0XxHL0DmcIXrR0A==", "dependencies": { "@radix-ui/primitive": "1.1.0", "@radix-ui/react-compose-refs": "1.1.0", @@ -7524,7 +7524,7 @@ "@radix-ui/react-focus-guards": "1.1.0", "@radix-ui/react-focus-scope": "1.1.0", "@radix-ui/react-id": "1.1.0", - "@radix-ui/react-portal": "1.1.1", + "@radix-ui/react-portal": "1.1.0", "@radix-ui/react-presence": "1.1.0", "@radix-ui/react-primitive": "2.0.0", "@radix-ui/react-slot": "1.1.0", @@ -7658,12 +7658,11 @@ } }, "node_modules/@radix-ui/react-portal": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/@radix-ui/react-portal/-/react-portal-1.1.1.tgz", - "integrity": "sha512-A3UtLk85UtqhzFqtoC8Q0KvR2GbXF3mtPgACSazajqq6A41mEQgo53iPzY4i6BwDxlIFqWIhiQ2G729n+2aw/g==", + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@radix-ui/react-portal/-/react-portal-1.1.0.tgz", + "integrity": "sha512-0tXZ5O6qAVvuN9SWP0X+zadHf9hzHiMf/vxOU+kXO+fbtS8lS57MXa6EmikDxk9s/Bmkk80+dcxgbvisIyeqxg==", "dependencies": { - "@radix-ui/react-primitive": "2.0.0", - "@radix-ui/react-use-layout-effect": "1.1.0" + "@radix-ui/react-primitive": "2.0.0" }, "peerDependencies": { "@types/react": "*", @@ -9575,9 +9574,9 @@ } }, "node_modules/@rnx-kit/chromium-edge-launcher/node_modules/@types/node": { - "version": "18.19.39", - "resolved": "https://registry.npmjs.org/@types/node/-/node-18.19.39.tgz", - "integrity": "sha512-nPwTRDKUctxw3di5b4TfT3I0sWDiWoPQCZjXhvdkINntwr8lcoVCKsTgnXeRubKIlfnV+eN/HYk6Jb40tbcEAQ==", + "version": "18.19.37", + "resolved": "https://registry.npmjs.org/@types/node/-/node-18.19.37.tgz", + "integrity": "sha512-Pi53fdVMk7Ig5IfAMltQQMgtY7xLzHaEous8IQasYsdQbYK3v90FkxI3XYQCe/Qme58pqp14lXJIsFmGP8VoZQ==", "peer": true, "dependencies": { "undici-types": "~5.26.4" @@ -9741,9 +9740,9 @@ } }, "node_modules/@safe-global/safe-gateway-typescript-sdk": { - "version": "3.21.6", - "resolved": "https://registry.npmjs.org/@safe-global/safe-gateway-typescript-sdk/-/safe-gateway-typescript-sdk-3.21.6.tgz", - "integrity": "sha512-S3OZ8Alya7N7Iie6KvVSbrp9Ev30cQZtpqvP4zkaWlWBG6W7XE3gYC/8GohmQ9E3BOYtYa1xfDupKRgSO9RfTw==", + "version": "3.21.4", + "resolved": "https://registry.npmjs.org/@safe-global/safe-gateway-typescript-sdk/-/safe-gateway-typescript-sdk-3.21.4.tgz", + "integrity": "sha512-BCY+7RtCfjkGO8X6crBRqlXPqAGM/0Ki/k0PWLYxV3IGmwM6ah2qFGkpp1omWQsdILdiKWxsmIKiderAWOyLjA==", "engines": { "node": ">=16" } @@ -10290,20 +10289,20 @@ } }, "node_modules/@tanstack/query-core": { - "version": "5.48.0", - "resolved": "https://registry.npmjs.org/@tanstack/query-core/-/query-core-5.48.0.tgz", - "integrity": "sha512-lZAfPPeVIqXCswE9SSbG33B6/91XOWt/Iq41bFeWb/mnHwQSIfFRbkS4bfs+WhIk9abRArF9Id2fp0Mgo+hq6Q==", + "version": "5.45.0", + "resolved": "https://registry.npmjs.org/@tanstack/query-core/-/query-core-5.45.0.tgz", + "integrity": "sha512-RVfIZQmFUTdjhSAAblvueimfngYyfN6HlwaJUPK71PKd7yi43Vs1S/rdimmZedPWX/WGppcq/U1HOj7O7FwYxw==", "funding": { "type": "github", "url": "https://github.com/sponsors/tannerlinsley" } }, "node_modules/@tanstack/react-query": { - "version": "5.48.0", - "resolved": "https://registry.npmjs.org/@tanstack/react-query/-/react-query-5.48.0.tgz", - "integrity": "sha512-GDExbjYWzvDokyRqMSWXdrPiYpp95Aig0oeMIrxTaruOJJgWiWfUP//OAaowm2RrRkGVsavSZdko/XmIrrV2Nw==", + "version": "5.45.1", + "resolved": "https://registry.npmjs.org/@tanstack/react-query/-/react-query-5.45.1.tgz", + "integrity": "sha512-mYYfJujKg2kxmkRRjA6nn4YKG3ITsKuH22f1kteJ5IuVQqgKUgbaSQfYwVP0gBS05mhwxO03HVpD0t7BMN7WOA==", "dependencies": { - "@tanstack/query-core": "5.48.0" + "@tanstack/query-core": "5.45.0" }, "funding": { "type": "github", @@ -10333,11 +10332,11 @@ } }, "node_modules/@tanstack/react-virtual": { - "version": "3.7.0", - "resolved": "https://registry.npmjs.org/@tanstack/react-virtual/-/react-virtual-3.7.0.tgz", - "integrity": "sha512-3RtOwEU1HKS4iFBoTcCrV3Szqt4KoERMhZr8v57dvnh5o70sR9GAdF+0aE/qhiOmePrKujGwAayFNJSr/8Dbqw==", + "version": "3.5.1", + "resolved": "https://registry.npmjs.org/@tanstack/react-virtual/-/react-virtual-3.5.1.tgz", + "integrity": "sha512-jIsuhfgy8GqA67PdWqg73ZB2LFE+HD9hjWL1L6ifEIZVyZVAKpYmgUG4WsKQ005aEyImJmbuimPiEvc57IY0Aw==", "dependencies": { - "@tanstack/virtual-core": "3.7.0" + "@tanstack/virtual-core": "3.5.1" }, "funding": { "type": "github", @@ -10361,9 +10360,9 @@ } }, "node_modules/@tanstack/virtual-core": { - "version": "3.7.0", - "resolved": "https://registry.npmjs.org/@tanstack/virtual-core/-/virtual-core-3.7.0.tgz", - "integrity": "sha512-p0CWuqn+n8iZmsL7/l0Xg7kbyIKnHNqkEJkMDOkg4x3Ni3LohszmnJY8FPhTgG7Ad9ZFGcdKmn1R1mKUGEh9Xg==", + "version": "3.5.1", + "resolved": "https://registry.npmjs.org/@tanstack/virtual-core/-/virtual-core-3.5.1.tgz", + "integrity": "sha512-046+AUSiDru/V9pajE1du8WayvBKeCvJ2NmKPy/mR8/SbKKrqmSbj7LJBfXE+nSq4f5TBXvnCzu0kcYebI9WdQ==", "funding": { "type": "github", "url": "https://github.com/sponsors/tannerlinsley" @@ -10606,9 +10605,9 @@ "integrity": "sha512-nG96G3Wp6acyAgJqGasjODb+acrI7KltPiRxzHPXnP3NgI28bpQDRv53olbqGXbfcgF5aiiHmO3xpwEpS5Ld9g==" }, "node_modules/@types/node": { - "version": "20.14.9", - "resolved": "https://registry.npmjs.org/@types/node/-/node-20.14.9.tgz", - "integrity": "sha512-06OCtnTXtWOZBJlRApleWndH4JsRVs1pDCc8dLSQp+7PpUpX3ePdHyeNSFTeSe7FtKyQkrlPvHwJOW3SLd8Oyg==", + "version": "20.14.6", + "resolved": "https://registry.npmjs.org/@types/node/-/node-20.14.6.tgz", + "integrity": "sha512-JbA0XIJPL1IiNnU7PFxDXyfAwcwVVrOoqyzzyQTyMeVhBzkJVMSkC1LlVsRQ2lpqiY4n6Bb9oCS6lzDKVQxbZw==", "dependencies": { "undici-types": "~5.26.4" } @@ -11329,12 +11328,12 @@ } }, "node_modules/@wagmi/connectors": { - "version": "5.0.19", - "resolved": "https://registry.npmjs.org/@wagmi/connectors/-/connectors-5.0.19.tgz", - "integrity": "sha512-yd0pkM3I7sJuIZf1lIiwxDApaWg5ZSFiN3ociM50SkcoWDAWAKcCWWP0FbaCZ4KT+TZQJEIqBpfk6eZ9mBAddQ==", + "version": "5.0.15", + "resolved": "https://registry.npmjs.org/@wagmi/connectors/-/connectors-5.0.15.tgz", + "integrity": "sha512-eQnsVfe1tX7g3pFPDg3sWjCdggTE+4C0z9g700h/pgUTNSJGnMRU+avTZqkewHFUkUkAhSk/tm1BZ4wfr6Wwfg==", "dependencies": { "@coinbase/wallet-sdk": "4.0.3", - "@metamask/sdk": "0.26.3", + "@metamask/sdk": "0.20.5", "@safe-global/safe-apps-provider": "0.18.1", "@safe-global/safe-apps-sdk": "8.1.0", "@walletconnect/ethereum-provider": "2.13.0", @@ -11345,7 +11344,7 @@ "url": "https://github.com/sponsors/wevm" }, "peerDependencies": { - "@wagmi/core": "2.11.5", + "@wagmi/core": "2.11.3", "typescript": ">=5.0.4", "viem": "2.x" }, @@ -11356,9 +11355,9 @@ } }, "node_modules/@wagmi/core": { - "version": "2.11.5", - "resolved": "https://registry.npmjs.org/@wagmi/core/-/core-2.11.5.tgz", - "integrity": "sha512-RmtZQkNf/ozdngyDST33WLTdKQHny9SsiNmxln8G06pbnOuhO4dDhnXnfiJ8Lh9GVIfFsjlmtqzfAIo1/86dqg==", + "version": "2.11.3", + "resolved": "https://registry.npmjs.org/@wagmi/core/-/core-2.11.3.tgz", + "integrity": "sha512-RxjjyDDmUehAy1CBJgSGzbnsbAAbaOrGwemsTXR7ru5dak+4lQ3Swx4Ikm1aPlxjSZbNy6c/epyidnkun9qzMQ==", "dependencies": { "eventemitter3": "5.0.1", "mipd": "0.0.5", @@ -13031,9 +13030,10 @@ "integrity": "sha512-wjkjR4ItpkCKnlN0JNkhoLutRf1yHTaGV1qEy1Z9tzkyfJmP/2jqwcCR1cWWxM/+iFE2UJd7Ea7CNgCWwFnvFw==" }, "node_modules/abitype": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/abitype/-/abitype-1.0.4.tgz", - "integrity": "sha512-UivtYZOGJGE8rsrM/N5vdRkUpqEZVmuTumfTuolm7m/6O09wprd958rx8kUBwVAAAhQDveGAgD0GJdBuR8s6tw==", + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/abitype/-/abitype-1.0.3.tgz", + "integrity": "sha512-8EyPgBBHMtW56OslHWHJ4HEjU+2snjxibmwNjV2aBJp4oDfx1DcxO8sQ4jkxo/Iu6oQ79c6/ihsrBE2nBMlURg==", + "dev": true, "funding": { "url": "https://github.com/sponsors/wevm" }, @@ -14302,9 +14302,9 @@ } }, "node_modules/caniuse-lite": { - "version": "1.0.30001637", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001637.tgz", - "integrity": "sha512-1x0qRI1mD1o9e+7mBI7XtzFAP4XszbHaVWsMiGbSPLYekKTJF7K+FNk6AsXH4sUpc+qrsI3pVgf1Jdl/uGkuSQ==", + "version": "1.0.30001636", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001636.tgz", + "integrity": "sha512-bMg2vmr8XBsbL6Lr0UHXy/21m84FTxDLWn2FSqMd5PrlbMxwJlQnC2YWYxVgp66PZE+BBNF2jYQUBKCo1FDeZg==", "funding": [ { "type": "opencollective", @@ -16182,9 +16182,9 @@ "peer": true }, "node_modules/electron-to-chromium": { - "version": "1.4.812", - "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.812.tgz", - "integrity": "sha512-7L8fC2Ey/b6SePDFKR2zHAy4mbdp1/38Yk5TsARO66W3hC5KEaeKMMHoxwtuH+jcu2AYLSn9QX04i95t6Fl1Hg==" + "version": "1.4.807", + "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.807.tgz", + "integrity": "sha512-kSmJl2ZwhNf/bcIuCH/imtNOKlpkLDn2jqT5FJ+/0CXjhnFaOa9cOe9gHKKy71eM49izwuQjZhKk+lWQ1JxB7A==" }, "node_modules/elliptic": { "version": "6.5.4", @@ -16476,9 +16476,9 @@ } }, "node_modules/es-module-lexer": { - "version": "1.5.4", - "resolved": "https://registry.npmjs.org/es-module-lexer/-/es-module-lexer-1.5.4.tgz", - "integrity": "sha512-MVNK56NiMrOwitFB7cqDwq0CQutbw+0BvLshJSse0MUNU+y1FC3bUS/AQg7oUng+/wKrrki7JfmwtVHkVfPLlw==", + "version": "1.5.3", + "resolved": "https://registry.npmjs.org/es-module-lexer/-/es-module-lexer-1.5.3.tgz", + "integrity": "sha512-i1gCgmR9dCl6Vil6UKPI/trA69s08g/syhiDK9TG0Nf1RJjjFI+AzoWW7sPufzkgYAn861skuCwJa0pIIHYxvg==", "dev": true, "peer": true }, @@ -17722,9 +17722,9 @@ "peer": true }, "node_modules/flow-parser": { - "version": "0.238.2", - "resolved": "https://registry.npmjs.org/flow-parser/-/flow-parser-0.238.2.tgz", - "integrity": "sha512-fs7FSnzzKF6oSzjk14JlBHt82DPchYHVsXtPi4Fkn+qrunVjWaBZY7nSO/mC9X4l9+wRah/R69DRd5NGDOrWqw==", + "version": "0.238.0", + "resolved": "https://registry.npmjs.org/flow-parser/-/flow-parser-0.238.0.tgz", + "integrity": "sha512-VE7XSv1epljsIN2YeBnxCmGJihpNIAnLLu/pPOdA+Gkso7qDltJwUi6vfHjgxdBbjSdAuPGnhuOHJUQG+yYwIg==", "peer": true, "engines": { "node": ">=0.4.0" @@ -18242,9 +18242,9 @@ } }, "node_modules/glob/node_modules/minimatch": { - "version": "9.0.5", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.5.tgz", - "integrity": "sha512-G6T0ZX48xgozx7587koeX9Ys2NYy6Gmv//P89sEte9V9whIapMNF4idKxnW2QtCcLiTWlb/wfCabAtAFWhhBow==", + "version": "9.0.4", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.4.tgz", + "integrity": "sha512-KqWh+VchfxcMNRAJjj2tnsSJdNbHsVgnkBhTNrW7AjVo6OvLtxw8zfT9oLw1JSohlFzJ8jCoTgaoXvJ+kHt6fw==", "dependencies": { "brace-expansion": "^2.0.1" }, @@ -18337,9 +18337,9 @@ "dev": true }, "node_modules/graphql": { - "version": "16.9.0", - "resolved": "https://registry.npmjs.org/graphql/-/graphql-16.9.0.tgz", - "integrity": "sha512-GGTKBX4SD7Wdb8mqeDLni2oaRGYQWjWHGKPQ24ZMnUtKfcsVoiv4uX8+LJr1K6U5VW2Lu1BwJnj7uiori0YtRw==", + "version": "16.8.2", + "resolved": "https://registry.npmjs.org/graphql/-/graphql-16.8.2.tgz", + "integrity": "sha512-cvVIBILwuoSyD54U4cF/UXDh5yAobhNV/tPygI4lZhgOIJQE/WLWC4waBRb4I6bDVYb3OVx3lfHbaQOEoUD5sg==", "engines": { "node": "^12.22.0 || ^14.16.0 || ^16.0.0 || >=17.0.0" } @@ -19018,14 +19018,11 @@ } }, "node_modules/is-core-module": { - "version": "2.14.0", - "resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.14.0.tgz", - "integrity": "sha512-a5dFJih5ZLYlRtDc0dZWP7RiKr6xIKzmn/oAYCDvdLThadVgyJwlaoQPmRtMSpz+rk0OGAgIu+TcM9HUF0fk1A==", + "version": "2.13.1", + "resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.13.1.tgz", + "integrity": "sha512-hHrIjvZsftOsvKSn2TRYl63zvxsgE0K+0mYMoH6gD4omR5IWB2KynivBQczo3+wF1cCkjzvptnI9Q0sPU66ilw==", "dependencies": { - "hasown": "^2.0.2" - }, - "engines": { - "node": ">= 0.4" + "hasown": "^2.0.0" }, "funding": { "url": "https://github.com/sponsors/ljharb" @@ -26880,13 +26877,10 @@ } }, "node_modules/object-inspect": { - "version": "1.13.2", - "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.13.2.tgz", - "integrity": "sha512-IRZSRuzJiynemAXPYtPe5BoI/RESNYR7TYm50MC5Mqbd3Jmw5y790sErYw3V6SryFJD64b74qQQs9wn5Bg/k3g==", + "version": "1.13.1", + "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.13.1.tgz", + "integrity": "sha512-5qoj1RUiKOMsCCNLV1CBiPYE10sziTsnmNxkAI/rZhiD63CF7IqdFGC/XzjWjpSgLf0LxXX3bDFIh0E18f6UhQ==", "dev": true, - "engines": { - "node": ">= 0.4" - }, "funding": { "url": "https://github.com/sponsors/ljharb" } @@ -27720,13 +27714,12 @@ } }, "node_modules/posthog-js": { - "version": "1.141.3", - "resolved": "https://registry.npmjs.org/posthog-js/-/posthog-js-1.141.3.tgz", - "integrity": "sha512-LZ+I6wJS82yX/SZVaK20V2WV4MEfB2G9fT2ZJoWlzwN5L3wsbpmjD9F2dVW818deBV3ms1w0Ho7rnlJtBGHx2g==", + "version": "1.139.5", + "resolved": "https://registry.npmjs.org/posthog-js/-/posthog-js-1.139.5.tgz", + "integrity": "sha512-awnIAefNa+x5GA481B8j8J6S2xLcvHQ7i5Osyzq1UK6QGtmAaM0ttGFU+oPjpKxo4yXeuF5R1aUo9YE67s4+vA==", "dependencies": { "fflate": "^0.4.8", - "preact": "^10.19.3", - "web-vitals": "^4.0.1" + "preact": "^10.19.3" } }, "node_modules/posthog-js/node_modules/fflate": { @@ -28248,9 +28241,9 @@ } }, "node_modules/react-devtools-core": { - "version": "5.3.0", - "resolved": "https://registry.npmjs.org/react-devtools-core/-/react-devtools-core-5.3.0.tgz", - "integrity": "sha512-IG3T+azv48Oc5VLdHR4XdBNKNZIUOKRtx0sJMRvb++Zom/uqtx73j6u37JCsIBNIaq6vA7RPH5Bbcf/Wj53KXA==", + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/react-devtools-core/-/react-devtools-core-5.2.0.tgz", + "integrity": "sha512-vZK+/gvxxsieAoAyYaiRIVFxlajb7KXhgBDV7OsoMzaAE+IqGpoxusBjIgq5ibqA2IloKu0p9n7tE68z1xs18A==", "peer": true, "dependencies": { "shell-quote": "^1.6.1", @@ -31744,9 +31737,9 @@ "dev": true }, "node_modules/typescript": { - "version": "5.5.2", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.5.2.tgz", - "integrity": "sha512-NcRtPEOsPFFWjobJEtfihkLCZCXZt/os3zf8nTxjVH3RvTSxjrCamJpbExGvYOF+tFHc3pA65qpdwPbzjohhew==", + "version": "5.4.5", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.4.5.tgz", + "integrity": "sha512-vcI4UpRgg81oIRUFwR0WSIHKt11nJ7SAVlYNIu+QpqeyXP+gpQJy/Z4+F0aGxSE4MqwjyXvW/TzgkLAx2AGHwQ==", "devOptional": true, "bin": { "tsc": "bin/tsc", @@ -32455,9 +32448,9 @@ } }, "node_modules/viem": { - "version": "2.16.2", - "resolved": "https://registry.npmjs.org/viem/-/viem-2.16.2.tgz", - "integrity": "sha512-qor3v1cJFR3jcPtcJxPbKfKURAH2agNf2IWZIaSReV6teNLERiu4Sr7kbqpkIeTAEpiDCVQwg336M+mub1m+pg==", + "version": "2.15.1", + "resolved": "https://registry.npmjs.org/viem/-/viem-2.15.1.tgz", + "integrity": "sha512-Vrveen3vDOJyPf8Q8TDyWePG2pTdK6IpSi4P6qlvAP+rXkAeqRvwYBy9AmGm+BeYpCETAyTT0SrCP6458XSt+w==", "funding": [ { "type": "github", @@ -32470,7 +32463,7 @@ "@noble/hashes": "1.3.2", "@scure/bip32": "1.3.2", "@scure/bip39": "1.2.1", - "abitype": "1.0.4", + "abitype": "1.0.0", "isows": "1.0.4", "ws": "8.17.1" }, @@ -32530,6 +32523,26 @@ "url": "https://paulmillr.com/funding/" } }, + "node_modules/viem/node_modules/abitype": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/abitype/-/abitype-1.0.0.tgz", + "integrity": "sha512-NMeMah//6bJ56H5XRj8QCV4AwuW6hB6zqz2LnhhLdcWVQOsXki6/Pn3APeqxCma62nXIcmZWdu1DlHWS74umVQ==", + "funding": { + "url": "https://github.com/sponsors/wevm" + }, + "peerDependencies": { + "typescript": ">=5.0.4", + "zod": "^3 >=3.22.0" + }, + "peerDependenciesMeta": { + "typescript": { + "optional": true + }, + "zod": { + "optional": true + } + } + }, "node_modules/viem/node_modules/ws": { "version": "8.17.1", "resolved": "https://registry.npmjs.org/ws/-/ws-8.17.1.tgz", @@ -32566,12 +32579,12 @@ } }, "node_modules/wagmi": { - "version": "2.10.7", - "resolved": "https://registry.npmjs.org/wagmi/-/wagmi-2.10.7.tgz", - "integrity": "sha512-RYh45bpqaPbQDcRYbfaiS0b5iZrEKVCCpjyFTJx83qtbkxZBvpT6MXy1rQbfLookVCgZz0PA3aYEYX8HJPajLg==", + "version": "2.10.3", + "resolved": "https://registry.npmjs.org/wagmi/-/wagmi-2.10.3.tgz", + "integrity": "sha512-B1GTa2jzwStnDvunQr8LGc7BfzhC/IdZE679Lm3XlIGTfsrOua38ZnZGE627kqLu3z6WewDBytj+JjHs5GpmXQ==", "dependencies": { - "@wagmi/connectors": "5.0.19", - "@wagmi/core": "2.11.5", + "@wagmi/connectors": "5.0.15", + "@wagmi/core": "2.11.3", "use-sync-external-store": "1.2.0" }, "funding": { @@ -32644,11 +32657,6 @@ "defaults": "^1.0.3" } }, - "node_modules/web-vitals": { - "version": "4.2.0", - "resolved": "https://registry.npmjs.org/web-vitals/-/web-vitals-4.2.0.tgz", - "integrity": "sha512-ohj72kbtVWCpKYMxcbJ+xaOBV3En76hW47j52dG+tEGG36LZQgfFw5yHl9xyjmosy3XUMn8d/GBUAy4YPM839w==" - }, "node_modules/webextension-polyfill": { "version": "0.10.0", "resolved": "https://registry.npmjs.org/webextension-polyfill/-/webextension-polyfill-0.10.0.tgz", diff --git a/package.json b/package.json index ae3c3b66c9..df80434981 100644 --- a/package.json +++ b/package.json @@ -29,7 +29,7 @@ "@emotion/styled": "^11.11.0", "@fuels/connectors": "^0.5.0", "@fuels/react": "^0.20.0", - "@guildxyz/types": "1.9.24", + "@guildxyz/types": "1.9.23", "@hcaptcha/react-hcaptcha": "^1.4.4", "@hookform/resolvers": "^3.3.4", "@lexical/code": "^0.12.0", diff --git a/src/components/[guild]/AddAndOrderRoles/components/OrderRolesModal.tsx b/src/components/[guild]/AddAndOrderRoles/components/OrderRolesModal.tsx index 1d98865b37..088d1016af 100644 --- a/src/components/[guild]/AddAndOrderRoles/components/OrderRolesModal.tsx +++ b/src/components/[guild]/AddAndOrderRoles/components/OrderRolesModal.tsx @@ -15,6 +15,7 @@ import DiscardAlert from "components/common/DiscardAlert" import { Modal } from "components/common/Modal" import { Reorder } from "framer-motion" import { useMemo, useState } from "react" +import { Visibility } from "types" import useReorderRoles from "../hooks/useReorderRoles" import DraggableRoleCard from "./DraggableRoleCard" @@ -50,7 +51,7 @@ const OrderRolesModal = ({ isOpen, onClose, finalFocusRef }): JSX.Element => { }, [relevantRoles]) const publicAndSecretRoles = sortedRoles.filter( - (role) => role.visibility !== "HIDDEN" + (role) => role.visibility !== Visibility.HIDDEN ) const defaultRoleIdsOrder = publicAndSecretRoles?.map((role) => role.id) diff --git a/src/components/[guild]/AddAndOrderRoles/hooks/useAddRoleForm.ts b/src/components/[guild]/AddAndOrderRoles/hooks/useAddRoleForm.ts index d7f953597b..22a3f59c8f 100644 --- a/src/components/[guild]/AddAndOrderRoles/hooks/useAddRoleForm.ts +++ b/src/components/[guild]/AddAndOrderRoles/hooks/useAddRoleForm.ts @@ -1,14 +1,14 @@ import useGuild from "components/[guild]/hooks/useGuild" import { RoleToCreate } from "components/create-guild/hooks/useCreateRole" import { useForm } from "react-hook-form" -import { RoleFormType } from "types" +import { RoleFormType, Visibility } from "types" import getRandomInt from "utils/getRandomInt" const useAddRoleForm = () => { const { id } = useGuild() const defaultValues: RoleToCreate = { - guildId: id as number, // Safe to cast here, since we'll have guildId by the time we call this hook + guildId: id, name: "", description: "", logic: "AND", @@ -19,7 +19,7 @@ const useAddRoleForm = () => { ], roleType: "NEW", imageUrl: `/guildLogos/${getRandomInt(286)}.svg`, - visibility: "PUBLIC", + visibility: Visibility.PUBLIC, rolePlatforms: [], } diff --git a/src/components/[guild]/AddRewardButton/AddRewardButton.tsx b/src/components/[guild]/AddRewardButton/AddRewardButton.tsx index 95db25146c..2acbb35c0d 100644 --- a/src/components/[guild]/AddRewardButton/AddRewardButton.tsx +++ b/src/components/[guild]/AddRewardButton/AddRewardButton.tsx @@ -1,5 +1,4 @@ import { ModalOverlay, useDisclosure } from "@chakra-ui/react" -import { Schemas, Visibility } from "@guildxyz/types" import Button from "components/common/Button" import DiscardAlert from "components/common/DiscardAlert" import { Modal } from "components/common/Modal" @@ -8,7 +7,7 @@ import { atom, useAtomValue } from "jotai" import { Plus } from "phosphor-react" import rewards, { modalSizeForPlatform } from "platforms/rewards" import { FormProvider, useForm, useWatch } from "react-hook-form" -import { RoleFormType } from "types" +import { Requirement, RoleFormType, Visibility } from "types" import { AddRewardProvider, useAddRewardContext } from "../AddRewardContext" import { ClientStateRequirementHandlerProvider } from "../RequirementHandlerContext" import SelectRewardPanel from "../RolePlatforms/components/AddRoleRewardModal/SelectRewardPanel" @@ -21,7 +20,7 @@ export type AddRewardForm = { // TODO: we could simplify the form - we don't need a rolePlatforms array here, we only need one rolePlatform rolePlatforms: RoleFormType["rolePlatforms"][number][] // TODO: use proper types, e.g. name & symbol shouldn't be required on this type - requirements?: Schemas["RequirementCreationPayload"][] + requirements?: Omit[] roleIds?: number[] visibility: Visibility roleName?: string // Name for role, if new role is created with reward @@ -31,7 +30,7 @@ export const defaultValues: AddRewardForm = { rolePlatforms: [], requirements: [{ type: "FREE" }], roleIds: [], - visibility: "PUBLIC", + visibility: Visibility.PUBLIC, } export const canCloseAddRewardModalAtom = atom(true) diff --git a/src/components/[guild]/AddRewardButton/SelectRolePanel.tsx b/src/components/[guild]/AddRewardButton/SelectRolePanel.tsx index 22f0681810..968318bb98 100644 --- a/src/components/[guild]/AddRewardButton/SelectRolePanel.tsx +++ b/src/components/[guild]/AddRewardButton/SelectRolePanel.tsx @@ -11,7 +11,6 @@ import { Tooltip, useColorModeValue, } from "@chakra-ui/react" -import { Visibility } from "@guildxyz/types" import { usePostHogContext } from "components/_app/PostHogProvider" import Button from "components/common/Button" import useCreateRRR, { SubmitData } from "hooks/useCreateRRR" @@ -20,6 +19,7 @@ import SelectRoleOrSetRequirements from "platforms/components/SelectRoleOrSetReq import rewards, { CAPACITY_TIME_PLATFORMS } from "platforms/rewards" import { useState } from "react" import { useFormContext, useWatch } from "react-hook-form" +import { Visibility } from "types" import { RoleTypeToAddTo, useAddRewardContext } from "../AddRewardContext" import useGuild from "../hooks/useGuild" import { defaultValues } from "./AddRewardButton" @@ -171,17 +171,17 @@ const SelectRolePanel = ({ const changeDataToDraft = (data: SubmitData): SubmitData => { if (!data.roleIds?.length) { - return { ...data, visibility: "HIDDEN" as Visibility } + return { ...data, visibility: Visibility.HIDDEN } } const { rolePlatforms, requirements, roleIds } = data const hiddenRolePlatforms = rolePlatforms.map((rp) => ({ ...rp, - visibility: "HIDDEN" as Visibility, + visibility: Visibility.HIDDEN, })) const hiddenRequirements = requirements.map((req) => - req.type === "FREE" ? req : { ...req, visibility: "HIDDEN" as Visibility } + req.type === "FREE" ? req : { ...req, visibility: Visibility.HIDDEN } ) return { diff --git a/src/components/[guild]/AddRewardButton/hooks/useCreateRequirements.ts b/src/components/[guild]/AddRewardButton/hooks/useCreateRequirements.ts index 3032eed2c8..324d1b5043 100644 --- a/src/components/[guild]/AddRewardButton/hooks/useCreateRequirements.ts +++ b/src/components/[guild]/AddRewardButton/hooks/useCreateRequirements.ts @@ -2,11 +2,8 @@ import useGuild from "components/[guild]/hooks/useGuild" import { usePostHogContext } from "components/_app/PostHogProvider" import { RequirementIdMap } from "hooks/useCreateRRR" import useShowErrorToast from "hooks/useShowErrorToast" -import { - RequirementCreateResponseOutput, - RequirementCreationPayloadWithTempID, -} from "types" +import { Requirement } from "types" import { useFetcherWithSign } from "utils/fetcher" import preprocessRequirement from "utils/preprocessRequirement" @@ -20,8 +17,7 @@ const useCreateRequirements = () => { } const createRequirements = async ( - // We can assign generated IDs to requirements on our frontend, so it's safe to extend this type with an ID - requirements: RequirementCreationPayloadWithTempID[], + requirements: Partial[], roleIds: number[] ) => { const requirementIdMap: RequirementIdMap = {} @@ -35,7 +31,7 @@ const useCreateRequirements = () => { body: preprocessRequirement(req), }, ]) - .then((res: RequirementCreateResponseOutput) => { + .then((res) => { if (!requirementIdMap[req.id]) requirementIdMap[req.id] = {} requirementIdMap[req.id][roleId] = res.id return { status: "fulfilled", result: res } diff --git a/src/components/[guild]/AddRewardButton/hooks/useMutateAdditionsToRoles.ts b/src/components/[guild]/AddRewardButton/hooks/useMutateAdditionsToRoles.ts index 8c29d81555..8ccb7e05a5 100644 --- a/src/components/[guild]/AddRewardButton/hooks/useMutateAdditionsToRoles.ts +++ b/src/components/[guild]/AddRewardButton/hooks/useMutateAdditionsToRoles.ts @@ -1,17 +1,13 @@ +import { Schemas } from "@guildxyz/types" import useGuild from "components/[guild]/hooks/useGuild" import { unstable_serialize, useSWRConfig } from "swr" -import { - Guild, - GuildPlatform, - RequirementCreateResponseOutput, - RolePlatform, -} from "types" +import { GuildPlatform, Requirement, RolePlatform } from "types" import { CreateRolePlatformResponse } from "./useCreateRolePlatforms" const groupRequirementsByRoleId = ( roleIds: number[], - requirements: RequirementCreateResponseOutput[] -): { [roleId: number]: RequirementCreateResponseOutput[] } => + requirements: Schemas["RequirementCreateResponse"][] +): { [roleId: number]: Schemas["RequirementCreateResponse"][] } => roleIds.reduce((acc, roleId) => { acc[roleId] = requirements.filter((req) => req.roleId === roleId) return acc @@ -58,7 +54,7 @@ const useMutateAdditionsToRoles = () => { const mutateAdditionsInGuild = ( roleIds: number[], - createdRequirements: RequirementCreateResponseOutput[], + createdRequirements: Schemas["RequirementCreateResponse"][], // TODO: create a RoleRewardCreateResponse schema in our types package createdRolePlatforms: CreateRolePlatformResponse[] ) => { @@ -94,24 +90,23 @@ const useMutateAdditionsToRoles = () => { ...role, requirements: [ ...role.requirements.filter((req) => !reqIdsToDelete.includes(req.id)), - ...createdRequirementsOnRole, + // TODO: we can remove the Requirement[] cast once we start using the Guild schema from our types package in the useGuild hook + ...(createdRequirementsOnRole as Requirement[]), ], rolePlatforms: [...role.rolePlatforms, ...createdRolePlatformsOnRole], } }) // Return the updated data - return !!prev - ? ({ - ...prev, - // TODO: we can remove the GuildPlatform[] cast once we start using the Guild schema from our types package in the useGuild hook - guildPlatforms: [ - ...(prev?.guildPlatforms ?? []), - ...(createdGuildPlatforms as GuildPlatform[]), - ], - roles: updatedRoles, - } satisfies Guild) - : undefined + return { + ...prev, + // TODO: we can remove the GuildPlatform[] cast once we start using the Guild schema from our types package in the useGuild hook + guildPlatforms: [ + ...prev.guildPlatforms, + ...(createdGuildPlatforms as GuildPlatform[]), + ], + roles: updatedRoles, + } }, { revalidate: false } ) @@ -119,7 +114,7 @@ const useMutateAdditionsToRoles = () => { const mutateAdditionsToRoles = ( roleIds: number[], - createdRequirements: RequirementCreateResponseOutput[], + createdRequirements: Schemas["RequirementCreateResponse"][], // TODO: create a RoleRewardCreateResponse schema in our types package createdRolePlatforms: CreateRolePlatformResponse[] ) => { diff --git a/src/components/[guild]/AddRewardButton/hooks/useSubmitAddReward.ts b/src/components/[guild]/AddRewardButton/hooks/useSubmitAddReward.ts index bf1e2486e9..63234ac290 100644 --- a/src/components/[guild]/AddRewardButton/hooks/useSubmitAddReward.ts +++ b/src/components/[guild]/AddRewardButton/hooks/useSubmitAddReward.ts @@ -1,4 +1,3 @@ -import { Visibility } from "@guildxyz/types" import { useAddRewardContext } from "components/[guild]/AddRewardContext" import useGuild from "components/[guild]/hooks/useGuild" import { usePostHogContext } from "components/_app/PostHogProvider" @@ -6,7 +5,7 @@ import useCreateRole from "components/create-guild/hooks/useCreateRole" import useToast from "hooks/useToast" import rewards from "platforms/rewards" import { useFormContext } from "react-hook-form" -import { PlatformType } from "types" +import { PlatformType, Visibility } from "types" import getRandomInt from "utils/getRandomInt" import { defaultValues } from "../AddRewardButton" import useCreateReqBasedTokenReward from "../useCreateTokenReward" @@ -136,7 +135,8 @@ const useSubmitAddReward = ({ } if (!data.roleIds || data?.roleIds.length === 0) { - const roleVisibility: Visibility = saveAs === "DRAFT" ? "HIDDEN" : "PUBLIC" + const roleVisibility = + saveAs === "DRAFT" ? Visibility.HIDDEN : Visibility.PUBLIC onCreateRoleSubmit({ ...data, name: data.roleName || `New ${rewards[selection].name} role`, @@ -168,7 +168,7 @@ const useSubmitAddReward = ({ ...data.rolePlatforms[0], visibility: saveAs === "DRAFT" - ? "HIDDEN" + ? Visibility.HIDDEN : roles.find((role) => role.id === +roleId).visibility, })), }) diff --git a/src/components/[guild]/AddRewardButton/useCreateTokenReward.ts b/src/components/[guild]/AddRewardButton/useCreateTokenReward.ts index d32eb6e569..a355297a2f 100644 --- a/src/components/[guild]/AddRewardButton/useCreateTokenReward.ts +++ b/src/components/[guild]/AddRewardButton/useCreateTokenReward.ts @@ -2,7 +2,7 @@ import { Schemas } from "@guildxyz/types" import { usePostHogContext } from "components/_app/PostHogProvider" import useCreateRole from "components/create-guild/hooks/useCreateRole" import useShowErrorToast from "hooks/useShowErrorToast" -import { PlatformType, Requirement, RolePlatform } from "types" +import { PlatformType, Requirement, RolePlatform, Visibility } from "types" import getRandomInt from "utils/getRandomInt" import useMembershipUpdate from "../JoinModal/hooks/useMembershipUpdate" import useGuild from "../hooks/useGuild" @@ -37,7 +37,7 @@ const getRewardSubmitData = ( platformRoleId: data.rolePlatforms[0].guildPlatform.platformGuildId || `${roleId}-${Date.now()}`, - visibility: saveAs === "DRAFT" ? "HIDDEN" : "PUBLIC", + visibility: saveAs === "DRAFT" ? Visibility.HIDDEN : Visibility.PUBLIC, }, ], }) @@ -96,7 +96,7 @@ const useCreateReqBasedTokenReward = ({ }) const createWithNewRole = async (data: CreateData, saveAs: "DRAFT" | "PUBLIC") => { - const roleVisibility = saveAs === "DRAFT" ? "HIDDEN" : "PUBLIC" + const roleVisibility = saveAs === "DRAFT" ? Visibility.HIDDEN : Visibility.PUBLIC const createdRole = await onCreateRoleSubmit({ ...data, diff --git a/src/components/[guild]/Requirements/RequirementErrorConfigContext.tsx b/src/components/[guild]/Requirements/RequirementErrorConfigContext.tsx index 9dbf5128fc..4fa8b5fc5f 100644 --- a/src/components/[guild]/Requirements/RequirementErrorConfigContext.tsx +++ b/src/components/[guild]/Requirements/RequirementErrorConfigContext.tsx @@ -5,7 +5,7 @@ type RequirementErrorConfig = Partial> const REQ_ERROR_CONFIG: RequirementErrorConfig = { GALAXY: "Galxe API error, please try again later", - // TWITTER: "X API error, please try again later", + TWITTER: "X API error, please try again later", } const RequirementErrorConfigContext = createContext({}) diff --git a/src/components/[guild]/Requirements/RoleRequirements.tsx b/src/components/[guild]/Requirements/RoleRequirements.tsx index feb2175cd5..1d4a438c9a 100644 --- a/src/components/[guild]/Requirements/RoleRequirements.tsx +++ b/src/components/[guild]/Requirements/RoleRequirements.tsx @@ -43,7 +43,7 @@ const RoleRequirements = ({ const requirements = role.hiddenRequirements || data?.length === 0 - ? [...(data ?? []), { roleId: role.id, visibility: "HIDDEN" } as Requirement] + ? [...(data ?? []), { type: "HIDDEN", roleId: role.id } as Requirement] : data const isVirtualList = requirements?.length > VIRTUAL_LIST_REQUIREMENT_LIMIT diff --git a/src/components/[guild]/Requirements/components/GuildCheckout/MintGuildPin/components/ActivateGuildPinForm.tsx b/src/components/[guild]/Requirements/components/GuildCheckout/MintGuildPin/components/ActivateGuildPinForm.tsx index 5bf19ecceb..8b096ed8d1 100644 --- a/src/components/[guild]/Requirements/components/GuildCheckout/MintGuildPin/components/ActivateGuildPinForm.tsx +++ b/src/components/[guild]/Requirements/components/GuildCheckout/MintGuildPin/components/ActivateGuildPinForm.tsx @@ -8,6 +8,7 @@ import useToast from "hooks/useToast" import { FormProvider, useController, useForm, useWatch } from "react-hook-form" import { traitsSupportedChains } from "requirements/Nft/NftForm" import ChainPicker from "requirements/common/ChainPicker" +import { Visibility } from "types" import { GUILD_PIN_CONTRACTS } from "utils/guildCheckout/constants" import { Chain } from "wagmiConfig/chains" import { useMintGuildPinContext } from "../../MintGuildPinContext" @@ -75,7 +76,7 @@ const ActivateGuildPinForm = (): JSX.Element => { }, ], rolePlatforms: [], - visibility: "PUBLIC", + visibility: Visibility.PUBLIC, }) } : showSuccessToastAndCloseModal, diff --git a/src/components/[guild]/Requirements/components/GuildCheckout/components/BuyTotal.tsx b/src/components/[guild]/Requirements/components/GuildCheckout/components/BuyTotal.tsx index 538981bfc0..adc4580719 100644 --- a/src/components/[guild]/Requirements/components/GuildCheckout/components/BuyTotal.tsx +++ b/src/components/[guild]/Requirements/components/GuildCheckout/components/BuyTotal.tsx @@ -3,7 +3,7 @@ import useTokenData from "hooks/useTokenData" import useVault from "requirements/Payment/hooks/useVault" import { NULL_ADDRESS } from "utils/guildCheckout/constants" import { formatUnits } from "viem" -import { Chain, CHAIN_CONFIG } from "wagmiConfig/chains" +import { CHAIN_CONFIG } from "wagmiConfig/chains" import { useRequirementContext } from "../../RequirementContext" import usePayFee from "../hooks/usePayFee" import FeesTable from "./FeesTable" @@ -14,17 +14,13 @@ const BuyTotal = (): JSX.Element => { const requirement = useRequirementContext() const { pickedCurrency } = useGuildCheckoutContext() - // TODO: we could remove the cast once we'll have schemas for "ERC..." requirements - const requirementChain = requirement.chain as Chain - const requirementAddress = requirement.address as `0x${string}` - const { token, fee, isLoading, error } = useVault( - requirementAddress, + requirement.address, requirement.data.id, - requirementChain + requirement.chain ) - const { data: tokenData } = useTokenData(requirementChain, token) + const { data: tokenData } = useTokenData(requirement.chain, token) const isNativeCurrency = pickedCurrency === NULL_ADDRESS @@ -35,7 +31,7 @@ const BuyTotal = (): JSX.Element => { ? parseFloat( formatUnits( estimatedGas, - CHAIN_CONFIG[requirementChain].nativeCurrency.decimals + CHAIN_CONFIG[requirement.chain].nativeCurrency.decimals ) ) : null @@ -43,7 +39,7 @@ const BuyTotal = (): JSX.Element => { const priceInSellToken = fee ? isNativeCurrency ? Number( - formatUnits(fee, CHAIN_CONFIG[requirementChain].nativeCurrency.decimals) + formatUnits(fee, CHAIN_CONFIG[requirement.chain].nativeCurrency.decimals) ) : tokenData?.decimals ? Number(formatUnits(fee, tokenData.decimals)) + @@ -101,7 +97,7 @@ const BuyTotal = (): JSX.Element => { {!estimatedGasInFloat ? "Couldn't estimate" : `${Number(estimatedGasInFloat.toFixed(8))} ${ - CHAIN_CONFIG[requirementChain].nativeCurrency.symbol + CHAIN_CONFIG[requirement.chain].nativeCurrency.symbol }`} diff --git a/src/components/[guild]/Requirements/components/GuildCheckout/components/PaymentFeeCurrency.tsx b/src/components/[guild]/Requirements/components/GuildCheckout/components/PaymentFeeCurrency.tsx index a3b8b5a953..0fc5a99d2d 100644 --- a/src/components/[guild]/Requirements/components/GuildCheckout/components/PaymentFeeCurrency.tsx +++ b/src/components/[guild]/Requirements/components/GuildCheckout/components/PaymentFeeCurrency.tsx @@ -13,11 +13,11 @@ const PaymentFeeCurrency = (): JSX.Element => { const lightShade = useColorModeValue("white", "gray.700") const borderWidth = useColorModeValue(1, 0) - const requirement = useRequirementContext<"PAYMENT">() + const requirement = useRequirementContext() const { pickedCurrency, setPickedCurrency } = useGuildCheckoutContext() const { token, fee, error, isLoading } = useVault( - requirement?.address as `0x${string}`, + requirement?.address, requirement?.data?.id, requirement?.chain ) diff --git a/src/components/[guild]/Requirements/components/GuildCheckout/components/PurchaseFeeAndTotal.tsx b/src/components/[guild]/Requirements/components/GuildCheckout/components/PurchaseFeeAndTotal.tsx index 3fb50d274d..3cc8674d50 100644 --- a/src/components/[guild]/Requirements/components/GuildCheckout/components/PurchaseFeeAndTotal.tsx +++ b/src/components/[guild]/Requirements/components/GuildCheckout/components/PurchaseFeeAndTotal.tsx @@ -3,7 +3,7 @@ import useTokenData from "hooks/useTokenData" import { Info, Question } from "phosphor-react" import { GUILD_FEE_PERCENTAGE, NULL_ADDRESS } from "utils/guildCheckout/constants" import { formatUnits } from "viem" -import { Chain, CHAIN_CONFIG } from "wagmiConfig/chains" +import { CHAIN_CONFIG } from "wagmiConfig/chains" import { useRequirementContext } from "../../RequirementContext" import usePrice from "../hooks/usePrice" import usePurchaseAsset from "../hooks/usePurchaseAsset" @@ -15,12 +15,9 @@ const PurchaseFeeAndTotal = (): JSX.Element => { const requirement = useRequirementContext() const { pickedCurrency } = useGuildCheckoutContext() - // TODO: we could remove the cast once we'll have schemas for "ERC..." requirements - const requirementChain = requirement.chain as Chain - const { data: { symbol }, - } = useTokenData(requirementChain, pickedCurrency) + } = useTokenData(requirement.chain, pickedCurrency) const { data: { @@ -42,7 +39,7 @@ const PurchaseFeeAndTotal = (): JSX.Element => { ? parseFloat( formatUnits( estimatedGas, - CHAIN_CONFIG[requirementChain].nativeCurrency.decimals + CHAIN_CONFIG[requirement.chain].nativeCurrency.decimals ) ) : null @@ -171,7 +168,7 @@ const PurchaseFeeAndTotal = (): JSX.Element => { {!estimatedGasInFloat ? "Couldn't estimate" : `${estimatedGasInFloat.toFixed(8)} ${ - CHAIN_CONFIG[requirementChain].nativeCurrency.symbol + CHAIN_CONFIG[requirement.chain].nativeCurrency.symbol }`} diff --git a/src/components/[guild]/Requirements/components/GuildCheckout/components/PurchasedRequirementInfo.tsx b/src/components/[guild]/Requirements/components/GuildCheckout/components/PurchasedRequirementInfo.tsx index eafb8a9740..5e49cb247c 100644 --- a/src/components/[guild]/Requirements/components/GuildCheckout/components/PurchasedRequirementInfo.tsx +++ b/src/components/[guild]/Requirements/components/GuildCheckout/components/PurchasedRequirementInfo.tsx @@ -8,7 +8,6 @@ import { VStack, } from "@chakra-ui/react" import useTokenData from "hooks/useTokenData" -import { Chain } from "wagmiConfig/chains" import { useRequirementContext } from "../../RequirementContext" type Props = { @@ -21,13 +20,9 @@ const PurchasedRequirementInfo = ({ rightElement, footer }: Props): JSX.Element const requirement = useRequirementContext() - // TODO: we could remove the cast once we'll have schemas for "ERC..." requirements - const requirementChain = requirement.chain as Chain - const requirementAddress = requirement.address as `0x${string}` - const { data: { symbol, logoURI }, - } = useTokenData(requirementChain, requirementAddress) + } = useTokenData(requirement?.chain, requirement?.address) return ( { const { captureEvent } = usePostHogContext() const { urlName } = useGuild() - const requirement = useRequirementContext<"PAYMENT">() - const requirementAddress = requirement.address as `0x${string}` - + const requirement = useRequirementContext() const requirementChainId = Chains[requirement.chain] const { pickedCurrency } = useGuildCheckoutContext() @@ -39,7 +37,7 @@ const BuyAllowanceButton = (): JSX.Element => { const tokenName = isNativeCurrencyPicked ? nativeCurrency.name : name const { fee, isLoading: isVaultLoading } = useVault( - requirementAddress, + requirement.address, requirement.data.id, requirement.chain ) @@ -50,7 +48,7 @@ const BuyAllowanceButton = (): JSX.Element => { isAllowing, allowanceError, allowSpendingTokens, - } = useAllowance(pickedCurrency, requirementAddress) + } = useAllowance(pickedCurrency, requirement.address) const isEnoughAllowance = typeof fee === "bigint" && typeof allowance === "bigint" diff --git a/src/components/[guild]/Requirements/components/GuildCheckout/components/buttons/BuyButton.tsx b/src/components/[guild]/Requirements/components/GuildCheckout/components/buttons/BuyButton.tsx index 30cd19f432..78f3fd86cd 100644 --- a/src/components/[guild]/Requirements/components/GuildCheckout/components/buttons/BuyButton.tsx +++ b/src/components/[guild]/Requirements/components/GuildCheckout/components/buttons/BuyButton.tsx @@ -18,9 +18,7 @@ const BuyButton = (): JSX.Element => { const { address, chainId } = useAccount() - const requirement = useRequirementContext<"PAYMENT">() - const requirementAddress = requirement.address as `0x${string}` - + const requirement = useRequirementContext() const { pickedCurrency, agreeWithTOS } = useGuildCheckoutContext() const { @@ -28,17 +26,17 @@ const BuyButton = (): JSX.Element => { multiplePayments, isLoading: isVaultLoading, error, - } = useVault(requirementAddress, requirement.data.id, requirement.chain) + } = useVault(requirement.address, requirement.data.id, requirement.chain) const { data: hasPaid, isLoading: isHasPaidLoading } = useHasPaid( - requirementAddress, - +requirement.data.id, + requirement.address, + requirement.data.id, requirement.chain ) const { allowance, isAllowanceLoading, allowanceError } = useAllowance( pickedCurrency, - requirementAddress + requirement.address ) const { diff --git a/src/components/[guild]/Requirements/components/GuildCheckout/components/buttons/PurchaseAllowanceButton.tsx b/src/components/[guild]/Requirements/components/GuildCheckout/components/buttons/PurchaseAllowanceButton.tsx index f8bd607850..d55c02da00 100644 --- a/src/components/[guild]/Requirements/components/GuildCheckout/components/buttons/PurchaseAllowanceButton.tsx +++ b/src/components/[guild]/Requirements/components/GuildCheckout/components/buttons/PurchaseAllowanceButton.tsx @@ -7,7 +7,7 @@ import useTokenData from "hooks/useTokenData" import { Check, Question, Warning } from "phosphor-react" import { NULL_ADDRESS, TOKEN_BUYER_CONTRACTS } from "utils/guildCheckout/constants" import { useChainId } from "wagmi" -import { Chain, CHAIN_CONFIG, Chains } from "wagmiConfig/chains" +import { CHAIN_CONFIG, Chains } from "wagmiConfig/chains" import { useRequirementContext } from "../../../RequirementContext" import usePrice from "../../hooks/usePrice" import { useGuildCheckoutContext } from "../GuildCheckoutContext" @@ -17,16 +17,14 @@ const PurchaseAllowanceButton = (): JSX.Element => { const { urlName } = useGuild() const requirement = useRequirementContext() - // TODO: remove typecast once we implement schemas for ERC20 requirements - const requirementChain = requirement.chain as Chain - const requirementChainId = Chains[requirementChain] + const requirementChainId = Chains[requirement.chain] const { pickedCurrency } = useGuildCheckoutContext() const chainId = useChainId() const { data: { symbol, name }, - } = useTokenData(requirementChain, pickedCurrency) + } = useTokenData(requirement.chain, pickedCurrency) const nativeCurrency = CHAIN_CONFIG[Chains[chainId]]?.nativeCurrency const isNativeCurrencyPicked = pickedCurrency === NULL_ADDRESS diff --git a/src/components/[guild]/Requirements/components/GuildCheckout/hooks/usePayFee.ts b/src/components/[guild]/Requirements/components/GuildCheckout/hooks/usePayFee.ts index f87a6dff99..e2a9c31069 100644 --- a/src/components/[guild]/Requirements/components/GuildCheckout/hooks/usePayFee.ts +++ b/src/components/[guild]/Requirements/components/GuildCheckout/hooks/usePayFee.ts @@ -22,9 +22,7 @@ const usePayFee = () => { const { address, chainId } = useAccount() - const requirement = useRequirementContext<"PAYMENT">() - const requirementAddress = requirement.address as `0x${string}` - + const requirement = useRequirementContext() const { pickedCurrency, onClose } = useGuildCheckoutContext() const showErrorToast = useShowErrorToast() @@ -35,11 +33,11 @@ const usePayFee = () => { multiplePayments, isLoading: isVaultLoading, refetch: refetchVault, - } = useVault(requirementAddress, requirement.data.id, requirement.chain) + } = useVault(requirement.address, requirement.data.id, requirement.chain) const { data: hasPaid, isLoading: isHasPaidLoading } = useHasPaid( - requirementAddress, - +requirement.data.id, + requirement.address, + requirement.data.id, requirement.chain ) @@ -62,7 +60,7 @@ const usePayFee = () => { ? coinBalanceData?.value >= fee : tokenBalanceData?.value >= fee) - const { allowance } = useAllowance(pickedCurrency, requirementAddress) + const { allowance } = useAllowance(pickedCurrency, requirement.address) const enabled = requirement?.chain === Chains[chainId] && diff --git a/src/components/[guild]/Requirements/components/GuildCheckout/hooks/usePurchaseAsset.ts b/src/components/[guild]/Requirements/components/GuildCheckout/hooks/usePurchaseAsset.ts index 45e7a4fa33..157469b484 100644 --- a/src/components/[guild]/Requirements/components/GuildCheckout/hooks/usePurchaseAsset.ts +++ b/src/components/[guild]/Requirements/components/GuildCheckout/hooks/usePurchaseAsset.ts @@ -62,7 +62,7 @@ const usePurchaseAsset = () => { }) const { data: purchasedTokenData } = useToken({ - address: requirement?.address as `0x${string}`, + address: requirement?.address, chainId: Chains[requirement?.chain], }) diff --git a/src/components/[guild]/Requirements/components/Requirement.tsx b/src/components/[guild]/Requirements/components/Requirement.tsx index 468f2e9f4f..7417f50906 100644 --- a/src/components/[guild]/Requirements/components/Requirement.tsx +++ b/src/components/[guild]/Requirements/components/Requirement.tsx @@ -12,6 +12,7 @@ import Visibility from "components/[guild]/Visibility" import dynamic from "next/dynamic" import React, { ComponentType, PropsWithChildren } from "react" import { useFormContext } from "react-hook-form" +import { Visibility as VisibilityType } from "types" import { useRequirementContext } from "./RequirementContext" import { RequirementImage, RequirementImageCircle } from "./RequirementImage" import ResetRequirementButton from "./ResetRequirementButton" @@ -76,8 +77,8 @@ const Requirement = ({ : requirement?.data?.customName || children} {!setValue ? ( ) : null} diff --git a/src/components/[guild]/Requirements/components/RequirementChainIndicator.tsx b/src/components/[guild]/Requirements/components/RequirementChainIndicator.tsx index 5afe8d54de..2aaee0a488 100644 --- a/src/components/[guild]/Requirements/components/RequirementChainIndicator.tsx +++ b/src/components/[guild]/Requirements/components/RequirementChainIndicator.tsx @@ -1,12 +1,11 @@ import { Img, Tag, TagLabel, TagProps, useColorModeValue } from "@chakra-ui/react" -import { Requirement } from "types" -import { CHAIN_CONFIG } from "wagmiConfig/chains" +import { CHAIN_CONFIG, Chain } from "wagmiConfig/chains" import { useRequirementContext } from "./RequirementContext" const RequirementChainIndicator = ({ chain: chainFromProp, ...rest -}: { chain?: Requirement["chain"] } & TagProps) => { +}: { chain?: Chain } & TagProps) => { const { chain: chainFromContext } = useRequirementContext() ?? {} const chain = chainFromProp ?? chainFromContext const bg = useColorModeValue("white", "blackAlpha.300") diff --git a/src/components/[guild]/Requirements/components/RequirementContext.tsx b/src/components/[guild]/Requirements/components/RequirementContext.tsx index e9690ce12b..ba7ba0d0c6 100644 --- a/src/components/[guild]/Requirements/components/RequirementContext.tsx +++ b/src/components/[guild]/Requirements/components/RequirementContext.tsx @@ -1,7 +1,5 @@ -import { schemas } from "@guildxyz/types" import { createContext, PropsWithChildren, useContext } from "react" import { Requirement } from "types" -import { z } from "zod" // It's safe to use undefine here as the default value, since we'll always have a default value in RequirementProvider const RequirementContext = createContext(undefined) @@ -24,13 +22,6 @@ const RequirementProvider = ({ ) } -type ReqType = z.output["type"] -const useRequirementContext = () => { - const requirement = useContext(RequirementContext) - return requirement as unknown as Extract< - z.output, - { type: RequirementType } - > -} +const useRequirementContext = () => useContext(RequirementContext) export { RequirementProvider, useRequirementContext } diff --git a/src/components/[guild]/Requirements/components/RequirementDisplayComponent.tsx b/src/components/[guild]/Requirements/components/RequirementDisplayComponent.tsx index 46bb5fc1c3..d95c750eec 100644 --- a/src/components/[guild]/Requirements/components/RequirementDisplayComponent.tsx +++ b/src/components/[guild]/Requirements/components/RequirementDisplayComponent.tsx @@ -22,7 +22,7 @@ const RequirementDisplayComponent = ({ rightElement = , ...rest }: Props) => { - if (requirement.visibility === "HIDDEN") + if (requirement.type === "HIDDEN") return ( } diff --git a/src/components/[guild]/RoleCard/RoleCard.tsx b/src/components/[guild]/RoleCard/RoleCard.tsx index 8f36dd5bee..da4a619970 100644 --- a/src/components/[guild]/RoleCard/RoleCard.tsx +++ b/src/components/[guild]/RoleCard/RoleCard.tsx @@ -17,7 +17,7 @@ import useMembership, { import dynamic from "next/dynamic" import rewards from "platforms/rewards" import { memo, useEffect, useRef } from "react" -import { PlatformType, Role } from "types" +import { PlatformType, Role, Visibility as VisibilityType } from "types" import RoleRequirements from "../Requirements" import useGuild from "../hooks/useGuild" import useGuildPermission from "../hooks/useGuildPermission" @@ -70,7 +70,8 @@ const RoleCard = memo(({ role }: Props) => { const isMobile = useBreakpointValue({ base: true, md: false }, { fallback: "md" }) - const collapsedHeight = isMobile && role.visibility === "PUBLIC" ? "90px" : "94px" + const collapsedHeight = + isMobile && role.visibility === VisibilityType.PUBLIC ? "90px" : "94px" return ( { onClick={() => { if (window.location.hash === `#role-${role.id}`) window.location.hash = "!" }} - {...(role.visibility === "HIDDEN" + {...(role.visibility === VisibilityType.HIDDEN ? { borderWidth: 2, borderStyle: "dashed", diff --git a/src/components/[guild]/RoleCard/components/EditRole/hooks/useEditRoleForm.ts b/src/components/[guild]/RoleCard/components/EditRole/hooks/useEditRoleForm.ts index 1d627f7d08..89dc2e4323 100644 --- a/src/components/[guild]/RoleCard/components/EditRole/hooks/useEditRoleForm.ts +++ b/src/components/[guild]/RoleCard/components/EditRole/hooks/useEditRoleForm.ts @@ -1,8 +1,7 @@ -import { Visibility } from "@guildxyz/types" import useGuild from "components/[guild]/hooks/useGuild" import { useEffect } from "react" import { useForm } from "react-hook-form" -import { Logic } from "types" +import { Logic, Visibility } from "types" export type RoleEditFormData = { id: number @@ -37,7 +36,7 @@ const useEditRoleForm = (roleId: number) => { imageUrl, logic, anyOfNum: anyOfNum ?? 1, - visibility: visibility ?? "PUBLIC", + visibility, visibilityRoleId, groupId, } diff --git a/src/components/[guild]/RoleCard/components/EditRole/hooks/useUpdateRolePlatformVisibility.ts b/src/components/[guild]/RoleCard/components/EditRole/hooks/useUpdateRolePlatformVisibility.ts index 90ef9daf56..424440c476 100644 --- a/src/components/[guild]/RoleCard/components/EditRole/hooks/useUpdateRolePlatformVisibility.ts +++ b/src/components/[guild]/RoleCard/components/EditRole/hooks/useUpdateRolePlatformVisibility.ts @@ -1,9 +1,8 @@ -import { Visibility } from "@guildxyz/types" import useGuild from "components/[guild]/hooks/useGuild" import useShowErrorToast from "hooks/useShowErrorToast" import useSubmit from "hooks/useSubmit" import useToast from "hooks/useToast" -import { RolePlatform } from "types" +import { RolePlatform, Visibility } from "types" import { useFetcherWithSign } from "utils/fetcher" import useLocalMutateRolePlatform from "./useLocalMutateRolePlatform" diff --git a/src/components/[guild]/RolePlatforms/components/AddRoleRewardModal/components/SelectExistingPlatform.tsx b/src/components/[guild]/RolePlatforms/components/AddRoleRewardModal/components/SelectExistingPlatform.tsx index ae1d1248f2..6928a27777 100644 --- a/src/components/[guild]/RolePlatforms/components/AddRoleRewardModal/components/SelectExistingPlatform.tsx +++ b/src/components/[guild]/RolePlatforms/components/AddRoleRewardModal/components/SelectExistingPlatform.tsx @@ -6,7 +6,13 @@ import { DISPLAY_CARD_INTERACTIVITY_STYLES } from "components/common/DisplayCard import rewards, { PlatformAsRewardRestrictions } from "platforms/rewards" import { useState } from "react" import { useWatch } from "react-hook-form" -import { PlatformType, Requirement, RoleFormType, RolePlatform } from "types" +import { + PlatformType, + Requirement, + RoleFormType, + RolePlatform, + Visibility, +} from "types" import EditRolePlatformModal from "../../EditRolePlatformModal" import PlatformCard from "../../PlatformCard" @@ -30,7 +36,7 @@ const SelectExistingPlatform = ({ onClose, onSelect }: Props) => { name: "rolePlatforms", }) - const roleVisibility = useWatch({ name: "visibility" }) + const roleVisibility: Visibility = useWatch({ name: ".visibility" }) const filteredPlatforms = guildPlatforms ? guildPlatforms.filter( diff --git a/src/components/[guild]/Roles.tsx b/src/components/[guild]/Roles.tsx index 52371e6c4d..c42572b9db 100644 --- a/src/components/[guild]/Roles.tsx +++ b/src/components/[guild]/Roles.tsx @@ -6,6 +6,7 @@ import useGuild from "components/[guild]/hooks/useGuild" import { useScrollBatchedRendering } from "hooks/useScrollBatchedRendering" import dynamic from "next/dynamic" import { useMemo, useState } from "react" +import { Visibility } from "types" import useGuildPermission from "./hooks/useGuildPermission" import useRoleGroup from "./hooks/useRoleGroup" @@ -43,8 +44,12 @@ const Roles = () => { ) }, [roles]) - const publicRoles = sortedRoles.filter((role) => role.visibility !== "HIDDEN") - const hiddenRoles = sortedRoles.filter((role) => role.visibility === "HIDDEN") + const publicRoles = sortedRoles.filter( + (role) => role.visibility !== Visibility.HIDDEN + ) + const hiddenRoles = sortedRoles.filter( + (role) => role.visibility === Visibility.HIDDEN + ) const [renderedRolesCount, setRenderedRolesCount] = useState(BATCH_SIZE) const rolesEl = useScrollBatchedRendering({ diff --git a/src/components/[guild]/SetVisibility/SetVisibility.tsx b/src/components/[guild]/SetVisibility/SetVisibility.tsx index ddd687166b..c54c371415 100644 --- a/src/components/[guild]/SetVisibility/SetVisibility.tsx +++ b/src/components/[guild]/SetVisibility/SetVisibility.tsx @@ -13,11 +13,11 @@ import { Tooltip, useColorModeValue, } from "@chakra-ui/react" -import { Visibility } from "@guildxyz/types" import Button from "components/common/Button" import RadioSelect from "components/common/RadioSelect" import { useRef } from "react" import { FormProvider, useController, useForm, useWatch } from "react-hook-form" +import { Visibility } from "types" import useVisibilityTooltipLabel from "./hooks/useVisibilityTooltipLabel" import { VISIBILITY_DATA } from "./visibilityData" @@ -35,7 +35,7 @@ const SetVisibility = ({ onSave, isLoading, defaultValues = { - visibility: "PUBLIC", + visibility: Visibility.PUBLIC, visibilityRoleId: undefined, }, ...buttonProps diff --git a/src/components/[guild]/SetVisibility/components/VisibilityTag.tsx b/src/components/[guild]/SetVisibility/components/VisibilityTag.tsx index 3ec22dfaee..4497c6917d 100644 --- a/src/components/[guild]/SetVisibility/components/VisibilityTag.tsx +++ b/src/components/[guild]/SetVisibility/components/VisibilityTag.tsx @@ -1,5 +1,5 @@ -import { Visibility } from "@guildxyz/types" import Button from "components/common/Button" +import { Visibility } from "types" import { VISIBILITY_DATA } from "../visibilityData" const VisibilityTag = ({ visibility }: { visibility: Visibility }) => { diff --git a/src/components/[guild]/SetVisibility/hooks/useVisibilityTooltipLabel.tsx b/src/components/[guild]/SetVisibility/hooks/useVisibilityTooltipLabel.tsx index 6be6a64bc4..0f29851adb 100644 --- a/src/components/[guild]/SetVisibility/hooks/useVisibilityTooltipLabel.tsx +++ b/src/components/[guild]/SetVisibility/hooks/useVisibilityTooltipLabel.tsx @@ -1,7 +1,7 @@ -import { Visibility } from "@guildxyz/types" import RoleTag from "components/[guild]/RoleTag" import useGuild from "components/[guild]/hooks/useGuild" import { ReactNode } from "react" +import { Visibility } from "types" import { VISIBILITY_DATA } from "../visibilityData" const useVisibilityTooltipLabel = ( @@ -10,12 +10,12 @@ const useVisibilityTooltipLabel = ( ): ReactNode => { const { roles } = useGuild() const role = - visibilityRoleId && visibility === "PRIVATE" + visibilityRoleId && visibility === Visibility.PRIVATE ? roles?.find(({ id }) => id === visibilityRoleId) : undefined const tooltipDescription = - visibility !== "PRIVATE" ? ( + visibility !== Visibility.PRIVATE ? ( VISIBILITY_DATA[visibility]?.description ?? VISIBILITY_DATA.PUBLIC.description ) : !visibilityRoleId ? ( "Only visible to role holders" diff --git a/src/components/[guild]/SetVisibility/visibilityData.tsx b/src/components/[guild]/SetVisibility/visibilityData.tsx index f754f7f14c..8205cddedc 100644 --- a/src/components/[guild]/SetVisibility/visibilityData.tsx +++ b/src/components/[guild]/SetVisibility/visibilityData.tsx @@ -1,6 +1,6 @@ -import { Visibility } from "@guildxyz/types" import { Option } from "components/common/RadioSelect/RadioSelect" import { Detective, EyeSlash, GlobeHemisphereEast, IconProps } from "phosphor-react" +import { Visibility } from "types" import PrivateVisibilityOptions from "./components/PrivateVisibilityOptions" export const VISIBILITY_DATA: Record< @@ -13,18 +13,18 @@ export const VISIBILITY_DATA: Record< Child?: typeof PrivateVisibilityOptions } > = { - PUBLIC: { + [Visibility.PUBLIC]: { title: "Public", Icon: GlobeHemisphereEast, description: "Visible to everyone", }, - PRIVATE: { + [Visibility.PRIVATE]: { title: "Secret", Icon: Detective, description: "Only visible to users that satisfy...", Child: PrivateVisibilityOptions, }, - HIDDEN: { + [Visibility.HIDDEN]: { title: "Hidden", Icon: EyeSlash, description: "Only visible to admins", diff --git a/src/components/[guild]/Visibility.tsx b/src/components/[guild]/Visibility.tsx index 621981204d..98a9a77cbc 100644 --- a/src/components/[guild]/Visibility.tsx +++ b/src/components/[guild]/Visibility.tsx @@ -1,5 +1,5 @@ import { Tag, TagLabel, TagLeftIcon, TagProps, Tooltip } from "@chakra-ui/react" -import { Visibility as VisibilityType } from "@guildxyz/types" +import { Visibility as VisibilityType } from "types" import useVisibilityTooltipLabel from "./SetVisibility/hooks/useVisibilityTooltipLabel" import { VISIBILITY_DATA } from "./SetVisibility/visibilityData" @@ -19,7 +19,7 @@ const Visibility = ({ const label = useVisibilityTooltipLabel(entityVisibility, visibilityRoleId) - if (entityVisibility === "PUBLIC") return null + if (entityVisibility === VisibilityType.PUBLIC) return null return ( diff --git a/src/components/[guild]/crm/FilterByRoles/FilterByRoles.tsx b/src/components/[guild]/crm/FilterByRoles/FilterByRoles.tsx index ef1e0c43da..f1e989a6a5 100644 --- a/src/components/[guild]/crm/FilterByRoles/FilterByRoles.tsx +++ b/src/components/[guild]/crm/FilterByRoles/FilterByRoles.tsx @@ -22,7 +22,7 @@ import { import { MemberCountWithSyncIndicator } from "components/[guild]/RoleCard/components/MemberCount" import { Funnel } from "phosphor-react" import { memo, useState } from "react" -import { Role } from "types" +import { Role, Visibility } from "types" import useGuild from "../../hooks/useGuild" import FilterByRolesLogicSelector from "./FilterByRolesLogicSelector" import AddAndEditHiddenRoles from "./components/AddAndEditHiddenRoles" @@ -33,8 +33,8 @@ const FilterByRoles = ({ getFilterValue, setFilterValue }: any) => { const { roles } = useGuild() const [searchValue, setSearchValue] = useState("") - const publicRoles = roles?.filter((role) => role.visibility !== "HIDDEN") - const hiddenRoles = roles?.filter((role) => role.visibility === "HIDDEN") + const publicRoles = roles?.filter((role) => role.visibility !== Visibility.HIDDEN) + const hiddenRoles = roles?.filter((role) => role.visibility === Visibility.HIDDEN) const selectedRoleIds: number[] = getFilterValue()?.roleIds ?? [] const setSelectedRoleIds = (newValue: number[]) => { diff --git a/src/components/[guild]/crm/FilterByRoles/components/AddHiddenRoleButton.tsx b/src/components/[guild]/crm/FilterByRoles/components/AddHiddenRoleButton.tsx index 8ed2153506..2ae80796e2 100644 --- a/src/components/[guild]/crm/FilterByRoles/components/AddHiddenRoleButton.tsx +++ b/src/components/[guild]/crm/FilterByRoles/components/AddHiddenRoleButton.tsx @@ -20,6 +20,7 @@ import usePinata from "hooks/usePinata" import useSubmitWithUpload from "hooks/useSubmitWithUpload" import { Plus } from "phosphor-react" import { FormProvider, useForm, useWatch } from "react-hook-form" +import { Visibility } from "types" import getRandomInt from "utils/getRandomInt" import SetHiddenRoleRequirements from "./SetHiddenRoleRequirements" import useCreateHiddenRole from "./useCreateHiddenRole" @@ -41,7 +42,7 @@ const AddHiddenRoleButton = (buttonProps) => { requirements: [], roleType: "NEW", imageUrl: `/guildLogos/${getRandomInt(286)}.svg`, - visibility: "HIDDEN", + visibility: Visibility.HIDDEN, } const methods = useForm({ mode: "all", defaultValues }) diff --git a/src/components/[guild]/crm/FilterByRoles/components/SetHiddenRoleRequirements.tsx b/src/components/[guild]/crm/FilterByRoles/components/SetHiddenRoleRequirements.tsx index 8362f52b3f..36d1052ff0 100644 --- a/src/components/[guild]/crm/FilterByRoles/components/SetHiddenRoleRequirements.tsx +++ b/src/components/[guild]/crm/FilterByRoles/components/SetHiddenRoleRequirements.tsx @@ -17,6 +17,7 @@ const SetHiddenRoleRequirements = (): JSX.Element => { const { fields, append, update } = useFieldArray({ name: "requirements", control, + keyName: "formFieldId", }) // Watching the nested fields too, so we can properly update the list @@ -51,7 +52,7 @@ const SetHiddenRoleRequirements = (): JSX.Element => { const type: RequirementType = getValues(`requirements.${i}.type`) return ( - + diff --git a/src/components/[guild]/crm/useMembers.tsx b/src/components/[guild]/crm/useMembers.tsx index f85013d56a..d28e1a3dd2 100644 --- a/src/components/[guild]/crm/useMembers.tsx +++ b/src/components/[guild]/crm/useMembers.tsx @@ -1,7 +1,7 @@ import useActiveStatusUpdates from "hooks/useActiveStatusUpdates" import { useCallback, useMemo } from "react" import useSWRInfinite from "swr/infinite" -import { PlatformAccountDetails } from "types" +import { PlatformAccountDetails, Visibility } from "types" import { useFetcherWithSign } from "utils/fetcher" import useGuild from "../hooks/useGuild" import { useUserPublic } from "../hooks/useUser" @@ -60,8 +60,12 @@ const useMembers = (queryString: string) => { platformUsers: user.platformUsers.sort(sortAccounts), isShared: user.isShared === true || user.isShared === null, roles: { - hidden: user.roles.filter((role) => role.visibility === "HIDDEN"), - public: user.roles.filter((role) => role.visibility !== "HIDDEN"), + hidden: user.roles.filter( + (role) => role.visibility === Visibility.HIDDEN + ), + public: user.roles.filter( + (role) => role.visibility !== Visibility.HIDDEN + ), }, })) ), diff --git a/src/components/[guild]/messages/Message.tsx b/src/components/[guild]/messages/Message.tsx index da15098e93..2732906cb5 100644 --- a/src/components/[guild]/messages/Message.tsx +++ b/src/components/[guild]/messages/Message.tsx @@ -28,6 +28,7 @@ import { import Card from "components/common/Card" import { Modal } from "components/common/Modal" import { Check, Question, Users } from "phosphor-react" +import { Visibility } from "types" import RoleTag from "../RoleTag" import useGuild from "../hooks/useGuild" import { Message as MessageType } from "./hooks/useGuildMessages" @@ -117,7 +118,7 @@ const Message = ({ key={role.id} name={role.name} imageUrl={role.imageUrl} - isHidden={role.visibility === "HIDDEN"} + isHidden={role.visibility === Visibility.HIDDEN} /> ))} {moreRolesCount > 0 && ( @@ -184,7 +185,7 @@ const Message = ({ key={role.id} name={role.name} imageUrl={role.imageUrl} - isHidden={role.visibility === "HIDDEN"} + isHidden={role.visibility === Visibility.HIDDEN} /> ))} diff --git a/src/components/create-guild/BasicInfo/components/ContactInfo.tsx b/src/components/create-guild/BasicInfo/components/ContactInfo.tsx index 1c6adf60c8..7902c526b5 100644 --- a/src/components/create-guild/BasicInfo/components/ContactInfo.tsx +++ b/src/components/create-guild/BasicInfo/components/ContactInfo.tsx @@ -40,14 +40,16 @@ const ContactInfo = ({ showAddButton = true }: Props): JSX.Element => { } = useFormContext() const { fields, append, remove } = useFieldArray({ + control, name: "contacts", + keyName: "formId", }) return ( {fields.map((contactField, index) => ( - + void + onAdd?: (req: Requirement) => void handleClose: (forceClose?: boolean) => void selectedType?: RequirementType setOnCloseAttemptToast: Dispatch> @@ -205,9 +204,10 @@ const AddRequirementForm = forwardRef( ) => { const FormComponent = REQUIREMENTS[selectedType].formComponent - const methods = useForm({ mode: "all" }) + const methods = useForm({ mode: "all" }) - const roleId: number = useWatch({ name: "id" }) + const roleVisibility: Visibility = useWatch({ name: ".visibility" }) + const roleId: number = useWatch({ name: ".id" }) const [isPresent, safeToRemove] = usePresence() useEffect(() => { @@ -228,13 +228,14 @@ const AddRequirementForm = forwardRef( }, }) - const onSubmit = methods.handleSubmit((data) => { - if (!selectedType) return + const formType = useWatch({ name: ".type" as any, control: methods.control }) - const requirement = schemas.RequirementCreationPayloadSchema.parse({ - ...data, + const onSubmit = methods.handleSubmit((data) => { + const requirement: Requirement = { type: selectedType, - }) + visibility: roleVisibility, + ...data, + } if (!roleId) { onAdd?.(requirement) @@ -265,16 +266,14 @@ const AddRequirementForm = forwardRef( providerTypesOnly={providerTypesOnly} /> - {!!REQUIREMENT_PROVIDED_VALUES[selectedType] && ( + {!!REQUIREMENT_PROVIDED_VALUES[formType ?? selectedType] && ( <> {" "} - } + requirement={{ + type: formType ?? (selectedType as RequirementType), + }} /> )} diff --git a/src/components/create-guild/Requirements/components/ExistingRequirementEditableCard.tsx b/src/components/create-guild/Requirements/components/ExistingRequirementEditableCard.tsx index dd83b83217..d5c8c434fc 100644 --- a/src/components/create-guild/Requirements/components/ExistingRequirementEditableCard.tsx +++ b/src/components/create-guild/Requirements/components/ExistingRequirementEditableCard.tsx @@ -8,10 +8,10 @@ import RequirementImageEditor from "components/[guild]/Requirements/components/R import RequirementNameEditor from "components/[guild]/Requirements/components/RequirementNameEditor" import SetVisibility from "components/[guild]/SetVisibility" import useVisibilityModalProps from "components/[guild]/SetVisibility/hooks/useVisibilityModalProps" -import { ComponentProps, PropsWithChildren, useRef } from "react" +import { PropsWithChildren, useRef } from "react" import { FormProvider, useForm } from "react-hook-form" import REQUIREMENTS from "requirements" -import { Requirement, Requirement as RequirementType } from "types" +import { Requirement as RequirementType } from "types" import mapRequirement from "utils/mapRequirement" import useEditRequirement from "../hooks/useEditRequirement" import BalancyFooter from "./BalancyFooter" @@ -118,7 +118,7 @@ const ExistingRequirementEditModal = ({ onClose, finalFocusRef, }: Omit) => { - const methods = useForm({ mode: "all", defaultValues: requirement }) + const methods = useForm({ mode: "all", defaultValues: requirement }) const { onSubmit: onEditRequirementSubmit, isLoading: isEditRequirementLoading } = useEditRequirement(requirement.roleId, { @@ -201,9 +201,7 @@ const RequirementNameEditorWithSave = ({ children }: PropsWithChildren) onSuccess: () => setVisibilityModalProps.onClose(), }) - const onEditVisibilitySubmit: ComponentProps["onSave"] = ( - visibilityData - ) => { + const onEditVisibilitySubmit = (visibilityData) => { const editedData = { ...requirement, ...visibilityData, diff --git a/src/components/create-guild/Requirements/components/RequirementEditableCard.tsx b/src/components/create-guild/Requirements/components/RequirementEditableCard.tsx index 17546b5862..c394fe8b1b 100644 --- a/src/components/create-guild/Requirements/components/RequirementEditableCard.tsx +++ b/src/components/create-guild/Requirements/components/RequirementEditableCard.tsx @@ -39,10 +39,7 @@ const RequirementEditableCard = ({ const editButtonRef = useRef() const { setValue } = useFormContext() - const methods = useForm({ - mode: "all", - defaultValues: field, - }) + const methods = useForm({ mode: "all", defaultValues: field }) const showViewOriginal = field?.data?.customName || field?.data?.customImage @@ -97,7 +94,7 @@ const RequirementEditableCard = ({ mt={-0.5} defaultValues={{ visibility: field.visibility, - visibilityRoleId: field.visibilityRoleId ?? undefined, + visibilityRoleId: field.visibilityRoleId, }} onSave={({ visibility, visibilityRoleId }) => { setValue(`requirements.${index}.visibility`, visibility, { diff --git a/src/components/create-guild/Requirements/hooks/useBalancy.ts b/src/components/create-guild/Requirements/hooks/useBalancy.ts index c04435d327..b9cb2ba713 100644 --- a/src/components/create-guild/Requirements/hooks/useBalancy.ts +++ b/src/components/create-guild/Requirements/hooks/useBalancy.ts @@ -3,6 +3,7 @@ import useDebouncedState from "hooks/useDebouncedState" import { useEffect, useMemo, useState } from "react" import { useWatch } from "react-hook-form" import useSWR from "swr" +import { Requirement } from "types" import fetcher from "utils/fetcher" import { parseUnits } from "viem" import { Chain, Chains } from "wagmiConfig/chains" @@ -96,7 +97,7 @@ const useBalancy = ( // Fixed logic for single requirement to avoid unnecessary refetch when changing logic const balancyLogic = baseFieldPath !== undefined ? "OR" : logic - const renderedRequirements = useMemo( + const renderedRequirements = useMemo( () => (baseFieldPath !== undefined ? debouncedRequirement diff --git a/src/components/create-guild/Requirements/hooks/useCreateRequirement.ts b/src/components/create-guild/Requirements/hooks/useCreateRequirement.ts index fb585e126e..f5d5820ea5 100644 --- a/src/components/create-guild/Requirements/hooks/useCreateRequirement.ts +++ b/src/components/create-guild/Requirements/hooks/useCreateRequirement.ts @@ -1,9 +1,8 @@ -import { Schemas } from "@guildxyz/types" import useGuild from "components/[guild]/hooks/useGuild" import useRequirements from "components/[guild]/hooks/useRequirements" import useShowErrorToast from "hooks/useShowErrorToast" import useSubmit from "hooks/useSubmit" -import { RequirementCreateResponseOutput } from "types" +import { Requirement } from "types" import { useFetcherWithSign } from "utils/fetcher" import preprocessRequirement from "utils/preprocessRequirement" @@ -16,9 +15,7 @@ const useCreateRequirement = ( const showErrorToast = useShowErrorToast() const fetcherWithSign = useFetcherWithSign() - const createRequirement = async ( - body?: Schemas["RequirementCreationPayload"] - ): Promise => + const createRequirement = async (body: Requirement): Promise => fetcherWithSign([ `/v2/guilds/${guildId}/roles/${roleId}/requirements`, { @@ -28,16 +25,16 @@ const useCreateRequirement = ( ]) return useSubmit< - Schemas["RequirementCreationPayload"], - RequirementCreateResponseOutput + Omit, + Requirement & { deletedRequirements?: number[] } >(createRequirement, { onSuccess: (response) => { if ( (response.type === "ALLOWLIST" || response.type === "ALLOWLIST_EMAIL") && response.data?.fileId ) { - // TODO: add the "status" prop to the schema - ;(response.data as any).status = "IN-PROGRESS" + response.data ??= {} + response.data.status = "IN-PROGRESS" } mutateRequirements( diff --git a/src/components/create-guild/Requirements/hooks/useEditRequirement.ts b/src/components/create-guild/Requirements/hooks/useEditRequirement.ts index 18eb66aeb1..bc4f42379f 100644 --- a/src/components/create-guild/Requirements/hooks/useEditRequirement.ts +++ b/src/components/create-guild/Requirements/hooks/useEditRequirement.ts @@ -1,18 +1,17 @@ -import { Schemas } from "@guildxyz/types" import useGuild from "components/[guild]/hooks/useGuild" import useRequirements from "components/[guild]/hooks/useRequirements" import useShowErrorToast from "hooks/useShowErrorToast" import useSubmit from "hooks/useSubmit" import useToast from "hooks/useToast" -import { RequirementCreateResponseOutput } from "types" +import { Requirement } from "types" import { useFetcherWithSign } from "utils/fetcher" import preprocessRequirement from "utils/preprocessRequirement" +type EditedRequirement = Requirement & { deletedRequirements?: number[] } + const useEditRequirement = ( roleId: number, - config?: { - onSuccess?: (editedRequirement: RequirementCreateResponseOutput) => void - } + config?: { onSuccess?: (editedRequirement: EditedRequirement) => void } ) => { const { id: guildId } = useGuild() const { mutate: mutateRequirements } = useRequirements(roleId) @@ -21,29 +20,27 @@ const useEditRequirement = ( const showErrorToast = useShowErrorToast() const fetcherWithSign = useFetcherWithSign() - const editRequirement = async ( - data?: Schemas["RequirementUpdatePayload"] & { id: number } - ): Promise => + const editRequirement = async (data: Requirement): Promise => fetcherWithSign([ - `/v2/guilds/${guildId}/roles/${roleId}/requirements/${data?.id}`, + `/v2/guilds/${guildId}/roles/${roleId}/requirements/${data.id}`, { method: "PUT", - body: preprocessRequirement(data), + body: preprocessRequirement({ + ...data, + id: undefined, + }), }, ]) - return useSubmit< - Schemas["RequirementUpdatePayload"] & { id: number }, - RequirementCreateResponseOutput - >(editRequirement, { + return useSubmit(editRequirement, { onSuccess: (editedRequirement) => { if ( (editedRequirement.type === "ALLOWLIST" || editedRequirement.type === "ALLOWLIST_EMAIL") && editedRequirement.data?.fileId ) { - // TODO: add the "status" prop to the schema - ;(editedRequirement.data as any).status = "IN-PROGRESS" + editedRequirement.data ??= {} + editedRequirement.data.status = "IN-PROGRESS" } toast({ diff --git a/src/components/create-guild/Requirements/hooks/useHandleRequirementState.ts b/src/components/create-guild/Requirements/hooks/useHandleRequirementState.ts index aea2edd6d6..672ef57e06 100644 --- a/src/components/create-guild/Requirements/hooks/useHandleRequirementState.ts +++ b/src/components/create-guild/Requirements/hooks/useHandleRequirementState.ts @@ -25,7 +25,7 @@ const useHandleRequirementState = (methods) => { } const append = (req: Requirement) => { - const reqToAdd = { ...req, id: Date.now() } + const reqToAdd = { id: Date.now(), ...req } if (freeEntry) { remove(0) } diff --git a/src/components/create-guild/hooks/useCreateRole.tsx b/src/components/create-guild/hooks/useCreateRole.tsx index d5fb058bb8..5c57b88f36 100644 --- a/src/components/create-guild/hooks/useCreateRole.tsx +++ b/src/components/create-guild/hooks/useCreateRole.tsx @@ -8,13 +8,7 @@ import useCustomPosthogEvents from "hooks/useCustomPosthogEvents" import useMatchMutate from "hooks/useMatchMutate" import useShowErrorToast from "hooks/useShowErrorToast" import { SignedValidation, useSubmitWithSign } from "hooks/useSubmit" -import { - GuildBase, - GuildPlatform, - Requirement, - RequirementCreationPayloadWithTempID, - Role, -} from "types" +import { GuildBase, GuildPlatform, Requirement, Role } from "types" import fetcher from "utils/fetcher" import replacer from "utils/guildJsonReplacer" import preprocessRequirement from "utils/preprocessRequirement" @@ -25,7 +19,7 @@ export type RoleToCreate = Omit< > & { guildId: number roleType?: "NEW" - requirements: RequirementCreationPayloadWithTempID[] + requirements: Omit[] } type CreateRoleResponse = Role & { diff --git a/src/hooks/useSubmitTransaction.ts b/src/hooks/useSubmitTransaction.ts index a43ad3e46e..2865977fc5 100644 --- a/src/hooks/useSubmitTransaction.ts +++ b/src/hooks/useSubmitTransaction.ts @@ -102,10 +102,7 @@ const useSubmitTransaction = ( functionName: contractCallConfig.functionName as ContractFunctionName, args: contractCallConfig.args as ContractFunctionArgs, value: contractCallConfig.value as bigint, - shouldFetch: - typeof contractCallConfig.query?.enabled === "boolean" - ? contractCallConfig.query.enabled - : true, + shouldFetch: contractCallConfig.query?.enabled ?? true, }) const { diff --git a/src/pages/[guild]/members.tsx b/src/pages/[guild]/members.tsx index bf39a78dec..c75d8f2ecf 100644 --- a/src/pages/[guild]/members.tsx +++ b/src/pages/[guild]/members.tsx @@ -30,6 +30,7 @@ import Head from "next/head" import { useRouter } from "next/router" import ErrorPage from "pages/_error" import { useEffect, useMemo, useRef, useState } from "react" +import { Visibility } from "types" const columnHelper = createColumnHelper() const getRowId = (row: Member) => `user_${row.userId}` @@ -159,7 +160,7 @@ const MembersPage = (): JSX.Element => { getRowId, }) - const hasHiddenRoles = roles?.some((role) => role.visibility === "HIDDEN") + const hasHiddenRoles = roles?.some((role) => role.visibility === Visibility.HIDDEN) useEffect(() => { const hiddenRolesColumn = table .getAllLeafColumns() diff --git a/src/platforms/components/SelectRoleOrSetRequirements.tsx b/src/platforms/components/SelectRoleOrSetRequirements.tsx index 1ab219483f..56193ed3b3 100644 --- a/src/platforms/components/SelectRoleOrSetRequirements.tsx +++ b/src/platforms/components/SelectRoleOrSetRequirements.tsx @@ -9,7 +9,7 @@ import useRoleGroup from "components/[guild]/hooks/useRoleGroup" import SetRequirements from "components/create-guild/Requirements" import rewards, { PlatformAsRewardRestrictions } from "platforms/rewards" import { useFormContext, useWatch } from "react-hook-form" -import { PlatformName } from "types" +import { PlatformName, Visibility } from "types" import getRandomInt from "utils/getRandomInt" type Props = { @@ -63,7 +63,7 @@ const SelectRoleOrSetRequirements = ({ isRoleSelectorDisabled }: Props) => { unregister("roleIds") setValue("name", data?.roleName || `New ${rewards[selection].name} role`) setValue("imageUrl", data?.imageUrl || `/guildLogos/${getRandomInt(286)}.svg`) - setValue("roleVisibility", "PUBLIC") + setValue("roleVisibility", Visibility.PUBLIC) } setActiveTab(value) diff --git a/src/requirements/Airdrop/AirdropRequirement.tsx b/src/requirements/Airdrop/AirdropRequirement.tsx index 29da3c7808..a25b44a57a 100644 --- a/src/requirements/Airdrop/AirdropRequirement.tsx +++ b/src/requirements/Airdrop/AirdropRequirement.tsx @@ -1,4 +1,5 @@ import { Icon, Text, useDisclosure } from "@chakra-ui/react" +import { Schemas } from "@guildxyz/types" import Requirement, { RequirementProps, } from "components/[guild]/Requirements/components/Requirement" @@ -9,7 +10,10 @@ import { ArrowSquareIn } from "phosphor-react" import REQUIREMENTS from "requirements" const AirdropRequirement = ({ ...rest }: RequirementProps): JSX.Element => { - const requirement = useRequirementContext<"GUILD_SNAPSHOT">() + const requirement = useRequirementContext() as Extract< + Schemas["Requirement"], + { type: "GUILD_SNAPSHOT" } + > const { isHidden } = requirement?.data diff --git a/src/requirements/Allowlist/AllowlistRequirement.tsx b/src/requirements/Allowlist/AllowlistRequirement.tsx index 4d18cd8197..f745842957 100644 --- a/src/requirements/Allowlist/AllowlistRequirement.tsx +++ b/src/requirements/Allowlist/AllowlistRequirement.tsx @@ -23,14 +23,13 @@ function HiddenAllowlistText({ isEmail }: { isEmail: boolean }) { } const AllowlistRequirement = ({ ...rest }: RequirementProps): JSX.Element => { - const requirement = useRequirementContext<"ALLOWLIST" | "ALLOWLIST_EMAIL">() - // TODO: we should add addressCount to the schema, and remove the cast later on - const castedRequirement = requirement as unknown as Extract< + const requirement = useRequirementContext() as Extract< Schemas["Requirement"], { type: "ALLOWLIST" | "ALLOWLIST_EMAIL" } > & { data: { // These are not included in the schemas, as these are appended on-the-fly by the BE, when sending the response + fileId?: string addressCount?: number } } @@ -43,12 +42,12 @@ const AllowlistRequirement = ({ ...rest }: RequirementProps): JSX.Element => { hideAllowlist, addressCount, fileId, - } = castedRequirement.data + } = requirement.data const willSearchAddresses = search !== debouncedSearch const { data: req, isValidating: isSearchingAddresses } = useRequirement( - castedRequirement?.roleId, - castedRequirement?.id, + requirement?.roleId, + requirement?.id, debouncedSearch ) @@ -61,12 +60,12 @@ const AllowlistRequirement = ({ ...rest }: RequirementProps): JSX.Element => { const { isOpen, onOpen, onClose } = useDisclosure() - const isEmail = castedRequirement.type === "ALLOWLIST_EMAIL" + const isEmail = requirement.type === "ALLOWLIST_EMAIL" - const { reqAccesses } = useRoleMembership(castedRequirement.roleId) + const { reqAccesses } = useRoleMembership(requirement.roleId) const hasAccess = reqAccesses?.find( - ({ requirementId }) => requirementId === castedRequirement.id + ({ requirementId }) => requirementId === requirement.id )?.access const shouldShowSearchHints = diff --git a/src/requirements/Farcaster/FarcasterRequirement.tsx b/src/requirements/Farcaster/FarcasterRequirement.tsx index e00b75f082..27d48c8e5f 100644 --- a/src/requirements/Farcaster/FarcasterRequirement.tsx +++ b/src/requirements/Farcaster/FarcasterRequirement.tsx @@ -14,7 +14,7 @@ import { useFarcasterUser } from "./hooks/useFarcasterUsers" const FarcasterProfile = (props: RequirementProps) => ( } {...props} > @@ -59,7 +59,7 @@ const FarcasterTotalFollowers = (props: RequirementProps) => { return ( } - image={REQUIREMENTS.FARCASTER_TOTAL_FOLLOWERS.icon.toString()} + image={REQUIREMENTS.FARCASTER.icon.toString()} {...props} > {`Have at least ${data?.min ?? "-"} followers on Farcaster`} @@ -79,7 +79,7 @@ const FarcasterLikeRecast = (props: RequirementProps) => { return ( } - image={REQUIREMENTS.FARCASTER_LIKE.icon.toString()} + image={REQUIREMENTS.FARCASTER.icon.toString()} {...props} > {type === "FARCASTER_LIKE" ? "Like" : "Recast"} @@ -105,7 +105,7 @@ const FarcasterFollowChannel = (props: RequirementProps) => { return ( } - image={REQUIREMENTS.FARCASTER_FOLLOW_CHANNEL.icon.toString()} + image={REQUIREMENTS.FARCASTER.icon.toString()} {...props} > {"Follow the "} @@ -136,13 +136,13 @@ const FarcasterIncludeText = (props: RequirementProps) => { return ( } - image={REQUIREMENTS.FARCASTER_BIO.icon.toString()} + image={REQUIREMENTS.FARCASTER.icon.toString()} {...props} > {"Have "} - {` in your ${REQUIREMENTS.FARCASTER_BIO.name} ${PROFILE_TARGETS[type]}`} + {` in your ${REQUIREMENTS.FARCASTER.name} ${PROFILE_TARGETS[type]}`} ) diff --git a/src/requirements/Fuel/FuelRequirement.tsx b/src/requirements/Fuel/FuelRequirement.tsx index db607a2a84..a9a8ec0422 100644 --- a/src/requirements/Fuel/FuelRequirement.tsx +++ b/src/requirements/Fuel/FuelRequirement.tsx @@ -12,11 +12,6 @@ const NULL_FUEL_ADDRESS = const FuelRequirement = (props: RequirementProps) => { const { type, address, data } = useRequirementContext() - - // TODO: remove these once we implement the Fuel requirement schema - const requirementAddress = address as `0x${string}` - const requirementDataSymbol = data.symbol - const tagBg = useColorModeValue("white", "blackAlpha.300") return ( @@ -52,11 +47,11 @@ const FuelRequirement = (props: RequirementProps) => { } `} {address === NULL_FUEL_ADDRESS ? ( "ETH" - ) : requirementDataSymbol ? ( - {requirementDataSymbol} + ) : data?.symbol ? ( + {data.symbol} ) : ( - - {shortenHex(requirementAddress)} + + {shortenHex(address)} )} diff --git a/src/requirements/Lens/LensRequirement.tsx b/src/requirements/Lens/LensRequirement.tsx index c224fe3ac4..3f2d6a9a73 100644 --- a/src/requirements/Lens/LensRequirement.tsx +++ b/src/requirements/Lens/LensRequirement.tsx @@ -51,7 +51,7 @@ const LensRequirement = (props: RequirementProps) => { return return ( - + {(() => { switch (requirement.type) { case "LENS_REACT": @@ -100,7 +100,7 @@ const LensFollowRequirement = (props: RequirementProps) => { return ( diff --git a/src/requirements/Lens/hooks/useLensProfile.ts b/src/requirements/Lens/hooks/useLensProfile.ts index b1a5e53e58..de4649aed5 100644 --- a/src/requirements/Lens/hooks/useLensProfile.ts +++ b/src/requirements/Lens/hooks/useLensProfile.ts @@ -45,7 +45,7 @@ const useLensProfile = (id: string) => { value: data.id, img: data.metadata?.picture?.optimized?.uri ?? - (REQUIREMENTS.LENS_ACTION.icon as string), + (REQUIREMENTS.LENS.icon as string), } : undefined, } diff --git a/src/requirements/Lens/hooks/useLensProfiles.ts b/src/requirements/Lens/hooks/useLensProfiles.ts index c5521a90ec..9a17db47a7 100644 --- a/src/requirements/Lens/hooks/useLensProfiles.ts +++ b/src/requirements/Lens/hooks/useLensProfiles.ts @@ -66,9 +66,7 @@ const useLensProfiles = (searchQuery: string) => { handles: data?.map(({ id, handle: { localName }, metadata }) => ({ label: `${localName}.lens`, value: id, - img: - metadata?.picture?.optimized?.uri ?? - (REQUIREMENTS.LENS_ACTION.icon as string), + img: metadata?.picture?.optimized?.uri ?? (REQUIREMENTS.LENS.icon as string), })), isLoading, } diff --git a/src/requirements/Mirror/MirrorRequirement.tsx b/src/requirements/Mirror/MirrorRequirement.tsx index abc3be01d5..66eb197955 100644 --- a/src/requirements/Mirror/MirrorRequirement.tsx +++ b/src/requirements/Mirror/MirrorRequirement.tsx @@ -6,19 +6,14 @@ import Requirement, { import { useRequirementContext } from "components/[guild]/Requirements/components/RequirementContext" import DataBlock from "components/common/DataBlock" import shortenHex from "utils/shortenHex" -import { Chain } from "wagmiConfig/chains" import useMirrorEdition from "./hooks/useMirrorEdition" const MirrorRequirement = (props: RequirementProps): JSX.Element => { const requirement = useRequirementContext() - // TODO: we could remove the cast once we'll have schemas for this requirement - const requirementChain = requirement.chain as Chain - const requirementAddress = requirement.address as `0x${string}` - const { isLoading, name, image, error } = useMirrorEdition( - requirementAddress, - requirementChain + requirement.address, + requirement.chain ) return ( @@ -39,7 +34,7 @@ const MirrorRequirement = (props: RequirementProps): JSX.Element => { isLoading={isLoading} error={error && "API error, please contact Mirror to report"} > - {name ?? shortenHex(requirementAddress, 3)} + {name ?? shortenHex(requirement.address, 3)} {` Mirror edition`} diff --git a/src/requirements/Nft/NftRequirement.tsx b/src/requirements/Nft/NftRequirement.tsx index afa80692c4..a11b11e369 100644 --- a/src/requirements/Nft/NftRequirement.tsx +++ b/src/requirements/Nft/NftRequirement.tsx @@ -19,7 +19,6 @@ import useSWRImmutable from "swr/immutable" import { Trait } from "types" import { GUILD_PIN_CONTRACTS } from "utils/guildCheckout/constants" import shortenHex from "utils/shortenHex" -import { Chain } from "wagmiConfig/chains" import useNftMetadata, { NOUNS_BACKGROUNDS, useNftMetadataWithTraits, @@ -43,13 +42,9 @@ const getNounsRequirementType = (trait: Trait) => const NftRequirement = (props: RequirementProps) => { const requirement = useRequirementContext() - // TODO: we could remove the cast once we'll have schemas for "ERC..." requirements - const requirementChain = requirement.chain as Chain - const requirementAddress = requirement.address as `0x${string}` - // This is a really basic solution, and it'll only handle the "Joined Guild" NFTs. We should probably think about a better solution in the future. const isGuildPin = - GUILD_PIN_CONTRACTS[requirementChain] === requirementAddress.toLowerCase() + GUILD_PIN_CONTRACTS[requirement.chain] === requirement.address.toLowerCase() const guildIdAttribute = isGuildPin && @@ -64,10 +59,10 @@ const NftRequirement = (props: RequirementProps) => { const { name: guildPinGuildName } = useGuild(guildIdAttribute ?? "") const { metadata: metadataWithTraits, isLoading: isMetadataWithTraitsLoading } = - useNftMetadata(requirementChain, requirementAddress, requirement.data?.id) + useNftMetadata(requirement.chain, requirement.address, requirement.data?.id) const { metadata, isLoading } = useNftMetadataWithTraits( - requirementChain, - requirementAddress + requirement.chain, + requirement.address ) const nftDataLoading = isLoading || isMetadataWithTraitsLoading @@ -88,7 +83,7 @@ const NftRequirement = (props: RequirementProps) => { : metadataWithTraits?.image || metadata?.image const shouldRenderImage = - ["ETHEREUM", "POLYGON"].includes(requirementChain) && + ["ETHEREUM", "POLYGON"].includes(requirement.chain) && (nftName || (requirement.name && requirement.name !== "-")) && (nftDataLoading || nftImage) @@ -134,7 +129,7 @@ const NftRequirement = (props: RequirementProps) => { {nftName || (!requirement.name || requirement.name === "-" ? metadata?.slug ?? ( - {shortenHex(requirementAddress, 3)} + {shortenHex(requirement.address, 3)} ) : requirement.name !== "-" && requirement.name)} diff --git a/src/requirements/Nft/providedValue/NftAmountProvidedValue.tsx b/src/requirements/Nft/providedValue/NftAmountProvidedValue.tsx index 6a5c2f771f..75765f02fd 100644 --- a/src/requirements/Nft/providedValue/NftAmountProvidedValue.tsx +++ b/src/requirements/Nft/providedValue/NftAmountProvidedValue.tsx @@ -4,7 +4,6 @@ import DataBlock from "components/common/DataBlock" import { ProvidedValueDisplayProps } from "requirements" import { GUILD_PIN_CONTRACTS } from "utils/guildCheckout/constants" import useNftMetadata, { useNftMetadataWithTraits } from "../hooks/useNftMetadata" -import { Chain } from "wagmiConfig/chains" export function hasOnlyTypeProperty(obj) { const keys = Object.keys(obj) @@ -12,12 +11,8 @@ export function hasOnlyTypeProperty(obj) { } const NftAmountProvidedValue = ({ requirement }: ProvidedValueDisplayProps) => { - // TODO: we could remove the cast once we'll have schemas for "ERC..." requirements - const requirementChain = requirement.chain as Chain - const requirementAddress = requirement.address as `0x${string}` - const isGuildPin = - GUILD_PIN_CONTRACTS[requirementChain] === requirement?.address?.toLowerCase() + GUILD_PIN_CONTRACTS[requirement.chain] === requirement?.address?.toLowerCase() const guildIdAttribute = isGuildPin && requirement.data?.attributes?.find((attr) => attr.trait_type === "guildId") @@ -26,11 +21,14 @@ const NftAmountProvidedValue = ({ requirement }: ProvidedValueDisplayProps) => { const { name: guildPinGuildName } = useGuild(guildIdAttribute ?? "") const { metadata: metadataWithTraits } = useNftMetadata( - requirementChain, - requirementAddress, + requirement.chain, + requirement.address, requirement.data?.id ) - const { metadata } = useNftMetadataWithTraits(requirementChain, requirementAddress) + const { metadata } = useNftMetadataWithTraits( + requirement.chain, + requirement.address + ) const nftName = isGuildPin ? ( <> diff --git a/src/requirements/Payment/PaymentRequirement.tsx b/src/requirements/Payment/PaymentRequirement.tsx index 2a75820173..035870beb4 100644 --- a/src/requirements/Payment/PaymentRequirement.tsx +++ b/src/requirements/Payment/PaymentRequirement.tsx @@ -27,14 +27,14 @@ const PaymentRequirement = (props: RequirementProps): JSX.Element => { chain, address, data: requirementData, - } = useRequirementContext<"PAYMENT">() + } = useRequirementContext() const { token, fee, multiplePayments, isLoading: isVaultLoading, error: vaultError, - } = useVault(address as `0x${string}`, requirementData?.id, chain) + } = useVault(address, requirementData?.id, chain) const isNativeCurrency = token === NULL_ADDRESS diff --git a/src/requirements/Payment/components/WithdrawButton/WithdrawButton.tsx b/src/requirements/Payment/components/WithdrawButton/WithdrawButton.tsx index d6a611224e..e2abdc918f 100644 --- a/src/requirements/Payment/components/WithdrawButton/WithdrawButton.tsx +++ b/src/requirements/Payment/components/WithdrawButton/WithdrawButton.tsx @@ -12,12 +12,7 @@ import { CHAIN_CONFIG, Chains } from "wagmiConfig/chains" import useWithdraw from "./hooks/useWithdraw" const WithdrawButton = (): JSX.Element => { - const { - address: vaultAddressAsString, - chain, - data, - } = useRequirementContext<"PAYMENT">() - const vaultAddress = vaultAddressAsString as `0x${string}` + const { address: vaultAddress, chain, data } = useRequirementContext() const { owner, token, balance } = useVault(vaultAddress, data?.id, chain) const { data: { symbol, decimals }, @@ -33,7 +28,7 @@ const WithdrawButton = (): JSX.Element => { const { onSubmitTransaction, isPreparing, isLoading, error } = useWithdraw( vaultAddress, - +data.id, + data?.id, chain ) diff --git a/src/requirements/Token/TokenRequirement.tsx b/src/requirements/Token/TokenRequirement.tsx index b93b448101..70fa4a3d7c 100644 --- a/src/requirements/Token/TokenRequirement.tsx +++ b/src/requirements/Token/TokenRequirement.tsx @@ -9,24 +9,20 @@ import Requirement, { import RequirementChainIndicator from "components/[guild]/Requirements/components/RequirementChainIndicator" import { useRequirementContext } from "components/[guild]/Requirements/components/RequirementContext" import useTokenData from "hooks/useTokenData" -import { Chain, CHAIN_CONFIG } from "wagmiConfig/chains" +import { CHAIN_CONFIG } from "wagmiConfig/chains" type Props = RequirementProps const TokenRequirement = ({ ...rest }: Props) => { const requirement = useRequirementContext() - // TODO: we could remove the cast once we'll have schemas for "ERC..." requirements - const requirementChain = requirement.chain as Chain - const requirementAddress = requirement.address as `0x${string}` - - const { data, isValidating } = useTokenData(requirementChain, requirementAddress) + const { data, isValidating } = useTokenData(requirement.chain, requirement.address) return ( ERC20 @@ -57,7 +53,7 @@ const TokenRequirement = ({ ...rest }: Props) => { : "any amount of" } ${ requirement.type === "COIN" - ? CHAIN_CONFIG[requirementChain].nativeCurrency.symbol + ? CHAIN_CONFIG[requirement.chain].nativeCurrency.symbol : data?.symbol ?? requirement.symbol }`} diff --git a/src/requirements/Token/providedValue/TokenProvidedValue.tsx b/src/requirements/Token/providedValue/TokenProvidedValue.tsx index 3443843b02..8e339986d0 100644 --- a/src/requirements/Token/providedValue/TokenProvidedValue.tsx +++ b/src/requirements/Token/providedValue/TokenProvidedValue.tsx @@ -3,16 +3,11 @@ import RequirementChainIndicator from "components/[guild]/Requirements/component import useTokenData from "hooks/useTokenData" import { ProvidedValueDisplayProps } from "requirements" import { NULL_ADDRESS } from "utils/guildCheckout/constants" -import { Chain } from "wagmiConfig/chains" const TokenProvidedValue = ({ requirement }: ProvidedValueDisplayProps) => { - // TODO: we could remove the cast once we'll have schemas for "ERC..." requirements - const requirementChain = requirement.chain as Chain - const requirementAddress = requirement.address as `0x${string}` - const { data: { symbol }, - } = useTokenData(requirementChain, requirementAddress ?? NULL_ADDRESS) + } = useTokenData(requirement?.chain, requirement?.address ?? NULL_ADDRESS) const tagBg = useColorModeValue("blackAlpha.100", "blackAlpha.300") diff --git a/src/requirements/Uniswap/UniswapRequirement.tsx b/src/requirements/Uniswap/UniswapRequirement.tsx index 3087c4a47a..64c05b6b84 100644 --- a/src/requirements/Uniswap/UniswapRequirement.tsx +++ b/src/requirements/Uniswap/UniswapRequirement.tsx @@ -1,5 +1,5 @@ import { HStack, Skeleton } from "@chakra-ui/react" -import { consts } from "@guildxyz/types" +import { Schemas, consts } from "@guildxyz/types" import Requirement, { RequirementProps, } from "components/[guild]/Requirements/components/Requirement" @@ -40,7 +40,10 @@ const UniswapRequirement = ({ ...rest }: RequirementProps): JSX.Element => { }, roleId, id, - } = useRequirementContext<"UNISWAP_V3_POSITIONS">() + } = useRequirementContext() as Extract< + Schemas["Requirement"], + { type: "UNISWAP_V3_POSITIONS" } + > const { symbol0, symbol1 } = useSymbolsOfPair( Chains[chain], diff --git a/src/requirements/WalletActivity/WalletActivityRequirement.tsx b/src/requirements/WalletActivity/WalletActivityRequirement.tsx index 6e249dc6d6..2b4b1824ed 100644 --- a/src/requirements/WalletActivity/WalletActivityRequirement.tsx +++ b/src/requirements/WalletActivity/WalletActivityRequirement.tsx @@ -27,16 +27,7 @@ const requirementIcons: Record< } const WalletActivityRequirement = (props: RequirementProps): JSX.Element => { - const requirement = useRequirementContext< - | "COVALENT_FIRST_TX" - | "COVALENT_FIRST_TX_RELATIVE" - | "COVALENT_CONTRACT_DEPLOY" - | "COVALENT_CONTRACT_DEPLOY_RELATIVE" - | "COVALENT_TX_COUNT" - | "COVALENT_TX_COUNT_RELATIVE" - | "COVALENT_TX_VALUE" - | "COVALENT_TX_VALUE_RELATIVE" - >() + const requirement = useRequirementContext() const maxAmount = requirement.data?.timestamps?.maxAmount const minAmount = requirement.data?.timestamps?.minAmount diff --git a/src/requirements/index.ts b/src/requirements/index.ts index 2a46012186..e065883810 100644 --- a/src/requirements/index.ts +++ b/src/requirements/index.ts @@ -1,4 +1,3 @@ -import { Schemas } from "@guildxyz/types" import { RequirementProps } from "components/[guild]/Requirements/components/Requirement" import { Icon } from "phosphor-react" import { ComponentType } from "react" @@ -17,7 +16,8 @@ export type ProvidedValueDisplayProps = { requirement: Partial } -export type RequirementType = Schemas["Requirement"]["type"] +const requirementTypes = REQUIREMENTS_DATA.flatMap((obj) => obj.types) +export type RequirementType = (typeof requirementTypes)[number] | "HIDDEN" export type RequirementFormProps = { baseFieldPath: string diff --git a/src/types.ts b/src/types.ts index 93af640e75..dbe663491c 100644 --- a/src/types.ts +++ b/src/types.ts @@ -1,9 +1,8 @@ -import { FarcasterProfile, schemas, Schemas, Visibility } from "@guildxyz/types" +import { FarcasterProfile, Schemas } from "@guildxyz/types" import { FeatureFlag } from "components/[guild]/EditGuild/components/FeatureFlags" import { ContractCallFunction } from "components/[guild]/RolePlatforms/components/AddRoleRewardModal/components/AddContractCallPanel/components/CreateNftForm/hooks/useCreateNft" import { RequirementType } from "requirements" import type { Chain, Chains } from "wagmiConfig/chains" -import { z } from "zod" export const FUEL_ADDRESS_REGEX = /^0x[a-f0-9]{64}$/i @@ -492,10 +491,26 @@ type Trait = { } } -type Requirement = z.output -type RequirementCreateResponseOutput = z.output< - typeof schemas.RequirementCreateResponseSchema -> +type Requirement = { + id: number + type: RequirementType + address?: `0x${string}` + chain?: Chain + data?: Record + roleId: number + name: string + symbol: string + decimals?: number + isNegated?: boolean + visibility?: Visibility + visibilityRoleId?: number | null + + // Props used inside the forms on the UI + formFieldId?: number + balancyDecimals?: number + createdAt?: string + updatedAt?: string +} type RolePlatformStatus = "ALL_CLAIMED" | "NOT_STARTED" | "ENDED" | "ACTIVE" @@ -517,6 +532,12 @@ type RolePlatform = { dynamicAmount?: Schemas["DynamicAmount"] } +enum Visibility { + PUBLIC = "PUBLIC", + PRIVATE = "PRIVATE", + HIDDEN = "HIDDEN", +} + type SimpleRole = { id: number name: string @@ -615,13 +636,9 @@ type Guild = { parentRoles: number[] } -type RequirementCreationPayloadWithTempID = Schemas["RequirementCreationPayload"] & { - id?: number -} - type RoleFormType = Partial< Omit & { - requirements: Array> + requirements: Array> rolePlatforms: Array< Partial> & { guildPlatform?: GuildPlatformWithOptionalId @@ -774,7 +791,7 @@ type DetailedPinLeaderboardUserData = { pins: LeaderboardPinData[] } -export { supportedEventSources, supportedSocialLinks, ValidationMethod } +export { ValidationMethod, Visibility, supportedEventSources, supportedSocialLinks } export type { BaseUser, CoingeckoToken, @@ -802,8 +819,6 @@ export type { Poap, RequestMintLinksForm, Requirement, - RequirementCreateResponseOutput, - RequirementCreationPayloadWithTempID, RequirementType, Rest, Role, diff --git a/src/utils/formatRelativeTimeFromNow.ts b/src/utils/formatRelativeTimeFromNow.ts index 2d2deb91c7..a6a0860aea 100644 --- a/src/utils/formatRelativeTimeFromNow.ts +++ b/src/utils/formatRelativeTimeFromNow.ts @@ -3,7 +3,7 @@ import pluralize from "./pluralize" export const DAY_IN_MS = 86400000 export const MINUTE_IN_MS = 60000 -const formatRelativeTimeFromNow = (since?: number) => { +const formatRelativeTimeFromNow = (since: number) => { if (!since) return undefined const sinceDays = since / DAY_IN_MS diff --git a/src/utils/mapRequirement.ts b/src/utils/mapRequirement.ts index 2c5f55fc79..be0b263b8a 100644 --- a/src/utils/mapRequirement.ts +++ b/src/utils/mapRequirement.ts @@ -1,10 +1,8 @@ -import { Requirement, RequirementCreateResponseOutput } from "types" +import { Requirement } from "types" -const mapRequirement = ( - requirement?: Requirement | RequirementCreateResponseOutput -) => { +const mapRequirement = (requirement?: Requirement) => { // Using structuredClone so we don't modify the original requirement unintentionally - const newRequirement = structuredClone(requirement) + const newRequirement: Requirement = structuredClone(requirement) if (requirement.type === "COIN") newRequirement.address = "0x0000000000000000000000000000000000000000" diff --git a/src/utils/preprocessRequirement.ts b/src/utils/preprocessRequirement.ts index 58233fd31b..2bc2fe9be8 100644 --- a/src/utils/preprocessRequirement.ts +++ b/src/utils/preprocessRequirement.ts @@ -1,12 +1,6 @@ -import { Schemas } from "@guildxyz/types" import { Requirement } from "types" -const preprocessRequirement = ( - requirement?: - | Partial - | Partial - | Partial -): Requirement => { +const preprocessRequirement = (requirement: Partial): Requirement => { const processedRequirement: Requirement = structuredClone( requirement ) as Requirement From fb79f5df1b0ecb5cf908df0a3bc4d036c2db8cfa Mon Sep 17 00:00:00 2001 From: BrickheadJohnny Date: Wed, 26 Jun 2024 14:53:47 +0200 Subject: [PATCH 25/41] Revert "Revert "refactor: remove the custom `Requirement` type (#1318)"" This reverts commit d3fc7c66dd16f0b0028caf4979688ed5458bea2c. --- package-lock.json | 250 +++++++++--------- package.json | 2 +- .../components/OrderRolesModal.tsx | 3 +- .../AddAndOrderRoles/hooks/useAddRoleForm.ts | 6 +- .../AddRewardButton/AddRewardButton.tsx | 7 +- .../AddRewardButton/SelectRolePanel.tsx | 8 +- .../hooks/useCreateRequirements.ts | 10 +- .../hooks/useMutateAdditionsToRoles.ts | 39 +-- .../hooks/useSubmitAddReward.ts | 8 +- .../AddRewardButton/useCreateTokenReward.ts | 6 +- .../RequirementErrorConfigContext.tsx | 2 +- .../[guild]/Requirements/RoleRequirements.tsx | 2 +- .../components/ActivateGuildPinForm.tsx | 3 +- .../GuildCheckout/components/BuyTotal.tsx | 18 +- .../components/PaymentFeeCurrency.tsx | 4 +- .../components/PurchaseFeeAndTotal.tsx | 11 +- .../components/PurchasedRequirementInfo.tsx | 7 +- .../components/buttons/BuyAllowanceButton.tsx | 8 +- .../components/buttons/BuyButton.tsx | 12 +- .../buttons/PurchaseAllowanceButton.tsx | 8 +- .../GuildCheckout/hooks/usePayFee.ts | 12 +- .../GuildCheckout/hooks/usePurchaseAsset.ts | 2 +- .../Requirements/components/Requirement.tsx | 5 +- .../components/RequirementChainIndicator.tsx | 5 +- .../components/RequirementContext.tsx | 11 +- .../RequirementDisplayComponent.tsx | 2 +- src/components/[guild]/RoleCard/RoleCard.tsx | 7 +- .../EditRole/hooks/useEditRoleForm.ts | 5 +- .../hooks/useUpdateRolePlatformVisibility.ts | 3 +- .../components/SelectExistingPlatform.tsx | 10 +- src/components/[guild]/Roles.tsx | 9 +- .../[guild]/SetVisibility/SetVisibility.tsx | 4 +- .../components/VisibilityTag.tsx | 2 +- .../hooks/useVisibilityTooltipLabel.tsx | 6 +- .../[guild]/SetVisibility/visibilityData.tsx | 8 +- src/components/[guild]/Visibility.tsx | 4 +- .../crm/FilterByRoles/FilterByRoles.tsx | 6 +- .../components/AddHiddenRoleButton.tsx | 3 +- .../components/SetHiddenRoleRequirements.tsx | 3 +- src/components/[guild]/crm/RoleTags.tsx | 4 +- src/components/[guild]/crm/useMembers.tsx | 10 +- src/components/[guild]/messages/Message.tsx | 5 +- .../BasicInfo/components/ContactInfo.tsx | 4 +- .../components/AddRequirement.tsx | 31 +-- .../ExistingRequirementEditableCard.tsx | 10 +- .../components/RequirementEditableCard.tsx | 7 +- .../Requirements/hooks/useBalancy.ts | 3 +- .../hooks/useCreateRequirement.ts | 15 +- .../Requirements/hooks/useEditRequirement.ts | 29 +- .../hooks/useHandleRequirementState.ts | 2 +- .../create-guild/hooks/useCreateRole.tsx | 10 +- src/hooks/useSubmitTransaction.ts | 5 +- src/pages/[guild]/members.tsx | 3 +- .../SelectRoleOrSetRequirements.tsx | 4 +- .../Airdrop/AirdropRequirement.tsx | 6 +- .../Allowlist/AllowlistRequirement.tsx | 17 +- .../Farcaster/FarcasterRequirement.tsx | 12 +- src/requirements/Fuel/FuelRequirement.tsx | 13 +- src/requirements/Lens/LensRequirement.tsx | 4 +- src/requirements/Lens/hooks/useLensProfile.ts | 2 +- .../Lens/hooks/useLensProfiles.ts | 4 +- src/requirements/Mirror/MirrorRequirement.tsx | 11 +- src/requirements/Nft/NftRequirement.tsx | 17 +- .../providedValue/NftAmountProvidedValue.tsx | 16 +- .../Payment/PaymentRequirement.tsx | 4 +- .../WithdrawButton/WithdrawButton.tsx | 9 +- src/requirements/Token/TokenRequirement.tsx | 12 +- .../providedValue/TokenProvidedValue.tsx | 7 +- .../Uniswap/UniswapRequirement.tsx | 7 +- .../WalletActivityRequirement.tsx | 11 +- src/requirements/index.ts | 4 +- src/types.ts | 43 +-- src/utils/formatRelativeTimeFromNow.ts | 2 +- src/utils/mapRequirement.ts | 8 +- src/utils/preprocessRequirement.ts | 8 +- 75 files changed, 469 insertions(+), 411 deletions(-) diff --git a/package-lock.json b/package-lock.json index 1b7e4c8233..3037a660d3 100644 --- a/package-lock.json +++ b/package-lock.json @@ -19,7 +19,7 @@ "@emotion/styled": "^11.11.0", "@fuels/connectors": "^0.5.0", "@fuels/react": "^0.20.0", - "@guildxyz/types": "1.9.23", + "@guildxyz/types": "1.9.24", "@hcaptcha/react-hcaptcha": "^1.4.4", "@hookform/resolvers": "^3.3.4", "@lexical/code": "^0.12.0", @@ -4618,17 +4618,17 @@ } }, "node_modules/@floating-ui/core": { - "version": "1.6.2", - "resolved": "https://registry.npmjs.org/@floating-ui/core/-/core-1.6.2.tgz", - "integrity": "sha512-+2XpQV9LLZeanU4ZevzRnGFg2neDeKHgFLjP6YLW+tly0IvrhqT4u8enLGjLH3qeh85g19xY5rsAusfwTdn5lg==", + "version": "1.6.3", + "resolved": "https://registry.npmjs.org/@floating-ui/core/-/core-1.6.3.tgz", + "integrity": "sha512-1ZpCvYf788/ZXOhRQGFxnYQOVgeU+pi0i+d0Ow34La7qjIXETi6RNswGVKkA6KcDO8/+Ysu2E/CeUmmeEBDvTg==", "dependencies": { - "@floating-ui/utils": "^0.2.0" + "@floating-ui/utils": "^0.2.3" } }, "node_modules/@floating-ui/core/node_modules/@floating-ui/utils": { - "version": "0.2.2", - "resolved": "https://registry.npmjs.org/@floating-ui/utils/-/utils-0.2.2.tgz", - "integrity": "sha512-J4yDIIthosAsRZ5CPYP/jQvUAQtlZTTD/4suA08/FEnlxqW3sKS9iAhgsa9VYLZ6vDHn/ixJgIqRQPotoBjxIw==" + "version": "0.2.3", + "resolved": "https://registry.npmjs.org/@floating-ui/utils/-/utils-0.2.3.tgz", + "integrity": "sha512-XGndio0l5/Gvd6CLIABvsav9HHezgDFFhDfHk1bvLfr9ni8dojqLSvBbotJEjmIwNHL7vK4QzBJTdBRoB+c1ww==" }, "node_modules/@floating-ui/dom": { "version": "1.5.1", @@ -5192,9 +5192,9 @@ } }, "node_modules/@guildxyz/types": { - "version": "1.9.23", - "resolved": "https://registry.npmjs.org/@guildxyz/types/-/types-1.9.23.tgz", - "integrity": "sha512-fRCBcDaqr6YFpTZPY7imy8/q1I7MC8jjej3LGNkeN31wwcJmULjOAbQz43C6kff3AMizjUfX2aP2BZnSC7MXjA==", + "version": "1.9.24", + "resolved": "https://registry.npmjs.org/@guildxyz/types/-/types-1.9.24.tgz", + "integrity": "sha512-tNy2i/KqbXU+UwDGLijaWXEDXqGmbKeKpANpTCvQ93AVCazvrrEp+359JaDJCJVv94Mzc0mTQgow6xiHgHcLFQ==", "dependencies": { "zod": "^3.22.4" } @@ -6387,14 +6387,14 @@ } }, "node_modules/@metamask/sdk": { - "version": "0.20.5", - "resolved": "https://registry.npmjs.org/@metamask/sdk/-/sdk-0.20.5.tgz", - "integrity": "sha512-BEL3BKbb0O09QgOzvyPH5xUONl2uicS9WT1AYhZ8yR4ytz5fhyHWJzs8Q/cwgm1qIdn3eumnjXfgA6pKirWa3A==", + "version": "0.26.3", + "resolved": "https://registry.npmjs.org/@metamask/sdk/-/sdk-0.26.3.tgz", + "integrity": "sha512-DM4BFPr1BDAIhTz7/RWb3oWQRvX79TJVZH8EL/Ljp+CRY7IjCbaVwaLdyQjVd8Doyq1V7AL4N/JjXplpo2YyYg==", "dependencies": { "@metamask/onboarding": "^1.0.1", "@metamask/providers": "^15.0.0", - "@metamask/sdk-communication-layer": "0.20.5", - "@metamask/sdk-install-modal-web": "0.20.4", + "@metamask/sdk-communication-layer": "0.26.2", + "@metamask/sdk-install-modal-web": "0.26.0", "@types/dom-screen-wake-lock": "^1.0.0", "bowser": "^2.9.0", "cross-fetch": "^4.0.0", @@ -6428,9 +6428,9 @@ } }, "node_modules/@metamask/sdk-communication-layer": { - "version": "0.20.5", - "resolved": "https://registry.npmjs.org/@metamask/sdk-communication-layer/-/sdk-communication-layer-0.20.5.tgz", - "integrity": "sha512-Y3pzg1GBB7tDUCUsyhvlhxQ+h/pDrTjO2yUwjCJj2S8Nx5OtdRv/foRGfbDHkfYt6Z9ANRfivWU2U6El17B24A==", + "version": "0.26.2", + "resolved": "https://registry.npmjs.org/@metamask/sdk-communication-layer/-/sdk-communication-layer-0.26.2.tgz", + "integrity": "sha512-YMqwjhCZ4sXYAsEp1LxLrZZycBwpUeEsA4yIx48m1yW9sZ8pv3NGnbjM+F0zf29DLjyqLxJdxHJ7b5YkgtB26g==", "dependencies": { "bufferutil": "^4.0.8", "date-fns": "^2.29.3", @@ -6447,9 +6447,9 @@ } }, "node_modules/@metamask/sdk-install-modal-web": { - "version": "0.20.4", - "resolved": "https://registry.npmjs.org/@metamask/sdk-install-modal-web/-/sdk-install-modal-web-0.20.4.tgz", - "integrity": "sha512-AX3mTr0IDpS0ajV83okTaixG+2wIxTVbgvEuQgAj2Ed7PWAdiZ1aX93AVcaCgkOWhTf267z7mXCSuBDpBCje9g==", + "version": "0.26.0", + "resolved": "https://registry.npmjs.org/@metamask/sdk-install-modal-web/-/sdk-install-modal-web-0.26.0.tgz", + "integrity": "sha512-LyDQFIsWWyU0ZgZR3O9LzRqKzXcYUEGJRCNfb26IjFOquvmQosbhQV0jDNlVa8Tk2Fg4ykTPoaauANh6sVJYVQ==", "dependencies": { "qr-code-styling": "^1.6.0-rc.1" }, @@ -7513,9 +7513,9 @@ } }, "node_modules/@radix-ui/react-dialog": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/@radix-ui/react-dialog/-/react-dialog-1.1.0.tgz", - "integrity": "sha512-oiSJcsjbdC8JqbXrOuhOd7oaEaPp3x2L2zn6V7ie6SSpEjrAha/WabDX4po6laGwbhAu9DT0XxHL0DmcIXrR0A==", + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/@radix-ui/react-dialog/-/react-dialog-1.1.1.tgz", + "integrity": "sha512-zysS+iU4YP3STKNS6USvFVqI4qqx8EpiwmT5TuCApVEBca+eRCbONi4EgzfNSuVnOXvC5UPHHMjs8RXO6DH9Bg==", "dependencies": { "@radix-ui/primitive": "1.1.0", "@radix-ui/react-compose-refs": "1.1.0", @@ -7524,7 +7524,7 @@ "@radix-ui/react-focus-guards": "1.1.0", "@radix-ui/react-focus-scope": "1.1.0", "@radix-ui/react-id": "1.1.0", - "@radix-ui/react-portal": "1.1.0", + "@radix-ui/react-portal": "1.1.1", "@radix-ui/react-presence": "1.1.0", "@radix-ui/react-primitive": "2.0.0", "@radix-ui/react-slot": "1.1.0", @@ -7658,11 +7658,12 @@ } }, "node_modules/@radix-ui/react-portal": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/@radix-ui/react-portal/-/react-portal-1.1.0.tgz", - "integrity": "sha512-0tXZ5O6qAVvuN9SWP0X+zadHf9hzHiMf/vxOU+kXO+fbtS8lS57MXa6EmikDxk9s/Bmkk80+dcxgbvisIyeqxg==", + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/@radix-ui/react-portal/-/react-portal-1.1.1.tgz", + "integrity": "sha512-A3UtLk85UtqhzFqtoC8Q0KvR2GbXF3mtPgACSazajqq6A41mEQgo53iPzY4i6BwDxlIFqWIhiQ2G729n+2aw/g==", "dependencies": { - "@radix-ui/react-primitive": "2.0.0" + "@radix-ui/react-primitive": "2.0.0", + "@radix-ui/react-use-layout-effect": "1.1.0" }, "peerDependencies": { "@types/react": "*", @@ -9574,9 +9575,9 @@ } }, "node_modules/@rnx-kit/chromium-edge-launcher/node_modules/@types/node": { - "version": "18.19.37", - "resolved": "https://registry.npmjs.org/@types/node/-/node-18.19.37.tgz", - "integrity": "sha512-Pi53fdVMk7Ig5IfAMltQQMgtY7xLzHaEous8IQasYsdQbYK3v90FkxI3XYQCe/Qme58pqp14lXJIsFmGP8VoZQ==", + "version": "18.19.39", + "resolved": "https://registry.npmjs.org/@types/node/-/node-18.19.39.tgz", + "integrity": "sha512-nPwTRDKUctxw3di5b4TfT3I0sWDiWoPQCZjXhvdkINntwr8lcoVCKsTgnXeRubKIlfnV+eN/HYk6Jb40tbcEAQ==", "peer": true, "dependencies": { "undici-types": "~5.26.4" @@ -9740,9 +9741,9 @@ } }, "node_modules/@safe-global/safe-gateway-typescript-sdk": { - "version": "3.21.4", - "resolved": "https://registry.npmjs.org/@safe-global/safe-gateway-typescript-sdk/-/safe-gateway-typescript-sdk-3.21.4.tgz", - "integrity": "sha512-BCY+7RtCfjkGO8X6crBRqlXPqAGM/0Ki/k0PWLYxV3IGmwM6ah2qFGkpp1omWQsdILdiKWxsmIKiderAWOyLjA==", + "version": "3.21.6", + "resolved": "https://registry.npmjs.org/@safe-global/safe-gateway-typescript-sdk/-/safe-gateway-typescript-sdk-3.21.6.tgz", + "integrity": "sha512-S3OZ8Alya7N7Iie6KvVSbrp9Ev30cQZtpqvP4zkaWlWBG6W7XE3gYC/8GohmQ9E3BOYtYa1xfDupKRgSO9RfTw==", "engines": { "node": ">=16" } @@ -10289,20 +10290,20 @@ } }, "node_modules/@tanstack/query-core": { - "version": "5.45.0", - "resolved": "https://registry.npmjs.org/@tanstack/query-core/-/query-core-5.45.0.tgz", - "integrity": "sha512-RVfIZQmFUTdjhSAAblvueimfngYyfN6HlwaJUPK71PKd7yi43Vs1S/rdimmZedPWX/WGppcq/U1HOj7O7FwYxw==", + "version": "5.48.0", + "resolved": "https://registry.npmjs.org/@tanstack/query-core/-/query-core-5.48.0.tgz", + "integrity": "sha512-lZAfPPeVIqXCswE9SSbG33B6/91XOWt/Iq41bFeWb/mnHwQSIfFRbkS4bfs+WhIk9abRArF9Id2fp0Mgo+hq6Q==", "funding": { "type": "github", "url": "https://github.com/sponsors/tannerlinsley" } }, "node_modules/@tanstack/react-query": { - "version": "5.45.1", - "resolved": "https://registry.npmjs.org/@tanstack/react-query/-/react-query-5.45.1.tgz", - "integrity": "sha512-mYYfJujKg2kxmkRRjA6nn4YKG3ITsKuH22f1kteJ5IuVQqgKUgbaSQfYwVP0gBS05mhwxO03HVpD0t7BMN7WOA==", + "version": "5.48.0", + "resolved": "https://registry.npmjs.org/@tanstack/react-query/-/react-query-5.48.0.tgz", + "integrity": "sha512-GDExbjYWzvDokyRqMSWXdrPiYpp95Aig0oeMIrxTaruOJJgWiWfUP//OAaowm2RrRkGVsavSZdko/XmIrrV2Nw==", "dependencies": { - "@tanstack/query-core": "5.45.0" + "@tanstack/query-core": "5.48.0" }, "funding": { "type": "github", @@ -10332,11 +10333,11 @@ } }, "node_modules/@tanstack/react-virtual": { - "version": "3.5.1", - "resolved": "https://registry.npmjs.org/@tanstack/react-virtual/-/react-virtual-3.5.1.tgz", - "integrity": "sha512-jIsuhfgy8GqA67PdWqg73ZB2LFE+HD9hjWL1L6ifEIZVyZVAKpYmgUG4WsKQ005aEyImJmbuimPiEvc57IY0Aw==", + "version": "3.7.0", + "resolved": "https://registry.npmjs.org/@tanstack/react-virtual/-/react-virtual-3.7.0.tgz", + "integrity": "sha512-3RtOwEU1HKS4iFBoTcCrV3Szqt4KoERMhZr8v57dvnh5o70sR9GAdF+0aE/qhiOmePrKujGwAayFNJSr/8Dbqw==", "dependencies": { - "@tanstack/virtual-core": "3.5.1" + "@tanstack/virtual-core": "3.7.0" }, "funding": { "type": "github", @@ -10360,9 +10361,9 @@ } }, "node_modules/@tanstack/virtual-core": { - "version": "3.5.1", - "resolved": "https://registry.npmjs.org/@tanstack/virtual-core/-/virtual-core-3.5.1.tgz", - "integrity": "sha512-046+AUSiDru/V9pajE1du8WayvBKeCvJ2NmKPy/mR8/SbKKrqmSbj7LJBfXE+nSq4f5TBXvnCzu0kcYebI9WdQ==", + "version": "3.7.0", + "resolved": "https://registry.npmjs.org/@tanstack/virtual-core/-/virtual-core-3.7.0.tgz", + "integrity": "sha512-p0CWuqn+n8iZmsL7/l0Xg7kbyIKnHNqkEJkMDOkg4x3Ni3LohszmnJY8FPhTgG7Ad9ZFGcdKmn1R1mKUGEh9Xg==", "funding": { "type": "github", "url": "https://github.com/sponsors/tannerlinsley" @@ -10605,9 +10606,9 @@ "integrity": "sha512-nG96G3Wp6acyAgJqGasjODb+acrI7KltPiRxzHPXnP3NgI28bpQDRv53olbqGXbfcgF5aiiHmO3xpwEpS5Ld9g==" }, "node_modules/@types/node": { - "version": "20.14.6", - "resolved": "https://registry.npmjs.org/@types/node/-/node-20.14.6.tgz", - "integrity": "sha512-JbA0XIJPL1IiNnU7PFxDXyfAwcwVVrOoqyzzyQTyMeVhBzkJVMSkC1LlVsRQ2lpqiY4n6Bb9oCS6lzDKVQxbZw==", + "version": "20.14.9", + "resolved": "https://registry.npmjs.org/@types/node/-/node-20.14.9.tgz", + "integrity": "sha512-06OCtnTXtWOZBJlRApleWndH4JsRVs1pDCc8dLSQp+7PpUpX3ePdHyeNSFTeSe7FtKyQkrlPvHwJOW3SLd8Oyg==", "dependencies": { "undici-types": "~5.26.4" } @@ -11328,12 +11329,12 @@ } }, "node_modules/@wagmi/connectors": { - "version": "5.0.15", - "resolved": "https://registry.npmjs.org/@wagmi/connectors/-/connectors-5.0.15.tgz", - "integrity": "sha512-eQnsVfe1tX7g3pFPDg3sWjCdggTE+4C0z9g700h/pgUTNSJGnMRU+avTZqkewHFUkUkAhSk/tm1BZ4wfr6Wwfg==", + "version": "5.0.19", + "resolved": "https://registry.npmjs.org/@wagmi/connectors/-/connectors-5.0.19.tgz", + "integrity": "sha512-yd0pkM3I7sJuIZf1lIiwxDApaWg5ZSFiN3ociM50SkcoWDAWAKcCWWP0FbaCZ4KT+TZQJEIqBpfk6eZ9mBAddQ==", "dependencies": { "@coinbase/wallet-sdk": "4.0.3", - "@metamask/sdk": "0.20.5", + "@metamask/sdk": "0.26.3", "@safe-global/safe-apps-provider": "0.18.1", "@safe-global/safe-apps-sdk": "8.1.0", "@walletconnect/ethereum-provider": "2.13.0", @@ -11344,7 +11345,7 @@ "url": "https://github.com/sponsors/wevm" }, "peerDependencies": { - "@wagmi/core": "2.11.3", + "@wagmi/core": "2.11.5", "typescript": ">=5.0.4", "viem": "2.x" }, @@ -11355,9 +11356,9 @@ } }, "node_modules/@wagmi/core": { - "version": "2.11.3", - "resolved": "https://registry.npmjs.org/@wagmi/core/-/core-2.11.3.tgz", - "integrity": "sha512-RxjjyDDmUehAy1CBJgSGzbnsbAAbaOrGwemsTXR7ru5dak+4lQ3Swx4Ikm1aPlxjSZbNy6c/epyidnkun9qzMQ==", + "version": "2.11.5", + "resolved": "https://registry.npmjs.org/@wagmi/core/-/core-2.11.5.tgz", + "integrity": "sha512-RmtZQkNf/ozdngyDST33WLTdKQHny9SsiNmxln8G06pbnOuhO4dDhnXnfiJ8Lh9GVIfFsjlmtqzfAIo1/86dqg==", "dependencies": { "eventemitter3": "5.0.1", "mipd": "0.0.5", @@ -13030,10 +13031,9 @@ "integrity": "sha512-wjkjR4ItpkCKnlN0JNkhoLutRf1yHTaGV1qEy1Z9tzkyfJmP/2jqwcCR1cWWxM/+iFE2UJd7Ea7CNgCWwFnvFw==" }, "node_modules/abitype": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/abitype/-/abitype-1.0.3.tgz", - "integrity": "sha512-8EyPgBBHMtW56OslHWHJ4HEjU+2snjxibmwNjV2aBJp4oDfx1DcxO8sQ4jkxo/Iu6oQ79c6/ihsrBE2nBMlURg==", - "dev": true, + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/abitype/-/abitype-1.0.4.tgz", + "integrity": "sha512-UivtYZOGJGE8rsrM/N5vdRkUpqEZVmuTumfTuolm7m/6O09wprd958rx8kUBwVAAAhQDveGAgD0GJdBuR8s6tw==", "funding": { "url": "https://github.com/sponsors/wevm" }, @@ -14302,9 +14302,9 @@ } }, "node_modules/caniuse-lite": { - "version": "1.0.30001636", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001636.tgz", - "integrity": "sha512-bMg2vmr8XBsbL6Lr0UHXy/21m84FTxDLWn2FSqMd5PrlbMxwJlQnC2YWYxVgp66PZE+BBNF2jYQUBKCo1FDeZg==", + "version": "1.0.30001637", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001637.tgz", + "integrity": "sha512-1x0qRI1mD1o9e+7mBI7XtzFAP4XszbHaVWsMiGbSPLYekKTJF7K+FNk6AsXH4sUpc+qrsI3pVgf1Jdl/uGkuSQ==", "funding": [ { "type": "opencollective", @@ -16182,9 +16182,9 @@ "peer": true }, "node_modules/electron-to-chromium": { - "version": "1.4.807", - "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.807.tgz", - "integrity": "sha512-kSmJl2ZwhNf/bcIuCH/imtNOKlpkLDn2jqT5FJ+/0CXjhnFaOa9cOe9gHKKy71eM49izwuQjZhKk+lWQ1JxB7A==" + "version": "1.4.812", + "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.812.tgz", + "integrity": "sha512-7L8fC2Ey/b6SePDFKR2zHAy4mbdp1/38Yk5TsARO66W3hC5KEaeKMMHoxwtuH+jcu2AYLSn9QX04i95t6Fl1Hg==" }, "node_modules/elliptic": { "version": "6.5.4", @@ -16476,9 +16476,9 @@ } }, "node_modules/es-module-lexer": { - "version": "1.5.3", - "resolved": "https://registry.npmjs.org/es-module-lexer/-/es-module-lexer-1.5.3.tgz", - "integrity": "sha512-i1gCgmR9dCl6Vil6UKPI/trA69s08g/syhiDK9TG0Nf1RJjjFI+AzoWW7sPufzkgYAn861skuCwJa0pIIHYxvg==", + "version": "1.5.4", + "resolved": "https://registry.npmjs.org/es-module-lexer/-/es-module-lexer-1.5.4.tgz", + "integrity": "sha512-MVNK56NiMrOwitFB7cqDwq0CQutbw+0BvLshJSse0MUNU+y1FC3bUS/AQg7oUng+/wKrrki7JfmwtVHkVfPLlw==", "dev": true, "peer": true }, @@ -17722,9 +17722,9 @@ "peer": true }, "node_modules/flow-parser": { - "version": "0.238.0", - "resolved": "https://registry.npmjs.org/flow-parser/-/flow-parser-0.238.0.tgz", - "integrity": "sha512-VE7XSv1epljsIN2YeBnxCmGJihpNIAnLLu/pPOdA+Gkso7qDltJwUi6vfHjgxdBbjSdAuPGnhuOHJUQG+yYwIg==", + "version": "0.238.2", + "resolved": "https://registry.npmjs.org/flow-parser/-/flow-parser-0.238.2.tgz", + "integrity": "sha512-fs7FSnzzKF6oSzjk14JlBHt82DPchYHVsXtPi4Fkn+qrunVjWaBZY7nSO/mC9X4l9+wRah/R69DRd5NGDOrWqw==", "peer": true, "engines": { "node": ">=0.4.0" @@ -18242,9 +18242,9 @@ } }, "node_modules/glob/node_modules/minimatch": { - "version": "9.0.4", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.4.tgz", - "integrity": "sha512-KqWh+VchfxcMNRAJjj2tnsSJdNbHsVgnkBhTNrW7AjVo6OvLtxw8zfT9oLw1JSohlFzJ8jCoTgaoXvJ+kHt6fw==", + "version": "9.0.5", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.5.tgz", + "integrity": "sha512-G6T0ZX48xgozx7587koeX9Ys2NYy6Gmv//P89sEte9V9whIapMNF4idKxnW2QtCcLiTWlb/wfCabAtAFWhhBow==", "dependencies": { "brace-expansion": "^2.0.1" }, @@ -18337,9 +18337,9 @@ "dev": true }, "node_modules/graphql": { - "version": "16.8.2", - "resolved": "https://registry.npmjs.org/graphql/-/graphql-16.8.2.tgz", - "integrity": "sha512-cvVIBILwuoSyD54U4cF/UXDh5yAobhNV/tPygI4lZhgOIJQE/WLWC4waBRb4I6bDVYb3OVx3lfHbaQOEoUD5sg==", + "version": "16.9.0", + "resolved": "https://registry.npmjs.org/graphql/-/graphql-16.9.0.tgz", + "integrity": "sha512-GGTKBX4SD7Wdb8mqeDLni2oaRGYQWjWHGKPQ24ZMnUtKfcsVoiv4uX8+LJr1K6U5VW2Lu1BwJnj7uiori0YtRw==", "engines": { "node": "^12.22.0 || ^14.16.0 || ^16.0.0 || >=17.0.0" } @@ -19018,11 +19018,14 @@ } }, "node_modules/is-core-module": { - "version": "2.13.1", - "resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.13.1.tgz", - "integrity": "sha512-hHrIjvZsftOsvKSn2TRYl63zvxsgE0K+0mYMoH6gD4omR5IWB2KynivBQczo3+wF1cCkjzvptnI9Q0sPU66ilw==", + "version": "2.14.0", + "resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.14.0.tgz", + "integrity": "sha512-a5dFJih5ZLYlRtDc0dZWP7RiKr6xIKzmn/oAYCDvdLThadVgyJwlaoQPmRtMSpz+rk0OGAgIu+TcM9HUF0fk1A==", "dependencies": { - "hasown": "^2.0.0" + "hasown": "^2.0.2" + }, + "engines": { + "node": ">= 0.4" }, "funding": { "url": "https://github.com/sponsors/ljharb" @@ -26877,10 +26880,13 @@ } }, "node_modules/object-inspect": { - "version": "1.13.1", - "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.13.1.tgz", - "integrity": "sha512-5qoj1RUiKOMsCCNLV1CBiPYE10sziTsnmNxkAI/rZhiD63CF7IqdFGC/XzjWjpSgLf0LxXX3bDFIh0E18f6UhQ==", + "version": "1.13.2", + "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.13.2.tgz", + "integrity": "sha512-IRZSRuzJiynemAXPYtPe5BoI/RESNYR7TYm50MC5Mqbd3Jmw5y790sErYw3V6SryFJD64b74qQQs9wn5Bg/k3g==", "dev": true, + "engines": { + "node": ">= 0.4" + }, "funding": { "url": "https://github.com/sponsors/ljharb" } @@ -27714,12 +27720,13 @@ } }, "node_modules/posthog-js": { - "version": "1.139.5", - "resolved": "https://registry.npmjs.org/posthog-js/-/posthog-js-1.139.5.tgz", - "integrity": "sha512-awnIAefNa+x5GA481B8j8J6S2xLcvHQ7i5Osyzq1UK6QGtmAaM0ttGFU+oPjpKxo4yXeuF5R1aUo9YE67s4+vA==", + "version": "1.141.3", + "resolved": "https://registry.npmjs.org/posthog-js/-/posthog-js-1.141.3.tgz", + "integrity": "sha512-LZ+I6wJS82yX/SZVaK20V2WV4MEfB2G9fT2ZJoWlzwN5L3wsbpmjD9F2dVW818deBV3ms1w0Ho7rnlJtBGHx2g==", "dependencies": { "fflate": "^0.4.8", - "preact": "^10.19.3" + "preact": "^10.19.3", + "web-vitals": "^4.0.1" } }, "node_modules/posthog-js/node_modules/fflate": { @@ -28241,9 +28248,9 @@ } }, "node_modules/react-devtools-core": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/react-devtools-core/-/react-devtools-core-5.2.0.tgz", - "integrity": "sha512-vZK+/gvxxsieAoAyYaiRIVFxlajb7KXhgBDV7OsoMzaAE+IqGpoxusBjIgq5ibqA2IloKu0p9n7tE68z1xs18A==", + "version": "5.3.0", + "resolved": "https://registry.npmjs.org/react-devtools-core/-/react-devtools-core-5.3.0.tgz", + "integrity": "sha512-IG3T+azv48Oc5VLdHR4XdBNKNZIUOKRtx0sJMRvb++Zom/uqtx73j6u37JCsIBNIaq6vA7RPH5Bbcf/Wj53KXA==", "peer": true, "dependencies": { "shell-quote": "^1.6.1", @@ -31737,9 +31744,9 @@ "dev": true }, "node_modules/typescript": { - "version": "5.4.5", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.4.5.tgz", - "integrity": "sha512-vcI4UpRgg81oIRUFwR0WSIHKt11nJ7SAVlYNIu+QpqeyXP+gpQJy/Z4+F0aGxSE4MqwjyXvW/TzgkLAx2AGHwQ==", + "version": "5.5.2", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.5.2.tgz", + "integrity": "sha512-NcRtPEOsPFFWjobJEtfihkLCZCXZt/os3zf8nTxjVH3RvTSxjrCamJpbExGvYOF+tFHc3pA65qpdwPbzjohhew==", "devOptional": true, "bin": { "tsc": "bin/tsc", @@ -32448,9 +32455,9 @@ } }, "node_modules/viem": { - "version": "2.15.1", - "resolved": "https://registry.npmjs.org/viem/-/viem-2.15.1.tgz", - "integrity": "sha512-Vrveen3vDOJyPf8Q8TDyWePG2pTdK6IpSi4P6qlvAP+rXkAeqRvwYBy9AmGm+BeYpCETAyTT0SrCP6458XSt+w==", + "version": "2.16.2", + "resolved": "https://registry.npmjs.org/viem/-/viem-2.16.2.tgz", + "integrity": "sha512-qor3v1cJFR3jcPtcJxPbKfKURAH2agNf2IWZIaSReV6teNLERiu4Sr7kbqpkIeTAEpiDCVQwg336M+mub1m+pg==", "funding": [ { "type": "github", @@ -32463,7 +32470,7 @@ "@noble/hashes": "1.3.2", "@scure/bip32": "1.3.2", "@scure/bip39": "1.2.1", - "abitype": "1.0.0", + "abitype": "1.0.4", "isows": "1.0.4", "ws": "8.17.1" }, @@ -32523,26 +32530,6 @@ "url": "https://paulmillr.com/funding/" } }, - "node_modules/viem/node_modules/abitype": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/abitype/-/abitype-1.0.0.tgz", - "integrity": "sha512-NMeMah//6bJ56H5XRj8QCV4AwuW6hB6zqz2LnhhLdcWVQOsXki6/Pn3APeqxCma62nXIcmZWdu1DlHWS74umVQ==", - "funding": { - "url": "https://github.com/sponsors/wevm" - }, - "peerDependencies": { - "typescript": ">=5.0.4", - "zod": "^3 >=3.22.0" - }, - "peerDependenciesMeta": { - "typescript": { - "optional": true - }, - "zod": { - "optional": true - } - } - }, "node_modules/viem/node_modules/ws": { "version": "8.17.1", "resolved": "https://registry.npmjs.org/ws/-/ws-8.17.1.tgz", @@ -32579,12 +32566,12 @@ } }, "node_modules/wagmi": { - "version": "2.10.3", - "resolved": "https://registry.npmjs.org/wagmi/-/wagmi-2.10.3.tgz", - "integrity": "sha512-B1GTa2jzwStnDvunQr8LGc7BfzhC/IdZE679Lm3XlIGTfsrOua38ZnZGE627kqLu3z6WewDBytj+JjHs5GpmXQ==", + "version": "2.10.7", + "resolved": "https://registry.npmjs.org/wagmi/-/wagmi-2.10.7.tgz", + "integrity": "sha512-RYh45bpqaPbQDcRYbfaiS0b5iZrEKVCCpjyFTJx83qtbkxZBvpT6MXy1rQbfLookVCgZz0PA3aYEYX8HJPajLg==", "dependencies": { - "@wagmi/connectors": "5.0.15", - "@wagmi/core": "2.11.3", + "@wagmi/connectors": "5.0.19", + "@wagmi/core": "2.11.5", "use-sync-external-store": "1.2.0" }, "funding": { @@ -32657,6 +32644,11 @@ "defaults": "^1.0.3" } }, + "node_modules/web-vitals": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/web-vitals/-/web-vitals-4.2.0.tgz", + "integrity": "sha512-ohj72kbtVWCpKYMxcbJ+xaOBV3En76hW47j52dG+tEGG36LZQgfFw5yHl9xyjmosy3XUMn8d/GBUAy4YPM839w==" + }, "node_modules/webextension-polyfill": { "version": "0.10.0", "resolved": "https://registry.npmjs.org/webextension-polyfill/-/webextension-polyfill-0.10.0.tgz", diff --git a/package.json b/package.json index df80434981..ae3c3b66c9 100644 --- a/package.json +++ b/package.json @@ -29,7 +29,7 @@ "@emotion/styled": "^11.11.0", "@fuels/connectors": "^0.5.0", "@fuels/react": "^0.20.0", - "@guildxyz/types": "1.9.23", + "@guildxyz/types": "1.9.24", "@hcaptcha/react-hcaptcha": "^1.4.4", "@hookform/resolvers": "^3.3.4", "@lexical/code": "^0.12.0", diff --git a/src/components/[guild]/AddAndOrderRoles/components/OrderRolesModal.tsx b/src/components/[guild]/AddAndOrderRoles/components/OrderRolesModal.tsx index 088d1016af..1d98865b37 100644 --- a/src/components/[guild]/AddAndOrderRoles/components/OrderRolesModal.tsx +++ b/src/components/[guild]/AddAndOrderRoles/components/OrderRolesModal.tsx @@ -15,7 +15,6 @@ import DiscardAlert from "components/common/DiscardAlert" import { Modal } from "components/common/Modal" import { Reorder } from "framer-motion" import { useMemo, useState } from "react" -import { Visibility } from "types" import useReorderRoles from "../hooks/useReorderRoles" import DraggableRoleCard from "./DraggableRoleCard" @@ -51,7 +50,7 @@ const OrderRolesModal = ({ isOpen, onClose, finalFocusRef }): JSX.Element => { }, [relevantRoles]) const publicAndSecretRoles = sortedRoles.filter( - (role) => role.visibility !== Visibility.HIDDEN + (role) => role.visibility !== "HIDDEN" ) const defaultRoleIdsOrder = publicAndSecretRoles?.map((role) => role.id) diff --git a/src/components/[guild]/AddAndOrderRoles/hooks/useAddRoleForm.ts b/src/components/[guild]/AddAndOrderRoles/hooks/useAddRoleForm.ts index 22a3f59c8f..d7f953597b 100644 --- a/src/components/[guild]/AddAndOrderRoles/hooks/useAddRoleForm.ts +++ b/src/components/[guild]/AddAndOrderRoles/hooks/useAddRoleForm.ts @@ -1,14 +1,14 @@ import useGuild from "components/[guild]/hooks/useGuild" import { RoleToCreate } from "components/create-guild/hooks/useCreateRole" import { useForm } from "react-hook-form" -import { RoleFormType, Visibility } from "types" +import { RoleFormType } from "types" import getRandomInt from "utils/getRandomInt" const useAddRoleForm = () => { const { id } = useGuild() const defaultValues: RoleToCreate = { - guildId: id, + guildId: id as number, // Safe to cast here, since we'll have guildId by the time we call this hook name: "", description: "", logic: "AND", @@ -19,7 +19,7 @@ const useAddRoleForm = () => { ], roleType: "NEW", imageUrl: `/guildLogos/${getRandomInt(286)}.svg`, - visibility: Visibility.PUBLIC, + visibility: "PUBLIC", rolePlatforms: [], } diff --git a/src/components/[guild]/AddRewardButton/AddRewardButton.tsx b/src/components/[guild]/AddRewardButton/AddRewardButton.tsx index 2acbb35c0d..95db25146c 100644 --- a/src/components/[guild]/AddRewardButton/AddRewardButton.tsx +++ b/src/components/[guild]/AddRewardButton/AddRewardButton.tsx @@ -1,4 +1,5 @@ import { ModalOverlay, useDisclosure } from "@chakra-ui/react" +import { Schemas, Visibility } from "@guildxyz/types" import Button from "components/common/Button" import DiscardAlert from "components/common/DiscardAlert" import { Modal } from "components/common/Modal" @@ -7,7 +8,7 @@ import { atom, useAtomValue } from "jotai" import { Plus } from "phosphor-react" import rewards, { modalSizeForPlatform } from "platforms/rewards" import { FormProvider, useForm, useWatch } from "react-hook-form" -import { Requirement, RoleFormType, Visibility } from "types" +import { RoleFormType } from "types" import { AddRewardProvider, useAddRewardContext } from "../AddRewardContext" import { ClientStateRequirementHandlerProvider } from "../RequirementHandlerContext" import SelectRewardPanel from "../RolePlatforms/components/AddRoleRewardModal/SelectRewardPanel" @@ -20,7 +21,7 @@ export type AddRewardForm = { // TODO: we could simplify the form - we don't need a rolePlatforms array here, we only need one rolePlatform rolePlatforms: RoleFormType["rolePlatforms"][number][] // TODO: use proper types, e.g. name & symbol shouldn't be required on this type - requirements?: Omit[] + requirements?: Schemas["RequirementCreationPayload"][] roleIds?: number[] visibility: Visibility roleName?: string // Name for role, if new role is created with reward @@ -30,7 +31,7 @@ export const defaultValues: AddRewardForm = { rolePlatforms: [], requirements: [{ type: "FREE" }], roleIds: [], - visibility: Visibility.PUBLIC, + visibility: "PUBLIC", } export const canCloseAddRewardModalAtom = atom(true) diff --git a/src/components/[guild]/AddRewardButton/SelectRolePanel.tsx b/src/components/[guild]/AddRewardButton/SelectRolePanel.tsx index 968318bb98..22f0681810 100644 --- a/src/components/[guild]/AddRewardButton/SelectRolePanel.tsx +++ b/src/components/[guild]/AddRewardButton/SelectRolePanel.tsx @@ -11,6 +11,7 @@ import { Tooltip, useColorModeValue, } from "@chakra-ui/react" +import { Visibility } from "@guildxyz/types" import { usePostHogContext } from "components/_app/PostHogProvider" import Button from "components/common/Button" import useCreateRRR, { SubmitData } from "hooks/useCreateRRR" @@ -19,7 +20,6 @@ import SelectRoleOrSetRequirements from "platforms/components/SelectRoleOrSetReq import rewards, { CAPACITY_TIME_PLATFORMS } from "platforms/rewards" import { useState } from "react" import { useFormContext, useWatch } from "react-hook-form" -import { Visibility } from "types" import { RoleTypeToAddTo, useAddRewardContext } from "../AddRewardContext" import useGuild from "../hooks/useGuild" import { defaultValues } from "./AddRewardButton" @@ -171,17 +171,17 @@ const SelectRolePanel = ({ const changeDataToDraft = (data: SubmitData): SubmitData => { if (!data.roleIds?.length) { - return { ...data, visibility: Visibility.HIDDEN } + return { ...data, visibility: "HIDDEN" as Visibility } } const { rolePlatforms, requirements, roleIds } = data const hiddenRolePlatforms = rolePlatforms.map((rp) => ({ ...rp, - visibility: Visibility.HIDDEN, + visibility: "HIDDEN" as Visibility, })) const hiddenRequirements = requirements.map((req) => - req.type === "FREE" ? req : { ...req, visibility: Visibility.HIDDEN } + req.type === "FREE" ? req : { ...req, visibility: "HIDDEN" as Visibility } ) return { diff --git a/src/components/[guild]/AddRewardButton/hooks/useCreateRequirements.ts b/src/components/[guild]/AddRewardButton/hooks/useCreateRequirements.ts index 324d1b5043..3032eed2c8 100644 --- a/src/components/[guild]/AddRewardButton/hooks/useCreateRequirements.ts +++ b/src/components/[guild]/AddRewardButton/hooks/useCreateRequirements.ts @@ -2,8 +2,11 @@ import useGuild from "components/[guild]/hooks/useGuild" import { usePostHogContext } from "components/_app/PostHogProvider" import { RequirementIdMap } from "hooks/useCreateRRR" import useShowErrorToast from "hooks/useShowErrorToast" +import { + RequirementCreateResponseOutput, + RequirementCreationPayloadWithTempID, +} from "types" -import { Requirement } from "types" import { useFetcherWithSign } from "utils/fetcher" import preprocessRequirement from "utils/preprocessRequirement" @@ -17,7 +20,8 @@ const useCreateRequirements = () => { } const createRequirements = async ( - requirements: Partial[], + // We can assign generated IDs to requirements on our frontend, so it's safe to extend this type with an ID + requirements: RequirementCreationPayloadWithTempID[], roleIds: number[] ) => { const requirementIdMap: RequirementIdMap = {} @@ -31,7 +35,7 @@ const useCreateRequirements = () => { body: preprocessRequirement(req), }, ]) - .then((res) => { + .then((res: RequirementCreateResponseOutput) => { if (!requirementIdMap[req.id]) requirementIdMap[req.id] = {} requirementIdMap[req.id][roleId] = res.id return { status: "fulfilled", result: res } diff --git a/src/components/[guild]/AddRewardButton/hooks/useMutateAdditionsToRoles.ts b/src/components/[guild]/AddRewardButton/hooks/useMutateAdditionsToRoles.ts index 8ccb7e05a5..8c29d81555 100644 --- a/src/components/[guild]/AddRewardButton/hooks/useMutateAdditionsToRoles.ts +++ b/src/components/[guild]/AddRewardButton/hooks/useMutateAdditionsToRoles.ts @@ -1,13 +1,17 @@ -import { Schemas } from "@guildxyz/types" import useGuild from "components/[guild]/hooks/useGuild" import { unstable_serialize, useSWRConfig } from "swr" -import { GuildPlatform, Requirement, RolePlatform } from "types" +import { + Guild, + GuildPlatform, + RequirementCreateResponseOutput, + RolePlatform, +} from "types" import { CreateRolePlatformResponse } from "./useCreateRolePlatforms" const groupRequirementsByRoleId = ( roleIds: number[], - requirements: Schemas["RequirementCreateResponse"][] -): { [roleId: number]: Schemas["RequirementCreateResponse"][] } => + requirements: RequirementCreateResponseOutput[] +): { [roleId: number]: RequirementCreateResponseOutput[] } => roleIds.reduce((acc, roleId) => { acc[roleId] = requirements.filter((req) => req.roleId === roleId) return acc @@ -54,7 +58,7 @@ const useMutateAdditionsToRoles = () => { const mutateAdditionsInGuild = ( roleIds: number[], - createdRequirements: Schemas["RequirementCreateResponse"][], + createdRequirements: RequirementCreateResponseOutput[], // TODO: create a RoleRewardCreateResponse schema in our types package createdRolePlatforms: CreateRolePlatformResponse[] ) => { @@ -90,23 +94,24 @@ const useMutateAdditionsToRoles = () => { ...role, requirements: [ ...role.requirements.filter((req) => !reqIdsToDelete.includes(req.id)), - // TODO: we can remove the Requirement[] cast once we start using the Guild schema from our types package in the useGuild hook - ...(createdRequirementsOnRole as Requirement[]), + ...createdRequirementsOnRole, ], rolePlatforms: [...role.rolePlatforms, ...createdRolePlatformsOnRole], } }) // Return the updated data - return { - ...prev, - // TODO: we can remove the GuildPlatform[] cast once we start using the Guild schema from our types package in the useGuild hook - guildPlatforms: [ - ...prev.guildPlatforms, - ...(createdGuildPlatforms as GuildPlatform[]), - ], - roles: updatedRoles, - } + return !!prev + ? ({ + ...prev, + // TODO: we can remove the GuildPlatform[] cast once we start using the Guild schema from our types package in the useGuild hook + guildPlatforms: [ + ...(prev?.guildPlatforms ?? []), + ...(createdGuildPlatforms as GuildPlatform[]), + ], + roles: updatedRoles, + } satisfies Guild) + : undefined }, { revalidate: false } ) @@ -114,7 +119,7 @@ const useMutateAdditionsToRoles = () => { const mutateAdditionsToRoles = ( roleIds: number[], - createdRequirements: Schemas["RequirementCreateResponse"][], + createdRequirements: RequirementCreateResponseOutput[], // TODO: create a RoleRewardCreateResponse schema in our types package createdRolePlatforms: CreateRolePlatformResponse[] ) => { diff --git a/src/components/[guild]/AddRewardButton/hooks/useSubmitAddReward.ts b/src/components/[guild]/AddRewardButton/hooks/useSubmitAddReward.ts index 63234ac290..bf1e2486e9 100644 --- a/src/components/[guild]/AddRewardButton/hooks/useSubmitAddReward.ts +++ b/src/components/[guild]/AddRewardButton/hooks/useSubmitAddReward.ts @@ -1,3 +1,4 @@ +import { Visibility } from "@guildxyz/types" import { useAddRewardContext } from "components/[guild]/AddRewardContext" import useGuild from "components/[guild]/hooks/useGuild" import { usePostHogContext } from "components/_app/PostHogProvider" @@ -5,7 +6,7 @@ import useCreateRole from "components/create-guild/hooks/useCreateRole" import useToast from "hooks/useToast" import rewards from "platforms/rewards" import { useFormContext } from "react-hook-form" -import { PlatformType, Visibility } from "types" +import { PlatformType } from "types" import getRandomInt from "utils/getRandomInt" import { defaultValues } from "../AddRewardButton" import useCreateReqBasedTokenReward from "../useCreateTokenReward" @@ -135,8 +136,7 @@ const useSubmitAddReward = ({ } if (!data.roleIds || data?.roleIds.length === 0) { - const roleVisibility = - saveAs === "DRAFT" ? Visibility.HIDDEN : Visibility.PUBLIC + const roleVisibility: Visibility = saveAs === "DRAFT" ? "HIDDEN" : "PUBLIC" onCreateRoleSubmit({ ...data, name: data.roleName || `New ${rewards[selection].name} role`, @@ -168,7 +168,7 @@ const useSubmitAddReward = ({ ...data.rolePlatforms[0], visibility: saveAs === "DRAFT" - ? Visibility.HIDDEN + ? "HIDDEN" : roles.find((role) => role.id === +roleId).visibility, })), }) diff --git a/src/components/[guild]/AddRewardButton/useCreateTokenReward.ts b/src/components/[guild]/AddRewardButton/useCreateTokenReward.ts index a355297a2f..d32eb6e569 100644 --- a/src/components/[guild]/AddRewardButton/useCreateTokenReward.ts +++ b/src/components/[guild]/AddRewardButton/useCreateTokenReward.ts @@ -2,7 +2,7 @@ import { Schemas } from "@guildxyz/types" import { usePostHogContext } from "components/_app/PostHogProvider" import useCreateRole from "components/create-guild/hooks/useCreateRole" import useShowErrorToast from "hooks/useShowErrorToast" -import { PlatformType, Requirement, RolePlatform, Visibility } from "types" +import { PlatformType, Requirement, RolePlatform } from "types" import getRandomInt from "utils/getRandomInt" import useMembershipUpdate from "../JoinModal/hooks/useMembershipUpdate" import useGuild from "../hooks/useGuild" @@ -37,7 +37,7 @@ const getRewardSubmitData = ( platformRoleId: data.rolePlatforms[0].guildPlatform.platformGuildId || `${roleId}-${Date.now()}`, - visibility: saveAs === "DRAFT" ? Visibility.HIDDEN : Visibility.PUBLIC, + visibility: saveAs === "DRAFT" ? "HIDDEN" : "PUBLIC", }, ], }) @@ -96,7 +96,7 @@ const useCreateReqBasedTokenReward = ({ }) const createWithNewRole = async (data: CreateData, saveAs: "DRAFT" | "PUBLIC") => { - const roleVisibility = saveAs === "DRAFT" ? Visibility.HIDDEN : Visibility.PUBLIC + const roleVisibility = saveAs === "DRAFT" ? "HIDDEN" : "PUBLIC" const createdRole = await onCreateRoleSubmit({ ...data, diff --git a/src/components/[guild]/Requirements/RequirementErrorConfigContext.tsx b/src/components/[guild]/Requirements/RequirementErrorConfigContext.tsx index 4fa8b5fc5f..9dbf5128fc 100644 --- a/src/components/[guild]/Requirements/RequirementErrorConfigContext.tsx +++ b/src/components/[guild]/Requirements/RequirementErrorConfigContext.tsx @@ -5,7 +5,7 @@ type RequirementErrorConfig = Partial> const REQ_ERROR_CONFIG: RequirementErrorConfig = { GALAXY: "Galxe API error, please try again later", - TWITTER: "X API error, please try again later", + // TWITTER: "X API error, please try again later", } const RequirementErrorConfigContext = createContext({}) diff --git a/src/components/[guild]/Requirements/RoleRequirements.tsx b/src/components/[guild]/Requirements/RoleRequirements.tsx index 1d4a438c9a..feb2175cd5 100644 --- a/src/components/[guild]/Requirements/RoleRequirements.tsx +++ b/src/components/[guild]/Requirements/RoleRequirements.tsx @@ -43,7 +43,7 @@ const RoleRequirements = ({ const requirements = role.hiddenRequirements || data?.length === 0 - ? [...(data ?? []), { type: "HIDDEN", roleId: role.id } as Requirement] + ? [...(data ?? []), { roleId: role.id, visibility: "HIDDEN" } as Requirement] : data const isVirtualList = requirements?.length > VIRTUAL_LIST_REQUIREMENT_LIMIT diff --git a/src/components/[guild]/Requirements/components/GuildCheckout/MintGuildPin/components/ActivateGuildPinForm.tsx b/src/components/[guild]/Requirements/components/GuildCheckout/MintGuildPin/components/ActivateGuildPinForm.tsx index 8b096ed8d1..5bf19ecceb 100644 --- a/src/components/[guild]/Requirements/components/GuildCheckout/MintGuildPin/components/ActivateGuildPinForm.tsx +++ b/src/components/[guild]/Requirements/components/GuildCheckout/MintGuildPin/components/ActivateGuildPinForm.tsx @@ -8,7 +8,6 @@ import useToast from "hooks/useToast" import { FormProvider, useController, useForm, useWatch } from "react-hook-form" import { traitsSupportedChains } from "requirements/Nft/NftForm" import ChainPicker from "requirements/common/ChainPicker" -import { Visibility } from "types" import { GUILD_PIN_CONTRACTS } from "utils/guildCheckout/constants" import { Chain } from "wagmiConfig/chains" import { useMintGuildPinContext } from "../../MintGuildPinContext" @@ -76,7 +75,7 @@ const ActivateGuildPinForm = (): JSX.Element => { }, ], rolePlatforms: [], - visibility: Visibility.PUBLIC, + visibility: "PUBLIC", }) } : showSuccessToastAndCloseModal, diff --git a/src/components/[guild]/Requirements/components/GuildCheckout/components/BuyTotal.tsx b/src/components/[guild]/Requirements/components/GuildCheckout/components/BuyTotal.tsx index adc4580719..538981bfc0 100644 --- a/src/components/[guild]/Requirements/components/GuildCheckout/components/BuyTotal.tsx +++ b/src/components/[guild]/Requirements/components/GuildCheckout/components/BuyTotal.tsx @@ -3,7 +3,7 @@ import useTokenData from "hooks/useTokenData" import useVault from "requirements/Payment/hooks/useVault" import { NULL_ADDRESS } from "utils/guildCheckout/constants" import { formatUnits } from "viem" -import { CHAIN_CONFIG } from "wagmiConfig/chains" +import { Chain, CHAIN_CONFIG } from "wagmiConfig/chains" import { useRequirementContext } from "../../RequirementContext" import usePayFee from "../hooks/usePayFee" import FeesTable from "./FeesTable" @@ -14,13 +14,17 @@ const BuyTotal = (): JSX.Element => { const requirement = useRequirementContext() const { pickedCurrency } = useGuildCheckoutContext() + // TODO: we could remove the cast once we'll have schemas for "ERC..." requirements + const requirementChain = requirement.chain as Chain + const requirementAddress = requirement.address as `0x${string}` + const { token, fee, isLoading, error } = useVault( - requirement.address, + requirementAddress, requirement.data.id, - requirement.chain + requirementChain ) - const { data: tokenData } = useTokenData(requirement.chain, token) + const { data: tokenData } = useTokenData(requirementChain, token) const isNativeCurrency = pickedCurrency === NULL_ADDRESS @@ -31,7 +35,7 @@ const BuyTotal = (): JSX.Element => { ? parseFloat( formatUnits( estimatedGas, - CHAIN_CONFIG[requirement.chain].nativeCurrency.decimals + CHAIN_CONFIG[requirementChain].nativeCurrency.decimals ) ) : null @@ -39,7 +43,7 @@ const BuyTotal = (): JSX.Element => { const priceInSellToken = fee ? isNativeCurrency ? Number( - formatUnits(fee, CHAIN_CONFIG[requirement.chain].nativeCurrency.decimals) + formatUnits(fee, CHAIN_CONFIG[requirementChain].nativeCurrency.decimals) ) : tokenData?.decimals ? Number(formatUnits(fee, tokenData.decimals)) + @@ -97,7 +101,7 @@ const BuyTotal = (): JSX.Element => { {!estimatedGasInFloat ? "Couldn't estimate" : `${Number(estimatedGasInFloat.toFixed(8))} ${ - CHAIN_CONFIG[requirement.chain].nativeCurrency.symbol + CHAIN_CONFIG[requirementChain].nativeCurrency.symbol }`} diff --git a/src/components/[guild]/Requirements/components/GuildCheckout/components/PaymentFeeCurrency.tsx b/src/components/[guild]/Requirements/components/GuildCheckout/components/PaymentFeeCurrency.tsx index 0fc5a99d2d..a3b8b5a953 100644 --- a/src/components/[guild]/Requirements/components/GuildCheckout/components/PaymentFeeCurrency.tsx +++ b/src/components/[guild]/Requirements/components/GuildCheckout/components/PaymentFeeCurrency.tsx @@ -13,11 +13,11 @@ const PaymentFeeCurrency = (): JSX.Element => { const lightShade = useColorModeValue("white", "gray.700") const borderWidth = useColorModeValue(1, 0) - const requirement = useRequirementContext() + const requirement = useRequirementContext<"PAYMENT">() const { pickedCurrency, setPickedCurrency } = useGuildCheckoutContext() const { token, fee, error, isLoading } = useVault( - requirement?.address, + requirement?.address as `0x${string}`, requirement?.data?.id, requirement?.chain ) diff --git a/src/components/[guild]/Requirements/components/GuildCheckout/components/PurchaseFeeAndTotal.tsx b/src/components/[guild]/Requirements/components/GuildCheckout/components/PurchaseFeeAndTotal.tsx index 3cc8674d50..3fb50d274d 100644 --- a/src/components/[guild]/Requirements/components/GuildCheckout/components/PurchaseFeeAndTotal.tsx +++ b/src/components/[guild]/Requirements/components/GuildCheckout/components/PurchaseFeeAndTotal.tsx @@ -3,7 +3,7 @@ import useTokenData from "hooks/useTokenData" import { Info, Question } from "phosphor-react" import { GUILD_FEE_PERCENTAGE, NULL_ADDRESS } from "utils/guildCheckout/constants" import { formatUnits } from "viem" -import { CHAIN_CONFIG } from "wagmiConfig/chains" +import { Chain, CHAIN_CONFIG } from "wagmiConfig/chains" import { useRequirementContext } from "../../RequirementContext" import usePrice from "../hooks/usePrice" import usePurchaseAsset from "../hooks/usePurchaseAsset" @@ -15,9 +15,12 @@ const PurchaseFeeAndTotal = (): JSX.Element => { const requirement = useRequirementContext() const { pickedCurrency } = useGuildCheckoutContext() + // TODO: we could remove the cast once we'll have schemas for "ERC..." requirements + const requirementChain = requirement.chain as Chain + const { data: { symbol }, - } = useTokenData(requirement.chain, pickedCurrency) + } = useTokenData(requirementChain, pickedCurrency) const { data: { @@ -39,7 +42,7 @@ const PurchaseFeeAndTotal = (): JSX.Element => { ? parseFloat( formatUnits( estimatedGas, - CHAIN_CONFIG[requirement.chain].nativeCurrency.decimals + CHAIN_CONFIG[requirementChain].nativeCurrency.decimals ) ) : null @@ -168,7 +171,7 @@ const PurchaseFeeAndTotal = (): JSX.Element => { {!estimatedGasInFloat ? "Couldn't estimate" : `${estimatedGasInFloat.toFixed(8)} ${ - CHAIN_CONFIG[requirement.chain].nativeCurrency.symbol + CHAIN_CONFIG[requirementChain].nativeCurrency.symbol }`} diff --git a/src/components/[guild]/Requirements/components/GuildCheckout/components/PurchasedRequirementInfo.tsx b/src/components/[guild]/Requirements/components/GuildCheckout/components/PurchasedRequirementInfo.tsx index 5e49cb247c..eafb8a9740 100644 --- a/src/components/[guild]/Requirements/components/GuildCheckout/components/PurchasedRequirementInfo.tsx +++ b/src/components/[guild]/Requirements/components/GuildCheckout/components/PurchasedRequirementInfo.tsx @@ -8,6 +8,7 @@ import { VStack, } from "@chakra-ui/react" import useTokenData from "hooks/useTokenData" +import { Chain } from "wagmiConfig/chains" import { useRequirementContext } from "../../RequirementContext" type Props = { @@ -20,9 +21,13 @@ const PurchasedRequirementInfo = ({ rightElement, footer }: Props): JSX.Element const requirement = useRequirementContext() + // TODO: we could remove the cast once we'll have schemas for "ERC..." requirements + const requirementChain = requirement.chain as Chain + const requirementAddress = requirement.address as `0x${string}` + const { data: { symbol, logoURI }, - } = useTokenData(requirement?.chain, requirement?.address) + } = useTokenData(requirementChain, requirementAddress) return ( { const { captureEvent } = usePostHogContext() const { urlName } = useGuild() - const requirement = useRequirementContext() + const requirement = useRequirementContext<"PAYMENT">() + const requirementAddress = requirement.address as `0x${string}` + const requirementChainId = Chains[requirement.chain] const { pickedCurrency } = useGuildCheckoutContext() @@ -37,7 +39,7 @@ const BuyAllowanceButton = (): JSX.Element => { const tokenName = isNativeCurrencyPicked ? nativeCurrency.name : name const { fee, isLoading: isVaultLoading } = useVault( - requirement.address, + requirementAddress, requirement.data.id, requirement.chain ) @@ -48,7 +50,7 @@ const BuyAllowanceButton = (): JSX.Element => { isAllowing, allowanceError, allowSpendingTokens, - } = useAllowance(pickedCurrency, requirement.address) + } = useAllowance(pickedCurrency, requirementAddress) const isEnoughAllowance = typeof fee === "bigint" && typeof allowance === "bigint" diff --git a/src/components/[guild]/Requirements/components/GuildCheckout/components/buttons/BuyButton.tsx b/src/components/[guild]/Requirements/components/GuildCheckout/components/buttons/BuyButton.tsx index 78f3fd86cd..30cd19f432 100644 --- a/src/components/[guild]/Requirements/components/GuildCheckout/components/buttons/BuyButton.tsx +++ b/src/components/[guild]/Requirements/components/GuildCheckout/components/buttons/BuyButton.tsx @@ -18,7 +18,9 @@ const BuyButton = (): JSX.Element => { const { address, chainId } = useAccount() - const requirement = useRequirementContext() + const requirement = useRequirementContext<"PAYMENT">() + const requirementAddress = requirement.address as `0x${string}` + const { pickedCurrency, agreeWithTOS } = useGuildCheckoutContext() const { @@ -26,17 +28,17 @@ const BuyButton = (): JSX.Element => { multiplePayments, isLoading: isVaultLoading, error, - } = useVault(requirement.address, requirement.data.id, requirement.chain) + } = useVault(requirementAddress, requirement.data.id, requirement.chain) const { data: hasPaid, isLoading: isHasPaidLoading } = useHasPaid( - requirement.address, - requirement.data.id, + requirementAddress, + +requirement.data.id, requirement.chain ) const { allowance, isAllowanceLoading, allowanceError } = useAllowance( pickedCurrency, - requirement.address + requirementAddress ) const { diff --git a/src/components/[guild]/Requirements/components/GuildCheckout/components/buttons/PurchaseAllowanceButton.tsx b/src/components/[guild]/Requirements/components/GuildCheckout/components/buttons/PurchaseAllowanceButton.tsx index d55c02da00..f8bd607850 100644 --- a/src/components/[guild]/Requirements/components/GuildCheckout/components/buttons/PurchaseAllowanceButton.tsx +++ b/src/components/[guild]/Requirements/components/GuildCheckout/components/buttons/PurchaseAllowanceButton.tsx @@ -7,7 +7,7 @@ import useTokenData from "hooks/useTokenData" import { Check, Question, Warning } from "phosphor-react" import { NULL_ADDRESS, TOKEN_BUYER_CONTRACTS } from "utils/guildCheckout/constants" import { useChainId } from "wagmi" -import { CHAIN_CONFIG, Chains } from "wagmiConfig/chains" +import { Chain, CHAIN_CONFIG, Chains } from "wagmiConfig/chains" import { useRequirementContext } from "../../../RequirementContext" import usePrice from "../../hooks/usePrice" import { useGuildCheckoutContext } from "../GuildCheckoutContext" @@ -17,14 +17,16 @@ const PurchaseAllowanceButton = (): JSX.Element => { const { urlName } = useGuild() const requirement = useRequirementContext() - const requirementChainId = Chains[requirement.chain] + // TODO: remove typecast once we implement schemas for ERC20 requirements + const requirementChain = requirement.chain as Chain + const requirementChainId = Chains[requirementChain] const { pickedCurrency } = useGuildCheckoutContext() const chainId = useChainId() const { data: { symbol, name }, - } = useTokenData(requirement.chain, pickedCurrency) + } = useTokenData(requirementChain, pickedCurrency) const nativeCurrency = CHAIN_CONFIG[Chains[chainId]]?.nativeCurrency const isNativeCurrencyPicked = pickedCurrency === NULL_ADDRESS diff --git a/src/components/[guild]/Requirements/components/GuildCheckout/hooks/usePayFee.ts b/src/components/[guild]/Requirements/components/GuildCheckout/hooks/usePayFee.ts index e2a9c31069..f87a6dff99 100644 --- a/src/components/[guild]/Requirements/components/GuildCheckout/hooks/usePayFee.ts +++ b/src/components/[guild]/Requirements/components/GuildCheckout/hooks/usePayFee.ts @@ -22,7 +22,9 @@ const usePayFee = () => { const { address, chainId } = useAccount() - const requirement = useRequirementContext() + const requirement = useRequirementContext<"PAYMENT">() + const requirementAddress = requirement.address as `0x${string}` + const { pickedCurrency, onClose } = useGuildCheckoutContext() const showErrorToast = useShowErrorToast() @@ -33,11 +35,11 @@ const usePayFee = () => { multiplePayments, isLoading: isVaultLoading, refetch: refetchVault, - } = useVault(requirement.address, requirement.data.id, requirement.chain) + } = useVault(requirementAddress, requirement.data.id, requirement.chain) const { data: hasPaid, isLoading: isHasPaidLoading } = useHasPaid( - requirement.address, - requirement.data.id, + requirementAddress, + +requirement.data.id, requirement.chain ) @@ -60,7 +62,7 @@ const usePayFee = () => { ? coinBalanceData?.value >= fee : tokenBalanceData?.value >= fee) - const { allowance } = useAllowance(pickedCurrency, requirement.address) + const { allowance } = useAllowance(pickedCurrency, requirementAddress) const enabled = requirement?.chain === Chains[chainId] && diff --git a/src/components/[guild]/Requirements/components/GuildCheckout/hooks/usePurchaseAsset.ts b/src/components/[guild]/Requirements/components/GuildCheckout/hooks/usePurchaseAsset.ts index 157469b484..45e7a4fa33 100644 --- a/src/components/[guild]/Requirements/components/GuildCheckout/hooks/usePurchaseAsset.ts +++ b/src/components/[guild]/Requirements/components/GuildCheckout/hooks/usePurchaseAsset.ts @@ -62,7 +62,7 @@ const usePurchaseAsset = () => { }) const { data: purchasedTokenData } = useToken({ - address: requirement?.address, + address: requirement?.address as `0x${string}`, chainId: Chains[requirement?.chain], }) diff --git a/src/components/[guild]/Requirements/components/Requirement.tsx b/src/components/[guild]/Requirements/components/Requirement.tsx index 7417f50906..468f2e9f4f 100644 --- a/src/components/[guild]/Requirements/components/Requirement.tsx +++ b/src/components/[guild]/Requirements/components/Requirement.tsx @@ -12,7 +12,6 @@ import Visibility from "components/[guild]/Visibility" import dynamic from "next/dynamic" import React, { ComponentType, PropsWithChildren } from "react" import { useFormContext } from "react-hook-form" -import { Visibility as VisibilityType } from "types" import { useRequirementContext } from "./RequirementContext" import { RequirementImage, RequirementImageCircle } from "./RequirementImage" import ResetRequirementButton from "./ResetRequirementButton" @@ -77,8 +76,8 @@ const Requirement = ({ : requirement?.data?.customName || children} {!setValue ? ( ) : null} diff --git a/src/components/[guild]/Requirements/components/RequirementChainIndicator.tsx b/src/components/[guild]/Requirements/components/RequirementChainIndicator.tsx index 2aaee0a488..5afe8d54de 100644 --- a/src/components/[guild]/Requirements/components/RequirementChainIndicator.tsx +++ b/src/components/[guild]/Requirements/components/RequirementChainIndicator.tsx @@ -1,11 +1,12 @@ import { Img, Tag, TagLabel, TagProps, useColorModeValue } from "@chakra-ui/react" -import { CHAIN_CONFIG, Chain } from "wagmiConfig/chains" +import { Requirement } from "types" +import { CHAIN_CONFIG } from "wagmiConfig/chains" import { useRequirementContext } from "./RequirementContext" const RequirementChainIndicator = ({ chain: chainFromProp, ...rest -}: { chain?: Chain } & TagProps) => { +}: { chain?: Requirement["chain"] } & TagProps) => { const { chain: chainFromContext } = useRequirementContext() ?? {} const chain = chainFromProp ?? chainFromContext const bg = useColorModeValue("white", "blackAlpha.300") diff --git a/src/components/[guild]/Requirements/components/RequirementContext.tsx b/src/components/[guild]/Requirements/components/RequirementContext.tsx index ba7ba0d0c6..e9690ce12b 100644 --- a/src/components/[guild]/Requirements/components/RequirementContext.tsx +++ b/src/components/[guild]/Requirements/components/RequirementContext.tsx @@ -1,5 +1,7 @@ +import { schemas } from "@guildxyz/types" import { createContext, PropsWithChildren, useContext } from "react" import { Requirement } from "types" +import { z } from "zod" // It's safe to use undefine here as the default value, since we'll always have a default value in RequirementProvider const RequirementContext = createContext(undefined) @@ -22,6 +24,13 @@ const RequirementProvider = ({ ) } -const useRequirementContext = () => useContext(RequirementContext) +type ReqType = z.output["type"] +const useRequirementContext = () => { + const requirement = useContext(RequirementContext) + return requirement as unknown as Extract< + z.output, + { type: RequirementType } + > +} export { RequirementProvider, useRequirementContext } diff --git a/src/components/[guild]/Requirements/components/RequirementDisplayComponent.tsx b/src/components/[guild]/Requirements/components/RequirementDisplayComponent.tsx index d95c750eec..46bb5fc1c3 100644 --- a/src/components/[guild]/Requirements/components/RequirementDisplayComponent.tsx +++ b/src/components/[guild]/Requirements/components/RequirementDisplayComponent.tsx @@ -22,7 +22,7 @@ const RequirementDisplayComponent = ({ rightElement = , ...rest }: Props) => { - if (requirement.type === "HIDDEN") + if (requirement.visibility === "HIDDEN") return ( } diff --git a/src/components/[guild]/RoleCard/RoleCard.tsx b/src/components/[guild]/RoleCard/RoleCard.tsx index da4a619970..8f36dd5bee 100644 --- a/src/components/[guild]/RoleCard/RoleCard.tsx +++ b/src/components/[guild]/RoleCard/RoleCard.tsx @@ -17,7 +17,7 @@ import useMembership, { import dynamic from "next/dynamic" import rewards from "platforms/rewards" import { memo, useEffect, useRef } from "react" -import { PlatformType, Role, Visibility as VisibilityType } from "types" +import { PlatformType, Role } from "types" import RoleRequirements from "../Requirements" import useGuild from "../hooks/useGuild" import useGuildPermission from "../hooks/useGuildPermission" @@ -70,8 +70,7 @@ const RoleCard = memo(({ role }: Props) => { const isMobile = useBreakpointValue({ base: true, md: false }, { fallback: "md" }) - const collapsedHeight = - isMobile && role.visibility === VisibilityType.PUBLIC ? "90px" : "94px" + const collapsedHeight = isMobile && role.visibility === "PUBLIC" ? "90px" : "94px" return ( { onClick={() => { if (window.location.hash === `#role-${role.id}`) window.location.hash = "!" }} - {...(role.visibility === VisibilityType.HIDDEN + {...(role.visibility === "HIDDEN" ? { borderWidth: 2, borderStyle: "dashed", diff --git a/src/components/[guild]/RoleCard/components/EditRole/hooks/useEditRoleForm.ts b/src/components/[guild]/RoleCard/components/EditRole/hooks/useEditRoleForm.ts index 89dc2e4323..1d627f7d08 100644 --- a/src/components/[guild]/RoleCard/components/EditRole/hooks/useEditRoleForm.ts +++ b/src/components/[guild]/RoleCard/components/EditRole/hooks/useEditRoleForm.ts @@ -1,7 +1,8 @@ +import { Visibility } from "@guildxyz/types" import useGuild from "components/[guild]/hooks/useGuild" import { useEffect } from "react" import { useForm } from "react-hook-form" -import { Logic, Visibility } from "types" +import { Logic } from "types" export type RoleEditFormData = { id: number @@ -36,7 +37,7 @@ const useEditRoleForm = (roleId: number) => { imageUrl, logic, anyOfNum: anyOfNum ?? 1, - visibility, + visibility: visibility ?? "PUBLIC", visibilityRoleId, groupId, } diff --git a/src/components/[guild]/RoleCard/components/EditRole/hooks/useUpdateRolePlatformVisibility.ts b/src/components/[guild]/RoleCard/components/EditRole/hooks/useUpdateRolePlatformVisibility.ts index 424440c476..90ef9daf56 100644 --- a/src/components/[guild]/RoleCard/components/EditRole/hooks/useUpdateRolePlatformVisibility.ts +++ b/src/components/[guild]/RoleCard/components/EditRole/hooks/useUpdateRolePlatformVisibility.ts @@ -1,8 +1,9 @@ +import { Visibility } from "@guildxyz/types" import useGuild from "components/[guild]/hooks/useGuild" import useShowErrorToast from "hooks/useShowErrorToast" import useSubmit from "hooks/useSubmit" import useToast from "hooks/useToast" -import { RolePlatform, Visibility } from "types" +import { RolePlatform } from "types" import { useFetcherWithSign } from "utils/fetcher" import useLocalMutateRolePlatform from "./useLocalMutateRolePlatform" diff --git a/src/components/[guild]/RolePlatforms/components/AddRoleRewardModal/components/SelectExistingPlatform.tsx b/src/components/[guild]/RolePlatforms/components/AddRoleRewardModal/components/SelectExistingPlatform.tsx index 6928a27777..ae1d1248f2 100644 --- a/src/components/[guild]/RolePlatforms/components/AddRoleRewardModal/components/SelectExistingPlatform.tsx +++ b/src/components/[guild]/RolePlatforms/components/AddRoleRewardModal/components/SelectExistingPlatform.tsx @@ -6,13 +6,7 @@ import { DISPLAY_CARD_INTERACTIVITY_STYLES } from "components/common/DisplayCard import rewards, { PlatformAsRewardRestrictions } from "platforms/rewards" import { useState } from "react" import { useWatch } from "react-hook-form" -import { - PlatformType, - Requirement, - RoleFormType, - RolePlatform, - Visibility, -} from "types" +import { PlatformType, Requirement, RoleFormType, RolePlatform } from "types" import EditRolePlatformModal from "../../EditRolePlatformModal" import PlatformCard from "../../PlatformCard" @@ -36,7 +30,7 @@ const SelectExistingPlatform = ({ onClose, onSelect }: Props) => { name: "rolePlatforms", }) - const roleVisibility: Visibility = useWatch({ name: ".visibility" }) + const roleVisibility = useWatch({ name: "visibility" }) const filteredPlatforms = guildPlatforms ? guildPlatforms.filter( diff --git a/src/components/[guild]/Roles.tsx b/src/components/[guild]/Roles.tsx index c42572b9db..52371e6c4d 100644 --- a/src/components/[guild]/Roles.tsx +++ b/src/components/[guild]/Roles.tsx @@ -6,7 +6,6 @@ import useGuild from "components/[guild]/hooks/useGuild" import { useScrollBatchedRendering } from "hooks/useScrollBatchedRendering" import dynamic from "next/dynamic" import { useMemo, useState } from "react" -import { Visibility } from "types" import useGuildPermission from "./hooks/useGuildPermission" import useRoleGroup from "./hooks/useRoleGroup" @@ -44,12 +43,8 @@ const Roles = () => { ) }, [roles]) - const publicRoles = sortedRoles.filter( - (role) => role.visibility !== Visibility.HIDDEN - ) - const hiddenRoles = sortedRoles.filter( - (role) => role.visibility === Visibility.HIDDEN - ) + const publicRoles = sortedRoles.filter((role) => role.visibility !== "HIDDEN") + const hiddenRoles = sortedRoles.filter((role) => role.visibility === "HIDDEN") const [renderedRolesCount, setRenderedRolesCount] = useState(BATCH_SIZE) const rolesEl = useScrollBatchedRendering({ diff --git a/src/components/[guild]/SetVisibility/SetVisibility.tsx b/src/components/[guild]/SetVisibility/SetVisibility.tsx index c54c371415..ddd687166b 100644 --- a/src/components/[guild]/SetVisibility/SetVisibility.tsx +++ b/src/components/[guild]/SetVisibility/SetVisibility.tsx @@ -13,11 +13,11 @@ import { Tooltip, useColorModeValue, } from "@chakra-ui/react" +import { Visibility } from "@guildxyz/types" import Button from "components/common/Button" import RadioSelect from "components/common/RadioSelect" import { useRef } from "react" import { FormProvider, useController, useForm, useWatch } from "react-hook-form" -import { Visibility } from "types" import useVisibilityTooltipLabel from "./hooks/useVisibilityTooltipLabel" import { VISIBILITY_DATA } from "./visibilityData" @@ -35,7 +35,7 @@ const SetVisibility = ({ onSave, isLoading, defaultValues = { - visibility: Visibility.PUBLIC, + visibility: "PUBLIC", visibilityRoleId: undefined, }, ...buttonProps diff --git a/src/components/[guild]/SetVisibility/components/VisibilityTag.tsx b/src/components/[guild]/SetVisibility/components/VisibilityTag.tsx index 4497c6917d..3ec22dfaee 100644 --- a/src/components/[guild]/SetVisibility/components/VisibilityTag.tsx +++ b/src/components/[guild]/SetVisibility/components/VisibilityTag.tsx @@ -1,5 +1,5 @@ +import { Visibility } from "@guildxyz/types" import Button from "components/common/Button" -import { Visibility } from "types" import { VISIBILITY_DATA } from "../visibilityData" const VisibilityTag = ({ visibility }: { visibility: Visibility }) => { diff --git a/src/components/[guild]/SetVisibility/hooks/useVisibilityTooltipLabel.tsx b/src/components/[guild]/SetVisibility/hooks/useVisibilityTooltipLabel.tsx index 0f29851adb..6be6a64bc4 100644 --- a/src/components/[guild]/SetVisibility/hooks/useVisibilityTooltipLabel.tsx +++ b/src/components/[guild]/SetVisibility/hooks/useVisibilityTooltipLabel.tsx @@ -1,7 +1,7 @@ +import { Visibility } from "@guildxyz/types" import RoleTag from "components/[guild]/RoleTag" import useGuild from "components/[guild]/hooks/useGuild" import { ReactNode } from "react" -import { Visibility } from "types" import { VISIBILITY_DATA } from "../visibilityData" const useVisibilityTooltipLabel = ( @@ -10,12 +10,12 @@ const useVisibilityTooltipLabel = ( ): ReactNode => { const { roles } = useGuild() const role = - visibilityRoleId && visibility === Visibility.PRIVATE + visibilityRoleId && visibility === "PRIVATE" ? roles?.find(({ id }) => id === visibilityRoleId) : undefined const tooltipDescription = - visibility !== Visibility.PRIVATE ? ( + visibility !== "PRIVATE" ? ( VISIBILITY_DATA[visibility]?.description ?? VISIBILITY_DATA.PUBLIC.description ) : !visibilityRoleId ? ( "Only visible to role holders" diff --git a/src/components/[guild]/SetVisibility/visibilityData.tsx b/src/components/[guild]/SetVisibility/visibilityData.tsx index 8205cddedc..f754f7f14c 100644 --- a/src/components/[guild]/SetVisibility/visibilityData.tsx +++ b/src/components/[guild]/SetVisibility/visibilityData.tsx @@ -1,6 +1,6 @@ +import { Visibility } from "@guildxyz/types" import { Option } from "components/common/RadioSelect/RadioSelect" import { Detective, EyeSlash, GlobeHemisphereEast, IconProps } from "phosphor-react" -import { Visibility } from "types" import PrivateVisibilityOptions from "./components/PrivateVisibilityOptions" export const VISIBILITY_DATA: Record< @@ -13,18 +13,18 @@ export const VISIBILITY_DATA: Record< Child?: typeof PrivateVisibilityOptions } > = { - [Visibility.PUBLIC]: { + PUBLIC: { title: "Public", Icon: GlobeHemisphereEast, description: "Visible to everyone", }, - [Visibility.PRIVATE]: { + PRIVATE: { title: "Secret", Icon: Detective, description: "Only visible to users that satisfy...", Child: PrivateVisibilityOptions, }, - [Visibility.HIDDEN]: { + HIDDEN: { title: "Hidden", Icon: EyeSlash, description: "Only visible to admins", diff --git a/src/components/[guild]/Visibility.tsx b/src/components/[guild]/Visibility.tsx index 98a9a77cbc..621981204d 100644 --- a/src/components/[guild]/Visibility.tsx +++ b/src/components/[guild]/Visibility.tsx @@ -1,5 +1,5 @@ import { Tag, TagLabel, TagLeftIcon, TagProps, Tooltip } from "@chakra-ui/react" -import { Visibility as VisibilityType } from "types" +import { Visibility as VisibilityType } from "@guildxyz/types" import useVisibilityTooltipLabel from "./SetVisibility/hooks/useVisibilityTooltipLabel" import { VISIBILITY_DATA } from "./SetVisibility/visibilityData" @@ -19,7 +19,7 @@ const Visibility = ({ const label = useVisibilityTooltipLabel(entityVisibility, visibilityRoleId) - if (entityVisibility === VisibilityType.PUBLIC) return null + if (entityVisibility === "PUBLIC") return null return ( diff --git a/src/components/[guild]/crm/FilterByRoles/FilterByRoles.tsx b/src/components/[guild]/crm/FilterByRoles/FilterByRoles.tsx index f1e989a6a5..ef1e0c43da 100644 --- a/src/components/[guild]/crm/FilterByRoles/FilterByRoles.tsx +++ b/src/components/[guild]/crm/FilterByRoles/FilterByRoles.tsx @@ -22,7 +22,7 @@ import { import { MemberCountWithSyncIndicator } from "components/[guild]/RoleCard/components/MemberCount" import { Funnel } from "phosphor-react" import { memo, useState } from "react" -import { Role, Visibility } from "types" +import { Role } from "types" import useGuild from "../../hooks/useGuild" import FilterByRolesLogicSelector from "./FilterByRolesLogicSelector" import AddAndEditHiddenRoles from "./components/AddAndEditHiddenRoles" @@ -33,8 +33,8 @@ const FilterByRoles = ({ getFilterValue, setFilterValue }: any) => { const { roles } = useGuild() const [searchValue, setSearchValue] = useState("") - const publicRoles = roles?.filter((role) => role.visibility !== Visibility.HIDDEN) - const hiddenRoles = roles?.filter((role) => role.visibility === Visibility.HIDDEN) + const publicRoles = roles?.filter((role) => role.visibility !== "HIDDEN") + const hiddenRoles = roles?.filter((role) => role.visibility === "HIDDEN") const selectedRoleIds: number[] = getFilterValue()?.roleIds ?? [] const setSelectedRoleIds = (newValue: number[]) => { diff --git a/src/components/[guild]/crm/FilterByRoles/components/AddHiddenRoleButton.tsx b/src/components/[guild]/crm/FilterByRoles/components/AddHiddenRoleButton.tsx index 2ae80796e2..8ed2153506 100644 --- a/src/components/[guild]/crm/FilterByRoles/components/AddHiddenRoleButton.tsx +++ b/src/components/[guild]/crm/FilterByRoles/components/AddHiddenRoleButton.tsx @@ -20,7 +20,6 @@ import usePinata from "hooks/usePinata" import useSubmitWithUpload from "hooks/useSubmitWithUpload" import { Plus } from "phosphor-react" import { FormProvider, useForm, useWatch } from "react-hook-form" -import { Visibility } from "types" import getRandomInt from "utils/getRandomInt" import SetHiddenRoleRequirements from "./SetHiddenRoleRequirements" import useCreateHiddenRole from "./useCreateHiddenRole" @@ -42,7 +41,7 @@ const AddHiddenRoleButton = (buttonProps) => { requirements: [], roleType: "NEW", imageUrl: `/guildLogos/${getRandomInt(286)}.svg`, - visibility: Visibility.HIDDEN, + visibility: "HIDDEN", } const methods = useForm({ mode: "all", defaultValues }) diff --git a/src/components/[guild]/crm/FilterByRoles/components/SetHiddenRoleRequirements.tsx b/src/components/[guild]/crm/FilterByRoles/components/SetHiddenRoleRequirements.tsx index 36d1052ff0..8362f52b3f 100644 --- a/src/components/[guild]/crm/FilterByRoles/components/SetHiddenRoleRequirements.tsx +++ b/src/components/[guild]/crm/FilterByRoles/components/SetHiddenRoleRequirements.tsx @@ -17,7 +17,6 @@ const SetHiddenRoleRequirements = (): JSX.Element => { const { fields, append, update } = useFieldArray({ name: "requirements", control, - keyName: "formFieldId", }) // Watching the nested fields too, so we can properly update the list @@ -52,7 +51,7 @@ const SetHiddenRoleRequirements = (): JSX.Element => { const type: RequirementType = getValues(`requirements.${i}.type`) return ( - + diff --git a/src/components/[guild]/crm/useMembers.tsx b/src/components/[guild]/crm/useMembers.tsx index d28e1a3dd2..f85013d56a 100644 --- a/src/components/[guild]/crm/useMembers.tsx +++ b/src/components/[guild]/crm/useMembers.tsx @@ -1,7 +1,7 @@ import useActiveStatusUpdates from "hooks/useActiveStatusUpdates" import { useCallback, useMemo } from "react" import useSWRInfinite from "swr/infinite" -import { PlatformAccountDetails, Visibility } from "types" +import { PlatformAccountDetails } from "types" import { useFetcherWithSign } from "utils/fetcher" import useGuild from "../hooks/useGuild" import { useUserPublic } from "../hooks/useUser" @@ -60,12 +60,8 @@ const useMembers = (queryString: string) => { platformUsers: user.platformUsers.sort(sortAccounts), isShared: user.isShared === true || user.isShared === null, roles: { - hidden: user.roles.filter( - (role) => role.visibility === Visibility.HIDDEN - ), - public: user.roles.filter( - (role) => role.visibility !== Visibility.HIDDEN - ), + hidden: user.roles.filter((role) => role.visibility === "HIDDEN"), + public: user.roles.filter((role) => role.visibility !== "HIDDEN"), }, })) ), diff --git a/src/components/[guild]/messages/Message.tsx b/src/components/[guild]/messages/Message.tsx index 2732906cb5..da15098e93 100644 --- a/src/components/[guild]/messages/Message.tsx +++ b/src/components/[guild]/messages/Message.tsx @@ -28,7 +28,6 @@ import { import Card from "components/common/Card" import { Modal } from "components/common/Modal" import { Check, Question, Users } from "phosphor-react" -import { Visibility } from "types" import RoleTag from "../RoleTag" import useGuild from "../hooks/useGuild" import { Message as MessageType } from "./hooks/useGuildMessages" @@ -118,7 +117,7 @@ const Message = ({ key={role.id} name={role.name} imageUrl={role.imageUrl} - isHidden={role.visibility === Visibility.HIDDEN} + isHidden={role.visibility === "HIDDEN"} /> ))} {moreRolesCount > 0 && ( @@ -185,7 +184,7 @@ const Message = ({ key={role.id} name={role.name} imageUrl={role.imageUrl} - isHidden={role.visibility === Visibility.HIDDEN} + isHidden={role.visibility === "HIDDEN"} /> ))} diff --git a/src/components/create-guild/BasicInfo/components/ContactInfo.tsx b/src/components/create-guild/BasicInfo/components/ContactInfo.tsx index 7902c526b5..1c6adf60c8 100644 --- a/src/components/create-guild/BasicInfo/components/ContactInfo.tsx +++ b/src/components/create-guild/BasicInfo/components/ContactInfo.tsx @@ -40,16 +40,14 @@ const ContactInfo = ({ showAddButton = true }: Props): JSX.Element => { } = useFormContext() const { fields, append, remove } = useFieldArray({ - control, name: "contacts", - keyName: "formId", }) return ( {fields.map((contactField, index) => ( - + void + onAdd?: (req: Schemas["RequirementCreationPayload"]) => void handleClose: (forceClose?: boolean) => void selectedType?: RequirementType setOnCloseAttemptToast: Dispatch> @@ -204,10 +205,9 @@ const AddRequirementForm = forwardRef( ) => { const FormComponent = REQUIREMENTS[selectedType].formComponent - const methods = useForm({ mode: "all" }) + const methods = useForm({ mode: "all" }) - const roleVisibility: Visibility = useWatch({ name: ".visibility" }) - const roleId: number = useWatch({ name: ".id" }) + const roleId: number = useWatch({ name: "id" }) const [isPresent, safeToRemove] = usePresence() useEffect(() => { @@ -228,14 +228,13 @@ const AddRequirementForm = forwardRef( }, }) - const formType = useWatch({ name: ".type" as any, control: methods.control }) - const onSubmit = methods.handleSubmit((data) => { - const requirement: Requirement = { - type: selectedType, - visibility: roleVisibility, + if (!selectedType) return + + const requirement = schemas.RequirementCreationPayloadSchema.parse({ ...data, - } + type: selectedType, + }) if (!roleId) { onAdd?.(requirement) @@ -266,14 +265,16 @@ const AddRequirementForm = forwardRef( providerTypesOnly={providerTypesOnly} /> - {!!REQUIREMENT_PROVIDED_VALUES[formType ?? selectedType] && ( + {!!REQUIREMENT_PROVIDED_VALUES[selectedType] && ( <> {" "} + } /> )} diff --git a/src/components/create-guild/Requirements/components/ExistingRequirementEditableCard.tsx b/src/components/create-guild/Requirements/components/ExistingRequirementEditableCard.tsx index d5c8c434fc..dd83b83217 100644 --- a/src/components/create-guild/Requirements/components/ExistingRequirementEditableCard.tsx +++ b/src/components/create-guild/Requirements/components/ExistingRequirementEditableCard.tsx @@ -8,10 +8,10 @@ import RequirementImageEditor from "components/[guild]/Requirements/components/R import RequirementNameEditor from "components/[guild]/Requirements/components/RequirementNameEditor" import SetVisibility from "components/[guild]/SetVisibility" import useVisibilityModalProps from "components/[guild]/SetVisibility/hooks/useVisibilityModalProps" -import { PropsWithChildren, useRef } from "react" +import { ComponentProps, PropsWithChildren, useRef } from "react" import { FormProvider, useForm } from "react-hook-form" import REQUIREMENTS from "requirements" -import { Requirement as RequirementType } from "types" +import { Requirement, Requirement as RequirementType } from "types" import mapRequirement from "utils/mapRequirement" import useEditRequirement from "../hooks/useEditRequirement" import BalancyFooter from "./BalancyFooter" @@ -118,7 +118,7 @@ const ExistingRequirementEditModal = ({ onClose, finalFocusRef, }: Omit) => { - const methods = useForm({ mode: "all", defaultValues: requirement }) + const methods = useForm({ mode: "all", defaultValues: requirement }) const { onSubmit: onEditRequirementSubmit, isLoading: isEditRequirementLoading } = useEditRequirement(requirement.roleId, { @@ -201,7 +201,9 @@ const RequirementNameEditorWithSave = ({ children }: PropsWithChildren) onSuccess: () => setVisibilityModalProps.onClose(), }) - const onEditVisibilitySubmit = (visibilityData) => { + const onEditVisibilitySubmit: ComponentProps["onSave"] = ( + visibilityData + ) => { const editedData = { ...requirement, ...visibilityData, diff --git a/src/components/create-guild/Requirements/components/RequirementEditableCard.tsx b/src/components/create-guild/Requirements/components/RequirementEditableCard.tsx index c394fe8b1b..17546b5862 100644 --- a/src/components/create-guild/Requirements/components/RequirementEditableCard.tsx +++ b/src/components/create-guild/Requirements/components/RequirementEditableCard.tsx @@ -39,7 +39,10 @@ const RequirementEditableCard = ({ const editButtonRef = useRef() const { setValue } = useFormContext() - const methods = useForm({ mode: "all", defaultValues: field }) + const methods = useForm({ + mode: "all", + defaultValues: field, + }) const showViewOriginal = field?.data?.customName || field?.data?.customImage @@ -94,7 +97,7 @@ const RequirementEditableCard = ({ mt={-0.5} defaultValues={{ visibility: field.visibility, - visibilityRoleId: field.visibilityRoleId, + visibilityRoleId: field.visibilityRoleId ?? undefined, }} onSave={({ visibility, visibilityRoleId }) => { setValue(`requirements.${index}.visibility`, visibility, { diff --git a/src/components/create-guild/Requirements/hooks/useBalancy.ts b/src/components/create-guild/Requirements/hooks/useBalancy.ts index b9cb2ba713..c04435d327 100644 --- a/src/components/create-guild/Requirements/hooks/useBalancy.ts +++ b/src/components/create-guild/Requirements/hooks/useBalancy.ts @@ -3,7 +3,6 @@ import useDebouncedState from "hooks/useDebouncedState" import { useEffect, useMemo, useState } from "react" import { useWatch } from "react-hook-form" import useSWR from "swr" -import { Requirement } from "types" import fetcher from "utils/fetcher" import { parseUnits } from "viem" import { Chain, Chains } from "wagmiConfig/chains" @@ -97,7 +96,7 @@ const useBalancy = ( // Fixed logic for single requirement to avoid unnecessary refetch when changing logic const balancyLogic = baseFieldPath !== undefined ? "OR" : logic - const renderedRequirements = useMemo( + const renderedRequirements = useMemo( () => (baseFieldPath !== undefined ? debouncedRequirement diff --git a/src/components/create-guild/Requirements/hooks/useCreateRequirement.ts b/src/components/create-guild/Requirements/hooks/useCreateRequirement.ts index f5d5820ea5..fb585e126e 100644 --- a/src/components/create-guild/Requirements/hooks/useCreateRequirement.ts +++ b/src/components/create-guild/Requirements/hooks/useCreateRequirement.ts @@ -1,8 +1,9 @@ +import { Schemas } from "@guildxyz/types" import useGuild from "components/[guild]/hooks/useGuild" import useRequirements from "components/[guild]/hooks/useRequirements" import useShowErrorToast from "hooks/useShowErrorToast" import useSubmit from "hooks/useSubmit" -import { Requirement } from "types" +import { RequirementCreateResponseOutput } from "types" import { useFetcherWithSign } from "utils/fetcher" import preprocessRequirement from "utils/preprocessRequirement" @@ -15,7 +16,9 @@ const useCreateRequirement = ( const showErrorToast = useShowErrorToast() const fetcherWithSign = useFetcherWithSign() - const createRequirement = async (body: Requirement): Promise => + const createRequirement = async ( + body?: Schemas["RequirementCreationPayload"] + ): Promise => fetcherWithSign([ `/v2/guilds/${guildId}/roles/${roleId}/requirements`, { @@ -25,16 +28,16 @@ const useCreateRequirement = ( ]) return useSubmit< - Omit, - Requirement & { deletedRequirements?: number[] } + Schemas["RequirementCreationPayload"], + RequirementCreateResponseOutput >(createRequirement, { onSuccess: (response) => { if ( (response.type === "ALLOWLIST" || response.type === "ALLOWLIST_EMAIL") && response.data?.fileId ) { - response.data ??= {} - response.data.status = "IN-PROGRESS" + // TODO: add the "status" prop to the schema + ;(response.data as any).status = "IN-PROGRESS" } mutateRequirements( diff --git a/src/components/create-guild/Requirements/hooks/useEditRequirement.ts b/src/components/create-guild/Requirements/hooks/useEditRequirement.ts index bc4f42379f..18eb66aeb1 100644 --- a/src/components/create-guild/Requirements/hooks/useEditRequirement.ts +++ b/src/components/create-guild/Requirements/hooks/useEditRequirement.ts @@ -1,17 +1,18 @@ +import { Schemas } from "@guildxyz/types" import useGuild from "components/[guild]/hooks/useGuild" import useRequirements from "components/[guild]/hooks/useRequirements" import useShowErrorToast from "hooks/useShowErrorToast" import useSubmit from "hooks/useSubmit" import useToast from "hooks/useToast" -import { Requirement } from "types" +import { RequirementCreateResponseOutput } from "types" import { useFetcherWithSign } from "utils/fetcher" import preprocessRequirement from "utils/preprocessRequirement" -type EditedRequirement = Requirement & { deletedRequirements?: number[] } - const useEditRequirement = ( roleId: number, - config?: { onSuccess?: (editedRequirement: EditedRequirement) => void } + config?: { + onSuccess?: (editedRequirement: RequirementCreateResponseOutput) => void + } ) => { const { id: guildId } = useGuild() const { mutate: mutateRequirements } = useRequirements(roleId) @@ -20,27 +21,29 @@ const useEditRequirement = ( const showErrorToast = useShowErrorToast() const fetcherWithSign = useFetcherWithSign() - const editRequirement = async (data: Requirement): Promise => + const editRequirement = async ( + data?: Schemas["RequirementUpdatePayload"] & { id: number } + ): Promise => fetcherWithSign([ - `/v2/guilds/${guildId}/roles/${roleId}/requirements/${data.id}`, + `/v2/guilds/${guildId}/roles/${roleId}/requirements/${data?.id}`, { method: "PUT", - body: preprocessRequirement({ - ...data, - id: undefined, - }), + body: preprocessRequirement(data), }, ]) - return useSubmit(editRequirement, { + return useSubmit< + Schemas["RequirementUpdatePayload"] & { id: number }, + RequirementCreateResponseOutput + >(editRequirement, { onSuccess: (editedRequirement) => { if ( (editedRequirement.type === "ALLOWLIST" || editedRequirement.type === "ALLOWLIST_EMAIL") && editedRequirement.data?.fileId ) { - editedRequirement.data ??= {} - editedRequirement.data.status = "IN-PROGRESS" + // TODO: add the "status" prop to the schema + ;(editedRequirement.data as any).status = "IN-PROGRESS" } toast({ diff --git a/src/components/create-guild/Requirements/hooks/useHandleRequirementState.ts b/src/components/create-guild/Requirements/hooks/useHandleRequirementState.ts index 672ef57e06..aea2edd6d6 100644 --- a/src/components/create-guild/Requirements/hooks/useHandleRequirementState.ts +++ b/src/components/create-guild/Requirements/hooks/useHandleRequirementState.ts @@ -25,7 +25,7 @@ const useHandleRequirementState = (methods) => { } const append = (req: Requirement) => { - const reqToAdd = { id: Date.now(), ...req } + const reqToAdd = { ...req, id: Date.now() } if (freeEntry) { remove(0) } diff --git a/src/components/create-guild/hooks/useCreateRole.tsx b/src/components/create-guild/hooks/useCreateRole.tsx index 5c57b88f36..d5fb058bb8 100644 --- a/src/components/create-guild/hooks/useCreateRole.tsx +++ b/src/components/create-guild/hooks/useCreateRole.tsx @@ -8,7 +8,13 @@ import useCustomPosthogEvents from "hooks/useCustomPosthogEvents" import useMatchMutate from "hooks/useMatchMutate" import useShowErrorToast from "hooks/useShowErrorToast" import { SignedValidation, useSubmitWithSign } from "hooks/useSubmit" -import { GuildBase, GuildPlatform, Requirement, Role } from "types" +import { + GuildBase, + GuildPlatform, + Requirement, + RequirementCreationPayloadWithTempID, + Role, +} from "types" import fetcher from "utils/fetcher" import replacer from "utils/guildJsonReplacer" import preprocessRequirement from "utils/preprocessRequirement" @@ -19,7 +25,7 @@ export type RoleToCreate = Omit< > & { guildId: number roleType?: "NEW" - requirements: Omit[] + requirements: RequirementCreationPayloadWithTempID[] } type CreateRoleResponse = Role & { diff --git a/src/hooks/useSubmitTransaction.ts b/src/hooks/useSubmitTransaction.ts index 2865977fc5..a43ad3e46e 100644 --- a/src/hooks/useSubmitTransaction.ts +++ b/src/hooks/useSubmitTransaction.ts @@ -102,7 +102,10 @@ const useSubmitTransaction = ( functionName: contractCallConfig.functionName as ContractFunctionName, args: contractCallConfig.args as ContractFunctionArgs, value: contractCallConfig.value as bigint, - shouldFetch: contractCallConfig.query?.enabled ?? true, + shouldFetch: + typeof contractCallConfig.query?.enabled === "boolean" + ? contractCallConfig.query.enabled + : true, }) const { diff --git a/src/pages/[guild]/members.tsx b/src/pages/[guild]/members.tsx index c75d8f2ecf..bf39a78dec 100644 --- a/src/pages/[guild]/members.tsx +++ b/src/pages/[guild]/members.tsx @@ -30,7 +30,6 @@ import Head from "next/head" import { useRouter } from "next/router" import ErrorPage from "pages/_error" import { useEffect, useMemo, useRef, useState } from "react" -import { Visibility } from "types" const columnHelper = createColumnHelper() const getRowId = (row: Member) => `user_${row.userId}` @@ -160,7 +159,7 @@ const MembersPage = (): JSX.Element => { getRowId, }) - const hasHiddenRoles = roles?.some((role) => role.visibility === Visibility.HIDDEN) + const hasHiddenRoles = roles?.some((role) => role.visibility === "HIDDEN") useEffect(() => { const hiddenRolesColumn = table .getAllLeafColumns() diff --git a/src/platforms/components/SelectRoleOrSetRequirements.tsx b/src/platforms/components/SelectRoleOrSetRequirements.tsx index 56193ed3b3..1ab219483f 100644 --- a/src/platforms/components/SelectRoleOrSetRequirements.tsx +++ b/src/platforms/components/SelectRoleOrSetRequirements.tsx @@ -9,7 +9,7 @@ import useRoleGroup from "components/[guild]/hooks/useRoleGroup" import SetRequirements from "components/create-guild/Requirements" import rewards, { PlatformAsRewardRestrictions } from "platforms/rewards" import { useFormContext, useWatch } from "react-hook-form" -import { PlatformName, Visibility } from "types" +import { PlatformName } from "types" import getRandomInt from "utils/getRandomInt" type Props = { @@ -63,7 +63,7 @@ const SelectRoleOrSetRequirements = ({ isRoleSelectorDisabled }: Props) => { unregister("roleIds") setValue("name", data?.roleName || `New ${rewards[selection].name} role`) setValue("imageUrl", data?.imageUrl || `/guildLogos/${getRandomInt(286)}.svg`) - setValue("roleVisibility", Visibility.PUBLIC) + setValue("roleVisibility", "PUBLIC") } setActiveTab(value) diff --git a/src/requirements/Airdrop/AirdropRequirement.tsx b/src/requirements/Airdrop/AirdropRequirement.tsx index a25b44a57a..29da3c7808 100644 --- a/src/requirements/Airdrop/AirdropRequirement.tsx +++ b/src/requirements/Airdrop/AirdropRequirement.tsx @@ -1,5 +1,4 @@ import { Icon, Text, useDisclosure } from "@chakra-ui/react" -import { Schemas } from "@guildxyz/types" import Requirement, { RequirementProps, } from "components/[guild]/Requirements/components/Requirement" @@ -10,10 +9,7 @@ import { ArrowSquareIn } from "phosphor-react" import REQUIREMENTS from "requirements" const AirdropRequirement = ({ ...rest }: RequirementProps): JSX.Element => { - const requirement = useRequirementContext() as Extract< - Schemas["Requirement"], - { type: "GUILD_SNAPSHOT" } - > + const requirement = useRequirementContext<"GUILD_SNAPSHOT">() const { isHidden } = requirement?.data diff --git a/src/requirements/Allowlist/AllowlistRequirement.tsx b/src/requirements/Allowlist/AllowlistRequirement.tsx index f745842957..4d18cd8197 100644 --- a/src/requirements/Allowlist/AllowlistRequirement.tsx +++ b/src/requirements/Allowlist/AllowlistRequirement.tsx @@ -23,13 +23,14 @@ function HiddenAllowlistText({ isEmail }: { isEmail: boolean }) { } const AllowlistRequirement = ({ ...rest }: RequirementProps): JSX.Element => { - const requirement = useRequirementContext() as Extract< + const requirement = useRequirementContext<"ALLOWLIST" | "ALLOWLIST_EMAIL">() + // TODO: we should add addressCount to the schema, and remove the cast later on + const castedRequirement = requirement as unknown as Extract< Schemas["Requirement"], { type: "ALLOWLIST" | "ALLOWLIST_EMAIL" } > & { data: { // These are not included in the schemas, as these are appended on-the-fly by the BE, when sending the response - fileId?: string addressCount?: number } } @@ -42,12 +43,12 @@ const AllowlistRequirement = ({ ...rest }: RequirementProps): JSX.Element => { hideAllowlist, addressCount, fileId, - } = requirement.data + } = castedRequirement.data const willSearchAddresses = search !== debouncedSearch const { data: req, isValidating: isSearchingAddresses } = useRequirement( - requirement?.roleId, - requirement?.id, + castedRequirement?.roleId, + castedRequirement?.id, debouncedSearch ) @@ -60,12 +61,12 @@ const AllowlistRequirement = ({ ...rest }: RequirementProps): JSX.Element => { const { isOpen, onOpen, onClose } = useDisclosure() - const isEmail = requirement.type === "ALLOWLIST_EMAIL" + const isEmail = castedRequirement.type === "ALLOWLIST_EMAIL" - const { reqAccesses } = useRoleMembership(requirement.roleId) + const { reqAccesses } = useRoleMembership(castedRequirement.roleId) const hasAccess = reqAccesses?.find( - ({ requirementId }) => requirementId === requirement.id + ({ requirementId }) => requirementId === castedRequirement.id )?.access const shouldShowSearchHints = diff --git a/src/requirements/Farcaster/FarcasterRequirement.tsx b/src/requirements/Farcaster/FarcasterRequirement.tsx index 27d48c8e5f..e00b75f082 100644 --- a/src/requirements/Farcaster/FarcasterRequirement.tsx +++ b/src/requirements/Farcaster/FarcasterRequirement.tsx @@ -14,7 +14,7 @@ import { useFarcasterUser } from "./hooks/useFarcasterUsers" const FarcasterProfile = (props: RequirementProps) => ( } {...props} > @@ -59,7 +59,7 @@ const FarcasterTotalFollowers = (props: RequirementProps) => { return ( } - image={REQUIREMENTS.FARCASTER.icon.toString()} + image={REQUIREMENTS.FARCASTER_TOTAL_FOLLOWERS.icon.toString()} {...props} > {`Have at least ${data?.min ?? "-"} followers on Farcaster`} @@ -79,7 +79,7 @@ const FarcasterLikeRecast = (props: RequirementProps) => { return ( } - image={REQUIREMENTS.FARCASTER.icon.toString()} + image={REQUIREMENTS.FARCASTER_LIKE.icon.toString()} {...props} > {type === "FARCASTER_LIKE" ? "Like" : "Recast"} @@ -105,7 +105,7 @@ const FarcasterFollowChannel = (props: RequirementProps) => { return ( } - image={REQUIREMENTS.FARCASTER.icon.toString()} + image={REQUIREMENTS.FARCASTER_FOLLOW_CHANNEL.icon.toString()} {...props} > {"Follow the "} @@ -136,13 +136,13 @@ const FarcasterIncludeText = (props: RequirementProps) => { return ( } - image={REQUIREMENTS.FARCASTER.icon.toString()} + image={REQUIREMENTS.FARCASTER_BIO.icon.toString()} {...props} > {"Have "} - {` in your ${REQUIREMENTS.FARCASTER.name} ${PROFILE_TARGETS[type]}`} + {` in your ${REQUIREMENTS.FARCASTER_BIO.name} ${PROFILE_TARGETS[type]}`} ) diff --git a/src/requirements/Fuel/FuelRequirement.tsx b/src/requirements/Fuel/FuelRequirement.tsx index a9a8ec0422..db607a2a84 100644 --- a/src/requirements/Fuel/FuelRequirement.tsx +++ b/src/requirements/Fuel/FuelRequirement.tsx @@ -12,6 +12,11 @@ const NULL_FUEL_ADDRESS = const FuelRequirement = (props: RequirementProps) => { const { type, address, data } = useRequirementContext() + + // TODO: remove these once we implement the Fuel requirement schema + const requirementAddress = address as `0x${string}` + const requirementDataSymbol = data.symbol + const tagBg = useColorModeValue("white", "blackAlpha.300") return ( @@ -47,11 +52,11 @@ const FuelRequirement = (props: RequirementProps) => { } `} {address === NULL_FUEL_ADDRESS ? ( "ETH" - ) : data?.symbol ? ( - {data.symbol} + ) : requirementDataSymbol ? ( + {requirementDataSymbol} ) : ( - - {shortenHex(address)} + + {shortenHex(requirementAddress)} )} diff --git a/src/requirements/Lens/LensRequirement.tsx b/src/requirements/Lens/LensRequirement.tsx index 3f2d6a9a73..c224fe3ac4 100644 --- a/src/requirements/Lens/LensRequirement.tsx +++ b/src/requirements/Lens/LensRequirement.tsx @@ -51,7 +51,7 @@ const LensRequirement = (props: RequirementProps) => { return return ( - + {(() => { switch (requirement.type) { case "LENS_REACT": @@ -100,7 +100,7 @@ const LensFollowRequirement = (props: RequirementProps) => { return ( diff --git a/src/requirements/Lens/hooks/useLensProfile.ts b/src/requirements/Lens/hooks/useLensProfile.ts index de4649aed5..b1a5e53e58 100644 --- a/src/requirements/Lens/hooks/useLensProfile.ts +++ b/src/requirements/Lens/hooks/useLensProfile.ts @@ -45,7 +45,7 @@ const useLensProfile = (id: string) => { value: data.id, img: data.metadata?.picture?.optimized?.uri ?? - (REQUIREMENTS.LENS.icon as string), + (REQUIREMENTS.LENS_ACTION.icon as string), } : undefined, } diff --git a/src/requirements/Lens/hooks/useLensProfiles.ts b/src/requirements/Lens/hooks/useLensProfiles.ts index 9a17db47a7..c5521a90ec 100644 --- a/src/requirements/Lens/hooks/useLensProfiles.ts +++ b/src/requirements/Lens/hooks/useLensProfiles.ts @@ -66,7 +66,9 @@ const useLensProfiles = (searchQuery: string) => { handles: data?.map(({ id, handle: { localName }, metadata }) => ({ label: `${localName}.lens`, value: id, - img: metadata?.picture?.optimized?.uri ?? (REQUIREMENTS.LENS.icon as string), + img: + metadata?.picture?.optimized?.uri ?? + (REQUIREMENTS.LENS_ACTION.icon as string), })), isLoading, } diff --git a/src/requirements/Mirror/MirrorRequirement.tsx b/src/requirements/Mirror/MirrorRequirement.tsx index 66eb197955..abc3be01d5 100644 --- a/src/requirements/Mirror/MirrorRequirement.tsx +++ b/src/requirements/Mirror/MirrorRequirement.tsx @@ -6,14 +6,19 @@ import Requirement, { import { useRequirementContext } from "components/[guild]/Requirements/components/RequirementContext" import DataBlock from "components/common/DataBlock" import shortenHex from "utils/shortenHex" +import { Chain } from "wagmiConfig/chains" import useMirrorEdition from "./hooks/useMirrorEdition" const MirrorRequirement = (props: RequirementProps): JSX.Element => { const requirement = useRequirementContext() + // TODO: we could remove the cast once we'll have schemas for this requirement + const requirementChain = requirement.chain as Chain + const requirementAddress = requirement.address as `0x${string}` + const { isLoading, name, image, error } = useMirrorEdition( - requirement.address, - requirement.chain + requirementAddress, + requirementChain ) return ( @@ -34,7 +39,7 @@ const MirrorRequirement = (props: RequirementProps): JSX.Element => { isLoading={isLoading} error={error && "API error, please contact Mirror to report"} > - {name ?? shortenHex(requirement.address, 3)} + {name ?? shortenHex(requirementAddress, 3)} {` Mirror edition`} diff --git a/src/requirements/Nft/NftRequirement.tsx b/src/requirements/Nft/NftRequirement.tsx index a11b11e369..afa80692c4 100644 --- a/src/requirements/Nft/NftRequirement.tsx +++ b/src/requirements/Nft/NftRequirement.tsx @@ -19,6 +19,7 @@ import useSWRImmutable from "swr/immutable" import { Trait } from "types" import { GUILD_PIN_CONTRACTS } from "utils/guildCheckout/constants" import shortenHex from "utils/shortenHex" +import { Chain } from "wagmiConfig/chains" import useNftMetadata, { NOUNS_BACKGROUNDS, useNftMetadataWithTraits, @@ -42,9 +43,13 @@ const getNounsRequirementType = (trait: Trait) => const NftRequirement = (props: RequirementProps) => { const requirement = useRequirementContext() + // TODO: we could remove the cast once we'll have schemas for "ERC..." requirements + const requirementChain = requirement.chain as Chain + const requirementAddress = requirement.address as `0x${string}` + // This is a really basic solution, and it'll only handle the "Joined Guild" NFTs. We should probably think about a better solution in the future. const isGuildPin = - GUILD_PIN_CONTRACTS[requirement.chain] === requirement.address.toLowerCase() + GUILD_PIN_CONTRACTS[requirementChain] === requirementAddress.toLowerCase() const guildIdAttribute = isGuildPin && @@ -59,10 +64,10 @@ const NftRequirement = (props: RequirementProps) => { const { name: guildPinGuildName } = useGuild(guildIdAttribute ?? "") const { metadata: metadataWithTraits, isLoading: isMetadataWithTraitsLoading } = - useNftMetadata(requirement.chain, requirement.address, requirement.data?.id) + useNftMetadata(requirementChain, requirementAddress, requirement.data?.id) const { metadata, isLoading } = useNftMetadataWithTraits( - requirement.chain, - requirement.address + requirementChain, + requirementAddress ) const nftDataLoading = isLoading || isMetadataWithTraitsLoading @@ -83,7 +88,7 @@ const NftRequirement = (props: RequirementProps) => { : metadataWithTraits?.image || metadata?.image const shouldRenderImage = - ["ETHEREUM", "POLYGON"].includes(requirement.chain) && + ["ETHEREUM", "POLYGON"].includes(requirementChain) && (nftName || (requirement.name && requirement.name !== "-")) && (nftDataLoading || nftImage) @@ -129,7 +134,7 @@ const NftRequirement = (props: RequirementProps) => { {nftName || (!requirement.name || requirement.name === "-" ? metadata?.slug ?? ( - {shortenHex(requirement.address, 3)} + {shortenHex(requirementAddress, 3)} ) : requirement.name !== "-" && requirement.name)} diff --git a/src/requirements/Nft/providedValue/NftAmountProvidedValue.tsx b/src/requirements/Nft/providedValue/NftAmountProvidedValue.tsx index 75765f02fd..6a5c2f771f 100644 --- a/src/requirements/Nft/providedValue/NftAmountProvidedValue.tsx +++ b/src/requirements/Nft/providedValue/NftAmountProvidedValue.tsx @@ -4,6 +4,7 @@ import DataBlock from "components/common/DataBlock" import { ProvidedValueDisplayProps } from "requirements" import { GUILD_PIN_CONTRACTS } from "utils/guildCheckout/constants" import useNftMetadata, { useNftMetadataWithTraits } from "../hooks/useNftMetadata" +import { Chain } from "wagmiConfig/chains" export function hasOnlyTypeProperty(obj) { const keys = Object.keys(obj) @@ -11,8 +12,12 @@ export function hasOnlyTypeProperty(obj) { } const NftAmountProvidedValue = ({ requirement }: ProvidedValueDisplayProps) => { + // TODO: we could remove the cast once we'll have schemas for "ERC..." requirements + const requirementChain = requirement.chain as Chain + const requirementAddress = requirement.address as `0x${string}` + const isGuildPin = - GUILD_PIN_CONTRACTS[requirement.chain] === requirement?.address?.toLowerCase() + GUILD_PIN_CONTRACTS[requirementChain] === requirement?.address?.toLowerCase() const guildIdAttribute = isGuildPin && requirement.data?.attributes?.find((attr) => attr.trait_type === "guildId") @@ -21,14 +26,11 @@ const NftAmountProvidedValue = ({ requirement }: ProvidedValueDisplayProps) => { const { name: guildPinGuildName } = useGuild(guildIdAttribute ?? "") const { metadata: metadataWithTraits } = useNftMetadata( - requirement.chain, - requirement.address, + requirementChain, + requirementAddress, requirement.data?.id ) - const { metadata } = useNftMetadataWithTraits( - requirement.chain, - requirement.address - ) + const { metadata } = useNftMetadataWithTraits(requirementChain, requirementAddress) const nftName = isGuildPin ? ( <> diff --git a/src/requirements/Payment/PaymentRequirement.tsx b/src/requirements/Payment/PaymentRequirement.tsx index 035870beb4..2a75820173 100644 --- a/src/requirements/Payment/PaymentRequirement.tsx +++ b/src/requirements/Payment/PaymentRequirement.tsx @@ -27,14 +27,14 @@ const PaymentRequirement = (props: RequirementProps): JSX.Element => { chain, address, data: requirementData, - } = useRequirementContext() + } = useRequirementContext<"PAYMENT">() const { token, fee, multiplePayments, isLoading: isVaultLoading, error: vaultError, - } = useVault(address, requirementData?.id, chain) + } = useVault(address as `0x${string}`, requirementData?.id, chain) const isNativeCurrency = token === NULL_ADDRESS diff --git a/src/requirements/Payment/components/WithdrawButton/WithdrawButton.tsx b/src/requirements/Payment/components/WithdrawButton/WithdrawButton.tsx index e2abdc918f..d6a611224e 100644 --- a/src/requirements/Payment/components/WithdrawButton/WithdrawButton.tsx +++ b/src/requirements/Payment/components/WithdrawButton/WithdrawButton.tsx @@ -12,7 +12,12 @@ import { CHAIN_CONFIG, Chains } from "wagmiConfig/chains" import useWithdraw from "./hooks/useWithdraw" const WithdrawButton = (): JSX.Element => { - const { address: vaultAddress, chain, data } = useRequirementContext() + const { + address: vaultAddressAsString, + chain, + data, + } = useRequirementContext<"PAYMENT">() + const vaultAddress = vaultAddressAsString as `0x${string}` const { owner, token, balance } = useVault(vaultAddress, data?.id, chain) const { data: { symbol, decimals }, @@ -28,7 +33,7 @@ const WithdrawButton = (): JSX.Element => { const { onSubmitTransaction, isPreparing, isLoading, error } = useWithdraw( vaultAddress, - data?.id, + +data.id, chain ) diff --git a/src/requirements/Token/TokenRequirement.tsx b/src/requirements/Token/TokenRequirement.tsx index 70fa4a3d7c..b93b448101 100644 --- a/src/requirements/Token/TokenRequirement.tsx +++ b/src/requirements/Token/TokenRequirement.tsx @@ -9,20 +9,24 @@ import Requirement, { import RequirementChainIndicator from "components/[guild]/Requirements/components/RequirementChainIndicator" import { useRequirementContext } from "components/[guild]/Requirements/components/RequirementContext" import useTokenData from "hooks/useTokenData" -import { CHAIN_CONFIG } from "wagmiConfig/chains" +import { Chain, CHAIN_CONFIG } from "wagmiConfig/chains" type Props = RequirementProps const TokenRequirement = ({ ...rest }: Props) => { const requirement = useRequirementContext() - const { data, isValidating } = useTokenData(requirement.chain, requirement.address) + // TODO: we could remove the cast once we'll have schemas for "ERC..." requirements + const requirementChain = requirement.chain as Chain + const requirementAddress = requirement.address as `0x${string}` + + const { data, isValidating } = useTokenData(requirementChain, requirementAddress) return ( ERC20 @@ -53,7 +57,7 @@ const TokenRequirement = ({ ...rest }: Props) => { : "any amount of" } ${ requirement.type === "COIN" - ? CHAIN_CONFIG[requirement.chain].nativeCurrency.symbol + ? CHAIN_CONFIG[requirementChain].nativeCurrency.symbol : data?.symbol ?? requirement.symbol }`} diff --git a/src/requirements/Token/providedValue/TokenProvidedValue.tsx b/src/requirements/Token/providedValue/TokenProvidedValue.tsx index 8e339986d0..3443843b02 100644 --- a/src/requirements/Token/providedValue/TokenProvidedValue.tsx +++ b/src/requirements/Token/providedValue/TokenProvidedValue.tsx @@ -3,11 +3,16 @@ import RequirementChainIndicator from "components/[guild]/Requirements/component import useTokenData from "hooks/useTokenData" import { ProvidedValueDisplayProps } from "requirements" import { NULL_ADDRESS } from "utils/guildCheckout/constants" +import { Chain } from "wagmiConfig/chains" const TokenProvidedValue = ({ requirement }: ProvidedValueDisplayProps) => { + // TODO: we could remove the cast once we'll have schemas for "ERC..." requirements + const requirementChain = requirement.chain as Chain + const requirementAddress = requirement.address as `0x${string}` + const { data: { symbol }, - } = useTokenData(requirement?.chain, requirement?.address ?? NULL_ADDRESS) + } = useTokenData(requirementChain, requirementAddress ?? NULL_ADDRESS) const tagBg = useColorModeValue("blackAlpha.100", "blackAlpha.300") diff --git a/src/requirements/Uniswap/UniswapRequirement.tsx b/src/requirements/Uniswap/UniswapRequirement.tsx index 64c05b6b84..3087c4a47a 100644 --- a/src/requirements/Uniswap/UniswapRequirement.tsx +++ b/src/requirements/Uniswap/UniswapRequirement.tsx @@ -1,5 +1,5 @@ import { HStack, Skeleton } from "@chakra-ui/react" -import { Schemas, consts } from "@guildxyz/types" +import { consts } from "@guildxyz/types" import Requirement, { RequirementProps, } from "components/[guild]/Requirements/components/Requirement" @@ -40,10 +40,7 @@ const UniswapRequirement = ({ ...rest }: RequirementProps): JSX.Element => { }, roleId, id, - } = useRequirementContext() as Extract< - Schemas["Requirement"], - { type: "UNISWAP_V3_POSITIONS" } - > + } = useRequirementContext<"UNISWAP_V3_POSITIONS">() const { symbol0, symbol1 } = useSymbolsOfPair( Chains[chain], diff --git a/src/requirements/WalletActivity/WalletActivityRequirement.tsx b/src/requirements/WalletActivity/WalletActivityRequirement.tsx index 2b4b1824ed..6e249dc6d6 100644 --- a/src/requirements/WalletActivity/WalletActivityRequirement.tsx +++ b/src/requirements/WalletActivity/WalletActivityRequirement.tsx @@ -27,7 +27,16 @@ const requirementIcons: Record< } const WalletActivityRequirement = (props: RequirementProps): JSX.Element => { - const requirement = useRequirementContext() + const requirement = useRequirementContext< + | "COVALENT_FIRST_TX" + | "COVALENT_FIRST_TX_RELATIVE" + | "COVALENT_CONTRACT_DEPLOY" + | "COVALENT_CONTRACT_DEPLOY_RELATIVE" + | "COVALENT_TX_COUNT" + | "COVALENT_TX_COUNT_RELATIVE" + | "COVALENT_TX_VALUE" + | "COVALENT_TX_VALUE_RELATIVE" + >() const maxAmount = requirement.data?.timestamps?.maxAmount const minAmount = requirement.data?.timestamps?.minAmount diff --git a/src/requirements/index.ts b/src/requirements/index.ts index e065883810..2a46012186 100644 --- a/src/requirements/index.ts +++ b/src/requirements/index.ts @@ -1,3 +1,4 @@ +import { Schemas } from "@guildxyz/types" import { RequirementProps } from "components/[guild]/Requirements/components/Requirement" import { Icon } from "phosphor-react" import { ComponentType } from "react" @@ -16,8 +17,7 @@ export type ProvidedValueDisplayProps = { requirement: Partial } -const requirementTypes = REQUIREMENTS_DATA.flatMap((obj) => obj.types) -export type RequirementType = (typeof requirementTypes)[number] | "HIDDEN" +export type RequirementType = Schemas["Requirement"]["type"] export type RequirementFormProps = { baseFieldPath: string diff --git a/src/types.ts b/src/types.ts index dbe663491c..93af640e75 100644 --- a/src/types.ts +++ b/src/types.ts @@ -1,8 +1,9 @@ -import { FarcasterProfile, Schemas } from "@guildxyz/types" +import { FarcasterProfile, schemas, Schemas, Visibility } from "@guildxyz/types" import { FeatureFlag } from "components/[guild]/EditGuild/components/FeatureFlags" import { ContractCallFunction } from "components/[guild]/RolePlatforms/components/AddRoleRewardModal/components/AddContractCallPanel/components/CreateNftForm/hooks/useCreateNft" import { RequirementType } from "requirements" import type { Chain, Chains } from "wagmiConfig/chains" +import { z } from "zod" export const FUEL_ADDRESS_REGEX = /^0x[a-f0-9]{64}$/i @@ -491,26 +492,10 @@ type Trait = { } } -type Requirement = { - id: number - type: RequirementType - address?: `0x${string}` - chain?: Chain - data?: Record - roleId: number - name: string - symbol: string - decimals?: number - isNegated?: boolean - visibility?: Visibility - visibilityRoleId?: number | null - - // Props used inside the forms on the UI - formFieldId?: number - balancyDecimals?: number - createdAt?: string - updatedAt?: string -} +type Requirement = z.output +type RequirementCreateResponseOutput = z.output< + typeof schemas.RequirementCreateResponseSchema +> type RolePlatformStatus = "ALL_CLAIMED" | "NOT_STARTED" | "ENDED" | "ACTIVE" @@ -532,12 +517,6 @@ type RolePlatform = { dynamicAmount?: Schemas["DynamicAmount"] } -enum Visibility { - PUBLIC = "PUBLIC", - PRIVATE = "PRIVATE", - HIDDEN = "HIDDEN", -} - type SimpleRole = { id: number name: string @@ -636,9 +615,13 @@ type Guild = { parentRoles: number[] } +type RequirementCreationPayloadWithTempID = Schemas["RequirementCreationPayload"] & { + id?: number +} + type RoleFormType = Partial< Omit & { - requirements: Array> + requirements: Array> rolePlatforms: Array< Partial> & { guildPlatform?: GuildPlatformWithOptionalId @@ -791,7 +774,7 @@ type DetailedPinLeaderboardUserData = { pins: LeaderboardPinData[] } -export { ValidationMethod, Visibility, supportedEventSources, supportedSocialLinks } +export { supportedEventSources, supportedSocialLinks, ValidationMethod } export type { BaseUser, CoingeckoToken, @@ -819,6 +802,8 @@ export type { Poap, RequestMintLinksForm, Requirement, + RequirementCreateResponseOutput, + RequirementCreationPayloadWithTempID, RequirementType, Rest, Role, diff --git a/src/utils/formatRelativeTimeFromNow.ts b/src/utils/formatRelativeTimeFromNow.ts index a6a0860aea..2d2deb91c7 100644 --- a/src/utils/formatRelativeTimeFromNow.ts +++ b/src/utils/formatRelativeTimeFromNow.ts @@ -3,7 +3,7 @@ import pluralize from "./pluralize" export const DAY_IN_MS = 86400000 export const MINUTE_IN_MS = 60000 -const formatRelativeTimeFromNow = (since: number) => { +const formatRelativeTimeFromNow = (since?: number) => { if (!since) return undefined const sinceDays = since / DAY_IN_MS diff --git a/src/utils/mapRequirement.ts b/src/utils/mapRequirement.ts index be0b263b8a..2c5f55fc79 100644 --- a/src/utils/mapRequirement.ts +++ b/src/utils/mapRequirement.ts @@ -1,8 +1,10 @@ -import { Requirement } from "types" +import { Requirement, RequirementCreateResponseOutput } from "types" -const mapRequirement = (requirement?: Requirement) => { +const mapRequirement = ( + requirement?: Requirement | RequirementCreateResponseOutput +) => { // Using structuredClone so we don't modify the original requirement unintentionally - const newRequirement: Requirement = structuredClone(requirement) + const newRequirement = structuredClone(requirement) if (requirement.type === "COIN") newRequirement.address = "0x0000000000000000000000000000000000000000" diff --git a/src/utils/preprocessRequirement.ts b/src/utils/preprocessRequirement.ts index 2bc2fe9be8..58233fd31b 100644 --- a/src/utils/preprocessRequirement.ts +++ b/src/utils/preprocessRequirement.ts @@ -1,6 +1,12 @@ +import { Schemas } from "@guildxyz/types" import { Requirement } from "types" -const preprocessRequirement = (requirement: Partial): Requirement => { +const preprocessRequirement = ( + requirement?: + | Partial + | Partial + | Partial +): Requirement => { const processedRequirement: Requirement = structuredClone( requirement ) as Requirement From 6237385c0c0b2fa73094c28705ae0e0885659a78 Mon Sep 17 00:00:00 2001 From: BrickheadJohnny Date: Wed, 26 Jun 2024 15:12:05 +0200 Subject: [PATCH 26/41] fix(AddRequirement): watch requirement type --- .../components/AddRequirement.tsx | 21 ++++++++++++------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/src/components/create-guild/Requirements/components/AddRequirement.tsx b/src/components/create-guild/Requirements/components/AddRequirement.tsx index bc6edaeaae..8445375f84 100644 --- a/src/components/create-guild/Requirements/components/AddRequirement.tsx +++ b/src/components/create-guild/Requirements/components/AddRequirement.tsx @@ -208,6 +208,11 @@ const AddRequirementForm = forwardRef( const methods = useForm({ mode: "all" }) const roleId: number = useWatch({ name: "id" }) + // We need to pass this value later in the code to override `selectedType` with it (e.g. if selectedType is "LENS" we should overwrite it with the actual type, for example with "LENS_TOTAL_FOLLOWERS") + const formType = useWatch({ + control: methods.control, + name: "type", + }) const [isPresent, safeToRemove] = usePresence() useEffect(() => { @@ -231,9 +236,11 @@ const AddRequirementForm = forwardRef( const onSubmit = methods.handleSubmit((data) => { if (!selectedType) return + const { type, ...requirementData } = data + const requirement = schemas.RequirementCreationPayloadSchema.parse({ - ...data, - type: selectedType, + type: type ?? selectedType, + ...requirementData, }) if (!roleId) { @@ -265,16 +272,14 @@ const AddRequirementForm = forwardRef( providerTypesOnly={providerTypesOnly} /> - {!!REQUIREMENT_PROVIDED_VALUES[selectedType] && ( + {!!REQUIREMENT_PROVIDED_VALUES[formType ?? selectedType] && ( <> {" "} - } + requirement={{ + type: formType ?? selectedType, + }} /> )} From 157648e130b11267dc2bedc3e0776aae1839e089 Mon Sep 17 00:00:00 2001 From: BrickheadJohnny Date: Wed, 26 Jun 2024 20:12:12 +0200 Subject: [PATCH 27/41] chore: remove some unused types --- src/types.ts | 37 ------------------------------------- 1 file changed, 37 deletions(-) diff --git a/src/types.ts b/src/types.ts index 93af640e75..fab414021a 100644 --- a/src/types.ts +++ b/src/types.ts @@ -648,17 +648,6 @@ type SelectOption = { img?: string | JSX.Element } & Rest -// Requested with Discord OAuth token -type DiscordServerData = { - id: string - name: string - icon: string - owner: boolean - permissions: number - features: string[] - permissions_new: string -} - export enum PlatformType { "UNSET" = -1, "DISCORD" = 1, @@ -680,30 +669,6 @@ export enum PlatformType { "ERC20" = 17, } -type WalletConnectConnectionData = { - connected: boolean - accounts: string[] - chainId: number - bridge: string - key: string - clientId: string - clientMeta: { - description: string - url: string - icons: string[] - name: string - } - peerId: string - peerMeta: { - description: string - url: string - icons: string[] - name: string - } - handshakeId: number - handshakeTopic: string -} - enum ValidationMethod { STANDARD = 1, KEYPAIR = 2, @@ -780,7 +745,6 @@ export type { CoingeckoToken, DetailedPinLeaderboardUserData as DetailedUserLeaderboardData, DiscordError, - DiscordServerData, EventSources, EventSourcesKey, GitPoap, @@ -819,6 +783,5 @@ export type { Trait, User, UserAddress, - WalletConnectConnectionData, WalletError, } From d146e0a15c14cda7a95e5dd8a27a1d52b91f7078 Mon Sep 17 00:00:00 2001 From: BrickheadJohnny Date: Wed, 26 Jun 2024 20:16:10 +0200 Subject: [PATCH 28/41] chore: use the `Logic` type from `@guildxyz/types` --- src/components/[guild]/LogicDivider.tsx | 3 ++- .../[guild]/Requirements/RoleRequirements.tsx | 3 ++- .../components/ExpandRequirementsButton.tsx | 2 +- .../components/EditRole/hooks/useEditRoleForm.ts | 3 +-- src/types.ts | 11 +++++++---- 5 files changed, 13 insertions(+), 9 deletions(-) diff --git a/src/components/[guild]/LogicDivider.tsx b/src/components/[guild]/LogicDivider.tsx index 2ec2bb23f4..b6fe0a393f 100644 --- a/src/components/[guild]/LogicDivider.tsx +++ b/src/components/[guild]/LogicDivider.tsx @@ -1,5 +1,6 @@ import { Divider, Flex, HStack, useColorMode } from "@chakra-ui/react" -import { Logic, Rest } from "types" +import { Logic } from "@guildxyz/types" +import { Rest } from "types" type Props = { logic: Logic } & Rest diff --git a/src/components/[guild]/Requirements/RoleRequirements.tsx b/src/components/[guild]/Requirements/RoleRequirements.tsx index feb2175cd5..84f76a1130 100644 --- a/src/components/[guild]/Requirements/RoleRequirements.tsx +++ b/src/components/[guild]/Requirements/RoleRequirements.tsx @@ -5,6 +5,7 @@ import { useColorModeValue, VStack, } from "@chakra-ui/react" +import { Logic } from "@guildxyz/types" import React, { Fragment, memo, @@ -14,7 +15,7 @@ import React, { useRef, } from "react" import { VariableSizeList } from "react-window" -import { Logic, Requirement, Role } from "types" +import { Requirement, Role } from "types" import useRequirements from "../hooks/useRequirements" import LogicDivider from "../LogicDivider" import { RoleCardCollapseProps } from "../RoleCard" diff --git a/src/components/[guild]/Requirements/components/ExpandRequirementsButton.tsx b/src/components/[guild]/Requirements/components/ExpandRequirementsButton.tsx index 91570eae42..b9b47dab64 100644 --- a/src/components/[guild]/Requirements/components/ExpandRequirementsButton.tsx +++ b/src/components/[guild]/Requirements/components/ExpandRequirementsButton.tsx @@ -1,8 +1,8 @@ import { Divider, Flex, Icon, useColorMode } from "@chakra-ui/react" +import { Logic } from "@guildxyz/types" import { formattedLogic } from "components/[guild]/LogicDivider" import Button from "components/common/Button" import { ArrowDown, ArrowUp } from "phosphor-react" -import { Logic } from "types" type Props = { logic: Logic diff --git a/src/components/[guild]/RoleCard/components/EditRole/hooks/useEditRoleForm.ts b/src/components/[guild]/RoleCard/components/EditRole/hooks/useEditRoleForm.ts index 1d627f7d08..7f1072ae16 100644 --- a/src/components/[guild]/RoleCard/components/EditRole/hooks/useEditRoleForm.ts +++ b/src/components/[guild]/RoleCard/components/EditRole/hooks/useEditRoleForm.ts @@ -1,8 +1,7 @@ -import { Visibility } from "@guildxyz/types" +import { Logic, Visibility } from "@guildxyz/types" import useGuild from "components/[guild]/hooks/useGuild" import { useEffect } from "react" import { useForm } from "react-hook-form" -import { Logic } from "types" export type RoleEditFormData = { id: number diff --git a/src/types.ts b/src/types.ts index fab414021a..e20a58760b 100644 --- a/src/types.ts +++ b/src/types.ts @@ -1,4 +1,10 @@ -import { FarcasterProfile, schemas, Schemas, Visibility } from "@guildxyz/types" +import { + FarcasterProfile, + Logic, + schemas, + Schemas, + Visibility, +} from "@guildxyz/types" import { FeatureFlag } from "components/[guild]/EditGuild/components/FeatureFlags" import { ContractCallFunction } from "components/[guild]/RolePlatforms/components/AddRoleRewardModal/components/AddContractCallPanel/components/CreateNftForm/hooks/useCreateNft" import { RequirementType } from "requirements" @@ -22,8 +28,6 @@ type Rest = { [x: string]: any } -type Logic = "AND" | "OR" | "ANY_OF" - type Theme = { color?: string backgroundImage?: string @@ -757,7 +761,6 @@ export type { GuildPlatformWithOptionalId, GuildTags, LeaderboardPinData, - Logic, NFT, OneOf, PlatformAccountDetails, From ff322c6c1545ab9b4b49001ac0b6a55afed9257c Mon Sep 17 00:00:00 2001 From: Dominik Stumpf <122315398+dominik-stumpf@users.noreply.github.com> Date: Thu, 27 Jun 2024 16:22:11 +0200 Subject: [PATCH 29/41] feat: add fallback image to reward icon (#1311) * feat: add fallback image to reward icon * chore: use img from reward config instead * chore: clean up RewardIcon * chore: do icon fallback as last resort * chore: add fallback if no src is present --- .../[guild]/RoleCard/components/Reward.tsx | 61 +++++++++++-------- 1 file changed, 36 insertions(+), 25 deletions(-) diff --git a/src/components/[guild]/RoleCard/components/Reward.tsx b/src/components/[guild]/RoleCard/components/Reward.tsx index a276299c65..a59dc70791 100644 --- a/src/components/[guild]/RoleCard/components/Reward.tsx +++ b/src/components/[guild]/RoleCard/components/Reward.tsx @@ -24,7 +24,7 @@ import { Transition, motion } from "framer-motion" import { ArrowSquareOut, LockSimple } from "phosphor-react" import GoogleCardWarning from "platforms/Google/GoogleCardWarning" import rewards from "platforms/rewards" -import { PropsWithChildren, ReactNode, useMemo } from "react" +import { PropsWithChildren, ReactNode, useMemo, useState } from "react" import { GuildPlatform, PlatformType, Role, RolePlatform } from "types" import capitalize from "utils/capitalize" @@ -105,11 +105,13 @@ const Reward = ({ return ( + platform.guildPlatform && ( + + ) } label={ <> @@ -184,7 +186,7 @@ const RewardDisplay = ({ export type RewardIconProps = { rolePlatformId: number - guildPlatform?: GuildPlatform + guildPlatform: GuildPlatform withMotionImg?: boolean transition?: Transition } @@ -198,43 +200,45 @@ const RewardIcon = ({ withMotionImg = true, transition, }: RewardIconProps) => { - const circleBgColor = useColorModeValue("gray.700", "gray.600") - + const [doIconFallback, setDoIconFallback] = useState(false) const props = { src: - guildPlatform?.platformGuildData?.imageUrl ?? - rewards[PlatformType[guildPlatform?.platformId]]?.imageUrl, - alt: guildPlatform?.platformGuildName, + guildPlatform.platformGuildData?.imageUrl ?? + rewards[PlatformType[guildPlatform.platformId]].imageUrl, + alt: guildPlatform.platformGuildName, boxSize: 6, rounded: "full", - } - - const circleProps = { - bgColor: circleBgColor, - boxSize: 6, + onError: () => { + setDoIconFallback(true) + }, } const motionElementProps = { layoutId: `${rolePlatformId}_reward_img`, transition: { type: "spring", duration: 0.5, ...transition }, } + const circleBgColor = useColorModeValue("gray.700", "gray.600") + const circleProps = { + bgColor: circleBgColor, + boxSize: 6, + } - if (!props.src) { - if (withMotionImg) + if (doIconFallback || !props.src) { + if (withMotionImg) { return ( ) - + } return ( @@ -242,9 +246,16 @@ const RewardIcon = ({ ) } - if (withMotionImg) return - - return + return ( + + + {withMotionImg ? ( + + ) : ( + + )} + + ) } const RewardWrapper = ({ platform, ...props }: RewardProps) => { From d970cd63a4be8476f9c5c5220049533085f17e7a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?B=C3=A1lint=20Ferenczy?= <40574454+FBalint@users.noreply.github.com> Date: Thu, 27 Jun 2024 21:51:19 +0200 Subject: [PATCH 30/41] refactor: make token reward work with new changes (#1308) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * refactor: EditRole (#1275) * refactor(EditRole): decomposing * refactor(useEditRole): remove reward handling * refactor(EditRolePlatforms): handleAdd * fix: EditRoleHeader spacing * refactor(EditRoleHeader): handleVisibilitySave * handle availability change * handle visibility change * reward update indicator * refactor(EditRolePlatforms): move reward adding logic to hook * refactor(EditRole): handle remove * refactor: unifying crud hooks * refactor: local mutate visibilty * refactor: local mutate availability * fixing warnings * fix(EditRoleHeader): add back drawer close button on mobile * cleanup: remove now unnecessary logic from RolePlatforms * fix(add reward mutation): object to array * copy(add reward toast): "updated" to "added" * refactor: generic to ExistingRolePlatformCard, RemovePlatformButton to abstract hook * add comment about useAddReward & useAddRewardWithExistingGP * refactor: extract local role platform mutate to hook (useLocalMutateRolePlatform) * fix: add missing 'revalidate: false' * fix: set default reward visibility to role's visibility * prepare mutateGateables on useRemoveRewards * refactor: preparations for add role flow * refactor(AddRoleDrawer): decompose into hooks and components * cleanup useLocalMutateRolePlatform --------- Co-authored-by: valid * refactor: RequirementHandlerContext to handle dynamic rewards in state * draft: submit order test * refactor: structuring & error handling * fix: mutate after role creation * fix: warning * fix: readd auto scroll to role * refactor(AddReward): submit hook DRAFT * typings * refactor(AddRoleDrawer): handle dynamic rewards in state (#1284) * refactor: RequirementHandlerContext to handle dynamic rewards in state * refactor: wrap DynamicTag with ApiRequirementHandlerProvider * perf(DynamicTag): remove provider wrapper, use requirements conditionally --------- Co-authored-by: valid * refactor(useSubmitEverything): modularization, break into smaller hooks * fix: save as draft * fix: warning when deleting provider requirement * refactor: useSubmitEverything in AddRole flow * fix warnings * refactor(useSubmitEverything): mutates added * fix(useMutateAdditionsToRoles): mutate `guildPlatforms` too & add types * refactor: rename creation hook to useCreateRRR * refactor: renamings & fixing edit role mutations * fix(useMutateCreatedRole): set createdGuildPlatforms * fix(EditRolePlatforms): set roleId in rolePlatform so that deletion is possible * refactor: make token reward work with new changes * refactor: add reward flow (#1289) * refactor: RequirementHandlerContext to handle dynamic rewards in state * draft: submit order test * refactor: structuring & error handling * fix: mutate after role creation * fix: warning * fix: readd auto scroll to role * refactor(AddReward): submit hook DRAFT * typings * refactor(useSubmitEverything): modularization, break into smaller hooks * fix: save as draft * fix: warning when deleting provider requirement * refactor: useSubmitEverything in AddRole flow * fix warnings * refactor(useSubmitEverything): mutates added * fix(useMutateAdditionsToRoles): mutate `guildPlatforms` too & add types * refactor: rename creation hook to useCreateRRR * refactor: renamings & fixing edit role mutations * fix(useMutateCreatedRole): set createdGuildPlatforms * fix(EditRolePlatforms): set roleId in rolePlatform so that deletion is possible * fix: subtler add animation * add posthog error events * changeDataToDraft: save only role as hidden if provided & move out of component * fix(useMutateAdditionsToRoles): don't mutate role counts in explorer * cleanup * refactor: edit rewards (#1300) * fix: quick add reward setup steps * refactor(NewRolePlatformCard): edit button added * refactor(ExistingRolePlatformCard): add placeholder edit functionality * review fixes * cleanup * refactor(EditRolePlatformModal): add type --------- Co-authored-by: valid * fix(useCreateRequirement): posthog hook placement --------- Co-authored-by: BrickheadJohnny Co-authored-by: valid * fix(AddRewardButton): cast `AddRewardPanel` * cleanup(SnapshotSelector): remove unnecessary any cast * chore: add better types * fix(AddRewardButton): remove incorrect early return * fix(token reward config): add back `RoleCardComponent` --------- Co-authored-by: valid Co-authored-by: BrickheadJohnny --- .../AddRewardButton/AddRewardButton.tsx | 11 +++-- .../AddRewardButton/SelectRolePanel.tsx | 10 +---- .../[guild]/RequirementHandlerContext.tsx | 14 ++++-- .../AddRoleRewardModal/AddRoleRewardModal.tsx | 6 +-- .../AddTokenPanel/AddTokenPanel.tsx | 29 +++++++++---- .../components/CustomSnapshotForm.tsx | 20 ++++----- .../components/SnapshotSelector.tsx | 23 +++++----- .../components/TokenAmountStep.tsx | 43 +------------------ .../hooks/useCreateRequirement.ts | 16 ++++--- .../hooks/useHandleRequirementState.ts | 11 +++-- src/pages/privacy-policy.tsx | 5 ++- src/platforms/Token/index.ts | 11 +++-- .../AddRewardPanelLoadingSpinner.tsx | 4 +- .../SelectRoleOrSetRequirements.tsx | 9 +--- src/platforms/constants.ts | 2 - src/platforms/rewards.ts | 2 +- src/platforms/types.ts | 15 ++++--- 17 files changed, 101 insertions(+), 130 deletions(-) diff --git a/src/components/[guild]/AddRewardButton/AddRewardButton.tsx b/src/components/[guild]/AddRewardButton/AddRewardButton.tsx index 95db25146c..789c533acd 100644 --- a/src/components/[guild]/AddRewardButton/AddRewardButton.tsx +++ b/src/components/[guild]/AddRewardButton/AddRewardButton.tsx @@ -7,6 +7,7 @@ import useShowErrorToast from "hooks/useShowErrorToast" import { atom, useAtomValue } from "jotai" import { Plus } from "phosphor-react" import rewards, { modalSizeForPlatform } from "platforms/rewards" +import { RewardData } from "platforms/types" import { FormProvider, useForm, useWatch } from "react-hook-form" import { RoleFormType } from "types" import { AddRewardProvider, useAddRewardContext } from "../AddRewardContext" @@ -36,7 +37,7 @@ export const defaultValues: AddRewardForm = { export const canCloseAddRewardModalAtom = atom(true) -const AddRewardButton = (): JSX.Element => { +const AddRewardButton = () => { const [isAddRewardPanelDirty, setIsAddRewardPanelDirty] = useAddRewardDiscardAlert() const { @@ -65,7 +66,9 @@ const AddRewardButton = (): JSX.Element => { const { isStuck } = useIsTabsStuck() const { textColor, buttonColorScheme } = useThemeContext() - const { AddRewardPanel } = rewards[selection] ?? {} + // TODO: once we separate rewards from platforms, we should be able to use this without ??, and it should properly infer types too. + const rewardConfig = rewards[selection] ?? {} + const AddRewardPanel = rewardConfig.AddRewardPanel as RewardData["AddRewardPanel"] const showErrorToast = useShowErrorToast() const isRewardSetupStep = selection && step !== "HOME" && step !== "SELECT_ROLE" @@ -123,7 +126,7 @@ const AddRewardButton = (): JSX.Element => { {step === "HOME" && } - {isRewardSetupStep && ( + {isRewardSetupStep && AddRewardPanel && ( { const { @@ -136,7 +139,7 @@ const AddRewardButton = (): JSX.Element => { visibility, }) if (roleName) methods.setValue("roleName", roleName) - if (requirements?.length > 0) { + if (Array.isArray(requirements) && requirements.length > 0) { methods.setValue("requirements", requirements) } setStep("SELECT_ROLE") diff --git a/src/components/[guild]/AddRewardButton/SelectRolePanel.tsx b/src/components/[guild]/AddRewardButton/SelectRolePanel.tsx index 22f0681810..36367f5621 100644 --- a/src/components/[guild]/AddRewardButton/SelectRolePanel.tsx +++ b/src/components/[guild]/AddRewardButton/SelectRolePanel.tsx @@ -61,11 +61,8 @@ const SelectRolePanel = ({ const [saveAsDraft, setSaveAsDraft] = useState(false) - const isRoleSelectorDisabled = selection === "ERC20" const isAddRewardButtonDisabled = - activeTab === RoleTypeToAddTo.NEW_ROLE || isRoleSelectorDisabled - ? !requirements?.length - : !roleIds?.length + activeTab === RoleTypeToAddTo.NEW_ROLE ? !requirements?.length : !roleIds?.length const { RewardPreview } = rewards[selection] ?? {} @@ -127,10 +124,7 @@ const SelectRolePanel = ({ display="flex" flexDir="column" > - + diff --git a/src/components/[guild]/RequirementHandlerContext.tsx b/src/components/[guild]/RequirementHandlerContext.tsx index 4c05da2bb5..90afd84f4f 100644 --- a/src/components/[guild]/RequirementHandlerContext.tsx +++ b/src/components/[guild]/RequirementHandlerContext.tsx @@ -1,11 +1,14 @@ +import { Schemas } from "@guildxyz/types" import useCreateRequirement from "components/create-guild/Requirements/hooks/useCreateRequirement" import useHandleRequirementState from "components/create-guild/Requirements/hooks/useHandleRequirementState" -import { ReactNode, createContext, useContext } from "react" -import { Requirement } from "types" +import { createContext, ReactNode, useContext } from "react" +import { Requirement, RequirementCreateResponseOutput } from "types" import useRequirements from "./hooks/useRequirements" const RequirementHandlerContext = createContext<{ - onAddRequirement: (requirement: Requirement) => void + onAddRequirement: ( + requirement: Schemas["RequirementCreationPayload"] + ) => RequirementCreateResponseOutput | Promise requirements: Requirement[] requirementsLoading?: boolean addRequirementLoading?: boolean @@ -42,11 +45,14 @@ const ApiRequirementHandlerProvider = ({ children: ReactNode }) => { const { - data: requirements, + data, mutate, isValidating, isLoading: reqsLoading, } = useRequirements(roleId) + + const requirements = data || [] + const { onSubmit, isLoading } = useCreateRequirement(roleId, { onSuccess: () => { mutate() diff --git a/src/components/[guild]/RolePlatforms/components/AddRoleRewardModal/AddRoleRewardModal.tsx b/src/components/[guild]/RolePlatforms/components/AddRoleRewardModal/AddRoleRewardModal.tsx index b0bddc9dcc..f395b5a937 100644 --- a/src/components/[guild]/RolePlatforms/components/AddRoleRewardModal/AddRoleRewardModal.tsx +++ b/src/components/[guild]/RolePlatforms/components/AddRoleRewardModal/AddRoleRewardModal.tsx @@ -69,11 +69,7 @@ const AddRoleRewardModal = ({ onAdd }: Props) => { {step === "HOME" && ( - + Add new reward diff --git a/src/components/[guild]/RolePlatforms/components/AddRoleRewardModal/components/AddTokenPanel/AddTokenPanel.tsx b/src/components/[guild]/RolePlatforms/components/AddRoleRewardModal/components/AddTokenPanel/AddTokenPanel.tsx index 2f6d839140..10853cbb62 100644 --- a/src/components/[guild]/RolePlatforms/components/AddRoleRewardModal/components/AddTokenPanel/AddTokenPanel.tsx +++ b/src/components/[guild]/RolePlatforms/components/AddRoleRewardModal/components/AddTokenPanel/AddTokenPanel.tsx @@ -14,9 +14,11 @@ import { import { Schemas } from "@guildxyz/types" import { useTokenRewards } from "components/[guild]/AccessHub/hooks/useTokenRewards" import { useAddRewardDiscardAlert } from "components/[guild]/AddRewardButton/hooks/useAddRewardDiscardAlert" +import { useAddRewardContext } from "components/[guild]/AddRewardContext" +import { useRequirementHandlerContext } from "components/[guild]/RequirementHandlerContext" import { AddRewardPanelProps } from "platforms/rewards" import { FormProvider, useForm } from "react-hook-form" -import { PlatformGuildData, PlatformType, Requirement } from "types" +import { PlatformGuildData, PlatformType } from "types" import { ERC20_CONTRACTS } from "utils/guildCheckout/constants" import { Chain } from "wagmiConfig/chains" import DefaultAddRewardPanelWrapper from "../../DefaultAddRewardPanelWrapper" @@ -46,7 +48,10 @@ export type AddTokenFormType = { snapshotId: number type: TokenRewardType staticValue?: number - requirements?: Requirement[] + snapshotRequirement?: Extract< + Schemas["RequirementCreationPayload"], + { type: "GUILD_SNAPSHOT" } + > } const AddTokenPanel = ({ onAdd }: AddRewardPanelProps) => { @@ -60,6 +65,9 @@ const AddTokenPanel = ({ onAdd }: AddRewardPanelProps) => { }) useAddRewardDiscardAlert(methods.formState.isDirty) + const { onAddRequirement } = useRequirementHandlerContext() + const { targetRoleId } = useAddRewardContext() + const steps = [ { title: "Set token", content: SetTokenStep }, { title: "Set claimable amount", content: TokenAmountStep }, @@ -73,7 +81,7 @@ const AddTokenPanel = ({ onAdd }: AddRewardPanelProps) => { const accessedTokens = useTokenRewards() - const constructSubmitData = (_data) => { + const constructSubmitData = async (_data: AddTokenFormType) => { const platform = accessedTokens.find( (guildPlatform) => guildPlatform.platformId === PlatformType.ERC20 && @@ -82,6 +90,10 @@ const AddTokenPanel = ({ onAdd }: AddRewardPanelProps) => { _data.tokenAddress?.toLowerCase() ) + const createdRequirement = _data.snapshotRequirement + ? await onAddRequirement(_data.snapshotRequirement) + : undefined + const dynamicAmount = { ...(_data.type === TokenRewardType.DYNAMIC_SNAPSHOT && { operation: { @@ -92,7 +104,8 @@ const AddTokenPanel = ({ onAdd }: AddRewardPanelProps) => { }, input: { type: "REQUIREMENT_AMOUNT", - // Will be filled after role creation + roleId: targetRoleId, + requirementId: createdRequirement?.id || null, }, }, }), @@ -134,15 +147,13 @@ const AddTokenPanel = ({ onAdd }: AddRewardPanelProps) => { return { ...guildPlatformPart, - ...(_data.type !== TokenRewardType.STATIC && { - requirements: _data.requirements, - }), ...rolePlatformPart, } } - const onSubmit = (_data) => { - onAdd(constructSubmitData(_data)) + const onSubmit = async (_data: AddTokenFormType) => { + const submitData = await constructSubmitData(_data) + onAdd(submitData) } return ( diff --git a/src/components/[guild]/RolePlatforms/components/AddRoleRewardModal/components/AddTokenPanel/components/CustomSnapshotForm.tsx b/src/components/[guild]/RolePlatforms/components/AddRoleRewardModal/components/AddTokenPanel/components/CustomSnapshotForm.tsx index 9b0ae689b7..bb275b82e9 100644 --- a/src/components/[guild]/RolePlatforms/components/AddRoleRewardModal/components/AddTokenPanel/components/CustomSnapshotForm.tsx +++ b/src/components/[guild]/RolePlatforms/components/AddRoleRewardModal/components/AddTokenPanel/components/CustomSnapshotForm.tsx @@ -32,7 +32,7 @@ const CustomSnapshotForm = () => { const showErrorToast = useShowErrorToast() const toast = useToast() - const requirements = useWatch({ name: "requirements" }) + const snapshotRequirement = useWatch({ name: "snapshotRequirement" }) const { addresses } = useUser() const { getRootProps, getInputProps } = useDropzone({ @@ -44,15 +44,13 @@ const CustomSnapshotForm = () => { reader.onload = function (e) { parseAndValidateCSV(e.target.result as string) .then((validatedData) => { - setValue("requirements", [ - { - type: "GUILD_SNAPSHOT", - data: { - snapshot: validatedData, - isHidden: false, - }, + setValue("snapshotRequirement", { + type: "GUILD_SNAPSHOT", + data: { + snapshot: validatedData, + isHidden: false, }, - ]) + }) }) .catch((error) => { showErrorToast(error) @@ -66,7 +64,7 @@ const CustomSnapshotForm = () => { return ( <> - {requirements?.length > 0 ? ( + {!!snapshotRequirement ? ( Snapshot uploaded!{" "} @@ -75,7 +73,7 @@ const CustomSnapshotForm = () => { variant="link" fontWeight="bold" fontSize="small" - onClick={() => setValue("requirements", [])} + onClick={() => setValue("snapshotRequirement", null)} > Remove diff --git a/src/components/[guild]/RolePlatforms/components/AddRoleRewardModal/components/AddTokenPanel/components/SnapshotSelector.tsx b/src/components/[guild]/RolePlatforms/components/AddRoleRewardModal/components/AddTokenPanel/components/SnapshotSelector.tsx index 3ba64a6469..961e7824ea 100644 --- a/src/components/[guild]/RolePlatforms/components/AddRoleRewardModal/components/AddTokenPanel/components/SnapshotSelector.tsx +++ b/src/components/[guild]/RolePlatforms/components/AddRoleRewardModal/components/AddTokenPanel/components/SnapshotSelector.tsx @@ -19,6 +19,7 @@ import { useFormContext, useWatch } from "react-hook-form" import Star from "static/icons/star.svg" import { PlatformGuildData, PlatformType, SelectOption } from "types" import ExistingPointsTypeSelect from "../../AddPointsPanel/components/ExistingPointsTypeSelect" +import { AddTokenFormType } from "../AddTokenPanel" const SnapshotSelector = () => { const { onClose, onOpen, isOpen } = useDisclosure() @@ -29,7 +30,7 @@ const SnapshotSelector = () => { (gp) => gp.platformId === PlatformType.POINTS ) - const { setValue: setRootValue } = useFormContext() + const { setValue } = useFormContext() const selectedPointsId = useWatch({ name: "data.guildPlatformId" }) @@ -42,7 +43,7 @@ const SnapshotSelector = () => { const handleCreateSuccess = (createdId: number) => { refetchSnapshots().then(() => { - setRootValue("snapshotId", createdId) + setValue("snapshotId", createdId) }) onClose() } @@ -60,17 +61,15 @@ const SnapshotSelector = () => { if (!snapshot) return const transformedData = transformSnapshotData(snapshot.data) - setRootValue("requirements", [ - { - type: "GUILD_SNAPSHOT", - data: { - snapshot: transformedData, - isHidden: false, - guildPlatformId: selectedPointsId, - }, + setValue("snapshotRequirement", { + type: "GUILD_SNAPSHOT", + data: { + snapshot: transformedData, + isHidden: false, + guildPlatformId: selectedPointsId, }, - ]) - }, [snapshot, selectedPointsId, setRootValue]) + }) + }, [snapshot, selectedPointsId, setValue]) const getPointPlatform = (guildPlatformId: number) => guildPlatforms.find((gp) => gp.id === guildPlatformId) diff --git a/src/components/[guild]/RolePlatforms/components/AddRoleRewardModal/components/AddTokenPanel/components/TokenAmountStep.tsx b/src/components/[guild]/RolePlatforms/components/AddRoleRewardModal/components/AddTokenPanel/components/TokenAmountStep.tsx index a4a98195c7..0906ecd620 100644 --- a/src/components/[guild]/RolePlatforms/components/AddRoleRewardModal/components/AddTokenPanel/components/TokenAmountStep.tsx +++ b/src/components/[guild]/RolePlatforms/components/AddRoleRewardModal/components/AddTokenPanel/components/TokenAmountStep.tsx @@ -22,11 +22,11 @@ const TokenAmountStep = ({ onContinue }: { onContinue: () => void }) => { const type = useWatch({ control, name: `type` }) - const requirements = useWatch({ control, name: `requirements` }) const multiplier = useWatch({ control, name: `multiplier` }) const addition = useWatch({ control, name: `addition` }) const chain = useWatch({ control, name: `chain` }) const address = useWatch({ control, name: `tokenAddress` }) + const snapshotRequirement = useWatch({ control, name: `snapshotRequirement` }) const { guildPlatforms } = useGuild() @@ -57,7 +57,7 @@ const TokenAmountStep = ({ onContinue }: { onContinue: () => void }) => { const getContinueDisabled = () => { switch (type) { case TokenRewardType.DYNAMIC_SNAPSHOT: - return requirements === undefined || multiplier === undefined + return snapshotRequirement === undefined || multiplier === undefined case TokenRewardType.STATIC: return addition === undefined case TokenRewardType.DYNAMIC_POINTS: @@ -69,21 +69,6 @@ const TokenAmountStep = ({ onContinue }: { onContinue: () => void }) => { } const isContinueDisabled = getContinueDisabled() - - const options = [ - { - label: "Dynamic amount", - value: TokenRewardType.DYNAMIC_SNAPSHOT, - disabled: - dynamicExists && - "Only one dynamic reward is permitted for each type of token.", - }, - { - label: "Static amount", - value: TokenRewardType.STATIC, - }, - ] - const [isCollapsed, ,] = useState(false) if (dynamicExists) @@ -103,22 +88,6 @@ const TokenAmountStep = ({ onContinue }: { onContinue: () => void }) => { return ( - {/* { - setValue("type", val) - }} - chakraStyles={{ - spacing: 1.5, - mt: 2, - size: "sm", - width: "full", - colorScheme: "indigo", - mb: -2, - }} - /> */} - void }) => { style={{ padding: "2px", margin: "-2px" }} > - {/* {[ - TokenRewardType.DYNAMIC_POINTS, - TokenRewardType.DYNAMIC_SNAPSHOT, - ].includes(type) ? ( - - ) : ( - - )} */} diff --git a/src/components/create-guild/Requirements/hooks/useCreateRequirement.ts b/src/components/create-guild/Requirements/hooks/useCreateRequirement.ts index fb585e126e..126f509852 100644 --- a/src/components/create-guild/Requirements/hooks/useCreateRequirement.ts +++ b/src/components/create-guild/Requirements/hooks/useCreateRequirement.ts @@ -9,7 +9,7 @@ import preprocessRequirement from "utils/preprocessRequirement" const useCreateRequirement = ( roleId: number, - config?: { onSuccess?: () => void; onError?: (err) => void } + config?: { onSuccess?: () => void; onError?: (err: any) => void } ) => { const { id: guildId } = useGuild() const { mutate: mutateRequirements } = useRequirements(roleId) @@ -23,7 +23,7 @@ const useCreateRequirement = ( `/v2/guilds/${guildId}/roles/${roleId}/requirements`, { method: "POST", - body: preprocessRequirement(body), + body: preprocessRequirement(body || {}), }, ]) @@ -42,11 +42,13 @@ const useCreateRequirement = ( mutateRequirements( (prevRequirements) => [ - ...prevRequirements.filter((req) => - Array.isArray(response.deletedRequirements) - ? !response.deletedRequirements.includes(req.id) - : true - ), + ...(prevRequirements + ? prevRequirements.filter((req) => + Array.isArray(response.deletedRequirements) + ? !response.deletedRequirements.includes(req.id) + : true + ) + : []), response, ], { revalidate: false } diff --git a/src/components/create-guild/Requirements/hooks/useHandleRequirementState.ts b/src/components/create-guild/Requirements/hooks/useHandleRequirementState.ts index aea2edd6d6..93cb300c4e 100644 --- a/src/components/create-guild/Requirements/hooks/useHandleRequirementState.ts +++ b/src/components/create-guild/Requirements/hooks/useHandleRequirementState.ts @@ -1,5 +1,6 @@ +import { Schemas } from "@guildxyz/types" import { useFieldArray } from "react-hook-form" -import { Requirement, RoleFormType } from "types" +import { RequirementCreateResponseOutput, RoleFormType } from "types" const useHandleRequirementState = (methods) => { const requirements = methods.watch("requirements") @@ -24,12 +25,16 @@ const useHandleRequirementState = (methods) => { } } - const append = (req: Requirement) => { - const reqToAdd = { ...req, id: Date.now() } + const append = ( + req: Schemas["RequirementCreationPayload"] + ): RequirementCreateResponseOutput => { + const reqToAdd = { id: Date.now(), ...req } if (freeEntry) { remove(0) } addRequirement(reqToAdd) + // TODO: find a better solution to avoid type casting + return reqToAdd as RequirementCreateResponseOutput } return { requirements, append, remove: removeReq, update, freeEntry } diff --git a/src/pages/privacy-policy.tsx b/src/pages/privacy-policy.tsx index f4f6932853..549007ae8e 100644 --- a/src/pages/privacy-policy.tsx +++ b/src/pages/privacy-policy.tsx @@ -245,8 +245,9 @@ const Page = (): JSX.Element => ( communications between you and others through our Services. - Marketing: Upon your consent, we may use your email address to send you marketing - communications and to provide you with updates about our services and products. + Marketing: Upon your consent, we may use your email address to + send you marketing communications and to provide you with updates about + our services and products. Security: We use information about you to secure your profile, diff --git a/src/platforms/Token/index.ts b/src/platforms/Token/index.ts index c6f0b2083f..349e95cb5b 100644 --- a/src/platforms/Token/index.ts +++ b/src/platforms/Token/index.ts @@ -1,10 +1,10 @@ -import { PlatformAsRewardRestrictions, RewardData } from "platforms/types" -import useTokenCardProps from "./hooks/useTokenCardProps" -import ClaimTokenButton from "./ClaimTokenButton" -import Token from "static/icons/token.svg" import dynamic from "next/dynamic" import { AddRewardPanelLoadingSpinner } from "platforms/components/AddRewardPanelLoadingSpinner" import LoadingRewardPreview from "platforms/components/LoadingRewardPreview" +import { PlatformAsRewardRestrictions, RewardData } from "platforms/types" +import Token from "static/icons/token.svg" +import ClaimTokenButton from "./ClaimTokenButton" +import useTokenCardProps from "./hooks/useTokenCardProps" export default { icon: Token, @@ -28,4 +28,7 @@ export default { ssr: false, loading: LoadingRewardPreview, }), + RoleCardComponent: dynamic(() => import("platforms/components/TokenReward"), { + ssr: false, + }), } as const satisfies RewardData diff --git a/src/platforms/components/AddRewardPanelLoadingSpinner.tsx b/src/platforms/components/AddRewardPanelLoadingSpinner.tsx index f96dd4fe50..25057b6fa8 100644 --- a/src/platforms/components/AddRewardPanelLoadingSpinner.tsx +++ b/src/platforms/components/AddRewardPanelLoadingSpinner.tsx @@ -1,5 +1,5 @@ -import { Center, Spinner } from "@chakra-ui/react"; -import React from "react"; +import { Center, Spinner } from "@chakra-ui/react" +import React from "react" export const AddRewardPanelLoadingSpinner = ({ height = "51vh" }: any) => (
diff --git a/src/platforms/components/SelectRoleOrSetRequirements.tsx b/src/platforms/components/SelectRoleOrSetRequirements.tsx index 1ab219483f..5e36e9d562 100644 --- a/src/platforms/components/SelectRoleOrSetRequirements.tsx +++ b/src/platforms/components/SelectRoleOrSetRequirements.tsx @@ -55,9 +55,6 @@ const SelectRoleOrSetRequirements = ({ isRoleSelectorDisabled }: Props) => { const { unregister, setValue } = useFormContext() const { selection, activeTab, setActiveTab } = useAddRewardContext() - const erc20Type: "REQUIREMENT_AMOUNT" | "STATIC" | null = - selection === "ERC20" ? data?.dynamicAmount.operation.input.type : null - const handleChange = (value: RoleTypeToAddTo) => { if (value === RoleTypeToAddTo.NEW_ROLE) { unregister("roleIds") @@ -97,11 +94,7 @@ const SelectRoleOrSetRequirements = ({ isRoleSelectorDisabled }: Props) => { setValue("roleIds", selectedRoleIds)} diff --git a/src/platforms/constants.ts b/src/platforms/constants.ts index 6f0a11c698..c878880b6a 100644 --- a/src/platforms/constants.ts +++ b/src/platforms/constants.ts @@ -11,5 +11,3 @@ export const CAPACITY_TIME_PLATFORMS: PlatformName[] = [ "GATHER_TOWN", "ERC20", ] as const - - diff --git a/src/platforms/rewards.ts b/src/platforms/rewards.ts index 02e4039dc0..c7d1defdff 100644 --- a/src/platforms/rewards.ts +++ b/src/platforms/rewards.ts @@ -109,7 +109,7 @@ export type Rewards = Readonly> export type AddRewardPanelProps = { onAdd: ( - data: RoleFormType["rolePlatforms"][number] & { + data: NonNullable[number] & { requirements?: Requirement[] roleName?: string } diff --git a/src/platforms/types.ts b/src/platforms/types.ts index 7447a6601e..16656b643c 100644 --- a/src/platforms/types.ts +++ b/src/platforms/types.ts @@ -1,9 +1,3 @@ -import type { - GuildPlatformWithOptionalId, - RoleFormType, - PlatformName, - Requirement, -} from "types" import type { ThemingProps } from "@chakra-ui/react" import type { RewardProps } from "components/[guild]/RoleCard/components/Reward" import type { IconProps } from "phosphor-react" @@ -13,6 +7,12 @@ import type { PropsWithChildren, RefAttributes, } from "react" +import type { + GuildPlatformWithOptionalId, + PlatformName, + Requirement, + RoleFormType, +} from "types" export type CardSettingsComponent = () => JSX.Element @@ -61,11 +61,12 @@ export type Rewards = Readonly> export type AddRewardPanelProps = { onAdd: ( - data: RoleFormType["rolePlatforms"][number] & { + data: NonNullable[number] & { requirements?: Requirement[] roleName?: string } ) => void + onCancel?: () => void skipSettings?: boolean } From c7b562a1be62a9504da9bc709461f5b8e4abb30e Mon Sep 17 00:00:00 2001 From: BrickheadJohnny <92519134+BrickheadJohnny@users.noreply.github.com> Date: Fri, 28 Jun 2024 10:08:11 +0200 Subject: [PATCH 31/41] feat(activity log): don't fetch `click join on web` actions (#1331) --- .../ActivityLogAction/components/ActionLabel.tsx | 10 ++++------ src/components/[guild]/activity/ActivityLogContext.tsx | 6 +++++- src/components/[guild]/activity/constants.ts | 6 ------ 3 files changed, 9 insertions(+), 13 deletions(-) diff --git a/src/components/[guild]/activity/ActivityLogAction/components/ActionLabel.tsx b/src/components/[guild]/activity/ActivityLogAction/components/ActionLabel.tsx index d5294d9181..741e7d4207 100644 --- a/src/components/[guild]/activity/ActivityLogAction/components/ActionLabel.tsx +++ b/src/components/[guild]/activity/ActivityLogAction/components/ActionLabel.tsx @@ -151,13 +151,12 @@ const ActionLabel = (): JSX.Element => { )} ) - case ACTION.ClickJoinOnWeb: + case ACTION.JoinGuild: return ( <> - Join Guild through website - {showGuildTag ? ( - - ) : ( + Join Guild + {showGuildTag && } + {activityLogType !== "user" && ( )} @@ -196,7 +195,6 @@ const ActionLabel = (): JSX.Element => { const isChildOfUserStatusUpdate = [ ACTION.UserStatusUpdate, ACTION.JoinGuild, - ACTION.ClickJoinOnWeb, ACTION.ClickJoinOnPlatform, ACTION.LeaveGuild, ].includes(parentaction) diff --git a/src/components/[guild]/activity/ActivityLogContext.tsx b/src/components/[guild]/activity/ActivityLogContext.tsx index 6c41ecc0b5..b708fde2fa 100644 --- a/src/components/[guild]/activity/ActivityLogContext.tsx +++ b/src/components/[guild]/activity/ActivityLogContext.tsx @@ -162,7 +162,11 @@ const ActivityLogProvider = ({ ? ADMIN_ACTIONS : actionGroup === ActivityLogActionGroup.UserAction ? USER_ACTIONS - : [] + : /** + * Adding all actions to the query by default in order to make sure we don't fetch + * unsupported ones (e.g. the "click join on web" action) + */ + [...USER_ACTIONS, ...ADMIN_ACTIONS] actions.forEach((action) => { searchParams.append("action", action.toString()) diff --git a/src/components/[guild]/activity/constants.ts b/src/components/[guild]/activity/constants.ts index 40696de741..771f978aa4 100644 --- a/src/components/[guild]/activity/constants.ts +++ b/src/components/[guild]/activity/constants.ts @@ -68,7 +68,6 @@ export enum ACTION { RestartStatusUpdate = "restart status update", StopStatusUpdate = "stop status update", // User - ClickJoinOnWeb = "click join on web", ClickJoinOnPlatform = "click join on platform", JoinGuild = "join guild", LeaveGuild = "leave guild", @@ -234,10 +233,6 @@ export const activityLogActionIcons: Record< as: ArrowsClockwise, color: "red.500", }, - [ACTION.ClickJoinOnWeb]: { - as: SignIn, - color: "green.500", - }, [ACTION.ClickJoinOnPlatform]: { as: SignIn, color: "green.500", @@ -329,7 +324,6 @@ export const HIDDEN_ACTIONS: ACTION[] = [ ] export const USER_ACTIONS: ACTION[] = [ - ACTION.ClickJoinOnWeb, ACTION.ClickJoinOnPlatform, ACTION.JoinGuild, ACTION.LeaveGuild, From 07572608384ff74043bfe1d561a98d75d1ea69a9 Mon Sep 17 00:00:00 2001 From: cs-balazs <44908417+cs-balazs@users.noreply.github.com> Date: Fri, 28 Jun 2024 11:32:39 +0200 Subject: [PATCH 32/41] feat: Farcaster follow, like and recast actions (#1322) * add follow like recast actions * tsc * move toasts inside useFarcasterAction * fix: tpyo * refactor: remove unnecessary farcasterProfile check * refactor: common FarcasterAction component --- .../Farcaster/FarcasterRequirement.tsx | 60 ++++++++++++--- .../Farcaster/components/FarcasterAction.tsx | 73 +++++++++++++++++++ .../Farcaster/hooks/useFarcasterAction.tsx | 69 ++++++++++++++++++ 3 files changed, 193 insertions(+), 9 deletions(-) create mode 100644 src/requirements/Farcaster/components/FarcasterAction.tsx create mode 100644 src/requirements/Farcaster/hooks/useFarcasterAction.tsx diff --git a/src/requirements/Farcaster/FarcasterRequirement.tsx b/src/requirements/Farcaster/FarcasterRequirement.tsx index e00b75f082..379af8d0e7 100644 --- a/src/requirements/Farcaster/FarcasterRequirement.tsx +++ b/src/requirements/Farcaster/FarcasterRequirement.tsx @@ -4,9 +4,12 @@ import Requirement, { RequirementProps, } from "components/[guild]/Requirements/components/Requirement" import { useRequirementContext } from "components/[guild]/Requirements/components/RequirementContext" +import useUser from "components/[guild]/hooks/useUser" import DataBlockWithCopy from "components/common/DataBlockWithCopy" +import { useRoleMembership } from "components/explorer/hooks/useMembership" import { ArrowSquareOut } from "phosphor-react" import REQUIREMENTS from "requirements" +import FarcasterAction from "./components/FarcasterAction" import FarcasterCast from "./components/FarcasterCast" import useFarcasterCast from "./hooks/useFarcasterCast" import { useFarcasterChannel } from "./hooks/useFarcasterChannels" @@ -23,22 +26,40 @@ const FarcasterProfile = (props: RequirementProps) => ( ) const FarcasterFollowUser = (props: RequirementProps) => { - const { data, type } = useRequirementContext() + const { farcasterProfiles } = useUser() + const isFarcasterConnected = !!farcasterProfiles?.[0]?.fid + + const { data, type, roleId, id } = useRequirementContext< + "FARCASTER_FOLLOW" | "FARCASTER_FOLLOWED_BY" + >() const { data: farcasterUser } = useFarcasterUser( + // TODO: Why is this check needed? Can't we just pass data.id? ["FARCASTER_FOLLOW", "FARCASTER_FOLLOWED_BY"].includes(type) ? data?.id : undefined ) + const { reqAccesses } = useRoleMembership(roleId) + + const access = reqAccesses?.find( + ({ requirementId }) => requirementId === id + )?.access + return ( } + footer={ + !isFarcasterConnected ? ( + + ) : access === false ? ( + + ) : undefined + } image={farcasterUser?.pfp_url || "/requirementLogos/farcaster.png"} {...props} > {type === "FARCASTER_FOLLOW" ? "Follow " : "Be followed by "} - + { } const FarcasterLikeRecast = (props: RequirementProps) => { - const { data, type } = useRequirementContext() + const { farcasterProfiles } = useUser() + const isFarcasterConnected = !!farcasterProfiles?.[0]?.fid + const { data, type, roleId, id } = useRequirementContext() const { data: cast, @@ -76,16 +99,28 @@ const FarcasterLikeRecast = (props: RequirementProps) => { error: castError, } = useFarcasterCast(data?.hash) + const { reqAccesses } = useRoleMembership(roleId) + + const access = reqAccesses?.find( + ({ requirementId }) => requirementId === id + )?.access + return ( } + footer={ + !isFarcasterConnected ? ( + + ) : access === false ? ( + + ) : undefined + } image={REQUIREMENTS.FARCASTER_LIKE.icon.toString()} {...props} > {type === "FARCASTER_LIKE" ? "Like" : "Recast"} <> {" this cast: "} - + { - const { type, data } = useRequirementContext() + const { type, data } = useRequirementContext< + "FARCASTER_FOLLOW_CHANNEL" | "FARCASTER_USERNAME" | "FARCASTER_BIO" + >() + + // This should never happen, but tells TS, that the requirement is expected to be USERNAME / BIO + if (type === "FARCASTER_FOLLOW_CHANNEL") { + return null + } return ( { - const { type } = useRequirementContext() + const { type } = useRequirementContext() const Component = types[type] return } diff --git a/src/requirements/Farcaster/components/FarcasterAction.tsx b/src/requirements/Farcaster/components/FarcasterAction.tsx new file mode 100644 index 0000000000..94d89a6aaf --- /dev/null +++ b/src/requirements/Farcaster/components/FarcasterAction.tsx @@ -0,0 +1,73 @@ +import { RequirementButton } from "components/[guild]/Requirements/components/RequirementButton" +import { useRequirementContext } from "components/[guild]/Requirements/components/RequirementContext" +import useUser from "components/[guild]/hooks/useUser" +import useFarcasterAction from "../hooks/useFarcasterAction" +import { useFarcasterUser } from "../hooks/useFarcasterUsers" + +const TYPE_TO_CTA = { + FARCASTER_FOLLOW: "Follow", + FARCASTER_LIKE: "Like", + FARCASTER_RECAST: "Recast", +} + +export default function FarcasterAction() { + const { farcasterProfiles } = useUser() + + const { data, roleId, type } = useRequirementContext< + | "FARCASTER_FOLLOW" + | "FARCASTER_FOLLOWED_BY" + | "FARCASTER_LIKE" + | "FARCASTER_RECAST" + >() + + const { data: farcasterUser } = useFarcasterUser( + type === "FARCASTER_FOLLOW" ? data.id : undefined + ) + + const { onSubmit, isLoading, response } = useFarcasterAction(roleId) + + if ( + (type !== "FARCASTER_FOLLOW" && + type !== "FARCASTER_LIKE" && + type !== "FARCASTER_RECAST") || + !farcasterProfiles?.[0]?.fid || + response + ) { + return null + } + + return ( + { + if (type === "FARCASTER_LIKE") { + return onSubmit({ + type: "like", + castId: data.hash ?? data.url, + }) + } + + if (type === "FARCASTER_RECAST") { + return onSubmit({ + type: "recast", + castId: data.hash ?? data.url, + }) + } + + if (type === "FARCASTER_FOLLOW") { + return onSubmit({ + type: "follow", + targetFid: data.id, + }) + } + }} + > + {type === "FARCASTER_FOLLOW" && farcasterUser?.display_name + ? `Follow ${farcasterUser?.display_name}` + : TYPE_TO_CTA[type]} + + ) +} diff --git a/src/requirements/Farcaster/hooks/useFarcasterAction.tsx b/src/requirements/Farcaster/hooks/useFarcasterAction.tsx new file mode 100644 index 0000000000..f950c3cd29 --- /dev/null +++ b/src/requirements/Farcaster/hooks/useFarcasterAction.tsx @@ -0,0 +1,69 @@ +import { Text } from "@chakra-ui/react" +import useMembershipUpdate from "components/[guild]/JoinModal/hooks/useMembershipUpdate" +import useUser from "components/[guild]/hooks/useUser" +import useShowErrorToast from "hooks/useShowErrorToast" +import useSubmit from "hooks/useSubmit" +import useToast from "hooks/useToast" +import { useFetcherWithSign } from "utils/fetcher" + +type Action = + | { + type: "follow" + targetFid: number + } + | { + type: "like" | "recast" + castId: string + } + +export default function useFarcasterAction(roleId: number) { + const { farcasterProfiles, id } = useUser() + const fetcherWithSign = useFetcherWithSign() + const { triggerMembershipUpdate } = useMembershipUpdate() + const toast = useToast() + const showErrorToast = useShowErrorToast() + + return useSubmit( + async (action?: Action) => { + if (!action) { + throw new Error("Unknown Farcaster action") + } + if (!farcasterProfiles?.[0]?.fid) { + throw new Error("First connect your Farcaster account") + } + + const actionType = action.type + const actionValue = action.type === "follow" ? action.targetFid : action.castId + + await fetcherWithSign([ + `/v2/users/${id}/farcaster-profiles/${ + farcasterProfiles[0].fid + }/${actionType}/${encodeURIComponent(actionValue)}`, + { method: "POST" }, + ]) + + triggerMembershipUpdate({ roleIds: [roleId] }) + + return action + }, + { + onSuccess: (action) => { + toast({ + status: "success", + description: ( + <> + Farcaster {action.type} successful + + It might take some time until it shows up in external clients, such + as Warpcast + + + ), + }) + }, + onError: (error) => { + showErrorToast(error) + }, + } + ) +} From 584d33328a1293ec56fee8640c547c38cce605d1 Mon Sep 17 00:00:00 2001 From: BrickheadJohnny Date: Sat, 29 Jun 2024 16:31:58 +0200 Subject: [PATCH 33/41] feat(AccountModal): add "Opened network modal" PostHog event --- .../Account/components/AccountModal/AccountModal.tsx | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/components/common/Layout/components/Account/components/AccountModal/AccountModal.tsx b/src/components/common/Layout/components/Account/components/AccountModal/AccountModal.tsx index d8f3d2b4f6..11ce6fd479 100644 --- a/src/components/common/Layout/components/Account/components/AccountModal/AccountModal.tsx +++ b/src/components/common/Layout/components/Account/components/AccountModal/AccountModal.tsx @@ -18,6 +18,7 @@ import { useDisclosure, } from "@chakra-ui/react" import useUser, { useUserPublic } from "components/[guild]/hooks/useUser" +import { usePostHogContext } from "components/_app/PostHogProvider" import useConnectorNameAndIcon from "components/_app/Web3ConnectionManager/hooks/useConnectorNameAndIcon" import useWeb3ConnectionManager from "components/_app/Web3ConnectionManager/hooks/useWeb3ConnectionManager" import Button from "components/common/Button" @@ -47,6 +48,7 @@ const AccountModal = () => { onOpen: openNetworkModal, onClose: closeNetworkModal, } = useDisclosure() + const { captureEvent } = usePostHogContext() const { id } = useUser() const { deleteKeys } = useUserPublic() @@ -109,7 +111,10 @@ const AccountModal = () => { @@ -139,7 +141,7 @@ const RequirementEditableCard = ({ onRemove()} /> - {!isEditDisabled && ( + {!isEditDisabled && !!FormComponent && ( { const requirements = methods.watch("requirements") @@ -27,14 +28,13 @@ const useHandleRequirementState = (methods) => { const append = ( req: Schemas["RequirementCreationPayload"] - ): RequirementCreateResponseOutput => { - const reqToAdd = { id: Date.now(), ...req } + ): ClientStateRequirementCreateResponse => { + const reqToAdd: ClientStateRequirementCreateResponse = { id: uuidv7(), ...req } if (freeEntry) { remove(0) } addRequirement(reqToAdd) - // TODO: find a better solution to avoid type casting - return reqToAdd as RequirementCreateResponseOutput + return reqToAdd } return { requirements, append, remove: removeReq, update, freeEntry } diff --git a/src/hooks/useCreateRRR.tsx b/src/hooks/useCreateRRR.tsx index fc19102bd1..8e5f4af4ff 100644 --- a/src/hooks/useCreateRRR.tsx +++ b/src/hooks/useCreateRRR.tsx @@ -27,9 +27,9 @@ export type SubmitData = /** * Array of requirements. If referenced in a rolePlatform, the requirement should - * have a temporal `id` generated with Date.now() A requirementIdMap will be - * created to match each temporalId-roleId pair with the actual backend-created - * ID after creation. + * have a temporal `id` generated using uuid. A requirementIdMap will be created + * to match each temporalId-roleId pair with the actual backend-created ID after + * creation. */ requirements: RoleToCreate["requirements"] @@ -62,7 +62,7 @@ export type SubmitData = * backend. */ export type RequirementIdMap = { - [tempRequirementId: number]: { + [tempRequirementId: string]: { [roleId: number]: number // real requirement ID assigned by the backend } } diff --git a/src/platforms/Discord/DiscordCardSettings/DiscordCardSettings.tsx b/src/platforms/Discord/DiscordCardSettings/DiscordCardSettings.tsx index ca66976dd7..687f1eb862 100644 --- a/src/platforms/Discord/DiscordCardSettings/DiscordCardSettings.tsx +++ b/src/platforms/Discord/DiscordCardSettings/DiscordCardSettings.tsx @@ -7,6 +7,7 @@ import GuildifyExistingRole from "./components/GuildifyExistingRole" const roleOptions = [ { value: "NEW", + defaultValue: "NEW", title: "Create a new Discord role for me", icon: Sparkle, }, @@ -24,12 +25,11 @@ const DiscordCardSettings = (): JSX.Element => { const { field } = useController({ name: "roleType", - defaultValue: "NEW", }) const handleChange = (value) => { field.onChange(value) - if (value === "NEW") setValue(`platformRoleId`, null) + if (value === "NEW") setValue("platformRoleId", "") } return ( diff --git a/src/platforms/Discord/DiscordCardSettings/components/GuildifyExistingRole.tsx b/src/platforms/Discord/DiscordCardSettings/components/GuildifyExistingRole.tsx index c56bd2f3fd..0aaa3226e6 100644 --- a/src/platforms/Discord/DiscordCardSettings/components/GuildifyExistingRole.tsx +++ b/src/platforms/Discord/DiscordCardSettings/components/GuildifyExistingRole.tsx @@ -18,7 +18,7 @@ const GuildifyExistingRole = () => { const { errors, dirtyFields, defaultValues } = useFormState() const { setValue } = useFormContext() const { roles: guildRoles } = useGuild() - const { guildPlatform, index } = useRolePlatform() + const { guildPlatform } = useRolePlatform() const { data: { roles: discordRoles }, } = useServerData(guildPlatform.platformGuildId, { memberCountDetails: true }) @@ -52,7 +52,7 @@ const GuildifyExistingRole = () => { { @@ -62,7 +62,7 @@ const GuildifyExistingRole = () => { /> - {errors.rolePlatforms?.[index]?.platformRoleId?.message} + {errors?.platformRoleId?.message?.toString()} diff --git a/src/types.ts b/src/types.ts index e20a58760b..6e7d3b5286 100644 --- a/src/types.ts +++ b/src/types.ts @@ -501,6 +501,24 @@ type RequirementCreateResponseOutput = z.output< typeof schemas.RequirementCreateResponseSchema > +type ClientStateRequirementCreateResponse = Omit< + Schemas["RequirementCreateResponse"], + /** + * These props won't be included in the response when we only store the requirement + * object on client side, so we omit them from the type & add them back as optional + * props + */ + "id" | "createdAt" | "updatedAt" | "roleId" | "deletedRequirements" +> & + Partial< + Pick< + Schemas["RequirementCreateResponse"], + "createdAt" | "updatedAt" | "roleId" | "deletedRequirements" + > + > & { + id: string | number + } + type RolePlatformStatus = "ALL_CLAIMED" | "NOT_STARTED" | "ENDED" | "ACTIVE" type RolePlatform = { @@ -625,7 +643,10 @@ type RequirementCreationPayloadWithTempID = Schemas["RequirementCreationPayload" type RoleFormType = Partial< Omit & { - requirements: Array> + requirements: Array< + | Partial + | Partial + > rolePlatforms: Array< Partial> & { guildPlatform?: GuildPlatformWithOptionalId @@ -746,6 +767,7 @@ type DetailedPinLeaderboardUserData = { export { supportedEventSources, supportedSocialLinks, ValidationMethod } export type { BaseUser, + ClientStateRequirementCreateResponse, CoingeckoToken, DetailedPinLeaderboardUserData as DetailedUserLeaderboardData, DiscordError, From 38c874987af29ece629abdd4174eb82a441be59a Mon Sep 17 00:00:00 2001 From: Dominik Stumpf <122315398+dominik-stumpf@users.noreply.github.com> Date: Tue, 2 Jul 2024 17:38:19 +0200 Subject: [PATCH 37/41] refactor: rename platforms to rewards (#1342) --- .gitignore | 4 +- .../[guild]/AccessHub/AccessHub.tsx | 4 +- .../components/AccessedGuildPlatformCard.tsx | 2 +- .../components/PlatformAccessButton.tsx | 2 +- .../components/RemovePlatformMenuItem.tsx | 2 +- .../components/usePlatformAccessButton.tsx | 2 +- .../AccessHub/hooks/useEditGuildPlatform.ts | 2 +- .../components/NewRolePlatformCard.tsx | 4 +- .../AddRewardButton/AddRewardButton.tsx | 4 +- .../AddRewardButton/SelectRolePanel.tsx | 4 +- .../[guild]/JoinModal/JoinModal.tsx | 2 +- .../JoinModal/components/ConnectPlatform.tsx | 2 +- .../JoinModal/hooks/useConnectPlatform.ts | 2 +- .../JoinModal/hooks/useMembershipUpdate.tsx | 2 +- .../JoinModal/utils/processConnectorError.ts | 2 +- .../ConnectRequirementPlatformButton.tsx | 2 +- src/components/[guild]/RoleCard/RoleCard.tsx | 2 +- .../components/DynamicReward/DynamicTag.tsx | 2 +- .../components/ExistingRolePlatformCard.tsx | 4 +- .../[guild]/RoleCard/components/Reward.tsx | 4 +- .../AddRoleRewardModal/AddRoleRewardModal.tsx | 5 +- .../DefaultAddRewardPanelWrapper.tsx | 2 +- .../AddContractCallPanel.tsx | 2 +- .../components/AddDiscordPanel.tsx | 2 +- .../components/AddFormPanel/AddFormPanel.tsx | 2 +- .../components/AddGatherPanel.tsx | 8 +- .../components/AddGithubPanel.tsx | 2 +- .../components/AddGooglePanel.tsx | 2 +- .../components/AddPoapPanel/AddPoapPanel.tsx | 2 +- .../AddPointsPanel/AddPointsPanel.tsx | 2 +- .../components/AddNewPointsType.tsx | 2 +- .../components/AddPolygonIDPanel.tsx | 2 +- .../components/AddSecretTextPanel.tsx | 6 +- .../components/AddTelegramPanel.tsx | 2 +- .../AddTokenPanel/AddTokenPanel.tsx | 2 +- .../components/DynamicAmount.tsx | 2 +- .../AddTokenPanel/components/PoolStep.tsx | 2 +- .../components/TokenAmountStep.tsx | 2 +- .../components/SelectExistingPlatform.tsx | 2 +- .../EditRewardAvailabilityModal.tsx | 2 +- .../components/EditRolePlatformModal.tsx | 2 +- .../components/PlatformCard/PlatformCard.tsx | 2 +- .../components/ActionLabel.tsx | 2 +- .../ActivityLogAction/components/FormTag.tsx | 2 +- .../components/IdentityTag.tsx | 2 +- .../components/RewardTag.tsx | 2 +- .../claim-poap/components/ClaimPoapButton.tsx | 2 +- .../EditNFTDescriptionModalButton.tsx | 2 +- .../collect/components/EditNftButton.tsx | 2 +- src/components/[guild]/crm/Identities.tsx | 2 +- src/components/[guild]/forms/FillForm.tsx | 2 +- .../forms/responses/FormResponsesTable.tsx | 2 +- .../forms/responses/FormResponsesTbody.tsx | 2 +- .../[guild]/forms/responses/ResponseModal.tsx | 2 +- .../leaderboard/LeaderboardAirdropCard.tsx | 8 +- .../components/PlatformMergeErrorAlert.tsx | 2 +- .../hooks/useConnectFromLocalStorage.ts | 2 +- .../components/GoogleDocCard.tsx | 2 +- .../components/AccountConnections.tsx | 2 +- .../components/SocialAccount/EmailAddress.tsx | 2 +- .../SocialAccount/FarcasterProfile.tsx | 2 +- .../SocialAccount/SocialAccount.tsx | 2 +- .../components/SocialAccountUI.tsx | 2 +- src/components/common/ReconnectAlert.tsx | 2 +- .../PlatformsGrid/PlatformsGrid.tsx | 2 +- .../components/PlatformSelectButton.tsx | 2 +- src/hooks/useOAuthResultToast.ts | 2 +- src/pages/[guild]/[group].tsx | 2 +- src/pages/[guild]/index.tsx | 2 +- src/pages/oauth-result.tsx | 2 +- src/platforms/rewards.ts | 147 ------------------ src/requirements/Form/FormRequirement.tsx | 4 +- .../Form/components/CreateFormModal.tsx | 2 +- src/requirements/requirements.ts | 2 +- .../ContractCall/ContractCallCardMenu.tsx | 0 .../ContractCall/ContractCallReward.tsx | 0 .../ContractCallRewardCardButton.tsx | 0 .../components/EditNFTDescriptionModal.tsx | 0 .../ContractCall/components/EditNftModal.tsx | 0 .../components/NftAvailabilityTags.tsx | 0 .../ContractCall/hooks/useEditNft.ts | 0 .../ContractCall/index.ts | 10 +- .../ContractCall/useContractCallCardProps.tsx | 0 .../DiscordCardMenu/DiscordCardMenu.tsx | 0 .../components/DiscordCaptchaSwitch.tsx | 0 .../components/DiscordRewardSettings.tsx.tsx | 0 .../Discord/DiscordCardMenu/index.ts | 0 .../DiscordCardSettings.tsx | 0 .../components/GuildifyExistingRole.tsx | 0 .../Discord/DiscordCardSettings/index.ts | 0 src/{platforms => rewards}/Discord/index.ts | 8 +- .../Discord/useDiscordCardProps.tsx | 0 src/{platforms => rewards}/Email/index.ts | 2 +- src/{platforms => rewards}/Farcaster/index.ts | 2 +- .../Forms/EditFormModal.tsx | 0 .../Forms/FormCardLinkButton.tsx | 2 +- .../Forms/FormCardMenu.tsx | 0 .../Forms/hooks/useEditForm.tsx | 0 .../Forms/hooks/useFormSubmissions.tsx | 0 src/{platforms => rewards}/Forms/index.ts | 10 +- .../Forms/useFormCardProps.tsx | 2 +- .../Gather/ClaimGatherModal.tsx | 0 .../Gather/EditGatherModal.tsx | 0 .../Gather/GatherCardButton.tsx | 2 +- .../Gather/GatherCardMenu.tsx | 0 .../Gather/GatherConnectionForm.tsx | 0 .../Gather/GatherConnectionStatusAlert.tsx | 0 .../Gather/GatherForm.tsx | 0 .../Gather/GatherGuestForm.tsx | 0 .../Gather/hooks/useClaimGather.tsx | 0 .../Gather/hooks/useGatherAccess.tsx | 0 src/{platforms => rewards}/Gather/index.ts | 10 +- .../Gather/useGatherCardProps.tsx | 2 +- .../Github/GithubCardMenu.tsx | 0 src/{platforms => rewards}/Github/index.ts | 8 +- .../Github/useGithubCardProps.ts | 0 .../Google/GoogleCardMenu.tsx | 0 .../Google/GoogleCardSettings.tsx | 0 .../Google/GoogleCardWarning.tsx | 0 src/{platforms => rewards}/Google/index.ts | 8 +- .../Google/useGoogleCardProps.tsx | 0 .../Poap/PoapCardButton.tsx | 4 +- .../Poap/PoapCardMenu.tsx | 0 .../Poap/ShowMintLinkButton.tsx | 2 +- .../Poap/UploadMintLinksModal.tsx | 0 src/{platforms => rewards}/Poap/index.ts | 8 +- .../Poap/usePoapCardProps.tsx | 2 +- .../Points/EditPointsModal.tsx | 0 .../Points/PointsCardButton.tsx | 0 .../Points/PointsCardMenu.tsx | 0 .../Points/PointsCardSettings.tsx | 0 .../Points/PointsRewardCard.tsx | 2 +- src/{platforms => rewards}/Points/index.tsx | 21 ++- .../Points/usePointsCardProps.tsx | 2 +- .../Points/useUsersPoints.ts | 0 .../PolygonID/PolygonIDCardButton.tsx | 0 .../PolygonID/PolygonIDCardMenu.tsx | 0 .../PolygonID/components/ConnectDIDModal.tsx | 0 .../components/MintPolygonIDProofModal.tsx | 0 .../components/MintPolygonIDProofProvider.tsx | 0 .../PolygonID/components/MintableRole.tsx | 0 .../components/PolygonIDQRCodeModal.tsx | 0 .../PolygonID/hooks/useClaimedRoles.ts | 0 .../PolygonID/hooks/useConnectedDID.ts | 0 src/{platforms => rewards}/PolygonID/index.ts | 10 +- .../PolygonID/usePolygonIDCardProps.tsx | 2 +- .../SecretText/EditSecretTextModal.tsx | 0 .../SecretText/SecretTextCardMenu.tsx | 0 .../SecretTextDataForm/SecretTextDataForm.tsx | 0 .../components/PublicRewardDataForm.tsx | 2 +- .../components/RewardImagePicker.tsx | 0 .../SecretText/SecretTextDataForm/index.ts | 0 .../SecretText/TextCardButton.tsx | 0 .../SecretText/hooks/useClaimText.tsx | 0 .../SecretText/index.ts | 10 +- .../SecretText/useSecretTextCardProps.tsx | 2 +- .../Telegram/TelegramCardMenu.tsx | 0 src/{platforms => rewards}/Telegram/index.ts | 8 +- .../Telegram/useTelegramCardProps.ts | 0 .../Token/ClaimTokenButton.tsx | 2 +- .../Token/ClaimTokenModal/ClaimTokenModal.tsx | 2 +- .../TokenRibbonIllustration.tsx | 0 .../Token/ClaimTokenModal/index.ts | 0 .../Token/DynamicRewardCalculationTable.tsx | 2 +- .../Token/DynamicRewardModal.tsx | 2 +- .../Token/DynamicTypeForm.tsx | 0 .../Token/EditDynamicRewardModal.tsx | 2 +- .../Token/EditTokenModal.tsx | 2 +- .../Token/FundPoolModal.tsx | 2 +- .../Token/GeogatedCountryAlert.tsx | 0 .../Token/PoolInformation.tsx | 0 src/{platforms => rewards}/Token/PoolTag.tsx | 6 +- .../Token/RemoveTokenRewardConfirmation.tsx | 0 .../Token/TokenClaimFeeTable.tsx | 0 .../Token/TokenConversionTag.tsx | 2 +- .../Token/TokenRewardCard.tsx | 2 +- .../Token/TokenRewardCardEditMenu.tsx | 0 .../Token/TokenRewardContext.tsx | 0 .../Token/TokenRolePlatformClaimCard.tsx | 0 .../Token/WithdrawPoolModal.tsx | 2 +- .../Token/hooks/useCalculateToken.tsx | 0 .../Token/hooks/useClaimToken.tsx | 0 .../Token/hooks/useCollectToken.tsx | 0 .../hooks/useDynamicRewardUserAmount.tsx | 0 .../Token/hooks/useFundPool.tsx | 0 .../Token/hooks/usePool.tsx | 0 .../Token/hooks/useRegisterPool.tsx | 0 .../Token/hooks/useRolePlatformsOfReward.tsx | 0 .../Token/hooks/useTokenCardProps.tsx | 0 .../Token/hooks/useTokenClaimedAmount.tsx | 0 .../Token/hooks/useWithdrawPool.tsx | 0 src/{platforms => rewards}/Token/index.ts | 10 +- src/{platforms => rewards}/Twitter/index.ts | 2 +- .../UniqueText/EditUniqueTextModal.tsx | 0 .../UniqueText/UniqueTextCardMenu.tsx | 0 .../UniqueText/UniqueTextDataForm.tsx | 2 +- .../UniqueText/index.ts | 10 +- .../UniqueText/useUniqueTextCardProps.tsx | 2 +- .../AddRewardPanelLoadingSpinner.tsx | 0 .../components/ContractCallPreview.tsx | 0 .../components/DiscordPreview.tsx | 0 .../components/FormPreview.tsx | 0 .../components/FormReward.tsx | 2 +- .../components/GatherPreview.tsx | 2 +- .../components/GatherReward.tsx | 8 +- .../components/GitHubPreview.tsx | 0 .../components/GooglePreview.tsx | 0 .../components/LoadingRewardPreview.tsx | 0 .../components/PoapPreview.tsx | 2 +- .../components/PoapReward.tsx | 6 +- .../components/PointsPreview.tsx | 0 .../components/PointsReward.tsx | 2 +- .../components/PolygonIDPreview.tsx | 2 +- .../components/PolygonIDReward.tsx | 6 +- .../components/RewardPreview.tsx | 2 +- .../components/SecretTextPreview.tsx | 2 +- .../SelectRoleOrSetRequirements.tsx | 2 +- .../components/TelegramPreview.tsx | 0 .../components/TextReward.tsx | 8 +- .../components/TokenPreview.tsx | 2 +- .../components/TokenReward.tsx | 12 +- .../components/UniqueTextPreview.tsx | 2 +- src/{platforms => rewards}/constants.ts | 0 .../hooks/usePlatformUsageInfo.ts | 0 src/rewards/index.ts | 41 +++++ src/{platforms => rewards}/types.ts | 0 src/{platforms => rewards}/utils.ts | 2 +- 227 files changed, 256 insertions(+), 368 deletions(-) delete mode 100644 src/platforms/rewards.ts rename src/{platforms => rewards}/ContractCall/ContractCallCardMenu.tsx (100%) rename src/{platforms => rewards}/ContractCall/ContractCallReward.tsx (100%) rename src/{platforms => rewards}/ContractCall/ContractCallRewardCardButton.tsx (100%) rename src/{platforms => rewards}/ContractCall/components/EditNFTDescriptionModal.tsx (100%) rename src/{platforms => rewards}/ContractCall/components/EditNftModal.tsx (100%) rename src/{platforms => rewards}/ContractCall/components/NftAvailabilityTags.tsx (100%) rename src/{platforms => rewards}/ContractCall/hooks/useEditNft.ts (100%) rename src/{platforms => rewards}/ContractCall/index.ts (70%) rename src/{platforms => rewards}/ContractCall/useContractCallCardProps.tsx (100%) rename src/{platforms => rewards}/Discord/DiscordCardMenu/DiscordCardMenu.tsx (100%) rename src/{platforms => rewards}/Discord/DiscordCardMenu/components/DiscordCaptchaSwitch.tsx (100%) rename src/{platforms => rewards}/Discord/DiscordCardMenu/components/DiscordRewardSettings.tsx.tsx (100%) rename src/{platforms => rewards}/Discord/DiscordCardMenu/index.ts (100%) rename src/{platforms => rewards}/Discord/DiscordCardSettings/DiscordCardSettings.tsx (100%) rename src/{platforms => rewards}/Discord/DiscordCardSettings/components/GuildifyExistingRole.tsx (100%) rename src/{platforms => rewards}/Discord/DiscordCardSettings/index.ts (100%) rename src/{platforms => rewards}/Discord/index.ts (73%) rename src/{platforms => rewards}/Discord/useDiscordCardProps.tsx (100%) rename src/{platforms => rewards}/Email/index.ts (78%) rename src/{platforms => rewards}/Farcaster/index.ts (82%) rename src/{platforms => rewards}/Forms/EditFormModal.tsx (100%) rename src/{platforms => rewards}/Forms/FormCardLinkButton.tsx (97%) rename src/{platforms => rewards}/Forms/FormCardMenu.tsx (100%) rename src/{platforms => rewards}/Forms/hooks/useEditForm.tsx (100%) rename src/{platforms => rewards}/Forms/hooks/useFormSubmissions.tsx (100%) rename src/{platforms => rewards}/Forms/index.ts (67%) rename src/{platforms => rewards}/Forms/useFormCardProps.tsx (97%) rename src/{platforms => rewards}/Gather/ClaimGatherModal.tsx (100%) rename src/{platforms => rewards}/Gather/EditGatherModal.tsx (100%) rename src/{platforms => rewards}/Gather/GatherCardButton.tsx (96%) rename src/{platforms => rewards}/Gather/GatherCardMenu.tsx (100%) rename src/{platforms => rewards}/Gather/GatherConnectionForm.tsx (100%) rename src/{platforms => rewards}/Gather/GatherConnectionStatusAlert.tsx (100%) rename src/{platforms => rewards}/Gather/GatherForm.tsx (100%) rename src/{platforms => rewards}/Gather/GatherGuestForm.tsx (100%) rename src/{platforms => rewards}/Gather/hooks/useClaimGather.tsx (100%) rename src/{platforms => rewards}/Gather/hooks/useGatherAccess.tsx (100%) rename src/{platforms => rewards}/Gather/index.ts (68%) rename src/{platforms => rewards}/Gather/useGatherCardProps.tsx (97%) rename src/{platforms => rewards}/Github/GithubCardMenu.tsx (100%) rename src/{platforms => rewards}/Github/index.ts (71%) rename src/{platforms => rewards}/Github/useGithubCardProps.ts (100%) rename src/{platforms => rewards}/Google/GoogleCardMenu.tsx (100%) rename src/{platforms => rewards}/Google/GoogleCardSettings.tsx (100%) rename src/{platforms => rewards}/Google/GoogleCardWarning.tsx (100%) rename src/{platforms => rewards}/Google/index.ts (75%) rename src/{platforms => rewards}/Google/useGoogleCardProps.tsx (100%) rename src/{platforms => rewards}/Poap/PoapCardButton.tsx (95%) rename src/{platforms => rewards}/Poap/PoapCardMenu.tsx (100%) rename src/{platforms => rewards}/Poap/ShowMintLinkButton.tsx (93%) rename src/{platforms => rewards}/Poap/UploadMintLinksModal.tsx (100%) rename src/{platforms => rewards}/Poap/index.ts (71%) rename src/{platforms => rewards}/Poap/usePoapCardProps.tsx (95%) rename src/{platforms => rewards}/Points/EditPointsModal.tsx (100%) rename src/{platforms => rewards}/Points/PointsCardButton.tsx (100%) rename src/{platforms => rewards}/Points/PointsCardMenu.tsx (100%) rename src/{platforms => rewards}/Points/PointsCardSettings.tsx (100%) rename src/{platforms => rewards}/Points/PointsRewardCard.tsx (97%) rename src/{platforms => rewards}/Points/index.tsx (56%) rename src/{platforms => rewards}/Points/usePointsCardProps.tsx (90%) rename src/{platforms => rewards}/Points/useUsersPoints.ts (100%) rename src/{platforms => rewards}/PolygonID/PolygonIDCardButton.tsx (100%) rename src/{platforms => rewards}/PolygonID/PolygonIDCardMenu.tsx (100%) rename src/{platforms => rewards}/PolygonID/components/ConnectDIDModal.tsx (100%) rename src/{platforms => rewards}/PolygonID/components/MintPolygonIDProofModal.tsx (100%) rename src/{platforms => rewards}/PolygonID/components/MintPolygonIDProofProvider.tsx (100%) rename src/{platforms => rewards}/PolygonID/components/MintableRole.tsx (100%) rename src/{platforms => rewards}/PolygonID/components/PolygonIDQRCodeModal.tsx (100%) rename src/{platforms => rewards}/PolygonID/hooks/useClaimedRoles.ts (100%) rename src/{platforms => rewards}/PolygonID/hooks/useConnectedDID.ts (100%) rename src/{platforms => rewards}/PolygonID/index.ts (71%) rename src/{platforms => rewards}/PolygonID/usePolygonIDCardProps.tsx (94%) rename src/{platforms => rewards}/SecretText/EditSecretTextModal.tsx (100%) rename src/{platforms => rewards}/SecretText/SecretTextCardMenu.tsx (100%) rename src/{platforms => rewards}/SecretText/SecretTextDataForm/SecretTextDataForm.tsx (100%) rename src/{platforms => rewards}/SecretText/SecretTextDataForm/components/PublicRewardDataForm.tsx (92%) rename src/{platforms => rewards}/SecretText/SecretTextDataForm/components/RewardImagePicker.tsx (100%) rename src/{platforms => rewards}/SecretText/SecretTextDataForm/index.ts (100%) rename src/{platforms => rewards}/SecretText/TextCardButton.tsx (100%) rename src/{platforms => rewards}/SecretText/hooks/useClaimText.tsx (100%) rename src/{platforms => rewards}/SecretText/index.ts (67%) rename src/{platforms => rewards}/SecretText/useSecretTextCardProps.tsx (97%) rename src/{platforms => rewards}/Telegram/TelegramCardMenu.tsx (100%) rename src/{platforms => rewards}/Telegram/index.ts (71%) rename src/{platforms => rewards}/Telegram/useTelegramCardProps.ts (100%) rename src/{platforms => rewards}/Token/ClaimTokenButton.tsx (94%) rename src/{platforms => rewards}/Token/ClaimTokenModal/ClaimTokenModal.tsx (98%) rename src/{platforms => rewards}/Token/ClaimTokenModal/TokenRibbonIllustration.tsx (100%) rename src/{platforms => rewards}/Token/ClaimTokenModal/index.ts (100%) rename src/{platforms => rewards}/Token/DynamicRewardCalculationTable.tsx (98%) rename src/{platforms => rewards}/Token/DynamicRewardModal.tsx (98%) rename src/{platforms => rewards}/Token/DynamicTypeForm.tsx (100%) rename src/{platforms => rewards}/Token/EditDynamicRewardModal.tsx (98%) rename src/{platforms => rewards}/Token/EditTokenModal.tsx (99%) rename src/{platforms => rewards}/Token/FundPoolModal.tsx (98%) rename src/{platforms => rewards}/Token/GeogatedCountryAlert.tsx (100%) rename src/{platforms => rewards}/Token/PoolInformation.tsx (100%) rename src/{platforms => rewards}/Token/PoolTag.tsx (95%) rename src/{platforms => rewards}/Token/RemoveTokenRewardConfirmation.tsx (100%) rename src/{platforms => rewards}/Token/TokenClaimFeeTable.tsx (100%) rename src/{platforms => rewards}/Token/TokenConversionTag.tsx (96%) rename src/{platforms => rewards}/Token/TokenRewardCard.tsx (98%) rename src/{platforms => rewards}/Token/TokenRewardCardEditMenu.tsx (100%) rename src/{platforms => rewards}/Token/TokenRewardContext.tsx (100%) rename src/{platforms => rewards}/Token/TokenRolePlatformClaimCard.tsx (100%) rename src/{platforms => rewards}/Token/WithdrawPoolModal.tsx (98%) rename src/{platforms => rewards}/Token/hooks/useCalculateToken.tsx (100%) rename src/{platforms => rewards}/Token/hooks/useClaimToken.tsx (100%) rename src/{platforms => rewards}/Token/hooks/useCollectToken.tsx (100%) rename src/{platforms => rewards}/Token/hooks/useDynamicRewardUserAmount.tsx (100%) rename src/{platforms => rewards}/Token/hooks/useFundPool.tsx (100%) rename src/{platforms => rewards}/Token/hooks/usePool.tsx (100%) rename src/{platforms => rewards}/Token/hooks/useRegisterPool.tsx (100%) rename src/{platforms => rewards}/Token/hooks/useRolePlatformsOfReward.tsx (100%) rename src/{platforms => rewards}/Token/hooks/useTokenCardProps.tsx (100%) rename src/{platforms => rewards}/Token/hooks/useTokenClaimedAmount.tsx (100%) rename src/{platforms => rewards}/Token/hooks/useWithdrawPool.tsx (100%) rename src/{platforms => rewards}/Token/index.ts (65%) rename src/{platforms => rewards}/Twitter/index.ts (86%) rename src/{platforms => rewards}/UniqueText/EditUniqueTextModal.tsx (100%) rename src/{platforms => rewards}/UniqueText/UniqueTextCardMenu.tsx (100%) rename src/{platforms => rewards}/UniqueText/UniqueTextDataForm.tsx (97%) rename src/{platforms => rewards}/UniqueText/index.ts (60%) rename src/{platforms => rewards}/UniqueText/useUniqueTextCardProps.tsx (97%) rename src/{platforms => rewards}/components/AddRewardPanelLoadingSpinner.tsx (100%) rename src/{platforms => rewards}/components/ContractCallPreview.tsx (100%) rename src/{platforms => rewards}/components/DiscordPreview.tsx (100%) rename src/{platforms => rewards}/components/FormPreview.tsx (100%) rename src/{platforms => rewards}/components/FormReward.tsx (95%) rename src/{platforms => rewards}/components/GatherPreview.tsx (91%) rename src/{platforms => rewards}/components/GatherReward.tsx (94%) rename src/{platforms => rewards}/components/GitHubPreview.tsx (100%) rename src/{platforms => rewards}/components/GooglePreview.tsx (100%) rename src/{platforms => rewards}/components/LoadingRewardPreview.tsx (100%) rename src/{platforms => rewards}/components/PoapPreview.tsx (93%) rename src/{platforms => rewards}/components/PoapReward.tsx (93%) rename src/{platforms => rewards}/components/PointsPreview.tsx (100%) rename src/{platforms => rewards}/components/PointsReward.tsx (95%) rename src/{platforms => rewards}/components/PolygonIDPreview.tsx (83%) rename src/{platforms => rewards}/components/PolygonIDReward.tsx (93%) rename src/{platforms => rewards}/components/RewardPreview.tsx (97%) rename src/{platforms => rewards}/components/SecretTextPreview.tsx (95%) rename src/{platforms => rewards}/components/SelectRoleOrSetRequirements.tsx (97%) rename src/{platforms => rewards}/components/TelegramPreview.tsx (100%) rename src/{platforms => rewards}/components/TextReward.tsx (94%) rename src/{platforms => rewards}/components/TokenPreview.tsx (94%) rename src/{platforms => rewards}/components/TokenReward.tsx (90%) rename src/{platforms => rewards}/components/UniqueTextPreview.tsx (95%) rename src/{platforms => rewards}/constants.ts (100%) rename src/{platforms => rewards}/hooks/usePlatformUsageInfo.ts (100%) create mode 100644 src/rewards/index.ts rename src/{platforms => rewards}/types.ts (100%) rename src/{platforms => rewards}/utils.ts (88%) diff --git a/.gitignore b/.gitignore index e4c40d4356..b884d92849 100644 --- a/.gitignore +++ b/.gitignore @@ -32,4 +32,6 @@ yarn-error.log* cypress/screenshots cypress/videos -.idea \ No newline at end of file +.idea + +*.tsbuildinfo diff --git a/src/components/[guild]/AccessHub/AccessHub.tsx b/src/components/[guild]/AccessHub/AccessHub.tsx index a16504a6cb..3dd9646a8d 100644 --- a/src/components/[guild]/AccessHub/AccessHub.tsx +++ b/src/components/[guild]/AccessHub/AccessHub.tsx @@ -12,8 +12,8 @@ import ClientOnly from "components/common/ClientOnly" import useMembership from "components/explorer/hooks/useMembership" import dynamic from "next/dynamic" import { StarHalf } from "phosphor-react" -import PointsRewardCard from "platforms/Points/PointsRewardCard" -import { TokenRewardCard } from "platforms/Token/TokenRewardCard" +import PointsRewardCard from "rewards/Points/PointsRewardCard" +import { TokenRewardCard } from "rewards/Token/TokenRewardCard" import { PlatformType } from "types" import useGuild from "../hooks/useGuild" import useGuildPermission from "../hooks/useGuildPermission" diff --git a/src/components/[guild]/AccessHub/components/AccessedGuildPlatformCard.tsx b/src/components/[guild]/AccessHub/components/AccessedGuildPlatformCard.tsx index d674f3135f..2d0a3800df 100644 --- a/src/components/[guild]/AccessHub/components/AccessedGuildPlatformCard.tsx +++ b/src/components/[guild]/AccessHub/components/AccessedGuildPlatformCard.tsx @@ -1,7 +1,7 @@ import PlatformCard from "components/[guild]/RolePlatforms/components/PlatformCard" import useGuild from "components/[guild]/hooks/useGuild" import useGuildPermission from "components/[guild]/hooks/useGuildPermission" -import rewards from "platforms/rewards" +import rewards from "rewards" import { GuildPlatform, PlatformName, PlatformType } from "types" import PlatformAccessButton from "./PlatformAccessButton" diff --git a/src/components/[guild]/AccessHub/components/PlatformAccessButton.tsx b/src/components/[guild]/AccessHub/components/PlatformAccessButton.tsx index 7019c0b7e8..159526070d 100644 --- a/src/components/[guild]/AccessHub/components/PlatformAccessButton.tsx +++ b/src/components/[guild]/AccessHub/components/PlatformAccessButton.tsx @@ -1,7 +1,7 @@ import { Icon } from "@chakra-ui/react" import Button from "components/common/Button" import { ArrowSquareOut } from "phosphor-react" -import rewards from "platforms/rewards" +import rewards from "rewards" import { GuildPlatform, PlatformType } from "types" import usePlatformAccessButton from "./usePlatformAccessButton" diff --git a/src/components/[guild]/AccessHub/components/RemovePlatformMenuItem.tsx b/src/components/[guild]/AccessHub/components/RemovePlatformMenuItem.tsx index 31492dd9b6..76d6fb918d 100644 --- a/src/components/[guild]/AccessHub/components/RemovePlatformMenuItem.tsx +++ b/src/components/[guild]/AccessHub/components/RemovePlatformMenuItem.tsx @@ -4,7 +4,7 @@ import { AlreadyGrantedAccessesWillRemainInfo } from "components/[guild]/RolePla import useGuild from "components/[guild]/hooks/useGuild" import ConfirmationAlert from "components/create-guild/Requirements/components/ConfirmationAlert" import { TrashSimple } from "phosphor-react" -import rewards from "platforms/rewards" +import rewards from "rewards" import { PlatformType } from "types" type Props = { diff --git a/src/components/[guild]/AccessHub/components/usePlatformAccessButton.tsx b/src/components/[guild]/AccessHub/components/usePlatformAccessButton.tsx index 0fa0ee2fee..9a0d840edf 100644 --- a/src/components/[guild]/AccessHub/components/usePlatformAccessButton.tsx +++ b/src/components/[guild]/AccessHub/components/usePlatformAccessButton.tsx @@ -2,7 +2,7 @@ import { ButtonProps, LinkProps } from "@chakra-ui/react" import useUser from "components/[guild]/hooks/useUser" import useConnectPlatform from "components/[guild]/JoinModal/hooks/useConnectPlatform" import useToast from "hooks/useToast" -import rewards from "platforms/rewards" +import rewards from "rewards" import { GuildPlatform, PlatformName, PlatformType } from "types" function sanitizeInviteLink(inviteLink: string) { diff --git a/src/components/[guild]/AccessHub/hooks/useEditGuildPlatform.ts b/src/components/[guild]/AccessHub/hooks/useEditGuildPlatform.ts index e674b56673..4b628a1c23 100644 --- a/src/components/[guild]/AccessHub/hooks/useEditGuildPlatform.ts +++ b/src/components/[guild]/AccessHub/hooks/useEditGuildPlatform.ts @@ -4,7 +4,7 @@ import useGuildPlatform from "components/[guild]/hooks/useGuildPlatform" import { useFetcherWithSign } from "hooks/useFetcherWithSign" import useShowErrorToast from "hooks/useShowErrorToast" import useSubmit from "hooks/useSubmit" -import { CAPACITY_TIME_PLATFORMS } from "platforms/rewards" +import { CAPACITY_TIME_PLATFORMS } from "rewards" import { GuildPlatform, PlatformName, PlatformType } from "types" type PartialGuildPlatform = Partial< diff --git a/src/components/[guild]/AddAndOrderRoles/components/NewRolePlatformCard.tsx b/src/components/[guild]/AddAndOrderRoles/components/NewRolePlatformCard.tsx index 080a0a887e..d4ebaecf7d 100644 --- a/src/components/[guild]/AddAndOrderRoles/components/NewRolePlatformCard.tsx +++ b/src/components/[guild]/AddAndOrderRoles/components/NewRolePlatformCard.tsx @@ -9,8 +9,8 @@ import SetVisibility from "components/[guild]/SetVisibility" import useVisibilityModalProps from "components/[guild]/SetVisibility/hooks/useVisibilityModalProps" import useGuild from "components/[guild]/hooks/useGuild" import Button from "components/common/Button" -import NftAvailabilityTags from "platforms/ContractCall/components/NftAvailabilityTags" -import rewards, { CAPACITY_TIME_PLATFORMS } from "platforms/rewards" +import NftAvailabilityTags from "rewards/ContractCall/components/NftAvailabilityTags" +import rewards, { CAPACITY_TIME_PLATFORMS } from "rewards" import { useFormContext, useWatch } from "react-hook-form" import { GuildPlatformWithOptionalId, diff --git a/src/components/[guild]/AddRewardButton/AddRewardButton.tsx b/src/components/[guild]/AddRewardButton/AddRewardButton.tsx index 789c533acd..00019fd2ab 100644 --- a/src/components/[guild]/AddRewardButton/AddRewardButton.tsx +++ b/src/components/[guild]/AddRewardButton/AddRewardButton.tsx @@ -6,8 +6,8 @@ import { Modal } from "components/common/Modal" import useShowErrorToast from "hooks/useShowErrorToast" import { atom, useAtomValue } from "jotai" import { Plus } from "phosphor-react" -import rewards, { modalSizeForPlatform } from "platforms/rewards" -import { RewardData } from "platforms/types" +import rewards, { modalSizeForPlatform } from "rewards" +import { RewardData } from "rewards/types" import { FormProvider, useForm, useWatch } from "react-hook-form" import { RoleFormType } from "types" import { AddRewardProvider, useAddRewardContext } from "../AddRewardContext" diff --git a/src/components/[guild]/AddRewardButton/SelectRolePanel.tsx b/src/components/[guild]/AddRewardButton/SelectRolePanel.tsx index 2a00365d84..fa1af10872 100644 --- a/src/components/[guild]/AddRewardButton/SelectRolePanel.tsx +++ b/src/components/[guild]/AddRewardButton/SelectRolePanel.tsx @@ -16,8 +16,8 @@ import { usePostHogContext } from "components/_app/PostHogProvider" import Button from "components/common/Button" import useCreateRRR, { SubmitData } from "hooks/useCreateRRR" import { ArrowLeft, Info } from "phosphor-react" -import SelectRoleOrSetRequirements from "platforms/components/SelectRoleOrSetRequirements" -import rewards, { CAPACITY_TIME_PLATFORMS } from "platforms/rewards" +import SelectRoleOrSetRequirements from "rewards/components/SelectRoleOrSetRequirements" +import rewards, { CAPACITY_TIME_PLATFORMS } from "rewards" import { useState } from "react" import { useFormContext, useWatch } from "react-hook-form" import { RoleTypeToAddTo, useAddRewardContext } from "../AddRewardContext" diff --git a/src/components/[guild]/JoinModal/JoinModal.tsx b/src/components/[guild]/JoinModal/JoinModal.tsx index 01a9c940dd..a8bfe03ce4 100644 --- a/src/components/[guild]/JoinModal/JoinModal.tsx +++ b/src/components/[guild]/JoinModal/JoinModal.tsx @@ -20,7 +20,7 @@ import DynamicDevTool from "components/create-guild/DynamicDevTool" import useShowErrorToast from "hooks/useShowErrorToast" import dynamic from "next/dynamic" import { ArrowRight } from "phosphor-react" -import rewards from "platforms/rewards" +import rewards from "rewards" import { ComponentType, useRef } from "react" import { FormProvider, useForm } from "react-hook-form" import { PlatformName, RequirementType } from "types" diff --git a/src/components/[guild]/JoinModal/components/ConnectPlatform.tsx b/src/components/[guild]/JoinModal/components/ConnectPlatform.tsx index 144c769682..92da363df5 100644 --- a/src/components/[guild]/JoinModal/components/ConnectPlatform.tsx +++ b/src/components/[guild]/JoinModal/components/ConnectPlatform.tsx @@ -3,7 +3,7 @@ import usePlatformsToReconnect from "components/[guild]/hooks/usePlatformsToReco import useUser from "components/[guild]/hooks/useUser" import useWeb3ConnectionManager from "components/_app/Web3ConnectionManager/hooks/useWeb3ConnectionManager" import Script from "next/script" -import rewards from "platforms/rewards" +import rewards from "rewards" import { useEffect } from "react" import { useFormContext } from "react-hook-form" import { PlatformName } from "types" diff --git a/src/components/[guild]/JoinModal/hooks/useConnectPlatform.ts b/src/components/[guild]/JoinModal/hooks/useConnectPlatform.ts index 554af12311..cdfa66dfb0 100644 --- a/src/components/[guild]/JoinModal/hooks/useConnectPlatform.ts +++ b/src/components/[guild]/JoinModal/hooks/useConnectPlatform.ts @@ -10,7 +10,7 @@ import { UseSubmitOptions } from "hooks/useSubmit/useSubmit" import useToast from "hooks/useToast" import { useSetAtom } from "jotai" import { OAuthResultParams } from "pages/oauth-result" -import rewards from "platforms/rewards" +import rewards from "rewards" import { useCallback, useMemo } from "react" import useSWR from "swr" import { PlatformName, PlatformType } from "types" diff --git a/src/components/[guild]/JoinModal/hooks/useMembershipUpdate.tsx b/src/components/[guild]/JoinModal/hooks/useMembershipUpdate.tsx index 9161d50bac..b7ac1af84f 100644 --- a/src/components/[guild]/JoinModal/hooks/useMembershipUpdate.tsx +++ b/src/components/[guild]/JoinModal/hooks/useMembershipUpdate.tsx @@ -8,7 +8,7 @@ import { useFetcherWithSign } from "hooks/useFetcherWithSign" import useSubmit from "hooks/useSubmit" import { UseSubmitOptions } from "hooks/useSubmit/useSubmit" import { atom, useAtom } from "jotai" -import useUsersPoints from "platforms/Points/useUsersPoints" +import useUsersPoints from "rewards/Points/useUsersPoints" import getGuildPlatformsOfRoles from "../utils/getGuildPlatformsOfRoles" import mapAccessJobState from "../utils/mapAccessJobState" import useActiveMembershipUpdate from "./useActiveMembershipUpdate" diff --git a/src/components/[guild]/JoinModal/utils/processConnectorError.ts b/src/components/[guild]/JoinModal/utils/processConnectorError.ts index 701c15b050..fea929baf6 100644 --- a/src/components/[guild]/JoinModal/utils/processConnectorError.ts +++ b/src/components/[guild]/JoinModal/utils/processConnectorError.ts @@ -1,4 +1,4 @@ -import rewards from "platforms/rewards" +import rewards from "rewards" import { PlatformType } from "types" import capitalize from "utils/capitalize" diff --git a/src/components/[guild]/Requirements/components/ConnectRequirementPlatformButton.tsx b/src/components/[guild]/Requirements/components/ConnectRequirementPlatformButton.tsx index 23f6671599..3c3aaa27bf 100644 --- a/src/components/[guild]/Requirements/components/ConnectRequirementPlatformButton.tsx +++ b/src/components/[guild]/Requirements/components/ConnectRequirementPlatformButton.tsx @@ -7,7 +7,7 @@ import { ConnectEmailButton } from "components/common/Layout/components/Account/ import { ConnectFarcasterButton } from "components/common/Layout/components/Account/components/AccountModal/components/SocialAccount/FarcasterProfile" import { useRoleMembership } from "components/explorer/hooks/useMembership" import useToast from "hooks/useToast" -import rewards from "platforms/rewards" +import rewards from "rewards" import REQUIREMENTS, { RequirementType } from "requirements" import { PlatformName } from "types" import { useRequirementContext } from "./RequirementContext" diff --git a/src/components/[guild]/RoleCard/RoleCard.tsx b/src/components/[guild]/RoleCard/RoleCard.tsx index 8f36dd5bee..2344c4ac8d 100644 --- a/src/components/[guild]/RoleCard/RoleCard.tsx +++ b/src/components/[guild]/RoleCard/RoleCard.tsx @@ -15,7 +15,7 @@ import useMembership, { useRoleMembership, } from "components/explorer/hooks/useMembership" import dynamic from "next/dynamic" -import rewards from "platforms/rewards" +import rewards from "rewards" import { memo, useEffect, useRef } from "react" import { PlatformType, Role } from "types" import RoleRequirements from "../Requirements" diff --git a/src/components/[guild]/RoleCard/components/DynamicReward/DynamicTag.tsx b/src/components/[guild]/RoleCard/components/DynamicReward/DynamicTag.tsx index 7da3442817..afe4d9aeb3 100644 --- a/src/components/[guild]/RoleCard/components/DynamicReward/DynamicTag.tsx +++ b/src/components/[guild]/RoleCard/components/DynamicReward/DynamicTag.tsx @@ -3,7 +3,7 @@ import { useRequirementHandlerContext } from "components/[guild]/RequirementHand import useGuildPermission from "components/[guild]/hooks/useGuildPermission" import useRequirements from "components/[guild]/hooks/useRequirements" import { Lightning, Warning } from "phosphor-react" -import DynamicRewardModal from "platforms/Token/DynamicRewardModal" +import DynamicRewardModal from "rewards/Token/DynamicRewardModal" import { Rest, RolePlatform } from "types" const DynamicTag = ({ diff --git a/src/components/[guild]/RoleCard/components/EditRole/components/ExistingRolePlatformCard.tsx b/src/components/[guild]/RoleCard/components/EditRole/components/ExistingRolePlatformCard.tsx index 8a4f48c786..4d35db3a4f 100644 --- a/src/components/[guild]/RoleCard/components/EditRole/components/ExistingRolePlatformCard.tsx +++ b/src/components/[guild]/RoleCard/components/EditRole/components/ExistingRolePlatformCard.tsx @@ -10,8 +10,8 @@ import SetVisibility from "components/[guild]/SetVisibility" import useVisibilityModalProps from "components/[guild]/SetVisibility/hooks/useVisibilityModalProps" import useGuild from "components/[guild]/hooks/useGuild" import Button from "components/common/Button" -import NftAvailabilityTags from "platforms/ContractCall/components/NftAvailabilityTags" -import rewards, { CAPACITY_TIME_PLATFORMS } from "platforms/rewards" +import NftAvailabilityTags from "rewards/ContractCall/components/NftAvailabilityTags" +import rewards, { CAPACITY_TIME_PLATFORMS } from "rewards" import { GuildPlatformWithOptionalId, PlatformName, diff --git a/src/components/[guild]/RoleCard/components/Reward.tsx b/src/components/[guild]/RoleCard/components/Reward.tsx index a59dc70791..34fd59e90e 100644 --- a/src/components/[guild]/RoleCard/components/Reward.tsx +++ b/src/components/[guild]/RoleCard/components/Reward.tsx @@ -22,8 +22,8 @@ import useMembership, { } from "components/explorer/hooks/useMembership" import { Transition, motion } from "framer-motion" import { ArrowSquareOut, LockSimple } from "phosphor-react" -import GoogleCardWarning from "platforms/Google/GoogleCardWarning" -import rewards from "platforms/rewards" +import GoogleCardWarning from "rewards/Google/GoogleCardWarning" +import rewards from "rewards" import { PropsWithChildren, ReactNode, useMemo, useState } from "react" import { GuildPlatform, PlatformType, Role, RolePlatform } from "types" import capitalize from "utils/capitalize" diff --git a/src/components/[guild]/RolePlatforms/components/AddRoleRewardModal/AddRoleRewardModal.tsx b/src/components/[guild]/RolePlatforms/components/AddRoleRewardModal/AddRoleRewardModal.tsx index f395b5a937..3dfdf103c2 100644 --- a/src/components/[guild]/RolePlatforms/components/AddRoleRewardModal/AddRoleRewardModal.tsx +++ b/src/components/[guild]/RolePlatforms/components/AddRoleRewardModal/AddRoleRewardModal.tsx @@ -3,10 +3,7 @@ import { useAddRewardDiscardAlert } from "components/[guild]/AddRewardButton/hoo import { useAddRewardContext } from "components/[guild]/AddRewardContext" import DiscardAlert from "components/common/DiscardAlert" import { Modal } from "components/common/Modal" -import rewards, { - AddRewardPanelProps, - modalSizeForPlatform, -} from "platforms/rewards" +import rewards, { AddRewardPanelProps, modalSizeForPlatform } from "rewards" import { useWatch } from "react-hook-form" import { RoleFormType } from "types" import SelectRewardPanel from "./SelectRewardPanel" diff --git a/src/components/[guild]/RolePlatforms/components/AddRoleRewardModal/DefaultAddRewardPanelWrapper.tsx b/src/components/[guild]/RolePlatforms/components/AddRoleRewardModal/DefaultAddRewardPanelWrapper.tsx index 54222aadcf..2058cb628e 100644 --- a/src/components/[guild]/RolePlatforms/components/AddRoleRewardModal/DefaultAddRewardPanelWrapper.tsx +++ b/src/components/[guild]/RolePlatforms/components/AddRoleRewardModal/DefaultAddRewardPanelWrapper.tsx @@ -9,7 +9,7 @@ import { } from "@chakra-ui/react" import { useAddRewardContext } from "components/[guild]/AddRewardContext" import { ArrowLeft } from "phosphor-react" -import rewards from "platforms/rewards" +import rewards from "rewards" import { ReactNode } from "react" export const DefaultAddRewardPanelWrapper = ({ diff --git a/src/components/[guild]/RolePlatforms/components/AddRoleRewardModal/components/AddContractCallPanel/AddContractCallPanel.tsx b/src/components/[guild]/RolePlatforms/components/AddRoleRewardModal/components/AddContractCallPanel/AddContractCallPanel.tsx index 1d98c12024..ed6171fd0b 100644 --- a/src/components/[guild]/RolePlatforms/components/AddRoleRewardModal/components/AddContractCallPanel/AddContractCallPanel.tsx +++ b/src/components/[guild]/RolePlatforms/components/AddRoleRewardModal/components/AddContractCallPanel/AddContractCallPanel.tsx @@ -1,4 +1,4 @@ -import { AddRewardPanelProps } from "platforms/rewards" +import { AddRewardPanelProps } from "rewards" import DefaultAddRewardPanelWrapper from "../../DefaultAddRewardPanelWrapper" import CreateNftForm from "./components/CreateNftForm" diff --git a/src/components/[guild]/RolePlatforms/components/AddRoleRewardModal/components/AddDiscordPanel.tsx b/src/components/[guild]/RolePlatforms/components/AddRoleRewardModal/components/AddDiscordPanel.tsx index c6602f19f0..f6c16a46a1 100644 --- a/src/components/[guild]/RolePlatforms/components/AddRoleRewardModal/components/AddDiscordPanel.tsx +++ b/src/components/[guild]/RolePlatforms/components/AddRoleRewardModal/components/AddDiscordPanel.tsx @@ -1,5 +1,5 @@ import DiscordGuildSetup from "components/common/DiscordGuildSetup" -import { AddRewardPanelProps } from "platforms/rewards" +import { AddRewardPanelProps } from "rewards" import { useWatch } from "react-hook-form" import { PlatformGuildData, PlatformType } from "types" import DefaultAddRewardPanelWrapper from "../DefaultAddRewardPanelWrapper" diff --git a/src/components/[guild]/RolePlatforms/components/AddRoleRewardModal/components/AddFormPanel/AddFormPanel.tsx b/src/components/[guild]/RolePlatforms/components/AddRoleRewardModal/components/AddFormPanel/AddFormPanel.tsx index ae90dafc9a..b6a22ae414 100644 --- a/src/components/[guild]/RolePlatforms/components/AddRoleRewardModal/components/AddFormPanel/AddFormPanel.tsx +++ b/src/components/[guild]/RolePlatforms/components/AddRoleRewardModal/components/AddFormPanel/AddFormPanel.tsx @@ -6,7 +6,7 @@ import useCreateForm from "components/[guild]/CreateFormModal/hooks/useCreateFor import { FormCreationSchema } from "components/[guild]/CreateFormModal/schemas" import Button from "components/common/Button" import { ArrowRight } from "phosphor-react" -import { AddRewardPanelProps } from "platforms/rewards" +import { AddRewardPanelProps } from "rewards" import { FormProvider, useForm, useWatch } from "react-hook-form" import { PlatformGuildData, PlatformType } from "types" import { uuidv7 } from "uuidv7" diff --git a/src/components/[guild]/RolePlatforms/components/AddRoleRewardModal/components/AddGatherPanel.tsx b/src/components/[guild]/RolePlatforms/components/AddRoleRewardModal/components/AddGatherPanel.tsx index 35b1f228cf..eeeb48d775 100644 --- a/src/components/[guild]/RolePlatforms/components/AddRoleRewardModal/components/AddGatherPanel.tsx +++ b/src/components/[guild]/RolePlatforms/components/AddRoleRewardModal/components/AddGatherPanel.tsx @@ -1,12 +1,12 @@ import { Button, Flex } from "@chakra-ui/react" import { useAddRewardDiscardAlert } from "components/[guild]/AddRewardButton/hooks/useAddRewardDiscardAlert" -import GatherForm from "platforms/Gather/GatherForm" -import useGatherAccess from "platforms/Gather/hooks/useGatherAccess" +import GatherForm from "rewards/Gather/GatherForm" +import useGatherAccess from "rewards/Gather/hooks/useGatherAccess" import { gatherSpaceIdToName, gatherSpaceUrlToSpaceId, -} from "platforms/Gather/useGatherCardProps" -import { AddRewardPanelProps } from "platforms/rewards" +} from "rewards/Gather/useGatherCardProps" +import { AddRewardPanelProps } from "rewards" import { FormProvider, useForm, useWatch } from "react-hook-form" import { PlatformType } from "types" import DefaultAddRewardPanelWrapper from "../DefaultAddRewardPanelWrapper" diff --git a/src/components/[guild]/RolePlatforms/components/AddRoleRewardModal/components/AddGithubPanel.tsx b/src/components/[guild]/RolePlatforms/components/AddRoleRewardModal/components/AddGithubPanel.tsx index 10113154be..d9f3594c9a 100644 --- a/src/components/[guild]/RolePlatforms/components/AddRoleRewardModal/components/AddGithubPanel.tsx +++ b/src/components/[guild]/RolePlatforms/components/AddRoleRewardModal/components/AddGithubPanel.tsx @@ -1,6 +1,6 @@ import { useAddRewardDiscardAlert } from "components/[guild]/AddRewardButton/hooks/useAddRewardDiscardAlert" import GitHubGuildSetup from "components/common/GitHubGuildSetup" -import { AddRewardPanelProps } from "platforms/rewards" +import { AddRewardPanelProps } from "rewards" import { FormProvider, useForm } from "react-hook-form" import { PlatformType } from "types" import DefaultAddRewardPanelWrapper from "../DefaultAddRewardPanelWrapper" diff --git a/src/components/[guild]/RolePlatforms/components/AddRoleRewardModal/components/AddGooglePanel.tsx b/src/components/[guild]/RolePlatforms/components/AddRoleRewardModal/components/AddGooglePanel.tsx index d76c2bfa4b..0b31153c17 100644 --- a/src/components/[guild]/RolePlatforms/components/AddRoleRewardModal/components/AddGooglePanel.tsx +++ b/src/components/[guild]/RolePlatforms/components/AddRoleRewardModal/components/AddGooglePanel.tsx @@ -1,6 +1,6 @@ import { useAddRewardDiscardAlert } from "components/[guild]/AddRewardButton/hooks/useAddRewardDiscardAlert" import GoogleGuildSetup from "components/common/GoogleGuildSetup" -import { AddRewardPanelProps } from "platforms/rewards" +import { AddRewardPanelProps } from "rewards" import { FormProvider, useForm } from "react-hook-form" import { PlatformType } from "types" import DefaultAddRewardPanelWrapper from "../DefaultAddRewardPanelWrapper" diff --git a/src/components/[guild]/RolePlatforms/components/AddRoleRewardModal/components/AddPoapPanel/AddPoapPanel.tsx b/src/components/[guild]/RolePlatforms/components/AddRoleRewardModal/components/AddPoapPanel/AddPoapPanel.tsx index 0f462ceac2..874d083279 100644 --- a/src/components/[guild]/RolePlatforms/components/AddRoleRewardModal/components/AddPoapPanel/AddPoapPanel.tsx +++ b/src/components/[guild]/RolePlatforms/components/AddRoleRewardModal/components/AddPoapPanel/AddPoapPanel.tsx @@ -18,7 +18,7 @@ import { useAddRewardDiscardAlert } from "components/[guild]/AddRewardButton/hoo import Button from "components/common/Button" import FormErrorMessage from "components/common/FormErrorMessage" import { Question } from "phosphor-react" -import rewards, { AddRewardPanelProps } from "platforms/rewards" +import rewards, { AddRewardPanelProps } from "rewards" import { useEffect } from "react" import { FormProvider, useController, useForm, useWatch } from "react-hook-form" import usePoapById from "requirements/Poap/hooks/usePoapById" diff --git a/src/components/[guild]/RolePlatforms/components/AddRoleRewardModal/components/AddPointsPanel/AddPointsPanel.tsx b/src/components/[guild]/RolePlatforms/components/AddRoleRewardModal/components/AddPointsPanel/AddPointsPanel.tsx index d72f8cbba8..2e082b703a 100644 --- a/src/components/[guild]/RolePlatforms/components/AddRoleRewardModal/components/AddPointsPanel/AddPointsPanel.tsx +++ b/src/components/[guild]/RolePlatforms/components/AddRoleRewardModal/components/AddPointsPanel/AddPointsPanel.tsx @@ -3,7 +3,7 @@ import { useAddRewardDiscardAlert } from "components/[guild]/AddRewardButton/hoo import { useAddRewardContext } from "components/[guild]/AddRewardContext" import useGuild from "components/[guild]/hooks/useGuild" import Button from "components/common/Button" -import { AddRewardPanelProps } from "platforms/rewards" +import { AddRewardPanelProps } from "rewards" import { FormProvider, useForm, useWatch } from "react-hook-form" import { PlatformGuildData, PlatformType } from "types" import DefaultAddRewardPanelWrapper from "../../DefaultAddRewardPanelWrapper" diff --git a/src/components/[guild]/RolePlatforms/components/AddRoleRewardModal/components/AddPointsPanel/components/AddNewPointsType.tsx b/src/components/[guild]/RolePlatforms/components/AddRoleRewardModal/components/AddPointsPanel/components/AddNewPointsType.tsx index 64968996a0..3e88d4bff2 100644 --- a/src/components/[guild]/RolePlatforms/components/AddRoleRewardModal/components/AddPointsPanel/components/AddNewPointsType.tsx +++ b/src/components/[guild]/RolePlatforms/components/AddRoleRewardModal/components/AddPointsPanel/components/AddNewPointsType.tsx @@ -1,6 +1,6 @@ import { Box, FormControl, HStack, Img, Input, Stack, Text } from "@chakra-ui/react" import FormErrorMessage from "components/common/FormErrorMessage" -import RewardImagePicker from "platforms/SecretText/SecretTextDataForm/components/RewardImagePicker" +import RewardImagePicker from "rewards/SecretText/SecretTextDataForm/components/RewardImagePicker" import { useFormContext } from "react-hook-form" import Star from "static/icons/star.svg" diff --git a/src/components/[guild]/RolePlatforms/components/AddRoleRewardModal/components/AddPolygonIDPanel.tsx b/src/components/[guild]/RolePlatforms/components/AddRoleRewardModal/components/AddPolygonIDPanel.tsx index 7e66799cd5..a9fe807a2c 100644 --- a/src/components/[guild]/RolePlatforms/components/AddRoleRewardModal/components/AddPolygonIDPanel.tsx +++ b/src/components/[guild]/RolePlatforms/components/AddRoleRewardModal/components/AddPolygonIDPanel.tsx @@ -1,5 +1,5 @@ import useGuild from "components/[guild]/hooks/useGuild" -import { AddRewardPanelProps } from "platforms/rewards" +import { AddRewardPanelProps } from "rewards" import { useEffect } from "react" import { PlatformType } from "types" diff --git a/src/components/[guild]/RolePlatforms/components/AddRoleRewardModal/components/AddSecretTextPanel.tsx b/src/components/[guild]/RolePlatforms/components/AddRoleRewardModal/components/AddSecretTextPanel.tsx index 44ab1c3dd1..2baae5a11e 100644 --- a/src/components/[guild]/RolePlatforms/components/AddRoleRewardModal/components/AddSecretTextPanel.tsx +++ b/src/components/[guild]/RolePlatforms/components/AddRoleRewardModal/components/AddSecretTextPanel.tsx @@ -4,11 +4,11 @@ import useUser from "components/[guild]/hooks/useUser" import Button from "components/common/Button" import SecretTextDataForm, { SecretTextRewardForm, -} from "platforms/SecretText/SecretTextDataForm/SecretTextDataForm" +} from "rewards/SecretText/SecretTextDataForm/SecretTextDataForm" import UniqueTextDataForm, { UniqueTextRewardForm, -} from "platforms/UniqueText/UniqueTextDataForm" -import { AddRewardPanelProps } from "platforms/rewards" +} from "rewards/UniqueText/UniqueTextDataForm" +import { AddRewardPanelProps } from "rewards" import { useState } from "react" import { FormProvider, useForm, useWatch } from "react-hook-form" import { PlatformGuildData, PlatformName, PlatformType } from "types" diff --git a/src/components/[guild]/RolePlatforms/components/AddRoleRewardModal/components/AddTelegramPanel.tsx b/src/components/[guild]/RolePlatforms/components/AddRoleRewardModal/components/AddTelegramPanel.tsx index 155acfb362..2011c62d01 100644 --- a/src/components/[guild]/RolePlatforms/components/AddRoleRewardModal/components/AddTelegramPanel.tsx +++ b/src/components/[guild]/RolePlatforms/components/AddRoleRewardModal/components/AddTelegramPanel.tsx @@ -1,7 +1,7 @@ import { useAddRewardDiscardAlert } from "components/[guild]/AddRewardButton/hooks/useAddRewardDiscardAlert" import Button from "components/common/Button" import TelegramGroup from "components/create-guild/TelegramGroup" -import { AddRewardPanelProps } from "platforms/rewards" +import { AddRewardPanelProps } from "rewards" import { FormProvider, useForm, useWatch } from "react-hook-form" import { PlatformType } from "types" import DefaultAddRewardPanelWrapper from "../DefaultAddRewardPanelWrapper" diff --git a/src/components/[guild]/RolePlatforms/components/AddRoleRewardModal/components/AddTokenPanel/AddTokenPanel.tsx b/src/components/[guild]/RolePlatforms/components/AddRoleRewardModal/components/AddTokenPanel/AddTokenPanel.tsx index 10853cbb62..168f0ef6c4 100644 --- a/src/components/[guild]/RolePlatforms/components/AddRoleRewardModal/components/AddTokenPanel/AddTokenPanel.tsx +++ b/src/components/[guild]/RolePlatforms/components/AddRoleRewardModal/components/AddTokenPanel/AddTokenPanel.tsx @@ -16,7 +16,7 @@ import { useTokenRewards } from "components/[guild]/AccessHub/hooks/useTokenRewa import { useAddRewardDiscardAlert } from "components/[guild]/AddRewardButton/hooks/useAddRewardDiscardAlert" import { useAddRewardContext } from "components/[guild]/AddRewardContext" import { useRequirementHandlerContext } from "components/[guild]/RequirementHandlerContext" -import { AddRewardPanelProps } from "platforms/rewards" +import { AddRewardPanelProps } from "rewards" import { FormProvider, useForm } from "react-hook-form" import { PlatformGuildData, PlatformType } from "types" import { ERC20_CONTRACTS } from "utils/guildCheckout/constants" diff --git a/src/components/[guild]/RolePlatforms/components/AddRoleRewardModal/components/AddTokenPanel/components/DynamicAmount.tsx b/src/components/[guild]/RolePlatforms/components/AddRoleRewardModal/components/AddTokenPanel/components/DynamicAmount.tsx index 81395f342b..f71b6f0f9f 100644 --- a/src/components/[guild]/RolePlatforms/components/AddRoleRewardModal/components/AddTokenPanel/components/DynamicAmount.tsx +++ b/src/components/[guild]/RolePlatforms/components/AddRoleRewardModal/components/AddTokenPanel/components/DynamicAmount.tsx @@ -3,7 +3,7 @@ import useGuildPlatform from "components/[guild]/hooks/useGuildPlatform" import OptionImage from "components/common/StyledSelect/components/CustomSelectOption/components/OptionImage" import useTokenData from "hooks/useTokenData" import { Star } from "phosphor-react" -import DynamicTypeForm from "platforms/Token/DynamicTypeForm" +import DynamicTypeForm from "rewards/Token/DynamicTypeForm" import { ReactNode } from "react" import { useWatch } from "react-hook-form" import Token from "static/icons/token.svg" diff --git a/src/components/[guild]/RolePlatforms/components/AddRoleRewardModal/components/AddTokenPanel/components/PoolStep.tsx b/src/components/[guild]/RolePlatforms/components/AddRoleRewardModal/components/AddTokenPanel/components/PoolStep.tsx index c0b3e6c37e..e2f948827b 100644 --- a/src/components/[guild]/RolePlatforms/components/AddRoleRewardModal/components/AddTokenPanel/components/PoolStep.tsx +++ b/src/components/[guild]/RolePlatforms/components/AddRoleRewardModal/components/AddTokenPanel/components/PoolStep.tsx @@ -17,7 +17,7 @@ import Button from "components/common/Button" import OptionImage from "components/common/StyledSelect/components/CustomSelectOption/components/OptionImage" import useTokenData from "hooks/useTokenData" import { useSetAtom } from "jotai" -import useRegisterPool from "platforms/Token/hooks/useRegisterPool" +import useRegisterPool from "rewards/Token/hooks/useRegisterPool" import { useEffect, useState } from "react" import { useController, useFormContext, useWatch } from "react-hook-form" import ControlledNumberInput from "requirements/WalletActivity/components/ControlledNumberInput" diff --git a/src/components/[guild]/RolePlatforms/components/AddRoleRewardModal/components/AddTokenPanel/components/TokenAmountStep.tsx b/src/components/[guild]/RolePlatforms/components/AddRoleRewardModal/components/AddTokenPanel/components/TokenAmountStep.tsx index 0906ecd620..df980b8e34 100644 --- a/src/components/[guild]/RolePlatforms/components/AddRoleRewardModal/components/AddTokenPanel/components/TokenAmountStep.tsx +++ b/src/components/[guild]/RolePlatforms/components/AddRoleRewardModal/components/AddTokenPanel/components/TokenAmountStep.tsx @@ -10,7 +10,7 @@ import { } from "@chakra-ui/react" import useGuild from "components/[guild]/hooks/useGuild" import Button from "components/common/Button" -import useRolePlatformsOfReward from "platforms/Token/hooks/useRolePlatformsOfReward" +import useRolePlatformsOfReward from "rewards/Token/hooks/useRolePlatformsOfReward" import { useEffect, useState } from "react" import { useFormContext, useWatch } from "react-hook-form" import { PlatformType } from "types" diff --git a/src/components/[guild]/RolePlatforms/components/AddRoleRewardModal/components/SelectExistingPlatform.tsx b/src/components/[guild]/RolePlatforms/components/AddRoleRewardModal/components/SelectExistingPlatform.tsx index ae1d1248f2..a71bbd6897 100644 --- a/src/components/[guild]/RolePlatforms/components/AddRoleRewardModal/components/SelectExistingPlatform.tsx +++ b/src/components/[guild]/RolePlatforms/components/AddRoleRewardModal/components/SelectExistingPlatform.tsx @@ -3,7 +3,7 @@ import { useAddRewardContext } from "components/[guild]/AddRewardContext" import LogicDivider from "components/[guild]/LogicDivider" import useGuild from "components/[guild]/hooks/useGuild" import { DISPLAY_CARD_INTERACTIVITY_STYLES } from "components/common/DisplayCard" -import rewards, { PlatformAsRewardRestrictions } from "platforms/rewards" +import rewards, { PlatformAsRewardRestrictions } from "rewards" import { useState } from "react" import { useWatch } from "react-hook-form" import { PlatformType, Requirement, RoleFormType, RolePlatform } from "types" diff --git a/src/components/[guild]/RolePlatforms/components/EditRewardAvailabilityModal/EditRewardAvailabilityModal.tsx b/src/components/[guild]/RolePlatforms/components/EditRewardAvailabilityModal/EditRewardAvailabilityModal.tsx index 2b699e71d5..6407dacc6c 100644 --- a/src/components/[guild]/RolePlatforms/components/EditRewardAvailabilityModal/EditRewardAvailabilityModal.tsx +++ b/src/components/[guild]/RolePlatforms/components/EditRewardAvailabilityModal/EditRewardAvailabilityModal.tsx @@ -17,7 +17,7 @@ import Button from "components/common/Button" import CheckboxColorCard from "components/common/CheckboxColorCard" import { Modal } from "components/common/Modal" import { Clock, Hash } from "phosphor-react" -import rewards from "platforms/rewards" +import rewards from "rewards" import { FormProvider, useController, useForm } from "react-hook-form" import { PlatformName } from "types" import StartEndTimeForm, { diff --git a/src/components/[guild]/RolePlatforms/components/EditRolePlatformModal.tsx b/src/components/[guild]/RolePlatforms/components/EditRolePlatformModal.tsx index bf3503b98b..3ecffb465e 100644 --- a/src/components/[guild]/RolePlatforms/components/EditRolePlatformModal.tsx +++ b/src/components/[guild]/RolePlatforms/components/EditRolePlatformModal.tsx @@ -8,7 +8,7 @@ import { } from "@chakra-ui/react" import Button from "components/common/Button" import { Modal } from "components/common/Modal" -import rewards from "platforms/rewards" +import rewards from "rewards" import { createContext, useContext, useRef, useState } from "react" import { FormProvider, useForm } from "react-hook-form" import { PlatformType, RoleFormType, RolePlatform } from "types" diff --git a/src/components/[guild]/RolePlatforms/components/PlatformCard/PlatformCard.tsx b/src/components/[guild]/RolePlatforms/components/PlatformCard/PlatformCard.tsx index 4391552c90..7f597a7705 100644 --- a/src/components/[guild]/RolePlatforms/components/PlatformCard/PlatformCard.tsx +++ b/src/components/[guild]/RolePlatforms/components/PlatformCard/PlatformCard.tsx @@ -1,5 +1,5 @@ import RewardCard from "components/common/RewardCard" -import rewards, { CardPropsHook } from "platforms/rewards" +import rewards, { CardPropsHook } from "rewards" import { PropsWithChildren } from "react" import { GuildPlatformWithOptionalId, Rest } from "types" diff --git a/src/components/[guild]/activity/ActivityLogAction/components/ActionLabel.tsx b/src/components/[guild]/activity/ActivityLogAction/components/ActionLabel.tsx index 741e7d4207..1a4fe221ed 100644 --- a/src/components/[guild]/activity/ActivityLogAction/components/ActionLabel.tsx +++ b/src/components/[guild]/activity/ActivityLogAction/components/ActionLabel.tsx @@ -1,6 +1,6 @@ import { Center, Icon, Text, Wrap } from "@chakra-ui/react" import { ArrowLeft, ArrowRight } from "phosphor-react" -import rewards from "platforms/rewards" +import rewards from "rewards" import capitalize from "utils/capitalize" import { useActivityLog } from "../../ActivityLogContext" import { ACTION } from "../../constants" diff --git a/src/components/[guild]/activity/ActivityLogAction/components/FormTag.tsx b/src/components/[guild]/activity/ActivityLogAction/components/FormTag.tsx index 7ca2c2d4bf..d9a767ba19 100644 --- a/src/components/[guild]/activity/ActivityLogAction/components/FormTag.tsx +++ b/src/components/[guild]/activity/ActivityLogAction/components/FormTag.tsx @@ -9,7 +9,7 @@ import { useColorModeValue, } from "@chakra-ui/react" import { DotsThreeVertical, IconProps } from "phosphor-react" -import rewards from "platforms/rewards" +import rewards from "rewards" import { ForwardRefExoticComponent, RefAttributes } from "react" import { useActivityLog } from "../../ActivityLogContext" import ClickableTagPopover from "./ClickableTagPopover" diff --git a/src/components/[guild]/activity/ActivityLogAction/components/IdentityTag.tsx b/src/components/[guild]/activity/ActivityLogAction/components/IdentityTag.tsx index 83cb889521..33c838f23a 100644 --- a/src/components/[guild]/activity/ActivityLogAction/components/IdentityTag.tsx +++ b/src/components/[guild]/activity/ActivityLogAction/components/IdentityTag.tsx @@ -1,6 +1,6 @@ import { Tag, TagLabel, TagLeftIcon } from "@chakra-ui/react" import { Wallet } from "phosphor-react" -import rewards from "platforms/rewards" +import rewards from "rewards" import { PlatformName } from "types" type Props = { diff --git a/src/components/[guild]/activity/ActivityLogAction/components/RewardTag.tsx b/src/components/[guild]/activity/ActivityLogAction/components/RewardTag.tsx index c18a5004b5..3915987870 100644 --- a/src/components/[guild]/activity/ActivityLogAction/components/RewardTag.tsx +++ b/src/components/[guild]/activity/ActivityLogAction/components/RewardTag.tsx @@ -7,7 +7,7 @@ import { TagRightIcon, } from "@chakra-ui/react" import { DotsThreeVertical, IconProps } from "phosphor-react" -import rewards from "platforms/rewards" +import rewards from "rewards" import { ForwardRefExoticComponent, RefAttributes } from "react" import { PlatformName, PlatformType } from "types" import { useActivityLog } from "../../ActivityLogContext" diff --git a/src/components/[guild]/claim-poap/components/ClaimPoapButton.tsx b/src/components/[guild]/claim-poap/components/ClaimPoapButton.tsx index b9c5d875c7..5f35b28b22 100644 --- a/src/components/[guild]/claim-poap/components/ClaimPoapButton.tsx +++ b/src/components/[guild]/claim-poap/components/ClaimPoapButton.tsx @@ -5,7 +5,7 @@ import { usePostHogContext } from "components/_app/PostHogProvider" import Button from "components/common/Button" import { useRoleMembership } from "components/explorer/hooks/useMembership" import useShowErrorToast from "hooks/useShowErrorToast" -import useClaimText from "platforms/SecretText/hooks/useClaimText" +import useClaimText from "rewards/SecretText/hooks/useClaimText" import { useAccount } from "wagmi" import { useClaimedReward } from "../../../../hooks/useClaimedReward" import { RolePlatform } from "../../../../types" diff --git a/src/components/[guild]/collect/components/EditNFTDescriptionModalButton.tsx b/src/components/[guild]/collect/components/EditNFTDescriptionModalButton.tsx index a246ca2b58..f069a1c235 100644 --- a/src/components/[guild]/collect/components/EditNFTDescriptionModalButton.tsx +++ b/src/components/[guild]/collect/components/EditNFTDescriptionModalButton.tsx @@ -1,6 +1,6 @@ import { Icon, IconButton, useDisclosure } from "@chakra-ui/react" import { PencilSimple } from "phosphor-react" -import EditNFTDescriptionModal from "platforms/ContractCall/components/EditNFTDescriptionModal" +import EditNFTDescriptionModal from "rewards/ContractCall/components/EditNFTDescriptionModal" import React from "react" import { GuildPlatform } from "types" diff --git a/src/components/[guild]/collect/components/EditNftButton.tsx b/src/components/[guild]/collect/components/EditNftButton.tsx index 6d1b2e34c6..285c3eabef 100644 --- a/src/components/[guild]/collect/components/EditNftButton.tsx +++ b/src/components/[guild]/collect/components/EditNftButton.tsx @@ -2,7 +2,7 @@ import { IconButton, useDisclosure } from "@chakra-ui/react" import { ContractCallFunction } from "components/[guild]/RolePlatforms/components/AddRoleRewardModal/components/AddContractCallPanel/components/CreateNftForm/hooks/useCreateNft" import { useThemeContext } from "components/[guild]/ThemeContext" import { GearSix } from "phosphor-react" -import EditNftModal from "platforms/ContractCall/components/EditNftModal" +import EditNftModal from "rewards/ContractCall/components/EditNftModal" import { useCollectNftContext } from "./CollectNftContext" const EditNftButton = () => { diff --git a/src/components/[guild]/crm/Identities.tsx b/src/components/[guild]/crm/Identities.tsx index 2d30f60936..27a65bf731 100644 --- a/src/components/[guild]/crm/Identities.tsx +++ b/src/components/[guild]/crm/Identities.tsx @@ -8,7 +8,7 @@ import { } from "@chakra-ui/react" import { useCardBg } from "components/common/Card" import { LockSimple, Wallet } from "phosphor-react" -import rewards from "platforms/rewards" +import rewards from "rewards" import { PropsWithChildren, memo } from "react" import { PlatformAccountDetails, PlatformType, Rest } from "types" import shortenHex from "utils/shortenHex" diff --git a/src/components/[guild]/forms/FillForm.tsx b/src/components/[guild]/forms/FillForm.tsx index 131fc22885..3b8effed0d 100644 --- a/src/components/[guild]/forms/FillForm.tsx +++ b/src/components/[guild]/forms/FillForm.tsx @@ -10,7 +10,7 @@ import useCustomPosthogEvents from "hooks/useCustomPosthogEvents" import useShowErrorToast from "hooks/useShowErrorToast" import { useSubmitWithSign } from "hooks/useSubmit" import useToast from "hooks/useToast" -import { useUserFormSubmission } from "platforms/Forms/hooks/useFormSubmissions" +import { useUserFormSubmission } from "rewards/Forms/hooks/useFormSubmissions" import { Controller, FormProvider, useForm } from "react-hook-form" import { PlatformType } from "types" import fetcher from "utils/fetcher" diff --git a/src/components/[guild]/forms/responses/FormResponsesTable.tsx b/src/components/[guild]/forms/responses/FormResponsesTable.tsx index dcbc712482..e783350266 100644 --- a/src/components/[guild]/forms/responses/FormResponsesTable.tsx +++ b/src/components/[guild]/forms/responses/FormResponsesTable.tsx @@ -18,7 +18,7 @@ import FormResponsesTbody from "components/[guild]/forms/responses/FormResponses import { useRouter } from "next/router" import useFormSubmissions, { FormSubmission, -} from "platforms/Forms/hooks/useFormSubmissions" +} from "rewards/Forms/hooks/useFormSubmissions" import { useEffect, useMemo, useRef, useState } from "react" const columnHelper = createColumnHelper() diff --git a/src/components/[guild]/forms/responses/FormResponsesTbody.tsx b/src/components/[guild]/forms/responses/FormResponsesTbody.tsx index 2185705773..4d49612c33 100644 --- a/src/components/[guild]/forms/responses/FormResponsesTbody.tsx +++ b/src/components/[guild]/forms/responses/FormResponsesTbody.tsx @@ -5,7 +5,7 @@ import { CrmRow, CrmSkeletonRow, } from "components/[guild]/crm/CRMTable/CrmTbody" -import { FormSubmission } from "platforms/Forms/hooks/useFormSubmissions" +import { FormSubmission } from "rewards/Forms/hooks/useFormSubmissions" import { useState } from "react" import ResponseModal from "./ResponseModal" diff --git a/src/components/[guild]/forms/responses/ResponseModal.tsx b/src/components/[guild]/forms/responses/ResponseModal.tsx index ed61e409ac..878ba854dd 100644 --- a/src/components/[guild]/forms/responses/ResponseModal.tsx +++ b/src/components/[guild]/forms/responses/ResponseModal.tsx @@ -23,7 +23,7 @@ import Button from "components/common/Button" import GuildAvatar from "components/common/GuildAvatar" import { Modal } from "components/common/Modal" import { CaretLeft, CaretRight } from "phosphor-react" -import { FormSubmission } from "platforms/Forms/hooks/useFormSubmissions" +import { FormSubmission } from "rewards/Forms/hooks/useFormSubmissions" import CollapsibleIdentityTags from "./CollapsibleIdentityTags" type Props = { diff --git a/src/components/[guild]/leaderboard/LeaderboardAirdropCard.tsx b/src/components/[guild]/leaderboard/LeaderboardAirdropCard.tsx index 6b9f8b4a21..14c8680497 100644 --- a/src/components/[guild]/leaderboard/LeaderboardAirdropCard.tsx +++ b/src/components/[guild]/leaderboard/LeaderboardAirdropCard.tsx @@ -14,13 +14,13 @@ import { import Card, { useCardBg } from "components/common/Card" import useMembership from "components/explorer/hooks/useMembership" import Image from "next/image" -import ClaimTokenButton from "platforms/Token/ClaimTokenButton" +import ClaimTokenButton from "rewards/Token/ClaimTokenButton" import { TokenRewardProvider, useTokenRewardContext, -} from "platforms/Token/TokenRewardContext" -import { useClaimableTokens } from "platforms/Token/hooks/useCalculateToken" -import useRolePlatformsOfReward from "platforms/Token/hooks/useRolePlatformsOfReward" +} from "rewards/Token/TokenRewardContext" +import { useClaimableTokens } from "rewards/Token/hooks/useCalculateToken" +import useRolePlatformsOfReward from "rewards/Token/hooks/useRolePlatformsOfReward" import { GuildPlatform } from "types" import { useTokenRewards } from "../AccessHub/hooks/useTokenRewards" import AvailabilityTags from "../RolePlatforms/components/PlatformCard/components/AvailabilityTags" diff --git a/src/components/_app/Web3ConnectionManager/components/PlatformMergeErrorAlert.tsx b/src/components/_app/Web3ConnectionManager/components/PlatformMergeErrorAlert.tsx index 778bc4a017..ee9a750adf 100644 --- a/src/components/_app/Web3ConnectionManager/components/PlatformMergeErrorAlert.tsx +++ b/src/components/_app/Web3ConnectionManager/components/PlatformMergeErrorAlert.tsx @@ -19,7 +19,7 @@ import { Alert } from "components/common/Modal" import useToast from "hooks/useToast" import { atom, useAtom } from "jotai" import { ArrowSquareOut } from "phosphor-react" -import rewards from "platforms/rewards" +import rewards from "rewards" import { useRef } from "react" import { PlatformName } from "types" import capitalize from "utils/capitalize" diff --git a/src/components/_app/Web3ConnectionManager/hooks/useConnectFromLocalStorage.ts b/src/components/_app/Web3ConnectionManager/hooks/useConnectFromLocalStorage.ts index 327d6a8dc3..212b0443bc 100644 --- a/src/components/_app/Web3ConnectionManager/hooks/useConnectFromLocalStorage.ts +++ b/src/components/_app/Web3ConnectionManager/hooks/useConnectFromLocalStorage.ts @@ -3,7 +3,7 @@ import { Message } from "components/[guild]/JoinModal/hooks/useOauthPopupWindow" import useUser, { useUserPublic } from "components/[guild]/hooks/useUser" import { usePostHogContext } from "components/_app/PostHogProvider" import useToast from "hooks/useToast" -import rewards from "platforms/rewards" +import rewards from "rewards" import { useEffect } from "react" const useConnectFromLocalStorage = () => { diff --git a/src/components/common/GoogleGuildSetup/components/GoogleDocCard.tsx b/src/components/common/GoogleGuildSetup/components/GoogleDocCard.tsx index 8e84d9c0bf..8f3a503e84 100644 --- a/src/components/common/GoogleGuildSetup/components/GoogleDocCard.tsx +++ b/src/components/common/GoogleGuildSetup/components/GoogleDocCard.tsx @@ -14,7 +14,7 @@ import CardMotionWrapper from "components/common/CardMotionWrapper" import OptionCard from "components/common/OptionCard" import { Gateables } from "hooks/useGateables" import NextLink from "next/link" -import { fileTypeNames } from "platforms/Google/useGoogleCardProps" +import { fileTypeNames } from "rewards/Google/useGoogleCardProps" import { PlatformType } from "types" type Props = { diff --git a/src/components/common/Layout/components/Account/components/AccountModal/components/AccountConnections.tsx b/src/components/common/Layout/components/Account/components/AccountModal/components/AccountConnections.tsx index 065bc5b7a3..a7b05b1de2 100644 --- a/src/components/common/Layout/components/Account/components/AccountModal/components/AccountConnections.tsx +++ b/src/components/common/Layout/components/Account/components/AccountModal/components/AccountConnections.tsx @@ -18,7 +18,7 @@ import { import useUser from "components/[guild]/hooks/useUser" import { SectionProps } from "components/common/Section" import { Question } from "phosphor-react" -import rewards from "platforms/rewards" +import rewards from "rewards" import { PropsWithChildren, useMemo } from "react" import { PlatformName } from "types" import useDelegateVaults from "../../delegate/useDelegateVaults" diff --git a/src/components/common/Layout/components/Account/components/AccountModal/components/SocialAccount/EmailAddress.tsx b/src/components/common/Layout/components/Account/components/AccountModal/components/SocialAccount/EmailAddress.tsx index 22b1aae3d5..502f542c7e 100644 --- a/src/components/common/Layout/components/Account/components/AccountModal/components/SocialAccount/EmailAddress.tsx +++ b/src/components/common/Layout/components/Account/components/AccountModal/components/SocialAccount/EmailAddress.tsx @@ -27,7 +27,7 @@ import { Modal } from "components/common/Modal" import { SignedValidation, useSubmitWithSign } from "hooks/useSubmit" import useToast from "hooks/useToast" import { PencilSimple } from "phosphor-react" -import rewards from "platforms/rewards" +import rewards from "rewards" import { useEffect, useRef, useState } from "react" import { useController, useForm, useWatch } from "react-hook-form" import fetcher from "utils/fetcher" diff --git a/src/components/common/Layout/components/Account/components/AccountModal/components/SocialAccount/FarcasterProfile.tsx b/src/components/common/Layout/components/Account/components/AccountModal/components/SocialAccount/FarcasterProfile.tsx index 8eb4025bec..13a0d10c39 100644 --- a/src/components/common/Layout/components/Account/components/AccountModal/components/SocialAccount/FarcasterProfile.tsx +++ b/src/components/common/Layout/components/Account/components/AccountModal/components/SocialAccount/FarcasterProfile.tsx @@ -30,7 +30,7 @@ import { useFetcherWithSign } from "hooks/useFetcherWithSign" import useSubmit, { SignedValidation, useSubmitWithSign } from "hooks/useSubmit" import useToast from "hooks/useToast" import { ArrowCounterClockwise, DeviceMobileCamera } from "phosphor-react" -import rewards from "platforms/rewards" +import rewards from "rewards" import { QRCodeSVG } from "qrcode.react" import { useCallback, useEffect, useState } from "react" import { isMobile } from "react-device-detect" diff --git a/src/components/common/Layout/components/Account/components/AccountModal/components/SocialAccount/SocialAccount.tsx b/src/components/common/Layout/components/Account/components/AccountModal/components/SocialAccount/SocialAccount.tsx index 92360b6f11..2cd09e6579 100644 --- a/src/components/common/Layout/components/Account/components/AccountModal/components/SocialAccount/SocialAccount.tsx +++ b/src/components/common/Layout/components/Account/components/AccountModal/components/SocialAccount/SocialAccount.tsx @@ -7,7 +7,7 @@ import { HStack, useDisclosure } from "@chakra-ui/react" import useMembershipUpdate from "components/[guild]/JoinModal/hooks/useMembershipUpdate" import useUser from "components/[guild]/hooks/useUser" import useMembership from "components/explorer/hooks/useMembership" -import rewards from "platforms/rewards" +import rewards from "rewards" import { memo } from "react" import useDisconnect from "../../hooks/useDisconnect" import DisconnectAccountButton from "./components/DisconnectAccountButton" diff --git a/src/components/common/Layout/components/Account/components/AccountModal/components/SocialAccount/components/SocialAccountUI.tsx b/src/components/common/Layout/components/Account/components/AccountModal/components/SocialAccount/components/SocialAccountUI.tsx index d2c8f55fe7..293dfdabdb 100644 --- a/src/components/common/Layout/components/Account/components/AccountModal/components/SocialAccount/components/SocialAccountUI.tsx +++ b/src/components/common/Layout/components/Account/components/AccountModal/components/SocialAccount/components/SocialAccountUI.tsx @@ -7,7 +7,7 @@ import { useColorModeValue, } from "@chakra-ui/react" import { motion } from "framer-motion" -import rewards from "platforms/rewards" +import rewards from "rewards" import { PropsWithChildren } from "react" import { PlatformName } from "types" diff --git a/src/components/common/ReconnectAlert.tsx b/src/components/common/ReconnectAlert.tsx index 1180bb59fe..5f1a7fbd28 100644 --- a/src/components/common/ReconnectAlert.tsx +++ b/src/components/common/ReconnectAlert.tsx @@ -1,7 +1,7 @@ import { Alert, AlertDescription, AlertIcon, HStack, Text } from "@chakra-ui/react" import useConnectPlatform from "components/[guild]/JoinModal/hooks/useConnectPlatform" import useGateables from "hooks/useGateables" -import rewards from "platforms/rewards" +import rewards from "rewards" import { PlatformName, PlatformType } from "types" import Button from "./Button" diff --git a/src/components/create-guild/PlatformsGrid/PlatformsGrid.tsx b/src/components/create-guild/PlatformsGrid/PlatformsGrid.tsx index 9fb6289451..0aba17dfd6 100644 --- a/src/components/create-guild/PlatformsGrid/PlatformsGrid.tsx +++ b/src/components/create-guild/PlatformsGrid/PlatformsGrid.tsx @@ -1,6 +1,6 @@ import { Box, Heading, SimpleGrid, Stack, StackProps } from "@chakra-ui/react" import useGuild from "components/[guild]/hooks/useGuild" -import rewards from "platforms/rewards" +import rewards from "rewards" import { PlatformName, PlatformType } from "types" import PlatformSelectButton from "./components/PlatformSelectButton" diff --git a/src/components/create-guild/PlatformsGrid/components/PlatformSelectButton.tsx b/src/components/create-guild/PlatformsGrid/components/PlatformSelectButton.tsx index 7735e2e3b2..d110d40244 100644 --- a/src/components/create-guild/PlatformsGrid/components/PlatformSelectButton.tsx +++ b/src/components/create-guild/PlatformsGrid/components/PlatformSelectButton.tsx @@ -18,7 +18,7 @@ import { useSetAtom } from "jotai" import dynamic from "next/dynamic" import Image from "next/image" import { ArrowSquareIn, CaretRight, IconProps } from "phosphor-react" -import rewards from "platforms/rewards" +import rewards from "rewards" import { ComponentType, RefAttributes, useMemo } from "react" import { PlatformName, Rest } from "types" diff --git a/src/hooks/useOAuthResultToast.ts b/src/hooks/useOAuthResultToast.ts index f819601864..fe3877d913 100644 --- a/src/hooks/useOAuthResultToast.ts +++ b/src/hooks/useOAuthResultToast.ts @@ -1,7 +1,7 @@ import { platformMergeAlertAtom } from "components/_app/Web3ConnectionManager/components/PlatformMergeErrorAlert" import { useSetAtom } from "jotai" import { useRouter } from "next/router" -import rewards from "platforms/rewards" +import rewards from "rewards" import { useEffect } from "react" import { PlatformName } from "types" import useToast from "./useToast" diff --git a/src/pages/[guild]/[group].tsx b/src/pages/[guild]/[group].tsx index 0120913371..c1d51fb024 100644 --- a/src/pages/[guild]/[group].tsx +++ b/src/pages/[guild]/[group].tsx @@ -18,7 +18,7 @@ import useMembership from "components/explorer/hooks/useMembership" import { GetStaticPaths, GetStaticProps } from "next" import dynamic from "next/dynamic" import Head from "next/head" -import { MintPolygonIDProofProvider } from "platforms/PolygonID/components/MintPolygonIDProofProvider" +import { MintPolygonIDProofProvider } from "rewards/PolygonID/components/MintPolygonIDProofProvider" import { useState } from "react" import { SWRConfig } from "swr" import { Guild } from "types" diff --git a/src/pages/[guild]/index.tsx b/src/pages/[guild]/index.tsx index e602d41dff..5293e2beb2 100644 --- a/src/pages/[guild]/index.tsx +++ b/src/pages/[guild]/index.tsx @@ -44,7 +44,7 @@ import dynamic from "next/dynamic" import Head from "next/head" import ErrorPage from "pages/_error" import { Info, Users } from "phosphor-react" -import { MintPolygonIDProofProvider } from "platforms/PolygonID/components/MintPolygonIDProofProvider" +import { MintPolygonIDProofProvider } from "rewards/PolygonID/components/MintPolygonIDProofProvider" import { useEffect } from "react" import { SWRConfig } from "swr" import { Guild, SocialLinkKey } from "types" diff --git a/src/pages/oauth-result.tsx b/src/pages/oauth-result.tsx index 8eaaa01b30..85240200cc 100644 --- a/src/pages/oauth-result.tsx +++ b/src/pages/oauth-result.tsx @@ -4,7 +4,7 @@ import { Center, Heading, Text } from "@chakra-ui/react" import { PlatformName } from "@guildxyz/types" import { GetServerSideProps, NextPage } from "next" import { useRouter } from "next/router" -import rewards from "platforms/rewards" +import rewards from "rewards" import { useEffect, useState } from "react" export type OAuthResultParams = diff --git a/src/platforms/rewards.ts b/src/platforms/rewards.ts deleted file mode 100644 index c7d1defdff..0000000000 --- a/src/platforms/rewards.ts +++ /dev/null @@ -1,147 +0,0 @@ -import contractCallReward from "platforms/ContractCall" -import discordReward from "platforms/Discord" -import emailReward from "platforms/Email" -import farcasterReward from "platforms/Farcaster" -import formReward from "platforms/Forms" -import gatherTownReward from "platforms/Gather" -import githubReward from "platforms/Github" -import googleReward from "platforms/Google" -import poapReward from "platforms/Poap" -import pointsReward from "platforms/Points" -import polygonIdReward from "platforms/PolygonID" -import textReward from "platforms/SecretText" -import telegramReward from "platforms/Telegram" -import tokenReward from "platforms/Token" -import twitterRewardV1, { twitterReward } from "platforms/Twitter" -import uniqueTextReward from "platforms/UniqueText" - -export default { - TWITTER_V1: twitterRewardV1, - TWITTER: twitterReward, - EMAIL: emailReward, - TELEGRAM: telegramReward, - ERC20: tokenReward, - GATHER_TOWN: gatherTownReward, - FORM: formReward, - POINTS: pointsReward, - POLYGON_ID: polygonIdReward, - UNIQUE_TEXT: uniqueTextReward, - TEXT: textReward, - CONTRACT_CALL: contractCallReward, - GOOGLE: googleReward, - DISCORD: discordReward, - GITHUB: githubReward, - POAP: poapReward, - FARCASTER: farcasterReward, -} as const satisfies Partial - -// TODO: resolve duplication by renaming rewards.ts to index.ts and updating imports - -import type { PlatformName, Requirement } from "types" - -/** - * "CONTRACT_CALL" is left out intentionally, because we store its capacity in the - * contract, so it isn't handled the same way as other platforms with capacity/time - */ -export const CAPACITY_TIME_PLATFORMS: PlatformName[] = [ - "TEXT", - "UNIQUE_TEXT", - "POAP", - "GATHER_TOWN", - "ERC20", -] as const - -import type { ThemingProps } from "@chakra-ui/react" -import type { RewardProps } from "components/[guild]/RoleCard/components/Reward" -import type { IconProps } from "phosphor-react" -import type { - ComponentType, - ForwardRefExoticComponent, - PropsWithChildren, - RefAttributes, -} from "react" -import type { GuildPlatformWithOptionalId, RoleFormType } from "types" - -export type CardSettingsComponent = () => JSX.Element - -export enum PlatformAsRewardRestrictions { - /** - * @example - * Twitter - */ - NOT_APPLICABLE, - /** - * @example - * Telegram - */ - SINGLE_ROLE, - /** - * @example - * Discord - */ - MULTIPLE_ROLES, -} - -export type RewardData = { - icon: ForwardRefExoticComponent> - imageUrl?: string - name: string - colorScheme: ThemingProps["colorScheme"] - gatedEntity: string - cardPropsHook?: CardPropsHook - /** - * True when the AddRewardPanel just automatically adds the platform without any - * user input - */ - autoRewardSetup?: boolean - cardSettingsComponent?: CardSettingsComponent - cardMenuComponent?: (props) => JSX.Element - cardWarningComponent?: (props) => JSX.Element - cardButton?: (props) => JSX.Element - AddRewardPanel?: ComponentType - RewardPreview?: ComponentType> - RoleCardComponent?: ComponentType - isPlatform?: boolean - asRewardRestriction: PlatformAsRewardRestrictions -} - -export type Rewards = Readonly> - -export type AddRewardPanelProps = { - onAdd: ( - data: NonNullable[number] & { - requirements?: Requirement[] - roleName?: string - } - ) => void - onCancel?: () => void - skipSettings?: boolean -} - -export type CardPropsHook = (guildPlatform: GuildPlatformWithOptionalId) => { - type: PlatformName - name: string - image?: string | JSX.Element - info?: string | JSX.Element - link?: string - shouldHide?: boolean -} - -export const modalSizeForPlatform = (platform: PlatformName) => { - switch (platform) { - case "ERC20": - case "POINTS": - return "xl" - case "UNIQUE_TEXT": - case "TEXT": - return "2xl" - case "POAP": - return "lg" - case "TELEGRAM": - return "md" - case "CONTRACT_CALL": - return "4xl" - default: - return "3xl" - } -} diff --git a/src/requirements/Form/FormRequirement.tsx b/src/requirements/Form/FormRequirement.tsx index 66362291fa..13fd8b7ff5 100644 --- a/src/requirements/Form/FormRequirement.tsx +++ b/src/requirements/Form/FormRequirement.tsx @@ -6,8 +6,8 @@ import Requirement, { import { useRequirementContext } from "components/[guild]/Requirements/components/RequirementContext" import useGuild from "components/[guild]/hooks/useGuild" import { useGuildForm } from "components/[guild]/hooks/useGuildForms" -import { useUserFormSubmission } from "platforms/Forms/hooks/useFormSubmissions" -import rewards from "platforms/rewards" +import { useUserFormSubmission } from "rewards/Forms/hooks/useFormSubmissions" +import rewards from "rewards" const FormRequirement = (props: RequirementProps) => { const { urlName } = useGuild() diff --git a/src/requirements/Form/components/CreateFormModal.tsx b/src/requirements/Form/components/CreateFormModal.tsx index adbb6603af..a1fed720b8 100644 --- a/src/requirements/Form/components/CreateFormModal.tsx +++ b/src/requirements/Form/components/CreateFormModal.tsx @@ -1,6 +1,6 @@ import { ModalOverlay } from "@chakra-ui/react" import { Modal } from "components/common/Modal" -import rewards, { modalSizeForPlatform } from "platforms/rewards" +import rewards, { modalSizeForPlatform } from "rewards" const CreateFormModal = ({ isOpen, onClose, onAdd }) => ( import("platforms/components/ContractCallPreview"), { + RewardPreview: dynamic(() => import("rewards/components/ContractCallPreview"), { ssr: false, loading: LoadingRewardPreview, }), RoleCardComponent: dynamic( - () => import("platforms/ContractCall/ContractCallReward"), + () => import("rewards/ContractCall/ContractCallReward"), { ssr: false, } diff --git a/src/platforms/ContractCall/useContractCallCardProps.tsx b/src/rewards/ContractCall/useContractCallCardProps.tsx similarity index 100% rename from src/platforms/ContractCall/useContractCallCardProps.tsx rename to src/rewards/ContractCall/useContractCallCardProps.tsx diff --git a/src/platforms/Discord/DiscordCardMenu/DiscordCardMenu.tsx b/src/rewards/Discord/DiscordCardMenu/DiscordCardMenu.tsx similarity index 100% rename from src/platforms/Discord/DiscordCardMenu/DiscordCardMenu.tsx rename to src/rewards/Discord/DiscordCardMenu/DiscordCardMenu.tsx diff --git a/src/platforms/Discord/DiscordCardMenu/components/DiscordCaptchaSwitch.tsx b/src/rewards/Discord/DiscordCardMenu/components/DiscordCaptchaSwitch.tsx similarity index 100% rename from src/platforms/Discord/DiscordCardMenu/components/DiscordCaptchaSwitch.tsx rename to src/rewards/Discord/DiscordCardMenu/components/DiscordCaptchaSwitch.tsx diff --git a/src/platforms/Discord/DiscordCardMenu/components/DiscordRewardSettings.tsx.tsx b/src/rewards/Discord/DiscordCardMenu/components/DiscordRewardSettings.tsx.tsx similarity index 100% rename from src/platforms/Discord/DiscordCardMenu/components/DiscordRewardSettings.tsx.tsx rename to src/rewards/Discord/DiscordCardMenu/components/DiscordRewardSettings.tsx.tsx diff --git a/src/platforms/Discord/DiscordCardMenu/index.ts b/src/rewards/Discord/DiscordCardMenu/index.ts similarity index 100% rename from src/platforms/Discord/DiscordCardMenu/index.ts rename to src/rewards/Discord/DiscordCardMenu/index.ts diff --git a/src/platforms/Discord/DiscordCardSettings/DiscordCardSettings.tsx b/src/rewards/Discord/DiscordCardSettings/DiscordCardSettings.tsx similarity index 100% rename from src/platforms/Discord/DiscordCardSettings/DiscordCardSettings.tsx rename to src/rewards/Discord/DiscordCardSettings/DiscordCardSettings.tsx diff --git a/src/platforms/Discord/DiscordCardSettings/components/GuildifyExistingRole.tsx b/src/rewards/Discord/DiscordCardSettings/components/GuildifyExistingRole.tsx similarity index 100% rename from src/platforms/Discord/DiscordCardSettings/components/GuildifyExistingRole.tsx rename to src/rewards/Discord/DiscordCardSettings/components/GuildifyExistingRole.tsx diff --git a/src/platforms/Discord/DiscordCardSettings/index.ts b/src/rewards/Discord/DiscordCardSettings/index.ts similarity index 100% rename from src/platforms/Discord/DiscordCardSettings/index.ts rename to src/rewards/Discord/DiscordCardSettings/index.ts diff --git a/src/platforms/Discord/index.ts b/src/rewards/Discord/index.ts similarity index 73% rename from src/platforms/Discord/index.ts rename to src/rewards/Discord/index.ts index ee73b2add9..a977259d6b 100644 --- a/src/platforms/Discord/index.ts +++ b/src/rewards/Discord/index.ts @@ -2,10 +2,10 @@ import { DiscordLogo } from "phosphor-react" import useDiscordCardProps from "./useDiscordCardProps" import DiscordCardSettings from "./DiscordCardSettings" import DiscordCardMenu from "./DiscordCardMenu" -import { PlatformAsRewardRestrictions, RewardData } from "platforms/types" +import { PlatformAsRewardRestrictions, RewardData } from "rewards/types" import dynamic from "next/dynamic" -import { AddRewardPanelLoadingSpinner } from "platforms/components/AddRewardPanelLoadingSpinner" -import LoadingRewardPreview from "platforms/components/LoadingRewardPreview" +import { AddRewardPanelLoadingSpinner } from "rewards/components/AddRewardPanelLoadingSpinner" +import LoadingRewardPreview from "rewards/components/LoadingRewardPreview" export default { icon: DiscordLogo, @@ -28,7 +28,7 @@ export default { loading: AddRewardPanelLoadingSpinner, } ), - RewardPreview: dynamic(() => import("platforms/components/DiscordPreview"), { + RewardPreview: dynamic(() => import("rewards/components/DiscordPreview"), { ssr: false, loading: LoadingRewardPreview, }), diff --git a/src/platforms/Discord/useDiscordCardProps.tsx b/src/rewards/Discord/useDiscordCardProps.tsx similarity index 100% rename from src/platforms/Discord/useDiscordCardProps.tsx rename to src/rewards/Discord/useDiscordCardProps.tsx diff --git a/src/platforms/Email/index.ts b/src/rewards/Email/index.ts similarity index 78% rename from src/platforms/Email/index.ts rename to src/rewards/Email/index.ts index 8cbdc4359c..c1cfd4fe93 100644 --- a/src/platforms/Email/index.ts +++ b/src/rewards/Email/index.ts @@ -1,5 +1,5 @@ import { EnvelopeSimple } from "phosphor-react" -import { PlatformAsRewardRestrictions, RewardData } from "platforms/types" +import { PlatformAsRewardRestrictions, RewardData } from "rewards/types" export default { icon: EnvelopeSimple, diff --git a/src/platforms/Farcaster/index.ts b/src/rewards/Farcaster/index.ts similarity index 82% rename from src/platforms/Farcaster/index.ts rename to src/rewards/Farcaster/index.ts index 0b7126afe1..286eebb885 100644 --- a/src/platforms/Farcaster/index.ts +++ b/src/rewards/Farcaster/index.ts @@ -1,4 +1,4 @@ -import { PlatformAsRewardRestrictions, RewardData } from "platforms/types" +import { PlatformAsRewardRestrictions, RewardData } from "rewards/types" import FarcasterIcon from "static/socialIcons/farcaster.svg" export default { diff --git a/src/platforms/Forms/EditFormModal.tsx b/src/rewards/Forms/EditFormModal.tsx similarity index 100% rename from src/platforms/Forms/EditFormModal.tsx rename to src/rewards/Forms/EditFormModal.tsx diff --git a/src/platforms/Forms/FormCardLinkButton.tsx b/src/rewards/Forms/FormCardLinkButton.tsx similarity index 97% rename from src/platforms/Forms/FormCardLinkButton.tsx rename to src/rewards/Forms/FormCardLinkButton.tsx index 4436751002..6b95c9b60c 100644 --- a/src/platforms/Forms/FormCardLinkButton.tsx +++ b/src/rewards/Forms/FormCardLinkButton.tsx @@ -5,7 +5,7 @@ import Button from "components/common/Button" import { LinkButton } from "components/common/LinkMenuItem" import Link from "next/link" import { Check } from "phosphor-react" -import rewards from "platforms/rewards" +import rewards from "rewards" import { GuildPlatform } from "types" import { useUserFormSubmission } from "./hooks/useFormSubmissions" diff --git a/src/platforms/Forms/FormCardMenu.tsx b/src/rewards/Forms/FormCardMenu.tsx similarity index 100% rename from src/platforms/Forms/FormCardMenu.tsx rename to src/rewards/Forms/FormCardMenu.tsx diff --git a/src/platforms/Forms/hooks/useEditForm.tsx b/src/rewards/Forms/hooks/useEditForm.tsx similarity index 100% rename from src/platforms/Forms/hooks/useEditForm.tsx rename to src/rewards/Forms/hooks/useEditForm.tsx diff --git a/src/platforms/Forms/hooks/useFormSubmissions.tsx b/src/rewards/Forms/hooks/useFormSubmissions.tsx similarity index 100% rename from src/platforms/Forms/hooks/useFormSubmissions.tsx rename to src/rewards/Forms/hooks/useFormSubmissions.tsx diff --git a/src/platforms/Forms/index.ts b/src/rewards/Forms/index.ts similarity index 67% rename from src/platforms/Forms/index.ts rename to src/rewards/Forms/index.ts index 4af52e3553..29a5daed91 100644 --- a/src/platforms/Forms/index.ts +++ b/src/rewards/Forms/index.ts @@ -1,11 +1,11 @@ import { PencilSimpleLine } from "phosphor-react" -import { PlatformAsRewardRestrictions, RewardData } from "platforms/types" +import { PlatformAsRewardRestrictions, RewardData } from "rewards/types" import useFormCardProps from "./useFormCardProps" import FormCardLinkButton from "./FormCardLinkButton" import FormCardMenu from "./FormCardMenu" import dynamic from "next/dynamic" -import { AddRewardPanelLoadingSpinner } from "platforms/components/AddRewardPanelLoadingSpinner" -import LoadingRewardPreview from "platforms/components/LoadingRewardPreview" +import { AddRewardPanelLoadingSpinner } from "rewards/components/AddRewardPanelLoadingSpinner" +import LoadingRewardPreview from "rewards/components/LoadingRewardPreview" export default { icon: PencilSimpleLine, @@ -16,7 +16,7 @@ export default { cardPropsHook: useFormCardProps, cardButton: FormCardLinkButton, cardMenuComponent: FormCardMenu, - RoleCardComponent: dynamic(() => import("platforms/components/FormReward"), { + RoleCardComponent: dynamic(() => import("rewards/components/FormReward"), { ssr: false, }), AddRewardPanel: dynamic( @@ -29,7 +29,7 @@ export default { loading: AddRewardPanelLoadingSpinner, } ), - RewardPreview: dynamic(() => import("platforms/components/FormPreview"), { + RewardPreview: dynamic(() => import("rewards/components/FormPreview"), { ssr: false, loading: LoadingRewardPreview, }), diff --git a/src/platforms/Forms/useFormCardProps.tsx b/src/rewards/Forms/useFormCardProps.tsx similarity index 97% rename from src/platforms/Forms/useFormCardProps.tsx rename to src/rewards/Forms/useFormCardProps.tsx index 973a65c8df..1cf2bded61 100644 --- a/src/platforms/Forms/useFormCardProps.tsx +++ b/src/rewards/Forms/useFormCardProps.tsx @@ -7,7 +7,7 @@ import { } from "@chakra-ui/react" import { useGuildForm } from "components/[guild]/hooks/useGuildForms" import useGuildPermission from "components/[guild]/hooks/useGuildPermission" -import rewards from "platforms/rewards" +import rewards from "rewards" import { GuildPlatformWithOptionalId, PlatformName } from "types" import pluralize from "utils/pluralize" import { useUserFormSubmission } from "./hooks/useFormSubmissions" diff --git a/src/platforms/Gather/ClaimGatherModal.tsx b/src/rewards/Gather/ClaimGatherModal.tsx similarity index 100% rename from src/platforms/Gather/ClaimGatherModal.tsx rename to src/rewards/Gather/ClaimGatherModal.tsx diff --git a/src/platforms/Gather/EditGatherModal.tsx b/src/rewards/Gather/EditGatherModal.tsx similarity index 100% rename from src/platforms/Gather/EditGatherModal.tsx rename to src/rewards/Gather/EditGatherModal.tsx diff --git a/src/platforms/Gather/GatherCardButton.tsx b/src/rewards/Gather/GatherCardButton.tsx similarity index 96% rename from src/platforms/Gather/GatherCardButton.tsx rename to src/rewards/Gather/GatherCardButton.tsx index a50c228339..776831e5d3 100644 --- a/src/platforms/Gather/GatherCardButton.tsx +++ b/src/rewards/Gather/GatherCardButton.tsx @@ -2,7 +2,7 @@ import { Tooltip } from "@chakra-ui/react" import useGuild from "components/[guild]/hooks/useGuild" import Button from "components/common/Button" import { ArrowSquareOut } from "phosphor-react" -import { claimTextButtonTooltipLabel } from "platforms/SecretText/TextCardButton" +import { claimTextButtonTooltipLabel } from "rewards/SecretText/TextCardButton" import { GuildPlatform } from "types" import { getRolePlatformStatus, diff --git a/src/platforms/Gather/GatherCardMenu.tsx b/src/rewards/Gather/GatherCardMenu.tsx similarity index 100% rename from src/platforms/Gather/GatherCardMenu.tsx rename to src/rewards/Gather/GatherCardMenu.tsx diff --git a/src/platforms/Gather/GatherConnectionForm.tsx b/src/rewards/Gather/GatherConnectionForm.tsx similarity index 100% rename from src/platforms/Gather/GatherConnectionForm.tsx rename to src/rewards/Gather/GatherConnectionForm.tsx diff --git a/src/platforms/Gather/GatherConnectionStatusAlert.tsx b/src/rewards/Gather/GatherConnectionStatusAlert.tsx similarity index 100% rename from src/platforms/Gather/GatherConnectionStatusAlert.tsx rename to src/rewards/Gather/GatherConnectionStatusAlert.tsx diff --git a/src/platforms/Gather/GatherForm.tsx b/src/rewards/Gather/GatherForm.tsx similarity index 100% rename from src/platforms/Gather/GatherForm.tsx rename to src/rewards/Gather/GatherForm.tsx diff --git a/src/platforms/Gather/GatherGuestForm.tsx b/src/rewards/Gather/GatherGuestForm.tsx similarity index 100% rename from src/platforms/Gather/GatherGuestForm.tsx rename to src/rewards/Gather/GatherGuestForm.tsx diff --git a/src/platforms/Gather/hooks/useClaimGather.tsx b/src/rewards/Gather/hooks/useClaimGather.tsx similarity index 100% rename from src/platforms/Gather/hooks/useClaimGather.tsx rename to src/rewards/Gather/hooks/useClaimGather.tsx diff --git a/src/platforms/Gather/hooks/useGatherAccess.tsx b/src/rewards/Gather/hooks/useGatherAccess.tsx similarity index 100% rename from src/platforms/Gather/hooks/useGatherAccess.tsx rename to src/rewards/Gather/hooks/useGatherAccess.tsx diff --git a/src/platforms/Gather/index.ts b/src/rewards/Gather/index.ts similarity index 68% rename from src/platforms/Gather/index.ts rename to src/rewards/Gather/index.ts index 33d2dc9631..953b834318 100644 --- a/src/platforms/Gather/index.ts +++ b/src/rewards/Gather/index.ts @@ -1,11 +1,11 @@ import { Buildings } from "phosphor-react" -import { PlatformAsRewardRestrictions, RewardData } from "platforms/types" +import { PlatformAsRewardRestrictions, RewardData } from "rewards/types" import useGatherCardProps from "./useGatherCardProps" import GatherCardButton from "./GatherCardButton" import GatherCardMenu from "./GatherCardMenu" import dynamic from "next/dynamic" -import LoadingRewardPreview from "platforms/components/LoadingRewardPreview" -import { AddRewardPanelLoadingSpinner } from "platforms/components/AddRewardPanelLoadingSpinner" +import LoadingRewardPreview from "rewards/components/LoadingRewardPreview" +import { AddRewardPanelLoadingSpinner } from "rewards/components/AddRewardPanelLoadingSpinner" export default { icon: Buildings, @@ -17,10 +17,10 @@ export default { cardPropsHook: useGatherCardProps, cardButton: GatherCardButton, cardMenuComponent: GatherCardMenu, - RoleCardComponent: dynamic(() => import("platforms/components/GatherReward"), { + RoleCardComponent: dynamic(() => import("rewards/components/GatherReward"), { ssr: false, }), - RewardPreview: dynamic(() => import("platforms/components/GatherPreview"), { + RewardPreview: dynamic(() => import("rewards/components/GatherPreview"), { ssr: false, loading: LoadingRewardPreview, }), diff --git a/src/platforms/Gather/useGatherCardProps.tsx b/src/rewards/Gather/useGatherCardProps.tsx similarity index 97% rename from src/platforms/Gather/useGatherCardProps.tsx rename to src/rewards/Gather/useGatherCardProps.tsx index 2b8307c397..986a7d871d 100644 --- a/src/platforms/Gather/useGatherCardProps.tsx +++ b/src/rewards/Gather/useGatherCardProps.tsx @@ -1,7 +1,7 @@ import { Circle, Img, useColorModeValue } from "@chakra-ui/react" import AvailabilityTags from "components/[guild]/RolePlatforms/components/PlatformCard/components/AvailabilityTags" import useGuild from "components/[guild]/hooks/useGuild" -import rewards from "platforms/rewards" +import rewards from "rewards" import { GuildPlatform, PlatformName } from "types" const useGatherCardProps = (guildPlatform: GuildPlatform) => { diff --git a/src/platforms/Github/GithubCardMenu.tsx b/src/rewards/Github/GithubCardMenu.tsx similarity index 100% rename from src/platforms/Github/GithubCardMenu.tsx rename to src/rewards/Github/GithubCardMenu.tsx diff --git a/src/platforms/Github/index.ts b/src/rewards/Github/index.ts similarity index 71% rename from src/platforms/Github/index.ts rename to src/rewards/Github/index.ts index e740c8ea90..c665b12e9e 100644 --- a/src/platforms/Github/index.ts +++ b/src/rewards/Github/index.ts @@ -1,10 +1,10 @@ -import { PlatformAsRewardRestrictions, RewardData } from "platforms/types" +import { PlatformAsRewardRestrictions, RewardData } from "rewards/types" import GithubCardMenu from "./GithubCardMenu" import useGithubCardProps from "./useGithubCardProps" import { GithubLogo } from "phosphor-react" import dynamic from "next/dynamic" -import { AddRewardPanelLoadingSpinner } from "platforms/components/AddRewardPanelLoadingSpinner" -import LoadingRewardPreview from "platforms/components/LoadingRewardPreview" +import { AddRewardPanelLoadingSpinner } from "rewards/components/AddRewardPanelLoadingSpinner" +import LoadingRewardPreview from "rewards/components/LoadingRewardPreview" export default { icon: GithubLogo, @@ -26,7 +26,7 @@ export default { loading: AddRewardPanelLoadingSpinner, } ), - RewardPreview: dynamic(() => import("platforms/components/GitHubPreview"), { + RewardPreview: dynamic(() => import("rewards/components/GitHubPreview"), { ssr: false, loading: LoadingRewardPreview, }), diff --git a/src/platforms/Github/useGithubCardProps.ts b/src/rewards/Github/useGithubCardProps.ts similarity index 100% rename from src/platforms/Github/useGithubCardProps.ts rename to src/rewards/Github/useGithubCardProps.ts diff --git a/src/platforms/Google/GoogleCardMenu.tsx b/src/rewards/Google/GoogleCardMenu.tsx similarity index 100% rename from src/platforms/Google/GoogleCardMenu.tsx rename to src/rewards/Google/GoogleCardMenu.tsx diff --git a/src/platforms/Google/GoogleCardSettings.tsx b/src/rewards/Google/GoogleCardSettings.tsx similarity index 100% rename from src/platforms/Google/GoogleCardSettings.tsx rename to src/rewards/Google/GoogleCardSettings.tsx diff --git a/src/platforms/Google/GoogleCardWarning.tsx b/src/rewards/Google/GoogleCardWarning.tsx similarity index 100% rename from src/platforms/Google/GoogleCardWarning.tsx rename to src/rewards/Google/GoogleCardWarning.tsx diff --git a/src/platforms/Google/index.ts b/src/rewards/Google/index.ts similarity index 75% rename from src/platforms/Google/index.ts rename to src/rewards/Google/index.ts index d239b9aa91..64dcdb6bce 100644 --- a/src/platforms/Google/index.ts +++ b/src/rewards/Google/index.ts @@ -1,12 +1,12 @@ import { GoogleLogo } from "phosphor-react" -import { PlatformAsRewardRestrictions, RewardData } from "platforms/types" +import { PlatformAsRewardRestrictions, RewardData } from "rewards/types" import useGoogleCardProps from "./useGoogleCardProps" import GoogleCardSettings from "./GoogleCardSettings" import GoogleCardMenu from "./GoogleCardMenu" import GoogleCardWarning from "./GoogleCardWarning" import dynamic from "next/dynamic" -import { AddRewardPanelLoadingSpinner } from "platforms/components/AddRewardPanelLoadingSpinner" -import LoadingRewardPreview from "platforms/components/LoadingRewardPreview" +import { AddRewardPanelLoadingSpinner } from "rewards/components/AddRewardPanelLoadingSpinner" +import LoadingRewardPreview from "rewards/components/LoadingRewardPreview" export default { icon: GoogleLogo, @@ -30,7 +30,7 @@ export default { loading: AddRewardPanelLoadingSpinner, } ), - RewardPreview: dynamic(() => import("platforms/components/GooglePreview"), { + RewardPreview: dynamic(() => import("rewards/components/GooglePreview"), { ssr: false, loading: LoadingRewardPreview, }), diff --git a/src/platforms/Google/useGoogleCardProps.tsx b/src/rewards/Google/useGoogleCardProps.tsx similarity index 100% rename from src/platforms/Google/useGoogleCardProps.tsx rename to src/rewards/Google/useGoogleCardProps.tsx diff --git a/src/platforms/Poap/PoapCardButton.tsx b/src/rewards/Poap/PoapCardButton.tsx similarity index 95% rename from src/platforms/Poap/PoapCardButton.tsx rename to src/rewards/Poap/PoapCardButton.tsx index cf37c372a2..266085b562 100644 --- a/src/platforms/Poap/PoapCardButton.tsx +++ b/src/rewards/Poap/PoapCardButton.tsx @@ -5,8 +5,8 @@ import Button from "components/common/Button" import { useClaimedReward } from "hooks/useClaimedReward" import dynamic from "next/dynamic" import Link from "next/link" -import { claimTextButtonTooltipLabel } from "platforms/SecretText/TextCardButton" -import rewards from "platforms/rewards" +import { claimTextButtonTooltipLabel } from "rewards/SecretText/TextCardButton" +import rewards from "rewards" import { GuildPlatform } from "types" import { getRolePlatformStatus, diff --git a/src/platforms/Poap/PoapCardMenu.tsx b/src/rewards/Poap/PoapCardMenu.tsx similarity index 100% rename from src/platforms/Poap/PoapCardMenu.tsx rename to src/rewards/Poap/PoapCardMenu.tsx diff --git a/src/platforms/Poap/ShowMintLinkButton.tsx b/src/rewards/Poap/ShowMintLinkButton.tsx similarity index 93% rename from src/platforms/Poap/ShowMintLinkButton.tsx rename to src/rewards/Poap/ShowMintLinkButton.tsx index e882d2966c..0157746c59 100644 --- a/src/platforms/Poap/ShowMintLinkButton.tsx +++ b/src/rewards/Poap/ShowMintLinkButton.tsx @@ -1,7 +1,7 @@ import { ButtonProps } from "@chakra-ui/react" import { MintLinkModal } from "components/[guild]/claim-poap/components/MintLinkModal" import Button from "components/common/Button" -import useClaimText from "platforms/SecretText/hooks/useClaimText" +import useClaimText from "rewards/SecretText/hooks/useClaimText" import { PropsWithChildren } from "react" import { Rest } from "types" diff --git a/src/platforms/Poap/UploadMintLinksModal.tsx b/src/rewards/Poap/UploadMintLinksModal.tsx similarity index 100% rename from src/platforms/Poap/UploadMintLinksModal.tsx rename to src/rewards/Poap/UploadMintLinksModal.tsx diff --git a/src/platforms/Poap/index.ts b/src/rewards/Poap/index.ts similarity index 71% rename from src/platforms/Poap/index.ts rename to src/rewards/Poap/index.ts index 08e56dfe9c..d73fd4314a 100644 --- a/src/platforms/Poap/index.ts +++ b/src/rewards/Poap/index.ts @@ -1,9 +1,9 @@ -import { PlatformAsRewardRestrictions, RewardData } from "platforms/types" +import { PlatformAsRewardRestrictions, RewardData } from "rewards/types" import usePoapCardProps from "./usePoapCardProps" import PoapCardButton from "./PoapCardButton" import PoapCardMenu from "./PoapCardMenu" import dynamic from "next/dynamic" -import LoadingRewardPreview from "platforms/components/LoadingRewardPreview" +import LoadingRewardPreview from "rewards/components/LoadingRewardPreview" export default { icon: null, @@ -24,11 +24,11 @@ export default { ssr: false, } ), - RewardPreview: dynamic(() => import("platforms/components/PoapPreview"), { + RewardPreview: dynamic(() => import("rewards/components/PoapPreview"), { ssr: false, loading: LoadingRewardPreview, }), - RoleCardComponent: dynamic(() => import("platforms/components/PoapReward"), { + RoleCardComponent: dynamic(() => import("rewards/components/PoapReward"), { ssr: false, }), } as const satisfies RewardData diff --git a/src/platforms/Poap/usePoapCardProps.tsx b/src/rewards/Poap/usePoapCardProps.tsx similarity index 95% rename from src/platforms/Poap/usePoapCardProps.tsx rename to src/rewards/Poap/usePoapCardProps.tsx index da83097571..655bcda47d 100644 --- a/src/platforms/Poap/usePoapCardProps.tsx +++ b/src/rewards/Poap/usePoapCardProps.tsx @@ -1,6 +1,6 @@ import AvailabilityTags from "components/[guild]/RolePlatforms/components/PlatformCard/components/AvailabilityTags" import useGuild from "components/[guild]/hooks/useGuild" -import rewards from "platforms/rewards" +import rewards from "rewards" import { GuildPlatformWithOptionalId, PlatformName } from "types" const usePoapCardProps = (guildPlatform: GuildPlatformWithOptionalId) => { diff --git a/src/platforms/Points/EditPointsModal.tsx b/src/rewards/Points/EditPointsModal.tsx similarity index 100% rename from src/platforms/Points/EditPointsModal.tsx rename to src/rewards/Points/EditPointsModal.tsx diff --git a/src/platforms/Points/PointsCardButton.tsx b/src/rewards/Points/PointsCardButton.tsx similarity index 100% rename from src/platforms/Points/PointsCardButton.tsx rename to src/rewards/Points/PointsCardButton.tsx diff --git a/src/platforms/Points/PointsCardMenu.tsx b/src/rewards/Points/PointsCardMenu.tsx similarity index 100% rename from src/platforms/Points/PointsCardMenu.tsx rename to src/rewards/Points/PointsCardMenu.tsx diff --git a/src/platforms/Points/PointsCardSettings.tsx b/src/rewards/Points/PointsCardSettings.tsx similarity index 100% rename from src/platforms/Points/PointsCardSettings.tsx rename to src/rewards/Points/PointsCardSettings.tsx diff --git a/src/platforms/Points/PointsRewardCard.tsx b/src/rewards/Points/PointsRewardCard.tsx similarity index 97% rename from src/platforms/Points/PointsRewardCard.tsx rename to src/rewards/Points/PointsRewardCard.tsx index 9c00974fb3..1200701f9f 100644 --- a/src/platforms/Points/PointsRewardCard.tsx +++ b/src/rewards/Points/PointsRewardCard.tsx @@ -2,7 +2,7 @@ import { Circle, useColorModeValue } from "@chakra-ui/react" import useGuildPermission from "components/[guild]/hooks/useGuildPermission" import RewardCard from "components/common/RewardCard" import dynamic from "next/dynamic" -import rewards from "platforms/rewards" +import rewards from "rewards" import Star from "static/icons/star.svg" import numberToOrdinal from "utils/numberToOrdinal" import PointsCardButton from "./PointsCardButton" diff --git a/src/platforms/Points/index.tsx b/src/rewards/Points/index.tsx similarity index 56% rename from src/platforms/Points/index.tsx rename to src/rewards/Points/index.tsx index cba84abfe9..3a088085c2 100644 --- a/src/platforms/Points/index.tsx +++ b/src/rewards/Points/index.tsx @@ -3,11 +3,11 @@ import { CardSettingsComponent, PlatformAsRewardRestrictions, RewardData, -} from "platforms/types" +} from "rewards/types" import usePointsCardProps from "./usePointsCardProps" import dynamic from "next/dynamic" -import LoadingRewardPreview from "platforms/components/LoadingRewardPreview" -import { AddRewardPanelLoadingSpinner } from "platforms/components/AddRewardPanelLoadingSpinner" +import LoadingRewardPreview from "rewards/components/LoadingRewardPreview" +import { AddRewardPanelLoadingSpinner } from "rewards/components/AddRewardPanelLoadingSpinner" export default { icon: Star, @@ -16,14 +16,11 @@ export default { gatedEntity: "", asRewardRestriction: PlatformAsRewardRestrictions.MULTIPLE_ROLES, cardPropsHook: usePointsCardProps, - cardSettingsComponent: dynamic( - () => import("platforms/Points/PointsCardSettings"), - { - ssr: false, - loading: () => , - } - ) as CardSettingsComponent, - RewardPreview: dynamic(() => import("platforms/components/PointsPreview"), { + cardSettingsComponent: dynamic(() => import("rewards/Points/PointsCardSettings"), { + ssr: false, + loading: () => , + }) as CardSettingsComponent, + RewardPreview: dynamic(() => import("rewards/components/PointsPreview"), { ssr: false, loading: LoadingRewardPreview, }), @@ -37,7 +34,7 @@ export default { loading: AddRewardPanelLoadingSpinner, } ), - RoleCardComponent: dynamic(() => import("platforms/components/PointsReward"), { + RoleCardComponent: dynamic(() => import("rewards/components/PointsReward"), { ssr: false, }), } as const satisfies RewardData diff --git a/src/platforms/Points/usePointsCardProps.tsx b/src/rewards/Points/usePointsCardProps.tsx similarity index 90% rename from src/platforms/Points/usePointsCardProps.tsx rename to src/rewards/Points/usePointsCardProps.tsx index 391889a837..e96ff3cff8 100644 --- a/src/platforms/Points/usePointsCardProps.tsx +++ b/src/rewards/Points/usePointsCardProps.tsx @@ -1,4 +1,4 @@ -import useDynamicRewardUserAmount from "platforms/Token/hooks/useDynamicRewardUserAmount" +import useDynamicRewardUserAmount from "rewards/Token/hooks/useDynamicRewardUserAmount" import Star from "static/icons/star.svg" import { GuildPlatformWithOptionalId, PlatformName } from "types" import { useRolePlatform } from "../../components/[guild]/RolePlatforms/components/RolePlatformProvider" diff --git a/src/platforms/Points/useUsersPoints.ts b/src/rewards/Points/useUsersPoints.ts similarity index 100% rename from src/platforms/Points/useUsersPoints.ts rename to src/rewards/Points/useUsersPoints.ts diff --git a/src/platforms/PolygonID/PolygonIDCardButton.tsx b/src/rewards/PolygonID/PolygonIDCardButton.tsx similarity index 100% rename from src/platforms/PolygonID/PolygonIDCardButton.tsx rename to src/rewards/PolygonID/PolygonIDCardButton.tsx diff --git a/src/platforms/PolygonID/PolygonIDCardMenu.tsx b/src/rewards/PolygonID/PolygonIDCardMenu.tsx similarity index 100% rename from src/platforms/PolygonID/PolygonIDCardMenu.tsx rename to src/rewards/PolygonID/PolygonIDCardMenu.tsx diff --git a/src/platforms/PolygonID/components/ConnectDIDModal.tsx b/src/rewards/PolygonID/components/ConnectDIDModal.tsx similarity index 100% rename from src/platforms/PolygonID/components/ConnectDIDModal.tsx rename to src/rewards/PolygonID/components/ConnectDIDModal.tsx diff --git a/src/platforms/PolygonID/components/MintPolygonIDProofModal.tsx b/src/rewards/PolygonID/components/MintPolygonIDProofModal.tsx similarity index 100% rename from src/platforms/PolygonID/components/MintPolygonIDProofModal.tsx rename to src/rewards/PolygonID/components/MintPolygonIDProofModal.tsx diff --git a/src/platforms/PolygonID/components/MintPolygonIDProofProvider.tsx b/src/rewards/PolygonID/components/MintPolygonIDProofProvider.tsx similarity index 100% rename from src/platforms/PolygonID/components/MintPolygonIDProofProvider.tsx rename to src/rewards/PolygonID/components/MintPolygonIDProofProvider.tsx diff --git a/src/platforms/PolygonID/components/MintableRole.tsx b/src/rewards/PolygonID/components/MintableRole.tsx similarity index 100% rename from src/platforms/PolygonID/components/MintableRole.tsx rename to src/rewards/PolygonID/components/MintableRole.tsx diff --git a/src/platforms/PolygonID/components/PolygonIDQRCodeModal.tsx b/src/rewards/PolygonID/components/PolygonIDQRCodeModal.tsx similarity index 100% rename from src/platforms/PolygonID/components/PolygonIDQRCodeModal.tsx rename to src/rewards/PolygonID/components/PolygonIDQRCodeModal.tsx diff --git a/src/platforms/PolygonID/hooks/useClaimedRoles.ts b/src/rewards/PolygonID/hooks/useClaimedRoles.ts similarity index 100% rename from src/platforms/PolygonID/hooks/useClaimedRoles.ts rename to src/rewards/PolygonID/hooks/useClaimedRoles.ts diff --git a/src/platforms/PolygonID/hooks/useConnectedDID.ts b/src/rewards/PolygonID/hooks/useConnectedDID.ts similarity index 100% rename from src/platforms/PolygonID/hooks/useConnectedDID.ts rename to src/rewards/PolygonID/hooks/useConnectedDID.ts diff --git a/src/platforms/PolygonID/index.ts b/src/rewards/PolygonID/index.ts similarity index 71% rename from src/platforms/PolygonID/index.ts rename to src/rewards/PolygonID/index.ts index b05cc4684e..c614add528 100644 --- a/src/platforms/PolygonID/index.ts +++ b/src/rewards/PolygonID/index.ts @@ -2,10 +2,10 @@ import { Key } from "phosphor-react" import usePolygonIDCardProps from "./usePolygonIDCardProps" import PolygonIDCardButton from "./PolygonIDCardButton" import PolygonIDCardMenu from "./PolygonIDCardMenu" -import { PlatformAsRewardRestrictions, RewardData } from "platforms/types" +import { PlatformAsRewardRestrictions, RewardData } from "rewards/types" import dynamic from "next/dynamic" -import { AddRewardPanelLoadingSpinner } from "platforms/components/AddRewardPanelLoadingSpinner" -import LoadingRewardPreview from "platforms/components/LoadingRewardPreview" +import { AddRewardPanelLoadingSpinner } from "rewards/components/AddRewardPanelLoadingSpinner" +import LoadingRewardPreview from "rewards/components/LoadingRewardPreview" export default { icon: Key, @@ -30,11 +30,11 @@ export default { loading: AddRewardPanelLoadingSpinner, } ), - RewardPreview: dynamic(() => import("platforms/components/PolygonIDPreview"), { + RewardPreview: dynamic(() => import("rewards/components/PolygonIDPreview"), { ssr: false, loading: LoadingRewardPreview, }), - RoleCardComponent: dynamic(() => import("platforms/components/PolygonIDReward"), { + RoleCardComponent: dynamic(() => import("rewards/components/PolygonIDReward"), { ssr: false, }), } as const satisfies RewardData diff --git a/src/platforms/PolygonID/usePolygonIDCardProps.tsx b/src/rewards/PolygonID/usePolygonIDCardProps.tsx similarity index 94% rename from src/platforms/PolygonID/usePolygonIDCardProps.tsx rename to src/rewards/PolygonID/usePolygonIDCardProps.tsx index 1ea87e4cf9..6c04a02e36 100644 --- a/src/platforms/PolygonID/usePolygonIDCardProps.tsx +++ b/src/rewards/PolygonID/usePolygonIDCardProps.tsx @@ -1,6 +1,6 @@ import { Circle, Img, useColorModeValue } from "@chakra-ui/react" import { useRolePlatform } from "components/[guild]/RolePlatforms/components/RolePlatformProvider" -import rewards from "platforms/rewards" +import rewards from "rewards" import { PlatformName } from "types" const usePolygonIDCardProps = () => { diff --git a/src/platforms/SecretText/EditSecretTextModal.tsx b/src/rewards/SecretText/EditSecretTextModal.tsx similarity index 100% rename from src/platforms/SecretText/EditSecretTextModal.tsx rename to src/rewards/SecretText/EditSecretTextModal.tsx diff --git a/src/platforms/SecretText/SecretTextCardMenu.tsx b/src/rewards/SecretText/SecretTextCardMenu.tsx similarity index 100% rename from src/platforms/SecretText/SecretTextCardMenu.tsx rename to src/rewards/SecretText/SecretTextCardMenu.tsx diff --git a/src/platforms/SecretText/SecretTextDataForm/SecretTextDataForm.tsx b/src/rewards/SecretText/SecretTextDataForm/SecretTextDataForm.tsx similarity index 100% rename from src/platforms/SecretText/SecretTextDataForm/SecretTextDataForm.tsx rename to src/rewards/SecretText/SecretTextDataForm/SecretTextDataForm.tsx diff --git a/src/platforms/SecretText/SecretTextDataForm/components/PublicRewardDataForm.tsx b/src/rewards/SecretText/SecretTextDataForm/components/PublicRewardDataForm.tsx similarity index 92% rename from src/platforms/SecretText/SecretTextDataForm/components/PublicRewardDataForm.tsx rename to src/rewards/SecretText/SecretTextDataForm/components/PublicRewardDataForm.tsx index 0d9b75bccb..4516a07f3d 100644 --- a/src/platforms/SecretText/SecretTextDataForm/components/PublicRewardDataForm.tsx +++ b/src/rewards/SecretText/SecretTextDataForm/components/PublicRewardDataForm.tsx @@ -1,6 +1,6 @@ import { Box, FormControl, FormLabel, HStack, Input } from "@chakra-ui/react" import FormErrorMessage from "components/common/FormErrorMessage" -import { UniqueTextRewardForm } from "platforms/UniqueText/UniqueTextDataForm" +import { UniqueTextRewardForm } from "rewards/UniqueText/UniqueTextDataForm" import { useFormContext } from "react-hook-form" import { SecretTextRewardForm } from "../SecretTextDataForm" import RewardImagePicker from "./RewardImagePicker" diff --git a/src/platforms/SecretText/SecretTextDataForm/components/RewardImagePicker.tsx b/src/rewards/SecretText/SecretTextDataForm/components/RewardImagePicker.tsx similarity index 100% rename from src/platforms/SecretText/SecretTextDataForm/components/RewardImagePicker.tsx rename to src/rewards/SecretText/SecretTextDataForm/components/RewardImagePicker.tsx diff --git a/src/platforms/SecretText/SecretTextDataForm/index.ts b/src/rewards/SecretText/SecretTextDataForm/index.ts similarity index 100% rename from src/platforms/SecretText/SecretTextDataForm/index.ts rename to src/rewards/SecretText/SecretTextDataForm/index.ts diff --git a/src/platforms/SecretText/TextCardButton.tsx b/src/rewards/SecretText/TextCardButton.tsx similarity index 100% rename from src/platforms/SecretText/TextCardButton.tsx rename to src/rewards/SecretText/TextCardButton.tsx diff --git a/src/platforms/SecretText/hooks/useClaimText.tsx b/src/rewards/SecretText/hooks/useClaimText.tsx similarity index 100% rename from src/platforms/SecretText/hooks/useClaimText.tsx rename to src/rewards/SecretText/hooks/useClaimText.tsx diff --git a/src/platforms/SecretText/index.ts b/src/rewards/SecretText/index.ts similarity index 67% rename from src/platforms/SecretText/index.ts rename to src/rewards/SecretText/index.ts index 95efbb6efd..c012bf1216 100644 --- a/src/platforms/SecretText/index.ts +++ b/src/rewards/SecretText/index.ts @@ -1,11 +1,11 @@ -import { PlatformAsRewardRestrictions, RewardData } from "platforms/types" +import { PlatformAsRewardRestrictions, RewardData } from "rewards/types" import SecretTextCardMenu from "./SecretTextCardMenu" import TextCardButton from "./TextCardButton" import useSecretTextCardProps from "./useSecretTextCardProps" import Box from "static/icons/box.svg" import dynamic from "next/dynamic" -import { AddRewardPanelLoadingSpinner } from "platforms/components/AddRewardPanelLoadingSpinner" -import LoadingRewardPreview from "platforms/components/LoadingRewardPreview" +import { AddRewardPanelLoadingSpinner } from "rewards/components/AddRewardPanelLoadingSpinner" +import LoadingRewardPreview from "rewards/components/LoadingRewardPreview" export default { icon: Box, @@ -26,11 +26,11 @@ export default { loading: AddRewardPanelLoadingSpinner, } ), - RewardPreview: dynamic(() => import("platforms/components/SecretTextPreview"), { + RewardPreview: dynamic(() => import("rewards/components/SecretTextPreview"), { ssr: false, loading: LoadingRewardPreview, }), - RoleCardComponent: dynamic(() => import("platforms/components/TextReward"), { + RoleCardComponent: dynamic(() => import("rewards/components/TextReward"), { ssr: false, }), } as const satisfies RewardData diff --git a/src/platforms/SecretText/useSecretTextCardProps.tsx b/src/rewards/SecretText/useSecretTextCardProps.tsx similarity index 97% rename from src/platforms/SecretText/useSecretTextCardProps.tsx rename to src/rewards/SecretText/useSecretTextCardProps.tsx index 9fa1f8ffdb..53573e61e7 100644 --- a/src/platforms/SecretText/useSecretTextCardProps.tsx +++ b/src/rewards/SecretText/useSecretTextCardProps.tsx @@ -3,7 +3,7 @@ import AvailabilityTags from "components/[guild]/RolePlatforms/components/Platfo import useGuild from "components/[guild]/hooks/useGuild" import useGuildPermission from "components/[guild]/hooks/useGuildPermission" import { useClaimedReward } from "hooks/useClaimedReward" -import rewards from "platforms/rewards" +import rewards from "rewards" import { GuildPlatformWithOptionalId, PlatformName } from "types" const useSecretTextCardProps = (guildPlatform: GuildPlatformWithOptionalId) => { diff --git a/src/platforms/Telegram/TelegramCardMenu.tsx b/src/rewards/Telegram/TelegramCardMenu.tsx similarity index 100% rename from src/platforms/Telegram/TelegramCardMenu.tsx rename to src/rewards/Telegram/TelegramCardMenu.tsx diff --git a/src/platforms/Telegram/index.ts b/src/rewards/Telegram/index.ts similarity index 71% rename from src/platforms/Telegram/index.ts rename to src/rewards/Telegram/index.ts index 58c67d5a99..89b73e5be2 100644 --- a/src/platforms/Telegram/index.ts +++ b/src/rewards/Telegram/index.ts @@ -1,10 +1,10 @@ import { TelegramLogo } from "phosphor-react" -import { PlatformAsRewardRestrictions, RewardData } from "platforms/types" +import { PlatformAsRewardRestrictions, RewardData } from "rewards/types" import useTelegramCardProps from "./useTelegramCardProps" import TelegramCardMenu from "./TelegramCardMenu" import dynamic from "next/dynamic" -import { AddRewardPanelLoadingSpinner } from "platforms/components/AddRewardPanelLoadingSpinner" -import LoadingRewardPreview from "platforms/components/LoadingRewardPreview" +import { AddRewardPanelLoadingSpinner } from "rewards/components/AddRewardPanelLoadingSpinner" +import LoadingRewardPreview from "rewards/components/LoadingRewardPreview" export default { icon: TelegramLogo, @@ -26,7 +26,7 @@ export default { loading: AddRewardPanelLoadingSpinner, } ), - RewardPreview: dynamic(() => import("platforms/components/TelegramPreview"), { + RewardPreview: dynamic(() => import("rewards/components/TelegramPreview"), { ssr: false, loading: LoadingRewardPreview, }), diff --git a/src/platforms/Telegram/useTelegramCardProps.ts b/src/rewards/Telegram/useTelegramCardProps.ts similarity index 100% rename from src/platforms/Telegram/useTelegramCardProps.ts rename to src/rewards/Telegram/useTelegramCardProps.ts diff --git a/src/platforms/Token/ClaimTokenButton.tsx b/src/rewards/Token/ClaimTokenButton.tsx similarity index 94% rename from src/platforms/Token/ClaimTokenButton.tsx rename to src/rewards/Token/ClaimTokenButton.tsx index f33cda21be..0ce76486e8 100644 --- a/src/platforms/Token/ClaimTokenButton.tsx +++ b/src/rewards/Token/ClaimTokenButton.tsx @@ -1,7 +1,7 @@ import { ButtonProps, Tooltip, useDisclosure } from "@chakra-ui/react" import Button from "components/common/Button" import dynamic from "next/dynamic" -import { claimTextButtonTooltipLabel } from "platforms/SecretText/TextCardButton" +import { claimTextButtonTooltipLabel } from "rewards/SecretText/TextCardButton" import { RolePlatform } from "types" import { getRolePlatformStatus, diff --git a/src/platforms/Token/ClaimTokenModal/ClaimTokenModal.tsx b/src/rewards/Token/ClaimTokenModal/ClaimTokenModal.tsx similarity index 98% rename from src/platforms/Token/ClaimTokenModal/ClaimTokenModal.tsx rename to src/rewards/Token/ClaimTokenModal/ClaimTokenModal.tsx index 5c0eaeec38..8bb1087c83 100644 --- a/src/platforms/Token/ClaimTokenModal/ClaimTokenModal.tsx +++ b/src/rewards/Token/ClaimTokenModal/ClaimTokenModal.tsx @@ -23,7 +23,7 @@ import Button from "components/common/Button" import { useCardBg } from "components/common/Card" import Image from "next/image" import { ArrowSquareOut } from "phosphor-react" -import { claimTextButtonTooltipLabel } from "platforms/SecretText/TextCardButton" +import { claimTextButtonTooltipLabel } from "rewards/SecretText/TextCardButton" import { useMemo, useState } from "react" import { NULL_ADDRESS } from "utils/guildCheckout/constants" import { diff --git a/src/platforms/Token/ClaimTokenModal/TokenRibbonIllustration.tsx b/src/rewards/Token/ClaimTokenModal/TokenRibbonIllustration.tsx similarity index 100% rename from src/platforms/Token/ClaimTokenModal/TokenRibbonIllustration.tsx rename to src/rewards/Token/ClaimTokenModal/TokenRibbonIllustration.tsx diff --git a/src/platforms/Token/ClaimTokenModal/index.ts b/src/rewards/Token/ClaimTokenModal/index.ts similarity index 100% rename from src/platforms/Token/ClaimTokenModal/index.ts rename to src/rewards/Token/ClaimTokenModal/index.ts diff --git a/src/platforms/Token/DynamicRewardCalculationTable.tsx b/src/rewards/Token/DynamicRewardCalculationTable.tsx similarity index 98% rename from src/platforms/Token/DynamicRewardCalculationTable.tsx rename to src/rewards/Token/DynamicRewardCalculationTable.tsx index dfe00df697..692a14810c 100644 --- a/src/platforms/Token/DynamicRewardCalculationTable.tsx +++ b/src/rewards/Token/DynamicRewardCalculationTable.tsx @@ -2,7 +2,7 @@ import { HStack, Icon, Skeleton, Td, Text, Tr } from "@chakra-ui/react" import FeesTable from "components/[guild]/Requirements/components/GuildCheckout/components/FeesTable" import OptionImage from "components/common/StyledSelect/components/CustomSelectOption/components/OptionImage" import { LockSimple, X } from "phosphor-react" -import rewards from "platforms/rewards" +import rewards from "rewards" import { REQUIREMENT_PROVIDED_VALUES } from "requirements/requirements" import { PlatformType, Requirement, RolePlatform } from "types" import useDynamicRewardUserAmount from "./hooks/useDynamicRewardUserAmount" diff --git a/src/platforms/Token/DynamicRewardModal.tsx b/src/rewards/Token/DynamicRewardModal.tsx similarity index 98% rename from src/platforms/Token/DynamicRewardModal.tsx rename to src/rewards/Token/DynamicRewardModal.tsx index a0fc46776c..e15c90add6 100644 --- a/src/platforms/Token/DynamicRewardModal.tsx +++ b/src/rewards/Token/DynamicRewardModal.tsx @@ -32,7 +32,7 @@ import { Requirement, RolePlatform } from "types" import DynamicRewardCalculationTable from "./DynamicRewardCalculationTable" const EditModalDynamic = dynamic( - () => import("platforms/Token/EditDynamicRewardModal") + () => import("rewards/Token/EditDynamicRewardModal") ) const LinkedRequirement = ({ requirement }: { requirement?: Requirement }) => ( diff --git a/src/platforms/Token/DynamicTypeForm.tsx b/src/rewards/Token/DynamicTypeForm.tsx similarity index 100% rename from src/platforms/Token/DynamicTypeForm.tsx rename to src/rewards/Token/DynamicTypeForm.tsx diff --git a/src/platforms/Token/EditDynamicRewardModal.tsx b/src/rewards/Token/EditDynamicRewardModal.tsx similarity index 98% rename from src/platforms/Token/EditDynamicRewardModal.tsx rename to src/rewards/Token/EditDynamicRewardModal.tsx index 054186a8be..60b1f784e6 100644 --- a/src/platforms/Token/EditDynamicRewardModal.tsx +++ b/src/rewards/Token/EditDynamicRewardModal.tsx @@ -13,7 +13,7 @@ import Button from "components/common/Button" import OptionImage from "components/common/StyledSelect/components/CustomSelectOption/components/OptionImage" import useToast from "hooks/useToast" import dynamic from "next/dynamic" -import rewards from "platforms/rewards" +import rewards from "rewards" import { FormProvider, useForm } from "react-hook-form" import { PlatformType, Requirement, RolePlatform } from "types" diff --git a/src/platforms/Token/EditTokenModal.tsx b/src/rewards/Token/EditTokenModal.tsx similarity index 99% rename from src/platforms/Token/EditTokenModal.tsx rename to src/rewards/Token/EditTokenModal.tsx index e9cafef78a..2248b7c3a1 100644 --- a/src/platforms/Token/EditTokenModal.tsx +++ b/src/rewards/Token/EditTokenModal.tsx @@ -33,7 +33,7 @@ import useCreateRequirement from "components/create-guild/Requirements/hooks/use import useEditRequirement from "components/create-guild/Requirements/hooks/useEditRequirement" import useToast from "hooks/useToast" import { Star } from "phosphor-react" -import { useTokenRewardContext } from "platforms/Token/TokenRewardContext" +import { useTokenRewardContext } from "rewards/Token/TokenRewardContext" import { ReactNode, useMemo, useState } from "react" import { FormProvider, useForm } from "react-hook-form" import Token from "static/icons/token.svg" diff --git a/src/platforms/Token/FundPoolModal.tsx b/src/rewards/Token/FundPoolModal.tsx similarity index 98% rename from src/platforms/Token/FundPoolModal.tsx rename to src/rewards/Token/FundPoolModal.tsx index ca250ecdfd..71761caf3d 100644 --- a/src/platforms/Token/FundPoolModal.tsx +++ b/src/rewards/Token/FundPoolModal.tsx @@ -21,7 +21,7 @@ import useAllowance from "components/[guild]/Requirements/components/GuildChecko import AllowanceButton from "components/[guild]/RolePlatforms/components/AddRoleRewardModal/components/AddTokenPanel/components/AllowanceButton" import useIsBalanceSufficient from "components/[guild]/RolePlatforms/components/AddRoleRewardModal/components/AddTokenPanel/hooks/useIsBalanceSufficient" import OptionImage from "components/common/StyledSelect/components/CustomSelectOption/components/OptionImage" -import { useTokenRewardContext } from "platforms/Token/TokenRewardContext" +import { useTokenRewardContext } from "rewards/Token/TokenRewardContext" import { RefObject } from "react" import { FormProvider, useForm, useWatch } from "react-hook-form" import ControlledNumberInput from "requirements/WalletActivity/components/ControlledNumberInput" diff --git a/src/platforms/Token/GeogatedCountryAlert.tsx b/src/rewards/Token/GeogatedCountryAlert.tsx similarity index 100% rename from src/platforms/Token/GeogatedCountryAlert.tsx rename to src/rewards/Token/GeogatedCountryAlert.tsx diff --git a/src/platforms/Token/PoolInformation.tsx b/src/rewards/Token/PoolInformation.tsx similarity index 100% rename from src/platforms/Token/PoolInformation.tsx rename to src/rewards/Token/PoolInformation.tsx diff --git a/src/platforms/Token/PoolTag.tsx b/src/rewards/Token/PoolTag.tsx similarity index 95% rename from src/platforms/Token/PoolTag.tsx rename to src/rewards/Token/PoolTag.tsx index 8b952dcccc..6f10170ae2 100644 --- a/src/platforms/Token/PoolTag.tsx +++ b/src/rewards/Token/PoolTag.tsx @@ -13,9 +13,9 @@ import { import ClickableTagPopover from "components/[guild]/activity/ActivityLogAction/components/ClickableTagPopover" import useToast from "hooks/useToast" import { Coin, DotsThreeVertical, Wallet } from "phosphor-react" -import FundPoolModal from "platforms/Token/FundPoolModal" -import { useTokenRewardContext } from "platforms/Token/TokenRewardContext" -import usePool from "platforms/Token/hooks/usePool" +import FundPoolModal from "rewards/Token/FundPoolModal" +import { useTokenRewardContext } from "rewards/Token/TokenRewardContext" +import usePool from "rewards/Token/hooks/usePool" import { useRef } from "react" import { formatUnits } from "viem" import WithdrawPoolModal from "./WithdrawPoolModal" diff --git a/src/platforms/Token/RemoveTokenRewardConfirmation.tsx b/src/rewards/Token/RemoveTokenRewardConfirmation.tsx similarity index 100% rename from src/platforms/Token/RemoveTokenRewardConfirmation.tsx rename to src/rewards/Token/RemoveTokenRewardConfirmation.tsx diff --git a/src/platforms/Token/TokenClaimFeeTable.tsx b/src/rewards/Token/TokenClaimFeeTable.tsx similarity index 100% rename from src/platforms/Token/TokenClaimFeeTable.tsx rename to src/rewards/Token/TokenClaimFeeTable.tsx diff --git a/src/platforms/Token/TokenConversionTag.tsx b/src/rewards/Token/TokenConversionTag.tsx similarity index 96% rename from src/platforms/Token/TokenConversionTag.tsx rename to src/rewards/Token/TokenConversionTag.tsx index 291a860f62..86d56186ee 100644 --- a/src/platforms/Token/TokenConversionTag.tsx +++ b/src/rewards/Token/TokenConversionTag.tsx @@ -3,7 +3,7 @@ import { useAccessedGuildPoints } from "components/[guild]/AccessHub/hooks/useAc import useRequirements from "components/[guild]/hooks/useRequirements" import GuildLogo from "components/common/GuildLogo" import { ArrowRight } from "phosphor-react" -import { useTokenRewardContext } from "platforms/Token/TokenRewardContext" +import { useTokenRewardContext } from "rewards/Token/TokenRewardContext" import { useMemo } from "react" import Star from "static/icons/star.svg" import { RolePlatform } from "types" diff --git a/src/platforms/Token/TokenRewardCard.tsx b/src/rewards/Token/TokenRewardCard.tsx similarity index 98% rename from src/platforms/Token/TokenRewardCard.tsx rename to src/rewards/Token/TokenRewardCard.tsx index 3dc1f6e5ec..4271634d27 100644 --- a/src/platforms/Token/TokenRewardCard.tsx +++ b/src/rewards/Token/TokenRewardCard.tsx @@ -5,7 +5,7 @@ import useGuildPermission from "components/[guild]/hooks/useGuildPermission" import RewardCard from "components/common/RewardCard" import useMembership from "components/explorer/hooks/useMembership" import dynamic from "next/dynamic" -import rewards from "platforms/rewards" +import rewards from "rewards" import { useMemo } from "react" import { GuildPlatform } from "types" import ClaimTokenButton from "./ClaimTokenButton" diff --git a/src/platforms/Token/TokenRewardCardEditMenu.tsx b/src/rewards/Token/TokenRewardCardEditMenu.tsx similarity index 100% rename from src/platforms/Token/TokenRewardCardEditMenu.tsx rename to src/rewards/Token/TokenRewardCardEditMenu.tsx diff --git a/src/platforms/Token/TokenRewardContext.tsx b/src/rewards/Token/TokenRewardContext.tsx similarity index 100% rename from src/platforms/Token/TokenRewardContext.tsx rename to src/rewards/Token/TokenRewardContext.tsx diff --git a/src/platforms/Token/TokenRolePlatformClaimCard.tsx b/src/rewards/Token/TokenRolePlatformClaimCard.tsx similarity index 100% rename from src/platforms/Token/TokenRolePlatformClaimCard.tsx rename to src/rewards/Token/TokenRolePlatformClaimCard.tsx diff --git a/src/platforms/Token/WithdrawPoolModal.tsx b/src/rewards/Token/WithdrawPoolModal.tsx similarity index 98% rename from src/platforms/Token/WithdrawPoolModal.tsx rename to src/rewards/Token/WithdrawPoolModal.tsx index 9b6c88ba49..ec3a29402a 100644 --- a/src/platforms/Token/WithdrawPoolModal.tsx +++ b/src/rewards/Token/WithdrawPoolModal.tsx @@ -17,7 +17,7 @@ import { import SwitchNetworkButton from "components/[guild]/Requirements/components/GuildCheckout/components/buttons/SwitchNetworkButton" import AllowanceButton from "components/[guild]/RolePlatforms/components/AddRoleRewardModal/components/AddTokenPanel/components/AllowanceButton" import useToast from "hooks/useToast" -import { useTokenRewardContext } from "platforms/Token/TokenRewardContext" +import { useTokenRewardContext } from "rewards/Token/TokenRewardContext" import { RefObject } from "react" import { ERC20_CONTRACTS } from "utils/guildCheckout/constants" import shortenHex from "utils/shortenHex" diff --git a/src/platforms/Token/hooks/useCalculateToken.tsx b/src/rewards/Token/hooks/useCalculateToken.tsx similarity index 100% rename from src/platforms/Token/hooks/useCalculateToken.tsx rename to src/rewards/Token/hooks/useCalculateToken.tsx diff --git a/src/platforms/Token/hooks/useClaimToken.tsx b/src/rewards/Token/hooks/useClaimToken.tsx similarity index 100% rename from src/platforms/Token/hooks/useClaimToken.tsx rename to src/rewards/Token/hooks/useClaimToken.tsx diff --git a/src/platforms/Token/hooks/useCollectToken.tsx b/src/rewards/Token/hooks/useCollectToken.tsx similarity index 100% rename from src/platforms/Token/hooks/useCollectToken.tsx rename to src/rewards/Token/hooks/useCollectToken.tsx diff --git a/src/platforms/Token/hooks/useDynamicRewardUserAmount.tsx b/src/rewards/Token/hooks/useDynamicRewardUserAmount.tsx similarity index 100% rename from src/platforms/Token/hooks/useDynamicRewardUserAmount.tsx rename to src/rewards/Token/hooks/useDynamicRewardUserAmount.tsx diff --git a/src/platforms/Token/hooks/useFundPool.tsx b/src/rewards/Token/hooks/useFundPool.tsx similarity index 100% rename from src/platforms/Token/hooks/useFundPool.tsx rename to src/rewards/Token/hooks/useFundPool.tsx diff --git a/src/platforms/Token/hooks/usePool.tsx b/src/rewards/Token/hooks/usePool.tsx similarity index 100% rename from src/platforms/Token/hooks/usePool.tsx rename to src/rewards/Token/hooks/usePool.tsx diff --git a/src/platforms/Token/hooks/useRegisterPool.tsx b/src/rewards/Token/hooks/useRegisterPool.tsx similarity index 100% rename from src/platforms/Token/hooks/useRegisterPool.tsx rename to src/rewards/Token/hooks/useRegisterPool.tsx diff --git a/src/platforms/Token/hooks/useRolePlatformsOfReward.tsx b/src/rewards/Token/hooks/useRolePlatformsOfReward.tsx similarity index 100% rename from src/platforms/Token/hooks/useRolePlatformsOfReward.tsx rename to src/rewards/Token/hooks/useRolePlatformsOfReward.tsx diff --git a/src/platforms/Token/hooks/useTokenCardProps.tsx b/src/rewards/Token/hooks/useTokenCardProps.tsx similarity index 100% rename from src/platforms/Token/hooks/useTokenCardProps.tsx rename to src/rewards/Token/hooks/useTokenCardProps.tsx diff --git a/src/platforms/Token/hooks/useTokenClaimedAmount.tsx b/src/rewards/Token/hooks/useTokenClaimedAmount.tsx similarity index 100% rename from src/platforms/Token/hooks/useTokenClaimedAmount.tsx rename to src/rewards/Token/hooks/useTokenClaimedAmount.tsx diff --git a/src/platforms/Token/hooks/useWithdrawPool.tsx b/src/rewards/Token/hooks/useWithdrawPool.tsx similarity index 100% rename from src/platforms/Token/hooks/useWithdrawPool.tsx rename to src/rewards/Token/hooks/useWithdrawPool.tsx diff --git a/src/platforms/Token/index.ts b/src/rewards/Token/index.ts similarity index 65% rename from src/platforms/Token/index.ts rename to src/rewards/Token/index.ts index 349e95cb5b..a77a1ac82c 100644 --- a/src/platforms/Token/index.ts +++ b/src/rewards/Token/index.ts @@ -1,7 +1,7 @@ import dynamic from "next/dynamic" -import { AddRewardPanelLoadingSpinner } from "platforms/components/AddRewardPanelLoadingSpinner" -import LoadingRewardPreview from "platforms/components/LoadingRewardPreview" -import { PlatformAsRewardRestrictions, RewardData } from "platforms/types" +import { AddRewardPanelLoadingSpinner } from "rewards/components/AddRewardPanelLoadingSpinner" +import LoadingRewardPreview from "rewards/components/LoadingRewardPreview" +import { PlatformAsRewardRestrictions, RewardData } from "rewards/types" import Token from "static/icons/token.svg" import ClaimTokenButton from "./ClaimTokenButton" import useTokenCardProps from "./hooks/useTokenCardProps" @@ -24,11 +24,11 @@ export default { loading: AddRewardPanelLoadingSpinner, } ), - RewardPreview: dynamic(() => import("platforms/components/TokenPreview"), { + RewardPreview: dynamic(() => import("rewards/components/TokenPreview"), { ssr: false, loading: LoadingRewardPreview, }), - RoleCardComponent: dynamic(() => import("platforms/components/TokenReward"), { + RoleCardComponent: dynamic(() => import("rewards/components/TokenReward"), { ssr: false, }), } as const satisfies RewardData diff --git a/src/platforms/Twitter/index.ts b/src/rewards/Twitter/index.ts similarity index 86% rename from src/platforms/Twitter/index.ts rename to src/rewards/Twitter/index.ts index 65ca861de4..0fc3481d50 100644 --- a/src/platforms/Twitter/index.ts +++ b/src/rewards/Twitter/index.ts @@ -1,4 +1,4 @@ -import { PlatformAsRewardRestrictions, RewardData } from "platforms/types" +import { PlatformAsRewardRestrictions, RewardData } from "rewards/types" import XLogo from "static/icons/x.svg" export default { diff --git a/src/platforms/UniqueText/EditUniqueTextModal.tsx b/src/rewards/UniqueText/EditUniqueTextModal.tsx similarity index 100% rename from src/platforms/UniqueText/EditUniqueTextModal.tsx rename to src/rewards/UniqueText/EditUniqueTextModal.tsx diff --git a/src/platforms/UniqueText/UniqueTextCardMenu.tsx b/src/rewards/UniqueText/UniqueTextCardMenu.tsx similarity index 100% rename from src/platforms/UniqueText/UniqueTextCardMenu.tsx rename to src/rewards/UniqueText/UniqueTextCardMenu.tsx diff --git a/src/platforms/UniqueText/UniqueTextDataForm.tsx b/src/rewards/UniqueText/UniqueTextDataForm.tsx similarity index 97% rename from src/platforms/UniqueText/UniqueTextDataForm.tsx rename to src/rewards/UniqueText/UniqueTextDataForm.tsx index ef5a5eb2f5..44ee948154 100644 --- a/src/platforms/UniqueText/UniqueTextDataForm.tsx +++ b/src/rewards/UniqueText/UniqueTextDataForm.tsx @@ -10,7 +10,7 @@ import Button from "components/common/Button" import FormErrorMessage from "components/common/FormErrorMessage" import useDropzone from "hooks/useDropzone" import { File } from "phosphor-react" -import PublicRewardDataForm from "platforms/SecretText/SecretTextDataForm/components/PublicRewardDataForm" +import PublicRewardDataForm from "rewards/SecretText/SecretTextDataForm/components/PublicRewardDataForm" import { PropsWithChildren, useState } from "react" import { useController, useFormContext, useWatch } from "react-hook-form" import Key from "static/icons/key.svg" diff --git a/src/platforms/UniqueText/index.ts b/src/rewards/UniqueText/index.ts similarity index 60% rename from src/platforms/UniqueText/index.ts rename to src/rewards/UniqueText/index.ts index 6140f1d66d..3f1415fe28 100644 --- a/src/platforms/UniqueText/index.ts +++ b/src/rewards/UniqueText/index.ts @@ -1,10 +1,10 @@ import { Key } from "phosphor-react" -import { PlatformAsRewardRestrictions, RewardData } from "platforms/types" +import { PlatformAsRewardRestrictions, RewardData } from "rewards/types" import useUniqueTextCardProps from "./useUniqueTextCardProps" -import TextCardButton from "platforms/SecretText/TextCardButton" +import TextCardButton from "rewards/SecretText/TextCardButton" import UniqueTextCardMenu from "./UniqueTextCardMenu" import dynamic from "next/dynamic" -import LoadingRewardPreview from "platforms/components/LoadingRewardPreview" +import LoadingRewardPreview from "rewards/components/LoadingRewardPreview" export default { icon: Key, @@ -15,11 +15,11 @@ export default { cardButton: TextCardButton, cardMenuComponent: UniqueTextCardMenu, asRewardRestriction: PlatformAsRewardRestrictions.SINGLE_ROLE, - RewardPreview: dynamic(() => import("platforms/components/UniqueTextPreview"), { + RewardPreview: dynamic(() => import("rewards/components/UniqueTextPreview"), { ssr: false, loading: LoadingRewardPreview, }), - RoleCardComponent: dynamic(() => import("platforms/components/TextReward"), { + RoleCardComponent: dynamic(() => import("rewards/components/TextReward"), { ssr: false, }), } as const satisfies RewardData diff --git a/src/platforms/UniqueText/useUniqueTextCardProps.tsx b/src/rewards/UniqueText/useUniqueTextCardProps.tsx similarity index 97% rename from src/platforms/UniqueText/useUniqueTextCardProps.tsx rename to src/rewards/UniqueText/useUniqueTextCardProps.tsx index 349812f890..acf314b940 100644 --- a/src/platforms/UniqueText/useUniqueTextCardProps.tsx +++ b/src/rewards/UniqueText/useUniqueTextCardProps.tsx @@ -3,7 +3,7 @@ import AvailabilityTags from "components/[guild]/RolePlatforms/components/Platfo import useGuild from "components/[guild]/hooks/useGuild" import useGuildPermission from "components/[guild]/hooks/useGuildPermission" import { useClaimedReward } from "hooks/useClaimedReward" -import rewards from "platforms/rewards" +import rewards from "rewards" import { GuildPlatformWithOptionalId, PlatformName } from "types" const useUniqueTextCardProps = (guildPlatform: GuildPlatformWithOptionalId) => { diff --git a/src/platforms/components/AddRewardPanelLoadingSpinner.tsx b/src/rewards/components/AddRewardPanelLoadingSpinner.tsx similarity index 100% rename from src/platforms/components/AddRewardPanelLoadingSpinner.tsx rename to src/rewards/components/AddRewardPanelLoadingSpinner.tsx diff --git a/src/platforms/components/ContractCallPreview.tsx b/src/rewards/components/ContractCallPreview.tsx similarity index 100% rename from src/platforms/components/ContractCallPreview.tsx rename to src/rewards/components/ContractCallPreview.tsx diff --git a/src/platforms/components/DiscordPreview.tsx b/src/rewards/components/DiscordPreview.tsx similarity index 100% rename from src/platforms/components/DiscordPreview.tsx rename to src/rewards/components/DiscordPreview.tsx diff --git a/src/platforms/components/FormPreview.tsx b/src/rewards/components/FormPreview.tsx similarity index 100% rename from src/platforms/components/FormPreview.tsx rename to src/rewards/components/FormPreview.tsx diff --git a/src/platforms/components/FormReward.tsx b/src/rewards/components/FormReward.tsx similarity index 95% rename from src/platforms/components/FormReward.tsx rename to src/rewards/components/FormReward.tsx index fe7bf71da6..c45a25cd39 100644 --- a/src/platforms/components/FormReward.tsx +++ b/src/rewards/components/FormReward.tsx @@ -9,7 +9,7 @@ import { useGuildForm } from "components/[guild]/hooks/useGuildForms" import Button from "components/common/Button" import Link from "next/link" import { ArrowRight } from "phosphor-react" -import { useUserFormSubmission } from "platforms/Forms/hooks/useFormSubmissions" +import { useUserFormSubmission } from "rewards/Forms/hooks/useFormSubmissions" const FormReward = ({ platform, withMotionImg }: RewardProps) => { const { urlName } = useGuild() diff --git a/src/platforms/components/GatherPreview.tsx b/src/rewards/components/GatherPreview.tsx similarity index 91% rename from src/platforms/components/GatherPreview.tsx rename to src/rewards/components/GatherPreview.tsx index 24cfb090ca..e2e88d571a 100644 --- a/src/platforms/components/GatherPreview.tsx +++ b/src/rewards/components/GatherPreview.tsx @@ -1,4 +1,4 @@ -import rewards from "platforms/rewards" +import rewards from "rewards" import { useWatch } from "react-hook-form" import RewardPreview from "./RewardPreview" diff --git a/src/platforms/components/GatherReward.tsx b/src/rewards/components/GatherReward.tsx similarity index 94% rename from src/platforms/components/GatherReward.tsx rename to src/rewards/components/GatherReward.tsx index e953f1b3ce..c7f12b6202 100644 --- a/src/platforms/components/GatherReward.tsx +++ b/src/rewards/components/GatherReward.tsx @@ -10,10 +10,10 @@ import useGuild from "components/[guild]/hooks/useGuild" import Button from "components/common/Button" import { useRoleMembership } from "components/explorer/hooks/useMembership" import { ArrowSquareOut, LockSimple } from "phosphor-react" -import ClaimGatherModal from "platforms/Gather/ClaimGatherModal" -import useClaimGather from "platforms/Gather/hooks/useClaimGather" -import { claimTextButtonTooltipLabel } from "platforms/SecretText/TextCardButton" -import rewards from "platforms/rewards" +import ClaimGatherModal from "rewards/Gather/ClaimGatherModal" +import useClaimGather from "rewards/Gather/hooks/useClaimGather" +import { claimTextButtonTooltipLabel } from "rewards/SecretText/TextCardButton" +import rewards from "rewards" import { useMemo } from "react" import { PlatformType } from "types" import { diff --git a/src/platforms/components/GitHubPreview.tsx b/src/rewards/components/GitHubPreview.tsx similarity index 100% rename from src/platforms/components/GitHubPreview.tsx rename to src/rewards/components/GitHubPreview.tsx diff --git a/src/platforms/components/GooglePreview.tsx b/src/rewards/components/GooglePreview.tsx similarity index 100% rename from src/platforms/components/GooglePreview.tsx rename to src/rewards/components/GooglePreview.tsx diff --git a/src/platforms/components/LoadingRewardPreview.tsx b/src/rewards/components/LoadingRewardPreview.tsx similarity index 100% rename from src/platforms/components/LoadingRewardPreview.tsx rename to src/rewards/components/LoadingRewardPreview.tsx diff --git a/src/platforms/components/PoapPreview.tsx b/src/rewards/components/PoapPreview.tsx similarity index 93% rename from src/platforms/components/PoapPreview.tsx rename to src/rewards/components/PoapPreview.tsx index 30c41a719c..12829ac50c 100644 --- a/src/platforms/components/PoapPreview.tsx +++ b/src/rewards/components/PoapPreview.tsx @@ -1,4 +1,4 @@ -import rewards from "platforms/rewards" +import rewards from "rewards" import { useWatch } from "react-hook-form" import RewardPreview from "./RewardPreview" diff --git a/src/platforms/components/PoapReward.tsx b/src/rewards/components/PoapReward.tsx similarity index 93% rename from src/platforms/components/PoapReward.tsx rename to src/rewards/components/PoapReward.tsx index ed3c768861..35a435ff7a 100644 --- a/src/platforms/components/PoapReward.tsx +++ b/src/rewards/components/PoapReward.tsx @@ -11,8 +11,8 @@ import { useClaimedReward } from "hooks/useClaimedReward" import dynamic from "next/dynamic" import Link from "next/link" import { ArrowRight } from "phosphor-react" -import { claimTextButtonTooltipLabel } from "platforms/SecretText/TextCardButton" -import rewards from "platforms/rewards" +import { claimTextButtonTooltipLabel } from "rewards/SecretText/TextCardButton" +import rewards from "rewards" import { PlatformType } from "types" import { getRolePlatformStatus, @@ -20,7 +20,7 @@ import { } from "utils/rolePlatformHelpers" const DynamicShowMintLinkButton = dynamic( - () => import("platforms/Poap/ShowMintLinkButton"), + () => import("rewards/Poap/ShowMintLinkButton"), { ssr: false, } diff --git a/src/platforms/components/PointsPreview.tsx b/src/rewards/components/PointsPreview.tsx similarity index 100% rename from src/platforms/components/PointsPreview.tsx rename to src/rewards/components/PointsPreview.tsx diff --git a/src/platforms/components/PointsReward.tsx b/src/rewards/components/PointsReward.tsx similarity index 95% rename from src/platforms/components/PointsReward.tsx rename to src/rewards/components/PointsReward.tsx index ce6ea3e103..884059d687 100644 --- a/src/platforms/components/PointsReward.tsx +++ b/src/rewards/components/PointsReward.tsx @@ -9,7 +9,7 @@ import { import useGuild from "components/[guild]/hooks/useGuild" import { useRoleMembership } from "components/explorer/hooks/useMembership" import { ArrowRight, Check } from "phosphor-react" -import useDynamicRewardUserAmount from "platforms/Token/hooks/useDynamicRewardUserAmount" +import useDynamicRewardUserAmount from "rewards/Token/hooks/useDynamicRewardUserAmount" const PointsReward = ({ platform, withMotionImg }: RewardProps) => { const { urlName } = useGuild() diff --git a/src/platforms/components/PolygonIDPreview.tsx b/src/rewards/components/PolygonIDPreview.tsx similarity index 83% rename from src/platforms/components/PolygonIDPreview.tsx rename to src/rewards/components/PolygonIDPreview.tsx index df25233168..66e8301a5b 100644 --- a/src/platforms/components/PolygonIDPreview.tsx +++ b/src/rewards/components/PolygonIDPreview.tsx @@ -1,4 +1,4 @@ -import rewards from "platforms/rewards" +import rewards from "rewards" import RewardPreview from "./RewardPreview" const PolygonIDPreview = (): JSX.Element => ( diff --git a/src/platforms/components/PolygonIDReward.tsx b/src/rewards/components/PolygonIDReward.tsx similarity index 93% rename from src/platforms/components/PolygonIDReward.tsx rename to src/rewards/components/PolygonIDReward.tsx index 8b7c0a2fd0..8c70a8d17d 100644 --- a/src/platforms/components/PolygonIDReward.tsx +++ b/src/rewards/components/PolygonIDReward.tsx @@ -11,9 +11,9 @@ import useMembership, { useRoleMembership, } from "components/explorer/hooks/useMembership" import { ArrowSquareIn, LockSimple } from "phosphor-react" -import { useMintPolygonIDProofContext } from "platforms/PolygonID/components/MintPolygonIDProofProvider" -import useConnectedDID from "platforms/PolygonID/hooks/useConnectedDID" -import rewards from "platforms/rewards" +import { useMintPolygonIDProofContext } from "rewards/PolygonID/components/MintPolygonIDProofProvider" +import useConnectedDID from "rewards/PolygonID/hooks/useConnectedDID" +import rewards from "rewards" import { useMemo } from "react" import { PlatformType } from "types" diff --git a/src/platforms/components/RewardPreview.tsx b/src/rewards/components/RewardPreview.tsx similarity index 97% rename from src/platforms/components/RewardPreview.tsx rename to src/rewards/components/RewardPreview.tsx index 3da9272a5a..e365565608 100644 --- a/src/platforms/components/RewardPreview.tsx +++ b/src/rewards/components/RewardPreview.tsx @@ -10,7 +10,7 @@ import { useColorModeValue, } from "@chakra-ui/react" import { Question } from "phosphor-react" -import rewards from "platforms/rewards" +import rewards from "rewards" import { PropsWithChildren } from "react" import { PlatformName } from "types" diff --git a/src/platforms/components/SecretTextPreview.tsx b/src/rewards/components/SecretTextPreview.tsx similarity index 95% rename from src/platforms/components/SecretTextPreview.tsx rename to src/rewards/components/SecretTextPreview.tsx index a40d0d09bd..4b94166e1c 100644 --- a/src/platforms/components/SecretTextPreview.tsx +++ b/src/rewards/components/SecretTextPreview.tsx @@ -1,5 +1,5 @@ import { Circle, Icon, useColorModeValue } from "@chakra-ui/react" -import rewards from "platforms/rewards" +import rewards from "rewards" import { useWatch } from "react-hook-form" import RewardPreview from "./RewardPreview" diff --git a/src/platforms/components/SelectRoleOrSetRequirements.tsx b/src/rewards/components/SelectRoleOrSetRequirements.tsx similarity index 97% rename from src/platforms/components/SelectRoleOrSetRequirements.tsx rename to src/rewards/components/SelectRoleOrSetRequirements.tsx index 5e36e9d562..3f36c6bd7d 100644 --- a/src/platforms/components/SelectRoleOrSetRequirements.tsx +++ b/src/rewards/components/SelectRoleOrSetRequirements.tsx @@ -7,7 +7,7 @@ import RoleSelector from "components/[guild]/RoleSelector" import useGuild from "components/[guild]/hooks/useGuild" import useRoleGroup from "components/[guild]/hooks/useRoleGroup" import SetRequirements from "components/create-guild/Requirements" -import rewards, { PlatformAsRewardRestrictions } from "platforms/rewards" +import rewards, { PlatformAsRewardRestrictions } from "rewards" import { useFormContext, useWatch } from "react-hook-form" import { PlatformName } from "types" import getRandomInt from "utils/getRandomInt" diff --git a/src/platforms/components/TelegramPreview.tsx b/src/rewards/components/TelegramPreview.tsx similarity index 100% rename from src/platforms/components/TelegramPreview.tsx rename to src/rewards/components/TelegramPreview.tsx diff --git a/src/platforms/components/TextReward.tsx b/src/rewards/components/TextReward.tsx similarity index 94% rename from src/platforms/components/TextReward.tsx rename to src/rewards/components/TextReward.tsx index 3d415cf70d..29256fcdc6 100644 --- a/src/platforms/components/TextReward.tsx +++ b/src/rewards/components/TextReward.tsx @@ -12,11 +12,9 @@ import useMembership, { useRoleMembership, } from "components/explorer/hooks/useMembership" import { ArrowSquareIn, LockSimple } from "phosphor-react" -import { claimTextButtonTooltipLabel } from "platforms/SecretText/TextCardButton" -import useClaimText, { - ClaimTextModal, -} from "platforms/SecretText/hooks/useClaimText" -import rewards from "platforms/rewards" +import { claimTextButtonTooltipLabel } from "rewards/SecretText/TextCardButton" +import useClaimText, { ClaimTextModal } from "rewards/SecretText/hooks/useClaimText" +import rewards from "rewards" import { useMemo } from "react" import { PlatformType } from "types" import { diff --git a/src/platforms/components/TokenPreview.tsx b/src/rewards/components/TokenPreview.tsx similarity index 94% rename from src/platforms/components/TokenPreview.tsx rename to src/rewards/components/TokenPreview.tsx index d20a442bd4..2c086b1017 100644 --- a/src/platforms/components/TokenPreview.tsx +++ b/src/rewards/components/TokenPreview.tsx @@ -1,7 +1,7 @@ import { TokenRewardProvider, useTokenRewardContext, -} from "platforms/Token/TokenRewardContext" +} from "rewards/Token/TokenRewardContext" import { useWatch } from "react-hook-form" import { GuildPlatform } from "types" import RewardPreview from "./RewardPreview" diff --git a/src/platforms/components/TokenReward.tsx b/src/rewards/components/TokenReward.tsx similarity index 90% rename from src/platforms/components/TokenReward.tsx rename to src/rewards/components/TokenReward.tsx index d1f4847297..1e2e2812cd 100644 --- a/src/platforms/components/TokenReward.tsx +++ b/src/rewards/components/TokenReward.tsx @@ -13,15 +13,15 @@ import useMembership, { useRoleMembership, } from "components/explorer/hooks/useMembership" import { ArrowSquareIn, LockSimple } from "phosphor-react" -import { claimTextButtonTooltipLabel } from "platforms/SecretText/TextCardButton" -import ClaimTokenButton from "platforms/Token/ClaimTokenButton" -import { useIsFromGeogatedCountry } from "platforms/Token/GeogatedCountryAlert" -import PoolTag from "platforms/Token/PoolTag" +import { claimTextButtonTooltipLabel } from "rewards/SecretText/TextCardButton" +import ClaimTokenButton from "rewards/Token/ClaimTokenButton" +import { useIsFromGeogatedCountry } from "rewards/Token/GeogatedCountryAlert" +import PoolTag from "rewards/Token/PoolTag" import { TokenRewardProvider, useTokenRewardContext, -} from "platforms/Token/TokenRewardContext" -import { useClaimableTokensForRolePlatform } from "platforms/Token/hooks/useCalculateToken" +} from "rewards/Token/TokenRewardContext" +import { useClaimableTokensForRolePlatform } from "rewards/Token/hooks/useCalculateToken" import { useMemo } from "react" import { RolePlatform } from "types" import { diff --git a/src/platforms/components/UniqueTextPreview.tsx b/src/rewards/components/UniqueTextPreview.tsx similarity index 95% rename from src/platforms/components/UniqueTextPreview.tsx rename to src/rewards/components/UniqueTextPreview.tsx index db64da7989..e025221acc 100644 --- a/src/platforms/components/UniqueTextPreview.tsx +++ b/src/rewards/components/UniqueTextPreview.tsx @@ -1,5 +1,5 @@ import { Circle, Icon, useColorModeValue } from "@chakra-ui/react" -import rewards from "platforms/rewards" +import rewards from "rewards" import { useWatch } from "react-hook-form" import RewardPreview from "./RewardPreview" diff --git a/src/platforms/constants.ts b/src/rewards/constants.ts similarity index 100% rename from src/platforms/constants.ts rename to src/rewards/constants.ts diff --git a/src/platforms/hooks/usePlatformUsageInfo.ts b/src/rewards/hooks/usePlatformUsageInfo.ts similarity index 100% rename from src/platforms/hooks/usePlatformUsageInfo.ts rename to src/rewards/hooks/usePlatformUsageInfo.ts diff --git a/src/rewards/index.ts b/src/rewards/index.ts new file mode 100644 index 0000000000..a769240fbd --- /dev/null +++ b/src/rewards/index.ts @@ -0,0 +1,41 @@ +import contractCallReward from "rewards/ContractCall" +import discordReward from "rewards/Discord" +import emailReward from "rewards/Email" +import farcasterReward from "rewards/Farcaster" +import formReward from "rewards/Forms" +import gatherTownReward from "rewards/Gather" +import githubReward from "rewards/Github" +import googleReward from "rewards/Google" +import poapReward from "rewards/Poap" +import pointsReward from "rewards/Points" +import polygonIdReward from "rewards/PolygonID" +import textReward from "rewards/SecretText" +import telegramReward from "rewards/Telegram" +import tokenReward from "rewards/Token" +import twitterRewardV1, { twitterReward } from "rewards/Twitter" +import uniqueTextReward from "rewards/UniqueText" +import { Rewards } from "./types" + +export default { + TWITTER_V1: twitterRewardV1, + TWITTER: twitterReward, + EMAIL: emailReward, + TELEGRAM: telegramReward, + ERC20: tokenReward, + GATHER_TOWN: gatherTownReward, + FORM: formReward, + POINTS: pointsReward, + POLYGON_ID: polygonIdReward, + UNIQUE_TEXT: uniqueTextReward, + TEXT: textReward, + CONTRACT_CALL: contractCallReward, + GOOGLE: googleReward, + DISCORD: discordReward, + GITHUB: githubReward, + POAP: poapReward, + FARCASTER: farcasterReward, +} as const satisfies Partial + +export * from "./types" +export * from "./constants" +export * from "./utils" diff --git a/src/platforms/types.ts b/src/rewards/types.ts similarity index 100% rename from src/platforms/types.ts rename to src/rewards/types.ts diff --git a/src/platforms/utils.ts b/src/rewards/utils.ts similarity index 88% rename from src/platforms/utils.ts rename to src/rewards/utils.ts index 62f7353243..eaa87c65ad 100644 --- a/src/platforms/utils.ts +++ b/src/rewards/utils.ts @@ -1,4 +1,4 @@ -import { PlatformName } from "@guildxyz/types" +import { PlatformName } from "types" export const modalSizeForPlatform = (platform: PlatformName) => { switch (platform) { From 93a04ae4b9e7777349877e00a0f1a482b317ba2b Mon Sep 17 00:00:00 2001 From: BrickheadJohnny <92519134+BrickheadJohnny@users.noreply.github.com> Date: Tue, 2 Jul 2024 18:08:23 +0200 Subject: [PATCH 38/41] chore: upgrade to `@phosphor-icons/react` (#1343) * chore: upgrade to `@phosphor-icons/react` * Revert "chore: upgrade to `@phosphor-icons/react`" This reverts commit 7d0e3c2aa9d271f8b91f29f07d31da39c8ab928e. * re-apply changes --- next.config.js | 1 + package-lock.json | 25 +++++++++-------- package.json | 2 +- .../[guild]/AccessHub/AccessHub.tsx | 2 +- .../CampaignCards/CampaignCards.tsx | 2 +- .../components/CampaignCardMenu.tsx | 2 +- .../EditRewardAvailabilityMenuItem.tsx | 2 +- .../components/GuildPinRewardCard.tsx | 2 +- .../components/PlatformAccessButton.tsx | 2 +- .../components/RemovePlatformMenuItem.tsx | 2 +- .../AddAndOrderRoles/AddAndOrderRoles.tsx | 2 +- .../components/DraggableRoleCard.tsx | 2 +- .../[guild]/AddRewardAndCampaign.tsx | 2 +- .../AddRewardButton/AddRewardButton.tsx | 4 +-- .../AddRewardButton/SelectRolePanel.tsx | 6 ++-- .../[guild]/CollapsibleRoleSection.tsx | 2 +- .../CreateCampaignModal.tsx | 2 +- .../FormCardEditable/FormCardEditable.tsx | 2 +- .../components/Setup/OptionLayout.tsx | 2 +- .../components/Setup/RemoveButton.tsx | 2 +- .../[guild]/CreateFormModal/formConfig.tsx | 4 +-- src/components/[guild]/DeleteButton.tsx | 2 +- .../[guild]/DiscordBotPermissionsChecker.tsx | 4 +-- .../[guild]/EditGuild/EditGuildButton.tsx | 2 +- .../Admins/components/AdminSelect.tsx | 2 +- .../components/BackgroundImageUploader.tsx | 2 +- .../EditGuild/components/Events/Events.tsx | 2 +- .../components/RemoveBackgroundImage.tsx | 4 +-- .../EditGuild/components/SocialLinks.tsx | 2 +- .../Events/EventCard/components/EventInfo.tsx | 2 +- .../EventCard/components/JoinEventButton.tsx | 2 +- .../[guild]/Events/FallbackFrame.tsx | 2 +- .../[guild]/JoinModal/JoinModal.tsx | 4 +-- .../components/CompleteCaptchaJoinStep.tsx | 2 +- .../components/ConnectEmailJoinStep.tsx | 2 +- .../components/JoinStepIndicator.tsx | 2 +- .../components/ShareSocialsCheckbox.tsx | 2 +- .../JoinModal/components/WalletAuthButton.tsx | 2 +- .../[guild]/JoinModal/hooks/useJoin.tsx | 2 +- .../[guild]/LeaveButton/LeaveButton.tsx | 2 +- .../[guild]/Members/components/Member.tsx | 2 +- .../Members/components/MembersExporter.tsx | 6 ++-- .../[guild]/NoPermissionToPageFallback.tsx | 2 +- .../SummonMembers/components/EntryChannel.tsx | 2 +- .../PanelBody/components/EditableControls.tsx | 2 +- .../SummonMembers/components/PanelButton.tsx | 2 +- .../[guild]/OngoingIssuesBanner.tsx | 2 +- .../[guild]/RecheckAccessesButton.tsx | 2 +- src/components/[guild]/ReportGuildButton.tsx | 2 +- .../components/DataProviderRequirement.tsx | 2 +- .../components/ExpandRequirementsButton.tsx | 2 +- .../components/GuildCheckout/BuyPass.tsx | 2 +- .../components/ActivateGuildPinModal.tsx | 2 +- .../GuildCheckout/PurchaseRequirement.tsx | 2 +- .../GuildCheckout/components/AlphaTag.tsx | 2 +- .../GuildCheckout/components/FeePopover.tsx | 2 +- .../GuildCheckout/components/FeesTable.tsx | 2 +- .../components/GuildPinImage.tsx | 4 +-- .../GuildCheckout/components/NoReward.tsx | 2 +- .../PaymentCurrencyPicker.tsx | 2 +- .../components/PurchaseFeeAndTotal.tsx | 2 +- .../components/GuildPinOpenseaLink.tsx | 2 +- .../components/OpenseaLink.tsx | 2 +- .../components/TransactionLink.tsx | 2 +- .../components/TxError.tsx | 2 +- .../components/buttons/BuyAllowanceButton.tsx | 2 +- .../buttons/PurchaseAllowanceButton.tsx | 2 +- .../HiddenRequirementAccessIndicator.tsx | 16 +++++------ .../components/RequirementAccessIndicator.tsx | 2 +- .../components/RequirementButton.tsx | 2 +- .../RequirementDisplayComponent.tsx | 2 +- .../components/RequirementImageEditor.tsx | 4 +-- .../components/RequirementNameEditor.tsx | 2 +- .../components/ViewOriginalPopover.tsx | 2 +- .../AccessIndicator/AccessIndicator.tsx | 2 +- .../components/DynamicReward/DynamicTag.tsx | 2 +- .../RoleCard/components/EditRole/EditRole.tsx | 2 +- .../EditRole/components/EditRoleFooter.tsx | 2 +- .../EditRole/components/EditRoleHeader.tsx | 2 +- .../EditRole/components/EditRolePlatforms.tsx | 2 +- .../RoleCard/components/HiddenRewards.tsx | 2 +- .../RoleCard/components/MemberCount.tsx | 2 +- .../components/MemberCountLastSyncTooltip.tsx | 2 +- .../[guild]/RoleCard/components/Reward.tsx | 6 ++-- .../RoleCard/components/RoleDescription.tsx | 2 +- .../RolePlatforms/AddRolePlatforms.tsx | 2 +- .../DefaultAddRewardPanelWrapper.tsx | 4 +-- .../CreateNftForm/components/ImagePicker.tsx | 2 +- .../CreateNftForm/components/NftDataForm.tsx | 8 +++++- .../components/AddFormPanel/AddFormPanel.tsx | 4 +-- .../ContinueWithExistingFormAlert.tsx | 2 +- .../components/AddPoapPanel/AddPoapPanel.tsx | 4 +-- .../AddPoapPanel/components/UploadTxt.tsx | 2 +- .../components/DynamicPointsAmountForm.tsx | 2 +- .../components/PointsAmountTypeSelector.tsx | 2 +- .../components/AllowanceButton.tsx | 2 +- .../components/ConversionInput.tsx | 2 +- .../components/CustomSnapshotForm.tsx | 2 +- .../components/DynamicAmount.tsx | 4 +-- .../AddTokenPanel/components/SetTokenStep.tsx | 2 +- .../DynamicSetup/BaseValueModal.tsx | 2 +- .../DynamicSetup/DynamicRewardSetup.tsx | 2 +- .../EditRewardAvailabilityButton.tsx | 2 +- .../EditRewardAvailabilityModal.tsx | 4 +-- .../components/AvailabilityTags.tsx | 2 +- .../components/PlatformCardMenu.tsx | 2 +- .../RemovePlatformButton.tsx | 2 +- src/components/[guild]/RoleTag.tsx | 2 +- .../[guild]/SetVisibility/visibilityData.tsx | 7 ++++- src/components/[guild]/SocialIcon.tsx | 2 +- src/components/[guild]/StayConnectedToast.tsx | 2 +- .../[guild]/[group]/EditCampaignButton.tsx | 2 +- .../ActivityLogAction/ActivityLogAction.tsx | 4 +-- .../components/ActionIcon.tsx | 2 +- .../components/ActionLabel.tsx | 2 +- .../components/ActivityLogRoleTag.tsx | 2 +- .../components/BeforeAfterActions.tsx | 4 +-- .../components/CopyAddress.tsx | 2 +- .../components/FilterBy.tsx | 4 +-- .../components/ViewInCRM.tsx | 2 +- .../components/ViewInFormResponses.tsx | 2 +- .../components/ViewRole.tsx | 2 +- .../ActivityLogAction/components/FormTag.tsx | 4 +-- .../ActivityLogAction/components/GuildTag.tsx | 2 +- .../components/IdentityTag.tsx | 2 +- .../components/MoreActions.tsx | 2 +- .../components/RewardTag.tsx | 4 +-- .../components/UpdatedDataGrid.tsx | 2 +- .../ActivityLogAction/components/UserTag.tsx | 2 +- .../components/DateRangeInput.tsx | 7 ++++- .../components/FilterTag/FilterTag.tsx | 2 +- .../components/FiltersInput.tsx | 2 +- src/components/[guild]/activity/constants.ts | 2 +- .../claim-poap/components/MintLinkModal.tsx | 2 +- .../claim-poap/components/PoapImage.tsx | 2 +- .../claim-poap/components/SocialLinks.tsx | 2 +- .../collect/components/CollectibleImage.tsx | 2 +- .../Details/components/BlockExplorerLink.tsx | 2 +- .../EditNFTDescriptionModalButton.tsx | 4 +-- .../collect/components/EditNftButton.tsx | 2 +- .../[guild]/collect/components/Links.tsx | 2 +- .../collect/components/RequirementsCard.tsx | 2 +- .../collect/components/ShareButton.tsx | 2 +- src/components/[guild]/crm/CrmMenu.tsx | 2 +- .../[guild]/crm/CustomizeViewModal.tsx | 2 +- .../ExportMembers/ExportCard/ExportCard.tsx | 2 +- .../ExportCard/ExportParamsTags.tsx | 2 +- .../crm/ExportMembers/ExportMembersModal.tsx | 2 +- .../crm/FilterByRoles/FilterByRoles.tsx | 2 +- .../components/AddAndEditHiddenRoles.tsx | 2 +- .../components/AddHiddenRoleButton.tsx | 2 +- .../components/FilterByRolesSearch.tsx | 2 +- src/components/[guild]/crm/Identities.tsx | 4 +-- .../[guild]/crm/IdentitiesExpansionToggle.tsx | 5 +++- .../[guild]/crm/IdentitiesSearch.tsx | 2 +- src/components/[guild]/crm/OrderByColumn.tsx | 2 +- src/components/[guild]/crm/RoleTags.tsx | 2 +- src/components/[guild]/forms/FormNoAccess.tsx | 2 +- .../forms/SuccessfullySubmittedForm.tsx | 2 +- .../responses/CollapsibleIdentityTags.tsx | 2 +- .../[guild]/forms/responses/ResponseModal.tsx | 2 +- .../LeaderboardAirdropFallbackCard.tsx | 2 +- .../leaderboard/LeaderboardPointsSelector.tsx | 2 +- .../leaderboard/LeaderboardUserCard.tsx | 2 +- .../RecalculateLeaderboardButton.tsx | 2 +- .../leaderboard/Snapshots/SnapshotTable.tsx | 2 +- src/components/[guild]/messages/Message.tsx | 2 +- .../[guild]/messages/NoMessages.tsx | 2 +- .../SendNewMessage/SendNewMessage.tsx | 2 +- src/components/_app/InfoBanner.tsx | 2 +- .../components/PlatformMergeErrorAlert.tsx | 4 +-- .../components/WalletLinkHelperModal.tsx | 2 +- .../WalletSelectorModal.tsx | 2 +- .../components/ConnectorButton.tsx | 2 +- .../components/ExportWaaSModal.tsx | 2 +- .../components/MembersChartTooltip.tsx | 2 +- src/components/common/AddCard.tsx | 2 +- src/components/common/CheckboxColorCard.tsx | 2 +- src/components/common/DataBlock.tsx | 2 +- src/components/common/DataBlockWithCopy.tsx | 2 +- .../components/DCServerCard.tsx | 2 +- .../GoogleGuildSetup/GoogleGuildSetup.tsx | 4 +-- .../Layout/components/Account/Account.tsx | 2 +- .../components/AccountModal/AccountModal.tsx | 2 +- .../components/AccountConnections.tsx | 4 +-- .../components/LinkAddressButton.tsx | 2 +- .../AccountModal/components/LinkedAddress.tsx | 2 +- .../AccountModal/components/SharedSocials.tsx | 12 ++++---- .../components/SocialAccount/EmailAddress.tsx | 4 +-- .../SocialAccount/FarcasterProfile.tsx | 4 +-- .../components/DisconnectAccountButton.tsx | 2 +- .../Notifications/Notifications.tsx | 2 +- .../components/NotificationsActivityLog.tsx | 2 +- .../components/Web3Inbox/Web3Inbox.tsx | 4 +-- .../components/Web3Inbox/Web3InboxMessage.tsx | 2 +- .../common/Layout/components/BackButton.tsx | 2 +- .../common/Layout/components/Footer.tsx | 2 +- .../Layout/components/NavMenu/NavMenu.tsx | 12 ++++---- .../NavMenu/components/ThemeSwitcher.tsx | 2 +- src/components/common/LinkMenuItem.tsx | 2 +- src/components/common/PulseMarker/Marker.tsx | 2 +- .../CustomIndicatorsContainerWithCopy.tsx | 2 +- .../components/OptionIcon.tsx | 2 +- src/components/common/VerifiedIcon.tsx | 2 +- .../BasicInfo/components/ContactInfo.tsx | 2 +- .../IconSelector/IconSelector.tsx | 2 +- .../IconSelector/components/PhotoUploader.tsx | 2 +- .../components/PlatformSelectButton.tsx | 4 +-- .../components/AddRequirement.tsx | 2 +- .../components/BalancyCounter.tsx | 2 +- .../components/ProvidedValueDisplay.tsx | 2 +- .../UnsupportedRequirementTypeCard.tsx | 2 +- .../TelegramGroup/TelegramGroup.tsx | 4 +-- .../explorer/GoToCreateGuildButton.tsx | 2 +- src/components/explorer/GuildCard.tsx | 2 +- src/components/explorer/SearchBar.tsx | 2 +- src/components/explorer/SearchBarFilters.tsx | 2 +- src/components/explorer/YourGuilds.tsx | 2 +- src/components/index/CallToAction.tsx | 2 +- src/components/index/Discover.tsx | 2 +- .../index/ExploreTrendingGuilds.tsx | 2 +- src/components/index/Hero.tsx | 2 +- src/components/index/TokenBasedMembership.tsx | 2 +- src/components/leaderboard/MysteryBoxCard.tsx | 2 +- .../leaderboard/PinLeaderboardUserCard.tsx | 4 +-- .../leaderboard/ScoreFormulaPopover.tsx | 2 +- .../plugins/ToolbarPlugin/ToolbarPlugin.tsx | 28 +++++++++---------- .../ToolbarPlugin/components/ImageEditor.tsx | 2 +- .../ToolbarPlugin/components/LinkEditor.tsx | 2 +- src/pages/[guild]/events.tsx | 2 +- src/pages/[guild]/index.tsx | 4 +-- src/pages/_app.tsx | 4 +-- src/pages/_error.tsx | 2 +- .../Airdrop/AirdropRequirement.tsx | 2 +- .../providedValue/AirdropProvidedValue.tsx | 2 +- .../Allowlist/AllowlistRequirement.tsx | 2 +- .../components/AllowlistFormInputs.tsx | 4 +-- .../Captcha/CaptchaRequirement.tsx | 2 +- .../Captcha/components/CompleteCaptcha.tsx | 2 +- .../ContractState/ContractStateForm.tsx | 2 +- .../ContractStateRequirement.tsx | 2 +- .../Discord/DiscordRequirement.tsx | 2 +- src/requirements/Email/EmailRequirement.tsx | 2 +- .../Farcaster/FarcasterRequirement.tsx | 2 +- .../Farcaster/components/FarcasterCast.tsx | 2 +- .../components/FarcasterCastSmall.tsx | 2 +- .../ExpectedMultipleChoice.tsx | 2 +- src/requirements/Free/FreeRequirement.tsx | 2 +- src/requirements/Fuel/FuelRequirement.tsx | 2 +- .../GitcoinPassportRequirement.tsx | 2 +- .../components/SetupPassport.tsx | 2 +- src/requirements/Github/GithubRequirement.tsx | 2 +- src/requirements/Guild/GuildRequirement.tsx | 2 +- src/requirements/Nft/NftForm.tsx | 2 +- src/requirements/Nft/NftRequirement.tsx | 4 +-- .../Nft/components/AttributePicker.tsx | 2 +- src/requirements/Nft/components/UploadIDs.tsx | 2 +- src/requirements/Parallel/ParallelForm.tsx | 2 +- src/requirements/Payment/PaymentForm.tsx | 2 +- .../Payment/PaymentRequirement.tsx | 2 +- .../WithdrawButton/WithdrawButton.tsx | 2 +- .../Points/components/MaxMinAmount.tsx | 2 +- .../PolygonID/PolygonIDRequirement.tsx | 2 +- .../PolygonID/components/ConnectPolygonID.tsx | 2 +- .../PolygonID/components/PolygonIDQuery.tsx | 2 +- .../Snapshot/SnapshotRequirement.tsx | 2 +- .../Strategy/components/SingleStrategy.tsx | 2 +- .../Twitter/TwitterRequirement.tsx | 2 +- .../Twitter/components/TwitterIntent.tsx | 2 +- .../Twitter/components/TwitterListLink.tsx | 2 +- .../Twitter/components/TwitterTweetLink.tsx | 2 +- src/requirements/Uniswap/UniswapForm.tsx | 2 +- .../VisitLink/VisitLinkRequirement.tsx | 2 +- .../WalletActivityRequirement.tsx | 8 +++++- .../Web3Inbox/Web3InboxRequirement.tsx | 2 +- src/requirements/common/ChainPicker.tsx | 2 +- src/requirements/common/MinMaxAmount.tsx | 2 +- src/requirements/index.ts | 2 +- src/requirements/requirements.ts | 8 +++--- .../ContractCall/ContractCallCardMenu.tsx | 2 +- .../ContractCall/ContractCallReward.tsx | 2 +- .../DiscordCardMenu/DiscordCardMenu.tsx | 2 +- .../components/DiscordCaptchaSwitch.tsx | 2 +- .../DiscordCardSettings.tsx | 2 +- src/rewards/Discord/index.ts | 10 +++---- src/rewards/Email/index.ts | 2 +- src/rewards/Forms/FormCardLinkButton.tsx | 2 +- src/rewards/Forms/FormCardMenu.tsx | 2 +- src/rewards/Forms/index.ts | 10 +++---- src/rewards/Gather/ClaimGatherModal.tsx | 2 +- src/rewards/Gather/GatherCardButton.tsx | 2 +- src/rewards/Gather/GatherCardMenu.tsx | 2 +- src/rewards/Gather/GatherConnectionForm.tsx | 2 +- src/rewards/Gather/index.ts | 10 +++---- src/rewards/Github/index.ts | 8 +++--- src/rewards/Google/GoogleCardWarning.tsx | 2 +- src/rewards/Google/index.ts | 12 ++++---- src/rewards/Poap/PoapCardMenu.tsx | 2 +- src/rewards/Points/PointsCardButton.tsx | 2 +- src/rewards/Points/PointsCardMenu.tsx | 2 +- src/rewards/Points/index.tsx | 8 +++--- .../PolygonID/components/ConnectDIDModal.tsx | 2 +- .../components/PolygonIDQRCodeModal.tsx | 4 +-- src/rewards/PolygonID/index.ts | 10 +++---- src/rewards/SecretText/SecretTextCardMenu.tsx | 2 +- src/rewards/Telegram/index.ts | 8 +++--- .../Token/ClaimTokenModal/ClaimTokenModal.tsx | 4 +-- .../Token/DynamicRewardCalculationTable.tsx | 4 +-- src/rewards/Token/DynamicRewardModal.tsx | 2 +- src/rewards/Token/DynamicTypeForm.tsx | 2 +- src/rewards/Token/EditTokenModal.tsx | 4 +-- src/rewards/Token/GeogatedCountryAlert.tsx | 2 +- src/rewards/Token/PoolTag.tsx | 4 +-- src/rewards/Token/TokenConversionTag.tsx | 4 +-- src/rewards/Token/TokenRewardCardEditMenu.tsx | 2 +- src/rewards/UniqueText/UniqueTextCardMenu.tsx | 2 +- src/rewards/UniqueText/UniqueTextDataForm.tsx | 4 +-- src/rewards/UniqueText/index.ts | 10 +++---- src/rewards/components/FormReward.tsx | 2 +- src/rewards/components/GatherReward.tsx | 6 ++-- src/rewards/components/PoapReward.tsx | 4 +-- src/rewards/components/PointsReward.tsx | 2 +- src/rewards/components/PolygonIDReward.tsx | 6 ++-- src/rewards/components/RewardPreview.tsx | 4 +-- src/rewards/components/TextReward.tsx | 6 ++-- src/rewards/components/TokenReward.tsx | 4 +-- src/rewards/types.ts | 2 +- 327 files changed, 485 insertions(+), 458 deletions(-) diff --git a/next.config.js b/next.config.js index df0acc8bf7..091c739d9d 100644 --- a/next.config.js +++ b/next.config.js @@ -80,6 +80,7 @@ const nextConfig = { }, experimental: { scrollRestoration: true, + optimizePackageImports: ["@phosphor-icons/react"], }, async rewrites() { return { diff --git a/package-lock.json b/package-lock.json index 3037a660d3..d13d5fc1e7 100644 --- a/package-lock.json +++ b/package-lock.json @@ -31,6 +31,7 @@ "@lexical/selection": "^0.12.0", "@lexical/utils": "^0.12.0", "@nouns/assets": "^0.4.2", + "@phosphor-icons/react": "^2.1.7", "@snyk/protect": "latest", "@t3-oss/env-nextjs": "^0.10.1", "@tanstack/react-query": "^5.26.3", @@ -57,7 +58,6 @@ "mini-svg-data-uri": "^1.4.4", "next": "14.0.1", "papaparse": "^5.4.1", - "phosphor-react": "^1.4.1", "posthog-js": "^1.139.3", "qrcode.react": "^3.1.0", "randombytes": "^2.1.0", @@ -7452,6 +7452,18 @@ "node": "^16 || ^18 || >= 20" } }, + "node_modules/@phosphor-icons/react": { + "version": "2.1.7", + "resolved": "https://registry.npmjs.org/@phosphor-icons/react/-/react-2.1.7.tgz", + "integrity": "sha512-g2e2eVAn1XG2a+LI09QU3IORLhnFNAFkNbo2iwbX6NOKSLOwvEMmTa7CgOzEbgNWR47z8i8kwjdvYZ5fkGx1mQ==", + "engines": { + "node": ">=10" + }, + "peerDependencies": { + "react": ">= 16.8", + "react-dom": ">= 16.8" + } + }, "node_modules/@pkgjs/parseargs": { "version": "0.11.0", "resolved": "https://registry.npmjs.org/@pkgjs/parseargs/-/parseargs-0.11.0.tgz", @@ -27419,17 +27431,6 @@ "node": ">=4" } }, - "node_modules/phosphor-react": { - "version": "1.4.1", - "resolved": "https://registry.npmjs.org/phosphor-react/-/phosphor-react-1.4.1.tgz", - "integrity": "sha512-gO5j7U0xZrdglTAYDYPACU4xDOFBTJmptrrB/GeR+tHhCZF3nUMyGmV/0hnloKjuTrOmpSFlbfOY78H39rgjUQ==", - "engines": { - "node": ">=10" - }, - "peerDependencies": { - "react": ">=16" - } - }, "node_modules/picocolors": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.0.1.tgz", diff --git a/package.json b/package.json index ae3c3b66c9..d3b3a4a070 100644 --- a/package.json +++ b/package.json @@ -41,6 +41,7 @@ "@lexical/selection": "^0.12.0", "@lexical/utils": "^0.12.0", "@nouns/assets": "^0.4.2", + "@phosphor-icons/react": "^2.1.7", "@snyk/protect": "latest", "@t3-oss/env-nextjs": "^0.10.1", "@tanstack/react-query": "^5.26.3", @@ -67,7 +68,6 @@ "mini-svg-data-uri": "^1.4.4", "next": "14.0.1", "papaparse": "^5.4.1", - "phosphor-react": "^1.4.1", "posthog-js": "^1.139.3", "qrcode.react": "^3.1.0", "randombytes": "^2.1.0", diff --git a/src/components/[guild]/AccessHub/AccessHub.tsx b/src/components/[guild]/AccessHub/AccessHub.tsx index 3dd9646a8d..2462c5226d 100644 --- a/src/components/[guild]/AccessHub/AccessHub.tsx +++ b/src/components/[guild]/AccessHub/AccessHub.tsx @@ -7,11 +7,11 @@ import { SimpleGrid, Stack, } from "@chakra-ui/react" +import { StarHalf } from "@phosphor-icons/react" import Card from "components/common/Card" import ClientOnly from "components/common/ClientOnly" import useMembership from "components/explorer/hooks/useMembership" import dynamic from "next/dynamic" -import { StarHalf } from "phosphor-react" import PointsRewardCard from "rewards/Points/PointsRewardCard" import { TokenRewardCard } from "rewards/Token/TokenRewardCard" import { PlatformType } from "types" diff --git a/src/components/[guild]/AccessHub/components/CampaignCards/CampaignCards.tsx b/src/components/[guild]/AccessHub/components/CampaignCards/CampaignCards.tsx index 683a843a7a..f593574843 100644 --- a/src/components/[guild]/AccessHub/components/CampaignCards/CampaignCards.tsx +++ b/src/components/[guild]/AccessHub/components/CampaignCards/CampaignCards.tsx @@ -6,6 +6,7 @@ import { Text, useColorModeValue, } from "@chakra-ui/react" +import { ArrowRight, Plus } from "@phosphor-icons/react" import useGuild from "components/[guild]/hooks/useGuild" import useGuildPermission from "components/[guild]/hooks/useGuildPermission" import Button from "components/common/Button" @@ -15,7 +16,6 @@ import dynamic from "next/dynamic" import Image from "next/image" import Link from "next/link" import { useRouter } from "next/router" -import { ArrowRight, Plus } from "phosphor-react" const DynamicCampaignCardMenu = dynamic( () => import("./components/CampaignCardMenu") diff --git a/src/components/[guild]/AccessHub/components/CampaignCards/components/CampaignCardMenu.tsx b/src/components/[guild]/AccessHub/components/CampaignCards/components/CampaignCardMenu.tsx index affeb1e88d..439b1c001c 100644 --- a/src/components/[guild]/AccessHub/components/CampaignCards/components/CampaignCardMenu.tsx +++ b/src/components/[guild]/AccessHub/components/CampaignCards/components/CampaignCardMenu.tsx @@ -9,10 +9,10 @@ import { useColorModeValue, useDisclosure, } from "@chakra-ui/react" +import { PencilSimple, TrashSimple } from "@phosphor-icons/react" import PlatformCardMenu from "components/[guild]/RolePlatforms/components/PlatformCard/components/PlatformCardMenu" import Button from "components/common/Button" import { Alert } from "components/common/Modal" -import { PencilSimple, TrashSimple } from "phosphor-react" import { useRef } from "react" import useDeleteRoleGroup from "../hooks/useDeleteRoleGroup" import EditCampaignModal from "./EditCampaignModal" diff --git a/src/components/[guild]/AccessHub/components/EditRewardAvailabilityMenuItem.tsx b/src/components/[guild]/AccessHub/components/EditRewardAvailabilityMenuItem.tsx index 470f966897..c12d9a3322 100644 --- a/src/components/[guild]/AccessHub/components/EditRewardAvailabilityMenuItem.tsx +++ b/src/components/[guild]/AccessHub/components/EditRewardAvailabilityMenuItem.tsx @@ -1,8 +1,8 @@ import { MenuItem, useDisclosure } from "@chakra-ui/react" +import { Clock } from "@phosphor-icons/react" import EditRewardAvailabilityModal from "components/[guild]/RolePlatforms/components/EditRewardAvailabilityModal" import useGuild from "components/[guild]/hooks/useGuild" import useToast from "hooks/useToast" -import { Clock } from "phosphor-react" import { PlatformName, PlatformType } from "types" import useEditRolePlatform from "../hooks/useEditRolePlatform" diff --git a/src/components/[guild]/AccessHub/components/GuildPinRewardCard.tsx b/src/components/[guild]/AccessHub/components/GuildPinRewardCard.tsx index f8fd1ba0ee..5441d55a9e 100644 --- a/src/components/[guild]/AccessHub/components/GuildPinRewardCard.tsx +++ b/src/components/[guild]/AccessHub/components/GuildPinRewardCard.tsx @@ -1,10 +1,10 @@ import { Icon, Tooltip, useColorModeValue } from "@chakra-ui/react" +import { CircleWavyCheck, Question } from "@phosphor-icons/react" import { useMintGuildPinContext } from "components/[guild]/Requirements/components/GuildCheckout/MintGuildPinContext" import useGuild from "components/[guild]/hooks/useGuild" import useGuildPermission from "components/[guild]/hooks/useGuildPermission" import RewardCard from "components/common/RewardCard" import dynamic from "next/dynamic" -import { CircleWavyCheck, Question } from "phosphor-react" const DynamicMintGuildPin = dynamic( () => diff --git a/src/components/[guild]/AccessHub/components/PlatformAccessButton.tsx b/src/components/[guild]/AccessHub/components/PlatformAccessButton.tsx index 159526070d..0239a54f9d 100644 --- a/src/components/[guild]/AccessHub/components/PlatformAccessButton.tsx +++ b/src/components/[guild]/AccessHub/components/PlatformAccessButton.tsx @@ -1,6 +1,6 @@ import { Icon } from "@chakra-ui/react" +import { ArrowSquareOut } from "@phosphor-icons/react" import Button from "components/common/Button" -import { ArrowSquareOut } from "phosphor-react" import rewards from "rewards" import { GuildPlatform, PlatformType } from "types" import usePlatformAccessButton from "./usePlatformAccessButton" diff --git a/src/components/[guild]/AccessHub/components/RemovePlatformMenuItem.tsx b/src/components/[guild]/AccessHub/components/RemovePlatformMenuItem.tsx index 76d6fb918d..281ac49108 100644 --- a/src/components/[guild]/AccessHub/components/RemovePlatformMenuItem.tsx +++ b/src/components/[guild]/AccessHub/components/RemovePlatformMenuItem.tsx @@ -1,9 +1,9 @@ import { MenuItem, useColorModeValue, useDisclosure } from "@chakra-ui/react" +import { TrashSimple } from "@phosphor-icons/react" import useRemoveGuildPlatform from "components/[guild]/AccessHub/hooks/useRemoveGuildPlatform" import { AlreadyGrantedAccessesWillRemainInfo } from "components/[guild]/RolePlatforms/components/RemovePlatformButton/RemovePlatformButton" import useGuild from "components/[guild]/hooks/useGuild" import ConfirmationAlert from "components/create-guild/Requirements/components/ConfirmationAlert" -import { TrashSimple } from "phosphor-react" import rewards from "rewards" import { PlatformType } from "types" diff --git a/src/components/[guild]/AddAndOrderRoles/AddAndOrderRoles.tsx b/src/components/[guild]/AddAndOrderRoles/AddAndOrderRoles.tsx index 0a4708886c..1fffc9d3ca 100644 --- a/src/components/[guild]/AddAndOrderRoles/AddAndOrderRoles.tsx +++ b/src/components/[guild]/AddAndOrderRoles/AddAndOrderRoles.tsx @@ -9,9 +9,9 @@ import { MenuList, useDisclosure, } from "@chakra-ui/react" +import { CaretDown, ListNumbers, Plus } from "@phosphor-icons/react" import Button from "components/common/Button" import useIsStuck from "hooks/useIsStuck" -import { CaretDown, ListNumbers, Plus } from "phosphor-react" import { useEffect, useRef } from "react" import RecheckAccessesButton from "../RecheckAccessesButton" import AddRoleDrawer from "./components/AddRoleDrawer" diff --git a/src/components/[guild]/AddAndOrderRoles/components/DraggableRoleCard.tsx b/src/components/[guild]/AddAndOrderRoles/components/DraggableRoleCard.tsx index 4cede9386f..905efc0b61 100644 --- a/src/components/[guild]/AddAndOrderRoles/components/DraggableRoleCard.tsx +++ b/src/components/[guild]/AddAndOrderRoles/components/DraggableRoleCard.tsx @@ -1,9 +1,9 @@ import { Heading, HStack, Icon, Spacer } from "@chakra-ui/react" +import { DotsSixVertical } from "@phosphor-icons/react" import MemberCount from "components/[guild]/RoleCard/components/MemberCount" import Visibility from "components/[guild]/Visibility" import Card from "components/common/Card" import GuildLogo from "components/common/GuildLogo" -import { DotsSixVertical } from "phosphor-react" import { Role } from "types" type Props = { diff --git a/src/components/[guild]/AddRewardAndCampaign.tsx b/src/components/[guild]/AddRewardAndCampaign.tsx index 1da0ac73ac..d61cc681d1 100644 --- a/src/components/[guild]/AddRewardAndCampaign.tsx +++ b/src/components/[guild]/AddRewardAndCampaign.tsx @@ -12,8 +12,8 @@ import { Text, useDisclosure, } from "@chakra-ui/react" +import { CaretDown, Plus } from "@phosphor-icons/react" import CreateCampaignModal from "components/[guild]/CreateCampaignModal" -import { CaretDown, Plus } from "phosphor-react" import AddRewardButton from "./AddRewardButton" import { useIsTabsStuck } from "./Tabs" import { useThemeContext } from "./ThemeContext" diff --git a/src/components/[guild]/AddRewardButton/AddRewardButton.tsx b/src/components/[guild]/AddRewardButton/AddRewardButton.tsx index 00019fd2ab..4df20b759b 100644 --- a/src/components/[guild]/AddRewardButton/AddRewardButton.tsx +++ b/src/components/[guild]/AddRewardButton/AddRewardButton.tsx @@ -1,14 +1,14 @@ import { ModalOverlay, useDisclosure } from "@chakra-ui/react" import { Schemas, Visibility } from "@guildxyz/types" +import { Plus } from "@phosphor-icons/react" import Button from "components/common/Button" import DiscardAlert from "components/common/DiscardAlert" import { Modal } from "components/common/Modal" import useShowErrorToast from "hooks/useShowErrorToast" import { atom, useAtomValue } from "jotai" -import { Plus } from "phosphor-react" +import { FormProvider, useForm, useWatch } from "react-hook-form" import rewards, { modalSizeForPlatform } from "rewards" import { RewardData } from "rewards/types" -import { FormProvider, useForm, useWatch } from "react-hook-form" import { RoleFormType } from "types" import { AddRewardProvider, useAddRewardContext } from "../AddRewardContext" import { ClientStateRequirementHandlerProvider } from "../RequirementHandlerContext" diff --git a/src/components/[guild]/AddRewardButton/SelectRolePanel.tsx b/src/components/[guild]/AddRewardButton/SelectRolePanel.tsx index fa1af10872..a12436a877 100644 --- a/src/components/[guild]/AddRewardButton/SelectRolePanel.tsx +++ b/src/components/[guild]/AddRewardButton/SelectRolePanel.tsx @@ -12,14 +12,14 @@ import { useColorModeValue, } from "@chakra-ui/react" import { Visibility } from "@guildxyz/types" +import { ArrowLeft, Info } from "@phosphor-icons/react" import { usePostHogContext } from "components/_app/PostHogProvider" import Button from "components/common/Button" import useCreateRRR, { SubmitData } from "hooks/useCreateRRR" -import { ArrowLeft, Info } from "phosphor-react" -import SelectRoleOrSetRequirements from "rewards/components/SelectRoleOrSetRequirements" -import rewards, { CAPACITY_TIME_PLATFORMS } from "rewards" import { useState } from "react" import { useFormContext, useWatch } from "react-hook-form" +import rewards, { CAPACITY_TIME_PLATFORMS } from "rewards" +import SelectRoleOrSetRequirements from "rewards/components/SelectRoleOrSetRequirements" import { RoleTypeToAddTo, useAddRewardContext } from "../AddRewardContext" import useGuild from "../hooks/useGuild" import { defaultValues } from "./AddRewardButton" diff --git a/src/components/[guild]/CollapsibleRoleSection.tsx b/src/components/[guild]/CollapsibleRoleSection.tsx index 71a3ba62f5..cf8f2666ed 100644 --- a/src/components/[guild]/CollapsibleRoleSection.tsx +++ b/src/components/[guild]/CollapsibleRoleSection.tsx @@ -1,6 +1,6 @@ import { Box, Button, Collapse, Icon, Stack, useDisclosure } from "@chakra-ui/react" -import { CaretDown } from "phosphor-react" +import { CaretDown } from "@phosphor-icons/react" import capitalize from "utils/capitalize" const CollapsibleRoleSection = ({ diff --git a/src/components/[guild]/CreateCampaignModal/CreateCampaignModal.tsx b/src/components/[guild]/CreateCampaignModal/CreateCampaignModal.tsx index ff937c2696..61dbd4e0fd 100644 --- a/src/components/[guild]/CreateCampaignModal/CreateCampaignModal.tsx +++ b/src/components/[guild]/CreateCampaignModal/CreateCampaignModal.tsx @@ -6,11 +6,11 @@ import { ModalHeader, ModalOverlay, } from "@chakra-ui/react" +import { ArrowRight } from "@phosphor-icons/react" import Button from "components/common/Button" import { Modal } from "components/common/Modal" import usePinata from "hooks/usePinata" import useSubmitWithUpload from "hooks/useSubmitWithUpload" -import { ArrowRight } from "phosphor-react" import { FormProvider, useForm } from "react-hook-form" import CampaignForm, { CampaignFormType } from "./components/CampaignForm" import useCreateRoleGroup from "./hooks/useCreateRoleGroup" diff --git a/src/components/[guild]/CreateFormModal/components/FormCardEditable/FormCardEditable.tsx b/src/components/[guild]/CreateFormModal/components/FormCardEditable/FormCardEditable.tsx index e7959fd1a3..1868e5534f 100644 --- a/src/components/[guild]/CreateFormModal/components/FormCardEditable/FormCardEditable.tsx +++ b/src/components/[guild]/CreateFormModal/components/FormCardEditable/FormCardEditable.tsx @@ -14,6 +14,7 @@ import { Tooltip, } from "@chakra-ui/react" import { Schemas } from "@guildxyz/types" +import { DotsSixVertical, PencilSimple, Trash } from "@phosphor-icons/react" import { CreateForm } from "components/[guild]/RolePlatforms/components/AddRoleRewardModal/components/AddFormPanel" import Button from "components/common/Button" import Card from "components/common/Card" @@ -21,7 +22,6 @@ import CardMotionWrapper from "components/common/CardMotionWrapper" import ControlledSelect from "components/common/ControlledSelect" import FormErrorMessage from "components/common/FormErrorMessage" import { Reorder, useDragControls } from "framer-motion" -import { DotsSixVertical, PencilSimple, Trash } from "phosphor-react" import { useState } from "react" import { useController, useFormContext, useWatch } from "react-hook-form" import { SelectOption } from "types" diff --git a/src/components/[guild]/CreateFormModal/components/Setup/OptionLayout.tsx b/src/components/[guild]/CreateFormModal/components/Setup/OptionLayout.tsx index 15f39eaa4f..6fb30a522f 100644 --- a/src/components/[guild]/CreateFormModal/components/Setup/OptionLayout.tsx +++ b/src/components/[guild]/CreateFormModal/components/Setup/OptionLayout.tsx @@ -7,8 +7,8 @@ import { Icon, useColorModeValue, } from "@chakra-ui/react" +import { DotsSixVertical } from "@phosphor-icons/react" import { Reorder, useDragControls } from "framer-motion" -import { DotsSixVertical } from "phosphor-react" import { PropsWithChildren, ReactNode } from "react" import { Rest } from "types" diff --git a/src/components/[guild]/CreateFormModal/components/Setup/RemoveButton.tsx b/src/components/[guild]/CreateFormModal/components/Setup/RemoveButton.tsx index 77c8c689f3..b269a4276d 100644 --- a/src/components/[guild]/CreateFormModal/components/Setup/RemoveButton.tsx +++ b/src/components/[guild]/CreateFormModal/components/Setup/RemoveButton.tsx @@ -1,5 +1,5 @@ import { IconButton, IconButtonProps } from "@chakra-ui/react" -import { X } from "phosphor-react" +import { X } from "@phosphor-icons/react" const RemoveButton = ( props: Omit< diff --git a/src/components/[guild]/CreateFormModal/formConfig.tsx b/src/components/[guild]/CreateFormModal/formConfig.tsx index 7628806ed5..e43c7f3b06 100644 --- a/src/components/[guild]/CreateFormModal/formConfig.tsx +++ b/src/components/[guild]/CreateFormModal/formConfig.tsx @@ -1,12 +1,12 @@ import { Schemas } from "@guildxyz/types" -import OptionIcon from "components/common/StyledSelect/components/CustomSelectOption/components/OptionIcon" import { CheckSquare, NumberCircleFive, NumberSquareFive, RadioButton, Textbox, -} from "phosphor-react" +} from "@phosphor-icons/react" +import OptionIcon from "components/common/StyledSelect/components/CustomSelectOption/components/OptionIcon" import { ComponentType, ReactNode } from "react" import { ExpectedFieldDataProps, diff --git a/src/components/[guild]/DeleteButton.tsx b/src/components/[guild]/DeleteButton.tsx index 0bfea6a0e3..7f1b66bcaf 100644 --- a/src/components/[guild]/DeleteButton.tsx +++ b/src/components/[guild]/DeleteButton.tsx @@ -1,5 +1,5 @@ import { ButtonProps, Icon, IconButton, Tooltip } from "@chakra-ui/react" -import { Trash } from "phosphor-react" +import { Trash } from "@phosphor-icons/react" import { PropsWithChildren } from "react" type Props = { diff --git a/src/components/[guild]/DiscordBotPermissionsChecker.tsx b/src/components/[guild]/DiscordBotPermissionsChecker.tsx index 2a9fccacb8..020ae5a493 100644 --- a/src/components/[guild]/DiscordBotPermissionsChecker.tsx +++ b/src/components/[guild]/DiscordBotPermissionsChecker.tsx @@ -1,4 +1,3 @@ -import { env } from "env" import { ListItem, ModalBody, @@ -12,11 +11,12 @@ import { UnorderedList, useDisclosure, } from "@chakra-ui/react" +import { ArrowSquareOut, Info } from "@phosphor-icons/react" import Button from "components/common/Button" import DiscordRoleVideo from "components/common/DiscordRoleVideo" import { Modal } from "components/common/Modal" +import { env } from "env" import { ActionToastOptions, useToastWithButton } from "hooks/useToast" -import { ArrowSquareOut, Info } from "phosphor-react" import { useMemo, useRef, useState } from "react" import useSWRImmutable from "swr/immutable" import { PlatformType } from "types" diff --git a/src/components/[guild]/EditGuild/EditGuildButton.tsx b/src/components/[guild]/EditGuild/EditGuildButton.tsx index d94fe3a328..be97084fe9 100644 --- a/src/components/[guild]/EditGuild/EditGuildButton.tsx +++ b/src/components/[guild]/EditGuild/EditGuildButton.tsx @@ -1,5 +1,5 @@ import { IconButton } from "@chakra-ui/react" -import { GearSix } from "phosphor-react" +import { GearSix } from "@phosphor-icons/react" import { useThemeContext } from "../ThemeContext" import { useEditGuildDrawer } from "./EditGuildDrawerContext" diff --git a/src/components/[guild]/EditGuild/components/Admins/components/AdminSelect.tsx b/src/components/[guild]/EditGuild/components/Admins/components/AdminSelect.tsx index eb29a4a167..67e1ffbf54 100644 --- a/src/components/[guild]/EditGuild/components/Admins/components/AdminSelect.tsx +++ b/src/components/[guild]/EditGuild/components/Admins/components/AdminSelect.tsx @@ -1,4 +1,5 @@ import { forwardRef, HStack, Icon } from "@chakra-ui/react" +import { Warning } from "@phosphor-icons/react" import { chakraComponents, CreatableSelect, @@ -9,7 +10,6 @@ import { import CopyableAddress from "components/common/CopyableAddress" import StyledSelect from "components/common/StyledSelect" import CustomMenuList from "components/common/StyledSelect/components/CustomMenuList" -import { Warning } from "phosphor-react" import { PropsWithChildren, useEffect } from "react" import { useFormContext, useWatch } from "react-hook-form" import { useEnsAddress } from "wagmi" diff --git a/src/components/[guild]/EditGuild/components/BackgroundImageUploader.tsx b/src/components/[guild]/EditGuild/components/BackgroundImageUploader.tsx index c94c29c26c..776ce75d00 100644 --- a/src/components/[guild]/EditGuild/components/BackgroundImageUploader.tsx +++ b/src/components/[guild]/EditGuild/components/BackgroundImageUploader.tsx @@ -1,10 +1,10 @@ import { FormControl, FormLabel, Progress, Wrap } from "@chakra-ui/react" +import { File } from "@phosphor-icons/react" import { useThemeContext } from "components/[guild]/ThemeContext" import Button from "components/common/Button" import FormErrorMessage from "components/common/FormErrorMessage" import useDropzone, { ERROR_MESSAGES } from "hooks/useDropzone" import { Uploader } from "hooks/usePinata/usePinata" -import { File } from "phosphor-react" import { useState } from "react" import RemoveBackgroundImage from "./RemoveBackgroundImage" diff --git a/src/components/[guild]/EditGuild/components/Events/Events.tsx b/src/components/[guild]/EditGuild/components/Events/Events.tsx index 1646b50a7a..17e14193f3 100644 --- a/src/components/[guild]/EditGuild/components/Events/Events.tsx +++ b/src/components/[guild]/EditGuild/components/Events/Events.tsx @@ -1,6 +1,6 @@ import { Icon, Img, SimpleGrid, Text } from "@chakra-ui/react" +import { Plus } from "@phosphor-icons/react" import StyledSelect from "components/common/StyledSelect" -import { Plus } from "phosphor-react" import { useFormContext, useWatch } from "react-hook-form" import { EventSourcesKey, SelectOption } from "types" import EventInput, { eventSourceNames, logos } from "./EventInput" diff --git a/src/components/[guild]/EditGuild/components/RemoveBackgroundImage.tsx b/src/components/[guild]/EditGuild/components/RemoveBackgroundImage.tsx index c946f7189d..338b1c51f1 100644 --- a/src/components/[guild]/EditGuild/components/RemoveBackgroundImage.tsx +++ b/src/components/[guild]/EditGuild/components/RemoveBackgroundImage.tsx @@ -1,7 +1,7 @@ import { Icon } from "@chakra-ui/react" -import Button from "components/common/Button" +import { X } from "@phosphor-icons/react" import { useThemeContext } from "components/[guild]/ThemeContext" -import { X } from "phosphor-react" +import Button from "components/common/Button" import { useFormContext } from "react-hook-form" const RemoveBackgroundImage = () => { diff --git a/src/components/[guild]/EditGuild/components/SocialLinks.tsx b/src/components/[guild]/EditGuild/components/SocialLinks.tsx index ecc06c8433..c4c3066fd5 100644 --- a/src/components/[guild]/EditGuild/components/SocialLinks.tsx +++ b/src/components/[guild]/EditGuild/components/SocialLinks.tsx @@ -10,10 +10,10 @@ import { SimpleGrid, } from "@chakra-ui/react" import { SocialLinks as SocialLinksType } from "@guildxyz/types" +import { Plus } from "@phosphor-icons/react" import SocialIcon from "components/[guild]/SocialIcon" import FormErrorMessage from "components/common/FormErrorMessage" import StyledSelect from "components/common/StyledSelect" -import { Plus } from "phosphor-react" import { useFormContext, useWatch } from "react-hook-form" import { SelectOption, SocialLinkKey, supportedSocialLinks } from "types" import capitalize from "utils/capitalize" diff --git a/src/components/[guild]/Events/EventCard/components/EventInfo.tsx b/src/components/[guild]/Events/EventCard/components/EventInfo.tsx index 4a8f9544b7..65b9ca5149 100644 --- a/src/components/[guild]/Events/EventCard/components/EventInfo.tsx +++ b/src/components/[guild]/Events/EventCard/components/EventInfo.tsx @@ -1,5 +1,5 @@ import { HStack, StackProps, Tag, TagLabel, TagLeftIcon } from "@chakra-ui/react" -import { Clock, Users } from "phosphor-react" +import { Clock, Users } from "@phosphor-icons/react" type Props = { startDate: number diff --git a/src/components/[guild]/Events/EventCard/components/JoinEventButton.tsx b/src/components/[guild]/Events/EventCard/components/JoinEventButton.tsx index 36fcd207e2..4f2b03b82c 100644 --- a/src/components/[guild]/Events/EventCard/components/JoinEventButton.tsx +++ b/src/components/[guild]/Events/EventCard/components/JoinEventButton.tsx @@ -1,8 +1,8 @@ import { ButtonProps } from "@chakra-ui/react" +import { ArrowSquareOut } from "@phosphor-icons/react" import { usePostHogContext } from "components/_app/PostHogProvider" import Button from "components/common/Button" import useColorPalette from "hooks/useColorPalette" -import { ArrowSquareOut } from "phosphor-react" import { EventSourcesKey } from "types" type Props = { diff --git a/src/components/[guild]/Events/FallbackFrame.tsx b/src/components/[guild]/Events/FallbackFrame.tsx index 33599ac575..8bad2680f4 100644 --- a/src/components/[guild]/Events/FallbackFrame.tsx +++ b/src/components/[guild]/Events/FallbackFrame.tsx @@ -1,6 +1,6 @@ import { Icon, Spinner, Text } from "@chakra-ui/react" +import { IconProps } from "@phosphor-icons/react" import Card from "components/common/Card" -import { IconProps } from "phosphor-react" import { ForwardRefExoticComponent } from "react" type FallbackProps = { diff --git a/src/components/[guild]/JoinModal/JoinModal.tsx b/src/components/[guild]/JoinModal/JoinModal.tsx index a8bfe03ce4..aa4b27409e 100644 --- a/src/components/[guild]/JoinModal/JoinModal.tsx +++ b/src/components/[guild]/JoinModal/JoinModal.tsx @@ -11,6 +11,7 @@ import { Text, VStack, } from "@chakra-ui/react" +import { ArrowRight } from "@phosphor-icons/react" import useGuild from "components/[guild]/hooks/useGuild" import useWeb3ConnectionManager from "components/_app/Web3ConnectionManager/hooks/useWeb3ConnectionManager" import Button from "components/common/Button" @@ -19,10 +20,9 @@ import ModalButton from "components/common/ModalButton" import DynamicDevTool from "components/create-guild/DynamicDevTool" import useShowErrorToast from "hooks/useShowErrorToast" import dynamic from "next/dynamic" -import { ArrowRight } from "phosphor-react" -import rewards from "rewards" import { ComponentType, useRef } from "react" import { FormProvider, useForm } from "react-hook-form" +import rewards from "rewards" import { PlatformName, RequirementType } from "types" import ConnectPlatform from "./components/ConnectPlatform" import ShareSocialsCheckbox from "./components/ShareSocialsCheckbox" diff --git a/src/components/[guild]/JoinModal/components/CompleteCaptchaJoinStep.tsx b/src/components/[guild]/JoinModal/components/CompleteCaptchaJoinStep.tsx index 2d82626ed3..0a92bd069b 100644 --- a/src/components/[guild]/JoinModal/components/CompleteCaptchaJoinStep.tsx +++ b/src/components/[guild]/JoinModal/components/CompleteCaptchaJoinStep.tsx @@ -1,7 +1,7 @@ import { Icon, useDisclosure } from "@chakra-ui/react" +import { Robot } from "@phosphor-icons/react" import useWeb3ConnectionManager from "components/_app/Web3ConnectionManager/hooks/useWeb3ConnectionManager" import useSWRWithOptionalAuth from "hooks/useSWRWithOptionalAuth" -import { Robot } from "phosphor-react" import { CompleteCaptchaModal } from "requirements/Captcha/components/CompleteCaptcha" import JoinStep from "./JoinStep" diff --git a/src/components/[guild]/JoinModal/components/ConnectEmailJoinStep.tsx b/src/components/[guild]/JoinModal/components/ConnectEmailJoinStep.tsx index b96c65d386..f3ea1437c2 100644 --- a/src/components/[guild]/JoinModal/components/ConnectEmailJoinStep.tsx +++ b/src/components/[guild]/JoinModal/components/ConnectEmailJoinStep.tsx @@ -1,7 +1,7 @@ import { Tooltip } from "@chakra-ui/react" +import { EnvelopeSimple } from "@phosphor-icons/react" import useUser from "components/[guild]/hooks/useUser" import { ConnectEmailButton } from "components/common/Layout/components/Account/components/AccountModal/components/SocialAccount/EmailAddress" -import { EnvelopeSimple } from "phosphor-react" import { useAccount } from "wagmi" import { JoinStepUI } from "./JoinStep" diff --git a/src/components/[guild]/JoinModal/components/JoinStepIndicator.tsx b/src/components/[guild]/JoinModal/components/JoinStepIndicator.tsx index e633c1c94a..21190b8711 100644 --- a/src/components/[guild]/JoinModal/components/JoinStepIndicator.tsx +++ b/src/components/[guild]/JoinModal/components/JoinStepIndicator.tsx @@ -5,7 +5,7 @@ import { Spinner, useColorModeValue, } from "@chakra-ui/react" -import { Check, X } from "phosphor-react" +import { Check, X } from "@phosphor-icons/react" export type JoinStepIndicatorProps = | { status: "INACTIVE" | "DONE" | "NO_ACCESS" | "LOADING" } diff --git a/src/components/[guild]/JoinModal/components/ShareSocialsCheckbox.tsx b/src/components/[guild]/JoinModal/components/ShareSocialsCheckbox.tsx index 3083648f8e..63d8793494 100644 --- a/src/components/[guild]/JoinModal/components/ShareSocialsCheckbox.tsx +++ b/src/components/[guild]/JoinModal/components/ShareSocialsCheckbox.tsx @@ -1,6 +1,6 @@ import { Checkbox, Icon, Link, Text } from "@chakra-ui/react" +import { ArrowSquareOut } from "@phosphor-icons/react" import { usePostHogContext } from "components/_app/PostHogProvider" -import { ArrowSquareOut } from "phosphor-react" import { useFormContext } from "react-hook-form" const ShareSocialsCheckbox = (): JSX.Element => { diff --git a/src/components/[guild]/JoinModal/components/WalletAuthButton.tsx b/src/components/[guild]/JoinModal/components/WalletAuthButton.tsx index c3b76c8e8b..1b8acdaaae 100644 --- a/src/components/[guild]/JoinModal/components/WalletAuthButton.tsx +++ b/src/components/[guild]/JoinModal/components/WalletAuthButton.tsx @@ -1,7 +1,7 @@ +import { SignIn, Wallet } from "@phosphor-icons/react" import { walletSelectorModalAtom } from "components/_app/Web3ConnectionManager/components/WalletSelectorModal" import useWeb3ConnectionManager from "components/_app/Web3ConnectionManager/hooks/useWeb3ConnectionManager" import { useSetAtom } from "jotai" -import { SignIn, Wallet } from "phosphor-react" import shortenHex from "utils/shortenHex" import JoinStep from "./JoinStep" diff --git a/src/components/[guild]/JoinModal/hooks/useJoin.tsx b/src/components/[guild]/JoinModal/hooks/useJoin.tsx index 04447d0cfd..556ef4c1ee 100644 --- a/src/components/[guild]/JoinModal/hooks/useJoin.tsx +++ b/src/components/[guild]/JoinModal/hooks/useJoin.tsx @@ -1,4 +1,5 @@ import { JoinJob } from "@guildxyz/types" +import { CircleWavyCheck } from "@phosphor-icons/react" import { GUILD_PIN_MAINTENANCE } from "components/[guild]/Requirements/components/GuildCheckout/MintGuildPin/MintGuildPin" import { useMintGuildPinContext } from "components/[guild]/Requirements/components/GuildCheckout/MintGuildPinContext" import useGuild from "components/[guild]/hooks/useGuild" @@ -6,7 +7,6 @@ import useUser from "components/[guild]/hooks/useUser" import { UseSubmitOptions } from "hooks/useSubmit/useSubmit" import { useToastWithButton, useToastWithTweetButton } from "hooks/useToast" import { useRouter } from "next/router" -import { CircleWavyCheck } from "phosphor-react" import { useState } from "react" import useMembershipUpdate from "./useMembershipUpdate" diff --git a/src/components/[guild]/LeaveButton/LeaveButton.tsx b/src/components/[guild]/LeaveButton/LeaveButton.tsx index 5a59df6ebe..c874e9d04c 100644 --- a/src/components/[guild]/LeaveButton/LeaveButton.tsx +++ b/src/components/[guild]/LeaveButton/LeaveButton.tsx @@ -8,11 +8,11 @@ import { Tooltip, useDisclosure, } from "@chakra-ui/react" +import { SignOut } from "@phosphor-icons/react" import useGuild from "components/[guild]/hooks/useGuild" import Button from "components/common/Button" import { Alert } from "components/common/Modal" import useMembership from "components/explorer/hooks/useMembership" -import { SignOut } from "phosphor-react" import { useRef } from "react" import { useIsTabsStuck } from "../Tabs/Tabs" import { useThemeContext } from "../ThemeContext" diff --git a/src/components/[guild]/Members/components/Member.tsx b/src/components/[guild]/Members/components/Member.tsx index e1b1025440..4598268b1c 100644 --- a/src/components/[guild]/Members/components/Member.tsx +++ b/src/components/[guild]/Members/components/Member.tsx @@ -1,7 +1,7 @@ import { Icon, Text, Tooltip, VStack } from "@chakra-ui/react" +import { Crown } from "@phosphor-icons/react" import GuildAvatar from "components/common/GuildAvatar" import useResolveAddress from "hooks/useResolveAddress" -import { Crown } from "phosphor-react" import shortenHex from "utils/shortenHex" type Props = { diff --git a/src/components/[guild]/Members/components/MembersExporter.tsx b/src/components/[guild]/Members/components/MembersExporter.tsx index 47fcf3bce7..7b58208d3f 100644 --- a/src/components/[guild]/Members/components/MembersExporter.tsx +++ b/src/components/[guild]/Members/components/MembersExporter.tsx @@ -19,12 +19,12 @@ import { useClipboard, useDisclosure, } from "@chakra-ui/react" -import Button from "components/common/Button" -import { Modal } from "components/common/Modal" +import { Check, Copy, DownloadSimple, Export } from "@phosphor-icons/react" import useGuild from "components/[guild]/hooks/useGuild" import RoleSelector from "components/[guild]/RoleSelector" +import Button from "components/common/Button" +import { Modal } from "components/common/Modal" import useSWRWithOptionalAuth from "hooks/useSWRWithOptionalAuth" -import { Check, Copy, DownloadSimple, Export } from "phosphor-react" import { useRef } from "react" const MembersExporter = (): JSX.Element => { diff --git a/src/components/[guild]/NoPermissionToPageFallback.tsx b/src/components/[guild]/NoPermissionToPageFallback.tsx index b0adc01b6e..435523d114 100644 --- a/src/components/[guild]/NoPermissionToPageFallback.tsx +++ b/src/components/[guild]/NoPermissionToPageFallback.tsx @@ -7,12 +7,12 @@ import { Stack, Text, } from "@chakra-ui/react" +import { SignIn } from "@phosphor-icons/react" import { walletSelectorModalAtom } from "components/_app/Web3ConnectionManager/components/WalletSelectorModal" import Button from "components/common/Button" import Card from "components/common/Card" import { accountModalAtom } from "components/common/Layout/components/Account/components/AccountModal" import { useSetAtom } from "jotai" -import { SignIn } from "phosphor-react" import useGuildPermission from "./hooks/useGuildPermission" import useUser from "./hooks/useUser" diff --git a/src/components/[guild]/Onboarding/components/SummonMembers/components/EntryChannel.tsx b/src/components/[guild]/Onboarding/components/SummonMembers/components/EntryChannel.tsx index 12e01880f5..de1c91ac18 100644 --- a/src/components/[guild]/Onboarding/components/SummonMembers/components/EntryChannel.tsx +++ b/src/components/[guild]/Onboarding/components/SummonMembers/components/EntryChannel.tsx @@ -1,6 +1,6 @@ import { FormControl, FormLabel, Select, Text, Tooltip } from "@chakra-ui/react" +import { Info } from "@phosphor-icons/react" import FormErrorMessage from "components/common/FormErrorMessage" -import { Info } from "phosphor-react" import { useEffect } from "react" import { useFormContext, useWatch } from "react-hook-form" import { Rest } from "types" diff --git a/src/components/[guild]/Onboarding/components/SummonMembers/components/PanelBody/components/EditableControls.tsx b/src/components/[guild]/Onboarding/components/SummonMembers/components/PanelBody/components/EditableControls.tsx index e629bca2a3..ffa3a9b181 100644 --- a/src/components/[guild]/Onboarding/components/SummonMembers/components/PanelBody/components/EditableControls.tsx +++ b/src/components/[guild]/Onboarding/components/SummonMembers/components/PanelBody/components/EditableControls.tsx @@ -4,7 +4,7 @@ import { useColorModeValue, useEditableControls, } from "@chakra-ui/react" -import { Check, PencilSimple } from "phosphor-react" +import { Check, PencilSimple } from "@phosphor-icons/react" const EditableControls = (props: Omit) => { const { isEditing, getSubmitButtonProps, getEditButtonProps } = diff --git a/src/components/[guild]/Onboarding/components/SummonMembers/components/PanelButton.tsx b/src/components/[guild]/Onboarding/components/SummonMembers/components/PanelButton.tsx index a99de5f334..1f5cda02af 100644 --- a/src/components/[guild]/Onboarding/components/SummonMembers/components/PanelButton.tsx +++ b/src/components/[guild]/Onboarding/components/SummonMembers/components/PanelButton.tsx @@ -8,7 +8,7 @@ import { Text, Wrap, } from "@chakra-ui/react" -import { ArrowSquareOut, Link as LinkIcon } from "phosphor-react" +import { ArrowSquareOut, Link as LinkIcon } from "@phosphor-icons/react" import { useController } from "react-hook-form" import EditableControls from "./PanelBody/components/EditableControls" diff --git a/src/components/[guild]/OngoingIssuesBanner.tsx b/src/components/[guild]/OngoingIssuesBanner.tsx index 5248f4b6f9..9e63980c72 100644 --- a/src/components/[guild]/OngoingIssuesBanner.tsx +++ b/src/components/[guild]/OngoingIssuesBanner.tsx @@ -1,7 +1,7 @@ import { Button } from "@chakra-ui/react" +import { ArrowSquareOut } from "@phosphor-icons/react" import InfoBanner from "components/_app/InfoBanner" import { triggerChat } from "components/_app/IntercomProvider" -import { ArrowSquareOut } from "phosphor-react" const OngoingIssuesBanner = () => ( diff --git a/src/components/[guild]/RecheckAccessesButton.tsx b/src/components/[guild]/RecheckAccessesButton.tsx index 0082020d53..141b88c2d6 100644 --- a/src/components/[guild]/RecheckAccessesButton.tsx +++ b/src/components/[guild]/RecheckAccessesButton.tsx @@ -13,12 +13,12 @@ import { Text, VStack, } from "@chakra-ui/react" +import { ArrowsClockwise, Check } from "@phosphor-icons/react" import { useRoleMembership } from "components/explorer/hooks/useMembership" import useShowErrorToast from "hooks/useShowErrorToast" import useToast from "hooks/useToast" import { useAtom } from "jotai" import { atomWithStorage } from "jotai/utils" -import { ArrowsClockwise, Check } from "phosphor-react" import { useEffect, useMemo, useState } from "react" import GetRewardsJoinStep from "./JoinModal/components/progress/GetRewardsJoinStep" import GetRolesJoinStep from "./JoinModal/components/progress/GetRolesJoinStep" diff --git a/src/components/[guild]/ReportGuildButton.tsx b/src/components/[guild]/ReportGuildButton.tsx index f8597b608d..8839288b4b 100644 --- a/src/components/[guild]/ReportGuildButton.tsx +++ b/src/components/[guild]/ReportGuildButton.tsx @@ -1,7 +1,7 @@ import { ButtonProps, IconButton, Tooltip } from "@chakra-ui/react" +import { Flag } from "@phosphor-icons/react" import { addIntercomSettings } from "components/_app/IntercomProvider" import Button from "components/common/Button" -import { Flag } from "phosphor-react" import { useEffect } from "react" import useGuild from "./hooks/useGuild" diff --git a/src/components/[guild]/Requirements/components/DataProviderRequirement.tsx b/src/components/[guild]/Requirements/components/DataProviderRequirement.tsx index 16035f916a..03023a3159 100644 --- a/src/components/[guild]/Requirements/components/DataProviderRequirement.tsx +++ b/src/components/[guild]/Requirements/components/DataProviderRequirement.tsx @@ -1,5 +1,5 @@ import { Box, Circle, Flex, HStack, Icon, SimpleGrid, Text } from "@chakra-ui/react" -import { Lightning } from "phosphor-react" +import { Lightning } from "@phosphor-icons/react" import { REQUIREMENT_PROVIDED_VALUES } from "requirements/requirements" import { RequirementProps } from "./Requirement" import { useRequirementContext } from "./RequirementContext" diff --git a/src/components/[guild]/Requirements/components/ExpandRequirementsButton.tsx b/src/components/[guild]/Requirements/components/ExpandRequirementsButton.tsx index b9b47dab64..164c116eea 100644 --- a/src/components/[guild]/Requirements/components/ExpandRequirementsButton.tsx +++ b/src/components/[guild]/Requirements/components/ExpandRequirementsButton.tsx @@ -1,8 +1,8 @@ import { Divider, Flex, Icon, useColorMode } from "@chakra-ui/react" import { Logic } from "@guildxyz/types" +import { ArrowDown, ArrowUp } from "@phosphor-icons/react" import { formattedLogic } from "components/[guild]/LogicDivider" import Button from "components/common/Button" -import { ArrowDown, ArrowUp } from "phosphor-react" type Props = { logic: Logic diff --git a/src/components/[guild]/Requirements/components/GuildCheckout/BuyPass.tsx b/src/components/[guild]/Requirements/components/GuildCheckout/BuyPass.tsx index 0c918f712b..79aff2811c 100644 --- a/src/components/[guild]/Requirements/components/GuildCheckout/BuyPass.tsx +++ b/src/components/[guild]/Requirements/components/GuildCheckout/BuyPass.tsx @@ -12,13 +12,13 @@ import { ModalOverlay, Stack, } from "@chakra-ui/react" +import { Coin } from "@phosphor-icons/react" import useGuild from "components/[guild]/hooks/useGuild" import { usePostHogContext } from "components/_app/PostHogProvider" import useWeb3ConnectionManager from "components/_app/Web3ConnectionManager/hooks/useWeb3ConnectionManager" import Button from "components/common/Button" import { Modal } from "components/common/Modal" import { useRoleMembership } from "components/explorer/hooks/useMembership" -import { Coin } from "phosphor-react" import { paymentSupportedChains } from "utils/guildCheckout/constants" import { useChainId } from "wagmi" import { Chains } from "wagmiConfig/chains" diff --git a/src/components/[guild]/Requirements/components/GuildCheckout/MintGuildPin/components/ActivateGuildPinModal.tsx b/src/components/[guild]/Requirements/components/GuildCheckout/MintGuildPin/components/ActivateGuildPinModal.tsx index 6248232983..c6c8be55a2 100644 --- a/src/components/[guild]/Requirements/components/GuildCheckout/MintGuildPin/components/ActivateGuildPinModal.tsx +++ b/src/components/[guild]/Requirements/components/GuildCheckout/MintGuildPin/components/ActivateGuildPinModal.tsx @@ -9,10 +9,10 @@ import { ModalOverlay, Stack, } from "@chakra-ui/react" +import { ArrowSquareOut } from "@phosphor-icons/react" import { useEditGuildDrawer } from "components/[guild]/EditGuild/EditGuildDrawerContext" import Button from "components/common/Button" import { Modal } from "components/common/Modal" -import { ArrowSquareOut } from "phosphor-react" import { useMintGuildPinContext } from "../../MintGuildPinContext" import GuildPinImage from "../../components/GuildPinImage" import ActivateGuildPinForm from "./ActivateGuildPinForm" diff --git a/src/components/[guild]/Requirements/components/GuildCheckout/PurchaseRequirement.tsx b/src/components/[guild]/Requirements/components/GuildCheckout/PurchaseRequirement.tsx index 43a6e95bed..3ac43e9d52 100644 --- a/src/components/[guild]/Requirements/components/GuildCheckout/PurchaseRequirement.tsx +++ b/src/components/[guild]/Requirements/components/GuildCheckout/PurchaseRequirement.tsx @@ -11,11 +11,11 @@ import { Stack, Text, } from "@chakra-ui/react" +import { ShoppingCartSimple } from "@phosphor-icons/react" import useGuild from "components/[guild]/hooks/useGuild" import { usePostHogContext } from "components/_app/PostHogProvider" import Button from "components/common/Button" import { Modal } from "components/common/Modal" -import { ShoppingCartSimple } from "phosphor-react" import { useAccount } from "wagmi" import { CHAIN_CONFIG, Chains } from "wagmiConfig/chains" import BlockExplorerUrl from "../BlockExplorerUrl" diff --git a/src/components/[guild]/Requirements/components/GuildCheckout/components/AlphaTag.tsx b/src/components/[guild]/Requirements/components/GuildCheckout/components/AlphaTag.tsx index 7a2b9af75a..425f5f45e7 100644 --- a/src/components/[guild]/Requirements/components/GuildCheckout/components/AlphaTag.tsx +++ b/src/components/[guild]/Requirements/components/GuildCheckout/components/AlphaTag.tsx @@ -9,9 +9,9 @@ import { Tag, Text, } from "@chakra-ui/react" +import { Chat } from "@phosphor-icons/react" import { triggerChat } from "components/_app/IntercomProvider" import Button from "components/common/Button" -import { Chat } from "phosphor-react" const AlphaTag = () => ( diff --git a/src/components/[guild]/Requirements/components/GuildCheckout/components/FeePopover.tsx b/src/components/[guild]/Requirements/components/GuildCheckout/components/FeePopover.tsx index 7cb1ade93d..7d6872cb04 100644 --- a/src/components/[guild]/Requirements/components/GuildCheckout/components/FeePopover.tsx +++ b/src/components/[guild]/Requirements/components/GuildCheckout/components/FeePopover.tsx @@ -7,7 +7,7 @@ import { PopoverContent, PopoverTrigger, } from "@chakra-ui/react" -import { ArrowSquareOut, Question } from "phosphor-react" +import { ArrowSquareOut, Question } from "@phosphor-icons/react" const FeePopover = () => ( diff --git a/src/components/[guild]/Requirements/components/GuildCheckout/components/FeesTable.tsx b/src/components/[guild]/Requirements/components/GuildCheckout/components/FeesTable.tsx index 2f2b5f080e..f047997dc3 100644 --- a/src/components/[guild]/Requirements/components/GuildCheckout/components/FeesTable.tsx +++ b/src/components/[guild]/Requirements/components/GuildCheckout/components/FeesTable.tsx @@ -8,8 +8,8 @@ import { Tbody, useDisclosure, } from "@chakra-ui/react" +import { CaretDown } from "@phosphor-icons/react" import Button from "components/common/Button" -import { CaretDown } from "phosphor-react" import { PropsWithChildren } from "react" type Props = { diff --git a/src/components/[guild]/Requirements/components/GuildCheckout/components/GuildPinImage.tsx b/src/components/[guild]/Requirements/components/GuildCheckout/components/GuildPinImage.tsx index af904c88b7..f009d6582e 100644 --- a/src/components/[guild]/Requirements/components/GuildCheckout/components/GuildPinImage.tsx +++ b/src/components/[guild]/Requirements/components/GuildCheckout/components/GuildPinImage.tsx @@ -1,4 +1,3 @@ -import { env } from "env" import { AspectRatio, Box, @@ -10,9 +9,10 @@ import { useColorModeValue, VStack, } from "@chakra-ui/react" +import { DownloadSimple } from "@phosphor-icons/react" import useGuild from "components/[guild]/hooks/useGuild" import useGuildPermission from "components/[guild]/hooks/useGuildPermission" -import { DownloadSimple } from "phosphor-react" +import { env } from "env" import GuildGhost from "static/avatars/ghost.svg" import useSWRImmutable from "swr/immutable" import convertSVGToPNG from "utils/convertSVGToPNG" diff --git a/src/components/[guild]/Requirements/components/GuildCheckout/components/NoReward.tsx b/src/components/[guild]/Requirements/components/GuildCheckout/components/NoReward.tsx index 07200ea30d..9d39fabfc0 100644 --- a/src/components/[guild]/Requirements/components/GuildCheckout/components/NoReward.tsx +++ b/src/components/[guild]/Requirements/components/GuildCheckout/components/NoReward.tsx @@ -1,5 +1,5 @@ import { HStack, Icon, Text } from "@chakra-ui/react" -import { StarHalf } from "phosphor-react" +import { StarHalf } from "@phosphor-icons/react" const NoReward = () => ( diff --git a/src/components/[guild]/Requirements/components/GuildCheckout/components/PaymentCurrencyPicker/PaymentCurrencyPicker.tsx b/src/components/[guild]/Requirements/components/GuildCheckout/components/PaymentCurrencyPicker/PaymentCurrencyPicker.tsx index 78b8269831..4d4e059a2f 100644 --- a/src/components/[guild]/Requirements/components/GuildCheckout/components/PaymentCurrencyPicker/PaymentCurrencyPicker.tsx +++ b/src/components/[guild]/Requirements/components/GuildCheckout/components/PaymentCurrencyPicker/PaymentCurrencyPicker.tsx @@ -10,10 +10,10 @@ import { Text, useColorModeValue, } from "@chakra-ui/react" +import { ArrowSquareOut, CaretDown } from "@phosphor-icons/react" import Button from "components/common/Button" import { accountModalAtom } from "components/common/Layout/components/Account/components/AccountModal" import { useSetAtom } from "jotai" -import { ArrowSquareOut, CaretDown } from "phosphor-react" import { useEffect } from "react" import { SUPPORTED_CURRENCIES } from "utils/guildCheckout/constants" import shortenHex from "utils/shortenHex" diff --git a/src/components/[guild]/Requirements/components/GuildCheckout/components/PurchaseFeeAndTotal.tsx b/src/components/[guild]/Requirements/components/GuildCheckout/components/PurchaseFeeAndTotal.tsx index 3fb50d274d..446c051343 100644 --- a/src/components/[guild]/Requirements/components/GuildCheckout/components/PurchaseFeeAndTotal.tsx +++ b/src/components/[guild]/Requirements/components/GuildCheckout/components/PurchaseFeeAndTotal.tsx @@ -1,6 +1,6 @@ import { HStack, Icon, Skeleton, Td, Text, Tooltip, Tr } from "@chakra-ui/react" +import { Info, Question } from "@phosphor-icons/react" import useTokenData from "hooks/useTokenData" -import { Info, Question } from "phosphor-react" import { GUILD_FEE_PERCENTAGE, NULL_ADDRESS } from "utils/guildCheckout/constants" import { formatUnits } from "viem" import { Chain, CHAIN_CONFIG } from "wagmiConfig/chains" diff --git a/src/components/[guild]/Requirements/components/GuildCheckout/components/TransactionStatusModal/components/GuildPinOpenseaLink.tsx b/src/components/[guild]/Requirements/components/GuildCheckout/components/TransactionStatusModal/components/GuildPinOpenseaLink.tsx index 50447a7ac7..5f843eb573 100644 --- a/src/components/[guild]/Requirements/components/GuildCheckout/components/TransactionStatusModal/components/GuildPinOpenseaLink.tsx +++ b/src/components/[guild]/Requirements/components/GuildCheckout/components/TransactionStatusModal/components/GuildPinOpenseaLink.tsx @@ -1,6 +1,6 @@ import { Link } from "@chakra-ui/next-js" import { Icon, Img, Text } from "@chakra-ui/react" -import { ArrowSquareOut } from "phosphor-react" +import { ArrowSquareOut } from "@phosphor-icons/react" import { GUILD_PIN_CONTRACTS, openseaBaseUrl } from "utils/guildCheckout/constants" import { useChainId } from "wagmi" import { Chains } from "wagmiConfig/chains" diff --git a/src/components/[guild]/Requirements/components/GuildCheckout/components/TransactionStatusModal/components/OpenseaLink.tsx b/src/components/[guild]/Requirements/components/GuildCheckout/components/TransactionStatusModal/components/OpenseaLink.tsx index 26d2cc2268..bf8b186131 100644 --- a/src/components/[guild]/Requirements/components/GuildCheckout/components/TransactionStatusModal/components/OpenseaLink.tsx +++ b/src/components/[guild]/Requirements/components/GuildCheckout/components/TransactionStatusModal/components/OpenseaLink.tsx @@ -1,7 +1,7 @@ import { Link } from "@chakra-ui/next-js" import { Icon, Img, Text } from "@chakra-ui/react" +import { ArrowSquareOut } from "@phosphor-icons/react" import { useCollectNftContext } from "components/[guild]/collect/components/CollectNftContext" -import { ArrowSquareOut } from "phosphor-react" import { openseaBaseUrl } from "utils/guildCheckout/constants" import { useChainId } from "wagmi" import { Chains } from "wagmiConfig/chains" diff --git a/src/components/[guild]/Requirements/components/GuildCheckout/components/TransactionStatusModal/components/TransactionLink.tsx b/src/components/[guild]/Requirements/components/GuildCheckout/components/TransactionStatusModal/components/TransactionLink.tsx index 07e866c0ef..042363812a 100644 --- a/src/components/[guild]/Requirements/components/GuildCheckout/components/TransactionStatusModal/components/TransactionLink.tsx +++ b/src/components/[guild]/Requirements/components/GuildCheckout/components/TransactionStatusModal/components/TransactionLink.tsx @@ -1,5 +1,5 @@ import { Icon, Link, Text } from "@chakra-ui/react" -import { ArrowSquareOut } from "phosphor-react" +import { ArrowSquareOut } from "@phosphor-icons/react" import { useChainId } from "wagmi" import { CHAIN_CONFIG, Chains } from "wagmiConfig/chains" import { useTransactionStatusContext } from "../../TransactionStatusContext" diff --git a/src/components/[guild]/Requirements/components/GuildCheckout/components/TransactionStatusModal/components/TxError.tsx b/src/components/[guild]/Requirements/components/GuildCheckout/components/TransactionStatusModal/components/TxError.tsx index 8795b5edb1..d988e60d16 100644 --- a/src/components/[guild]/Requirements/components/GuildCheckout/components/TransactionStatusModal/components/TxError.tsx +++ b/src/components/[guild]/Requirements/components/GuildCheckout/components/TransactionStatusModal/components/TxError.tsx @@ -1,5 +1,5 @@ import { Center, Flex, Icon, ModalBody, ModalFooter } from "@chakra-ui/react" -import { XCircle } from "phosphor-react" +import { XCircle } from "@phosphor-icons/react" import { PropsWithChildren } from "react" import TransactionModalCloseButton from "./TransactionModalCloseButton" diff --git a/src/components/[guild]/Requirements/components/GuildCheckout/components/buttons/BuyAllowanceButton.tsx b/src/components/[guild]/Requirements/components/GuildCheckout/components/buttons/BuyAllowanceButton.tsx index bc1ff93db8..f1347e6265 100644 --- a/src/components/[guild]/Requirements/components/GuildCheckout/components/buttons/BuyAllowanceButton.tsx +++ b/src/components/[guild]/Requirements/components/GuildCheckout/components/buttons/BuyAllowanceButton.tsx @@ -1,9 +1,9 @@ import { Collapse, Icon, Tooltip } from "@chakra-ui/react" +import { Check, Question, Warning } from "@phosphor-icons/react" import useGuild from "components/[guild]/hooks/useGuild" import { usePostHogContext } from "components/_app/PostHogProvider" import Button from "components/common/Button" import useToken from "hooks/useToken" -import { Check, Question, Warning } from "phosphor-react" import useVault from "requirements/Payment/hooks/useVault" import { NULL_ADDRESS } from "utils/guildCheckout/constants" import { useChainId } from "wagmi" diff --git a/src/components/[guild]/Requirements/components/GuildCheckout/components/buttons/PurchaseAllowanceButton.tsx b/src/components/[guild]/Requirements/components/GuildCheckout/components/buttons/PurchaseAllowanceButton.tsx index f8bd607850..8da47a16fd 100644 --- a/src/components/[guild]/Requirements/components/GuildCheckout/components/buttons/PurchaseAllowanceButton.tsx +++ b/src/components/[guild]/Requirements/components/GuildCheckout/components/buttons/PurchaseAllowanceButton.tsx @@ -1,10 +1,10 @@ import { Collapse, Icon, Tooltip } from "@chakra-ui/react" +import { Check, Question, Warning } from "@phosphor-icons/react" import useAllowance from "components/[guild]/Requirements/components/GuildCheckout/hooks/useAllowance" import useGuild from "components/[guild]/hooks/useGuild" import { usePostHogContext } from "components/_app/PostHogProvider" import Button from "components/common/Button" import useTokenData from "hooks/useTokenData" -import { Check, Question, Warning } from "phosphor-react" import { NULL_ADDRESS, TOKEN_BUYER_CONTRACTS } from "utils/guildCheckout/constants" import { useChainId } from "wagmi" import { Chain, CHAIN_CONFIG, Chains } from "wagmiConfig/chains" diff --git a/src/components/[guild]/Requirements/components/HiddenRequirementAccessIndicator.tsx b/src/components/[guild]/Requirements/components/HiddenRequirementAccessIndicator.tsx index d9aa18c308..34475db25a 100644 --- a/src/components/[guild]/Requirements/components/HiddenRequirementAccessIndicator.tsx +++ b/src/components/[guild]/Requirements/components/HiddenRequirementAccessIndicator.tsx @@ -14,13 +14,6 @@ import { Text, useDisclosure, } from "@chakra-ui/react" -import RecheckAccessesButton from "components/[guild]/RecheckAccessesButton" -import useGuild from "components/[guild]/hooks/useGuild" -import useRequirements from "components/[guild]/hooks/useRequirements" -import Button from "components/common/Button" -import { accountModalAtom } from "components/common/Layout/components/Account/components/AccountModal" -import { useRoleMembership } from "components/explorer/hooks/useMembership" -import { useSetAtom } from "jotai" import { ArrowSquareIn, CaretDown, @@ -30,7 +23,14 @@ import { LockSimple, Warning, X, -} from "phosphor-react" +} from "@phosphor-icons/react" +import RecheckAccessesButton from "components/[guild]/RecheckAccessesButton" +import useGuild from "components/[guild]/hooks/useGuild" +import useRequirements from "components/[guild]/hooks/useRequirements" +import Button from "components/common/Button" +import { accountModalAtom } from "components/common/Layout/components/Account/components/AccountModal" +import { useRoleMembership } from "components/explorer/hooks/useMembership" +import { useSetAtom } from "jotai" import capitalize from "utils/capitalize" import { POPOVER_FOOTER_STYLES, diff --git a/src/components/[guild]/Requirements/components/RequirementAccessIndicator.tsx b/src/components/[guild]/Requirements/components/RequirementAccessIndicator.tsx index e4491d1e8c..8bd09b8d8e 100644 --- a/src/components/[guild]/Requirements/components/RequirementAccessIndicator.tsx +++ b/src/components/[guild]/Requirements/components/RequirementAccessIndicator.tsx @@ -6,13 +6,13 @@ import { PopoverHeader, Text, } from "@chakra-ui/react" +import { ArrowSquareIn, Check, LockSimple, Warning, X } from "@phosphor-icons/react" import RecheckAccessesButton from "components/[guild]/RecheckAccessesButton" import Button from "components/common/Button" import { accountModalAtom } from "components/common/Layout/components/Account/components/AccountModal" import { useRoleMembership } from "components/explorer/hooks/useMembership" import { useSetAtom } from "jotai" import dynamic from "next/dynamic" -import { ArrowSquareIn, Check, LockSimple, Warning, X } from "phosphor-react" import RequirementAccessIndicatorUI from "./RequirementAccessIndicatorUI" import { useRequirementContext } from "./RequirementContext" diff --git a/src/components/[guild]/Requirements/components/RequirementButton.tsx b/src/components/[guild]/Requirements/components/RequirementButton.tsx index b6f7377a75..5042494701 100644 --- a/src/components/[guild]/Requirements/components/RequirementButton.tsx +++ b/src/components/[guild]/Requirements/components/RequirementButton.tsx @@ -1,6 +1,6 @@ import { Img } from "@chakra-ui/react" +import { ArrowSquareOut } from "@phosphor-icons/react" import Button from "components/common/Button" -import { ArrowSquareOut } from "phosphor-react" import { forwardRef, PropsWithChildren } from "react" import { Rest } from "types" diff --git a/src/components/[guild]/Requirements/components/RequirementDisplayComponent.tsx b/src/components/[guild]/Requirements/components/RequirementDisplayComponent.tsx index 46bb5fc1c3..40323ad22d 100644 --- a/src/components/[guild]/Requirements/components/RequirementDisplayComponent.tsx +++ b/src/components/[guild]/Requirements/components/RequirementDisplayComponent.tsx @@ -1,7 +1,7 @@ import { Icon } from "@chakra-ui/react" +import { Question, Warning } from "@phosphor-icons/react" import { usePostHogContext } from "components/_app/PostHogProvider" import DataBlock from "components/common/DataBlock" -import { Question, Warning } from "phosphor-react" import { PropsWithChildren } from "react" import { ErrorBoundary } from "react-error-boundary" import REQUIREMENTS from "requirements" diff --git a/src/components/[guild]/Requirements/components/RequirementImageEditor.tsx b/src/components/[guild]/Requirements/components/RequirementImageEditor.tsx index e5f3017a6a..e970a9dd8e 100644 --- a/src/components/[guild]/Requirements/components/RequirementImageEditor.tsx +++ b/src/components/[guild]/Requirements/components/RequirementImageEditor.tsx @@ -1,9 +1,9 @@ -import { env } from "env" import { Circle, Icon, Spinner, Text } from "@chakra-ui/react" +import { Upload, X } from "@phosphor-icons/react" +import { env } from "env" import usePinata from "hooks/usePinata" import useShowErrorToast from "hooks/useShowErrorToast" import useToast from "hooks/useToast" -import { Upload, X } from "phosphor-react" import { PropsWithChildren, useCallback, useState } from "react" import { useDropzone } from "react-dropzone" import { useRequirementContext } from "./RequirementContext" diff --git a/src/components/[guild]/Requirements/components/RequirementNameEditor.tsx b/src/components/[guild]/Requirements/components/RequirementNameEditor.tsx index a163c21fe1..ea26f605d1 100644 --- a/src/components/[guild]/Requirements/components/RequirementNameEditor.tsx +++ b/src/components/[guild]/Requirements/components/RequirementNameEditor.tsx @@ -7,7 +7,7 @@ import { Tooltip, useEditableContext, } from "@chakra-ui/react" -import { Check, PencilSimple } from "phosphor-react" +import { Check, PencilSimple } from "@phosphor-icons/react" import { MutableRefObject, PropsWithChildren, ReactNode, useRef } from "react" import { FormProvider, diff --git a/src/components/[guild]/Requirements/components/ViewOriginalPopover.tsx b/src/components/[guild]/Requirements/components/ViewOriginalPopover.tsx index 2f14a437be..c6b8674531 100644 --- a/src/components/[guild]/Requirements/components/ViewOriginalPopover.tsx +++ b/src/components/[guild]/Requirements/components/ViewOriginalPopover.tsx @@ -5,7 +5,7 @@ import { PopoverTrigger, Portal, } from "@chakra-ui/react" -import { CaretDown } from "phosphor-react" +import { CaretDown } from "@phosphor-icons/react" import { PropsWithChildren } from "react" import { RequirementButton } from "./RequirementButton" diff --git a/src/components/[guild]/RoleCard/components/AccessIndicator/AccessIndicator.tsx b/src/components/[guild]/RoleCard/components/AccessIndicator/AccessIndicator.tsx index 61db803cde..ff4e461534 100644 --- a/src/components/[guild]/RoleCard/components/AccessIndicator/AccessIndicator.tsx +++ b/src/components/[guild]/RoleCard/components/AccessIndicator/AccessIndicator.tsx @@ -6,6 +6,7 @@ import { useBreakpointValue, useColorModeValue, } from "@chakra-ui/react" +import { CaretDown, Check, LockSimple, Warning, X } from "@phosphor-icons/react" import { useOpenJoinModal } from "components/[guild]/JoinModal/JoinModalProvider" import RecheckAccessesButton from "components/[guild]/RecheckAccessesButton" import { useRequirementErrorConfig } from "components/[guild]/Requirements/RequirementErrorConfigContext" @@ -17,7 +18,6 @@ import useMembership, { useRoleMembership, } from "components/explorer/hooks/useMembership" import { useSetAtom } from "jotai" -import { CaretDown, Check, LockSimple, Warning, X } from "phosphor-react" import AccessIndicatorUI, { ACCESS_INDICATOR_STYLES, } from "./components/AccessIndicatorUI" diff --git a/src/components/[guild]/RoleCard/components/DynamicReward/DynamicTag.tsx b/src/components/[guild]/RoleCard/components/DynamicReward/DynamicTag.tsx index afe4d9aeb3..e6ae91e58a 100644 --- a/src/components/[guild]/RoleCard/components/DynamicReward/DynamicTag.tsx +++ b/src/components/[guild]/RoleCard/components/DynamicReward/DynamicTag.tsx @@ -1,8 +1,8 @@ import { Icon, Tag, Tooltip, Wrap, useDisclosure } from "@chakra-ui/react" +import { Lightning, Warning } from "@phosphor-icons/react" import { useRequirementHandlerContext } from "components/[guild]/RequirementHandlerContext" import useGuildPermission from "components/[guild]/hooks/useGuildPermission" import useRequirements from "components/[guild]/hooks/useRequirements" -import { Lightning, Warning } from "phosphor-react" import DynamicRewardModal from "rewards/Token/DynamicRewardModal" import { Rest, RolePlatform } from "types" diff --git a/src/components/[guild]/RoleCard/components/EditRole/EditRole.tsx b/src/components/[guild]/RoleCard/components/EditRole/EditRole.tsx index 3ffdd97a31..7d9df584ec 100644 --- a/src/components/[guild]/RoleCard/components/EditRole/EditRole.tsx +++ b/src/components/[guild]/RoleCard/components/EditRole/EditRole.tsx @@ -11,6 +11,7 @@ import { useDisclosure, VStack, } from "@chakra-ui/react" +import { PencilSimple } from "@phosphor-icons/react" import useGuild from "components/[guild]/hooks/useGuild" import { ApiRequirementHandlerProvider } from "components/[guild]/RequirementHandlerContext" import DiscardAlert from "components/common/DiscardAlert" @@ -21,7 +22,6 @@ import IconSelector from "components/create-guild/IconSelector" import Name from "components/create-guild/Name" import EditRequirements from "components/create-guild/Requirements/EditRequirements" import useWarnIfUnsavedChanges from "hooks/useWarnIfUnsavedChanges" -import { PencilSimple } from "phosphor-react" import { useRef } from "react" import { FormProvider } from "react-hook-form" import EditRoleFooter from "./components/EditRoleFooter" diff --git a/src/components/[guild]/RoleCard/components/EditRole/components/EditRoleFooter.tsx b/src/components/[guild]/RoleCard/components/EditRole/components/EditRoleFooter.tsx index 9b17ea526c..c049b910c6 100644 --- a/src/components/[guild]/RoleCard/components/EditRole/components/EditRoleFooter.tsx +++ b/src/components/[guild]/RoleCard/components/EditRole/components/EditRoleFooter.tsx @@ -1,7 +1,7 @@ import { DrawerFooter, Icon } from "@chakra-ui/react" +import { Check } from "@phosphor-icons/react" import Button from "components/common/Button" import { AnimatePresence, motion } from "framer-motion" -import { Check } from "phosphor-react" const MotionDrawerFooter = motion(DrawerFooter) const FOOTER_OFFSET = 76 // Footer is 76px high diff --git a/src/components/[guild]/RoleCard/components/EditRole/components/EditRoleHeader.tsx b/src/components/[guild]/RoleCard/components/EditRole/components/EditRoleHeader.tsx index 263f22bc60..9a6418db53 100644 --- a/src/components/[guild]/RoleCard/components/EditRole/components/EditRoleHeader.tsx +++ b/src/components/[guild]/RoleCard/components/EditRole/components/EditRoleHeader.tsx @@ -1,9 +1,9 @@ import { HStack, Icon, IconButton } from "@chakra-ui/react" +import { ArrowLeft } from "@phosphor-icons/react" import SetVisibility, { SetVisibilityForm } from "components/[guild]/SetVisibility" import useVisibilityModalProps from "components/[guild]/SetVisibility/hooks/useVisibilityModalProps" import useGuild from "components/[guild]/hooks/useGuild" import DrawerHeader from "components/common/DrawerHeader" -import { ArrowLeft } from "phosphor-react" import { useFormContext, useWatch } from "react-hook-form" import { RoleEditFormData } from "../hooks/useEditRoleForm" import DeleteRoleButton from "./DeleteRoleButton" diff --git a/src/components/[guild]/RoleCard/components/EditRole/components/EditRolePlatforms.tsx b/src/components/[guild]/RoleCard/components/EditRole/components/EditRolePlatforms.tsx index 0c26d2ccc1..bc51762840 100644 --- a/src/components/[guild]/RoleCard/components/EditRole/components/EditRolePlatforms.tsx +++ b/src/components/[guild]/RoleCard/components/EditRole/components/EditRolePlatforms.tsx @@ -1,4 +1,5 @@ import { Box, Collapse, Spacer, Spinner, Stack, Tag } from "@chakra-ui/react" +import { Plus } from "@phosphor-icons/react" import { AddRewardProvider, useAddRewardContext, @@ -11,7 +12,6 @@ import AddCard from "components/common/AddCard" import Button from "components/common/Button" import Section from "components/common/Section" import { atom } from "jotai" -import { Plus } from "phosphor-react" import useAddRolePlatform from "../hooks/useAddRolePlatform" import ExistingRolePlatformCard from "./ExistingRolePlatformCard" diff --git a/src/components/[guild]/RoleCard/components/HiddenRewards.tsx b/src/components/[guild]/RoleCard/components/HiddenRewards.tsx index 696ddf0248..2d78f99cf2 100644 --- a/src/components/[guild]/RoleCard/components/HiddenRewards.tsx +++ b/src/components/[guild]/RoleCard/components/HiddenRewards.tsx @@ -1,5 +1,5 @@ import { Center, useColorModeValue } from "@chakra-ui/react" -import { Question } from "phosphor-react" +import { Question } from "@phosphor-icons/react" import { RewardDisplay } from "./Reward" const HiddenRewards = () => { diff --git a/src/components/[guild]/RoleCard/components/MemberCount.tsx b/src/components/[guild]/RoleCard/components/MemberCount.tsx index 4305c62ebd..0758aa83b4 100644 --- a/src/components/[guild]/RoleCard/components/MemberCount.tsx +++ b/src/components/[guild]/RoleCard/components/MemberCount.tsx @@ -17,12 +17,12 @@ import { TagRightIcon, Text, } from "@chakra-ui/react" +import { Users } from "@phosphor-icons/react" import { POPOVER_HEADER_STYLES } from "components/[guild]/Requirements/components/RequirementAccessIndicator" import useGuild from "components/[guild]/hooks/useGuild" import useGuildPermission from "components/[guild]/hooks/useGuildPermission" import useUser from "components/[guild]/hooks/useUser" import useActiveStatusUpdates from "hooks/useActiveStatusUpdates" -import { Users } from "phosphor-react" import { PropsWithChildren } from "react" import MemberCountLastSyncTooltip, { SyncRoleButton, diff --git a/src/components/[guild]/RoleCard/components/MemberCountLastSyncTooltip.tsx b/src/components/[guild]/RoleCard/components/MemberCountLastSyncTooltip.tsx index 29cc5a4e11..008049c3f7 100644 --- a/src/components/[guild]/RoleCard/components/MemberCountLastSyncTooltip.tsx +++ b/src/components/[guild]/RoleCard/components/MemberCountLastSyncTooltip.tsx @@ -7,11 +7,11 @@ import { Portal, TagRightIcon, } from "@chakra-ui/react" +import { Info, UserSwitch } from "@phosphor-icons/react" import Button from "components/common/Button" import useShowErrorToast from "hooks/useShowErrorToast" import useSubmit from "hooks/useSubmit" import useToast from "hooks/useToast" -import { Info, UserSwitch } from "phosphor-react" import { PropsWithChildren, useMemo } from "react" import fetcher from "utils/fetcher" import formatRelativeTimeFromNow, { diff --git a/src/components/[guild]/RoleCard/components/Reward.tsx b/src/components/[guild]/RoleCard/components/Reward.tsx index 34fd59e90e..92b60a178b 100644 --- a/src/components/[guild]/RoleCard/components/Reward.tsx +++ b/src/components/[guild]/RoleCard/components/Reward.tsx @@ -11,6 +11,7 @@ import { Wrap, useColorModeValue, } from "@chakra-ui/react" +import { ArrowSquareOut, LockSimple } from "@phosphor-icons/react" import usePlatformAccessButton from "components/[guild]/AccessHub/components/usePlatformAccessButton" import { useOpenJoinModal } from "components/[guild]/JoinModal/JoinModalProvider" import { ApiRequirementHandlerProvider } from "components/[guild]/RequirementHandlerContext" @@ -21,10 +22,9 @@ import useMembership, { useRoleMembership, } from "components/explorer/hooks/useMembership" import { Transition, motion } from "framer-motion" -import { ArrowSquareOut, LockSimple } from "phosphor-react" -import GoogleCardWarning from "rewards/Google/GoogleCardWarning" -import rewards from "rewards" import { PropsWithChildren, ReactNode, useMemo, useState } from "react" +import rewards from "rewards" +import GoogleCardWarning from "rewards/Google/GoogleCardWarning" import { GuildPlatform, PlatformType, Role, RolePlatform } from "types" import capitalize from "utils/capitalize" diff --git a/src/components/[guild]/RoleCard/components/RoleDescription.tsx b/src/components/[guild]/RoleCard/components/RoleDescription.tsx index 2953e2ec55..cbae80d15e 100644 --- a/src/components/[guild]/RoleCard/components/RoleDescription.tsx +++ b/src/components/[guild]/RoleCard/components/RoleDescription.tsx @@ -6,8 +6,8 @@ import { Icon, useColorModeValue, } from "@chakra-ui/react" +import { ArrowDown, ArrowUp } from "@phosphor-icons/react" import Button from "components/common/Button" -import { ArrowDown, ArrowUp } from "phosphor-react" import { useEffect, useState } from "react" import parseDescription from "utils/parseDescription" import { RoleCardCollapseProps } from ".." diff --git a/src/components/[guild]/RolePlatforms/AddRolePlatforms.tsx b/src/components/[guild]/RolePlatforms/AddRolePlatforms.tsx index 11dbd6feeb..1c26399e7d 100644 --- a/src/components/[guild]/RolePlatforms/AddRolePlatforms.tsx +++ b/src/components/[guild]/RolePlatforms/AddRolePlatforms.tsx @@ -1,10 +1,10 @@ import { SimpleGrid, Spacer } from "@chakra-ui/react" +import { Plus } from "@phosphor-icons/react" import TransitioningPlatformIcons from "components/[guild]/RolePlatforms/components/TransitioningPlatformIcons" import AddCard from "components/common/AddCard" import Button from "components/common/Button" import Section from "components/common/Section" import { atom } from "jotai" -import { Plus } from "phosphor-react" import { useFieldArray, useFormContext } from "react-hook-form" import { RoleFormType, RolePlatform } from "types" import NewRolePlatformCard from "../AddAndOrderRoles/components/NewRolePlatformCard" diff --git a/src/components/[guild]/RolePlatforms/components/AddRoleRewardModal/DefaultAddRewardPanelWrapper.tsx b/src/components/[guild]/RolePlatforms/components/AddRoleRewardModal/DefaultAddRewardPanelWrapper.tsx index 2058cb628e..60b326bd05 100644 --- a/src/components/[guild]/RolePlatforms/components/AddRoleRewardModal/DefaultAddRewardPanelWrapper.tsx +++ b/src/components/[guild]/RolePlatforms/components/AddRoleRewardModal/DefaultAddRewardPanelWrapper.tsx @@ -7,10 +7,10 @@ import { ModalHeader, Text, } from "@chakra-ui/react" +import { ArrowLeft } from "@phosphor-icons/react" import { useAddRewardContext } from "components/[guild]/AddRewardContext" -import { ArrowLeft } from "phosphor-react" -import rewards from "rewards" import { ReactNode } from "react" +import rewards from "rewards" export const DefaultAddRewardPanelWrapper = ({ children, diff --git a/src/components/[guild]/RolePlatforms/components/AddRoleRewardModal/components/AddContractCallPanel/components/CreateNftForm/components/ImagePicker.tsx b/src/components/[guild]/RolePlatforms/components/AddRoleRewardModal/components/AddContractCallPanel/components/CreateNftForm/components/ImagePicker.tsx index 88baac2187..5379a738df 100644 --- a/src/components/[guild]/RolePlatforms/components/AddRoleRewardModal/components/AddContractCallPanel/components/CreateNftForm/components/ImagePicker.tsx +++ b/src/components/[guild]/RolePlatforms/components/AddRoleRewardModal/components/AddContractCallPanel/components/CreateNftForm/components/ImagePicker.tsx @@ -9,12 +9,12 @@ import { Text, VStack, } from "@chakra-ui/react" +import { Image } from "@phosphor-icons/react" import TiltCard from "components/[guild]/collect/components/TiltCard" import Button from "components/common/Button" import FormErrorMessage from "components/common/FormErrorMessage" import useDropzone from "hooks/useDropzone" import usePinata from "hooks/usePinata" -import { Image } from "phosphor-react" import { Fragment, useState } from "react" import { useController, useFormContext } from "react-hook-form" import { CreateNftFormType } from "./NftDataForm" diff --git a/src/components/[guild]/RolePlatforms/components/AddRoleRewardModal/components/AddContractCallPanel/components/CreateNftForm/components/NftDataForm.tsx b/src/components/[guild]/RolePlatforms/components/AddRoleRewardModal/components/AddContractCallPanel/components/CreateNftForm/components/NftDataForm.tsx index 636ef24e32..984a0f5d01 100644 --- a/src/components/[guild]/RolePlatforms/components/AddRoleRewardModal/components/AddContractCallPanel/components/CreateNftForm/components/NftDataForm.tsx +++ b/src/components/[guild]/RolePlatforms/components/AddRoleRewardModal/components/AddContractCallPanel/components/CreateNftForm/components/NftDataForm.tsx @@ -26,6 +26,13 @@ import { Tooltip, useColorModeValue, } from "@chakra-ui/react" +import { + ArrowSquareOut, + Clock, + Hash, + Plus, + TrashSimple, +} from "@phosphor-icons/react" import StartEndTimeForm from "components/[guild]/RolePlatforms/components/EditRewardAvailabilityModal/components/StartEndTimeForm" import useGuildFee from "components/[guild]/collect/hooks/useGuildFee" import Button from "components/common/Button" @@ -33,7 +40,6 @@ import CheckboxColorCard from "components/common/CheckboxColorCard" import FormErrorMessage from "components/common/FormErrorMessage" import useTriggerNetworkChange from "hooks/useTriggerNetworkChange" import { useRouter } from "next/router" -import { ArrowSquareOut, Clock, Hash, Plus, TrashSimple } from "phosphor-react" import { useController, useFieldArray, diff --git a/src/components/[guild]/RolePlatforms/components/AddRoleRewardModal/components/AddFormPanel/AddFormPanel.tsx b/src/components/[guild]/RolePlatforms/components/AddRoleRewardModal/components/AddFormPanel/AddFormPanel.tsx index b6a22ae414..49e6799714 100644 --- a/src/components/[guild]/RolePlatforms/components/AddRoleRewardModal/components/AddFormPanel/AddFormPanel.tsx +++ b/src/components/[guild]/RolePlatforms/components/AddRoleRewardModal/components/AddFormPanel/AddFormPanel.tsx @@ -1,13 +1,13 @@ import { Stack } from "@chakra-ui/react" import { zodResolver } from "@hookform/resolvers/zod" +import { ArrowRight } from "@phosphor-icons/react" import { useAddRewardDiscardAlert } from "components/[guild]/AddRewardButton/hooks/useAddRewardDiscardAlert" import CreateFormForm from "components/[guild]/CreateFormModal/components/CreateFormForm" import useCreateForm from "components/[guild]/CreateFormModal/hooks/useCreateForm" import { FormCreationSchema } from "components/[guild]/CreateFormModal/schemas" import Button from "components/common/Button" -import { ArrowRight } from "phosphor-react" -import { AddRewardPanelProps } from "rewards" import { FormProvider, useForm, useWatch } from "react-hook-form" +import { AddRewardPanelProps } from "rewards" import { PlatformGuildData, PlatformType } from "types" import { uuidv7 } from "uuidv7" import { CreateForm } from "." diff --git a/src/components/[guild]/RolePlatforms/components/AddRoleRewardModal/components/AddFormPanel/components/ContinueWithExistingFormAlert.tsx b/src/components/[guild]/RolePlatforms/components/AddRoleRewardModal/components/AddFormPanel/components/ContinueWithExistingFormAlert.tsx index 787d328e5c..cd973aabdf 100644 --- a/src/components/[guild]/RolePlatforms/components/AddRoleRewardModal/components/AddFormPanel/components/ContinueWithExistingFormAlert.tsx +++ b/src/components/[guild]/RolePlatforms/components/AddRoleRewardModal/components/AddFormPanel/components/ContinueWithExistingFormAlert.tsx @@ -9,9 +9,9 @@ import { Stack, } from "@chakra-ui/react" import { Schemas } from "@guildxyz/types" +import { ArrowRight } from "@phosphor-icons/react" import useGuild from "components/[guild]/hooks/useGuild" import StyledSelect from "components/common/StyledSelect" -import { ArrowRight } from "phosphor-react" import { useMemo } from "react" import useSWRImmutable from "swr/immutable" import { PlatformGuildData } from "types" diff --git a/src/components/[guild]/RolePlatforms/components/AddRoleRewardModal/components/AddPoapPanel/AddPoapPanel.tsx b/src/components/[guild]/RolePlatforms/components/AddRoleRewardModal/components/AddPoapPanel/AddPoapPanel.tsx index 874d083279..dc8d0651d5 100644 --- a/src/components/[guild]/RolePlatforms/components/AddRoleRewardModal/components/AddPoapPanel/AddPoapPanel.tsx +++ b/src/components/[guild]/RolePlatforms/components/AddRoleRewardModal/components/AddPoapPanel/AddPoapPanel.tsx @@ -14,14 +14,14 @@ import { Text, Tooltip, } from "@chakra-ui/react" +import { Question } from "@phosphor-icons/react" import { useAddRewardDiscardAlert } from "components/[guild]/AddRewardButton/hooks/useAddRewardDiscardAlert" import Button from "components/common/Button" import FormErrorMessage from "components/common/FormErrorMessage" -import { Question } from "phosphor-react" -import rewards, { AddRewardPanelProps } from "rewards" import { useEffect } from "react" import { FormProvider, useController, useForm, useWatch } from "react-hook-form" import usePoapById from "requirements/Poap/hooks/usePoapById" +import rewards, { AddRewardPanelProps } from "rewards" import { PlatformGuildData, PlatformType } from "types" import DefaultAddRewardPanelWrapper from "../../DefaultAddRewardPanelWrapper" import UploadMintLinks from "./components/UploadMintLinks" diff --git a/src/components/[guild]/RolePlatforms/components/AddRoleRewardModal/components/AddPoapPanel/components/UploadTxt.tsx b/src/components/[guild]/RolePlatforms/components/AddRoleRewardModal/components/AddPoapPanel/components/UploadTxt.tsx index 85ae109aac..4c3e972fc5 100644 --- a/src/components/[guild]/RolePlatforms/components/AddRoleRewardModal/components/AddPoapPanel/components/UploadTxt.tsx +++ b/src/components/[guild]/RolePlatforms/components/AddRoleRewardModal/components/AddPoapPanel/components/UploadTxt.tsx @@ -1,6 +1,6 @@ +import { File } from "@phosphor-icons/react" import Button from "components/common/Button" import useDropzone from "hooks/useDropzone" -import { File } from "phosphor-react" import { useFormContext } from "react-hook-form" import { ImportPoapForm } from "../AddPoapPanel" import { INVALID_LINKS_ERROR, validatePoapLinks } from "./UploadMintLinks" diff --git a/src/components/[guild]/RolePlatforms/components/AddRoleRewardModal/components/AddPointsPanel/components/SetPointsAmount/components/DynamicPointsAmountForm.tsx b/src/components/[guild]/RolePlatforms/components/AddRoleRewardModal/components/AddPointsPanel/components/SetPointsAmount/components/DynamicPointsAmountForm.tsx index 07e8b6d373..4cbc32eaab 100644 --- a/src/components/[guild]/RolePlatforms/components/AddRoleRewardModal/components/AddPointsPanel/components/SetPointsAmount/components/DynamicPointsAmountForm.tsx +++ b/src/components/[guild]/RolePlatforms/components/AddRoleRewardModal/components/AddPointsPanel/components/SetPointsAmount/components/DynamicPointsAmountForm.tsx @@ -1,9 +1,9 @@ import { Icon, Text, useColorModeValue, useDisclosure } from "@chakra-ui/react" +import { ArrowSquareOut, Star } from "@phosphor-icons/react" import DynamicRewardSetup from "components/[guild]/RolePlatforms/components/AddRoleRewardModal/components/DynamicSetup/DynamicRewardSetup" import { useEditRolePlatformContext } from "components/[guild]/RolePlatforms/components/EditRolePlatformModal" import Button from "components/common/Button" import OptionImage from "components/common/StyledSelect/components/CustomSelectOption/components/OptionImage" -import { ArrowSquareOut, Star } from "phosphor-react" import { useEffect, type ReactNode } from "react" import { useWatch } from "react-hook-form" import InformationModal from "../../../../DynamicSetup/InformationModal" diff --git a/src/components/[guild]/RolePlatforms/components/AddRoleRewardModal/components/AddPointsPanel/components/SetPointsAmount/components/PointsAmountTypeSelector.tsx b/src/components/[guild]/RolePlatforms/components/AddRoleRewardModal/components/AddPointsPanel/components/SetPointsAmount/components/PointsAmountTypeSelector.tsx index 5313156da1..024ca4ebf1 100644 --- a/src/components/[guild]/RolePlatforms/components/AddRoleRewardModal/components/AddPointsPanel/components/SetPointsAmount/components/PointsAmountTypeSelector.tsx +++ b/src/components/[guild]/RolePlatforms/components/AddRoleRewardModal/components/AddPointsPanel/components/SetPointsAmount/components/PointsAmountTypeSelector.tsx @@ -9,8 +9,8 @@ import { Portal, Text, } from "@chakra-ui/react" +import { CaretDown, Lightning } from "@phosphor-icons/react" import Button from "components/common/Button" -import { CaretDown, Lightning } from "phosphor-react" const PointsAmountTypeSelector = ({ type, setType }) => { const options = [ diff --git a/src/components/[guild]/RolePlatforms/components/AddRoleRewardModal/components/AddTokenPanel/components/AllowanceButton.tsx b/src/components/[guild]/RolePlatforms/components/AddRoleRewardModal/components/AddTokenPanel/components/AllowanceButton.tsx index 1d658a2d42..2a82cfdbea 100644 --- a/src/components/[guild]/RolePlatforms/components/AddRoleRewardModal/components/AddTokenPanel/components/AllowanceButton.tsx +++ b/src/components/[guild]/RolePlatforms/components/AddRoleRewardModal/components/AddTokenPanel/components/AllowanceButton.tsx @@ -1,8 +1,8 @@ import { Collapse, Icon, Tooltip } from "@chakra-ui/react" +import { Question, Warning } from "@phosphor-icons/react" import useAllowance from "components/[guild]/Requirements/components/GuildCheckout/hooks/useAllowance" import Button from "components/common/Button" import useTokenData from "hooks/useTokenData" -import { Question, Warning } from "phosphor-react" import { NULL_ADDRESS } from "utils/guildCheckout/constants" import { useAccount } from "wagmi" import { Chain, Chains } from "wagmiConfig/chains" diff --git a/src/components/[guild]/RolePlatforms/components/AddRoleRewardModal/components/AddTokenPanel/components/ConversionInput.tsx b/src/components/[guild]/RolePlatforms/components/AddRoleRewardModal/components/AddTokenPanel/components/ConversionInput.tsx index 36309b6c25..a08be7e91a 100644 --- a/src/components/[guild]/RolePlatforms/components/AddRoleRewardModal/components/AddTokenPanel/components/ConversionInput.tsx +++ b/src/components/[guild]/RolePlatforms/components/AddRoleRewardModal/components/AddTokenPanel/components/ConversionInput.tsx @@ -6,7 +6,7 @@ import { InputGroup, InputLeftElement, } from "@chakra-ui/react" -import { ArrowRight, Lock, LockOpen } from "phosphor-react" +import { ArrowRight, Lock, LockOpen } from "@phosphor-icons/react" import { ReactNode, useEffect, useState } from "react" import { FormProvider, useForm, useFormContext, useWatch } from "react-hook-form" import ControlledNumberInput from "requirements/WalletActivity/components/ControlledNumberInput" diff --git a/src/components/[guild]/RolePlatforms/components/AddRoleRewardModal/components/AddTokenPanel/components/CustomSnapshotForm.tsx b/src/components/[guild]/RolePlatforms/components/AddRoleRewardModal/components/AddTokenPanel/components/CustomSnapshotForm.tsx index bb275b82e9..e292bd7579 100644 --- a/src/components/[guild]/RolePlatforms/components/AddRoleRewardModal/components/AddTokenPanel/components/CustomSnapshotForm.tsx +++ b/src/components/[guild]/RolePlatforms/components/AddRoleRewardModal/components/AddTokenPanel/components/CustomSnapshotForm.tsx @@ -17,13 +17,13 @@ import { Thead, Tr, } from "@chakra-ui/react" +import { Info, Upload } from "@phosphor-icons/react" import useUser from "components/[guild]/hooks/useUser" import Button from "components/common/Button" import CopyableAddress from "components/common/CopyableAddress" import useShowErrorToast from "hooks/useShowErrorToast" import useToast from "hooks/useToast" import Papa from "papaparse" -import { Info, Upload } from "phosphor-react" import { useDropzone } from "react-dropzone" import { useFormContext, useWatch } from "react-hook-form" diff --git a/src/components/[guild]/RolePlatforms/components/AddRoleRewardModal/components/AddTokenPanel/components/DynamicAmount.tsx b/src/components/[guild]/RolePlatforms/components/AddRoleRewardModal/components/AddTokenPanel/components/DynamicAmount.tsx index f71b6f0f9f..66e3e557b6 100644 --- a/src/components/[guild]/RolePlatforms/components/AddRoleRewardModal/components/AddTokenPanel/components/DynamicAmount.tsx +++ b/src/components/[guild]/RolePlatforms/components/AddRoleRewardModal/components/AddTokenPanel/components/DynamicAmount.tsx @@ -1,11 +1,11 @@ import { Icon, Stack, Text } from "@chakra-ui/react" +import { Star } from "@phosphor-icons/react" import useGuildPlatform from "components/[guild]/hooks/useGuildPlatform" import OptionImage from "components/common/StyledSelect/components/CustomSelectOption/components/OptionImage" import useTokenData from "hooks/useTokenData" -import { Star } from "phosphor-react" -import DynamicTypeForm from "rewards/Token/DynamicTypeForm" import { ReactNode } from "react" import { useWatch } from "react-hook-form" +import DynamicTypeForm from "rewards/Token/DynamicTypeForm" import Token from "static/icons/token.svg" import ConversionInput from "./ConversionInput" diff --git a/src/components/[guild]/RolePlatforms/components/AddRoleRewardModal/components/AddTokenPanel/components/SetTokenStep.tsx b/src/components/[guild]/RolePlatforms/components/AddRoleRewardModal/components/AddTokenPanel/components/SetTokenStep.tsx index 76aa149891..bbd7849c49 100644 --- a/src/components/[guild]/RolePlatforms/components/AddRoleRewardModal/components/AddTokenPanel/components/SetTokenStep.tsx +++ b/src/components/[guild]/RolePlatforms/components/AddRoleRewardModal/components/AddTokenPanel/components/SetTokenStep.tsx @@ -1,8 +1,8 @@ import { Button, Flex, HStack, Stack, Text, useToast } from "@chakra-ui/react" +import { Upload, X } from "@phosphor-icons/react" import usePinata from "hooks/usePinata" import useShowErrorToast from "hooks/useShowErrorToast" import useTokenData from "hooks/useTokenData" -import { Upload, X } from "phosphor-react" import { useCallback, useEffect, useState } from "react" import { useDropzone } from "react-dropzone" import { useFormContext, useWatch } from "react-hook-form" diff --git a/src/components/[guild]/RolePlatforms/components/AddRoleRewardModal/components/DynamicSetup/BaseValueModal.tsx b/src/components/[guild]/RolePlatforms/components/AddRoleRewardModal/components/DynamicSetup/BaseValueModal.tsx index 149d418a02..cc98dd0e1d 100644 --- a/src/components/[guild]/RolePlatforms/components/AddRoleRewardModal/components/DynamicSetup/BaseValueModal.tsx +++ b/src/components/[guild]/RolePlatforms/components/AddRoleRewardModal/components/DynamicSetup/BaseValueModal.tsx @@ -8,13 +8,13 @@ import { Text, VStack, } from "@chakra-ui/react" +import { CaretRight } from "@phosphor-icons/react" import LogicDivider from "components/[guild]/LogicDivider" import { useRequirementHandlerContext } from "components/[guild]/RequirementHandlerContext" import RequirementDisplayComponent from "components/[guild]/Requirements/components/RequirementDisplayComponent" import DisplayCard from "components/common/DisplayCard" import { Modal } from "components/common/Modal" import AddRequirement from "components/create-guild/Requirements/components/AddRequirement" -import { CaretRight } from "phosphor-react" import { REQUIREMENT_PROVIDED_VALUES } from "requirements/requirements" type Props = { diff --git a/src/components/[guild]/RolePlatforms/components/AddRoleRewardModal/components/DynamicSetup/DynamicRewardSetup.tsx b/src/components/[guild]/RolePlatforms/components/AddRoleRewardModal/components/DynamicSetup/DynamicRewardSetup.tsx index a27623586d..b601cb1bd7 100644 --- a/src/components/[guild]/RolePlatforms/components/AddRoleRewardModal/components/DynamicSetup/DynamicRewardSetup.tsx +++ b/src/components/[guild]/RolePlatforms/components/AddRoleRewardModal/components/DynamicSetup/DynamicRewardSetup.tsx @@ -8,12 +8,12 @@ import { Text, useDisclosure, } from "@chakra-ui/react" +import { ArrowsClockwise, Lightning } from "@phosphor-icons/react" import { useRequirementHandlerContext } from "components/[guild]/RequirementHandlerContext" import RequirementDisplayComponent from "components/[guild]/Requirements/components/RequirementDisplayComponent" import AddCard from "components/common/AddCard" import Button from "components/common/Button" import Card from "components/common/Card" -import { ArrowsClockwise, Lightning } from "phosphor-react" import { useFormContext, useWatch } from "react-hook-form" import ConversionInput from "../AddTokenPanel/components/ConversionInput" import BaseValueModal from "./BaseValueModal" diff --git a/src/components/[guild]/RolePlatforms/components/EditRewardAvailabilityButton.tsx b/src/components/[guild]/RolePlatforms/components/EditRewardAvailabilityButton.tsx index 0a34f68b29..c343f7a64e 100644 --- a/src/components/[guild]/RolePlatforms/components/EditRewardAvailabilityButton.tsx +++ b/src/components/[guild]/RolePlatforms/components/EditRewardAvailabilityButton.tsx @@ -1,6 +1,6 @@ import { IconButton } from "@chakra-ui/react" +import { Clock, GearSix } from "@phosphor-icons/react" import Button from "components/common/Button" -import { Clock, GearSix } from "phosphor-react" type Props = { onClick: () => void diff --git a/src/components/[guild]/RolePlatforms/components/EditRewardAvailabilityModal/EditRewardAvailabilityModal.tsx b/src/components/[guild]/RolePlatforms/components/EditRewardAvailabilityModal/EditRewardAvailabilityModal.tsx index 6407dacc6c..9889dee192 100644 --- a/src/components/[guild]/RolePlatforms/components/EditRewardAvailabilityModal/EditRewardAvailabilityModal.tsx +++ b/src/components/[guild]/RolePlatforms/components/EditRewardAvailabilityModal/EditRewardAvailabilityModal.tsx @@ -13,12 +13,12 @@ import { Text, Tooltip, } from "@chakra-ui/react" +import { Clock, Hash } from "@phosphor-icons/react" import Button from "components/common/Button" import CheckboxColorCard from "components/common/CheckboxColorCard" import { Modal } from "components/common/Modal" -import { Clock, Hash } from "phosphor-react" -import rewards from "rewards" import { FormProvider, useController, useForm } from "react-hook-form" +import rewards from "rewards" import { PlatformName } from "types" import StartEndTimeForm, { AUTO_TIMEFRAME_PLATFORMS, diff --git a/src/components/[guild]/RolePlatforms/components/PlatformCard/components/AvailabilityTags.tsx b/src/components/[guild]/RolePlatforms/components/PlatformCard/components/AvailabilityTags.tsx index 988aeb4a7f..f9d4934f7e 100644 --- a/src/components/[guild]/RolePlatforms/components/PlatformCard/components/AvailabilityTags.tsx +++ b/src/components/[guild]/RolePlatforms/components/PlatformCard/components/AvailabilityTags.tsx @@ -7,7 +7,7 @@ import { Wrap, WrapProps, } from "@chakra-ui/react" -import { Clock } from "phosphor-react" +import { Clock } from "@phosphor-icons/react" import { PropsWithChildren, useState } from "react" import { RolePlatform } from "types" import formatRelativeTimeFromNow, { diff --git a/src/components/[guild]/RolePlatforms/components/PlatformCard/components/PlatformCardMenu.tsx b/src/components/[guild]/RolePlatforms/components/PlatformCard/components/PlatformCardMenu.tsx index e20c1ff335..ecc235c324 100644 --- a/src/components/[guild]/RolePlatforms/components/PlatformCard/components/PlatformCardMenu.tsx +++ b/src/components/[guild]/RolePlatforms/components/PlatformCard/components/PlatformCardMenu.tsx @@ -1,5 +1,5 @@ import { IconButton, Menu, MenuButton, MenuList, Portal } from "@chakra-ui/react" -import { DotsThree } from "phosphor-react" +import { DotsThree } from "@phosphor-icons/react" import { PropsWithChildren } from "react" const PlatformCardMenu = ({ children }: PropsWithChildren) => ( diff --git a/src/components/[guild]/RolePlatforms/components/RemovePlatformButton/RemovePlatformButton.tsx b/src/components/[guild]/RolePlatforms/components/RemovePlatformButton/RemovePlatformButton.tsx index 59e4f6a16f..eafe1f5f29 100644 --- a/src/components/[guild]/RolePlatforms/components/RemovePlatformButton/RemovePlatformButton.tsx +++ b/src/components/[guild]/RolePlatforms/components/RemovePlatformButton/RemovePlatformButton.tsx @@ -6,8 +6,8 @@ import { Tooltip, useDisclosure, } from "@chakra-ui/react" +import { Info } from "@phosphor-icons/react" import ConfirmationAlert from "components/create-guild/Requirements/components/ConfirmationAlert" -import { Info } from "phosphor-react" import useRemovePlatform from "./hooks/useRemovePlatform" type Props = { diff --git a/src/components/[guild]/RoleTag.tsx b/src/components/[guild]/RoleTag.tsx index 5720780f71..7b47477181 100644 --- a/src/components/[guild]/RoleTag.tsx +++ b/src/components/[guild]/RoleTag.tsx @@ -9,7 +9,7 @@ import { TagRightIcon, useColorModeValue, } from "@chakra-ui/react" -import { IconProps } from "phosphor-react" +import { IconProps } from "@phosphor-icons/react" import { ForwardRefExoticComponent, memo, RefAttributes } from "react" type Props = { diff --git a/src/components/[guild]/SetVisibility/visibilityData.tsx b/src/components/[guild]/SetVisibility/visibilityData.tsx index f754f7f14c..47c9b17623 100644 --- a/src/components/[guild]/SetVisibility/visibilityData.tsx +++ b/src/components/[guild]/SetVisibility/visibilityData.tsx @@ -1,6 +1,11 @@ import { Visibility } from "@guildxyz/types" +import { + Detective, + EyeSlash, + GlobeHemisphereEast, + IconProps, +} from "@phosphor-icons/react" import { Option } from "components/common/RadioSelect/RadioSelect" -import { Detective, EyeSlash, GlobeHemisphereEast, IconProps } from "phosphor-react" import PrivateVisibilityOptions from "./components/PrivateVisibilityOptions" export const VISIBILITY_DATA: Record< diff --git a/src/components/[guild]/SocialIcon.tsx b/src/components/[guild]/SocialIcon.tsx index 9e78f4ccff..204bd769cb 100644 --- a/src/components/[guild]/SocialIcon.tsx +++ b/src/components/[guild]/SocialIcon.tsx @@ -5,7 +5,7 @@ import { MediumLogo, SpotifyLogo, YoutubeLogo, -} from "phosphor-react" +} from "@phosphor-icons/react" import { ForwardRefExoticComponent, RefAttributes } from "react" import XLogo from "static/icons/x.svg" import MirrorLogo from "static/socialIcons/mirror.svg" diff --git a/src/components/[guild]/StayConnectedToast.tsx b/src/components/[guild]/StayConnectedToast.tsx index 22072a6d66..2a441b27e2 100644 --- a/src/components/[guild]/StayConnectedToast.tsx +++ b/src/components/[guild]/StayConnectedToast.tsx @@ -1,8 +1,8 @@ import { ToastId, useToast } from "@chakra-ui/react" +import { ArrowRight } from "@phosphor-icons/react" import useLocalStorage from "hooks/useLocalStorage" import { useToastWithButton } from "hooks/useToast" import { useRouter } from "next/router" -import { ArrowRight } from "phosphor-react" import { useCallback, useEffect, useRef } from "react" import useGuild from "./hooks/useGuild" import useGuildPermission from "./hooks/useGuildPermission" diff --git a/src/components/[guild]/[group]/EditCampaignButton.tsx b/src/components/[guild]/[group]/EditCampaignButton.tsx index 344f59945b..bf9b3bbbff 100644 --- a/src/components/[guild]/[group]/EditCampaignButton.tsx +++ b/src/components/[guild]/[group]/EditCampaignButton.tsx @@ -1,5 +1,5 @@ import { IconButton, useDisclosure } from "@chakra-ui/react" -import { GearSix } from "phosphor-react" +import { GearSix } from "@phosphor-icons/react" import EditCampaignModal from "../AccessHub/components/CampaignCards/components/EditCampaignModal" import { useThemeContext } from "../ThemeContext" import useRoleGroup from "../hooks/useRoleGroup" diff --git a/src/components/[guild]/activity/ActivityLogAction/ActivityLogAction.tsx b/src/components/[guild]/activity/ActivityLogAction/ActivityLogAction.tsx index 2139f934e1..7b46fc2ad3 100644 --- a/src/components/[guild]/activity/ActivityLogAction/ActivityLogAction.tsx +++ b/src/components/[guild]/activity/ActivityLogAction/ActivityLogAction.tsx @@ -9,9 +9,9 @@ import { useColorModeValue, useDisclosure, } from "@chakra-ui/react" -import Card from "components/common/Card" +import { CaretDown } from "@phosphor-icons/react" import RequirementDisplayComponent from "components/[guild]/Requirements/components/RequirementDisplayComponent" -import { CaretDown } from "phosphor-react" +import Card from "components/common/Card" import { Requirement } from "types" import { ACTION, ActivityLogAction as Action } from "../constants" import { diff --git a/src/components/[guild]/activity/ActivityLogAction/components/ActionIcon.tsx b/src/components/[guild]/activity/ActivityLogAction/components/ActionIcon.tsx index 860f3c8f21..1a68e61351 100644 --- a/src/components/[guild]/activity/ActivityLogAction/components/ActionIcon.tsx +++ b/src/components/[guild]/activity/ActivityLogAction/components/ActionIcon.tsx @@ -1,6 +1,6 @@ import { Icon } from "@chakra-ui/react" import { SystemStyleObject } from "@chakra-ui/theme-tools" -import { IconProps, Question } from "phosphor-react" +import { IconProps, Question } from "@phosphor-icons/react" import { Rest } from "types" import { ACTION, activityLogActionIcons } from "../../constants" import { useActivityLogActionContext } from "../ActivityLogActionContext" diff --git a/src/components/[guild]/activity/ActivityLogAction/components/ActionLabel.tsx b/src/components/[guild]/activity/ActivityLogAction/components/ActionLabel.tsx index 1a4fe221ed..705b07236d 100644 --- a/src/components/[guild]/activity/ActivityLogAction/components/ActionLabel.tsx +++ b/src/components/[guild]/activity/ActivityLogAction/components/ActionLabel.tsx @@ -1,5 +1,5 @@ import { Center, Icon, Text, Wrap } from "@chakra-ui/react" -import { ArrowLeft, ArrowRight } from "phosphor-react" +import { ArrowLeft, ArrowRight } from "@phosphor-icons/react" import rewards from "rewards" import capitalize from "utils/capitalize" import { useActivityLog } from "../../ActivityLogContext" diff --git a/src/components/[guild]/activity/ActivityLogAction/components/ActivityLogRoleTag.tsx b/src/components/[guild]/activity/ActivityLogAction/components/ActivityLogRoleTag.tsx index 06cfe00b08..c371e9f33d 100644 --- a/src/components/[guild]/activity/ActivityLogAction/components/ActivityLogRoleTag.tsx +++ b/src/components/[guild]/activity/ActivityLogAction/components/ActivityLogRoleTag.tsx @@ -1,7 +1,7 @@ import { forwardRef, TagProps } from "@chakra-ui/react" +import { DotsThreeVertical, IconProps } from "@phosphor-icons/react" import useGuild from "components/[guild]/hooks/useGuild" import RoleTag from "components/[guild]/RoleTag" -import { DotsThreeVertical, IconProps } from "phosphor-react" import { ForwardRefExoticComponent, RefAttributes } from "react" import { useActivityLog } from "../../ActivityLogContext" import ClickableTagPopover from "./ClickableTagPopover" diff --git a/src/components/[guild]/activity/ActivityLogAction/components/BeforeAfterActions.tsx b/src/components/[guild]/activity/ActivityLogAction/components/BeforeAfterActions.tsx index 1f67369af9..18491a57b9 100644 --- a/src/components/[guild]/activity/ActivityLogAction/components/BeforeAfterActions.tsx +++ b/src/components/[guild]/activity/ActivityLogAction/components/BeforeAfterActions.tsx @@ -8,10 +8,10 @@ import { Stack, Text, } from "@chakra-ui/react" -import GuildLogo from "components/common/GuildLogo" +import { ArrowRight } from "@phosphor-icons/react" import RequirementDisplayComponent from "components/[guild]/Requirements/components/RequirementDisplayComponent" +import GuildLogo from "components/common/GuildLogo" import useColorPalette from "hooks/useColorPalette" -import { ArrowRight } from "phosphor-react" import { Requirement } from "types" import { useActivityLog } from "../../ActivityLogContext" import { ACTION } from "../../constants" diff --git a/src/components/[guild]/activity/ActivityLogAction/components/ClickableTagPopover/components/CopyAddress.tsx b/src/components/[guild]/activity/ActivityLogAction/components/ClickableTagPopover/components/CopyAddress.tsx index 25a4f1e329..ac58d6e50d 100644 --- a/src/components/[guild]/activity/ActivityLogAction/components/ClickableTagPopover/components/CopyAddress.tsx +++ b/src/components/[guild]/activity/ActivityLogAction/components/ClickableTagPopover/components/CopyAddress.tsx @@ -1,6 +1,6 @@ import { useClipboard } from "@chakra-ui/react" +import { Check, Copy } from "@phosphor-icons/react" import Button from "components/common/Button" -import { Check, Copy } from "phosphor-react" type Props = { address: string diff --git a/src/components/[guild]/activity/ActivityLogAction/components/ClickableTagPopover/components/FilterBy.tsx b/src/components/[guild]/activity/ActivityLogAction/components/ClickableTagPopover/components/FilterBy.tsx index d5903b10c4..18eb70f899 100644 --- a/src/components/[guild]/activity/ActivityLogAction/components/ClickableTagPopover/components/FilterBy.tsx +++ b/src/components/[guild]/activity/ActivityLogAction/components/ClickableTagPopover/components/FilterBy.tsx @@ -1,10 +1,10 @@ -import Button from "components/common/Button" +import { Funnel } from "@phosphor-icons/react" import { Filter, FILTER_NAMES, useActivityLogFilters, } from "components/[guild]/activity/ActivityLogFiltersBar/components/ActivityLogFiltersContext" -import { Funnel } from "phosphor-react" +import Button from "components/common/Button" type Props = { filter: Omit diff --git a/src/components/[guild]/activity/ActivityLogAction/components/ClickableTagPopover/components/ViewInCRM.tsx b/src/components/[guild]/activity/ActivityLogAction/components/ClickableTagPopover/components/ViewInCRM.tsx index e152c7398a..1ba22d24c6 100644 --- a/src/components/[guild]/activity/ActivityLogAction/components/ClickableTagPopover/components/ViewInCRM.tsx +++ b/src/components/[guild]/activity/ActivityLogAction/components/ClickableTagPopover/components/ViewInCRM.tsx @@ -1,8 +1,8 @@ +import { ArrowSquareOut } from "@phosphor-icons/react" import { useActivityLog } from "components/[guild]/activity/ActivityLogContext" import useGuild from "components/[guild]/hooks/useGuild" import Button from "components/common/Button" import { useRouter } from "next/router" -import { ArrowSquareOut } from "phosphor-react" type Props = { label: string diff --git a/src/components/[guild]/activity/ActivityLogAction/components/ClickableTagPopover/components/ViewInFormResponses.tsx b/src/components/[guild]/activity/ActivityLogAction/components/ClickableTagPopover/components/ViewInFormResponses.tsx index 5ded3bccd6..f3d17d37df 100644 --- a/src/components/[guild]/activity/ActivityLogAction/components/ClickableTagPopover/components/ViewInFormResponses.tsx +++ b/src/components/[guild]/activity/ActivityLogAction/components/ClickableTagPopover/components/ViewInFormResponses.tsx @@ -1,7 +1,7 @@ +import { ArrowSquareOut } from "@phosphor-icons/react" import useGuild from "components/[guild]/hooks/useGuild" import Button from "components/common/Button" import { useRouter } from "next/router" -import { ArrowSquareOut } from "phosphor-react" type Props = { label: string diff --git a/src/components/[guild]/activity/ActivityLogAction/components/ClickableTagPopover/components/ViewRole.tsx b/src/components/[guild]/activity/ActivityLogAction/components/ClickableTagPopover/components/ViewRole.tsx index e433991c85..d4a93994f3 100644 --- a/src/components/[guild]/activity/ActivityLogAction/components/ClickableTagPopover/components/ViewRole.tsx +++ b/src/components/[guild]/activity/ActivityLogAction/components/ClickableTagPopover/components/ViewRole.tsx @@ -1,7 +1,7 @@ +import { ArrowSquareOut } from "@phosphor-icons/react" import useGuild from "components/[guild]/hooks/useGuild" import Button from "components/common/Button" import { useRouter } from "next/router" -import { ArrowSquareOut } from "phosphor-react" import { useState } from "react" type Props = { diff --git a/src/components/[guild]/activity/ActivityLogAction/components/FormTag.tsx b/src/components/[guild]/activity/ActivityLogAction/components/FormTag.tsx index d9a767ba19..38f702eb10 100644 --- a/src/components/[guild]/activity/ActivityLogAction/components/FormTag.tsx +++ b/src/components/[guild]/activity/ActivityLogAction/components/FormTag.tsx @@ -8,9 +8,9 @@ import { Text, useColorModeValue, } from "@chakra-ui/react" -import { DotsThreeVertical, IconProps } from "phosphor-react" -import rewards from "rewards" +import { DotsThreeVertical, IconProps } from "@phosphor-icons/react" import { ForwardRefExoticComponent, RefAttributes } from "react" +import rewards from "rewards" import { useActivityLog } from "../../ActivityLogContext" import ClickableTagPopover from "./ClickableTagPopover" import FilterBy from "./ClickableTagPopover/components/FilterBy" diff --git a/src/components/[guild]/activity/ActivityLogAction/components/GuildTag.tsx b/src/components/[guild]/activity/ActivityLogAction/components/GuildTag.tsx index 1f6ebdfb78..42e995ff26 100644 --- a/src/components/[guild]/activity/ActivityLogAction/components/GuildTag.tsx +++ b/src/components/[guild]/activity/ActivityLogAction/components/GuildTag.tsx @@ -9,8 +9,8 @@ import { Text, useColorModeValue, } from "@chakra-ui/react" +import { DotsThreeVertical, IconProps } from "@phosphor-icons/react" import { useYourGuilds } from "components/explorer/YourGuilds" -import { DotsThreeVertical, IconProps } from "phosphor-react" import { ForwardRefExoticComponent, RefAttributes } from "react" import { useActivityLog } from "../../ActivityLogContext" import ClickableTagPopover from "./ClickableTagPopover" diff --git a/src/components/[guild]/activity/ActivityLogAction/components/IdentityTag.tsx b/src/components/[guild]/activity/ActivityLogAction/components/IdentityTag.tsx index 33c838f23a..2a84551260 100644 --- a/src/components/[guild]/activity/ActivityLogAction/components/IdentityTag.tsx +++ b/src/components/[guild]/activity/ActivityLogAction/components/IdentityTag.tsx @@ -1,5 +1,5 @@ import { Tag, TagLabel, TagLeftIcon } from "@chakra-ui/react" -import { Wallet } from "phosphor-react" +import { Wallet } from "@phosphor-icons/react" import rewards from "rewards" import { PlatformName } from "types" diff --git a/src/components/[guild]/activity/ActivityLogAction/components/MoreActions.tsx b/src/components/[guild]/activity/ActivityLogAction/components/MoreActions.tsx index 0c91c78f38..c8a35c7155 100644 --- a/src/components/[guild]/activity/ActivityLogAction/components/MoreActions.tsx +++ b/src/components/[guild]/activity/ActivityLogAction/components/MoreActions.tsx @@ -12,9 +12,9 @@ import { UnorderedList, useDisclosure, } from "@chakra-ui/react" +import { ArrowSquareOut, DotsThree } from "@phosphor-icons/react" import Button from "components/common/Button" import { Modal } from "components/common/Modal" -import { ArrowSquareOut, DotsThree } from "phosphor-react" import { CSSProperties, memo, useEffect, useRef } from "react" import { VariableSizeList } from "react-window" import { ActivityLogAction } from "../../constants" diff --git a/src/components/[guild]/activity/ActivityLogAction/components/RewardTag.tsx b/src/components/[guild]/activity/ActivityLogAction/components/RewardTag.tsx index 3915987870..fd9ac8e438 100644 --- a/src/components/[guild]/activity/ActivityLogAction/components/RewardTag.tsx +++ b/src/components/[guild]/activity/ActivityLogAction/components/RewardTag.tsx @@ -6,9 +6,9 @@ import { TagProps, TagRightIcon, } from "@chakra-ui/react" -import { DotsThreeVertical, IconProps } from "phosphor-react" -import rewards from "rewards" +import { DotsThreeVertical, IconProps } from "@phosphor-icons/react" import { ForwardRefExoticComponent, RefAttributes } from "react" +import rewards from "rewards" import { PlatformName, PlatformType } from "types" import { useActivityLog } from "../../ActivityLogContext" import ClickableTagPopover from "./ClickableTagPopover" diff --git a/src/components/[guild]/activity/ActivityLogAction/components/UpdatedDataGrid.tsx b/src/components/[guild]/activity/ActivityLogAction/components/UpdatedDataGrid.tsx index a2a19e03bf..03650796df 100644 --- a/src/components/[guild]/activity/ActivityLogAction/components/UpdatedDataGrid.tsx +++ b/src/components/[guild]/activity/ActivityLogAction/components/UpdatedDataGrid.tsx @@ -7,7 +7,7 @@ import { useBreakpointValue, useColorModeValue, } from "@chakra-ui/react" -import { ArrowDown, ArrowRight } from "phosphor-react" +import { ArrowDown, ArrowRight } from "@phosphor-icons/react" type Props = { before: JSX.Element diff --git a/src/components/[guild]/activity/ActivityLogAction/components/UserTag.tsx b/src/components/[guild]/activity/ActivityLogAction/components/UserTag.tsx index 512b5e6867..54d47d9323 100644 --- a/src/components/[guild]/activity/ActivityLogAction/components/UserTag.tsx +++ b/src/components/[guild]/activity/ActivityLogAction/components/UserTag.tsx @@ -7,8 +7,8 @@ import { TagRightIcon, useColorModeValue, } from "@chakra-ui/react" +import { DotsThreeVertical } from "@phosphor-icons/react" import GuildAvatar from "components/common/GuildAvatar" -import { DotsThreeVertical } from "phosphor-react" import useSWRImmutable from "swr/immutable" import shortenHex from "utils/shortenHex" import { useActivityLog } from "../../ActivityLogContext" diff --git a/src/components/[guild]/activity/ActivityLogFiltersBar/components/DateRangeInput.tsx b/src/components/[guild]/activity/ActivityLogFiltersBar/components/DateRangeInput.tsx index d4f3568f0f..39f2e109ab 100644 --- a/src/components/[guild]/activity/ActivityLogFiltersBar/components/DateRangeInput.tsx +++ b/src/components/[guild]/activity/ActivityLogFiltersBar/components/DateRangeInput.tsx @@ -13,8 +13,13 @@ import { useBreakpointValue, useColorModeValue, } from "@chakra-ui/react" +import { + CalendarBlank, + CalendarCheck, + CaretDown, + TrashSimple, +} from "@phosphor-icons/react" import Button from "components/common/Button" -import { CalendarBlank, CalendarCheck, CaretDown, TrashSimple } from "phosphor-react" import { ChangeEvent } from "react" import { useActivityLog } from "../../ActivityLogContext" import { diff --git a/src/components/[guild]/activity/ActivityLogFiltersBar/components/FilterTag/FilterTag.tsx b/src/components/[guild]/activity/ActivityLogFiltersBar/components/FilterTag/FilterTag.tsx index f1e35d1cb4..83ad2adf2e 100644 --- a/src/components/[guild]/activity/ActivityLogFiltersBar/components/FilterTag/FilterTag.tsx +++ b/src/components/[guild]/activity/ActivityLogFiltersBar/components/FilterTag/FilterTag.tsx @@ -15,11 +15,11 @@ import * as combobox from "@zag-js/combobox" import { normalizeProps, useMachine } from "@zag-js/react" import ActivityLogRoleTag from "../../../ActivityLogAction/components/ActivityLogRoleTag" +import { Warning, X } from "@phosphor-icons/react" import FormTag from "components/[guild]/activity/ActivityLogAction/components/FormTag" import GuildTag from "components/[guild]/activity/ActivityLogAction/components/GuildTag" import { useActivityLog } from "components/[guild]/activity/ActivityLogContext" import useGuild from "components/[guild]/hooks/useGuild" -import { Warning, X } from "phosphor-react" import { PropsWithChildren, useEffect, useState } from "react" import { PlatformName, PlatformType } from "types" import capitalize from "utils/capitalize" diff --git a/src/components/[guild]/activity/ActivityLogFiltersBar/components/FiltersInput.tsx b/src/components/[guild]/activity/ActivityLogFiltersBar/components/FiltersInput.tsx index 883ad08b09..b109d4d10f 100644 --- a/src/components/[guild]/activity/ActivityLogFiltersBar/components/FiltersInput.tsx +++ b/src/components/[guild]/activity/ActivityLogFiltersBar/components/FiltersInput.tsx @@ -6,9 +6,9 @@ import { useColorModeValue, Wrap, } from "@chakra-ui/react" +import { CaretDown, X } from "@phosphor-icons/react" import * as combobox from "@zag-js/combobox" import { normalizeProps, useMachine } from "@zag-js/react" -import { CaretDown, X } from "phosphor-react" import { KeyboardEvent, useEffect, useRef, useState } from "react" import { isSupportedQueryParam, diff --git a/src/components/[guild]/activity/constants.ts b/src/components/[guild]/activity/constants.ts index 771f978aa4..164711c95f 100644 --- a/src/components/[guild]/activity/constants.ts +++ b/src/components/[guild]/activity/constants.ts @@ -29,7 +29,7 @@ import { UserList, UserMinus, UserSwitch, -} from "phosphor-react" +} from "@phosphor-icons/react" import { ForwardRefExoticComponent, RefAttributes } from "react" export enum ACTION { diff --git a/src/components/[guild]/claim-poap/components/MintLinkModal.tsx b/src/components/[guild]/claim-poap/components/MintLinkModal.tsx index 1eae287e6c..d11803c439 100644 --- a/src/components/[guild]/claim-poap/components/MintLinkModal.tsx +++ b/src/components/[guild]/claim-poap/components/MintLinkModal.tsx @@ -12,7 +12,7 @@ import { Spinner, Text, } from "@chakra-ui/react" -import { ArrowSquareOut, CheckCircle } from "phosphor-react" +import { ArrowSquareOut, CheckCircle } from "@phosphor-icons/react" import { useAccount } from "wagmi" import ErrorAlert from "../../../common/ErrorAlert" import { Modal } from "../../../common/Modal" diff --git a/src/components/[guild]/claim-poap/components/PoapImage.tsx b/src/components/[guild]/claim-poap/components/PoapImage.tsx index 2e7cf02ee8..7aed26a62d 100644 --- a/src/components/[guild]/claim-poap/components/PoapImage.tsx +++ b/src/components/[guild]/claim-poap/components/PoapImage.tsx @@ -9,8 +9,8 @@ import { Spinner, useColorModeValue, } from "@chakra-ui/react" +import { Image } from "@phosphor-icons/react" import Card from "components/common/Card" -import { Image } from "phosphor-react" import PoapBg from "static/icons/poap-bg.svg" type Props = { diff --git a/src/components/[guild]/claim-poap/components/SocialLinks.tsx b/src/components/[guild]/claim-poap/components/SocialLinks.tsx index 4cab3e33bf..a4a277a201 100644 --- a/src/components/[guild]/claim-poap/components/SocialLinks.tsx +++ b/src/components/[guild]/claim-poap/components/SocialLinks.tsx @@ -1,8 +1,8 @@ import { Icon, Link, Wrap } from "@chakra-ui/react" import type { SocialLinks as SocialLinksType } from "@guildxyz/types" +import { ArrowSquareOut } from "@phosphor-icons/react" import SocialIcon from "components/[guild]/SocialIcon" import Section from "components/common/Section" -import { ArrowSquareOut } from "phosphor-react" import { SocialLinkKey } from "types" import capitalize from "utils/capitalize" diff --git a/src/components/[guild]/collect/components/CollectibleImage.tsx b/src/components/[guild]/collect/components/CollectibleImage.tsx index 3d3f27a28d..9c21f4b9d5 100644 --- a/src/components/[guild]/collect/components/CollectibleImage.tsx +++ b/src/components/[guild]/collect/components/CollectibleImage.tsx @@ -7,8 +7,8 @@ import { Img, Spinner, } from "@chakra-ui/react" +import { Image } from "@phosphor-icons/react" import Card from "components/common/Card" -import { Image } from "phosphor-react" import { ComponentType, Fragment } from "react" type Props = { diff --git a/src/components/[guild]/collect/components/Details/components/BlockExplorerLink.tsx b/src/components/[guild]/collect/components/Details/components/BlockExplorerLink.tsx index 0abbe8529d..6bda89906b 100644 --- a/src/components/[guild]/collect/components/Details/components/BlockExplorerLink.tsx +++ b/src/components/[guild]/collect/components/Details/components/BlockExplorerLink.tsx @@ -1,6 +1,6 @@ import { Link } from "@chakra-ui/next-js" import { Icon, Skeleton, Text } from "@chakra-ui/react" -import { ArrowSquareOut } from "phosphor-react" +import { ArrowSquareOut } from "@phosphor-icons/react" import shortenHex from "utils/shortenHex" import { CHAIN_CONFIG, Chain } from "wagmiConfig/chains" diff --git a/src/components/[guild]/collect/components/EditNFTDescriptionModalButton.tsx b/src/components/[guild]/collect/components/EditNFTDescriptionModalButton.tsx index f069a1c235..fd5dcdaf8e 100644 --- a/src/components/[guild]/collect/components/EditNFTDescriptionModalButton.tsx +++ b/src/components/[guild]/collect/components/EditNFTDescriptionModalButton.tsx @@ -1,7 +1,7 @@ import { Icon, IconButton, useDisclosure } from "@chakra-ui/react" -import { PencilSimple } from "phosphor-react" -import EditNFTDescriptionModal from "rewards/ContractCall/components/EditNFTDescriptionModal" +import { PencilSimple } from "@phosphor-icons/react" import React from "react" +import EditNFTDescriptionModal from "rewards/ContractCall/components/EditNFTDescriptionModal" import { GuildPlatform } from "types" type Props = { diff --git a/src/components/[guild]/collect/components/EditNftButton.tsx b/src/components/[guild]/collect/components/EditNftButton.tsx index 285c3eabef..000e789732 100644 --- a/src/components/[guild]/collect/components/EditNftButton.tsx +++ b/src/components/[guild]/collect/components/EditNftButton.tsx @@ -1,7 +1,7 @@ import { IconButton, useDisclosure } from "@chakra-ui/react" +import { GearSix } from "@phosphor-icons/react" import { ContractCallFunction } from "components/[guild]/RolePlatforms/components/AddRoleRewardModal/components/AddContractCallPanel/components/CreateNftForm/hooks/useCreateNft" import { useThemeContext } from "components/[guild]/ThemeContext" -import { GearSix } from "phosphor-react" import EditNftModal from "rewards/ContractCall/components/EditNftModal" import { useCollectNftContext } from "./CollectNftContext" diff --git a/src/components/[guild]/collect/components/Links.tsx b/src/components/[guild]/collect/components/Links.tsx index e8c868abbb..4b74bbcea2 100644 --- a/src/components/[guild]/collect/components/Links.tsx +++ b/src/components/[guild]/collect/components/Links.tsx @@ -1,9 +1,9 @@ import { Icon, Img, Link, useColorMode, Wrap } from "@chakra-ui/react" +import { ArrowSquareOut } from "@phosphor-icons/react" import { useCollectNftContext } from "components/[guild]/collect/components/CollectNftContext" import useGuild from "components/[guild]/hooks/useGuild" import SocialIcon from "components/[guild]/SocialIcon" import Section from "components/common/Section" -import { ArrowSquareOut } from "phosphor-react" import { SocialLinkKey } from "types" import capitalize from "utils/capitalize" import { openseaBaseUrl } from "utils/guildCheckout/constants" diff --git a/src/components/[guild]/collect/components/RequirementsCard.tsx b/src/components/[guild]/collect/components/RequirementsCard.tsx index fd0f6b4c70..1eeeeaac2b 100644 --- a/src/components/[guild]/collect/components/RequirementsCard.tsx +++ b/src/components/[guild]/collect/components/RequirementsCard.tsx @@ -1,10 +1,10 @@ import { Box, Icon, Stack, useColorModeValue, useDisclosure } from "@chakra-ui/react" +import { Question } from "@phosphor-icons/react" import RoleRequirements from "components/[guild]/Requirements" import Requirement from "components/[guild]/Requirements/components/Requirement" import { RoleRequirementsSectionHeader } from "components/[guild]/RoleCard/components/RoleRequirementsSection" import Card from "components/common/Card" import CardMotionWrapper from "components/common/CardMotionWrapper" -import { Question } from "phosphor-react" import { PropsWithChildren } from "react" import { Role } from "types" diff --git a/src/components/[guild]/collect/components/ShareButton.tsx b/src/components/[guild]/collect/components/ShareButton.tsx index ee0c0e33d1..873f1bc3ab 100644 --- a/src/components/[guild]/collect/components/ShareButton.tsx +++ b/src/components/[guild]/collect/components/ShareButton.tsx @@ -6,9 +6,9 @@ import { Portal, useClipboard, } from "@chakra-ui/react" +import { CopySimple, ShareNetwork } from "@phosphor-icons/react" import { useThemeContext } from "components/[guild]/ThemeContext" import Button from "components/common/Button" -import { CopySimple, ShareNetwork } from "phosphor-react" import XLogo from "static/icons/x.svg" type Props = { diff --git a/src/components/[guild]/crm/CrmMenu.tsx b/src/components/[guild]/crm/CrmMenu.tsx index dc033464ba..243efc397b 100644 --- a/src/components/[guild]/crm/CrmMenu.tsx +++ b/src/components/[guild]/crm/CrmMenu.tsx @@ -9,9 +9,9 @@ import { // Portal, useDisclosure, } from "@chakra-ui/react" +import { /* CaretDown, */ Export, Sliders } from "@phosphor-icons/react" import { Table } from "@tanstack/react-table" import Button from "components/common/Button" -import { /* CaretDown, */ Export, Sliders } from "phosphor-react" import { useIsTabsStuck } from "../Tabs/Tabs" import { useThemeContext } from "../ThemeContext" import CustomizeViewModal from "./CustomizeViewModal" diff --git a/src/components/[guild]/crm/CustomizeViewModal.tsx b/src/components/[guild]/crm/CustomizeViewModal.tsx index 119c08d966..7fbeeaef1f 100644 --- a/src/components/[guild]/crm/CustomizeViewModal.tsx +++ b/src/components/[guild]/crm/CustomizeViewModal.tsx @@ -10,10 +10,10 @@ import { Stack, useColorModeValue, } from "@chakra-ui/react" +import { DotsSixVertical } from "@phosphor-icons/react" import { Column, Table } from "@tanstack/react-table" import { Modal } from "components/common/Modal" import { Reorder } from "framer-motion" -import { DotsSixVertical } from "phosphor-react" import { useState } from "react" import { Member } from "./useMembers" diff --git a/src/components/[guild]/crm/ExportMembers/ExportCard/ExportCard.tsx b/src/components/[guild]/crm/ExportMembers/ExportCard/ExportCard.tsx index f8613f71a2..965d137e66 100644 --- a/src/components/[guild]/crm/ExportMembers/ExportCard/ExportCard.tsx +++ b/src/components/[guild]/crm/ExportMembers/ExportCard/ExportCard.tsx @@ -7,6 +7,7 @@ import { Text, Tooltip, } from "@chakra-ui/react" +import { Download } from "@phosphor-icons/react" import MemberCount from "components/[guild]/RoleCard/components/MemberCount" import useGuild from "components/[guild]/hooks/useGuild" import Card from "components/common/Card" @@ -14,7 +15,6 @@ import CardMotionWrapper from "components/common/CardMotionWrapper" import useShowErrorToast from "hooks/useShowErrorToast" import { useSubmitWithSign } from "hooks/useSubmit" import { atom, useAtom } from "jotai" -import { Download } from "phosphor-react" import fetcher from "utils/fetcher" import formatRelativeTimeFromNow from "utils/formatRelativeTimeFromNow" import { ExportData } from "../useExports" diff --git a/src/components/[guild]/crm/ExportMembers/ExportCard/ExportParamsTags.tsx b/src/components/[guild]/crm/ExportMembers/ExportCard/ExportParamsTags.tsx index 331daf8675..12f5603b05 100644 --- a/src/components/[guild]/crm/ExportMembers/ExportCard/ExportParamsTags.tsx +++ b/src/components/[guild]/crm/ExportMembers/ExportCard/ExportParamsTags.tsx @@ -1,7 +1,7 @@ import { Tag, TagLeftIcon, Tooltip, Wrap } from "@chakra-ui/react" +import { SortAscending, SortDescending } from "@phosphor-icons/react" import RoleTag from "components/[guild]/RoleTag" import useGuild from "components/[guild]/hooks/useGuild" -import { SortAscending, SortDescending } from "phosphor-react" import MagnifyingGlassX from "static/icons/magnifying-glass-x.svg" import capitalize from "utils/capitalize" import { ExportData, crmOrderByParams } from "../useExports" diff --git a/src/components/[guild]/crm/ExportMembers/ExportMembersModal.tsx b/src/components/[guild]/crm/ExportMembers/ExportMembersModal.tsx index 24f05431b8..5df7ee34fc 100644 --- a/src/components/[guild]/crm/ExportMembers/ExportMembersModal.tsx +++ b/src/components/[guild]/crm/ExportMembers/ExportMembersModal.tsx @@ -9,10 +9,10 @@ import { Stack, Text, } from "@chakra-ui/react" +import { ArchiveBox } from "@phosphor-icons/react" import Button from "components/common/Button" import { Modal } from "components/common/Modal" import { SectionTitle } from "components/common/Section" -import { ArchiveBox } from "phosphor-react" import ExportCard from "./ExportCard" import useExportMembers from "./useExportMembers" import useExports from "./useExports" diff --git a/src/components/[guild]/crm/FilterByRoles/FilterByRoles.tsx b/src/components/[guild]/crm/FilterByRoles/FilterByRoles.tsx index ef1e0c43da..0a29d88489 100644 --- a/src/components/[guild]/crm/FilterByRoles/FilterByRoles.tsx +++ b/src/components/[guild]/crm/FilterByRoles/FilterByRoles.tsx @@ -19,8 +19,8 @@ import { useColorMode, useColorModeValue, } from "@chakra-ui/react" +import { Funnel } from "@phosphor-icons/react" import { MemberCountWithSyncIndicator } from "components/[guild]/RoleCard/components/MemberCount" -import { Funnel } from "phosphor-react" import { memo, useState } from "react" import { Role } from "types" import useGuild from "../../hooks/useGuild" diff --git a/src/components/[guild]/crm/FilterByRoles/components/AddAndEditHiddenRoles.tsx b/src/components/[guild]/crm/FilterByRoles/components/AddAndEditHiddenRoles.tsx index 2baee071a8..ef06ffea07 100644 --- a/src/components/[guild]/crm/FilterByRoles/components/AddAndEditHiddenRoles.tsx +++ b/src/components/[guild]/crm/FilterByRoles/components/AddAndEditHiddenRoles.tsx @@ -6,9 +6,9 @@ import { MenuButton, MenuList, } from "@chakra-ui/react" +import { CaretDown, PencilSimple } from "@phosphor-icons/react" import useGuild from "components/[guild]/hooks/useGuild" import LinkMenuItem from "components/common/LinkMenuItem" -import { CaretDown, PencilSimple } from "phosphor-react" import AddHiddenRoleButton from "./AddHiddenRoleButton" const AddAndEditHiddenRoles = () => { diff --git a/src/components/[guild]/crm/FilterByRoles/components/AddHiddenRoleButton.tsx b/src/components/[guild]/crm/FilterByRoles/components/AddHiddenRoleButton.tsx index 8ed2153506..ab3d91193a 100644 --- a/src/components/[guild]/crm/FilterByRoles/components/AddHiddenRoleButton.tsx +++ b/src/components/[guild]/crm/FilterByRoles/components/AddHiddenRoleButton.tsx @@ -10,6 +10,7 @@ import { ModalOverlay, useDisclosure, } from "@chakra-ui/react" +import { Plus } from "@phosphor-icons/react" import useGuild from "components/[guild]/hooks/useGuild" import Button from "components/common/Button" import DiscardAlert from "components/common/DiscardAlert" @@ -18,7 +19,6 @@ import IconSelector from "components/create-guild/IconSelector" import Name from "components/create-guild/Name" import usePinata from "hooks/usePinata" import useSubmitWithUpload from "hooks/useSubmitWithUpload" -import { Plus } from "phosphor-react" import { FormProvider, useForm, useWatch } from "react-hook-form" import getRandomInt from "utils/getRandomInt" import SetHiddenRoleRequirements from "./SetHiddenRoleRequirements" diff --git a/src/components/[guild]/crm/FilterByRoles/components/FilterByRolesSearch.tsx b/src/components/[guild]/crm/FilterByRoles/components/FilterByRolesSearch.tsx index 76a3323ad1..f0765d20e3 100644 --- a/src/components/[guild]/crm/FilterByRoles/components/FilterByRolesSearch.tsx +++ b/src/components/[guild]/crm/FilterByRoles/components/FilterByRolesSearch.tsx @@ -6,7 +6,7 @@ import { InputLeftElement, InputRightElement, } from "@chakra-ui/react" -import { MagnifyingGlass } from "phosphor-react" +import { MagnifyingGlass } from "@phosphor-icons/react" import { Dispatch, SetStateAction, useRef } from "react" type Props = { diff --git a/src/components/[guild]/crm/Identities.tsx b/src/components/[guild]/crm/Identities.tsx index 27a65bf731..1d601e3299 100644 --- a/src/components/[guild]/crm/Identities.tsx +++ b/src/components/[guild]/crm/Identities.tsx @@ -6,10 +6,10 @@ import { TagProps, Tooltip, } from "@chakra-ui/react" +import { LockSimple, Wallet } from "@phosphor-icons/react" import { useCardBg } from "components/common/Card" -import { LockSimple, Wallet } from "phosphor-react" -import rewards from "rewards" import { PropsWithChildren, memo } from "react" +import rewards from "rewards" import { PlatformAccountDetails, PlatformType, Rest } from "types" import shortenHex from "utils/shortenHex" import { Member } from "./useMembers" diff --git a/src/components/[guild]/crm/IdentitiesExpansionToggle.tsx b/src/components/[guild]/crm/IdentitiesExpansionToggle.tsx index 3eead8bc17..33387f3a38 100644 --- a/src/components/[guild]/crm/IdentitiesExpansionToggle.tsx +++ b/src/components/[guild]/crm/IdentitiesExpansionToggle.tsx @@ -1,6 +1,9 @@ import { IconButton } from "@chakra-ui/react" +import { + ArrowsInLineHorizontal, + ArrowsOutLineHorizontal, +} from "@phosphor-icons/react" import useLocalStorage from "hooks/useLocalStorage" -import { ArrowsInLineHorizontal, ArrowsOutLineHorizontal } from "phosphor-react" export const IDENTITIES_COLLAPSED_STYLE = `.identityTd .identityTag:not(:first-child) {margin-left: var(--stacked-margin-left)}` diff --git a/src/components/[guild]/crm/IdentitiesSearch.tsx b/src/components/[guild]/crm/IdentitiesSearch.tsx index cda1e2c140..932e4240c0 100644 --- a/src/components/[guild]/crm/IdentitiesSearch.tsx +++ b/src/components/[guild]/crm/IdentitiesSearch.tsx @@ -6,9 +6,9 @@ import { InputLeftElement, InputRightElement, } from "@chakra-ui/react" +import { MagnifyingGlass } from "@phosphor-icons/react" import { Column } from "@tanstack/react-table" import useDebouncedState from "hooks/useDebouncedState" -import { MagnifyingGlass } from "phosphor-react" import { useEffect, useRef, useState } from "react" type Props = { diff --git a/src/components/[guild]/crm/OrderByColumn.tsx b/src/components/[guild]/crm/OrderByColumn.tsx index 8eefe85bdf..3938d8f3aa 100644 --- a/src/components/[guild]/crm/OrderByColumn.tsx +++ b/src/components/[guild]/crm/OrderByColumn.tsx @@ -13,8 +13,8 @@ import { Stack, Text, } from "@chakra-ui/react" +import { SortAscending, SortDescending, TrashSimple } from "@phosphor-icons/react" import { Column } from "@tanstack/react-table" -import { SortAscending, SortDescending, TrashSimple } from "phosphor-react" import capitalize from "utils/capitalize" type Props = { diff --git a/src/components/[guild]/crm/RoleTags.tsx b/src/components/[guild]/crm/RoleTags.tsx index 12e13ebe6a..d6cf04f8d6 100644 --- a/src/components/[guild]/crm/RoleTags.tsx +++ b/src/components/[guild]/crm/RoleTags.tsx @@ -15,8 +15,8 @@ import { useColorModeValue, Wrap, } from "@chakra-ui/react" +import { Funnel } from "@phosphor-icons/react" import Button from "components/common/Button" -import { Funnel } from "phosphor-react" import { memo } from "react" import { Role } from "types" import pluralize from "utils/pluralize" diff --git a/src/components/[guild]/forms/FormNoAccess.tsx b/src/components/[guild]/forms/FormNoAccess.tsx index 38b6a28257..e69bde6694 100644 --- a/src/components/[guild]/forms/FormNoAccess.tsx +++ b/src/components/[guild]/forms/FormNoAccess.tsx @@ -7,10 +7,10 @@ import { useBreakpointValue, useColorModeValue, } from "@chakra-ui/react" +import { Lock } from "@phosphor-icons/react" import Button from "components/common/Button" import Card from "components/common/Card" import ClientOnly from "components/common/ClientOnly" -import { Lock } from "phosphor-react" import { useOpenJoinModal } from "../JoinModal/JoinModalProvider" import RecheckAccessesButton from "../RecheckAccessesButton" diff --git a/src/components/[guild]/forms/SuccessfullySubmittedForm.tsx b/src/components/[guild]/forms/SuccessfullySubmittedForm.tsx index 30f389fd4f..1a04092281 100644 --- a/src/components/[guild]/forms/SuccessfullySubmittedForm.tsx +++ b/src/components/[guild]/forms/SuccessfullySubmittedForm.tsx @@ -1,8 +1,8 @@ import { Icon, Text, VStack, useColorModeValue } from "@chakra-ui/react" +import { ArrowRight, CheckCircle } from "@phosphor-icons/react" import Button from "components/common/Button" import Card from "components/common/Card" import Link from "next/link" -import { ArrowRight, CheckCircle } from "phosphor-react" import useGuild from "../hooks/useGuild" const SuccessfullySubmittedForm = () => { diff --git a/src/components/[guild]/forms/responses/CollapsibleIdentityTags.tsx b/src/components/[guild]/forms/responses/CollapsibleIdentityTags.tsx index ffca159d3e..5ccf5a8820 100644 --- a/src/components/[guild]/forms/responses/CollapsibleIdentityTags.tsx +++ b/src/components/[guild]/forms/responses/CollapsibleIdentityTags.tsx @@ -1,10 +1,10 @@ import { Center, Collapse, Icon, IconButton } from "@chakra-ui/react" +import { CaretDown } from "@phosphor-icons/react" import { WalletTag } from "components/[guild]/crm/Identities" import UserPlatformTags from "components/[guild]/crm/UserPlatformTags" import useGuild from "components/[guild]/hooks/useGuild" import { LinkButton } from "components/common/LinkMenuItem" import useResolveAddress from "hooks/useResolveAddress" -import { CaretDown } from "phosphor-react" import { useState } from "react" import shortenHex from "utils/shortenHex" diff --git a/src/components/[guild]/forms/responses/ResponseModal.tsx b/src/components/[guild]/forms/responses/ResponseModal.tsx index 878ba854dd..78dcb30dc3 100644 --- a/src/components/[guild]/forms/responses/ResponseModal.tsx +++ b/src/components/[guild]/forms/responses/ResponseModal.tsx @@ -15,6 +15,7 @@ import { Text, useColorModeValue, } from "@chakra-ui/react" +import { CaretLeft, CaretRight } from "@phosphor-icons/react" import { Row } from "@tanstack/react-table" import FormFieldTitle from "components/[guild]/CreateFormModal/components/FormCardEditable/components/FormFieldTitle" import { fieldTypes } from "components/[guild]/CreateFormModal/formConfig" @@ -22,7 +23,6 @@ import { useGuildForm } from "components/[guild]/hooks/useGuildForms" import Button from "components/common/Button" import GuildAvatar from "components/common/GuildAvatar" import { Modal } from "components/common/Modal" -import { CaretLeft, CaretRight } from "phosphor-react" import { FormSubmission } from "rewards/Forms/hooks/useFormSubmissions" import CollapsibleIdentityTags from "./CollapsibleIdentityTags" diff --git a/src/components/[guild]/leaderboard/LeaderboardAirdropFallbackCard.tsx b/src/components/[guild]/leaderboard/LeaderboardAirdropFallbackCard.tsx index 9ff40d289b..7e040f5b9f 100644 --- a/src/components/[guild]/leaderboard/LeaderboardAirdropFallbackCard.tsx +++ b/src/components/[guild]/leaderboard/LeaderboardAirdropFallbackCard.tsx @@ -1,11 +1,11 @@ import { Center, Collapse, Img, useColorModeValue } from "@chakra-ui/react" +import { SignIn, X } from "@phosphor-icons/react" import { walletSelectorModalAtom } from "components/_app/Web3ConnectionManager/components/WalletSelectorModal" import ActionCard from "components/common/ActionCard" import Button from "components/common/Button" import { LinkButton } from "components/common/LinkMenuItem" import useToast from "hooks/useToast" import { atom, useAtom, useSetAtom } from "jotai" -import { SignIn, X } from "phosphor-react" import { useAccount } from "wagmi" import useMembershipUpdate from "../JoinModal/hooks/useMembershipUpdate" import useGuild from "../hooks/useGuild" diff --git a/src/components/[guild]/leaderboard/LeaderboardPointsSelector.tsx b/src/components/[guild]/leaderboard/LeaderboardPointsSelector.tsx index d2eab8337d..c9f7c1a804 100644 --- a/src/components/[guild]/leaderboard/LeaderboardPointsSelector.tsx +++ b/src/components/[guild]/leaderboard/LeaderboardPointsSelector.tsx @@ -9,11 +9,11 @@ import { MenuList, Portal, } from "@chakra-ui/react" +import { CaretDown } from "@phosphor-icons/react" import Button from "components/common/Button" import Card from "components/common/Card" import Link from "next/link" import { useRouter } from "next/router" -import { CaretDown } from "phosphor-react" import Star from "static/icons/star.svg" import { useAccessedGuildPoints } from "../AccessHub/hooks/useAccessedGuildPoints" import useGuild from "../hooks/useGuild" diff --git a/src/components/[guild]/leaderboard/LeaderboardUserCard.tsx b/src/components/[guild]/leaderboard/LeaderboardUserCard.tsx index e39afb8add..cf57b55446 100644 --- a/src/components/[guild]/leaderboard/LeaderboardUserCard.tsx +++ b/src/components/[guild]/leaderboard/LeaderboardUserCard.tsx @@ -11,11 +11,11 @@ import { useColorModeValue, VStack, } from "@chakra-ui/react" +import { Trophy } from "@phosphor-icons/react" import Card from "components/common/Card" import GuildAvatar from "components/common/GuildAvatar" import useResolveAddress from "hooks/useResolveAddress" import { useRouter } from "next/router" -import { Trophy } from "phosphor-react" import shortenHex from "utils/shortenHex" import useGuildPlatform from "../hooks/useGuildPlatform" diff --git a/src/components/[guild]/leaderboard/RecalculateLeaderboardButton.tsx b/src/components/[guild]/leaderboard/RecalculateLeaderboardButton.tsx index 0af7450811..59c7115290 100644 --- a/src/components/[guild]/leaderboard/RecalculateLeaderboardButton.tsx +++ b/src/components/[guild]/leaderboard/RecalculateLeaderboardButton.tsx @@ -1,9 +1,9 @@ import { IconButton, Tooltip } from "@chakra-ui/react" +import { ArrowsClockwise } from "@phosphor-icons/react" import Button from "components/common/Button" import useSWRWithOptionalAuth from "hooks/useSWRWithOptionalAuth" import useShowErrorToast from "hooks/useShowErrorToast" import { useRouter } from "next/router" -import { ArrowsClockwise } from "phosphor-react" import { useState } from "react" import useGuild from "../hooks/useGuild" import usePointsLeaderboard, { diff --git a/src/components/[guild]/leaderboard/Snapshots/SnapshotTable.tsx b/src/components/[guild]/leaderboard/Snapshots/SnapshotTable.tsx index 18e9905314..5426f78043 100644 --- a/src/components/[guild]/leaderboard/Snapshots/SnapshotTable.tsx +++ b/src/components/[guild]/leaderboard/Snapshots/SnapshotTable.tsx @@ -16,10 +16,10 @@ import { Tr, useColorModeValue, } from "@chakra-ui/react" +import { MagnifyingGlass } from "@phosphor-icons/react" import { useVirtualizer } from "@tanstack/react-virtual" import CopyableAddress from "components/common/CopyableAddress" import useDebouncedState from "hooks/useDebouncedState" -import { MagnifyingGlass } from "phosphor-react" import { useMemo, useRef, useState } from "react" type Props = { diff --git a/src/components/[guild]/messages/Message.tsx b/src/components/[guild]/messages/Message.tsx index da15098e93..fd39a0f59b 100644 --- a/src/components/[guild]/messages/Message.tsx +++ b/src/components/[guild]/messages/Message.tsx @@ -25,9 +25,9 @@ import { useColorModeValue, useDisclosure, } from "@chakra-ui/react" +import { Check, Question, Users } from "@phosphor-icons/react" import Card from "components/common/Card" import { Modal } from "components/common/Modal" -import { Check, Question, Users } from "phosphor-react" import RoleTag from "../RoleTag" import useGuild from "../hooks/useGuild" import { Message as MessageType } from "./hooks/useGuildMessages" diff --git a/src/components/[guild]/messages/NoMessages.tsx b/src/components/[guild]/messages/NoMessages.tsx index d443b9de91..706cc22a61 100644 --- a/src/components/[guild]/messages/NoMessages.tsx +++ b/src/components/[guild]/messages/NoMessages.tsx @@ -1,7 +1,7 @@ import { Link } from "@chakra-ui/next-js" import { HStack, Icon, Img, Stack, Text } from "@chakra-ui/react" +import { ArrowSquareOut } from "@phosphor-icons/react" import Card from "components/common/Card" -import { ArrowSquareOut } from "phosphor-react" import SendNewMessage from "./SendNewMessage" const NoMessages = () => ( diff --git a/src/components/[guild]/messages/SendNewMessage/SendNewMessage.tsx b/src/components/[guild]/messages/SendNewMessage/SendNewMessage.tsx index 5f6d4a37f8..c65ed10349 100644 --- a/src/components/[guild]/messages/SendNewMessage/SendNewMessage.tsx +++ b/src/components/[guild]/messages/SendNewMessage/SendNewMessage.tsx @@ -17,13 +17,13 @@ import { useColorModeValue, useDisclosure, } from "@chakra-ui/react" +import { Chat, PaperPlaneRight } from "@phosphor-icons/react" import { useIsTabsStuck } from "components/[guild]/Tabs" import { useThemeContext } from "components/[guild]/ThemeContext" import Button from "components/common/Button" import FormErrorMessage from "components/common/FormErrorMessage" import { Modal } from "components/common/Modal" import dynamic from "next/dynamic" -import { Chat, PaperPlaneRight } from "phosphor-react" import { FormProvider, useForm, useWatch } from "react-hook-form" import { DAY_IN_MS } from "utils/formatRelativeTimeFromNow" import useGuildMessages from "../hooks/useGuildMessages" diff --git a/src/components/_app/InfoBanner.tsx b/src/components/_app/InfoBanner.tsx index 7549d26119..05fab35348 100644 --- a/src/components/_app/InfoBanner.tsx +++ b/src/components/_app/InfoBanner.tsx @@ -1,6 +1,6 @@ import { Alert, AlertIcon, HStack, IconButton, Text } from "@chakra-ui/react" +import { X } from "@phosphor-icons/react" import { useRouter } from "next/router" -import { X } from "phosphor-react" import { PropsWithChildren } from "react" const IGNORED_PATHS = ["/", "/oauth", "/oauth-result"] diff --git a/src/components/_app/Web3ConnectionManager/components/PlatformMergeErrorAlert.tsx b/src/components/_app/Web3ConnectionManager/components/PlatformMergeErrorAlert.tsx index ee9a750adf..4a8f43f2fc 100644 --- a/src/components/_app/Web3ConnectionManager/components/PlatformMergeErrorAlert.tsx +++ b/src/components/_app/Web3ConnectionManager/components/PlatformMergeErrorAlert.tsx @@ -12,15 +12,15 @@ import { UnorderedList, chakra, } from "@chakra-ui/react" +import { ArrowSquareOut } from "@phosphor-icons/react" import useConnectPlatform from "components/[guild]/JoinModal/hooks/useConnectPlatform" import Button from "components/common/Button" import CopyableAddress from "components/common/CopyableAddress" import { Alert } from "components/common/Modal" import useToast from "hooks/useToast" import { atom, useAtom } from "jotai" -import { ArrowSquareOut } from "phosphor-react" -import rewards from "rewards" import { useRef } from "react" +import rewards from "rewards" import { PlatformName } from "types" import capitalize from "utils/capitalize" import shortenHex from "utils/shortenHex" diff --git a/src/components/_app/Web3ConnectionManager/components/WalletLinkHelperModal.tsx b/src/components/_app/Web3ConnectionManager/components/WalletLinkHelperModal.tsx index 2b9b838726..a24abfcb64 100644 --- a/src/components/_app/Web3ConnectionManager/components/WalletLinkHelperModal.tsx +++ b/src/components/_app/Web3ConnectionManager/components/WalletLinkHelperModal.tsx @@ -7,11 +7,11 @@ import { ModalOverlay, Text, } from "@chakra-ui/react" +import { SignOut } from "@phosphor-icons/react" import LogicDivider from "components/[guild]/LogicDivider" import Button from "components/common/Button" import { Modal } from "components/common/Modal" import { atom, useAtom } from "jotai" -import { SignOut } from "phosphor-react" export const walletLinkHelperModalAtom = atom(false) diff --git a/src/components/_app/Web3ConnectionManager/components/WalletSelectorModal/WalletSelectorModal.tsx b/src/components/_app/Web3ConnectionManager/components/WalletSelectorModal/WalletSelectorModal.tsx index c36ea236bb..4a971ba725 100644 --- a/src/components/_app/Web3ConnectionManager/components/WalletSelectorModal/WalletSelectorModal.tsx +++ b/src/components/_app/Web3ConnectionManager/components/WalletSelectorModal/WalletSelectorModal.tsx @@ -14,6 +14,7 @@ import { } from "@chakra-ui/react" import { Link } from "@chakra-ui/next-js" +import { ArrowLeft, ArrowSquareOut } from "@phosphor-icons/react" import { useUserPublic } from "components/[guild]/hooks/useUser" import { usePostHogContext } from "components/_app/PostHogProvider" import CardMotionWrapper from "components/common/CardMotionWrapper" @@ -24,7 +25,6 @@ import ModalButton from "components/common/ModalButton" import useSetKeyPair from "hooks/useSetKeyPair" import useShowErrorToast from "hooks/useShowErrorToast" import { useAtom, useSetAtom } from "jotai" -import { ArrowLeft, ArrowSquareOut } from "phosphor-react" import { useEffect } from "react" import { useAccount, useConnect, type Connector } from "wagmi" import useWeb3ConnectionManager from "../../hooks/useWeb3ConnectionManager" diff --git a/src/components/_app/Web3ConnectionManager/components/WalletSelectorModal/components/ConnectorButton.tsx b/src/components/_app/Web3ConnectionManager/components/WalletSelectorModal/components/ConnectorButton.tsx index 33d9a6242d..2236775264 100644 --- a/src/components/_app/Web3ConnectionManager/components/WalletSelectorModal/components/ConnectorButton.tsx +++ b/src/components/_app/Web3ConnectionManager/components/WalletSelectorModal/components/ConnectorButton.tsx @@ -1,10 +1,10 @@ import { ButtonProps, Center, Icon, Img } from "@chakra-ui/react" +import { Wallet } from "@phosphor-icons/react" import { useUserPublic } from "components/[guild]/hooks/useUser" import useConnectorNameAndIcon from "components/_app/Web3ConnectionManager/hooks/useConnectorNameAndIcon" import Button from "components/common/Button" import { addressLinkParamsAtom } from "components/common/Layout/components/Account/components/AccountModal/components/LinkAddressButton" import { useAtomValue, useSetAtom } from "jotai" -import { Wallet } from "phosphor-react" import { useAccount, type Connector } from "wagmi" import { walletLinkHelperModalAtom } from "../../WalletLinkHelperModal" import { COINBASE_WALLET_SDK_ID } from "../WalletSelectorModal" diff --git a/src/components/_app/Web3ConnectionManager/components/WalletSelectorModal/components/GoogleLoginButton/components/ExportWaaSModal.tsx b/src/components/_app/Web3ConnectionManager/components/WalletSelectorModal/components/GoogleLoginButton/components/ExportWaaSModal.tsx index 6f9fc2e9c0..20d0284011 100644 --- a/src/components/_app/Web3ConnectionManager/components/WalletSelectorModal/components/GoogleLoginButton/components/ExportWaaSModal.tsx +++ b/src/components/_app/Web3ConnectionManager/components/WalletSelectorModal/components/GoogleLoginButton/components/ExportWaaSModal.tsx @@ -18,13 +18,13 @@ import { } from "@chakra-ui/react" import type { RawPrivateKey, Waas } from "@coinbase/waas-sdk-web" // eslint-disable-next-line import/no-extraneous-dependencies +import { Check, Copy, Wallet } from "@phosphor-icons/react" import { usePostHogContext } from "components/_app/PostHogProvider" import Button from "components/common/Button" import { Modal } from "components/common/Modal" import ConfirmationAlert from "components/create-guild/Requirements/components/ConfirmationAlert" import useSubmit from "hooks/useSubmit" import useToast from "hooks/useToast" -import { Check, Copy, Wallet } from "phosphor-react" import { useState } from "react" import fetcher from "utils/fetcher" import { useConnect } from "wagmi" diff --git a/src/components/analytics/MembersChart/components/MembersChartTooltip.tsx b/src/components/analytics/MembersChart/components/MembersChartTooltip.tsx index ab0f7e1515..6f335c297c 100644 --- a/src/components/analytics/MembersChart/components/MembersChartTooltip.tsx +++ b/src/components/analytics/MembersChart/components/MembersChartTooltip.tsx @@ -8,10 +8,10 @@ import { TagLeftIcon, Text, } from "@chakra-ui/react" +import { Users } from "@phosphor-icons/react" import { Tooltip, TooltipDatum } from "@visx/xychart" import useGuild from "components/[guild]/hooks/useGuild" import Card, { useCardBg } from "components/common/Card" -import { Users } from "phosphor-react" import { PropsWithChildren } from "react" import { MemberCountData, MembersChartAccessors } from "../MembersChart" import SimpleRoleTag from "./SimpleRoleTag" diff --git a/src/components/common/AddCard.tsx b/src/components/common/AddCard.tsx index 753ef53d8e..9d88b0aca3 100644 --- a/src/components/common/AddCard.tsx +++ b/src/components/common/AddCard.tsx @@ -1,6 +1,6 @@ import { Link } from "@chakra-ui/next-js" import { Box, HStack, Icon, Stack, Tag, Text, useColorMode } from "@chakra-ui/react" -import { Plus } from "phosphor-react" +import { Plus } from "@phosphor-icons/react" import { FC, forwardRef } from "react" import { Rest } from "types" diff --git a/src/components/common/CheckboxColorCard.tsx b/src/components/common/CheckboxColorCard.tsx index ff8a2f46ef..84ac921773 100644 --- a/src/components/common/CheckboxColorCard.tsx +++ b/src/components/common/CheckboxColorCard.tsx @@ -11,8 +11,8 @@ import { Text, useColorModeValue, } from "@chakra-ui/react" +import { IconProps } from "@phosphor-icons/react" import ColorCard from "components/common/ColorCard" -import { IconProps } from "phosphor-react" import { PropsWithChildren, forwardRef, useState } from "react" type Props = { diff --git a/src/components/common/DataBlock.tsx b/src/components/common/DataBlock.tsx index 9b6106ad3a..2c212f6151 100644 --- a/src/components/common/DataBlock.tsx +++ b/src/components/common/DataBlock.tsx @@ -1,5 +1,5 @@ import { Icon, Skeleton, Text, Tooltip, useColorModeValue } from "@chakra-ui/react" -import { Warning } from "phosphor-react" +import { Warning } from "@phosphor-icons/react" import { PropsWithChildren } from "react" type Props = { diff --git a/src/components/common/DataBlockWithCopy.tsx b/src/components/common/DataBlockWithCopy.tsx index bd0c784dff..4b70bbef7d 100644 --- a/src/components/common/DataBlockWithCopy.tsx +++ b/src/components/common/DataBlockWithCopy.tsx @@ -1,5 +1,5 @@ import { HStack, Icon, Text, Tooltip, useClipboard } from "@chakra-ui/react" -import { Check } from "phosphor-react" +import { Check } from "@phosphor-icons/react" import { PropsWithChildren } from "react" import DataBlock from "./DataBlock" diff --git a/src/components/common/DiscordGuildSetup/components/DCServerCard.tsx b/src/components/common/DiscordGuildSetup/components/DCServerCard.tsx index 210dd33348..674643bbe3 100644 --- a/src/components/common/DiscordGuildSetup/components/DCServerCard.tsx +++ b/src/components/common/DiscordGuildSetup/components/DCServerCard.tsx @@ -1,3 +1,4 @@ +import { ArrowSquareOut } from "@phosphor-icons/react" import useGuild from "components/[guild]/hooks/useGuild" import Button from "components/common/Button" import CardMotionWrapper from "components/common/CardMotionWrapper" @@ -5,7 +6,6 @@ import OptionCard from "components/common/OptionCard" import { Gateables } from "hooks/useGateables" import useServerPermissions from "hooks/useServerPermissions" import Link from "next/link" -import { ArrowSquareOut } from "phosphor-react" import { PlatformType } from "types" type Props = { diff --git a/src/components/common/GoogleGuildSetup/GoogleGuildSetup.tsx b/src/components/common/GoogleGuildSetup/GoogleGuildSetup.tsx index 620a87f2df..8e9856dfe3 100644 --- a/src/components/common/GoogleGuildSetup/GoogleGuildSetup.tsx +++ b/src/components/common/GoogleGuildSetup/GoogleGuildSetup.tsx @@ -1,4 +1,3 @@ -import { env } from "env" import { ButtonGroup, GridItem, @@ -14,12 +13,13 @@ import { useClipboard, useDisclosure, } from "@chakra-ui/react" +import { Check, CopySimple, PencilSimple } from "@phosphor-icons/react" import useUser from "components/[guild]/hooks/useUser" import Button from "components/common/Button" +import { env } from "env" import { AnimatePresence } from "framer-motion" import useGateables from "hooks/useGateables" import { useSetAtom } from "jotai" -import { Check, CopySimple, PencilSimple } from "phosphor-react" import { useEffect, useState } from "react" import { useFormContext, useWatch } from "react-hook-form" import { PlatformType } from "types" diff --git a/src/components/common/Layout/components/Account/Account.tsx b/src/components/common/Layout/components/Account/Account.tsx index f20147ed3b..9e23025bf3 100644 --- a/src/components/common/Layout/components/Account/Account.tsx +++ b/src/components/common/Layout/components/Account/Account.tsx @@ -1,11 +1,11 @@ import { ButtonGroup, Divider, HStack, Text, VStack } from "@chakra-ui/react" +import { SignIn } from "@phosphor-icons/react" import useUser from "components/[guild]/hooks/useUser" import { walletSelectorModalAtom } from "components/_app/Web3ConnectionManager/components/WalletSelectorModal" import useWeb3ConnectionManager from "components/_app/Web3ConnectionManager/hooks/useWeb3ConnectionManager" import GuildAvatar from "components/common/GuildAvatar" import useResolveAddress from "hooks/useResolveAddress" import { useSetAtom } from "jotai" -import { SignIn } from "phosphor-react" import shortenHex from "utils/shortenHex" import AccountButton from "./components/AccountButton" import { accountModalAtom } from "./components/AccountModal" diff --git a/src/components/common/Layout/components/Account/components/AccountModal/AccountModal.tsx b/src/components/common/Layout/components/Account/components/AccountModal/AccountModal.tsx index 11ce6fd479..827f31cd37 100644 --- a/src/components/common/Layout/components/Account/components/AccountModal/AccountModal.tsx +++ b/src/components/common/Layout/components/Account/components/AccountModal/AccountModal.tsx @@ -17,6 +17,7 @@ import { useColorModeValue, useDisclosure, } from "@chakra-ui/react" +import { LinkBreak, SignOut } from "@phosphor-icons/react" import useUser, { useUserPublic } from "components/[guild]/hooks/useUser" import { usePostHogContext } from "components/_app/PostHogProvider" import useConnectorNameAndIcon from "components/_app/Web3ConnectionManager/hooks/useConnectorNameAndIcon" @@ -28,7 +29,6 @@ import { Modal } from "components/common/Modal" import useResolveAddress from "hooks/useResolveAddress" import { deleteKeyPairFromIdb } from "hooks/useSetKeyPair" import { useAtom } from "jotai" -import { LinkBreak, SignOut } from "phosphor-react" import { useAccount } from "wagmi" import { CHAIN_CONFIG, Chains } from "wagmiConfig/chains" import { accountModalAtom } from "." diff --git a/src/components/common/Layout/components/Account/components/AccountModal/components/AccountConnections.tsx b/src/components/common/Layout/components/Account/components/AccountModal/components/AccountConnections.tsx index a7b05b1de2..2a339bf0d8 100644 --- a/src/components/common/Layout/components/Account/components/AccountModal/components/AccountConnections.tsx +++ b/src/components/common/Layout/components/Account/components/AccountModal/components/AccountConnections.tsx @@ -15,11 +15,11 @@ import { Text, useColorModeValue, } from "@chakra-ui/react" +import { Question } from "@phosphor-icons/react" import useUser from "components/[guild]/hooks/useUser" import { SectionProps } from "components/common/Section" -import { Question } from "phosphor-react" -import rewards from "rewards" import { PropsWithChildren, useMemo } from "react" +import rewards from "rewards" import { PlatformName } from "types" import useDelegateVaults from "../../delegate/useDelegateVaults" import LinkAddressButton from "./LinkAddressButton" diff --git a/src/components/common/Layout/components/Account/components/AccountModal/components/LinkAddressButton.tsx b/src/components/common/Layout/components/Account/components/AccountModal/components/LinkAddressButton.tsx index 339a19b717..f0a8d21a7e 100644 --- a/src/components/common/Layout/components/Account/components/AccountModal/components/LinkAddressButton.tsx +++ b/src/components/common/Layout/components/Account/components/AccountModal/components/LinkAddressButton.tsx @@ -1,9 +1,9 @@ +import { Plus } from "@phosphor-icons/react" import useUser from "components/[guild]/hooks/useUser" import { walletSelectorModalAtom } from "components/_app/Web3ConnectionManager/components/WalletSelectorModal" import useWeb3ConnectionManager from "components/_app/Web3ConnectionManager/hooks/useWeb3ConnectionManager" import Button from "components/common/Button" import { atom, useSetAtom } from "jotai" -import { Plus } from "phosphor-react" export type AddressLinkParams = { userId?: number diff --git a/src/components/common/Layout/components/Account/components/AccountModal/components/LinkedAddress.tsx b/src/components/common/Layout/components/Account/components/AccountModal/components/LinkedAddress.tsx index 55df2fe794..7c493da196 100644 --- a/src/components/common/Layout/components/Account/components/AccountModal/components/LinkedAddress.tsx +++ b/src/components/common/Layout/components/Account/components/AccountModal/components/LinkedAddress.tsx @@ -21,13 +21,13 @@ import { useColorModeValue, useDisclosure, } from "@chakra-ui/react" +import { DotsThree, LinkBreak, UserSwitch } from "@phosphor-icons/react" import useWeb3ConnectionManager from "components/_app/Web3ConnectionManager/hooks/useWeb3ConnectionManager" import Button from "components/common/Button" import CopyableAddress from "components/common/CopyableAddress" import GuildAvatar from "components/common/GuildAvatar" import { Alert } from "components/common/Modal" import Image from "next/image" -import { DotsThree, LinkBreak, UserSwitch } from "phosphor-react" import { useRef } from "react" import { User } from "types" import shortenHex from "utils/shortenHex" diff --git a/src/components/common/Layout/components/Account/components/AccountModal/components/SharedSocials.tsx b/src/components/common/Layout/components/Account/components/AccountModal/components/SharedSocials.tsx index 99dc14f70a..bc60a61f94 100644 --- a/src/components/common/Layout/components/Account/components/AccountModal/components/SharedSocials.tsx +++ b/src/components/common/Layout/components/Account/components/AccountModal/components/SharedSocials.tsx @@ -20,18 +20,18 @@ import { Text, useDisclosure, } from "@chakra-ui/react" -import useGuild, { useSimpleGuild } from "components/[guild]/hooks/useGuild" -import useUser from "components/[guild]/hooks/useUser" -import Button from "components/common/Button" -import GuildLogo from "components/common/GuildLogo" -import { Modal } from "components/common/Modal" import { ArrowSquareOut, CaretDown, Check, Shield, ShieldCheck, -} from "phosphor-react" +} from "@phosphor-icons/react" +import useGuild, { useSimpleGuild } from "components/[guild]/hooks/useGuild" +import useUser from "components/[guild]/hooks/useUser" +import Button from "components/common/Button" +import GuildLogo from "components/common/GuildLogo" +import { Modal } from "components/common/Modal" import { useEffect, useRef } from "react" import pluralize from "utils/pluralize" import useEditSharedSocials from "../hooks/useEditSharedSocials" diff --git a/src/components/common/Layout/components/Account/components/AccountModal/components/SocialAccount/EmailAddress.tsx b/src/components/common/Layout/components/Account/components/AccountModal/components/SocialAccount/EmailAddress.tsx index 502f542c7e..f1d2ce6e15 100644 --- a/src/components/common/Layout/components/Account/components/AccountModal/components/SocialAccount/EmailAddress.tsx +++ b/src/components/common/Layout/components/Account/components/AccountModal/components/SocialAccount/EmailAddress.tsx @@ -19,6 +19,7 @@ import { useDisclosure, VStack, } from "@chakra-ui/react" +import { PencilSimple } from "@phosphor-icons/react" import useUser from "components/[guild]/hooks/useUser" import { useConnectEmail } from "components/[guild]/JoinModal/hooks/useConnectPlatform" import Button from "components/common/Button" @@ -26,10 +27,9 @@ import { Error } from "components/common/Error" import { Modal } from "components/common/Modal" import { SignedValidation, useSubmitWithSign } from "hooks/useSubmit" import useToast from "hooks/useToast" -import { PencilSimple } from "phosphor-react" -import rewards from "rewards" import { useEffect, useRef, useState } from "react" import { useController, useForm, useWatch } from "react-hook-form" +import rewards from "rewards" import fetcher from "utils/fetcher" import { useDisconnectEmail } from "../../hooks/useDisconnect" import DisconnectAccountButton from "./components/DisconnectAccountButton" diff --git a/src/components/common/Layout/components/Account/components/AccountModal/components/SocialAccount/FarcasterProfile.tsx b/src/components/common/Layout/components/Account/components/AccountModal/components/SocialAccount/FarcasterProfile.tsx index 13a0d10c39..42041d15f6 100644 --- a/src/components/common/Layout/components/Account/components/AccountModal/components/SocialAccount/FarcasterProfile.tsx +++ b/src/components/common/Layout/components/Account/components/AccountModal/components/SocialAccount/FarcasterProfile.tsx @@ -22,6 +22,7 @@ import { useBreakpointValue, useDisclosure, } from "@chakra-ui/react" +import { ArrowCounterClockwise, DeviceMobileCamera } from "@phosphor-icons/react" import useUser from "components/[guild]/hooks/useUser" import { usePostHogContext } from "components/_app/PostHogProvider" import Button from "components/common/Button" @@ -29,11 +30,10 @@ import { Modal } from "components/common/Modal" import { useFetcherWithSign } from "hooks/useFetcherWithSign" import useSubmit, { SignedValidation, useSubmitWithSign } from "hooks/useSubmit" import useToast from "hooks/useToast" -import { ArrowCounterClockwise, DeviceMobileCamera } from "phosphor-react" -import rewards from "rewards" import { QRCodeSVG } from "qrcode.react" import { useCallback, useEffect, useState } from "react" import { isMobile } from "react-device-detect" +import rewards from "rewards" import { useCountdown } from "usehooks-ts" import fetcher from "utils/fetcher" import DisconnectAccountButton from "./components/DisconnectAccountButton" diff --git a/src/components/common/Layout/components/Account/components/AccountModal/components/SocialAccount/components/DisconnectAccountButton.tsx b/src/components/common/Layout/components/Account/components/AccountModal/components/SocialAccount/components/DisconnectAccountButton.tsx index 9f27936e03..0c1b29e458 100644 --- a/src/components/common/Layout/components/Account/components/AccountModal/components/SocialAccount/components/DisconnectAccountButton.tsx +++ b/src/components/common/Layout/components/Account/components/AccountModal/components/SocialAccount/components/DisconnectAccountButton.tsx @@ -9,9 +9,9 @@ import { Tooltip, useDisclosure, } from "@chakra-ui/react" +import { LinkBreak } from "@phosphor-icons/react" import Button from "components/common/Button" import { Alert } from "components/common/Modal" -import { LinkBreak } from "phosphor-react" import { useRef } from "react" import { PathString } from "react-hook-form" diff --git a/src/components/common/Layout/components/Account/components/Notifications/Notifications.tsx b/src/components/common/Layout/components/Account/components/Notifications/Notifications.tsx index 89658f49c4..d6b249fedb 100644 --- a/src/components/common/Layout/components/Account/components/Notifications/Notifications.tsx +++ b/src/components/common/Layout/components/Account/components/Notifications/Notifications.tsx @@ -9,13 +9,13 @@ import { PopoverTrigger, Stack, } from "@chakra-ui/react" +import { Bell } from "@phosphor-icons/react" import { ActivityLogProvider } from "components/[guild]/activity/ActivityLogContext" import useUser from "components/[guild]/hooks/useUser" import { usePostHogContext } from "components/_app/PostHogProvider" import useWeb3ConnectionManager from "components/_app/Web3ConnectionManager/hooks/useWeb3ConnectionManager" import useLocalStorage from "hooks/useLocalStorage" import dynamic from "next/dynamic" -import { Bell } from "phosphor-react" import AccountButton from "../AccountButton" import WebInboxSkeleton from "../Web3Inbox/WebInboxSkeleton" import NotificationsActivityLog from "./components/NotificationsActivityLog" diff --git a/src/components/common/Layout/components/Account/components/Notifications/components/NotificationsActivityLog.tsx b/src/components/common/Layout/components/Account/components/Notifications/components/NotificationsActivityLog.tsx index f5bfe1b7c3..bb3b8798ba 100644 --- a/src/components/common/Layout/components/Account/components/Notifications/components/NotificationsActivityLog.tsx +++ b/src/components/common/Layout/components/Account/components/Notifications/components/NotificationsActivityLog.tsx @@ -7,13 +7,13 @@ import { Stack, Text, } from "@chakra-ui/react" +import { ArrowRight } from "@phosphor-icons/react" import { ActivityLogActionProvider } from "components/[guild]/activity/ActivityLogAction/ActivityLogActionContext" import ActionIcon from "components/[guild]/activity/ActivityLogAction/components/ActionIcon" import ActionLabel from "components/[guild]/activity/ActivityLogAction/components/ActionLabel" import { useActivityLog } from "components/[guild]/activity/ActivityLogContext" import Button from "components/common/Button" import Link from "next/link" -import { ArrowRight } from "phosphor-react" import GhostIcon from "static/avatars/ghost.svg" const SHOWN_ACTIONS_COUNT = 3 diff --git a/src/components/common/Layout/components/Account/components/Web3Inbox/Web3Inbox.tsx b/src/components/common/Layout/components/Account/components/Web3Inbox/Web3Inbox.tsx index 40ab47095c..3ec29b4809 100644 --- a/src/components/common/Layout/components/Account/components/Web3Inbox/Web3Inbox.tsx +++ b/src/components/common/Layout/components/Account/components/Web3Inbox/Web3Inbox.tsx @@ -1,4 +1,3 @@ -import { env } from "env" import { Box, Center, @@ -17,6 +16,7 @@ import { Text, useDisclosure, } from "@chakra-ui/react" +import { ArrowRight, ArrowSquareOut } from "@phosphor-icons/react" import { initWeb3InboxClient, useNotifications, @@ -29,10 +29,10 @@ import { } from "@web3inbox/react" import Button from "components/common/Button" import { Modal } from "components/common/Modal" +import { env } from "env" import useShowErrorToast from "hooks/useShowErrorToast" import useToast from "hooks/useToast" import dynamic from "next/dynamic" -import { ArrowRight, ArrowSquareOut } from "phosphor-react" import { useRef, useState } from "react" import { useAccount, useSignMessage } from "wagmi" import WebInboxSkeleton from "./WebInboxSkeleton" diff --git a/src/components/common/Layout/components/Account/components/Web3Inbox/Web3InboxMessage.tsx b/src/components/common/Layout/components/Account/components/Web3Inbox/Web3InboxMessage.tsx index d765e2ae4f..e55b1d09c1 100644 --- a/src/components/common/Layout/components/Account/components/Web3Inbox/Web3InboxMessage.tsx +++ b/src/components/common/Layout/components/Account/components/Web3Inbox/Web3InboxMessage.tsx @@ -13,10 +13,10 @@ import { useColorModeValue, useDisclosure, } from "@chakra-ui/react" +import { ArrowRight } from "@phosphor-icons/react" import Button from "components/common/Button" import { Modal } from "components/common/Modal" import Link from "next/link" -import { ArrowRight } from "phosphor-react" import formatRelativeTimeFromNow from "utils/formatRelativeTimeFromNow" const GUILD_NOTIFICATION_ICON = "/requirementLogos/guild.png" diff --git a/src/components/common/Layout/components/BackButton.tsx b/src/components/common/Layout/components/BackButton.tsx index cab3f81927..5607d307a3 100644 --- a/src/components/common/Layout/components/BackButton.tsx +++ b/src/components/common/Layout/components/BackButton.tsx @@ -1,8 +1,8 @@ +import { ArrowLeft } from "@phosphor-icons/react" import { useThemeContext } from "components/[guild]/ThemeContext" import Button from "components/common/Button" import Link from "next/link" import { useRouter } from "next/router" -import { ArrowLeft } from "phosphor-react" import { PropsWithChildren } from "react" type Props = { diff --git a/src/components/common/Layout/components/Footer.tsx b/src/components/common/Layout/components/Footer.tsx index 98eaa80ca4..eb70ce898b 100644 --- a/src/components/common/Layout/components/Footer.tsx +++ b/src/components/common/Layout/components/Footer.tsx @@ -1,6 +1,6 @@ import { Link } from "@chakra-ui/next-js" import { Box, Icon, Text } from "@chakra-ui/react" -import { ArrowSquareOut } from "phosphor-react" +import { ArrowSquareOut } from "@phosphor-icons/react" const Footer = (): JSX.Element => ( diff --git a/src/components/common/Layout/components/NavMenu/NavMenu.tsx b/src/components/common/Layout/components/NavMenu/NavMenu.tsx index 0af0c01c31..c6c955f1c7 100644 --- a/src/components/common/Layout/components/NavMenu/NavMenu.tsx +++ b/src/components/common/Layout/components/NavMenu/NavMenu.tsx @@ -11,11 +11,6 @@ import { Text, useColorModeValue, } from "@chakra-ui/react" -import Button from "components/common/Button" -import { useSetAtom } from "jotai" -import dynamic from "next/dynamic" -import { useRouter } from "next/router" -import { explorerScrollRestorationAtom } from "pages/explorer" import { Book, CircleWavyCheck, @@ -30,7 +25,12 @@ import { Plus, Shield, UsersThree, -} from "phosphor-react" +} from "@phosphor-icons/react" +import Button from "components/common/Button" +import { useSetAtom } from "jotai" +import dynamic from "next/dynamic" +import { useRouter } from "next/router" +import { explorerScrollRestorationAtom } from "pages/explorer" import XLogo from "static/icons/x.svg" import NavButton from "./components/NavButton" import NavGroup from "./components/NavGroup" diff --git a/src/components/common/Layout/components/NavMenu/components/ThemeSwitcher.tsx b/src/components/common/Layout/components/NavMenu/components/ThemeSwitcher.tsx index e5f7a17fe5..74ff06872b 100644 --- a/src/components/common/Layout/components/NavMenu/components/ThemeSwitcher.tsx +++ b/src/components/common/Layout/components/NavMenu/components/ThemeSwitcher.tsx @@ -4,9 +4,9 @@ import { useColorMode, useRadioGroup, } from "@chakra-ui/react" +import { Moon, Sun } from "@phosphor-icons/react" import useLocalStorage from "hooks/useLocalStorage" import dynamic from "next/dynamic" -import { Moon, Sun } from "phosphor-react" import { useEffect } from "react" /** diff --git a/src/components/common/LinkMenuItem.tsx b/src/components/common/LinkMenuItem.tsx index 23dbac939e..0fc6f645eb 100644 --- a/src/components/common/LinkMenuItem.tsx +++ b/src/components/common/LinkMenuItem.tsx @@ -1,6 +1,6 @@ import { ButtonProps, MenuItem, MenuItemProps, Spinner } from "@chakra-ui/react" +import { ArrowRight } from "@phosphor-icons/react" import Link, { LinkProps } from "next/link" -import { ArrowRight } from "phosphor-react" import { useState } from "react" import Button from "./Button" diff --git a/src/components/common/PulseMarker/Marker.tsx b/src/components/common/PulseMarker/Marker.tsx index 7dae492555..e55a777345 100644 --- a/src/components/common/PulseMarker/Marker.tsx +++ b/src/components/common/PulseMarker/Marker.tsx @@ -1,5 +1,5 @@ import { Center, Icon } from "@chakra-ui/react" -import { Circle } from "phosphor-react" +import { Circle } from "@phosphor-icons/react" export type MarkerProps = { colorScheme?: string diff --git a/src/components/common/StyledSelect/components/CustomIndicatorsContainerWithCopy.tsx b/src/components/common/StyledSelect/components/CustomIndicatorsContainerWithCopy.tsx index b28eb11184..a0e39a8e54 100644 --- a/src/components/common/StyledSelect/components/CustomIndicatorsContainerWithCopy.tsx +++ b/src/components/common/StyledSelect/components/CustomIndicatorsContainerWithCopy.tsx @@ -1,7 +1,7 @@ import { IconButton, theme, useColorModeValue } from "@chakra-ui/react" import { transparentize } from "@chakra-ui/theme-tools" +import { Check, Copy } from "@phosphor-icons/react" import { GroupBase, IndicatorsContainerProps, components } from "chakra-react-select" -import { Check, Copy } from "phosphor-react" import { useState } from "react" import parseFromObject from "utils/parseFromObject" import { StyledSelectProps } from "../StyledSelect" diff --git a/src/components/common/StyledSelect/components/CustomSelectOption/components/OptionIcon.tsx b/src/components/common/StyledSelect/components/CustomSelectOption/components/OptionIcon.tsx index 0bb40153a4..b5ce3cdd81 100644 --- a/src/components/common/StyledSelect/components/CustomSelectOption/components/OptionIcon.tsx +++ b/src/components/common/StyledSelect/components/CustomSelectOption/components/OptionIcon.tsx @@ -1,5 +1,5 @@ import { Center, Icon } from "@chakra-ui/react" -import { IconProps } from "phosphor-react" +import { IconProps } from "@phosphor-icons/react" import { ForwardRefExoticComponent, RefAttributes } from "react" const OptionIcon = ({ diff --git a/src/components/common/VerifiedIcon.tsx b/src/components/common/VerifiedIcon.tsx index 6ad80e20a3..20f23b5ea3 100644 --- a/src/components/common/VerifiedIcon.tsx +++ b/src/components/common/VerifiedIcon.tsx @@ -6,7 +6,7 @@ import { ResponsiveValue, Tooltip, } from "@chakra-ui/react" -import { CircleWavyCheck } from "phosphor-react" +import { CircleWavyCheck } from "@phosphor-icons/react" type Props = { size: ResponsiveValue diff --git a/src/components/create-guild/BasicInfo/components/ContactInfo.tsx b/src/components/create-guild/BasicInfo/components/ContactInfo.tsx index 1c6adf60c8..61774aa32b 100644 --- a/src/components/create-guild/BasicInfo/components/ContactInfo.tsx +++ b/src/components/create-guild/BasicInfo/components/ContactInfo.tsx @@ -11,12 +11,12 @@ import { Stack, Text, } from "@chakra-ui/react" +import { ArrowSquareOut, Plus, TrashSimple } from "@phosphor-icons/react" import Button from "components/common/Button" import ClientOnly from "components/common/ClientOnly" import FormErrorMessage from "components/common/FormErrorMessage" import StyledSelect from "components/common/StyledSelect" import { CreateGuildFormType } from "components/create-guild/CreateGuildForm" -import { ArrowSquareOut, Plus, TrashSimple } from "phosphor-react" import { Controller, useFieldArray, useFormContext } from "react-hook-form" import { SelectOption } from "types" diff --git a/src/components/create-guild/IconSelector/IconSelector.tsx b/src/components/create-guild/IconSelector/IconSelector.tsx index 3c327438df..aada9e673d 100644 --- a/src/components/create-guild/IconSelector/IconSelector.tsx +++ b/src/components/create-guild/IconSelector/IconSelector.tsx @@ -23,11 +23,11 @@ import { useDisclosure, useRadioGroup, } from "@chakra-ui/react" +import { Image } from "@phosphor-icons/react" import LogicDivider from "components/[guild]/LogicDivider" import GuildLogo from "components/common/GuildLogo" import { Modal } from "components/common/Modal" import { Uploader } from "hooks/usePinata/usePinata" -import { Image } from "phosphor-react" import React, { ComponentProps, useEffect } from "react" import { useController, useFormContext } from "react-hook-form" import { CreateGuildFormType } from "../CreateGuildForm" diff --git a/src/components/create-guild/IconSelector/components/PhotoUploader.tsx b/src/components/create-guild/IconSelector/components/PhotoUploader.tsx index bd3b46373c..850fa696c8 100644 --- a/src/components/create-guild/IconSelector/components/PhotoUploader.tsx +++ b/src/components/create-guild/IconSelector/components/PhotoUploader.tsx @@ -1,10 +1,10 @@ import { FormControl, FormLabel, HStack } from "@chakra-ui/react" +import { File } from "@phosphor-icons/react" import Button from "components/common/Button" import FormErrorMessage from "components/common/FormErrorMessage" import GuildLogo from "components/common/GuildLogo" import useDropzone, { ERROR_MESSAGES } from "hooks/useDropzone" import { Uploader } from "hooks/usePinata/usePinata" -import { File } from "phosphor-react" import { FileError } from "react-dropzone" import { useFormContext, useWatch } from "react-hook-form" diff --git a/src/components/create-guild/PlatformsGrid/components/PlatformSelectButton.tsx b/src/components/create-guild/PlatformsGrid/components/PlatformSelectButton.tsx index d110d40244..6525dc930f 100644 --- a/src/components/create-guild/PlatformsGrid/components/PlatformSelectButton.tsx +++ b/src/components/create-guild/PlatformsGrid/components/PlatformSelectButton.tsx @@ -9,6 +9,7 @@ import { useColorModeValue, VStack, } from "@chakra-ui/react" +import { ArrowSquareIn, CaretRight, IconProps } from "@phosphor-icons/react" import useUser from "components/[guild]/hooks/useUser" import useConnectPlatform from "components/[guild]/JoinModal/hooks/useConnectPlatform" import { walletSelectorModalAtom } from "components/_app/Web3ConnectionManager/components/WalletSelectorModal" @@ -17,9 +18,8 @@ import DisplayCard from "components/common/DisplayCard" import { useSetAtom } from "jotai" import dynamic from "next/dynamic" import Image from "next/image" -import { ArrowSquareIn, CaretRight, IconProps } from "phosphor-react" -import rewards from "rewards" import { ComponentType, RefAttributes, useMemo } from "react" +import rewards from "rewards" import { PlatformName, Rest } from "types" export type PlatformHookType = ({ diff --git a/src/components/create-guild/Requirements/components/AddRequirement.tsx b/src/components/create-guild/Requirements/components/AddRequirement.tsx index 8445375f84..f1a7e79a57 100644 --- a/src/components/create-guild/Requirements/components/AddRequirement.tsx +++ b/src/components/create-guild/Requirements/components/AddRequirement.tsx @@ -20,6 +20,7 @@ import { VStack, } from "@chakra-ui/react" import { schemas, Schemas } from "@guildxyz/types" +import { ArrowLeft, CaretRight } from "@phosphor-icons/react" import useGuild from "components/[guild]/hooks/useGuild" import AddCard from "components/common/AddCard" import Button from "components/common/Button" @@ -28,7 +29,6 @@ import { Modal } from "components/common/Modal" import SearchBar from "components/explorer/SearchBar" import { AnimatePresence, AnimateSharedLayout, usePresence } from "framer-motion" import useToast from "hooks/useToast" -import { ArrowLeft, CaretRight } from "phosphor-react" import { Dispatch, FC, diff --git a/src/components/create-guild/Requirements/components/BalancyCounter.tsx b/src/components/create-guild/Requirements/components/BalancyCounter.tsx index 9e0557f60a..a7839c8881 100644 --- a/src/components/create-guild/Requirements/components/BalancyCounter.tsx +++ b/src/components/create-guild/Requirements/components/BalancyCounter.tsx @@ -11,8 +11,8 @@ import { useClipboard, Wrap, } from "@chakra-ui/react" +import { Copy, DownloadSimple, Question, Warning } from "@phosphor-icons/react" import Button from "components/common/Button" -import { Copy, DownloadSimple, Question, Warning } from "phosphor-react" import useBalancy from "../hooks/useBalancy" const BalancyCounterWithPopover = ({ ...rest }) => { diff --git a/src/components/create-guild/Requirements/components/ProvidedValueDisplay.tsx b/src/components/create-guild/Requirements/components/ProvidedValueDisplay.tsx index f8485adb34..2580e560d7 100644 --- a/src/components/create-guild/Requirements/components/ProvidedValueDisplay.tsx +++ b/src/components/create-guild/Requirements/components/ProvidedValueDisplay.tsx @@ -12,8 +12,8 @@ import { Tooltip, useColorModeValue, } from "@chakra-ui/react" +import { Info, Lightning, Question } from "@phosphor-icons/react" import Card from "components/common/Card" -import { Info, Lightning, Question } from "phosphor-react" import { REQUIREMENT_PROVIDED_VALUES } from "requirements/requirements" import { Requirement } from "types" diff --git a/src/components/create-guild/Requirements/components/UnsupportedRequirementTypeCard.tsx b/src/components/create-guild/Requirements/components/UnsupportedRequirementTypeCard.tsx index 5ced8fa8f2..255021b1ea 100644 --- a/src/components/create-guild/Requirements/components/UnsupportedRequirementTypeCard.tsx +++ b/src/components/create-guild/Requirements/components/UnsupportedRequirementTypeCard.tsx @@ -1,7 +1,7 @@ import { Icon } from "@chakra-ui/react" +import { Warning } from "@phosphor-icons/react" import Requirement from "components/[guild]/Requirements/components/Requirement" import DataBlock from "components/common/DataBlock" -import { Warning } from "phosphor-react" import { PropsWithChildren } from "react" import RequirementBaseCard from "./RequirementBaseCard" diff --git a/src/components/create-guild/TelegramGroup/TelegramGroup.tsx b/src/components/create-guild/TelegramGroup/TelegramGroup.tsx index 5c9fb70009..7795262287 100644 --- a/src/components/create-guild/TelegramGroup/TelegramGroup.tsx +++ b/src/components/create-guild/TelegramGroup/TelegramGroup.tsx @@ -1,8 +1,8 @@ -import { env } from "env" import { FormControl, FormLabel, HStack, Icon, Input, Stack } from "@chakra-ui/react" +import { ArrowSquareOut, Check } from "@phosphor-icons/react" import Button from "components/common/Button" import FormErrorMessage from "components/common/FormErrorMessage" -import { ArrowSquareOut, Check } from "phosphor-react" +import { env } from "env" import { PropsWithChildren } from "react" import { useFormContext, useWatch } from "react-hook-form" import parseFromObject from "utils/parseFromObject" diff --git a/src/components/explorer/GoToCreateGuildButton.tsx b/src/components/explorer/GoToCreateGuildButton.tsx index f04d7e8755..0423d80f8d 100644 --- a/src/components/explorer/GoToCreateGuildButton.tsx +++ b/src/components/explorer/GoToCreateGuildButton.tsx @@ -1,8 +1,8 @@ import { useBreakpointValue } from "@chakra-ui/react" +import { Plus } from "@phosphor-icons/react" import { useIsTabsStuck } from "components/[guild]/Tabs" import Button from "components/common/Button" import Link from "next/link" -import { Plus } from "phosphor-react" const GoToCreateGuildButton = () => { const { isStuck } = useIsTabsStuck() diff --git a/src/components/explorer/GuildCard.tsx b/src/components/explorer/GuildCard.tsx index 86a11d5840..4231ff8b1c 100644 --- a/src/components/explorer/GuildCard.tsx +++ b/src/components/explorer/GuildCard.tsx @@ -11,11 +11,11 @@ import { VStack, Wrap, } from "@chakra-ui/react" +import { Users } from "@phosphor-icons/react" import DisplayCard from "components/common/DisplayCard" import GuildLogo from "components/common/GuildLogo" import VerifiedIcon from "components/common/VerifiedIcon" import image from "next/image" -import { Users } from "phosphor-react" import { GuildBase } from "types" import pluralize from "utils/pluralize" diff --git a/src/components/explorer/SearchBar.tsx b/src/components/explorer/SearchBar.tsx index b124e1a974..f31acd932a 100644 --- a/src/components/explorer/SearchBar.tsx +++ b/src/components/explorer/SearchBar.tsx @@ -9,8 +9,8 @@ import { InputRightElement, useColorModeValue, } from "@chakra-ui/react" +import { MagnifyingGlass } from "@phosphor-icons/react" import useDebouncedState from "hooks/useDebouncedState" -import { MagnifyingGlass } from "phosphor-react" import { useEffect, useRef, useState } from "react" type Props = { diff --git a/src/components/explorer/SearchBarFilters.tsx b/src/components/explorer/SearchBarFilters.tsx index 6dab4fadb3..c156f19279 100644 --- a/src/components/explorer/SearchBarFilters.tsx +++ b/src/components/explorer/SearchBarFilters.tsx @@ -1,7 +1,7 @@ import { Box, HStack, Icon, useColorModeValue } from "@chakra-ui/react" +import { PushPin, Sparkle } from "@phosphor-icons/react" import Button from "components/common/Button" import { motion } from "framer-motion" -import { PushPin, Sparkle } from "phosphor-react" const ExplorerFilters = ["FEATURED", "NEWEST"] as const export type Filters = (typeof ExplorerFilters)[number] diff --git a/src/components/explorer/YourGuilds.tsx b/src/components/explorer/YourGuilds.tsx index b1c9a02036..672e8705de 100644 --- a/src/components/explorer/YourGuilds.tsx +++ b/src/components/explorer/YourGuilds.tsx @@ -1,4 +1,5 @@ import { Box, HStack, Img, Stack, Text } from "@chakra-ui/react" +import { Plus, SignIn } from "@phosphor-icons/react" import { walletSelectorModalAtom } from "components/_app/Web3ConnectionManager/components/WalletSelectorModal" import useWeb3ConnectionManager from "components/_app/Web3ConnectionManager/hooks/useWeb3ConnectionManager" import ActionCard from "components/common/ActionCard" @@ -9,7 +10,6 @@ import GuildCardsGrid from "components/explorer/GuildCardsGrid" import useSWRWithOptionalAuth from "hooks/useSWRWithOptionalAuth" import { useSetAtom } from "jotai" import Link from "next/link" -import { Plus, SignIn } from "phosphor-react" import { forwardRef } from "react" import { GuildBase } from "types" diff --git a/src/components/index/CallToAction.tsx b/src/components/index/CallToAction.tsx index 085a3b76e8..8a76352e09 100644 --- a/src/components/index/CallToAction.tsx +++ b/src/components/index/CallToAction.tsx @@ -1,6 +1,6 @@ import { Box, Flex, Heading, Text } from "@chakra-ui/react" +import { CaretRight } from "@phosphor-icons/react" import { useRouter } from "next/router" -import { CaretRight } from "phosphor-react" import LandingButton from "./LandingButton" const CallToAction = (): JSX.Element => { diff --git a/src/components/index/Discover.tsx b/src/components/index/Discover.tsx index 60e60cebcd..19908da173 100644 --- a/src/components/index/Discover.tsx +++ b/src/components/index/Discover.tsx @@ -8,10 +8,10 @@ import { Text, useColorMode, } from "@chakra-ui/react" +import { CaretDown } from "@phosphor-icons/react" import Card from "components/common/Card" import { motion } from "framer-motion" import Image from "next/image" -import { CaretDown } from "phosphor-react" import { useState } from "react" import LandingButton from "./LandingButton" import LandingWideSection from "./LandingWideSection" diff --git a/src/components/index/ExploreTrendingGuilds.tsx b/src/components/index/ExploreTrendingGuilds.tsx index 5474f1c2d4..85c890ebe3 100644 --- a/src/components/index/ExploreTrendingGuilds.tsx +++ b/src/components/index/ExploreTrendingGuilds.tsx @@ -1,8 +1,8 @@ import { Box, Flex, Spinner } from "@chakra-ui/react" +import { ArrowRight } from "@phosphor-icons/react" import GuildCard from "components/explorer/GuildCard" import GuildCardsGrid from "components/explorer/GuildCardsGrid" import Link from "next/link" -import { ArrowRight } from "phosphor-react" import useSWR from "swr" import LandingButton from "./LandingButton" import LandingWideSection from "./LandingWideSection" diff --git a/src/components/index/Hero.tsx b/src/components/index/Hero.tsx index 695cbe96b8..409cdc047d 100644 --- a/src/components/index/Hero.tsx +++ b/src/components/index/Hero.tsx @@ -9,9 +9,9 @@ import { useBreakpointValue, } from "@chakra-ui/react" import { DotLottiePlayer, type DotLottieCommonPlayer } from "@dotlottie/react-player" +import { ArrowRight, CaretDown } from "@phosphor-icons/react" import useScrollEffect from "hooks/useScrollEffect" import Link from "next/link" -import { ArrowRight, CaretDown } from "phosphor-react" import { useRef, useState } from "react" import LandingButton from "./LandingButton" diff --git a/src/components/index/TokenBasedMembership.tsx b/src/components/index/TokenBasedMembership.tsx index 506372987d..852227c86d 100644 --- a/src/components/index/TokenBasedMembership.tsx +++ b/src/components/index/TokenBasedMembership.tsx @@ -1,5 +1,5 @@ import { Box, Icon, Img, Text, VStack } from "@chakra-ui/react" -import { Sparkle } from "phosphor-react" +import { Sparkle } from "@phosphor-icons/react" import LandingSection from "./LandingSection" import LandingSectionText from "./LandingSectionText" diff --git a/src/components/leaderboard/MysteryBoxCard.tsx b/src/components/leaderboard/MysteryBoxCard.tsx index df70f65c9d..fa134a7b5a 100644 --- a/src/components/leaderboard/MysteryBoxCard.tsx +++ b/src/components/leaderboard/MysteryBoxCard.tsx @@ -14,12 +14,12 @@ import { Text, useDisclosure, } from "@chakra-ui/react" +import { Check, Gift } from "@phosphor-icons/react" import Button from "components/common/Button" import Card from "components/common/Card" import CardMotionWrapper from "components/common/CardMotionWrapper" import FormErrorMessage from "components/common/FormErrorMessage" import { Modal } from "components/common/Modal" -import { Check, Gift } from "phosphor-react" import { useForm } from "react-hook-form" import useClaimMysteryBox from "./hooks/useClaimMysteryBox" import useHasAlreadyClaimedMysteryBox from "./hooks/useHasAlreadyClaimedMysteryBox" diff --git a/src/components/leaderboard/PinLeaderboardUserCard.tsx b/src/components/leaderboard/PinLeaderboardUserCard.tsx index c5eea81985..8154851930 100644 --- a/src/components/leaderboard/PinLeaderboardUserCard.tsx +++ b/src/components/leaderboard/PinLeaderboardUserCard.tsx @@ -1,4 +1,3 @@ -import { env } from "env" import { Link } from "@chakra-ui/next-js" import { Center, @@ -21,12 +20,13 @@ import { useColorModeValue, VStack, } from "@chakra-ui/react" +import { CaretDown, Trophy } from "@phosphor-icons/react" import Button from "components/common/Button" import Card from "components/common/Card" import GuildAvatar from "components/common/GuildAvatar" +import { env } from "env" import useResolveAddress from "hooks/useResolveAddress" import dynamic from "next/dynamic" -import { CaretDown, Trophy } from "phosphor-react" import { GuildPinMetadata } from "types" import base64ToObject from "utils/base64ToObject" import shortenHex from "utils/shortenHex" diff --git a/src/components/leaderboard/ScoreFormulaPopover.tsx b/src/components/leaderboard/ScoreFormulaPopover.tsx index c2e243799f..b8535759bc 100644 --- a/src/components/leaderboard/ScoreFormulaPopover.tsx +++ b/src/components/leaderboard/ScoreFormulaPopover.tsx @@ -15,7 +15,7 @@ import { Thead, Tr, } from "@chakra-ui/react" -import { Info } from "phosphor-react" +import { Info } from "@phosphor-icons/react" const ScoreFormulaPopover = () => ( diff --git a/src/components/lexical/plugins/ToolbarPlugin/ToolbarPlugin.tsx b/src/components/lexical/plugins/ToolbarPlugin/ToolbarPlugin.tsx index 3d7a3053de..0b7df31e1f 100644 --- a/src/components/lexical/plugins/ToolbarPlugin/ToolbarPlugin.tsx +++ b/src/components/lexical/plugins/ToolbarPlugin/ToolbarPlugin.tsx @@ -25,19 +25,6 @@ import { } from "@lexical/rich-text" import { $isAtNodeEnd, $wrapNodes } from "@lexical/selection" import { $getNearestNodeOfType, mergeRegister } from "@lexical/utils" -import Button from "components/common/Button" -import { - $createParagraphNode, - $getSelection, - $isRangeSelection, - CAN_REDO_COMMAND, - CAN_UNDO_COMMAND, - FORMAT_TEXT_COMMAND, - LexicalEditor, - REDO_COMMAND, - SELECTION_CHANGE_COMMAND, - UNDO_COMMAND, -} from "lexical" import { ArrowClockwise, ArrowCounterClockwise, @@ -52,7 +39,20 @@ import { TextHTwo, TextItalic, TextT, -} from "phosphor-react" +} from "@phosphor-icons/react" +import Button from "components/common/Button" +import { + $createParagraphNode, + $getSelection, + $isRangeSelection, + CAN_REDO_COMMAND, + CAN_UNDO_COMMAND, + FORMAT_TEXT_COMMAND, + LexicalEditor, + REDO_COMMAND, + SELECTION_CHANGE_COMMAND, + UNDO_COMMAND, +} from "lexical" import { useCallback, useEffect, useRef, useState } from "react" import ImageEditor from "./components/ImageEditor" import LinkEditor from "./components/LinkEditor" diff --git a/src/components/lexical/plugins/ToolbarPlugin/components/ImageEditor.tsx b/src/components/lexical/plugins/ToolbarPlugin/components/ImageEditor.tsx index 1041418fd5..0d26980d94 100644 --- a/src/components/lexical/plugins/ToolbarPlugin/components/ImageEditor.tsx +++ b/src/components/lexical/plugins/ToolbarPlugin/components/ImageEditor.tsx @@ -14,8 +14,8 @@ import { useDisclosure, } from "@chakra-ui/react" import { useLexicalComposerContext } from "@lexical/react/LexicalComposerContext" +import { ImageSquare } from "@phosphor-icons/react" import Button from "components/common/Button" -import { ImageSquare } from "phosphor-react" import { useRef, useState } from "react" import { INSERT_IMAGE_COMMAND } from "../../ImagesPlugin" diff --git a/src/components/lexical/plugins/ToolbarPlugin/components/LinkEditor.tsx b/src/components/lexical/plugins/ToolbarPlugin/components/LinkEditor.tsx index 42d623f774..8f3173d2f4 100644 --- a/src/components/lexical/plugins/ToolbarPlugin/components/LinkEditor.tsx +++ b/src/components/lexical/plugins/ToolbarPlugin/components/LinkEditor.tsx @@ -15,9 +15,9 @@ import { import { $isLinkNode, TOGGLE_LINK_COMMAND } from "@lexical/link" import { useLexicalComposerContext } from "@lexical/react/LexicalComposerContext" import { mergeRegister } from "@lexical/utils" +import { Link } from "@phosphor-icons/react" import Button from "components/common/Button" import { $getSelection, $isRangeSelection, SELECTION_CHANGE_COMMAND } from "lexical" -import { Link } from "phosphor-react" import { useCallback, useEffect, useRef, useState } from "react" import { FormProvider, useForm } from "react-hook-form" import { ensureUrlProtocol } from "utils/ensureUrlProtocol" diff --git a/src/pages/[guild]/events.tsx b/src/pages/[guild]/events.tsx index b6daf84649..d2c16b7075 100644 --- a/src/pages/[guild]/events.tsx +++ b/src/pages/[guild]/events.tsx @@ -1,4 +1,5 @@ import { HStack, Link, VStack, Wrap } from "@chakra-ui/react" +import { NoteBlank } from "@phosphor-icons/react" import { EditGuildDrawerProvider } from "components/[guild]/EditGuild/EditGuildDrawerContext" import EventCard from "components/[guild]/Events/EventCard" import FallbackFrame from "components/[guild]/Events/FallbackFrame" @@ -15,7 +16,6 @@ import BackButton from "components/common/Layout/components/BackButton" import useGuildEvents, { GuildEvent } from "hooks/useGuildEvents" import { GetStaticPaths, GetStaticProps } from "next" import dynamic from "next/dynamic" -import { NoteBlank } from "phosphor-react" import { SWRConfig } from "swr" import { Guild, SocialLinkKey } from "types" import parseDescription from "utils/parseDescription" diff --git a/src/pages/[guild]/index.tsx b/src/pages/[guild]/index.tsx index 5293e2beb2..89c11627e7 100644 --- a/src/pages/[guild]/index.tsx +++ b/src/pages/[guild]/index.tsx @@ -12,6 +12,7 @@ import { Text, Wrap, } from "@chakra-ui/react" +import { Info, Users } from "@phosphor-icons/react" import AccessHub from "components/[guild]/AccessHub" import { useAccessedGuildPlatforms } from "components/[guild]/AccessHub/AccessHub" import { @@ -43,9 +44,8 @@ import { GetStaticPaths, GetStaticProps } from "next" import dynamic from "next/dynamic" import Head from "next/head" import ErrorPage from "pages/_error" -import { Info, Users } from "phosphor-react" -import { MintPolygonIDProofProvider } from "rewards/PolygonID/components/MintPolygonIDProofProvider" import { useEffect } from "react" +import { MintPolygonIDProofProvider } from "rewards/PolygonID/components/MintPolygonIDProofProvider" import { SWRConfig } from "swr" import { Guild, SocialLinkKey } from "types" import fetcher from "utils/fetcher" diff --git a/src/pages/_app.tsx b/src/pages/_app.tsx index a7873286db..b3045cfa01 100644 --- a/src/pages/_app.tsx +++ b/src/pages/_app.tsx @@ -1,7 +1,7 @@ -import { env } from "env" import { Box, Progress, Slide, useColorMode } from "@chakra-ui/react" import { FuelWalletConnector, FueletWalletConnector } from "@fuels/connectors" import { FuelProvider } from "@fuels/react" +import { IconContext } from "@phosphor-icons/react" import { QueryClient, QueryClientProvider } from "@tanstack/react-query" import { bugsnagStart } from "bugsnag" import AppErrorBoundary from "components/_app/AppErrorBoundary" @@ -11,13 +11,13 @@ import { PostHogProvider } from "components/_app/PostHogProvider" import Web3ConnectionManager from "components/_app/Web3ConnectionManager" import ClientOnly from "components/common/ClientOnly" import AccountModal from "components/common/Layout/components/Account/components/AccountModal" +import { env } from "env" import { dystopian, inter } from "fonts" import useOAuthResultToast from "hooks/useOAuthResultToast" import { useAtomValue } from "jotai" import type { AppProps } from "next/app" import dynamic from "next/dynamic" import { useRouter } from "next/router" -import { IconContext } from "phosphor-react" import { useEffect, useState } from "react" import { SWRConfig } from "swr" import "theme/custom-scrollbar.css" diff --git a/src/pages/_error.tsx b/src/pages/_error.tsx index 5c33f67ab1..5a95e8c599 100644 --- a/src/pages/_error.tsx +++ b/src/pages/_error.tsx @@ -1,8 +1,8 @@ import { Flex, Heading, Icon, Stack } from "@chakra-ui/react" +import { ChatCircle, House } from "@phosphor-icons/react" import IntercomProvider, { triggerChat } from "components/_app/IntercomProvider" import Button from "components/common/Button" import Head from "next/head" -import { ChatCircle, House } from "phosphor-react" import NotFoundIcon from "static/avatars/58.svg" const Page = ({ statusCode }): JSX.Element => ( diff --git a/src/requirements/Airdrop/AirdropRequirement.tsx b/src/requirements/Airdrop/AirdropRequirement.tsx index 29da3c7808..135bc72330 100644 --- a/src/requirements/Airdrop/AirdropRequirement.tsx +++ b/src/requirements/Airdrop/AirdropRequirement.tsx @@ -1,11 +1,11 @@ import { Icon, Text, useDisclosure } from "@chakra-ui/react" +import { ArrowSquareIn } from "@phosphor-icons/react" import Requirement, { RequirementProps, } from "components/[guild]/Requirements/components/Requirement" import { useRequirementContext } from "components/[guild]/Requirements/components/RequirementContext" import SnapshotModal from "components/[guild]/leaderboard/Snapshots/SnapshotModal" import Button from "components/common/Button" -import { ArrowSquareIn } from "phosphor-react" import REQUIREMENTS from "requirements" const AirdropRequirement = ({ ...rest }: RequirementProps): JSX.Element => { diff --git a/src/requirements/Airdrop/providedValue/AirdropProvidedValue.tsx b/src/requirements/Airdrop/providedValue/AirdropProvidedValue.tsx index 75299f8aa8..4202e72ec3 100644 --- a/src/requirements/Airdrop/providedValue/AirdropProvidedValue.tsx +++ b/src/requirements/Airdrop/providedValue/AirdropProvidedValue.tsx @@ -1,7 +1,7 @@ import { HStack, Text, useDisclosure } from "@chakra-ui/react" +import { ArrowSquareIn } from "@phosphor-icons/react" import SnapshotModal from "components/[guild]/leaderboard/Snapshots/SnapshotModal" import Button from "components/common/Button" -import { ArrowSquareIn } from "phosphor-react" import { ProvidedValueDisplayProps } from "requirements" const AirdropProvidedValue = ({ requirement }: ProvidedValueDisplayProps) => { diff --git a/src/requirements/Allowlist/AllowlistRequirement.tsx b/src/requirements/Allowlist/AllowlistRequirement.tsx index 4d18cd8197..765dbee42d 100644 --- a/src/requirements/Allowlist/AllowlistRequirement.tsx +++ b/src/requirements/Allowlist/AllowlistRequirement.tsx @@ -1,5 +1,6 @@ import { Fade, HStack, Icon, Text, useDisclosure } from "@chakra-ui/react" import { Schemas } from "@guildxyz/types" +import { ArrowSquareIn, ListPlus } from "@phosphor-icons/react" import RequirementConnectButton from "components/[guild]/Requirements/components/ConnectRequirementPlatformButton" import Requirement, { RequirementProps, @@ -9,7 +10,6 @@ import useRequirement from "components/[guild]/hooks/useRequirement" import Button from "components/common/Button" import { useRoleMembership } from "components/explorer/hooks/useMembership" import useDebouncedState from "hooks/useDebouncedState" -import { ArrowSquareIn, ListPlus } from "phosphor-react" import { useState } from "react" import SearchableVirtualListModal from "requirements/common/SearchableVirtualListModal" import { isAddress } from "viem" diff --git a/src/requirements/Allowlist/components/AllowlistFormInputs.tsx b/src/requirements/Allowlist/components/AllowlistFormInputs.tsx index 613464f0e3..3798bcfe7d 100644 --- a/src/requirements/Allowlist/components/AllowlistFormInputs.tsx +++ b/src/requirements/Allowlist/components/AllowlistFormInputs.tsx @@ -1,4 +1,3 @@ -import { env } from "env" import { Checkbox, Collapse, @@ -10,13 +9,14 @@ import { Textarea, Tooltip, } from "@chakra-ui/react" +import { ArrowCounterClockwise, Check, File } from "@phosphor-icons/react" import { isValidAddress } from "components/[guild]/EditGuild/components/Admins/Admins" import Button from "components/common/Button" import FormErrorMessage from "components/common/FormErrorMessage" +import { env } from "env" import useDropzone from "hooks/useDropzone" import useSubmit from "hooks/useSubmit" import { useRouter } from "next/router" -import { ArrowCounterClockwise, Check, File } from "phosphor-react" import { Controller, useFormContext, useWatch } from "react-hook-form" import fetcher from "utils/fetcher" import parseFromObject from "utils/parseFromObject" diff --git a/src/requirements/Captcha/CaptchaRequirement.tsx b/src/requirements/Captcha/CaptchaRequirement.tsx index 3772144f14..cc89f5c65b 100644 --- a/src/requirements/Captcha/CaptchaRequirement.tsx +++ b/src/requirements/Captcha/CaptchaRequirement.tsx @@ -1,10 +1,10 @@ import { Icon } from "@chakra-ui/react" +import { Robot } from "@phosphor-icons/react" import Requirement, { RequirementProps, } from "components/[guild]/Requirements/components/Requirement" import { useRequirementContext } from "components/[guild]/Requirements/components/RequirementContext" import DataBlock from "components/common/DataBlock" -import { Robot } from "phosphor-react" import formatRelativeTimeFromNow from "utils/formatRelativeTimeFromNow" import CompleteCaptcha from "./components/CompleteCaptcha" diff --git a/src/requirements/Captcha/components/CompleteCaptcha.tsx b/src/requirements/Captcha/components/CompleteCaptcha.tsx index 3d664501cd..c71c0eaf88 100644 --- a/src/requirements/Captcha/components/CompleteCaptcha.tsx +++ b/src/requirements/Captcha/components/CompleteCaptcha.tsx @@ -14,6 +14,7 @@ import { useDisclosure, } from "@chakra-ui/react" import HCaptcha from "@hcaptcha/react-hcaptcha" +import { Robot } from "@phosphor-icons/react" import useMembershipUpdate from "components/[guild]/JoinModal/hooks/useMembershipUpdate" import { useRequirementContext } from "components/[guild]/Requirements/components/RequirementContext" import useUser from "components/[guild]/hooks/useUser" @@ -22,7 +23,6 @@ import ErrorAlert from "components/common/ErrorAlert" import { Modal } from "components/common/Modal" import { useRoleMembership } from "components/explorer/hooks/useMembership" import { useFetcherWithSign } from "hooks/useFetcherWithSign" -import { Robot } from "phosphor-react" import { useEffect } from "react" import useSWRImmutable from "swr/immutable" import useVerifyCaptcha from "../hooks/useVerifyCaptcha" diff --git a/src/requirements/ContractState/ContractStateForm.tsx b/src/requirements/ContractState/ContractStateForm.tsx index 70b54c2579..743523ac35 100644 --- a/src/requirements/ContractState/ContractStateForm.tsx +++ b/src/requirements/ContractState/ContractStateForm.tsx @@ -23,11 +23,11 @@ import { Text, TextProps, } from "@chakra-ui/react" +import { Info, Plus, X } from "@phosphor-icons/react" import Button from "components/common/Button" import ControlledSelect from "components/common/ControlledSelect" import DataBlockWithCopy from "components/common/DataBlockWithCopy" import FormErrorMessage from "components/common/FormErrorMessage" -import { Info, Plus, X } from "phosphor-react" import { useMemo } from "react" import { Controller, useFieldArray, useFormContext, useWatch } from "react-hook-form" import { RequirementFormProps } from "requirements" diff --git a/src/requirements/ContractState/ContractStateRequirement.tsx b/src/requirements/ContractState/ContractStateRequirement.tsx index a9e877e355..b4fa9af41d 100644 --- a/src/requirements/ContractState/ContractStateRequirement.tsx +++ b/src/requirements/ContractState/ContractStateRequirement.tsx @@ -14,6 +14,7 @@ import { Tr, useColorModeValue, } from "@chakra-ui/react" +import { CaretDown, Function } from "@phosphor-icons/react" import BlockExplorerUrl from "components/[guild]/Requirements/components/BlockExplorerUrl" import Requirement, { RequirementProps, @@ -21,7 +22,6 @@ import Requirement, { import { RequirementButton } from "components/[guild]/Requirements/components/RequirementButton" import { useRequirementContext } from "components/[guild]/Requirements/components/RequirementContext" import DataBlock from "components/common/DataBlock" -import { CaretDown, Function } from "phosphor-react" import shortenHex from "utils/shortenHex" const ADDRESS_REGEX = /^0x[A-F0-9]{40}$/i diff --git a/src/requirements/Discord/DiscordRequirement.tsx b/src/requirements/Discord/DiscordRequirement.tsx index a97d938efa..a45deed732 100644 --- a/src/requirements/Discord/DiscordRequirement.tsx +++ b/src/requirements/Discord/DiscordRequirement.tsx @@ -1,4 +1,5 @@ import { Icon, Text } from "@chakra-ui/react" +import { DiscordLogo } from "@phosphor-icons/react" import ConnectRequirementPlatformButton from "components/[guild]/Requirements/components/ConnectRequirementPlatformButton" import DataBlockWithDate from "components/[guild]/Requirements/components/DataBlockWithDate" import Requirement, { @@ -7,7 +8,6 @@ import Requirement, { import { useRequirementContext } from "components/[guild]/Requirements/components/RequirementContext" import DataBlock from "components/common/DataBlock" import useServerData from "hooks/useServerData" -import { DiscordLogo } from "phosphor-react" import formatRelativeTimeFromNow from "utils/formatRelativeTimeFromNow" const DiscordRequirement = (props: RequirementProps) => { diff --git a/src/requirements/Email/EmailRequirement.tsx b/src/requirements/Email/EmailRequirement.tsx index a7a7c98cb8..f2f360fc17 100644 --- a/src/requirements/Email/EmailRequirement.tsx +++ b/src/requirements/Email/EmailRequirement.tsx @@ -1,11 +1,11 @@ import { Icon } from "@chakra-ui/react" +import { EnvelopeSimple } from "@phosphor-icons/react" import RequirementConnectButton from "components/[guild]/Requirements/components/ConnectRequirementPlatformButton" import Requirement, { RequirementProps, } from "components/[guild]/Requirements/components/Requirement" import { useRequirementContext } from "components/[guild]/Requirements/components/RequirementContext" import DataBlock from "components/common/DataBlock" -import { EnvelopeSimple } from "phosphor-react" const EmailRequirement = (props: RequirementProps) => { const { data, type } = useRequirementContext() diff --git a/src/requirements/Farcaster/FarcasterRequirement.tsx b/src/requirements/Farcaster/FarcasterRequirement.tsx index 379af8d0e7..da25ba0367 100644 --- a/src/requirements/Farcaster/FarcasterRequirement.tsx +++ b/src/requirements/Farcaster/FarcasterRequirement.tsx @@ -1,4 +1,5 @@ import { Icon, Link, Skeleton, Text } from "@chakra-ui/react" +import { ArrowSquareOut } from "@phosphor-icons/react" import RequirementConnectButton from "components/[guild]/Requirements/components/ConnectRequirementPlatformButton" import Requirement, { RequirementProps, @@ -7,7 +8,6 @@ import { useRequirementContext } from "components/[guild]/Requirements/component import useUser from "components/[guild]/hooks/useUser" import DataBlockWithCopy from "components/common/DataBlockWithCopy" import { useRoleMembership } from "components/explorer/hooks/useMembership" -import { ArrowSquareOut } from "phosphor-react" import REQUIREMENTS from "requirements" import FarcasterAction from "./components/FarcasterAction" import FarcasterCast from "./components/FarcasterCast" diff --git a/src/requirements/Farcaster/components/FarcasterCast.tsx b/src/requirements/Farcaster/components/FarcasterCast.tsx index cde5288722..b0d920e2b4 100644 --- a/src/requirements/Farcaster/components/FarcasterCast.tsx +++ b/src/requirements/Farcaster/components/FarcasterCast.tsx @@ -16,7 +16,7 @@ import { Heart, ShareNetwork, WarningCircle, -} from "phosphor-react" +} from "@phosphor-icons/react" import { PropsWithChildren } from "react" import FarcasterCastSmall from "./FarcasterCastSmall" diff --git a/src/requirements/Farcaster/components/FarcasterCastSmall.tsx b/src/requirements/Farcaster/components/FarcasterCastSmall.tsx index 814fcaa3a9..b256d6fc69 100644 --- a/src/requirements/Farcaster/components/FarcasterCastSmall.tsx +++ b/src/requirements/Farcaster/components/FarcasterCastSmall.tsx @@ -1,6 +1,6 @@ import { Flex, HStack, Image, Link, Skeleton, Text } from "@chakra-ui/react" +import { Chat, Heart, ShareNetwork, WarningCircle } from "@phosphor-icons/react" import DataBlock from "components/common/DataBlock" -import { Chat, Heart, ShareNetwork, WarningCircle } from "phosphor-react" import { FarcasterCastData } from "./FarcasterCast" const FarcasterCastSmall = ({ diff --git a/src/requirements/Form/components/ExpectedAnswerRequirements/ExpectedMultipleChoice.tsx b/src/requirements/Form/components/ExpectedAnswerRequirements/ExpectedMultipleChoice.tsx index 97b135fd51..3d32a24b07 100644 --- a/src/requirements/Form/components/ExpectedAnswerRequirements/ExpectedMultipleChoice.tsx +++ b/src/requirements/Form/components/ExpectedAnswerRequirements/ExpectedMultipleChoice.tsx @@ -1,7 +1,7 @@ import { FormControl, FormLabel, HStack, Stack, Text } from "@chakra-ui/react" +import { Check, Minus, X } from "@phosphor-icons/react" import FormErrorMessage from "components/common/FormErrorMessage" import RadioButtonGroup from "components/common/RadioButtonGroup" -import { Check, Minus, X } from "phosphor-react" import { useFieldArray, useFormContext, useFormState } from "react-hook-form" export const ExpectedMultipleChoice = ({ field }) => { diff --git a/src/requirements/Free/FreeRequirement.tsx b/src/requirements/Free/FreeRequirement.tsx index 574c10f2d3..60f4c3205d 100644 --- a/src/requirements/Free/FreeRequirement.tsx +++ b/src/requirements/Free/FreeRequirement.tsx @@ -1,6 +1,6 @@ import { Icon } from "@chakra-ui/react" +import { Icon as PhosphorIcon } from "@phosphor-icons/react" import Requirement from "components/[guild]/Requirements/components/Requirement" -import { Icon as PhosphorIcon } from "phosphor-react" import REQUIREMENTS from "requirements" const FreeRequirement = ({ ...rest }) => ( diff --git a/src/requirements/Fuel/FuelRequirement.tsx b/src/requirements/Fuel/FuelRequirement.tsx index db607a2a84..fac1b50d18 100644 --- a/src/requirements/Fuel/FuelRequirement.tsx +++ b/src/requirements/Fuel/FuelRequirement.tsx @@ -1,10 +1,10 @@ import { Icon, Img, Tag, TagLabel, Text, useColorModeValue } from "@chakra-ui/react" +import { ArrowsLeftRight } from "@phosphor-icons/react" import Requirement, { RequirementProps, } from "components/[guild]/Requirements/components/Requirement" import { useRequirementContext } from "components/[guild]/Requirements/components/RequirementContext" import DataBlockWithCopy from "components/common/DataBlockWithCopy" -import { ArrowsLeftRight } from "phosphor-react" import shortenHex from "utils/shortenHex" const NULL_FUEL_ADDRESS = diff --git a/src/requirements/GitcoinPassport/GitcoinPassportRequirement.tsx b/src/requirements/GitcoinPassport/GitcoinPassportRequirement.tsx index 56e36cadc9..6b33310fc8 100644 --- a/src/requirements/GitcoinPassport/GitcoinPassportRequirement.tsx +++ b/src/requirements/GitcoinPassport/GitcoinPassportRequirement.tsx @@ -14,6 +14,7 @@ import { Tr, useColorModeValue, } from "@chakra-ui/react" +import { CaretDown } from "@phosphor-icons/react" import Requirement, { RequirementProps, } from "components/[guild]/Requirements/components/Requirement" @@ -21,7 +22,6 @@ import { RequirementButton } from "components/[guild]/Requirements/components/Re import { useRequirementContext } from "components/[guild]/Requirements/components/RequirementContext" import DataBlock from "components/common/DataBlock" import { useRoleMembership } from "components/explorer/hooks/useMembership" -import { CaretDown } from "phosphor-react" import { scorers } from "./components/Score" import SetupPassport from "./components/SetupPassport" diff --git a/src/requirements/GitcoinPassport/components/SetupPassport.tsx b/src/requirements/GitcoinPassport/components/SetupPassport.tsx index 914cd7d053..95d922460f 100644 --- a/src/requirements/GitcoinPassport/components/SetupPassport.tsx +++ b/src/requirements/GitcoinPassport/components/SetupPassport.tsx @@ -1,7 +1,7 @@ import { Link } from "@chakra-ui/next-js" import { ButtonProps } from "@chakra-ui/react" +import { ArrowSquareOut } from "@phosphor-icons/react" import Button from "components/common/Button" -import { ArrowSquareOut } from "phosphor-react" const SetupPassport = (buttonProps: ButtonProps) => ( { diff --git a/src/requirements/Guild/GuildRequirement.tsx b/src/requirements/Guild/GuildRequirement.tsx index 454dbe1e69..af3a3a33ec 100644 --- a/src/requirements/Guild/GuildRequirement.tsx +++ b/src/requirements/Guild/GuildRequirement.tsx @@ -1,5 +1,6 @@ import { Link } from "@chakra-ui/next-js" import { Icon, Img, Skeleton, Text } from "@chakra-ui/react" +import { Detective } from "@phosphor-icons/react" import DataBlockWithDate from "components/[guild]/Requirements/components/DataBlockWithDate" import Requirement, { RequirementProps, @@ -7,7 +8,6 @@ import Requirement, { import { useRequirementContext } from "components/[guild]/Requirements/components/RequirementContext" import { useSimpleGuild } from "components/[guild]/hooks/useGuild" import useRole from "components/[guild]/hooks/useRole" -import { Detective } from "phosphor-react" import useSWRImmutable from "swr/immutable" import { Group } from "types" import pluralize from "utils/pluralize" diff --git a/src/requirements/Nft/NftForm.tsx b/src/requirements/Nft/NftForm.tsx index 1ac05dd85b..c2e9e89053 100644 --- a/src/requirements/Nft/NftForm.tsx +++ b/src/requirements/Nft/NftForm.tsx @@ -20,11 +20,11 @@ import { Stack, Textarea, } from "@chakra-ui/react" +import { Plus } from "@phosphor-icons/react" import Button from "components/common/Button" import FormErrorMessage from "components/common/FormErrorMessage" import StyledSelect from "components/common/StyledSelect" import OptionImage from "components/common/StyledSelect/components/CustomSelectOption/components/OptionImage" -import { Plus } from "phosphor-react" import { useEffect, useMemo, useState } from "react" import { useController, diff --git a/src/requirements/Nft/NftRequirement.tsx b/src/requirements/Nft/NftRequirement.tsx index afa80692c4..7be2bfdc5f 100644 --- a/src/requirements/Nft/NftRequirement.tsx +++ b/src/requirements/Nft/NftRequirement.tsx @@ -1,6 +1,6 @@ -import { env } from "env" import { HStack, Text, useDisclosure } from "@chakra-ui/react" import { ImageData } from "@nouns/assets" +import { ArrowSquareOut } from "@phosphor-icons/react" import BlockExplorerUrl from "components/[guild]/Requirements/components/BlockExplorerUrl" import DynamicPurchaseRequirement from "components/[guild]/Requirements/components/GuildCheckout/DynamicPurchaseRequirement" import { GuildCheckoutProvider } from "components/[guild]/Requirements/components/GuildCheckout/components/GuildCheckoutContext" @@ -12,7 +12,7 @@ import { useRequirementContext } from "components/[guild]/Requirements/component import useGuild from "components/[guild]/hooks/useGuild" import Button from "components/common/Button" import DataBlock from "components/common/DataBlock" -import { ArrowSquareOut } from "phosphor-react" +import { env } from "env" import { Fragment } from "react" import SearchableVirtualListModal from "requirements/common/SearchableVirtualListModal" import useSWRImmutable from "swr/immutable" diff --git a/src/requirements/Nft/components/AttributePicker.tsx b/src/requirements/Nft/components/AttributePicker.tsx index d43e7f5e24..64edb5b0cb 100644 --- a/src/requirements/Nft/components/AttributePicker.tsx +++ b/src/requirements/Nft/components/AttributePicker.tsx @@ -8,10 +8,10 @@ import { Stack, useColorModeValue, } from "@chakra-ui/react" +import { Plus, TrashSimple, X } from "@phosphor-icons/react" import Button from "components/common/Button" import ControlledSelect from "components/common/ControlledSelect" import FormErrorMessage from "components/common/FormErrorMessage" -import { Plus, TrashSimple, X } from "phosphor-react" import { useEffect, useMemo, useState } from "react" import { useFormContext, useWatch } from "react-hook-form" import capitalize from "utils/capitalize" diff --git a/src/requirements/Nft/components/UploadIDs.tsx b/src/requirements/Nft/components/UploadIDs.tsx index e692299a12..0f08572c9d 100644 --- a/src/requirements/Nft/components/UploadIDs.tsx +++ b/src/requirements/Nft/components/UploadIDs.tsx @@ -1,6 +1,6 @@ +import { File } from "@phosphor-icons/react" import Button from "components/common/Button" import useDropzone from "hooks/useDropzone" -import { File } from "phosphor-react" export const INVALID_TOKEN_IDS_ERROR = { type: "validate", diff --git a/src/requirements/Parallel/ParallelForm.tsx b/src/requirements/Parallel/ParallelForm.tsx index 0a3035a7e6..0a727754d5 100644 --- a/src/requirements/Parallel/ParallelForm.tsx +++ b/src/requirements/Parallel/ParallelForm.tsx @@ -7,9 +7,9 @@ import { Link, Stack, } from "@chakra-ui/react" +import { ArrowSquareOut } from "@phosphor-icons/react" import ControlledSelect from "components/common/ControlledSelect" import FormErrorMessage from "components/common/FormErrorMessage" -import { ArrowSquareOut } from "phosphor-react" import { Controller, useFormContext, useWatch } from "react-hook-form" import { RequirementFormProps } from "requirements" import parseFromObject from "utils/parseFromObject" diff --git a/src/requirements/Payment/PaymentForm.tsx b/src/requirements/Payment/PaymentForm.tsx index 03ffafeda5..d95710e0e3 100644 --- a/src/requirements/Payment/PaymentForm.tsx +++ b/src/requirements/Payment/PaymentForm.tsx @@ -1,7 +1,7 @@ import { HStack, Icon, Stack, Tooltip } from "@chakra-ui/react" +import { Check, Question } from "@phosphor-icons/react" import Button from "components/common/Button" import useTriggerNetworkChange from "hooks/useTriggerNetworkChange" -import { Check, Question } from "phosphor-react" import { useEffect } from "react" import { FormProvider, useForm, useFormContext, useWatch } from "react-hook-form" import { RequirementFormProps } from "requirements" diff --git a/src/requirements/Payment/PaymentRequirement.tsx b/src/requirements/Payment/PaymentRequirement.tsx index 2a75820173..6d391d8774 100644 --- a/src/requirements/Payment/PaymentRequirement.tsx +++ b/src/requirements/Payment/PaymentRequirement.tsx @@ -1,4 +1,5 @@ import { Icon, Text } from "@chakra-ui/react" +import { Coins } from "@phosphor-icons/react" import BlockExplorerUrl from "components/[guild]/Requirements/components/BlockExplorerUrl" import BuyPass from "components/[guild]/Requirements/components/GuildCheckout/BuyPass" import { GuildCheckoutProvider } from "components/[guild]/Requirements/components/GuildCheckout/components/GuildCheckoutContext" @@ -10,7 +11,6 @@ import useGuildPermission from "components/[guild]/hooks/useGuildPermission" import DataBlock from "components/common/DataBlock" import { useRoleMembership } from "components/explorer/hooks/useMembership" import useToken from "hooks/useToken" -import { Coins } from "phosphor-react" import { NULL_ADDRESS } from "utils/guildCheckout/constants" import { formatUnits } from "viem" import { CHAIN_CONFIG, Chains } from "wagmiConfig/chains" diff --git a/src/requirements/Payment/components/WithdrawButton/WithdrawButton.tsx b/src/requirements/Payment/components/WithdrawButton/WithdrawButton.tsx index d6a611224e..23072e98b0 100644 --- a/src/requirements/Payment/components/WithdrawButton/WithdrawButton.tsx +++ b/src/requirements/Payment/components/WithdrawButton/WithdrawButton.tsx @@ -1,9 +1,9 @@ import { Icon, Spinner, Tooltip } from "@chakra-ui/react" +import { LinkBreak, Wallet } from "@phosphor-icons/react" import { useRequirementContext } from "components/[guild]/Requirements/components/RequirementContext" import Button from "components/common/Button" import useTokenData from "hooks/useTokenData" import useTriggerNetworkChange from "hooks/useTriggerNetworkChange" -import { LinkBreak, Wallet } from "phosphor-react" import useVault from "requirements/Payment/hooks/useVault" import shortenHex from "utils/shortenHex" import { formatUnits } from "viem" diff --git a/src/requirements/Points/components/MaxMinAmount.tsx b/src/requirements/Points/components/MaxMinAmount.tsx index e3ab596efe..b40eeffaf4 100644 --- a/src/requirements/Points/components/MaxMinAmount.tsx +++ b/src/requirements/Points/components/MaxMinAmount.tsx @@ -11,9 +11,9 @@ import { Text, Tooltip, } from "@chakra-ui/react" +import { Question } from "@phosphor-icons/react" import Button from "components/common/Button" import FormErrorMessage from "components/common/FormErrorMessage" -import { Question } from "phosphor-react" import { useEffect, useState } from "react" import { Controller, useFormContext } from "react-hook-form" import { Requirement } from "types" diff --git a/src/requirements/PolygonID/PolygonIDRequirement.tsx b/src/requirements/PolygonID/PolygonIDRequirement.tsx index 001dd7134b..f1f9782a28 100644 --- a/src/requirements/PolygonID/PolygonIDRequirement.tsx +++ b/src/requirements/PolygonID/PolygonIDRequirement.tsx @@ -11,12 +11,12 @@ import { Text, useColorModeValue, } from "@chakra-ui/react" +import { CaretDown } from "@phosphor-icons/react" import Requirement, { RequirementProps, } from "components/[guild]/Requirements/components/Requirement" import { useRequirementContext } from "components/[guild]/Requirements/components/RequirementContext" import DataBlock from "components/common/DataBlock" -import { CaretDown } from "phosphor-react" import formatRelativeTimeFromNow from "utils/formatRelativeTimeFromNow" import ConnectPolygonID from "./components/ConnectPolygonID" diff --git a/src/requirements/PolygonID/components/ConnectPolygonID.tsx b/src/requirements/PolygonID/components/ConnectPolygonID.tsx index 70a4e58616..4e5f441896 100644 --- a/src/requirements/PolygonID/components/ConnectPolygonID.tsx +++ b/src/requirements/PolygonID/components/ConnectPolygonID.tsx @@ -13,6 +13,7 @@ import { useBreakpointValue, useDisclosure, } from "@chakra-ui/react" +import { ArrowsClockwise } from "@phosphor-icons/react" import useMembershipUpdate from "components/[guild]/JoinModal/hooks/useMembershipUpdate" import { useRequirementContext } from "components/[guild]/Requirements/components/RequirementContext" import useUser from "components/[guild]/hooks/useUser" @@ -22,7 +23,6 @@ import { Modal } from "components/common/Modal" import { useRoleMembership } from "components/explorer/hooks/useMembership" import { useFetcherWithSign } from "hooks/useFetcherWithSign" import useShowErrorToast from "hooks/useShowErrorToast" -import { ArrowsClockwise } from "phosphor-react" import { QRCodeSVG } from "qrcode.react" import { useEffect } from "react" import useSWRImmutable from "swr/immutable" diff --git a/src/requirements/PolygonID/components/PolygonIDQuery.tsx b/src/requirements/PolygonID/components/PolygonIDQuery.tsx index 00d8988eb1..6ebb733417 100644 --- a/src/requirements/PolygonID/components/PolygonIDQuery.tsx +++ b/src/requirements/PolygonID/components/PolygonIDQuery.tsx @@ -8,8 +8,8 @@ import { Text, Textarea, } from "@chakra-ui/react" +import { ArrowSquareOut } from "@phosphor-icons/react" import FormErrorMessage from "components/common/FormErrorMessage" -import { ArrowSquareOut } from "phosphor-react" import { Controller, useFormContext } from "react-hook-form" import { RequirementFormProps } from "requirements" import parseFromObject from "utils/parseFromObject" diff --git a/src/requirements/Snapshot/SnapshotRequirement.tsx b/src/requirements/Snapshot/SnapshotRequirement.tsx index 0a978fa31d..3707a301a4 100644 --- a/src/requirements/Snapshot/SnapshotRequirement.tsx +++ b/src/requirements/Snapshot/SnapshotRequirement.tsx @@ -7,6 +7,7 @@ import { PopoverTrigger, Portal, } from "@chakra-ui/react" +import { CaretDown } from "@phosphor-icons/react" import DataBlockWithDate from "components/[guild]/Requirements/components/DataBlockWithDate" import Requirement, { RequirementProps, @@ -14,7 +15,6 @@ import Requirement, { import { RequirementButton } from "components/[guild]/Requirements/components/RequirementButton" import { useRequirementContext } from "components/[guild]/Requirements/components/RequirementContext" import DataBlock from "components/common/DataBlock" -import { CaretDown } from "phosphor-react" import useSWRImmutable from "swr/immutable" import pluralize from "utils/pluralize" import SnapshotSpaceLink from "./components/SnapshotSpaceLink" diff --git a/src/requirements/Snapshot/components/Strategy/components/SingleStrategy.tsx b/src/requirements/Snapshot/components/Strategy/components/SingleStrategy.tsx index 0ccf29145d..2825862a3c 100644 --- a/src/requirements/Snapshot/components/Strategy/components/SingleStrategy.tsx +++ b/src/requirements/Snapshot/components/Strategy/components/SingleStrategy.tsx @@ -14,9 +14,9 @@ import { Text, Textarea, } from "@chakra-ui/react" +import { ArrowSquareOut } from "@phosphor-icons/react" import ControlledSelect from "components/common/ControlledSelect" import FormErrorMessage from "components/common/FormErrorMessage" -import { ArrowSquareOut } from "phosphor-react" import { useEffect, useMemo, useState } from "react" import { Controller, useFormContext, useWatch } from "react-hook-form" import useSWRImmutable from "swr/immutable" diff --git a/src/requirements/Twitter/TwitterRequirement.tsx b/src/requirements/Twitter/TwitterRequirement.tsx index ae1dcc9458..32a2be7b0f 100644 --- a/src/requirements/Twitter/TwitterRequirement.tsx +++ b/src/requirements/Twitter/TwitterRequirement.tsx @@ -1,4 +1,5 @@ import { Icon, Text } from "@chakra-ui/react" +import { ArrowSquareOut } from "@phosphor-icons/react" import ConnectRequirementPlatformButton from "components/[guild]/Requirements/components/ConnectRequirementPlatformButton" import DataBlockWithDate from "components/[guild]/Requirements/components/DataBlockWithDate" import Requirement, { @@ -8,7 +9,6 @@ import { useRequirementContext } from "components/[guild]/Requirements/component import useUser from "components/[guild]/hooks/useUser" import DataBlock from "components/common/DataBlock" import DataBlockWithCopy from "components/common/DataBlockWithCopy" -import { ArrowSquareOut } from "phosphor-react" import XLogo from "static/icons/x.svg" import useSWRImmutable from "swr/immutable" import { PlatformType } from "types" diff --git a/src/requirements/Twitter/components/TwitterIntent.tsx b/src/requirements/Twitter/components/TwitterIntent.tsx index 136463a723..654a68a025 100644 --- a/src/requirements/Twitter/components/TwitterIntent.tsx +++ b/src/requirements/Twitter/components/TwitterIntent.tsx @@ -1,4 +1,5 @@ import { Icon, Link } from "@chakra-ui/react" +import { Heart, Share, UserPlus, type IconProps } from "@phosphor-icons/react" import useMembershipUpdate from "components/[guild]/JoinModal/hooks/useMembershipUpdate" import { useRequirementContext } from "components/[guild]/Requirements/components/RequirementContext" import useUser from "components/[guild]/hooks/useUser" @@ -7,7 +8,6 @@ import { useRoleMembership } from "components/explorer/hooks/useMembership" import useIsIOS from "hooks/useIsIOS" import usePopupWindow from "hooks/usePopupWindow" import { SignedValidation, useSubmitWithSign } from "hooks/useSubmit" -import { Heart, Share, UserPlus, type IconProps } from "phosphor-react" import { PropsWithChildren, useState } from "react" import useSWR from "swr" import { PlatformType } from "types" diff --git a/src/requirements/Twitter/components/TwitterListLink.tsx b/src/requirements/Twitter/components/TwitterListLink.tsx index e79abbaa80..6ea030d8bc 100644 --- a/src/requirements/Twitter/components/TwitterListLink.tsx +++ b/src/requirements/Twitter/components/TwitterListLink.tsx @@ -1,5 +1,5 @@ import { Icon, Link } from "@chakra-ui/react" -import { ArrowSquareOut } from "phosphor-react" +import { ArrowSquareOut } from "@phosphor-icons/react" import { Requirement } from "types" type Props = { diff --git a/src/requirements/Twitter/components/TwitterTweetLink.tsx b/src/requirements/Twitter/components/TwitterTweetLink.tsx index 05c0f12c7e..a1473a47a5 100644 --- a/src/requirements/Twitter/components/TwitterTweetLink.tsx +++ b/src/requirements/Twitter/components/TwitterTweetLink.tsx @@ -1,5 +1,5 @@ import { Icon, Link } from "@chakra-ui/react" -import { ArrowSquareOut } from "phosphor-react" +import { ArrowSquareOut } from "@phosphor-icons/react" import { Requirement } from "types" type Props = { diff --git a/src/requirements/Uniswap/UniswapForm.tsx b/src/requirements/Uniswap/UniswapForm.tsx index ff6a326e45..121b8017f9 100644 --- a/src/requirements/Uniswap/UniswapForm.tsx +++ b/src/requirements/Uniswap/UniswapForm.tsx @@ -12,10 +12,10 @@ import { Tooltip, } from "@chakra-ui/react" import { consts } from "@guildxyz/types" +import { Question } from "@phosphor-icons/react" import Button from "components/common/Button" import ControlledSelect from "components/common/ControlledSelect" import FormErrorMessage from "components/common/FormErrorMessage" -import { Question } from "phosphor-react" import { useCallback, useState } from "react" import { useFormContext, useWatch } from "react-hook-form" import { RequirementFormProps } from "requirements" diff --git a/src/requirements/VisitLink/VisitLinkRequirement.tsx b/src/requirements/VisitLink/VisitLinkRequirement.tsx index beb2e6f809..cce4e79480 100644 --- a/src/requirements/VisitLink/VisitLinkRequirement.tsx +++ b/src/requirements/VisitLink/VisitLinkRequirement.tsx @@ -14,6 +14,7 @@ import { useColorModeValue, useDisclosure, } from "@chakra-ui/react" +import { ArrowSquareOut, Link as LinkIcon } from "@phosphor-icons/react" import useMembershipUpdate from "components/[guild]/JoinModal/hooks/useMembershipUpdate" import Requirement, { RequirementProps, @@ -33,7 +34,6 @@ import { useRoleMembership } from "components/explorer/hooks/useMembership" import useShowErrorToast from "hooks/useShowErrorToast" import { SignedValidation, useSubmitWithSign } from "hooks/useSubmit" import NextLink from "next/link" -import { ArrowSquareOut, Link as LinkIcon } from "phosphor-react" import { useRef } from "react" import { useFormContext } from "react-hook-form" import fetcher from "utils/fetcher" diff --git a/src/requirements/WalletActivity/WalletActivityRequirement.tsx b/src/requirements/WalletActivity/WalletActivityRequirement.tsx index 6e249dc6d6..41959baa31 100644 --- a/src/requirements/WalletActivity/WalletActivityRequirement.tsx +++ b/src/requirements/WalletActivity/WalletActivityRequirement.tsx @@ -1,4 +1,11 @@ import { Icon } from "@chakra-ui/react" +import { + ArrowsLeftRight, + Coins, + FileText, + IconProps, + Wallet, +} from "@phosphor-icons/react" import DataBlockWithDate from "components/[guild]/Requirements/components/DataBlockWithDate" import Requirement, { RequirementProps, @@ -7,7 +14,6 @@ import RequirementChainIndicator from "components/[guild]/Requirements/component import { useRequirementContext } from "components/[guild]/Requirements/components/RequirementContext" import DataBlock from "components/common/DataBlock" import DataBlockWithCopy from "components/common/DataBlockWithCopy" -import { ArrowsLeftRight, Coins, FileText, IconProps, Wallet } from "phosphor-react" import { ForwardRefExoticComponent, RefAttributes } from "react" import formatRelativeTimeFromNow from "utils/formatRelativeTimeFromNow" import shortenHex from "utils/shortenHex" diff --git a/src/requirements/Web3Inbox/Web3InboxRequirement.tsx b/src/requirements/Web3Inbox/Web3InboxRequirement.tsx index 7323a73d3e..0fc53feedc 100644 --- a/src/requirements/Web3Inbox/Web3InboxRequirement.tsx +++ b/src/requirements/Web3Inbox/Web3InboxRequirement.tsx @@ -1,11 +1,11 @@ import { Link, Text } from "@chakra-ui/react" +import { ArrowSquareOut } from "@phosphor-icons/react" import Requirement, { RequirementProps, } from "components/[guild]/Requirements/components/Requirement" import { useRequirementContext } from "components/[guild]/Requirements/components/RequirementContext" import Button from "components/common/Button" import { useRoleMembership } from "components/explorer/hooks/useMembership" -import { ArrowSquareOut } from "phosphor-react" import { APP_DETAILS } from "./Web3InboxForm" const Web3InboxRequirement = (props: RequirementProps) => { diff --git a/src/requirements/common/ChainPicker.tsx b/src/requirements/common/ChainPicker.tsx index c837c83ff9..fb66d2b53c 100644 --- a/src/requirements/common/ChainPicker.tsx +++ b/src/requirements/common/ChainPicker.tsx @@ -6,10 +6,10 @@ import { InputGroup, InputLeftElement, } from "@chakra-ui/react" +import { Question } from "@phosphor-icons/react" import ControlledSelect from "components/common/ControlledSelect" import { StyledSelectProps } from "components/common/StyledSelect/StyledSelect" import OptionImage from "components/common/StyledSelect/components/CustomSelectOption/components/OptionImage" -import { Question } from "phosphor-react" import { useEffect } from "react" import { useFormContext, useWatch } from "react-hook-form" import { useChainId } from "wagmi" diff --git a/src/requirements/common/MinMaxAmount.tsx b/src/requirements/common/MinMaxAmount.tsx index b519acf953..ce23fcf888 100644 --- a/src/requirements/common/MinMaxAmount.tsx +++ b/src/requirements/common/MinMaxAmount.tsx @@ -11,9 +11,9 @@ import { Text, Tooltip, } from "@chakra-ui/react" +import { Question } from "@phosphor-icons/react" import Button from "components/common/Button" import FormErrorMessage from "components/common/FormErrorMessage" -import { Question } from "phosphor-react" import { useState } from "react" import { Controller, useFormContext } from "react-hook-form" import { Requirement } from "types" diff --git a/src/requirements/index.ts b/src/requirements/index.ts index 2a46012186..4e50165d20 100644 --- a/src/requirements/index.ts +++ b/src/requirements/index.ts @@ -1,6 +1,6 @@ import { Schemas } from "@guildxyz/types" +import { Icon } from "@phosphor-icons/react" import { RequirementProps } from "components/[guild]/Requirements/components/Requirement" -import { Icon } from "phosphor-react" import { ComponentType } from "react" import { UseControllerProps } from "react-hook-form" import { Requirement } from "types" diff --git a/src/requirements/requirements.ts b/src/requirements/requirements.ts index ba9b50a672..619ed99535 100644 --- a/src/requirements/requirements.ts +++ b/src/requirements/requirements.ts @@ -1,5 +1,3 @@ -import { RequirementProps } from "components/[guild]/Requirements/components/Requirement" -import dynamic from "next/dynamic" import { Coins, CurrencyCircleDollar, @@ -11,8 +9,9 @@ import { Robot, Wallet, Wrench, -} from "phosphor-react" -import rewards from "rewards" +} from "@phosphor-icons/react" +import { RequirementProps } from "components/[guild]/Requirements/components/Requirement" +import dynamic from "next/dynamic" import { ComponentType } from "react" import { ProvidedValueDisplayProps, @@ -20,6 +19,7 @@ import { RequirementType, } from "requirements" import { VISIT_LINK_REGEX } from "requirements/VisitLink/VisitLinkRequirement" +import rewards from "rewards" import Star from "static/icons/star.svg" import GuildLogo from "static/logo.svg" diff --git a/src/rewards/ContractCall/ContractCallCardMenu.tsx b/src/rewards/ContractCall/ContractCallCardMenu.tsx index e8f67f0e95..91a2d7c4b1 100644 --- a/src/rewards/ContractCall/ContractCallCardMenu.tsx +++ b/src/rewards/ContractCall/ContractCallCardMenu.tsx @@ -1,4 +1,5 @@ import { MenuItem, useDisclosure } from "@chakra-ui/react" +import { PencilSimple } from "@phosphor-icons/react" import RemovePlatformMenuItem from "components/[guild]/AccessHub/components/RemovePlatformMenuItem" import { ContractCallFunction } from "components/[guild]/RolePlatforms/components/AddRoleRewardModal/components/AddContractCallPanel/components/CreateNftForm/hooks/useCreateNft" import PlatformCardMenu from "components/[guild]/RolePlatforms/components/PlatformCard/components/PlatformCardMenu" @@ -6,7 +7,6 @@ import useNftDetails from "components/[guild]/collect/hooks/useNftDetails" import useGuild from "components/[guild]/hooks/useGuild" import useGuildPermission from "components/[guild]/hooks/useGuildPermission" import useWeb3ConnectionManager from "components/_app/Web3ConnectionManager/hooks/useWeb3ConnectionManager" -import { PencilSimple } from "phosphor-react" import EditNFTDescriptionModal from "./components/EditNFTDescriptionModal" import EditNftModal from "./components/EditNftModal" diff --git a/src/rewards/ContractCall/ContractCallReward.tsx b/src/rewards/ContractCall/ContractCallReward.tsx index 26ebce95c1..30d81edc60 100644 --- a/src/rewards/ContractCall/ContractCallReward.tsx +++ b/src/rewards/ContractCall/ContractCallReward.tsx @@ -1,9 +1,9 @@ import { Circle, Img, SkeletonCircle, SkeletonProps } from "@chakra-ui/react" +import { ArrowRight } from "@phosphor-icons/react" import useNftDetails from "components/[guild]/collect/hooks/useNftDetails" import useGuild from "components/[guild]/hooks/useGuild" import Button from "components/common/Button" import { motion } from "framer-motion" -import { ArrowRight } from "phosphor-react" import { RewardDisplay, RewardIconProps, diff --git a/src/rewards/Discord/DiscordCardMenu/DiscordCardMenu.tsx b/src/rewards/Discord/DiscordCardMenu/DiscordCardMenu.tsx index 6cf1f3b90c..eef7038542 100644 --- a/src/rewards/Discord/DiscordCardMenu/DiscordCardMenu.tsx +++ b/src/rewards/Discord/DiscordCardMenu/DiscordCardMenu.tsx @@ -1,8 +1,8 @@ import { MenuDivider, MenuItem, useDisclosure } from "@chakra-ui/react" +import { ChatDots, Link } from "@phosphor-icons/react" import RemovePlatformMenuItem from "components/[guild]/AccessHub/components/RemovePlatformMenuItem" import SendDiscordJoinButtonModal from "components/[guild]/Onboarding/components/SummonMembers/components/SendDiscordJoinButtonModal" import PlatformCardMenu from "components/[guild]/RolePlatforms/components/PlatformCard/components/PlatformCardMenu" -import { ChatDots, Link } from "phosphor-react" import DiscordCaptchaSwitch from "./components/DiscordCaptchaSwitch" import DiscordRewardSettings from "./components/DiscordRewardSettings.tsx" diff --git a/src/rewards/Discord/DiscordCardMenu/components/DiscordCaptchaSwitch.tsx b/src/rewards/Discord/DiscordCardMenu/components/DiscordCaptchaSwitch.tsx index b128be74cd..514d45f49a 100644 --- a/src/rewards/Discord/DiscordCardMenu/components/DiscordCaptchaSwitch.tsx +++ b/src/rewards/Discord/DiscordCardMenu/components/DiscordCaptchaSwitch.tsx @@ -1,10 +1,10 @@ import { Box, HStack, Icon, Spinner, Text, Tooltip } from "@chakra-ui/react" +import { Question, Shield } from "@phosphor-icons/react" import useGuild from "components/[guild]/hooks/useGuild" import Switch from "components/common/Switch" import useShowErrorToast from "hooks/useShowErrorToast" import { SignedValidation, useSubmitWithSign } from "hooks/useSubmit" import useToast from "hooks/useToast" -import { Question, Shield } from "phosphor-react" import { useState } from "react" import { GuildPlatform, PlatformGuildData } from "types" import fetcher from "utils/fetcher" diff --git a/src/rewards/Discord/DiscordCardSettings/DiscordCardSettings.tsx b/src/rewards/Discord/DiscordCardSettings/DiscordCardSettings.tsx index 687f1eb862..720489d925 100644 --- a/src/rewards/Discord/DiscordCardSettings/DiscordCardSettings.tsx +++ b/src/rewards/Discord/DiscordCardSettings/DiscordCardSettings.tsx @@ -1,6 +1,6 @@ import { FormControl, FormErrorMessage, FormLabel } from "@chakra-ui/react" +import { ShieldCheck, Sparkle } from "@phosphor-icons/react" import RadioSelect from "components/common/RadioSelect" -import { ShieldCheck, Sparkle } from "phosphor-react" import { useController, useFormContext, useFormState } from "react-hook-form" import GuildifyExistingRole from "./components/GuildifyExistingRole" diff --git a/src/rewards/Discord/index.ts b/src/rewards/Discord/index.ts index a977259d6b..ad73f9b3e9 100644 --- a/src/rewards/Discord/index.ts +++ b/src/rewards/Discord/index.ts @@ -1,11 +1,11 @@ -import { DiscordLogo } from "phosphor-react" -import useDiscordCardProps from "./useDiscordCardProps" -import DiscordCardSettings from "./DiscordCardSettings" -import DiscordCardMenu from "./DiscordCardMenu" -import { PlatformAsRewardRestrictions, RewardData } from "rewards/types" +import { DiscordLogo } from "@phosphor-icons/react" import dynamic from "next/dynamic" import { AddRewardPanelLoadingSpinner } from "rewards/components/AddRewardPanelLoadingSpinner" import LoadingRewardPreview from "rewards/components/LoadingRewardPreview" +import { PlatformAsRewardRestrictions, RewardData } from "rewards/types" +import DiscordCardMenu from "./DiscordCardMenu" +import DiscordCardSettings from "./DiscordCardSettings" +import useDiscordCardProps from "./useDiscordCardProps" export default { icon: DiscordLogo, diff --git a/src/rewards/Email/index.ts b/src/rewards/Email/index.ts index c1cfd4fe93..52f0d7055d 100644 --- a/src/rewards/Email/index.ts +++ b/src/rewards/Email/index.ts @@ -1,4 +1,4 @@ -import { EnvelopeSimple } from "phosphor-react" +import { EnvelopeSimple } from "@phosphor-icons/react" import { PlatformAsRewardRestrictions, RewardData } from "rewards/types" export default { diff --git a/src/rewards/Forms/FormCardLinkButton.tsx b/src/rewards/Forms/FormCardLinkButton.tsx index 6b95c9b60c..18b0674369 100644 --- a/src/rewards/Forms/FormCardLinkButton.tsx +++ b/src/rewards/Forms/FormCardLinkButton.tsx @@ -1,10 +1,10 @@ +import { Check } from "@phosphor-icons/react" import useGuild from "components/[guild]/hooks/useGuild" import { useGuildForm } from "components/[guild]/hooks/useGuildForms" import useGuildPermission from "components/[guild]/hooks/useGuildPermission" import Button from "components/common/Button" import { LinkButton } from "components/common/LinkMenuItem" import Link from "next/link" -import { Check } from "phosphor-react" import rewards from "rewards" import { GuildPlatform } from "types" import { useUserFormSubmission } from "./hooks/useFormSubmissions" diff --git a/src/rewards/Forms/FormCardMenu.tsx b/src/rewards/Forms/FormCardMenu.tsx index 472039c4b6..5037c0eb85 100644 --- a/src/rewards/Forms/FormCardMenu.tsx +++ b/src/rewards/Forms/FormCardMenu.tsx @@ -1,9 +1,9 @@ import { MenuItem, useDisclosure } from "@chakra-ui/react" +import { PencilSimple, Table } from "@phosphor-icons/react" import RemovePlatformMenuItem from "components/[guild]/AccessHub/components/RemovePlatformMenuItem" import useGuild from "components/[guild]/hooks/useGuild" import { useGuildForm } from "components/[guild]/hooks/useGuildForms" import LinkMenuItem from "components/common/LinkMenuItem" -import { PencilSimple, Table } from "phosphor-react" import PlatformCardMenu from "../../components/[guild]/RolePlatforms/components/PlatformCard/components/PlatformCardMenu" import EditFormModal from "./EditFormModal" diff --git a/src/rewards/Forms/index.ts b/src/rewards/Forms/index.ts index 29a5daed91..7c8d628aad 100644 --- a/src/rewards/Forms/index.ts +++ b/src/rewards/Forms/index.ts @@ -1,11 +1,11 @@ -import { PencilSimpleLine } from "phosphor-react" -import { PlatformAsRewardRestrictions, RewardData } from "rewards/types" -import useFormCardProps from "./useFormCardProps" -import FormCardLinkButton from "./FormCardLinkButton" -import FormCardMenu from "./FormCardMenu" +import { PencilSimpleLine } from "@phosphor-icons/react" import dynamic from "next/dynamic" import { AddRewardPanelLoadingSpinner } from "rewards/components/AddRewardPanelLoadingSpinner" import LoadingRewardPreview from "rewards/components/LoadingRewardPreview" +import { PlatformAsRewardRestrictions, RewardData } from "rewards/types" +import FormCardLinkButton from "./FormCardLinkButton" +import FormCardMenu from "./FormCardMenu" +import useFormCardProps from "./useFormCardProps" export default { icon: PencilSimpleLine, diff --git a/src/rewards/Gather/ClaimGatherModal.tsx b/src/rewards/Gather/ClaimGatherModal.tsx index 8352ae9efc..446a373803 100644 --- a/src/rewards/Gather/ClaimGatherModal.tsx +++ b/src/rewards/Gather/ClaimGatherModal.tsx @@ -14,10 +14,10 @@ import { ModalOverlay, Text, } from "@chakra-ui/react" +import { ArrowSquareOut } from "@phosphor-icons/react" import useUser from "components/[guild]/hooks/useUser" import { AccountSection } from "components/common/Layout/components/Account/components/AccountModal/components/AccountConnections" import EmailAddress from "components/common/Layout/components/Account/components/AccountModal/components/SocialAccount/EmailAddress" -import { ArrowSquareOut } from "phosphor-react" type ModalProps = { title: string diff --git a/src/rewards/Gather/GatherCardButton.tsx b/src/rewards/Gather/GatherCardButton.tsx index 776831e5d3..af115aff86 100644 --- a/src/rewards/Gather/GatherCardButton.tsx +++ b/src/rewards/Gather/GatherCardButton.tsx @@ -1,7 +1,7 @@ import { Tooltip } from "@chakra-ui/react" +import { ArrowSquareOut } from "@phosphor-icons/react" import useGuild from "components/[guild]/hooks/useGuild" import Button from "components/common/Button" -import { ArrowSquareOut } from "phosphor-react" import { claimTextButtonTooltipLabel } from "rewards/SecretText/TextCardButton" import { GuildPlatform } from "types" import { diff --git a/src/rewards/Gather/GatherCardMenu.tsx b/src/rewards/Gather/GatherCardMenu.tsx index 0cb5f3ab27..676f1769bc 100644 --- a/src/rewards/Gather/GatherCardMenu.tsx +++ b/src/rewards/Gather/GatherCardMenu.tsx @@ -1,9 +1,9 @@ import { MenuItem, useDisclosure } from "@chakra-ui/react" +import { PencilSimple } from "@phosphor-icons/react" import EditRewardAvailabilityMenuItem from "components/[guild]/AccessHub/components/EditRewardAvailabilityMenuItem" import RemovePlatformMenuItem from "components/[guild]/AccessHub/components/RemovePlatformMenuItem" import PlatformCardMenu from "components/[guild]/RolePlatforms/components/PlatformCard/components/PlatformCardMenu" import useGuild from "components/[guild]/hooks/useGuild" -import { PencilSimple } from "phosphor-react" import EditGatherModal from "./EditGatherModal" type Props = { diff --git a/src/rewards/Gather/GatherConnectionForm.tsx b/src/rewards/Gather/GatherConnectionForm.tsx index cc0d442187..2a5cc000df 100644 --- a/src/rewards/Gather/GatherConnectionForm.tsx +++ b/src/rewards/Gather/GatherConnectionForm.tsx @@ -12,9 +12,9 @@ import { Stack, Tooltip, } from "@chakra-ui/react" +import { Eye, EyeClosed, Question } from "@phosphor-icons/react" import { AddGatherFormType } from "components/[guild]/RolePlatforms/components/AddRoleRewardModal/components/AddGatherPanel" import FormErrorMessage from "components/common/FormErrorMessage" -import { Eye, EyeClosed, Question } from "phosphor-react" import { CSSProperties, useState } from "react" import { useFormContext, useWatch } from "react-hook-form" import GatherConnectionStatusAlert from "./GatherConnectionStatusAlert" diff --git a/src/rewards/Gather/index.ts b/src/rewards/Gather/index.ts index 953b834318..fd1d9773d8 100644 --- a/src/rewards/Gather/index.ts +++ b/src/rewards/Gather/index.ts @@ -1,11 +1,11 @@ -import { Buildings } from "phosphor-react" +import { Buildings } from "@phosphor-icons/react" +import dynamic from "next/dynamic" +import { AddRewardPanelLoadingSpinner } from "rewards/components/AddRewardPanelLoadingSpinner" +import LoadingRewardPreview from "rewards/components/LoadingRewardPreview" import { PlatformAsRewardRestrictions, RewardData } from "rewards/types" -import useGatherCardProps from "./useGatherCardProps" import GatherCardButton from "./GatherCardButton" import GatherCardMenu from "./GatherCardMenu" -import dynamic from "next/dynamic" -import LoadingRewardPreview from "rewards/components/LoadingRewardPreview" -import { AddRewardPanelLoadingSpinner } from "rewards/components/AddRewardPanelLoadingSpinner" +import useGatherCardProps from "./useGatherCardProps" export default { icon: Buildings, diff --git a/src/rewards/Github/index.ts b/src/rewards/Github/index.ts index c665b12e9e..2abd6901fb 100644 --- a/src/rewards/Github/index.ts +++ b/src/rewards/Github/index.ts @@ -1,10 +1,10 @@ -import { PlatformAsRewardRestrictions, RewardData } from "rewards/types" -import GithubCardMenu from "./GithubCardMenu" -import useGithubCardProps from "./useGithubCardProps" -import { GithubLogo } from "phosphor-react" +import { GithubLogo } from "@phosphor-icons/react" import dynamic from "next/dynamic" import { AddRewardPanelLoadingSpinner } from "rewards/components/AddRewardPanelLoadingSpinner" import LoadingRewardPreview from "rewards/components/LoadingRewardPreview" +import { PlatformAsRewardRestrictions, RewardData } from "rewards/types" +import GithubCardMenu from "./GithubCardMenu" +import useGithubCardProps from "./useGithubCardProps" export default { icon: GithubLogo, diff --git a/src/rewards/Google/GoogleCardWarning.tsx b/src/rewards/Google/GoogleCardWarning.tsx index ce6a77d0f2..51da9d5568 100644 --- a/src/rewards/Google/GoogleCardWarning.tsx +++ b/src/rewards/Google/GoogleCardWarning.tsx @@ -7,8 +7,8 @@ import { PopoverTrigger, Portal, } from "@chakra-ui/react" +import { WarningCircle } from "@phosphor-icons/react" import useGuild from "components/[guild]/hooks/useGuild" -import { WarningCircle } from "phosphor-react" import { GuildPlatform } from "types" type Props = { diff --git a/src/rewards/Google/index.ts b/src/rewards/Google/index.ts index 64dcdb6bce..a4649df805 100644 --- a/src/rewards/Google/index.ts +++ b/src/rewards/Google/index.ts @@ -1,12 +1,12 @@ -import { GoogleLogo } from "phosphor-react" -import { PlatformAsRewardRestrictions, RewardData } from "rewards/types" -import useGoogleCardProps from "./useGoogleCardProps" -import GoogleCardSettings from "./GoogleCardSettings" -import GoogleCardMenu from "./GoogleCardMenu" -import GoogleCardWarning from "./GoogleCardWarning" +import { GoogleLogo } from "@phosphor-icons/react" import dynamic from "next/dynamic" import { AddRewardPanelLoadingSpinner } from "rewards/components/AddRewardPanelLoadingSpinner" import LoadingRewardPreview from "rewards/components/LoadingRewardPreview" +import { PlatformAsRewardRestrictions, RewardData } from "rewards/types" +import GoogleCardMenu from "./GoogleCardMenu" +import GoogleCardSettings from "./GoogleCardSettings" +import GoogleCardWarning from "./GoogleCardWarning" +import useGoogleCardProps from "./useGoogleCardProps" export default { icon: GoogleLogo, diff --git a/src/rewards/Poap/PoapCardMenu.tsx b/src/rewards/Poap/PoapCardMenu.tsx index 261e50cd44..751292e382 100644 --- a/src/rewards/Poap/PoapCardMenu.tsx +++ b/src/rewards/Poap/PoapCardMenu.tsx @@ -1,8 +1,8 @@ import { MenuItem, useDisclosure } from "@chakra-ui/react" +import { UploadSimple } from "@phosphor-icons/react" import RemovePlatformMenuItem from "components/[guild]/AccessHub/components/RemovePlatformMenuItem" import PlatformCardMenu from "components/[guild]/RolePlatforms/components/PlatformCard/components/PlatformCardMenu" import useGuild from "components/[guild]/hooks/useGuild" -import { UploadSimple } from "phosphor-react" import UploadMintLinksModal from "./UploadMintLinksModal" type Props = { diff --git a/src/rewards/Points/PointsCardButton.tsx b/src/rewards/Points/PointsCardButton.tsx index eeba1cd84c..b3b22f25e4 100644 --- a/src/rewards/Points/PointsCardButton.tsx +++ b/src/rewards/Points/PointsCardButton.tsx @@ -1,8 +1,8 @@ import { Icon } from "@chakra-ui/react" +import { ArrowRight } from "@phosphor-icons/react" import useGuild from "components/[guild]/hooks/useGuild" import Button from "components/common/Button" import Link from "next/link" -import { ArrowRight } from "phosphor-react" import { GuildPlatform } from "types" type Props = { diff --git a/src/rewards/Points/PointsCardMenu.tsx b/src/rewards/Points/PointsCardMenu.tsx index 2a6e2a6c9e..8142f1139e 100644 --- a/src/rewards/Points/PointsCardMenu.tsx +++ b/src/rewards/Points/PointsCardMenu.tsx @@ -1,8 +1,8 @@ import { MenuItem, useDisclosure } from "@chakra-ui/react" +import { PencilSimple } from "@phosphor-icons/react" import RemovePlatformMenuItem from "components/[guild]/AccessHub/components/RemovePlatformMenuItem" import PlatformCardMenu from "components/[guild]/RolePlatforms/components/PlatformCard/components/PlatformCardMenu" import useGuild from "components/[guild]/hooks/useGuild" -import { PencilSimple } from "phosphor-react" import EditPointsModal from "./EditPointsModal" type Props = { diff --git a/src/rewards/Points/index.tsx b/src/rewards/Points/index.tsx index 3a088085c2..30898dcfd6 100644 --- a/src/rewards/Points/index.tsx +++ b/src/rewards/Points/index.tsx @@ -1,13 +1,13 @@ -import { Star } from "phosphor-react" +import { Star } from "@phosphor-icons/react" +import dynamic from "next/dynamic" +import { AddRewardPanelLoadingSpinner } from "rewards/components/AddRewardPanelLoadingSpinner" +import LoadingRewardPreview from "rewards/components/LoadingRewardPreview" import { CardSettingsComponent, PlatformAsRewardRestrictions, RewardData, } from "rewards/types" import usePointsCardProps from "./usePointsCardProps" -import dynamic from "next/dynamic" -import LoadingRewardPreview from "rewards/components/LoadingRewardPreview" -import { AddRewardPanelLoadingSpinner } from "rewards/components/AddRewardPanelLoadingSpinner" export default { icon: Star, diff --git a/src/rewards/PolygonID/components/ConnectDIDModal.tsx b/src/rewards/PolygonID/components/ConnectDIDModal.tsx index 0aa8784103..6133115db2 100644 --- a/src/rewards/PolygonID/components/ConnectDIDModal.tsx +++ b/src/rewards/PolygonID/components/ConnectDIDModal.tsx @@ -11,13 +11,13 @@ import { Text, useBreakpointValue, } from "@chakra-ui/react" +import { ArrowsClockwise } from "@phosphor-icons/react" import useUser from "components/[guild]/hooks/useUser" import Button from "components/common/Button" import ErrorAlert from "components/common/ErrorAlert" import { env } from "env" import { useFetcherWithSign } from "hooks/useFetcherWithSign" import useToast from "hooks/useToast" -import { ArrowsClockwise } from "phosphor-react" import { QRCodeSVG } from "qrcode.react" import { useEffect } from "react" import useSWR from "swr" diff --git a/src/rewards/PolygonID/components/PolygonIDQRCodeModal.tsx b/src/rewards/PolygonID/components/PolygonIDQRCodeModal.tsx index bec23a387d..82501c78ee 100644 --- a/src/rewards/PolygonID/components/PolygonIDQRCodeModal.tsx +++ b/src/rewards/PolygonID/components/PolygonIDQRCodeModal.tsx @@ -1,4 +1,3 @@ -import { env } from "env" import { Box, Center, @@ -12,11 +11,12 @@ import { Text, useBreakpointValue, } from "@chakra-ui/react" +import { ArrowsClockwise } from "@phosphor-icons/react" import useGuild from "components/[guild]/hooks/useGuild" import useUser from "components/[guild]/hooks/useUser" import Button from "components/common/Button" import ErrorAlert from "components/common/ErrorAlert" -import { ArrowsClockwise } from "phosphor-react" +import { env } from "env" import { QRCodeSVG } from "qrcode.react" import useSWRImmutable from "swr/immutable" import { Role } from "types" diff --git a/src/rewards/PolygonID/index.ts b/src/rewards/PolygonID/index.ts index c614add528..3b4937c135 100644 --- a/src/rewards/PolygonID/index.ts +++ b/src/rewards/PolygonID/index.ts @@ -1,11 +1,11 @@ -import { Key } from "phosphor-react" -import usePolygonIDCardProps from "./usePolygonIDCardProps" -import PolygonIDCardButton from "./PolygonIDCardButton" -import PolygonIDCardMenu from "./PolygonIDCardMenu" -import { PlatformAsRewardRestrictions, RewardData } from "rewards/types" +import { Key } from "@phosphor-icons/react" import dynamic from "next/dynamic" import { AddRewardPanelLoadingSpinner } from "rewards/components/AddRewardPanelLoadingSpinner" import LoadingRewardPreview from "rewards/components/LoadingRewardPreview" +import { PlatformAsRewardRestrictions, RewardData } from "rewards/types" +import PolygonIDCardButton from "./PolygonIDCardButton" +import PolygonIDCardMenu from "./PolygonIDCardMenu" +import usePolygonIDCardProps from "./usePolygonIDCardProps" export default { icon: Key, diff --git a/src/rewards/SecretText/SecretTextCardMenu.tsx b/src/rewards/SecretText/SecretTextCardMenu.tsx index a4c52298c4..9f74586dff 100644 --- a/src/rewards/SecretText/SecretTextCardMenu.tsx +++ b/src/rewards/SecretText/SecretTextCardMenu.tsx @@ -1,8 +1,8 @@ import { MenuItem, useDisclosure } from "@chakra-ui/react" +import { PencilSimple } from "@phosphor-icons/react" import EditRewardAvailabilityMenuItem from "components/[guild]/AccessHub/components/EditRewardAvailabilityMenuItem" import RemovePlatformMenuItem from "components/[guild]/AccessHub/components/RemovePlatformMenuItem" import useGuild from "components/[guild]/hooks/useGuild" -import { PencilSimple } from "phosphor-react" import PlatformCardMenu from "../../components/[guild]/RolePlatforms/components/PlatformCard/components/PlatformCardMenu" import EditSecretTextModal from "./EditSecretTextModal" diff --git a/src/rewards/Telegram/index.ts b/src/rewards/Telegram/index.ts index 89b73e5be2..bb6f4b7f14 100644 --- a/src/rewards/Telegram/index.ts +++ b/src/rewards/Telegram/index.ts @@ -1,10 +1,10 @@ -import { TelegramLogo } from "phosphor-react" -import { PlatformAsRewardRestrictions, RewardData } from "rewards/types" -import useTelegramCardProps from "./useTelegramCardProps" -import TelegramCardMenu from "./TelegramCardMenu" +import { TelegramLogo } from "@phosphor-icons/react" import dynamic from "next/dynamic" import { AddRewardPanelLoadingSpinner } from "rewards/components/AddRewardPanelLoadingSpinner" import LoadingRewardPreview from "rewards/components/LoadingRewardPreview" +import { PlatformAsRewardRestrictions, RewardData } from "rewards/types" +import TelegramCardMenu from "./TelegramCardMenu" +import useTelegramCardProps from "./useTelegramCardProps" export default { icon: TelegramLogo, diff --git a/src/rewards/Token/ClaimTokenModal/ClaimTokenModal.tsx b/src/rewards/Token/ClaimTokenModal/ClaimTokenModal.tsx index 8bb1087c83..14428aa88a 100644 --- a/src/rewards/Token/ClaimTokenModal/ClaimTokenModal.tsx +++ b/src/rewards/Token/ClaimTokenModal/ClaimTokenModal.tsx @@ -15,6 +15,7 @@ import { Tooltip, VStack, } from "@chakra-ui/react" +import { ArrowSquareOut } from "@phosphor-icons/react" import useMembershipUpdate from "components/[guild]/JoinModal/hooks/useMembershipUpdate" import SwitchNetworkButton from "components/[guild]/Requirements/components/GuildCheckout/components/buttons/SwitchNetworkButton" import useIsBalanceSufficient from "components/[guild]/RolePlatforms/components/AddRoleRewardModal/components/AddTokenPanel/hooks/useIsBalanceSufficient" @@ -22,9 +23,8 @@ import AvailabilityTags from "components/[guild]/RolePlatforms/components/Platfo import Button from "components/common/Button" import { useCardBg } from "components/common/Card" import Image from "next/image" -import { ArrowSquareOut } from "phosphor-react" -import { claimTextButtonTooltipLabel } from "rewards/SecretText/TextCardButton" import { useMemo, useState } from "react" +import { claimTextButtonTooltipLabel } from "rewards/SecretText/TextCardButton" import { NULL_ADDRESS } from "utils/guildCheckout/constants" import { getRolePlatformStatus, diff --git a/src/rewards/Token/DynamicRewardCalculationTable.tsx b/src/rewards/Token/DynamicRewardCalculationTable.tsx index 692a14810c..c153c04683 100644 --- a/src/rewards/Token/DynamicRewardCalculationTable.tsx +++ b/src/rewards/Token/DynamicRewardCalculationTable.tsx @@ -1,9 +1,9 @@ import { HStack, Icon, Skeleton, Td, Text, Tr } from "@chakra-ui/react" +import { LockSimple, X } from "@phosphor-icons/react" import FeesTable from "components/[guild]/Requirements/components/GuildCheckout/components/FeesTable" import OptionImage from "components/common/StyledSelect/components/CustomSelectOption/components/OptionImage" -import { LockSimple, X } from "phosphor-react" -import rewards from "rewards" import { REQUIREMENT_PROVIDED_VALUES } from "requirements/requirements" +import rewards from "rewards" import { PlatformType, Requirement, RolePlatform } from "types" import useDynamicRewardUserAmount from "./hooks/useDynamicRewardUserAmount" diff --git a/src/rewards/Token/DynamicRewardModal.tsx b/src/rewards/Token/DynamicRewardModal.tsx index e15c90add6..34f4b4d8c7 100644 --- a/src/rewards/Token/DynamicRewardModal.tsx +++ b/src/rewards/Token/DynamicRewardModal.tsx @@ -23,11 +23,11 @@ import { useColorModeValue, useDisclosure, } from "@chakra-ui/react" +import { Lightning, PencilSimple, Question } from "@phosphor-icons/react" import RequirementDisplayComponent from "components/[guild]/Requirements/components/RequirementDisplayComponent" import useGuildPermission from "components/[guild]/hooks/useGuildPermission" import Card from "components/common/Card" import dynamic from "next/dynamic" -import { Lightning, PencilSimple, Question } from "phosphor-react" import { Requirement, RolePlatform } from "types" import DynamicRewardCalculationTable from "./DynamicRewardCalculationTable" diff --git a/src/rewards/Token/DynamicTypeForm.tsx b/src/rewards/Token/DynamicTypeForm.tsx index 5072c64153..363232cc3f 100644 --- a/src/rewards/Token/DynamicTypeForm.tsx +++ b/src/rewards/Token/DynamicTypeForm.tsx @@ -1,10 +1,10 @@ import { Circle, FormControl, Icon, useColorModeValue } from "@chakra-ui/react" +import { ListNumbers } from "@phosphor-icons/react" import CustomSnapshotForm from "components/[guild]/RolePlatforms/components/AddRoleRewardModal/components/AddTokenPanel/components/CustomSnapshotForm" import { SnapshotOption } from "components/[guild]/RolePlatforms/components/AddRoleRewardModal/components/AddTokenPanel/components/DynamicAmount" import GuildPointsSnapshotForm from "components/[guild]/RolePlatforms/components/AddRoleRewardModal/components/AddTokenPanel/components/GuildPointsSnapshotForm" import RadioSelect from "components/common/RadioSelect" import { Option } from "components/common/RadioSelect/RadioSelect" -import { ListNumbers } from "phosphor-react" import { useController, useFormContext } from "react-hook-form" import Star from "static/icons/star.svg" diff --git a/src/rewards/Token/EditTokenModal.tsx b/src/rewards/Token/EditTokenModal.tsx index 2248b7c3a1..c10a9d8925 100644 --- a/src/rewards/Token/EditTokenModal.tsx +++ b/src/rewards/Token/EditTokenModal.tsx @@ -17,6 +17,7 @@ import { Text, useDisclosure, } from "@chakra-ui/react" +import { Star } from "@phosphor-icons/react" import useEditRolePlatform from "components/[guild]/AccessHub/hooks/useEditRolePlatform" import useMembershipUpdate from "components/[guild]/JoinModal/hooks/useMembershipUpdate" import { AddTokenFormType } from "components/[guild]/RolePlatforms/components/AddRoleRewardModal/components/AddTokenPanel/AddTokenPanel" @@ -32,10 +33,9 @@ import OptionImage from "components/common/StyledSelect/components/CustomSelectO import useCreateRequirement from "components/create-guild/Requirements/hooks/useCreateRequirement" import useEditRequirement from "components/create-guild/Requirements/hooks/useEditRequirement" import useToast from "hooks/useToast" -import { Star } from "phosphor-react" -import { useTokenRewardContext } from "rewards/Token/TokenRewardContext" import { ReactNode, useMemo, useState } from "react" import { FormProvider, useForm } from "react-hook-form" +import { useTokenRewardContext } from "rewards/Token/TokenRewardContext" import Token from "static/icons/token.svg" import DynamicTypeForm from "./DynamicTypeForm" import useRolePlatformsOfReward from "./hooks/useRolePlatformsOfReward" diff --git a/src/rewards/Token/GeogatedCountryAlert.tsx b/src/rewards/Token/GeogatedCountryAlert.tsx index 5179e506b0..2e5fa3ad4d 100644 --- a/src/rewards/Token/GeogatedCountryAlert.tsx +++ b/src/rewards/Token/GeogatedCountryAlert.tsx @@ -10,10 +10,10 @@ import { PopoverTrigger, Portal, } from "@chakra-ui/react" +import { Chat } from "@phosphor-icons/react" import { triggerChat } from "components/_app/IntercomProvider" import Button from "components/common/Button" import { IpGeodata } from "pages/api/ip-geodata" -import { Chat } from "phosphor-react" import useSWRImmutable from "swr/immutable" const BLOCKED_COUNTRY_CODES = [ diff --git a/src/rewards/Token/PoolTag.tsx b/src/rewards/Token/PoolTag.tsx index 6f10170ae2..c78cfa087a 100644 --- a/src/rewards/Token/PoolTag.tsx +++ b/src/rewards/Token/PoolTag.tsx @@ -10,13 +10,13 @@ import { useColorMode, useDisclosure, } from "@chakra-ui/react" +import { Coin, DotsThreeVertical, Wallet } from "@phosphor-icons/react" import ClickableTagPopover from "components/[guild]/activity/ActivityLogAction/components/ClickableTagPopover" import useToast from "hooks/useToast" -import { Coin, DotsThreeVertical, Wallet } from "phosphor-react" +import { useRef } from "react" import FundPoolModal from "rewards/Token/FundPoolModal" import { useTokenRewardContext } from "rewards/Token/TokenRewardContext" import usePool from "rewards/Token/hooks/usePool" -import { useRef } from "react" import { formatUnits } from "viem" import WithdrawPoolModal from "./WithdrawPoolModal" diff --git a/src/rewards/Token/TokenConversionTag.tsx b/src/rewards/Token/TokenConversionTag.tsx index 86d56186ee..38782b6f54 100644 --- a/src/rewards/Token/TokenConversionTag.tsx +++ b/src/rewards/Token/TokenConversionTag.tsx @@ -1,10 +1,10 @@ import { Circle, Icon, Tag, Tooltip, useColorModeValue } from "@chakra-ui/react" +import { ArrowRight } from "@phosphor-icons/react" import { useAccessedGuildPoints } from "components/[guild]/AccessHub/hooks/useAccessedGuildPoints" import useRequirements from "components/[guild]/hooks/useRequirements" import GuildLogo from "components/common/GuildLogo" -import { ArrowRight } from "phosphor-react" -import { useTokenRewardContext } from "rewards/Token/TokenRewardContext" import { useMemo } from "react" +import { useTokenRewardContext } from "rewards/Token/TokenRewardContext" import Star from "static/icons/star.svg" import { RolePlatform } from "types" diff --git a/src/rewards/Token/TokenRewardCardEditMenu.tsx b/src/rewards/Token/TokenRewardCardEditMenu.tsx index a008d3afd5..0704dc381c 100644 --- a/src/rewards/Token/TokenRewardCardEditMenu.tsx +++ b/src/rewards/Token/TokenRewardCardEditMenu.tsx @@ -4,10 +4,10 @@ import { useColorModeValue, useDisclosure, } from "@chakra-ui/react" +import { Coin, Pencil, TrashSimple, Wallet } from "@phosphor-icons/react" import EditRewardAvailabilityMenuItem from "components/[guild]/AccessHub/components/EditRewardAvailabilityMenuItem" import PlatformCardMenu from "components/[guild]/RolePlatforms/components/PlatformCard/components/PlatformCardMenu" import useToast from "hooks/useToast" -import { Coin, Pencil, TrashSimple, Wallet } from "phosphor-react" import { GuildPlatform } from "types" import EditTokenModal from "./EditTokenModal" import FundPoolModal from "./FundPoolModal" diff --git a/src/rewards/UniqueText/UniqueTextCardMenu.tsx b/src/rewards/UniqueText/UniqueTextCardMenu.tsx index 23ca37c1e4..2bb7c760ac 100644 --- a/src/rewards/UniqueText/UniqueTextCardMenu.tsx +++ b/src/rewards/UniqueText/UniqueTextCardMenu.tsx @@ -1,8 +1,8 @@ import { MenuItem, useDisclosure } from "@chakra-ui/react" +import { PencilSimple } from "@phosphor-icons/react" import EditRewardAvailabilityMenuItem from "components/[guild]/AccessHub/components/EditRewardAvailabilityMenuItem" import RemovePlatformMenuItem from "components/[guild]/AccessHub/components/RemovePlatformMenuItem" import useGuild from "components/[guild]/hooks/useGuild" -import { PencilSimple } from "phosphor-react" import PlatformCardMenu from "../../components/[guild]/RolePlatforms/components/PlatformCard/components/PlatformCardMenu" import EditUniqueTextModal from "./EditUniqueTextModal" diff --git a/src/rewards/UniqueText/UniqueTextDataForm.tsx b/src/rewards/UniqueText/UniqueTextDataForm.tsx index 44ee948154..a3802b58aa 100644 --- a/src/rewards/UniqueText/UniqueTextDataForm.tsx +++ b/src/rewards/UniqueText/UniqueTextDataForm.tsx @@ -6,13 +6,13 @@ import { Text, Textarea, } from "@chakra-ui/react" +import { File } from "@phosphor-icons/react" import Button from "components/common/Button" import FormErrorMessage from "components/common/FormErrorMessage" import useDropzone from "hooks/useDropzone" -import { File } from "phosphor-react" -import PublicRewardDataForm from "rewards/SecretText/SecretTextDataForm/components/PublicRewardDataForm" import { PropsWithChildren, useState } from "react" import { useController, useFormContext, useWatch } from "react-hook-form" +import PublicRewardDataForm from "rewards/SecretText/SecretTextDataForm/components/PublicRewardDataForm" import Key from "static/icons/key.svg" export type UniqueTextRewardForm = { diff --git a/src/rewards/UniqueText/index.ts b/src/rewards/UniqueText/index.ts index 3f1415fe28..d5569653b2 100644 --- a/src/rewards/UniqueText/index.ts +++ b/src/rewards/UniqueText/index.ts @@ -1,10 +1,10 @@ -import { Key } from "phosphor-react" -import { PlatformAsRewardRestrictions, RewardData } from "rewards/types" -import useUniqueTextCardProps from "./useUniqueTextCardProps" -import TextCardButton from "rewards/SecretText/TextCardButton" -import UniqueTextCardMenu from "./UniqueTextCardMenu" +import { Key } from "@phosphor-icons/react" import dynamic from "next/dynamic" import LoadingRewardPreview from "rewards/components/LoadingRewardPreview" +import TextCardButton from "rewards/SecretText/TextCardButton" +import { PlatformAsRewardRestrictions, RewardData } from "rewards/types" +import UniqueTextCardMenu from "./UniqueTextCardMenu" +import useUniqueTextCardProps from "./useUniqueTextCardProps" export default { icon: Key, diff --git a/src/rewards/components/FormReward.tsx b/src/rewards/components/FormReward.tsx index c45a25cd39..c4328d6476 100644 --- a/src/rewards/components/FormReward.tsx +++ b/src/rewards/components/FormReward.tsx @@ -1,4 +1,5 @@ import { Skeleton, Tooltip } from "@chakra-ui/react" +import { ArrowRight } from "@phosphor-icons/react" import { RewardDisplay, RewardIcon, @@ -8,7 +9,6 @@ import useGuild from "components/[guild]/hooks/useGuild" import { useGuildForm } from "components/[guild]/hooks/useGuildForms" import Button from "components/common/Button" import Link from "next/link" -import { ArrowRight } from "phosphor-react" import { useUserFormSubmission } from "rewards/Forms/hooks/useFormSubmissions" const FormReward = ({ platform, withMotionImg }: RewardProps) => { diff --git a/src/rewards/components/GatherReward.tsx b/src/rewards/components/GatherReward.tsx index c7f12b6202..efbc6b2975 100644 --- a/src/rewards/components/GatherReward.tsx +++ b/src/rewards/components/GatherReward.tsx @@ -1,4 +1,5 @@ import { Icon, Spinner, Text, Tooltip } from "@chakra-ui/react" +import { ArrowSquareOut, LockSimple } from "@phosphor-icons/react" import { useOpenJoinModal } from "components/[guild]/JoinModal/JoinModalProvider" import { RewardDisplay, @@ -9,12 +10,11 @@ import AvailabilityTags from "components/[guild]/RolePlatforms/components/Platfo import useGuild from "components/[guild]/hooks/useGuild" import Button from "components/common/Button" import { useRoleMembership } from "components/explorer/hooks/useMembership" -import { ArrowSquareOut, LockSimple } from "phosphor-react" +import { useMemo } from "react" +import rewards from "rewards" import ClaimGatherModal from "rewards/Gather/ClaimGatherModal" import useClaimGather from "rewards/Gather/hooks/useClaimGather" import { claimTextButtonTooltipLabel } from "rewards/SecretText/TextCardButton" -import rewards from "rewards" -import { useMemo } from "react" import { PlatformType } from "types" import { getRolePlatformStatus, diff --git a/src/rewards/components/PoapReward.tsx b/src/rewards/components/PoapReward.tsx index 35a435ff7a..bd490de035 100644 --- a/src/rewards/components/PoapReward.tsx +++ b/src/rewards/components/PoapReward.tsx @@ -1,4 +1,5 @@ import { Tooltip } from "@chakra-ui/react" +import { ArrowRight } from "@phosphor-icons/react" import { RewardDisplay, RewardIcon, @@ -10,9 +11,8 @@ import Button from "components/common/Button" import { useClaimedReward } from "hooks/useClaimedReward" import dynamic from "next/dynamic" import Link from "next/link" -import { ArrowRight } from "phosphor-react" -import { claimTextButtonTooltipLabel } from "rewards/SecretText/TextCardButton" import rewards from "rewards" +import { claimTextButtonTooltipLabel } from "rewards/SecretText/TextCardButton" import { PlatformType } from "types" import { getRolePlatformStatus, diff --git a/src/rewards/components/PointsReward.tsx b/src/rewards/components/PointsReward.tsx index 884059d687..2619a91c6a 100644 --- a/src/rewards/components/PointsReward.tsx +++ b/src/rewards/components/PointsReward.tsx @@ -1,5 +1,6 @@ import { Link } from "@chakra-ui/next-js" import { Icon, Tooltip, useColorModeValue } from "@chakra-ui/react" +import { ArrowRight, Check } from "@phosphor-icons/react" import DynamicTag from "components/[guild]/RoleCard/components/DynamicReward/DynamicTag" import { RewardDisplay, @@ -8,7 +9,6 @@ import { } from "components/[guild]/RoleCard/components/Reward" import useGuild from "components/[guild]/hooks/useGuild" import { useRoleMembership } from "components/explorer/hooks/useMembership" -import { ArrowRight, Check } from "phosphor-react" import useDynamicRewardUserAmount from "rewards/Token/hooks/useDynamicRewardUserAmount" const PointsReward = ({ platform, withMotionImg }: RewardProps) => { diff --git a/src/rewards/components/PolygonIDReward.tsx b/src/rewards/components/PolygonIDReward.tsx index 8c70a8d17d..2e58aaf14b 100644 --- a/src/rewards/components/PolygonIDReward.tsx +++ b/src/rewards/components/PolygonIDReward.tsx @@ -1,4 +1,5 @@ import { Icon, Spinner, Tooltip } from "@chakra-ui/react" +import { ArrowSquareIn, LockSimple } from "@phosphor-icons/react" import { useOpenJoinModal } from "components/[guild]/JoinModal/JoinModalProvider" import { RewardDisplay, @@ -10,11 +11,10 @@ import Button from "components/common/Button" import useMembership, { useRoleMembership, } from "components/explorer/hooks/useMembership" -import { ArrowSquareIn, LockSimple } from "phosphor-react" +import { useMemo } from "react" +import rewards from "rewards" import { useMintPolygonIDProofContext } from "rewards/PolygonID/components/MintPolygonIDProofProvider" import useConnectedDID from "rewards/PolygonID/hooks/useConnectedDID" -import rewards from "rewards" -import { useMemo } from "react" import { PlatformType } from "types" const PolygonIDReward = ({ platform, withMotionImg }: RewardProps) => { diff --git a/src/rewards/components/RewardPreview.tsx b/src/rewards/components/RewardPreview.tsx index e365565608..004250bd86 100644 --- a/src/rewards/components/RewardPreview.tsx +++ b/src/rewards/components/RewardPreview.tsx @@ -9,9 +9,9 @@ import { Text, useColorModeValue, } from "@chakra-ui/react" -import { Question } from "phosphor-react" -import rewards from "rewards" +import { Question } from "@phosphor-icons/react" import { PropsWithChildren } from "react" +import rewards from "rewards" import { PlatformName } from "types" type Props = { diff --git a/src/rewards/components/TextReward.tsx b/src/rewards/components/TextReward.tsx index 29256fcdc6..85f14f3cc7 100644 --- a/src/rewards/components/TextReward.tsx +++ b/src/rewards/components/TextReward.tsx @@ -1,4 +1,5 @@ import { Icon, Spinner, Text, Tooltip } from "@chakra-ui/react" +import { ArrowSquareIn, LockSimple } from "@phosphor-icons/react" import { useOpenJoinModal } from "components/[guild]/JoinModal/JoinModalProvider" import { RewardDisplay, @@ -11,11 +12,10 @@ import Button from "components/common/Button" import useMembership, { useRoleMembership, } from "components/explorer/hooks/useMembership" -import { ArrowSquareIn, LockSimple } from "phosphor-react" +import { useMemo } from "react" +import rewards from "rewards" import { claimTextButtonTooltipLabel } from "rewards/SecretText/TextCardButton" import useClaimText, { ClaimTextModal } from "rewards/SecretText/hooks/useClaimText" -import rewards from "rewards" -import { useMemo } from "react" import { PlatformType } from "types" import { getRolePlatformStatus, diff --git a/src/rewards/components/TokenReward.tsx b/src/rewards/components/TokenReward.tsx index 1e2e2812cd..e843e1b3d3 100644 --- a/src/rewards/components/TokenReward.tsx +++ b/src/rewards/components/TokenReward.tsx @@ -1,4 +1,5 @@ import { Icon, Spinner, Tooltip } from "@chakra-ui/react" +import { ArrowSquareIn, LockSimple } from "@phosphor-icons/react" import { useOpenJoinModal } from "components/[guild]/JoinModal/JoinModalProvider" import DynamicTag from "components/[guild]/RoleCard/components/DynamicReward/DynamicTag" import { @@ -12,7 +13,7 @@ import Button from "components/common/Button" import useMembership, { useRoleMembership, } from "components/explorer/hooks/useMembership" -import { ArrowSquareIn, LockSimple } from "phosphor-react" +import { useMemo } from "react" import { claimTextButtonTooltipLabel } from "rewards/SecretText/TextCardButton" import ClaimTokenButton from "rewards/Token/ClaimTokenButton" import { useIsFromGeogatedCountry } from "rewards/Token/GeogatedCountryAlert" @@ -22,7 +23,6 @@ import { useTokenRewardContext, } from "rewards/Token/TokenRewardContext" import { useClaimableTokensForRolePlatform } from "rewards/Token/hooks/useCalculateToken" -import { useMemo } from "react" import { RolePlatform } from "types" import { getRolePlatformStatus, diff --git a/src/rewards/types.ts b/src/rewards/types.ts index 16656b643c..18c27c54b9 100644 --- a/src/rewards/types.ts +++ b/src/rewards/types.ts @@ -1,6 +1,6 @@ import type { ThemingProps } from "@chakra-ui/react" +import type { IconProps } from "@phosphor-icons/react" import type { RewardProps } from "components/[guild]/RoleCard/components/Reward" -import type { IconProps } from "phosphor-react" import type { ComponentType, ForwardRefExoticComponent, From ca644f45dad62244ef222b6b2b2e51c828204065 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?B=C3=A1lint=20Ferenczy?= <40574454+FBalint@users.noreply.github.com> Date: Tue, 2 Jul 2024 18:48:01 +0200 Subject: [PATCH 39/41] hotfix: skip free requirement creation (#1344) * hotfix(useCreateRequirements): skip free requirement creation * fix: when is preselected, role name was not set * fix(SelectRoleOrSetRequirements): set rolename, image and others as well * fix: wrap initNewRole in useCallback --- .eslintrc.json | 1 + .../hooks/useCreateRequirements.ts | 3 ++- .../SelectRoleOrSetRequirements.tsx | 23 ++++++++++--------- 3 files changed, 15 insertions(+), 12 deletions(-) diff --git a/.eslintrc.json b/.eslintrc.json index 4d2b814d88..892ef6271c 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -1,4 +1,5 @@ { + "parser": "@typescript-eslint/parser", "parserOptions": { "project": "./tsconfig.json" }, diff --git a/src/components/[guild]/AddRewardButton/hooks/useCreateRequirements.ts b/src/components/[guild]/AddRewardButton/hooks/useCreateRequirements.ts index f411c04945..ab0a64963c 100644 --- a/src/components/[guild]/AddRewardButton/hooks/useCreateRequirements.ts +++ b/src/components/[guild]/AddRewardButton/hooks/useCreateRequirements.ts @@ -25,9 +25,10 @@ const useCreateRequirements = () => { roleIds: number[] ) => { const requirementIdMap: RequirementIdMap = {} + const requirementsToCreate = requirements.filter((req) => req.type !== "FREE") const promises = roleIds.flatMap((roleId) => - requirements.map((req) => + requirementsToCreate.map((req) => fetcherWithSign([ `/v2/guilds/${guildId}/roles/${roleId}/requirements`, { diff --git a/src/rewards/components/SelectRoleOrSetRequirements.tsx b/src/rewards/components/SelectRoleOrSetRequirements.tsx index 3f36c6bd7d..ac9a145199 100644 --- a/src/rewards/components/SelectRoleOrSetRequirements.tsx +++ b/src/rewards/components/SelectRoleOrSetRequirements.tsx @@ -7,8 +7,9 @@ import RoleSelector from "components/[guild]/RoleSelector" import useGuild from "components/[guild]/hooks/useGuild" import useRoleGroup from "components/[guild]/hooks/useRoleGroup" import SetRequirements from "components/create-guild/Requirements" -import rewards, { PlatformAsRewardRestrictions } from "rewards" +import { useCallback, useEffect } from "react" import { useFormContext, useWatch } from "react-hook-form" +import rewards, { PlatformAsRewardRestrictions } from "rewards" import { PlatformName } from "types" import getRandomInt from "utils/getRandomInt" @@ -55,16 +56,16 @@ const SelectRoleOrSetRequirements = ({ isRoleSelectorDisabled }: Props) => { const { unregister, setValue } = useFormContext() const { selection, activeTab, setActiveTab } = useAddRewardContext() - const handleChange = (value: RoleTypeToAddTo) => { - if (value === RoleTypeToAddTo.NEW_ROLE) { - unregister("roleIds") - setValue("name", data?.roleName || `New ${rewards[selection].name} role`) - setValue("imageUrl", data?.imageUrl || `/guildLogos/${getRandomInt(286)}.svg`) - setValue("roleVisibility", "PUBLIC") - } + const initNewRole = useCallback(() => { + unregister("roleIds") + setValue("name", data?.roleName || `New ${rewards[selection].name} role`) + setValue("imageUrl", data?.imageUrl || `/guildLogos/${getRandomInt(286)}.svg`) + setValue("roleVisibility", "PUBLIC") + }, [data, selection, setValue, unregister]) - setActiveTab(value) - } + useEffect(() => { + if (activeTab === RoleTypeToAddTo.NEW_ROLE) initNewRole() + }, [activeTab, initNewRole]) const { asRewardRestriction } = rewards[selection] @@ -76,7 +77,7 @@ const SelectRoleOrSetRequirements = ({ isRoleSelectorDisabled }: Props) => { variant="solid" colorScheme="indigo" index={isRoleSelectorDisabled ? RoleTypeToAddTo.NEW_ROLE : activeTab} - onChange={handleChange} + onChange={setActiveTab} > Date: Tue, 2 Jul 2024 19:03:35 +0200 Subject: [PATCH 40/41] hotfix(SelectRoleOrSetRequirements): fix useEffect infinite dependency loop --- src/rewards/components/SelectRoleOrSetRequirements.tsx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/rewards/components/SelectRoleOrSetRequirements.tsx b/src/rewards/components/SelectRoleOrSetRequirements.tsx index ac9a145199..cdceac580d 100644 --- a/src/rewards/components/SelectRoleOrSetRequirements.tsx +++ b/src/rewards/components/SelectRoleOrSetRequirements.tsx @@ -7,7 +7,7 @@ import RoleSelector from "components/[guild]/RoleSelector" import useGuild from "components/[guild]/hooks/useGuild" import useRoleGroup from "components/[guild]/hooks/useRoleGroup" import SetRequirements from "components/create-guild/Requirements" -import { useCallback, useEffect } from "react" +import { useEffect } from "react" import { useFormContext, useWatch } from "react-hook-form" import rewards, { PlatformAsRewardRestrictions } from "rewards" import { PlatformName } from "types" @@ -56,16 +56,16 @@ const SelectRoleOrSetRequirements = ({ isRoleSelectorDisabled }: Props) => { const { unregister, setValue } = useFormContext() const { selection, activeTab, setActiveTab } = useAddRewardContext() - const initNewRole = useCallback(() => { + const initNewRole = () => { unregister("roleIds") setValue("name", data?.roleName || `New ${rewards[selection].name} role`) setValue("imageUrl", data?.imageUrl || `/guildLogos/${getRandomInt(286)}.svg`) setValue("roleVisibility", "PUBLIC") - }, [data, selection, setValue, unregister]) + } useEffect(() => { if (activeTab === RoleTypeToAddTo.NEW_ROLE) initNewRole() - }, [activeTab, initNewRole]) + }, [activeTab]) const { asRewardRestriction } = rewards[selection] From 12fcefde0c481df75775a7a068687feac2f51ea0 Mon Sep 17 00:00:00 2001 From: BrickheadJohnny Date: Wed, 3 Jul 2024 16:01:27 +0200 Subject: [PATCH 41/41] =?UTF-8?q?chore:=20use=20the=20new=20Fuel=20Guild?= =?UTF-8?q?=20Pin=20contract=20&=C2=A0re-enable=20minting?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Fuel/GuildPinContractAbi.d.ts | 168 ++---- .../Fuel/GuildPinContractAbi_factory.ts | 534 ++++++++++-------- .../Fuel/MintFuelGuildPinButton.tsx | 3 +- .../MintGuildPin/Fuel/common.d.ts | 30 +- .../Fuel/hooks/useAlreadyMinted.ts | 10 +- .../Fuel/hooks/useFuelGuildPinFee.ts | 8 +- .../Fuel/hooks/useMintFuelGuildPin.ts | 22 +- .../Fuel/hooks/useUsersFuelGuildPins.ts | 2 +- .../components/ActivateGuildPinForm.tsx | 11 +- 9 files changed, 380 insertions(+), 408 deletions(-) diff --git a/src/components/[guild]/Requirements/components/GuildCheckout/MintGuildPin/Fuel/GuildPinContractAbi.d.ts b/src/components/[guild]/Requirements/components/GuildCheckout/MintGuildPin/Fuel/GuildPinContractAbi.d.ts index b05f701bdc..187557bd2c 100644 --- a/src/components/[guild]/Requirements/components/GuildCheckout/MintGuildPin/Fuel/GuildPinContractAbi.d.ts +++ b/src/components/[guild]/Requirements/components/GuildCheckout/MintGuildPin/Fuel/GuildPinContractAbi.d.ts @@ -4,21 +4,21 @@ /* eslint-disable */ /* - Fuels version: 0.60.0 - Forc version: 0.44.0 - Fuel-Core version: 0.20.5 + Fuels version: 0.90.0 + Forc version: 0.60.0 + Fuel-Core version: 0.30.0 */ import type { BigNumberish, BN, - BytesLike, + Bytes, Contract, - DecodedValue, EvmAddress, FunctionFragment, Interface, InvokeFunction, + StdString, } from "fuels" import type { Enum, Option } from "./common" @@ -55,6 +55,24 @@ export enum InitErrorOutput { AlreadyInitialized = "AlreadyInitialized", NotInitialized = "NotInitialized", } +export enum InitializationErrorInput { + CannotReinitialized = "CannotReinitialized", +} +export enum InitializationErrorOutput { + CannotReinitialized = "CannotReinitialized", +} +export type MetadataInput = Enum<{ + B256: string + Bytes: Bytes + Int: BigNumberish + String: StdString +}> +export type MetadataOutput = Enum<{ + B256: string + Bytes: Bytes + Int: BN + String: StdString +}> export type StateInput = Enum<{ Uninitialized: [] Initialized: IdentityInput @@ -90,12 +108,10 @@ export enum TokenErrorOutput { CouldNotRemoveEntry = "CouldNotRemoveEntry", } -export type AddressInput = { value: string } +export type AddressInput = { bits: string } export type AddressOutput = AddressInput -export type AssetIdInput = { value: string } +export type AssetIdInput = { bits: string } export type AssetIdOutput = AssetIdInput -export type BytesInput = { buf: RawBytesInput; len: BigNumberish } -export type BytesOutput = { buf: RawBytesOutput; len: BN } export type ClaimParametersInput = { recipient: AddressInput action: GuildActionInput @@ -124,7 +140,7 @@ export type ClaimParametersOutput = { admin_fee: BN contract_id: ContractIdOutput } -export type ContractIdInput = { value: string } +export type ContractIdInput = { bits: string } export type ContractIdOutput = ContractIdInput export type ContractInitializedInput = { owner: IdentityInput @@ -140,18 +156,22 @@ export type ContractInitializedOutput = { } export type FeeChangedInput = { old: BigNumberish; new: BigNumberish } export type FeeChangedOutput = { old: BN; new: BN } -export type OwnerChangedInput = { old: IdentityInput; new: IdentityInput } -export type OwnerChangedOutput = { old: IdentityOutput; new: IdentityOutput } +export type OwnershipSetInput = { new_owner: IdentityInput } +export type OwnershipSetOutput = { new_owner: IdentityOutput } +export type OwnershipTransferredInput = { + new_owner: IdentityInput + previous_owner: IdentityInput +} +export type OwnershipTransferredOutput = { + new_owner: IdentityOutput + previous_owner: IdentityOutput +} export type PinBurnedInput = { pin_owner: AddressInput; pin_id: BigNumberish } export type PinBurnedOutput = { pin_owner: AddressOutput; pin_id: BN } export type PinMintedInput = { recipient: AddressInput; pin_id: BigNumberish } export type PinMintedOutput = { recipient: AddressOutput; pin_id: BN } -export type RawBytesInput = { ptr: BigNumberish; cap: BigNumberish } -export type RawBytesOutput = { ptr: BN; cap: BN } export type SignerChangedInput = { old: EvmAddress; new: EvmAddress } export type SignerChangedOutput = SignerChangedInput -export type StringInput = { bytes: BytesInput } -export type StringOutput = { bytes: BytesOutput } export type TreasuryChangedInput = { old: IdentityInput; new: IdentityInput } export type TreasuryChangedOutput = { old: IdentityOutput; new: IdentityOutput } @@ -189,110 +209,10 @@ interface GuildPinContractAbiInterface extends Interface { symbol: FunctionFragment total_assets: FunctionFragment total_supply: FunctionFragment - encoded_metadata: FunctionFragment metadata: FunctionFragment + encoded_metadata: FunctionFragment + pin_metadata: FunctionFragment } - - encodeFunctionData(functionFragment: "initialize", values: []): Uint8Array - encodeFunctionData(functionFragment: "set_fee", values: [BigNumberish]): Uint8Array - encodeFunctionData( - functionFragment: "set_owner", - values: [IdentityInput] - ): Uint8Array - encodeFunctionData( - functionFragment: "set_signer", - values: [EvmAddress] - ): Uint8Array - encodeFunctionData( - functionFragment: "set_treasury", - values: [IdentityInput] - ): Uint8Array - encodeFunctionData(functionFragment: "fee", values: []): Uint8Array - encodeFunctionData(functionFragment: "signer", values: []): Uint8Array - encodeFunctionData(functionFragment: "treasury", values: []): Uint8Array - encodeFunctionData(functionFragment: "burn", values: [BigNumberish]): Uint8Array - encodeFunctionData( - functionFragment: "claim", - values: [ClaimParametersInput, string] - ): Uint8Array - encodeFunctionData( - functionFragment: "balance_of", - values: [AddressInput] - ): Uint8Array - encodeFunctionData( - functionFragment: "pin_id_by_address", - values: [AddressInput, BigNumberish, GuildActionInput] - ): Uint8Array - encodeFunctionData( - functionFragment: "pin_id_by_user_id", - values: [BigNumberish, BigNumberish, GuildActionInput] - ): Uint8Array - encodeFunctionData( - functionFragment: "pin_owner", - values: [BigNumberish] - ): Uint8Array - encodeFunctionData(functionFragment: "total_minted", values: []): Uint8Array - encodeFunctionData( - functionFragment: "total_minted_per_guild", - values: [BigNumberish] - ): Uint8Array - encodeFunctionData(functionFragment: "owner", values: []): Uint8Array - encodeFunctionData( - functionFragment: "decimals", - values: [AssetIdInput] - ): Uint8Array - encodeFunctionData(functionFragment: "name", values: [AssetIdInput]): Uint8Array - encodeFunctionData(functionFragment: "symbol", values: [AssetIdInput]): Uint8Array - encodeFunctionData(functionFragment: "total_assets", values: []): Uint8Array - encodeFunctionData( - functionFragment: "total_supply", - values: [AssetIdInput] - ): Uint8Array - encodeFunctionData( - functionFragment: "encoded_metadata", - values: [BigNumberish] - ): Uint8Array - encodeFunctionData( - functionFragment: "metadata", - values: [BigNumberish] - ): Uint8Array - - decodeFunctionData(functionFragment: "initialize", data: BytesLike): DecodedValue - decodeFunctionData(functionFragment: "set_fee", data: BytesLike): DecodedValue - decodeFunctionData(functionFragment: "set_owner", data: BytesLike): DecodedValue - decodeFunctionData(functionFragment: "set_signer", data: BytesLike): DecodedValue - decodeFunctionData(functionFragment: "set_treasury", data: BytesLike): DecodedValue - decodeFunctionData(functionFragment: "fee", data: BytesLike): DecodedValue - decodeFunctionData(functionFragment: "signer", data: BytesLike): DecodedValue - decodeFunctionData(functionFragment: "treasury", data: BytesLike): DecodedValue - decodeFunctionData(functionFragment: "burn", data: BytesLike): DecodedValue - decodeFunctionData(functionFragment: "claim", data: BytesLike): DecodedValue - decodeFunctionData(functionFragment: "balance_of", data: BytesLike): DecodedValue - decodeFunctionData( - functionFragment: "pin_id_by_address", - data: BytesLike - ): DecodedValue - decodeFunctionData( - functionFragment: "pin_id_by_user_id", - data: BytesLike - ): DecodedValue - decodeFunctionData(functionFragment: "pin_owner", data: BytesLike): DecodedValue - decodeFunctionData(functionFragment: "total_minted", data: BytesLike): DecodedValue - decodeFunctionData( - functionFragment: "total_minted_per_guild", - data: BytesLike - ): DecodedValue - decodeFunctionData(functionFragment: "owner", data: BytesLike): DecodedValue - decodeFunctionData(functionFragment: "decimals", data: BytesLike): DecodedValue - decodeFunctionData(functionFragment: "name", data: BytesLike): DecodedValue - decodeFunctionData(functionFragment: "symbol", data: BytesLike): DecodedValue - decodeFunctionData(functionFragment: "total_assets", data: BytesLike): DecodedValue - decodeFunctionData(functionFragment: "total_supply", data: BytesLike): DecodedValue - decodeFunctionData( - functionFragment: "encoded_metadata", - data: BytesLike - ): DecodedValue - decodeFunctionData(functionFragment: "metadata", data: BytesLike): DecodedValue } export class GuildPinContractAbi extends Contract { @@ -322,11 +242,15 @@ export class GuildPinContractAbi extends Contract { total_minted_per_guild: InvokeFunction<[guild_id: BigNumberish], BN> owner: InvokeFunction<[], StateOutput> decimals: InvokeFunction<[asset: AssetIdInput], Option> - name: InvokeFunction<[asset: AssetIdInput], Option> - symbol: InvokeFunction<[asset: AssetIdInput], Option> + name: InvokeFunction<[asset: AssetIdInput], Option> + symbol: InvokeFunction<[asset: AssetIdInput], Option> total_assets: InvokeFunction<[], BN> total_supply: InvokeFunction<[asset: AssetIdInput], Option> - encoded_metadata: InvokeFunction<[pin_id: BigNumberish], StringOutput> - metadata: InvokeFunction<[pin_id: BigNumberish], StringOutput> + metadata: InvokeFunction< + [asset_id: AssetIdInput, key: StdString], + Option + > + encoded_metadata: InvokeFunction<[pin_id: BigNumberish], StdString> + pin_metadata: InvokeFunction<[pin_id: BigNumberish], StdString> } } diff --git a/src/components/[guild]/Requirements/components/GuildCheckout/MintGuildPin/Fuel/GuildPinContractAbi_factory.ts b/src/components/[guild]/Requirements/components/GuildCheckout/MintGuildPin/Fuel/GuildPinContractAbi_factory.ts index 517114cc5f..dd73df1783 100644 --- a/src/components/[guild]/Requirements/components/GuildCheckout/MintGuildPin/Fuel/GuildPinContractAbi_factory.ts +++ b/src/components/[guild]/Requirements/components/GuildCheckout/MintGuildPin/Fuel/GuildPinContractAbi_factory.ts @@ -4,9 +4,9 @@ /* eslint-disable */ /* - Fuels version: 0.60.0 - Forc version: 0.44.0 - Fuel-Core version: 0.20.5 + Fuels version: 0.90.0 + Forc version: 0.60.0 + Fuel-Core version: 0.30.0 */ import type { @@ -15,6 +15,7 @@ import type { BytesLike, DeployContractOptions, Provider, + StorageSlot, } from "fuels" import { Contract, ContractFactory, Interface } from "fuels" import type { @@ -23,6 +24,7 @@ import type { } from "./GuildPinContractAbi" const _abi = { + encoding: "1", types: [ { typeId: 0, @@ -88,12 +90,12 @@ const _abi = { components: [ { name: "Address", - type: 15, + type: 17, typeArguments: null, }, { name: "ContractId", - type: 20, + type: 22, typeArguments: null, }, ], @@ -118,6 +120,45 @@ const _abi = { }, { typeId: 7, + type: "enum InitializationError", + components: [ + { + name: "CannotReinitialized", + type: 0, + typeArguments: null, + }, + ], + typeParameters: null, + }, + { + typeId: 8, + type: "enum Metadata", + components: [ + { + name: "B256", + type: 2, + typeArguments: null, + }, + { + name: "Bytes", + type: 20, + typeArguments: null, + }, + { + name: "Int", + type: 34, + typeArguments: null, + }, + { + name: "String", + type: 32, + typeArguments: null, + }, + ], + typeParameters: null, + }, + { + typeId: 9, type: "enum Option", components: [ { @@ -127,14 +168,14 @@ const _abi = { }, { name: "Some", - type: 10, + type: 12, typeArguments: null, }, ], - typeParameters: [10], + typeParameters: [12], }, { - typeId: 8, + typeId: 10, type: "enum State", components: [ { @@ -156,7 +197,7 @@ const _abi = { typeParameters: null, }, { - typeId: 9, + typeId: 11, type: "enum TokenError", components: [ { @@ -213,41 +254,41 @@ const _abi = { typeParameters: null, }, { - typeId: 10, + typeId: 12, type: "generic T", components: null, typeParameters: null, }, { - typeId: 11, + typeId: 13, type: "raw untyped ptr", components: null, typeParameters: null, }, { - typeId: 12, + typeId: 14, type: "str[5]", components: null, typeParameters: null, }, { - typeId: 13, + typeId: 15, type: "str[64]", components: null, typeParameters: null, }, { - typeId: 14, + typeId: 16, type: "str[9]", components: null, typeParameters: null, }, { - typeId: 15, + typeId: 17, type: "struct Address", components: [ { - name: "value", + name: "bits", type: 2, typeArguments: null, }, @@ -255,11 +296,11 @@ const _abi = { typeParameters: null, }, { - typeId: 16, + typeId: 18, type: "struct AssetId", components: [ { - name: "value", + name: "bits", type: 2, typeArguments: null, }, @@ -267,11 +308,11 @@ const _abi = { typeParameters: null, }, { - typeId: 17, + typeId: 19, type: "struct B512", components: [ { - name: "bytes", + name: "bits", type: 1, typeArguments: null, }, @@ -279,29 +320,29 @@ const _abi = { typeParameters: null, }, { - typeId: 18, + typeId: 20, type: "struct Bytes", components: [ { name: "buf", - type: 27, + type: 30, typeArguments: null, }, { name: "len", - type: 31, + type: 34, typeArguments: null, }, ], typeParameters: null, }, { - typeId: 19, + typeId: 21, type: "struct ClaimParameters", components: [ { name: "recipient", - type: 15, + type: 17, typeArguments: null, }, { @@ -311,37 +352,37 @@ const _abi = { }, { name: "user_id", - type: 31, + type: 34, typeArguments: null, }, { name: "guild_id", - type: 31, + type: 34, typeArguments: null, }, { name: "guild_name", - type: 13, + type: 15, typeArguments: null, }, { name: "created_at", - type: 31, + type: 34, typeArguments: null, }, { name: "signed_at", - type: 31, + type: 34, typeArguments: null, }, { name: "chain_id", - type: 31, + type: 34, typeArguments: null, }, { name: "cid", - type: 13, + type: 15, typeArguments: null, }, { @@ -351,23 +392,23 @@ const _abi = { }, { name: "admin_fee", - type: 31, + type: 34, typeArguments: null, }, { name: "contract_id", - type: 20, + type: 22, typeArguments: null, }, ], typeParameters: null, }, { - typeId: 20, + typeId: 22, type: "struct ContractId", components: [ { - name: "value", + name: "bits", type: 2, typeArguments: null, }, @@ -375,7 +416,7 @@ const _abi = { typeParameters: null, }, { - typeId: 21, + typeId: 23, type: "struct ContractInitialized", components: [ { @@ -385,7 +426,7 @@ const _abi = { }, { name: "signer", - type: 22, + type: 24, typeArguments: null, }, { @@ -395,18 +436,18 @@ const _abi = { }, { name: "fee", - type: 31, + type: 34, typeArguments: null, }, ], typeParameters: null, }, { - typeId: 22, + typeId: 24, type: "struct EvmAddress", components: [ { - name: "value", + name: "bits", type: 2, typeArguments: null, }, @@ -414,33 +455,45 @@ const _abi = { typeParameters: null, }, { - typeId: 23, + typeId: 25, type: "struct FeeChanged", components: [ { name: "old", - type: 31, + type: 34, typeArguments: null, }, { name: "new", - type: 31, + type: 34, typeArguments: null, }, ], typeParameters: null, }, { - typeId: 24, - type: "struct OwnerChanged", + typeId: 26, + type: "struct OwnershipSet", components: [ { - name: "old", + name: "new_owner", + type: 5, + typeArguments: null, + }, + ], + typeParameters: null, + }, + { + typeId: 27, + type: "struct OwnershipTransferred", + components: [ + { + name: "new_owner", type: 5, typeArguments: null, }, { - name: "new", + name: "previous_owner", type: 5, typeArguments: null, }, @@ -448,87 +501,87 @@ const _abi = { typeParameters: null, }, { - typeId: 25, + typeId: 28, type: "struct PinBurned", components: [ { name: "pin_owner", - type: 15, + type: 17, typeArguments: null, }, { name: "pin_id", - type: 31, + type: 34, typeArguments: null, }, ], typeParameters: null, }, { - typeId: 26, + typeId: 29, type: "struct PinMinted", components: [ { name: "recipient", - type: 15, + type: 17, typeArguments: null, }, { name: "pin_id", - type: 31, + type: 34, typeArguments: null, }, ], typeParameters: null, }, { - typeId: 27, + typeId: 30, type: "struct RawBytes", components: [ { name: "ptr", - type: 11, + type: 13, typeArguments: null, }, { name: "cap", - type: 31, + type: 34, typeArguments: null, }, ], typeParameters: null, }, { - typeId: 28, + typeId: 31, type: "struct SignerChanged", components: [ { name: "old", - type: 22, + type: 24, typeArguments: null, }, { name: "new", - type: 22, + type: 24, typeArguments: null, }, ], typeParameters: null, }, { - typeId: 29, + typeId: 32, type: "struct String", components: [ { name: "bytes", - type: 18, + type: 20, typeArguments: null, }, ], typeParameters: null, }, { - typeId: 30, + typeId: 33, type: "struct TreasuryChanged", components: [ { @@ -545,13 +598,13 @@ const _abi = { typeParameters: null, }, { - typeId: 31, + typeId: 34, type: "u64", components: null, typeParameters: null, }, { - typeId: 32, + typeId: 35, type: "u8", components: null, typeParameters: null, @@ -577,7 +630,7 @@ const _abi = { inputs: [ { name: "fee", - type: 31, + type: 34, typeArguments: null, }, ], @@ -619,7 +672,7 @@ const _abi = { inputs: [ { name: "signer", - type: 22, + type: 24, typeArguments: null, }, ], @@ -662,7 +715,7 @@ const _abi = { name: "fee", output: { name: "", - type: 31, + type: 34, typeArguments: null, }, attributes: [ @@ -706,7 +759,7 @@ const _abi = { inputs: [ { name: "pin_id", - type: 31, + type: 34, typeArguments: null, }, ], @@ -727,12 +780,12 @@ const _abi = { inputs: [ { name: "params", - type: 19, + type: 21, typeArguments: null, }, { name: "signature", - type: 17, + type: 19, typeArguments: null, }, ], @@ -757,14 +810,14 @@ const _abi = { inputs: [ { name: "id", - type: 15, + type: 17, typeArguments: null, }, ], name: "balance_of", output: { name: "", - type: 31, + type: 34, typeArguments: null, }, attributes: [ @@ -778,12 +831,12 @@ const _abi = { inputs: [ { name: "user", - type: 15, + type: 17, typeArguments: null, }, { name: "guild_id", - type: 31, + type: 34, typeArguments: null, }, { @@ -795,11 +848,11 @@ const _abi = { name: "pin_id_by_address", output: { name: "", - type: 7, + type: 9, typeArguments: [ { name: "", - type: 31, + type: 34, typeArguments: null, }, ], @@ -815,12 +868,12 @@ const _abi = { inputs: [ { name: "user_id", - type: 31, + type: 34, typeArguments: null, }, { name: "guild_id", - type: 31, + type: 34, typeArguments: null, }, { @@ -832,11 +885,11 @@ const _abi = { name: "pin_id_by_user_id", output: { name: "", - type: 7, + type: 9, typeArguments: [ { name: "", - type: 31, + type: 34, typeArguments: null, }, ], @@ -852,18 +905,18 @@ const _abi = { inputs: [ { name: "pin_id", - type: 31, + type: 34, typeArguments: null, }, ], name: "pin_owner", output: { name: "", - type: 7, + type: 9, typeArguments: [ { name: "", - type: 15, + type: 17, typeArguments: null, }, ], @@ -880,7 +933,7 @@ const _abi = { name: "total_minted", output: { name: "", - type: 31, + type: 34, typeArguments: null, }, attributes: [ @@ -894,14 +947,14 @@ const _abi = { inputs: [ { name: "guild_id", - type: 31, + type: 34, typeArguments: null, }, ], name: "total_minted_per_guild", output: { name: "", - type: 31, + type: 34, typeArguments: null, }, attributes: [ @@ -916,7 +969,7 @@ const _abi = { name: "owner", output: { name: "", - type: 8, + type: 10, typeArguments: null, }, attributes: [ @@ -930,18 +983,18 @@ const _abi = { inputs: [ { name: "asset", - type: 16, + type: 18, typeArguments: null, }, ], name: "decimals", output: { name: "", - type: 7, + type: 9, typeArguments: [ { name: "", - type: 32, + type: 35, typeArguments: null, }, ], @@ -957,18 +1010,18 @@ const _abi = { inputs: [ { name: "asset", - type: 16, + type: 18, typeArguments: null, }, ], name: "name", output: { name: "", - type: 7, + type: 9, typeArguments: [ { name: "", - type: 29, + type: 32, typeArguments: null, }, ], @@ -984,18 +1037,18 @@ const _abi = { inputs: [ { name: "asset", - type: 16, + type: 18, typeArguments: null, }, ], name: "symbol", output: { name: "", - type: 7, + type: 9, typeArguments: [ { name: "", - type: 29, + type: 32, typeArguments: null, }, ], @@ -1012,7 +1065,7 @@ const _abi = { name: "total_assets", output: { name: "", - type: 31, + type: 34, typeArguments: null, }, attributes: [ @@ -1026,18 +1079,50 @@ const _abi = { inputs: [ { name: "asset", - type: 16, + type: 18, typeArguments: null, }, ], name: "total_supply", output: { name: "", - type: 7, + type: 9, typeArguments: [ { name: "", - type: 31, + type: 34, + typeArguments: null, + }, + ], + }, + attributes: [ + { + name: "storage", + arguments: ["read"], + }, + ], + }, + { + inputs: [ + { + name: "asset_id", + type: 18, + typeArguments: null, + }, + { + name: "key", + type: 32, + typeArguments: null, + }, + ], + name: "metadata", + output: { + name: "", + type: 9, + typeArguments: [ + { + name: "", + type: 8, typeArguments: null, }, ], @@ -1053,14 +1138,14 @@ const _abi = { inputs: [ { name: "pin_id", - type: 31, + type: 34, typeArguments: null, }, ], name: "encoded_metadata", output: { name: "", - type: 29, + type: 32, typeArguments: null, }, attributes: [ @@ -1074,14 +1159,14 @@ const _abi = { inputs: [ { name: "pin_id", - type: 31, + type: 34, typeArguments: null, }, ], - name: "metadata", + name: "pin_metadata", output: { name: "", - type: 29, + type: 32, typeArguments: null, }, attributes: [ @@ -1094,7 +1179,7 @@ const _abi = { ], loggedTypes: [ { - logId: 0, + logId: "2894384429946533623", loggedType: { name: "", type: 6, @@ -1102,23 +1187,23 @@ const _abi = { }, }, { - logId: 1, + logId: "2161305517876418151", loggedType: { name: "", - type: 21, + type: 7, typeArguments: [], }, }, { - logId: 2, + logId: "16280289466020123285", loggedType: { name: "", - type: 3, + type: 26, typeArguments: [], }, }, { - logId: 3, + logId: "14366998805467575349", loggedType: { name: "", type: 23, @@ -1126,7 +1211,7 @@ const _abi = { }, }, { - logId: 4, + logId: "4571204900286667806", loggedType: { name: "", type: 3, @@ -1134,87 +1219,7 @@ const _abi = { }, }, { - logId: 5, - loggedType: { - name: "", - type: 24, - typeArguments: [], - }, - }, - { - logId: 6, - loggedType: { - name: "", - type: 3, - typeArguments: [], - }, - }, - { - logId: 7, - loggedType: { - name: "", - type: 28, - typeArguments: [], - }, - }, - { - logId: 8, - loggedType: { - name: "", - type: 3, - typeArguments: [], - }, - }, - { - logId: 9, - loggedType: { - name: "", - type: 30, - typeArguments: [], - }, - }, - { - logId: 10, - loggedType: { - name: "", - type: 9, - typeArguments: [], - }, - }, - { - logId: 11, - loggedType: { - name: "", - type: 9, - typeArguments: [], - }, - }, - { - logId: 12, - loggedType: { - name: "", - type: 9, - typeArguments: [], - }, - }, - { - logId: 13, - loggedType: { - name: "", - type: 9, - typeArguments: [], - }, - }, - { - logId: 14, - loggedType: { - name: "", - type: 9, - typeArguments: [], - }, - }, - { - logId: 15, + logId: "2446762064164283588", loggedType: { name: "", type: 25, @@ -1222,83 +1227,73 @@ const _abi = { }, }, { - logId: 16, - loggedType: { - name: "", - type: 6, - typeArguments: [], - }, - }, - { - logId: 17, + logId: "12970362301975156672", loggedType: { name: "", - type: 9, - typeArguments: [], - }, - }, - { - logId: 18, - loggedType: { - name: "", - type: 9, + type: 27, typeArguments: [], }, }, { - logId: 19, + logId: "1176917155281974327", loggedType: { name: "", - type: 9, + type: 31, typeArguments: [], }, }, { - logId: 20, + logId: "15028988019905214435", loggedType: { name: "", - type: 9, + type: 33, typeArguments: [], }, }, { - logId: 21, + logId: "8391453796649435963", loggedType: { name: "", - type: 9, + type: 11, typeArguments: [], }, }, { - logId: 22, + logId: "7283728223483314652", loggedType: { name: "", - type: 9, + type: 28, typeArguments: [], }, }, { - logId: 23, + logId: "6914920428417705670", loggedType: { name: "", - type: 26, + type: 29, typeArguments: [], }, }, { - logId: 24, + logId: "11132648958528852192", loggedType: { name: "", - type: 9, + type: 32, typeArguments: [], }, }, { - logId: 25, + logId: "15587543869071072960", loggedType: { name: "", type: 9, - typeArguments: [], + typeArguments: [ + { + name: "", + type: 34, + typeArguments: null, + }, + ], }, }, ], @@ -1308,19 +1303,19 @@ const _abi = { name: "NAME", configurableType: { name: "", - type: 14, + type: 16, typeArguments: null, }, - offset: 147320, + offset: 86520, }, { name: "SYMBOL", configurableType: { name: "", - type: 12, + type: 14, typeArguments: null, }, - offset: 147336, + offset: 86536, }, { name: "OWNER", @@ -1329,7 +1324,7 @@ const _abi = { type: 5, typeArguments: [], }, - offset: 146552, + offset: 86296, }, { name: "SIGNER", @@ -1338,16 +1333,16 @@ const _abi = { type: 2, typeArguments: null, }, - offset: 146520, + offset: 86344, }, { name: "SIGNATURE_VALIDITY_PERIOD", configurableType: { name: "", - type: 31, + type: 34, typeArguments: null, }, - offset: 147168, + offset: 86488, }, { name: "TREASURY", @@ -1356,42 +1351,83 @@ const _abi = { type: 5, typeArguments: [], }, - offset: 146592, + offset: 86376, }, { name: "FEE", configurableType: { name: "", - type: 31, + type: 34, typeArguments: null, }, - offset: 146632, + offset: 86416, }, ], } -export class GuildPinContractAbi__factory { - static readonly abi = _abi - static createInterface(): GuildPinContractAbiInterface { - return new Interface(_abi as any) as unknown as GuildPinContractAbiInterface - } - static connect( +const _storageSlots: StorageSlot[] = [ + { + key: "0a860bae2f483542169820f52be34ca40c507a967660cdc5941c15815204bc4d", + value: "0000000000000000000000000000000000000000000000000000000000000000", + }, + { + key: "b48b753af346966d0d169c0b2e3234611f65d5cfdb57c7b6e7cd6ca93707bee0", + value: "0000000000000000000000000000000000000000000000000000000000000000", + }, + { + key: "c5e69153be998bc6f957aeb6f8fd46a0e9c5bc2d3dff421a73e02f64a3012fbb", + value: "0000000000000000000000000000000000000000000000000000000000000000", + }, + { + key: "d02e07f5a716bd3b6670aaf9a73352164e6b946c24db14f72005b7029e67d96a", + value: "0000000000000000000000000000000000000000000000000000000000000000", + }, + { + key: "de9090cb50e71c2588c773487d1da7066d0c719849a7e58dc8b6397a25c567c0", + value: "0000000000000000000000000000000000000000000000000000000000000000", + }, + { + key: "de9090cb50e71c2588c773487d1da7066d0c719849a7e58dc8b6397a25c567c1", + value: "0000000000000000000000000000000000000000000000000000000000000000", + }, + { + key: "f383b0ce51358be57daa3b725fe44acdb2d880604e367199080b4379c41bb6ed", + value: "0000000000000000000000000000000000000000000000000000000000000000", + }, +] + +export const GuildPinContractAbi__factory = { + abi: _abi, + + storageSlots: _storageSlots, + + createInterface(): GuildPinContractAbiInterface { + return new Interface(_abi) as unknown as GuildPinContractAbiInterface + }, + + connect( id: string | AbstractAddress, accountOrProvider: Account | Provider ): GuildPinContractAbi { return new Contract( id, - _abi as any, + _abi, accountOrProvider ) as unknown as GuildPinContractAbi - } - static async deployContract( + }, + + async deployContract( bytecode: BytesLike, wallet: Account, options: DeployContractOptions = {} ): Promise { - const factory = new ContractFactory(bytecode, _abi as any, wallet) - const contract = await factory.deployContract(options) + const factory = new ContractFactory(bytecode, _abi, wallet) + + const contract = await factory.deployContract({ + storageSlots: _storageSlots, + ...options, + }) + return contract as unknown as GuildPinContractAbi - } + }, } diff --git a/src/components/[guild]/Requirements/components/GuildCheckout/MintGuildPin/Fuel/MintFuelGuildPinButton.tsx b/src/components/[guild]/Requirements/components/GuildCheckout/MintGuildPin/Fuel/MintFuelGuildPinButton.tsx index 5f22a6cee8..a467436c4a 100644 --- a/src/components/[guild]/Requirements/components/GuildCheckout/MintGuildPin/Fuel/MintFuelGuildPinButton.tsx +++ b/src/components/[guild]/Requirements/components/GuildCheckout/MintGuildPin/Fuel/MintFuelGuildPinButton.tsx @@ -17,8 +17,9 @@ const MintFuelGuildPinButton = () => { const { data: fee, isValidating: isFeeValidating } = useFuelGuildPinFee() const { provider } = useProvider() + const { balance, isLoading: isBalanceValidating } = useBalance({ - address: provider.getBaseAssetId(), + address: provider?.getBaseAssetId(), }) const { data: alreadyMinted, isValidating: isAlreadyMintedValidating } = diff --git a/src/components/[guild]/Requirements/components/GuildCheckout/MintGuildPin/Fuel/common.d.ts b/src/components/[guild]/Requirements/components/GuildCheckout/MintGuildPin/Fuel/common.d.ts index c835c0c1c4..53a17b566d 100644 --- a/src/components/[guild]/Requirements/components/GuildCheckout/MintGuildPin/Fuel/common.d.ts +++ b/src/components/[guild]/Requirements/components/GuildCheckout/MintGuildPin/Fuel/common.d.ts @@ -4,22 +4,26 @@ /* eslint-disable */ /* - Fuels version: 0.60.0 - Forc version: 0.44.0 - Fuel-Core version: 0.20.5 + Fuels version: 0.90.0 + Forc version: 0.60.0 + Fuel-Core version: 0.30.0 */ -/* - Mimics Sway Enum, requires at least one Key-Value but - does not raise error on multiple pairs. - This is done in the abi-coder -*/ -export type Enum }> = Partial & U[keyof U] +/** + * Mimics Sway Enum. Requires one and only one Key-Value pair and raises error if + * more are provided. + */ +export type Enum = { + [K in keyof T]: Pick & { [P in Exclude]?: never } +}[keyof T] -/* - Mimics Sway Option and Vectors. - Vectors are treated like arrays in Typescript. -*/ +/** Mimics Sway Option and Vectors. Vectors are treated like arrays in Typescript. */ export type Option = T | undefined export type Vec = T[] + +/** + * Mimics Sway Result enum type. Ok represents the success case, while Err represents + * the error case. + */ +export type Result = Enum<{ Ok: T; Err: E }> diff --git a/src/components/[guild]/Requirements/components/GuildCheckout/MintGuildPin/Fuel/hooks/useAlreadyMinted.ts b/src/components/[guild]/Requirements/components/GuildCheckout/MintGuildPin/Fuel/hooks/useAlreadyMinted.ts index 2c406a1758..b8c0accc23 100644 --- a/src/components/[guild]/Requirements/components/GuildCheckout/MintGuildPin/Fuel/hooks/useAlreadyMinted.ts +++ b/src/components/[guild]/Requirements/components/GuildCheckout/MintGuildPin/Fuel/hooks/useAlreadyMinted.ts @@ -4,7 +4,7 @@ import useUser from "components/[guild]/hooks/useUser" import useSWRImmutable from "swr/immutable" import type { GuildActionInput } from "../GuildPinContractAbi" import { GuildPinContractAbi__factory } from "../GuildPinContractAbi_factory" -import { FUEL_GUILD_PIN_CONTRACT_ID } from "./useMintFuelGuildPin" +import { FUEL_GUILD_PIN_CONTRACT_ID_0X } from "./useMintFuelGuildPin" const useAlreadyMinted = () => { const { id: userId } = useUser() @@ -12,15 +12,19 @@ const useAlreadyMinted = () => { const { wallet } = useWallet() const getAlreadyMinted = async () => { + // Won't happen, just trying to make TS happy here + if (!guildId) throw new Error("Invalid guild ID") + if (!wallet) throw new Error("Couldn't find Fuel wallet") + const contract = GuildPinContractAbi__factory.connect( - FUEL_GUILD_PIN_CONTRACT_ID, + FUEL_GUILD_PIN_CONTRACT_ID_0X, wallet ) const { value } = await contract.functions .pin_id_by_user_id(userId, guildId, "Joined" as GuildActionInput) .simulate() - return value.gt(0) + return value?.gt(0) } return useSWRImmutable( diff --git a/src/components/[guild]/Requirements/components/GuildCheckout/MintGuildPin/Fuel/hooks/useFuelGuildPinFee.ts b/src/components/[guild]/Requirements/components/GuildCheckout/MintGuildPin/Fuel/hooks/useFuelGuildPinFee.ts index b8e1eb6886..07445c2c57 100644 --- a/src/components/[guild]/Requirements/components/GuildCheckout/MintGuildPin/Fuel/hooks/useFuelGuildPinFee.ts +++ b/src/components/[guild]/Requirements/components/GuildCheckout/MintGuildPin/Fuel/hooks/useFuelGuildPinFee.ts @@ -1,17 +1,19 @@ import { useWallet } from "@fuels/react" import useSWRImmutable from "swr/immutable" import { GuildPinContractAbi__factory } from "../GuildPinContractAbi_factory" -import { FUEL_GUILD_PIN_CONTRACT_ID } from "./useMintFuelGuildPin" +import { FUEL_GUILD_PIN_CONTRACT_ID_0X } from "./useMintFuelGuildPin" const useFuelGuildPinFee = () => { const { wallet } = useWallet() const getFee = async () => { + if (!wallet) throw new Error("Couldn't find Fuel wallet") + const contract = GuildPinContractAbi__factory.connect( - FUEL_GUILD_PIN_CONTRACT_ID, + FUEL_GUILD_PIN_CONTRACT_ID_0X, wallet ) - const { value } = await contract.functions.fee().simulate() + const { value } = await contract.functions.fee().get() return value } diff --git a/src/components/[guild]/Requirements/components/GuildCheckout/MintGuildPin/Fuel/hooks/useMintFuelGuildPin.ts b/src/components/[guild]/Requirements/components/GuildCheckout/MintGuildPin/Fuel/hooks/useMintFuelGuildPin.ts index 577b73dec2..a2785e5338 100644 --- a/src/components/[guild]/Requirements/components/GuildCheckout/MintGuildPin/Fuel/hooks/useMintFuelGuildPin.ts +++ b/src/components/[guild]/Requirements/components/GuildCheckout/MintGuildPin/Fuel/hooks/useMintFuelGuildPin.ts @@ -1,4 +1,3 @@ -import { env } from "env" /* eslint-disable @typescript-eslint/naming-convention */ import { useAccount, useProvider, useWallet } from "@fuels/react" import useGuild from "components/[guild]/hooks/useGuild" @@ -9,7 +8,7 @@ import { useToastWithTweetButton } from "hooks/useToast" import { useState } from "react" import fetcher from "utils/fetcher" import { useMintGuildPinContext } from "../../../MintGuildPinContext" -import type { GuildActionInput } from "../GuildPinContractAbi" +import type { ClaimParametersInput, GuildActionInput } from "../GuildPinContractAbi" import { GuildPinContractAbi__factory } from "../GuildPinContractAbi_factory" import parseFuelAddress from "../parseFuelAddress" import useFuelGuildPinFee from "./useFuelGuildPinFee" @@ -29,10 +28,8 @@ type FuelMintData = { signature: string } -export const FUEL_GUILD_PIN_CONTRACT_ID = - "fuel1yvn3x47tp8knyhfc9706qvuydsqxlnd8fj7ehcycepm9pfclskdseq9fz0" export const FUEL_GUILD_PIN_CONTRACT_ID_0X = - "0x23271357cb09ed325d382f9fa033846c006fcda74cbd9be098c87650a71f859b" + "0xb67efb48d800c5f5394163f5b5b4a9e6b06dc5c9e5fc3a49fa73e6b84bc3863b" export const FUEL_FAKE_CHAIN_ID = 123456789 const useMintFuelGuildPin = () => { @@ -82,14 +79,19 @@ const useMintFuelGuildPin = () => { setLoadingText("Check your wallet") + // We shouldn't run into these + if (!provider) throw new Error("Couldn't find Fuel provider") + if (!wallet) throw new Error("Couldn't find Fuel wallet") + if (typeof fee === "undefined") throw new Error("Couldn't fetch fee") + const contract = GuildPinContractAbi__factory.connect( - FUEL_GUILD_PIN_CONTRACT_ID, + FUEL_GUILD_PIN_CONTRACT_ID_0X, wallet ) const contractCallParams = { recipient: { - value: userAddress, + bits: userAddress, }, action: guildAction, user_id: userId, @@ -101,14 +103,14 @@ const useMintFuelGuildPin = () => { cid: cid.padEnd(64, " "), admin_treasury: { ContractId: { - value: adminTreasury, + bits: adminTreasury, }, }, admin_fee: adminFee, contract_id: { - value: contractAddress, + bits: contractAddress, }, - } as const + } as const satisfies ClaimParametersInput await contract.functions .claim(contractCallParams, signature) diff --git a/src/components/[guild]/Requirements/components/GuildCheckout/MintGuildPin/Fuel/hooks/useUsersFuelGuildPins.ts b/src/components/[guild]/Requirements/components/GuildCheckout/MintGuildPin/Fuel/hooks/useUsersFuelGuildPins.ts index a8fb051f3f..0954620229 100644 --- a/src/components/[guild]/Requirements/components/GuildCheckout/MintGuildPin/Fuel/hooks/useUsersFuelGuildPins.ts +++ b/src/components/[guild]/Requirements/components/GuildCheckout/MintGuildPin/Fuel/hooks/useUsersFuelGuildPins.ts @@ -23,7 +23,7 @@ const useUsersFuelGuildPins = (disabled = false) => { const fetchFuelGuildPins = async () => [] // TODO // const contract = GuildPinContractAbi__factory.connect( - // FUEL_GUILD_PIN_CONTRACT_ID, + // FUEL_GUILD_PIN_CONTRACT_ID_0X, // wallet // ) diff --git a/src/components/[guild]/Requirements/components/GuildCheckout/MintGuildPin/components/ActivateGuildPinForm.tsx b/src/components/[guild]/Requirements/components/GuildCheckout/MintGuildPin/components/ActivateGuildPinForm.tsx index 5bf19ecceb..55046601c8 100644 --- a/src/components/[guild]/Requirements/components/GuildCheckout/MintGuildPin/components/ActivateGuildPinForm.tsx +++ b/src/components/[guild]/Requirements/components/GuildCheckout/MintGuildPin/components/ActivateGuildPinForm.tsx @@ -1,9 +1,9 @@ -import { env } from "env" import { Checkbox, Stack, useColorModeValue } from "@chakra-ui/react" import useEditGuild from "components/[guild]/EditGuild/hooks/useEditGuild" import useGuild from "components/[guild]/hooks/useGuild" import Button from "components/common/Button" import useCreateRole from "components/create-guild/hooks/useCreateRole" +import { env } from "env" import useToast from "hooks/useToast" import { FormProvider, useController, useForm, useWatch } from "react-hook-form" import { traitsSupportedChains } from "requirements/Nft/NftForm" @@ -100,11 +100,10 @@ const ActivateGuildPinForm = (): JSX.Element => {