Skip to content

Commit

Permalink
Merge branch 'develop' into fix-address-input-field-validation
Browse files Browse the repository at this point in the history
  • Loading branch information
adamgall committed Sep 20, 2024
2 parents 677d0f0 + 630149c commit 02d4c86
Show file tree
Hide file tree
Showing 20 changed files with 725 additions and 271 deletions.
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
20.16.0
20.17.0
411 changes: 269 additions & 142 deletions package-lock.json

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
"viem": "^2.13.1",
"vite": "^5.1.0",
"vite-plugin-checker": "^0.6.4",
"wagmi": "^2.9.7",
"wagmi": "^2.12.12",
"yup": "^1",
"zustand": "^4.5.2"
},
Expand All @@ -83,8 +83,8 @@
"postinstall": "npm run graphql:build"
},
"engines": {
"node": "20.16.0",
"npm": "10.8.1"
"node": "20.17.0",
"npm": "10.8.2"
},
"browserslist": {
"production": [
Expand Down
59 changes: 0 additions & 59 deletions src/components/pages/DAOTreasury/sendAssets.ts

This file was deleted.

7 changes: 5 additions & 2 deletions src/components/pages/Roles/RoleCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,10 @@ export function RoleCardShort({
handleRoleClick: () => void;
}) {
return (
<Card onClick={handleRoleClick}>
<Card
cursor={'pointer'}
onClick={handleRoleClick}
>
<Flex justifyContent="space-between">
<Text
textStyle="display-lg"
Expand All @@ -270,7 +273,7 @@ export function RoleCardShort({
<EditBadge editStatus={editStatus} />
<Icon
as={CaretCircleRight}
color="white-0"
color="lilac-0"
boxSize="1.5rem"
/>
</Flex>
Expand Down
17 changes: 9 additions & 8 deletions src/components/pages/Roles/RolePaymentDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@ import { useTranslation } from 'react-i18next';
import { useNavigate } from 'react-router-dom';
import { Address, getAddress, Hex } from 'viem';
import { useAccount, usePublicClient } from 'wagmi';
import { NEUTRAL_2_82_TRANSPARENT, CARD_SHADOW } from '../../../constants/common';
import {
NEUTRAL_2_82_TRANSPARENT,
CARD_SHADOW,
DETAILS_BOX_SHADOW,
} from '../../../constants/common';
import { DAO_ROUTES } from '../../../constants/routes';
import { useFractal } from '../../../providers/App/AppProvider';
import { useNetworkConfig } from '../../../providers/NetworkConfig/NetworkConfigProvider';
Expand All @@ -18,9 +22,6 @@ import { ModalType } from '../../ui/modals/ModalProvider';
import { useDecentModal } from '../../ui/modals/useDecentModal';
import { RoleFormValues } from './types';

const PAYMENT_DETAILS_BOX_SHADOW =
'0px 0px 0px 1px #100414, 0px 0px 0px 1px rgba(248, 244, 252, 0.04) inset, 0px 1px 0px 0px rgba(248, 244, 252, 0.04) inset';

function CancelStreamMenu({
streamId,
paymentIsCancelling,
Expand Down Expand Up @@ -76,7 +77,7 @@ function CancelStreamMenu({
return (
<Flex
justifyContent="flex-end"
boxShadow={PAYMENT_DETAILS_BOX_SHADOW}
boxShadow={DETAILS_BOX_SHADOW}
borderTopRadius="0.5rem"
w="full"
py="0.25rem"
Expand Down Expand Up @@ -293,7 +294,7 @@ export function RolePaymentDetails({
? {
bg: 'neutral-2',
sx: undefined,
boxShadow: PAYMENT_DETAILS_BOX_SHADOW,
boxShadow: DETAILS_BOX_SHADOW,
}
: {
sx: {
Expand Down Expand Up @@ -416,7 +417,7 @@ export function RolePaymentDetails({
borderLeft="1px solid"
borderColor="white-alpha-08"
h="full"
boxShadow={PAYMENT_DETAILS_BOX_SHADOW}
boxShadow={DETAILS_BOX_SHADOW}
w="0"
/>
</GridItem>
Expand All @@ -431,7 +432,7 @@ export function RolePaymentDetails({
borderLeft="1px solid"
borderColor="white-alpha-08"
h="full"
boxShadow={PAYMENT_DETAILS_BOX_SHADOW}
boxShadow={DETAILS_BOX_SHADOW}
w="0"
/>
</GridItem>
Expand Down
131 changes: 110 additions & 21 deletions src/components/pages/Roles/forms/RoleFormCreateProposal.tsx
Original file line number Diff line number Diff line change
@@ -1,25 +1,83 @@
import { Box, Button, Flex, FormControl, Show } from '@chakra-ui/react';
import { Box, Button, Flex, FormControl, Show, Text, Icon } from '@chakra-ui/react';
import { SquaresFour, ArrowsDownUp, Trash } from '@phosphor-icons/react';
import { Field, FieldProps, useFormikContext } from 'formik';
import { useCallback, useMemo, useState } from 'react';
import { useTranslation } from 'react-i18next';
import { useNavigate } from 'react-router-dom';
import { getAddress, Hex } from 'viem';
import { formatUnits, getAddress, Hex } from 'viem';
import { CARD_SHADOW } from '../../../../constants/common';
import { DAO_ROUTES } from '../../../../constants/routes';
import useDisplayName from '../../../../hooks/utils/useDisplayName';
import { useFractal } from '../../../../providers/App/AppProvider';
import { useNetworkConfig } from '../../../../providers/NetworkConfig/NetworkConfigProvider';
import { Card } from '../../../ui/cards/Card';
import { CustomNonceInput } from '../../../ui/forms/CustomNonceInput';
import { InputComponent, TextareaComponent } from '../../../ui/forms/InputComponent';
import LabelWrapper from '../../../ui/forms/LabelWrapper';
import { AddActions } from '../../../ui/modals/AddActions';
import { SendAssetsData } from '../../../ui/modals/SendAssetsModal';
import { RoleCardShort } from '../RoleCard';
import RolesDetailsDrawer from '../RolesDetailsDrawer';
import RolesDetailsDrawerMobile from '../RolesDetailsDrawerMobile';
import { EditedRole, RoleDetailsDrawerRoleHatProp, RoleFormValues } from '../types';

function SendAssetsAction({
index,
action,
onRemove,
}: {
index: number;
action: SendAssetsData;
onRemove: (index: number) => void;
}) {
const { t } = useTranslation('common');
const { displayName } = useDisplayName(action.destinationAddress);

return (
<Card my="1rem">
<Flex justifyContent="space-between">
<Flex
alignItems="center"
gap="0.5rem"
>
<Icon
as={ArrowsDownUp}
w="1.5rem"
h="1.5rem"
color="lilac-0"
/>
<Text>{t('transfer')}</Text>
<Text color="lilac-0">
{formatUnits(action.transferAmount, action.asset.decimals)} {action.asset.symbol}
</Text>
<Text>{t('to').toLowerCase()}</Text>
<Text color="lilac-0">{displayName}</Text>
</Flex>
<Button
color="red-0"
variant="tertiary"
size="sm"
onClick={() => {
onRemove(index);
}}
>
<Icon as={Trash} />
</Button>
</Flex>
</Card>
);
}

export default function RoleFormCreateProposal({ close }: { close: () => void }) {
const [drawerViewingRole, setDrawerViewingRole] = useState<RoleDetailsDrawerRoleHatProp>();
const { t } = useTranslation(['modals', 'common', 'proposal']);
const { values, isSubmitting, submitForm } = useFormikContext<RoleFormValues>();
const {
values,
setFieldValue: setFieldValueTopLevel,
isSubmitting,
submitForm,
} = useFormikContext<RoleFormValues>();

const editedRoles = useMemo<
(RoleDetailsDrawerRoleHatProp & {
editedRole: EditedRole;
Expand Down Expand Up @@ -80,6 +138,10 @@ export default function RoleFormCreateProposal({ close }: { close: () => void })

const handleCloseDrawer = () => setDrawerViewingRole(undefined);

const addSendAssetsAction = (sendAssetsAction: SendAssetsData) => {
setFieldValueTopLevel('actions', [...values.actions, sendAssetsAction]);
};

return (
<Box maxW="736px">
<Flex
Expand Down Expand Up @@ -155,25 +217,52 @@ export default function RoleFormCreateProposal({ close }: { close: () => void })
</Field>
</FormControl>
</Flex>
<Box
p="1rem"
bg="neutral-2"
boxShadow={CARD_SHADOW}
borderRadius="0.5rem"

<Flex
mt={4}
mb={2}
alignItems="center"
>
{editedRoles.map((role, index) => {
return (
<RoleCardShort
key={index}
name={role.name}
handleRoleClick={() => {
setDrawerViewingRole(role);
}}
editStatus={role.editedRole?.status}
/>
);
})}
</Box>
<Icon
as={SquaresFour}
w="1.5rem"
h="1.5rem"
/>
<Text
textStyle="display-lg"
ml={2}
>
{t('actions', { ns: 'actions' })}
</Text>
</Flex>
{editedRoles.map((role, index) => {
return (
<RoleCardShort
key={index}
name={role.name}
handleRoleClick={() => {
setDrawerViewingRole(role);
}}
editStatus={role.editedRole?.status}
/>
);
})}
{values.actions.map((action, index) => (
<SendAssetsAction
action={action}
key={index}
index={index}
onRemove={idx => {
setFieldValueTopLevel(
'actions',
values.actions.filter((_, i) => i !== idx),
);
}}
/>
))}

<AddActions addSendAssetsAction={addSendAssetsAction} />

<Flex
gap="1rem"
mt="1rem"
Expand Down
2 changes: 2 additions & 0 deletions src/components/pages/Roles/types.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Address, Hex } from 'viem';
import { DecentRoleHat } from '../../../store/roles';
import { BigIntValuePair, CreateProposalMetadata } from '../../../types';
import { SendAssetsData } from '../../ui/modals/SendAssetsModal';

export interface SablierAsset {
address: Address;
Expand Down Expand Up @@ -131,6 +132,7 @@ export interface RoleFormValues {
hats: RoleHatFormValue[];
roleEditing?: RoleHatFormValue;
customNonce?: number;
actions: SendAssetsData[];
}

export type PreparedAddedHatsData = HatStruct & { id: bigint };
Expand Down
Loading

0 comments on commit 02d4c86

Please sign in to comment.