-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2590 from decentdao/issue/2583-remove-roles-drawer
`[PRD | Issue #2582]` Move Role Form to own page
- Loading branch information
Showing
12 changed files
with
274 additions
and
478 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
src/pages/dao/roles/edit/SafeRolesEditFormikPageWrapper.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import * as amplitude from '@amplitude/analytics-browser'; | ||
import { Formik } from 'formik'; | ||
import { useEffect, useMemo } from 'react'; | ||
import { Outlet } from 'react-router-dom'; | ||
import { useRolesSchema } from '../../../../hooks/schemas/roles/useRolesSchema'; | ||
import useCreateRoles from '../../../../hooks/utils/useCreateRoles'; | ||
import { analyticsEvents } from '../../../../insights/analyticsEvents'; | ||
import { useDaoInfoStore } from '../../../../store/daoInfo/useDaoInfoStore'; | ||
import { useRolesStore } from '../../../../store/roles/useRolesStore'; | ||
import { RoleFormValues } from '../../../../types/roles'; | ||
|
||
export default function SafeRolesEditFormikPageWrapper() { | ||
useEffect(() => { | ||
amplitude.track(analyticsEvents.RolesEditPageOpened); | ||
}, []); | ||
|
||
const { safe } = useDaoInfoStore(); | ||
|
||
const { rolesSchema } = useRolesSchema(); | ||
const { hatsTree } = useRolesStore(); | ||
|
||
const { createEditRolesProposal } = useCreateRoles(); | ||
const initialValues: RoleFormValues = useMemo(() => { | ||
const hats = hatsTree?.roleHats || []; | ||
return { | ||
proposalMetadata: { | ||
title: '', | ||
description: '', | ||
}, | ||
hats: hats.map(hat => ({ | ||
...hat, | ||
resolvedWearer: hat.wearerAddress, | ||
wearer: hat.wearerAddress, | ||
roleTerms: hat.roleTerms.allTerms, | ||
})), | ||
customNonce: safe?.nextNonce || 0, | ||
actions: [], | ||
}; | ||
}, [hatsTree?.roleHats, safe?.nextNonce]); | ||
return ( | ||
<Formik<RoleFormValues> | ||
initialValues={initialValues} | ||
enableReinitialize | ||
validationSchema={rolesSchema} | ||
validateOnMount | ||
onSubmit={createEditRolesProposal} | ||
> | ||
{({ handleSubmit }) => ( | ||
<form onSubmit={handleSubmit}> | ||
<Outlet /> | ||
</form> | ||
)} | ||
</Formik> | ||
); | ||
} |
Oops, something went wrong.