Skip to content

Commit

Permalink
Merge branch 'staging' of github.com:hackdays-io/mint-rally into staging
Browse files Browse the repository at this point in the history
  • Loading branch information
yu23ki14 committed Feb 16, 2024
2 parents e1c1e23 + 4d8e01e commit d4da6c7
Show file tree
Hide file tree
Showing 28 changed files with 1,061 additions and 121 deletions.
3 changes: 3 additions & 0 deletions frontend/.sentryclirc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@

[auth]
token=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
17 changes: 17 additions & 0 deletions frontend/src/components/molecules/EventGroupTab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ const EventGroupTab: FC<Props> = ({ group }) => {
return 1;
case router.asPath.includes("role"):
return 2;
case router.asPath.includes("transfer"):
return 3;
default:
break;
}
Expand Down Expand Up @@ -81,6 +83,21 @@ const EventGroupTab: FC<Props> = ({ group }) => {
{t.RBAC_EDIT_COLLABORATORS}
</Tab>
)}
{(group.ownerAddress === address) && (
<Tab
_selected={{
borderColor: "mintGreen.300",
borderWidth: 1,
borderBottom: "none",
backgroundColor: "mintGreen.50",
}}
onClick={() =>
router.push(`/event-groups/${router.query.eventgroupid}/transfer`)
}
>
{t.EVENT_GROUP_TAB_TRANSFER}
</Tab>
)}
</TabList>
</Tabs>
);
Expand Down
102 changes: 102 additions & 0 deletions frontend/src/components/molecules/EventTransferLock.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
import { Box, Button, Flex, Grid, Spinner, Text } from "@chakra-ui/react";
import { BigNumber } from "ethers";
import { FC, useEffect } from "react";
import { useIsNonTransferable, useTransferLock } from "src/hooks/useMintNFT";
import AlertMessage from "../atoms/form/AlertMessage";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import { faLock, faLockOpen } from "@fortawesome/free-solid-svg-icons";
import { useLocale } from "src/hooks/useLocale";

type Props = {
eventId: BigNumber;
};

const EventTransferLock: FC<Props> = ({ eventId }) => {
const { t } = useLocale();
const { isNonTransferable, refetch, isLoading } =
useIsNonTransferable(eventId);

const {
lock,
isLoading: isLocking,
error,
isSuccess,
status,
} = useTransferLock(eventId, !isNonTransferable);

useEffect(() => {
refetch();
}, [status]);

return (
<>
<Text fontWeight="bold">{t.EVENT_TRANSFERLOCK_SETTING}</Text>
<Text color="grey.600" fontSize="sm" mb={3}>
{t.EVENT_TRANSFERLOCK_SETTING_DESC}
</Text>
{isLoading ? (
<Spinner />
) : (
<Box>
<Flex alignItems="center">
<Flex
borderRadius="full"
backgroundColor="white"
p={2}
alignItems="center"
>
<Box
as="span"
color={isNonTransferable ? "mintGreen.800" : "yellow.800"}
background={isNonTransferable ? "gray.300" : "yellow.300"}
width="40px"
height="40px"
borderRadius="full"
display="inline-flex"
justifyContent="center"
alignItems="center"
mr={2}
>
<FontAwesomeIcon
icon={isNonTransferable ? faLock : faLockOpen}
/>
</Box>
<Box>
<Text fontSize="sm" color="yellow.800">
{isNonTransferable
? t.EVENT_ISNONTRANSFERABLE_TRUE
: t.EVENT_ISNONTRANSFERABLE_FALSE}
</Text>
<Text fontSize="xs" color="gray.600">
{isNonTransferable
? t.EVENT_ISNONTRANSFERABLE_TRUE_DESC
: t.EVENT_ISNONTRANSFERABLE_FALSE_DESC}
</Text>
</Box>
</Flex>
<Button
ml={3}
size="sm"
disabled={isLocking}
isLoading={isLocking}
onClick={() => lock()}
backgroundColor="transparent"
border="1px solid"
borderColor="yellow.800"
color="yellow.800"
>
{t.EVENT_ADMIN_SUBMIT}
</Button>
</Flex>
</Box>
)}
{error && (
<AlertMessage title={t.EVENT_TRANSFERLOCK_FAIL}>
{(error as any).reason}
</AlertMessage>
)}
</>
);
};

export default EventTransferLock;
40 changes: 37 additions & 3 deletions frontend/src/components/organisms/CreateEventForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ export interface EventFormData {
secretPhrase: string;
mintLimit: number;
useMtx: "true" | "false";
nonTransferable: "true" | "false";
nfts: NFT.NFTImage[];
}

Expand Down Expand Up @@ -89,7 +90,8 @@ const CreateEventForm: FC<Props> = ({ address }) => {
endTime: "",
secretPhrase: "",
mintLimit: 10,
useMtx: undefined,
useMtx: "false",
nonTransferable: "false",
nfts: [
{
name: "",
Expand Down Expand Up @@ -138,6 +140,7 @@ const CreateEventForm: FC<Props> = ({ address }) => {
secretPhrase: formData.secretPhrase,
mintLimit: Number(formData.mintLimit),
useMtx: formData.useMtx === "true",
nonTransferable: formData.nonTransferable === "true",
attributes: nftAttributes,
};
await createEvent(params);
Expand Down Expand Up @@ -191,7 +194,6 @@ const CreateEventForm: FC<Props> = ({ address }) => {
);
if (foundEvent && copiedPastEventId) {
const pastAttributeRecords = await copyPastAttribute(copiedPastEventId);
console.log(pastAttributeRecords);

setValue("eventName", foundEvent.name);
setValue("description", foundEvent.description);
Expand Down Expand Up @@ -557,7 +559,7 @@ const CreateEventForm: FC<Props> = ({ address }) => {
formState: { errors },
}) => (
<>
<RadioGroup onChange={onChange}>
<RadioGroup onChange={onChange} value={value}>
<Radio value="false" mr={6}>
{t.EVENT_USE_MTX_FALSE}
</Radio>
Expand All @@ -579,6 +581,38 @@ const CreateEventForm: FC<Props> = ({ address }) => {
)}
</FormControl>

<FormControl mb={5}>
<FormLabel mb={0}>{t.EVENT_USE_NTT}</FormLabel>

<Text fontSize="sm" mb={3} color="gray.600">
{t.EVENT_USE_NTT_DESC}
</Text>

<Controller
control={control}
name="nonTransferable"
rules={{
required: "required",
}}
render={({
field: { onChange, value },
formState: { errors },
}) => (
<>
<RadioGroup onChange={onChange} value={value}>
<Radio value="false" mr={6}>
{t.EVENT_USE_NTT_FALSE}
</Radio>
<Radio value="true">{t.EVENT_USE_NTT_TRUE}</Radio>
</RadioGroup>
<ErrorMessage>
{errors.nonTransferable?.message}
</ErrorMessage>
</>
)}
/>
</FormControl>

<FormControl mb={5}>
<FormLabel htmlFor="secret">
{t.EVENT_SECRETPHRASE}
Expand Down
5 changes: 5 additions & 0 deletions frontend/src/components/organisms/EventEditSection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { FC, useMemo } from "react";
import { useCollaboratorAccessEventGroups } from "src/hooks/useEvent";
import { Event } from "types/Event";
import EventMintLock from "../molecules/EventMintLock";
import EventTransferLock from "../molecules/EventTransferLock";
import ResetSecretPhrase from "../molecules/ResetSecretPhrase";
import { useLocale } from "src/hooks/useLocale";
import DropNFTs from "./nft/DropNFTs";
Expand Down Expand Up @@ -44,6 +45,10 @@ const EventEditSection: FC<Props> = ({ event }) => {

<Divider my={3} />

<EventTransferLock eventId={event.eventRecordId} />

<Divider my={3} />

<ResetSecretPhrase eventId={event.eventRecordId} />

<Divider my={3} />
Expand Down
33 changes: 31 additions & 2 deletions frontend/src/contracts/EventManager.json

Large diffs are not rendered by default.

Loading

0 comments on commit d4da6c7

Please sign in to comment.