Skip to content

Commit

Permalink
Feature/672 rage quit (#865)
Browse files Browse the repository at this point in the history
* Publish new lib versions. (#412)

* fix/fix-table-types (#354)

* removed the any types from hub

* renamed Table to DaoTable and DataTable to DaoTable to be more consistent with DaoCard

* removed commented out DaoData type

* one more comment -- thought i got both before

* Fix/355 summon params mixup (#356)

* more ignore

* fixes bad init params order in summon tx

* Feature/tag component (#349)

* Created basic tag component

* Added dynamic color selections for tags

* Bumped versions fixed filer

* Added icon support to tag component

Co-authored-by: Jord <[email protected]>
Co-authored-by: Jonathan Prozzi <[email protected]>

* Feature/delegate play (#357)

* more ignore

* fixes bad init params order in summon tx

* delegate testing and subgraph field updates

* finishes mapping

* update dao-data query and transformer

* adds delegate tag to list view and hooks up delegate filtering

* refactors filter into query helper

* Spencer's Summon tooltip suggestions (#370)

* Spencer's Summon tooltip suggestions

- Summon portion of #365 

* Delimiter references

#368

For now, just referencing spaces. But if tabs, commas, or other delimiters are also supported, those should be references in the tooltips as well.

* Address Jord's comments

Co-authored-by: Sam Kuhlmann <[email protected]>

* Fix/summon poll (#375)

* more ignore

* fixes bad init params order in summon tx

* delegate testing and subgraph field updates

* finishes mapping

* update dao-data query and transformer

* adds delegate tag to list view and hooks up delegate filtering

* adds schema field to tx entity

* updates poll for tx entity made before dao entity

* Feature/alpha baal update (#376)

* new abis

* updates summoner tx logic and contract addresses

* fixes transaction entity creation location;

* fixes some test

* Feature/unit utils (#380)

* create custom d.ts for human-format

* type and convert unit fn from V2

* readableNumber util accepts number strings, throws error if string but number string

* fix 0 to 1 utils, extend MaxDecimals to shorten decimal places

* refine spacer and unit symbol placement

* update new card to handle new params

* update table

* corrections

* alter d.ts file

* potential solutions to ts bug

* implement keating's d.ts fix

* fix comment

* Fix/network switcher (#381)

* better error handling

* fix bug

* remove log

* get react-table TS to stop yelling (#382)

Co-authored-by: Sam Kuhlmann <[email protected]>

* Feature/hub sort (#383)

* wip

* gets query working on dao entity after lots of subgraph updates

* updates front end for sort

* fixes type issue

* fixes build issue

* reviewing v3 monorepo and saw some networks missing (#399)

* Feature/public profile (#384)

* Add some stuff

* Add public profile

* Add ens

* Get build to pass

* Update apps/hub-app/src/pages/PublicProfilePage.tsx

Co-authored-by: Rowdy <[email protected]>

Co-authored-by: Sam Kuhlmann <[email protected]>
Co-authored-by: Rowdy <[email protected]>

* fixing doc display name from <[object Object]> to displayName (#402)

Co-authored-by: Sam Kuhlmann <[email protected]>

* adds search (#401)

* adds search wip

* correctly types the onChange for the input

* cleans up unsed imports

* naming

* Feature/public profile (#384)

* Add some stuff

* Add public profile

* Add ens

* Get build to pass

* Update apps/hub-app/src/pages/PublicProfilePage.tsx

Co-authored-by: Rowdy <[email protected]>

Co-authored-by: Sam Kuhlmann <[email protected]>
Co-authored-by: Rowdy <[email protected]>

* fixing doc display name from <[object Object]> to displayName (#402)

Co-authored-by: Sam Kuhlmann <[email protected]>

* conflicts

* correctly types the onChange for the input

* cleans up unsed imports

* naming

* fix build error

Co-authored-by: Alexander Keating <[email protected]>
Co-authored-by: Rowdy <[email protected]>
Co-authored-by: Brian Rossetti <[email protected]>

* Release/12072022 (#411)

* adds search wip

* correctly types the onChange for the input

* cleans up unsed imports

* naming

* conflicts

* correctly types the onChange for the input

* cleans up unsed imports

* naming

* fix build error

* feature bump

Co-authored-by: Jonathan Prozzi <[email protected]>
Co-authored-by: Rowdy <[email protected]>
Co-authored-by: Jord <[email protected]>
Co-authored-by: Spencer Graham <[email protected]>
Co-authored-by: Brian Rossetti <[email protected]>
Co-authored-by: Alexander Keating <[email protected]>

* Revert "Publish new lib versions. (#412)"

This reverts commit bab7077.

* develop to master (#482)

* UI/layout cleanup (#438)

* run generator

* import connect, theme libs. Add eindow.global. Ensure main.tsx uses React 17 API.

* deletes app test

* updates favicon and title

* remove nx defaults

* rough in layout box, target DH connect nav with class

* remove even more css. World's dubest layout component

* switches to connect class padding for mobile

* extract base layout component to storybook

* hook export chain, change name to outerlayout

* extract formSegment from summon-app; replace in all instances in summon

* extract split-column, replace all instances in summon

* document future changes in comments

* fix exports

* switch core-app to nx default project

* fix spacing

* Fix/split column bug (#444)

- fix bug

* Layouts/subnav (#447)

* clear out extra app.t.tsx

* build sub-nav

* style sub-nav

* test subnav

* extract subNavLink into component

* subnavlink story

* build subnavlink story

* fix broken as prop

* add mobile view, icon button trigger

* add tsc command to core-app

* adds human-format, removes profanity

* Fix summon (#446)

* Fix summon

* clear out extra app.t.tsx

* build sub-nav

* style sub-nav

* test subnav

* extract subNavLink into component

* subnavlink story

* build subnavlink story

* fix broken as prop

* Fix summon

* add mobile view, icon button trigger

* add tsc command to core-app

* adds human-format, removes profanity

* add human-format to dao-data

* move dts file

Co-authored-by: jordan <[email protected]>
Co-authored-by: Jord <[email protected]>

* Haus layout (#451)

* Publish new lib versions. (#412)

* fix/fix-table-types (#354)

* removed the any types from hub

* renamed Table to DaoTable and DataTable to DaoTable to be more consistent with DaoCard

* removed commented out DaoData type

* one more comment -- thought i got both before

* Fix/355 summon params mixup (#356)

* more ignore

* fixes bad init params order in summon tx

* Feature/tag component (#349)

* Created basic tag component

* Added dynamic color selections for tags

* Bumped versions fixed filer

* Added icon support to tag component

Co-authored-by: Jord <[email protected]>
Co-authored-by: Jonathan Prozzi <[email protected]>

* Feature/delegate play (#357)

* more ignore

* fixes bad init params order in summon tx

* delegate testing and subgraph field updates

* finishes mapping

* update dao-data query and transformer

* adds delegate tag to list view and hooks up delegate filtering

* refactors filter into query helper

* Spencer's Summon tooltip suggestions (#370)

* Spencer's Summon tooltip suggestions

- Summon portion of #365 

* Delimiter references

#368

For now, just referencing spaces. But if tabs, commas, or other delimiters are also supported, those should be references in the tooltips as well.

* Address Jord's comments

Co-authored-by: Sam Kuhlmann <[email protected]>

* Fix/summon poll (#375)

* more ignore

* fixes bad init params order in summon tx

* delegate testing and subgraph field updates

* finishes mapping

* update dao-data query and transformer

* adds delegate tag to list view and hooks up delegate filtering

* adds schema field to tx entity

* updates poll for tx entity made before dao entity

* Feature/alpha baal update (#376)

* new abis

* updates summoner tx logic and contract addresses

* fixes transaction entity creation location;

* fixes some test

* Feature/unit utils (#380)

* create custom d.ts for human-format

* type and convert unit fn from V2

* readableNumber util accepts number strings, throws error if string but number string

* fix 0 to 1 utils, extend MaxDecimals to shorten decimal places

* refine spacer and unit symbol placement

* update new card to handle new params

* update table

* corrections

* alter d.ts file

* potential solutions to ts bug

* implement keating's d.ts fix

* fix comment

* Fix/network switcher (#381)

* better error handling

* fix bug

* remove log

* get react-table TS to stop yelling (#382)

Co-authored-by: Sam Kuhlmann <[email protected]>

* Feature/hub sort (#383)

* wip

* gets query working on dao entity after lots of subgraph updates

* updates front end for sort

* fixes type issue

* fixes build issue

* reviewing v3 monorepo and saw some networks missing (#399)

* Feature/public profile (#384)

* Add some stuff

* Add public profile

* Add ens

* Get build to pass

* Update apps/hub-app/src/pages/PublicProfilePage.tsx

Co-authored-by: Rowdy <[email protected]>

Co-authored-by: Sam Kuhlmann <[email protected]>
Co-authored-by: Rowdy <[email protected]>

* fixing doc display name from <[object Object]> to displayName (#402)

Co-authored-by: Sam Kuhlmann <[email protected]>

* adds search (#401)

* adds search wip

* correctly types the onChange for the input

* cleans up unsed imports

* naming

* Feature/public profile (#384)

* Add some stuff

* Add public profile

* Add ens

* Get build to pass

* Update apps/hub-app/src/pages/PublicProfilePage.tsx

Co-authored-by: Rowdy <[email protected]>

Co-authored-by: Sam Kuhlmann <[email protected]>
Co-authored-by: Rowdy <[email protected]>

* fixing doc display name from <[object Object]> to displayName (#402)

Co-authored-by: Sam Kuhlmann <[email protected]>

* conflicts

* correctly types the onChange for the input

* cleans up unsed imports

* naming

* fix build error

Co-authored-by: Alexander Keating <[email protected]>
Co-authored-by: Rowdy <[email protected]>
Co-authored-by: Brian Rossetti <[email protected]>

* Release/12072022 (#411)

* adds search wip

* correctly types the onChange for the input

* cleans up unsed imports

* naming

* conflicts

* correctly types the onChange for the input

* cleans up unsed imports

* naming

* fix build error

* feature bump

Co-authored-by: Jonathan Prozzi <[email protected]>
Co-authored-by: Rowdy <[email protected]>
Co-authored-by: Jord <[email protected]>
Co-authored-by: Spencer Graham <[email protected]>
Co-authored-by: Brian Rossetti <[email protected]>
Co-authored-by: Alexander Keating <[email protected]>

* Revert "Publish new lib versions. (#412)"

This reverts commit bab7077.

* build formLayout Component

* type correction

* build formLayout story

* rough in bicolumn layout

* handle bicolumn mobile switch, finish bicolumn

* fix mainlayout naming

* build story for bi-column layout

* build dh layout one shot?

* yes, one shot

* fix import

* change prop name

Co-authored-by: Jonathan Prozzi <[email protected]>
Co-authored-by: Alexander Keating <[email protected]>
Co-authored-by: Sam Kuhlmann <[email protected]>
Co-authored-by: Rowdy <[email protected]>
Co-authored-by: Spencer Graham <[email protected]>
Co-authored-by: Brian Rossetti <[email protected]>

* bumping packages that were published pre revert last week - causing fialures with package publishing (#460)

* removing period from info content which casues confusing tooltip (#453)

Co-authored-by: Sam Kuhlmann <[email protected]>

* Feature/hub profile menu fix (#480)

* fixes profile link and layout

* dao list style

* adds toast to share link

* Readme tables preferred (#483)

* adjusting breakdown of apps and libs to tables

* adding additoonal app references and libs

* adding timestamp and address fields to many events (#468)

* adding timestamps and address fields to many events

* addressing code review

* shortening naming convention on proposals, top level txHash defined as txHash going forward

* update version

* deploy subgraph and generate query types

Co-authored-by: skuhlmann <[email protected]>

Co-authored-by: Jord <[email protected]>
Co-authored-by: Alexander Keating <[email protected]>
Co-authored-by: jordan <[email protected]>
Co-authored-by: Jonathan Prozzi <[email protected]>
Co-authored-by: Sam Kuhlmann <[email protected]>
Co-authored-by: Rowdy <[email protected]>
Co-authored-by: Spencer Graham <[email protected]>

* Revert "develop to master (#482)" (#492)

This reverts commit 5f7d121.

Co-authored-by: Sam Kuhlmann <[email protected]>

* Develop into master (#577)

* Feature/form builder (#553)

* Publish new lib versions. (#412)

* fix/fix-table-types (#354)

* removed the any types from hub

* renamed Table to DaoTable and DataTable to DaoTable to be more consistent with DaoCard

* removed commented out DaoData type

* one more comment -- thought i got both before

* Fix/355 summon params mixup (#356)

* more ignore

* fixes bad init params order in summon tx

* Feature/tag component (#349)

* Created basic tag component

* Added dynamic color selections for tags

* Bumped versions fixed filer

* Added icon support to tag component

Co-authored-by: Jord <[email protected]>
Co-authored-by: Jonathan Prozzi <[email protected]>

* Feature/delegate play (#357)

* more ignore

* fixes bad init params order in summon tx

* delegate testing and subgraph field updates

* finishes mapping

* update dao-data query and transformer

* adds delegate tag to list view and hooks up delegate filtering

* refactors filter into query helper

* Spencer's Summon tooltip suggestions (#370)

* Spencer's Summon tooltip suggestions

- Summon portion of #365 

* Delimiter references

#368

For now, just referencing spaces. But if tabs, commas, or other delimiters are also supported, those should be references in the tooltips as well.

* Address Jord's comments

Co-authored-by: Sam Kuhlmann <[email protected]>

* Fix/summon poll (#375)

* more ignore

* fixes bad init params order in summon tx

* delegate testing and subgraph field updates

* finishes mapping

* update dao-data query and transformer

* adds delegate tag to list view and hooks up delegate filtering

* adds schema field to tx entity

* updates poll for tx entity made before dao entity

* Feature/alpha baal update (#376)

* new abis

* updates summoner tx logic and contract addresses

* fixes transaction entity creation location;

* fixes some test

* Feature/unit utils (#380)

* create custom d.ts for human-format

* type and convert unit fn from V2

* readableNumber util accepts number strings, throws error if string but number string

* fix 0 to 1 utils, extend MaxDecimals to shorten decimal places

* refine spacer and unit symbol placement

* update new card to handle new params

* update table

* corrections

* alter d.ts file

* potential solutions to ts bug

* implement keating's d.ts fix

* fix comment

* Fix/network switcher (#381)

* better error handling

* fix bug

* remove log

* get react-table TS to stop yelling (#382)

Co-authored-by: Sam Kuhlmann <[email protected]>

* Feature/hub sort (#383)

* wip

* gets query working on dao entity after lots of subgraph updates

* updates front end for sort

* fixes type issue

* fixes build issue

* reviewing v3 monorepo and saw some networks missing (#399)

* Feature/public profile (#384)

* Add some stuff

* Add public profile

* Add ens

* Get build to pass

* Update apps/hub-app/src/pages/PublicProfilePage.tsx

Co-authored-by: Rowdy <[email protected]>

Co-authored-by: Sam Kuhlmann <[email protected]>
Co-authored-by: Rowdy <[email protected]>

* fixing doc display name from <[object Object]> to displayName (#402)

Co-authored-by: Sam Kuhlmann <[email protected]>

* adds search (#401)

* adds search wip

* correctly types the onChange for the input

* cleans up unsed imports

* naming

* Feature/public profile (#384)

* Add some stuff

* Add public profile

* Add ens

* Get build to pass

* Update apps/hub-app/src/pages/PublicProfilePage.tsx

Co-authored-by: Rowdy <[email protected]>

Co-authored-by: Sam Kuhlmann <[email protected]>
Co-authored-by: Rowdy <[email protected]>

* fixing doc display name from <[object Object]> to displayName (#402)

Co-authored-by: Sam Kuhlmann <[email protected]>

* conflicts

* correctly types the onChange for the input

* cleans up unsed imports

* naming

* fix build error

Co-authored-by: Alexander Keating <[email protected]>
Co-authored-by: Rowdy <[email protected]>
Co-authored-by: Brian Rossetti <[email protected]>

* Release/12072022 (#411)

* adds search wip

* correctly types the onChange for the input

* cleans up unsed imports

* naming

* conflicts

* correctly types the onChange for the input

* cleans up unsed imports

* naming

* fix build error

* feature bump

Co-authored-by: Jonathan Prozzi <[email protected]>
Co-authored-by: Rowdy <[email protected]>
Co-authored-by: Jord <[email protected]>
Co-authored-by: Spencer Graham <[email protected]>
Co-authored-by: Brian Rossetti <[email protected]>
Co-authored-by: Alexander Keating <[email protected]>

* Revert "Publish new lib versions. (#412)"

This reverts commit bab7077.

* build formLayout Component

* type correction

* build formLayout story

* rough in bicolumn layout

* handle bicolumn mobile switch, finish bicolumn

* fix mainlayout naming

* build story for bi-column layout

* scaffold formBuilder library

* rough in formBuilder

* restructure types

* refactor component structure

* test render inputs

* add core fields to builder enum

* add row layout to builder

* built logger, fix logger bug

* add disable all functionality

* handle asynchronous callback as props to form builder

* remove some comments

* put submit button in form footer

* fix code based on review

* build validation pipeline

* clean form and field types

* revise types again, simplify rules API

* commit after refactor carnage

* roll back to react-hook-form v6, finally get some traction

* found source of bug, trying new rhf version

* ...and the bug was slain, returned to that cold, miserable shit heap from whence it came.

* reintroduce devtool and logger

* build metadata form, form segment subForm component

* clean, add custom submit btn text

* clean

* build string validations

* derive validation type from function obj

* wrestled types into validation system

* rebuild form builder as context

* build formBuilder hook, use it in the factory

* create sample test

* update form placement

* more post merge corrections

* write validation updaters and add to pipeline, test required updaters, test validation, test pipeline

* try jest testing

* ensure field state updates on formState change

* more cleaning

* reorg files

* build metadata form

* tweak button styles, add defaultValues to formBuilder

* good place to stop

* remove comments

* fix Jest errors

* fix field wrapper stories, update lock

* may have fixed jest errors

Co-authored-by: Jonathan Prozzi <[email protected]>
Co-authored-by: Alexander Keating <[email protected]>
Co-authored-by: Sam Kuhlmann <[email protected]>
Co-authored-by: Rowdy <[email protected]>
Co-authored-by: Spencer Graham <[email protected]>
Co-authored-by: Brian Rossetti <[email protected]>

* Fix build (#563)

* Fix build

* Almost

* More changes

Co-authored-by: Jord <[email protected]>
Co-authored-by: Jonathan Prozzi <[email protected]>
Co-authored-by: Sam Kuhlmann <[email protected]>
Co-authored-by: Rowdy <[email protected]>
Co-authored-by: Spencer Graham <[email protected]>
Co-authored-by: Brian Rossetti <[email protected]>

* Revert "Develop into master (#577)"

This reverts commit b8644d3.

* gets member profile menu setup

* gets delegation form working

* gets other delegate links working in member list

* adds some better tooltip text

* addresses feedback and does some cleanup

* creates page and wires to drop down

* gets 2 of 3 form sections ready

* token list styles

* rage quit is done

Co-authored-by: Jonathan Prozzi <[email protected]>
Co-authored-by: Alexander Keating <[email protected]>
Co-authored-by: Rowdy <[email protected]>
Co-authored-by: Jord <[email protected]>
Co-authored-by: Spencer Graham <[email protected]>
Co-authored-by: Brian Rossetti <[email protected]>
Co-authored-by: jordan <[email protected]>
  • Loading branch information
8 people authored Sep 20, 2022
1 parent b3942cb commit 72c6b9a
Show file tree
Hide file tree
Showing 17 changed files with 418 additions and 16 deletions.
2 changes: 2 additions & 0 deletions apps/core-app/src/Routes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import UpdateSettings from './pages/UpdateSettings';
import ProposalDetails from './pages/ProposalDetails';
import { DaoContainer } from './pages/DaoContainer';
import { Banner } from '@daohaus/ui';
import RageQuit from './pages/RageQuit';

const Routes = () => {
return (
Expand All @@ -32,6 +33,7 @@ const Routes = () => {
<Route path="members/:memberAddress" element={<Member />} />
<Route path="settings" element={<Settings />} />
<Route path="settings/update" element={<UpdateSettings />} />
<Route path="members/ragequit" element={<RageQuit />} />
</Route>
</RoutesDom>
</>
Expand Down
6 changes: 5 additions & 1 deletion apps/core-app/src/components/MemberProfileMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,11 @@ export const MemberProfileMenu = ({
</Dialog>
</DropdownMenuItem>
<DropdownMenuItem key="ragequit" asChild>
<ProfileMenuText className="disabled">Rage Quit</ProfileMenuText>
<ProfileMenuLink
href={`/molochv3/${daochain}/${daoid}/members/ragequit`}
>
Rage Quit
</ProfileMenuLink>
</DropdownMenuItem>
</>
)}
Expand Down
1 change: 0 additions & 1 deletion apps/core-app/src/components/Profile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import {
fromWei,
votingPowerPercentage,
} from '@daohaus/common-utilities';

import { TMembership, useDao } from '@daohaus/dao-context';
import { MemberProfileMenu } from './MemberProfileMenu';

Expand Down
55 changes: 55 additions & 0 deletions apps/core-app/src/components/customFields/RagequitToken.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import { useMemo } from 'react';
import { RegisterOptions, useFormContext } from 'react-hook-form';
import { toWholeUnits, handleBaseUnits } from '@daohaus/common-utilities';
import { Buildable, Button, WrappedInput, Field } from '@daohaus/ui';

import { useConnectedMembership, useDao } from '@daohaus/dao-context';

export const RagequitToken = (props: Buildable<Field>) => {
const { id } = props;
const { setValue } = useFormContext();
const { dao } = useDao();
const { connectedMembership } = useConnectedMembership();

const daoTokenData = useMemo(() => {
if (!dao || !connectedMembership) return null;
return {
label:
id === 'sharesToBurn'
? `Voting Tokens (${dao.shareTokenSymbol})`
: `Non-Voting Tokens (${dao.lootTokenSymbol})`,
maxAmount:
id === 'sharesToBurn'
? connectedMembership.shares
: connectedMembership.loot,
};
}, [connectedMembership, dao, id]);

const setMax = () => {
setValue(id, toWholeUnits(daoTokenData?.maxAmount || '0'));
};

const newRules: RegisterOptions = {
setValueAs: (value) => handleBaseUnits(value, 18),
...props.rules,
};

if (!daoTokenData) {
return null;
}

return (
<WrappedInput
{...props}
id={id}
label={daoTokenData.label}
defaultValue="0"
rightAddon={
<Button secondary sm onClick={setMax} type="button">
Max: {toWholeUnits(daoTokenData.maxAmount || '0')}
</Button>
}
rules={newRules}
/>
);
};
212 changes: 212 additions & 0 deletions apps/core-app/src/components/customFields/RagequitTokenList.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,212 @@
import { useMemo } from 'react';
import { useFormContext } from 'react-hook-form';
import {
getNetwork,
formatValueTo,
memberTokenBalanceShare,
memberUsdValueShare,
NETWORK_TOKEN_ETH_ADDRESS,
} from '@daohaus/common-utilities';
import {
Buildable,
Field,
ParSm,
WrappedCheckbox,
Checkbox,
DataSm,
} from '@daohaus/ui';

import { useConnectedMembership, useDao } from '@daohaus/dao-context';
import { CheckboxProps, CheckedState } from '@radix-ui/react-checkbox';
import styled from 'styled-components';
import { TokenBalance } from '@daohaus/dao-data';
import { useParams } from 'react-router-dom';
import { sortTokensForRageQuit } from '../../utils/general';

const TokenListContainer = styled.div`
display: flex;
justify-content: space-between;
`;

const Column = styled.div`
width: 33%;
`;

const DataColumn = styled(Column)`
display: flex;
flex-direction: column;
gap: 1.2rem;
padding-top: 0.8rem;
`;

type TokenTable = {
tokenCheckboxes: CheckboxProps[];
amounts: React.ReactNode[];
usdValue: React.ReactNode[];
};

export const RagequitTokenList = (props: Buildable<Field>) => {
const { id } = props;
const { dao } = useDao();
const { connectedMembership } = useConnectedMembership();
const { daochain } = useParams();
const { setValue, watch } = useFormContext();

const [sharesToBurn, lootToBurn, tokens] = watch([
'sharesToBurn',
'lootToBurn',
'tokens',
]);

const networkData = useMemo(() => {
if (!daochain) return null;
return getNetwork(daochain);
}, [daochain]);

const handleSelectAll = (checked: CheckedState) => {
if (checked) {
setValue(
id,
sortTokensForRageQuit(
dao?.tokenBalances
.filter((token) => Number(token.balance) > 0)
.map((token) => token.tokenAddress || NETWORK_TOKEN_ETH_ADDRESS) ||
[]
)
);
} else {
setValue(id, []);
}

dao?.tokenBalances.forEach((token) => {
if (Number(token.balance) > 0) {
setValue(token.tokenAddress || NETWORK_TOKEN_ETH_ADDRESS, checked);
}
});
};

const tokenTable = useMemo((): TokenTable | null => {
if (!dao || !networkData || !connectedMembership) return null;
return dao?.tokenBalances
.filter((token) => Number(token.balance) > 0)
.reduce(
(acc: TokenTable, token: TokenBalance) => {
acc.tokenCheckboxes = [
...acc.tokenCheckboxes,
{
id: token.tokenAddress || NETWORK_TOKEN_ETH_ADDRESS,
title: token.token?.name || networkData.symbol,
name: token.tokenAddress || NETWORK_TOKEN_ETH_ADDRESS,
defaultChecked: true,
disabled: false,
required: false,
onCheckedChange: (checked: CheckedState) => {
if (checked) {
setValue(
id,
sortTokensForRageQuit([
...tokens,
token.tokenAddress || NETWORK_TOKEN_ETH_ADDRESS,
])
);
}

if (!checked) {
const targetAddress =
token.tokenAddress || NETWORK_TOKEN_ETH_ADDRESS;
setValue(
id,
sortTokensForRageQuit(
tokens.filter((t: string) => t !== targetAddress)
)
);
}

setValue(
token.tokenAddress || NETWORK_TOKEN_ETH_ADDRESS,
checked
);
},
},
];
acc.amounts = [
...acc.amounts,
<DataSm key={token.tokenAddress}>
{formatValueTo({
value: memberTokenBalanceShare(
token.balance,
dao.totalShares || 0,
sharesToBurn || 0,
lootToBurn || 0,
token.token?.decimals || 18
),
format: 'number',
})}
</DataSm>,
];

acc.usdValue = [
...acc.usdValue,
<DataSm key={token.tokenAddress}>
{formatValueTo({
value: memberUsdValueShare(
token.fiatBalance,
dao.totalShares || 0,
sharesToBurn || 0,
lootToBurn || 0
),
decimals: 2,
format: 'currency',
})}
</DataSm>,
];

return acc;
},
{ tokenCheckboxes: [], amounts: [], usdValue: [] }
);
}, [
dao,
networkData,
connectedMembership,
sharesToBurn,
lootToBurn,
id,
tokens,
setValue,
]);

if (!tokenTable) return null;

return (
<>
<TokenListContainer>
<Column>
<Checkbox
title="Token"
defaultChecked={true}
onCheckedChange={handleSelectAll}
/>
</Column>

<Column>
<ParSm>Amount</ParSm>
</Column>
<Column>
<ParSm>USD Value</ParSm>
</Column>
</TokenListContainer>
<TokenListContainer>
<Column>
<WrappedCheckbox
{...props}
id={id}
checkboxes={tokenTable.tokenCheckboxes}
/>
</Column>
<DataColumn>{tokenTable.amounts}</DataColumn>
<DataColumn>{tokenTable.usdValue}</DataColumn>
</TokenListContainer>
</>
);
};
4 changes: 4 additions & 0 deletions apps/core-app/src/legos/config.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import { TagsInput } from '../components/customFields/tagsInput';
import { FakeMarkdown } from '../components/FakeMarkdown';
import { ProposalOffering } from '../components/customFields/ProposalOffering';
import { DelegateInput } from '../components/customFields/delegateInput';
import { RagequitToken } from '../components/customFields/RagequitToken';
import { RagequitTokenList } from '../components/customFields/RagequitTokenList';

export const CustomFields = {
...CoreFieldLookup,
Expand All @@ -23,6 +25,8 @@ export const CustomFields = {
fakeMarkdown: FakeMarkdown,
proposalOffering: ProposalOffering,
delegateInput: DelegateInput,
ragequitToken: RagequitToken,
ragequitTokenList: RagequitTokenList,
};

export type CustomFieldLego = FieldLegoBase<typeof CustomFields>;
Expand Down
4 changes: 4 additions & 0 deletions apps/core-app/src/legos/fields.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ export const FIELD: Record<string, CustomFieldLego> = {
id: 'paymentAmount',
type: 'requestNativeToken',
},
RAGEQUIT_TOKEN: {
id: 'sharesToBurn',
type: 'ragequitToken',
},
TO_WEI: {
id: 'shouldOverwrite',
type: 'toWeiInput',
Expand Down
46 changes: 46 additions & 0 deletions apps/core-app/src/legos/form.ts
Original file line number Diff line number Diff line change
Expand Up @@ -543,4 +543,50 @@ export const COMMON_FORMS: Record<string, CustomFormLego> = {
submitButtonText: 'Update Delegate',
tx: TX.MANAGE_DELEGATE,
},
RAGEQUIT: {
id: 'RAGEQUIT',
title: 'Ragequit',
subtitle: 'Members',
fields: [
{
id: 'tokenAmounts',
type: 'formSegment',
title: 'Step 1. Select voting and/or non-voting tokens to ragequit',
fields: [
{
id: 'sharesToBurn',
// @ts-expect-error: cannot resolve type within formSegment using custom fields sent from the core-app
type: 'ragequitToken',
},
// @ts-expect-error: cannot resolve type within formSegment using custom fields sent from the core-app
{ id: 'lootToBurn', type: 'ragequitToken' },
],
},
{
id: 'tokenAddresses',
type: 'formSegment',
title:
'Step 2. Select treasury tokens you want to receive in exchange for your dao tokens',
fields: [
// @ts-expect-error: cannot resolve type within formSegment using custom fields sent from the core-app
{ id: 'tokens', type: 'ragequitTokenList' },
],
},
{
id: 'checkRender',
type: 'checkRender',
gateLabel: 'Ragequit to different address (optional)',
components: [
{
id: 'to',
type: 'input',
label: 'Address to send funds',
expectType: 'ethAddress',
placeholder: '0x...',
},
],
},
],
tx: TX.RAGEQUIT,
},
};
Loading

0 comments on commit 72c6b9a

Please sign in to comment.