Skip to content

Commit

Permalink
feat: add edit to payment builder action
Browse files Browse the repository at this point in the history
feat: handle add recipient

feat: add multiple funding steps

fix: changes type
  • Loading branch information
CzarekDryl committed Sep 23, 2024
1 parent a29047e commit 49c736a
Show file tree
Hide file tree
Showing 43 changed files with 2,460 additions and 455 deletions.
26 changes: 23 additions & 3 deletions src/components/v5/common/ActionSidebar/ActionSidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ const ActionSidebar: FC<PropsWithChildren<ActionSidebarProps>> = ({
} = useGetActionData(transactionId);

const {
isEditMode,
actionSidebarToggle: [
isActionSidebarOpen,
{ toggle: toggleActionSidebarOff, registerContainerRef },
Expand Down Expand Up @@ -261,7 +262,7 @@ const ActionSidebar: FC<PropsWithChildren<ActionSidebarProps>> = ({
ref={registerContainerRef}
>
<div className="relative">
<div className="flex w-full items-center justify-between border-b border-gray-200 px-6 py-4">
<div className="flex w-full items-center justify-between px-6 py-4">
<div className="flex items-center gap-2">
<button
type="button"
Expand All @@ -288,20 +289,39 @@ const ActionSidebar: FC<PropsWithChildren<ActionSidebarProps>> = ({
</button>
{getShareButton()}
</div>
{action && !isMotion && !expenditure && (
{action && !isMotion && !expenditure && !isEditMode && (
<PillsBase
className="bg-success-100 text-success-400"
isCapitalized={false}
>
{formatText({ id: 'action.passed' })}
</PillsBase>
)}
{!!expenditure && (
{!!expenditure && !isEditMode && (
<ExpenditureActionStatusBadge
expenditure={expenditure}
withAdditionalStatuses
/>
)}
{!!expenditure && isEditMode && (
<Tooltip
tooltipContent={
<span className="font-medium">
{formatText({
id: 'expenditure.edit.tooltip',
})}
</span>
}
placement="bottom-start"
>
<PillsBase
className="bg-warning-100 text-warning-400"
isCapitalized={false}
>
{formatText({ id: 'badge.edit' })}
</PillsBase>
</Tooltip>
)}
<MotionOutcomeBadge motionState={motionState} />
</div>
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ const ActionSidebarContent: FC<ActionSidebarContentProps> = ({

return (
<div
className={clsx('flex w-full flex-grow', {
className={clsx('flex w-full flex-grow border-t border-gray-200', {
'flex-col-reverse overflow-auto sm:overflow-hidden md:flex-row':
!!transactionId,
'overflow-hidden': !transactionId,
Expand Down
75 changes: 48 additions & 27 deletions src/components/v5/common/CompletedAction/CompletedAction.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import clsx from 'clsx';
import React from 'react';

import { useActionSidebarContext } from '~context/ActionSidebarContext/ActionSidebarContext.ts';
import { useColonyContext } from '~context/ColonyContext/ColonyContext.ts';
import { ColonyActionType } from '~gql';
import { ExtendedColonyActionType } from '~types/actions.ts';
Expand All @@ -13,12 +14,14 @@ import Motions from '../ActionSidebar/partials/Motions/index.ts';
import AddVerifiedMembers from './partials/AddVerifiedMembers/index.ts';
import CreateDecision from './partials/CreateDecision/index.ts';
import EditColonyDetails from './partials/EditColonyDetails/index.ts';
import ExitEditModeModal from './partials/ExitEditModeModal/ExitEditModeModal.tsx';
import ManageReputation from './partials/ManageReputation/index.ts';
import ManageTeam from './partials/ManageTeam/index.ts';
import ManageTokens from './partials/ManageTokens/ManageTokens.tsx';
import MintTokens from './partials/MintTokens/index.ts';
import PaymentBuilderWidget from './partials/PaymentBuilder/partials/PaymentBuilderWidget/PaymentBuilderWidget.tsx';
import PaymentBuilder from './partials/PaymentBuilder/PaymentBuilder.tsx';
import PaymentBuilderEdit from './partials/PaymentBuilderEdit/PaymentBuilderEdit.tsx';
import RemoveVerifiedMembers from './partials/RemoveVerifiedMembers/index.ts';
import SetUserRoles from './partials/SetUserRoles/index.ts';
import SimplePayment from './partials/SimplePayment/index.ts';
Expand All @@ -38,6 +41,13 @@ const CompletedAction = ({ action }: CompletedActionProps) => {
const { colony } = useColonyContext();

const actionType = getExtendedActionType(action, colony.metadata);
const {
isEditMode,
cancelEditModalToggle: [
isCancelModalOpen,
{ toggleOff: toggleOffCancelModal },
],
} = useActionSidebarContext();

const getActionContent = () => {
switch (actionType) {
Expand Down Expand Up @@ -128,36 +138,47 @@ const CompletedAction = ({ action }: CompletedActionProps) => {
}
};

const getEditContent = () => {
switch (actionType) {
case ColonyActionType.CreateExpenditure:
return <PaymentBuilderEdit action={action} />;
default:
return <div>Not implemented yet</div>;
}
};

return (
<div className="flex flex-grow flex-col-reverse justify-end overflow-auto sm:flex-row sm:justify-start">
<div
className={clsx('w-full overflow-y-auto px-6 pb-6 pt-8', {
'sm:w-[calc(100%-23.75rem)]': action.isMotion,
})}
>
{getActionContent()}
</div>
<>
<div className="relative flex flex-grow flex-col-reverse justify-end overflow-auto sm:flex-row sm:justify-start">
<div
className={clsx(
'w-full overflow-y-auto px-6 pb-6 pt-8 sm:border sm:border-gray-200',
{
'sm:w-[calc(100%-23.75rem)]': action.isMotion,
'mb-[8.5rem] sm:mb-[5.5rem] sm:border-warning-400': isEditMode,
'sm:border-b-0 sm:border-l-0': !isEditMode,
},
)}
>
{isEditMode ? getEditContent() : getActionContent()}
</div>

<div
className={`
w-full
border-b
border-b-gray-200
bg-gray-25
px-6
py-8
sm:h-full
sm:w-[23.75rem]
sm:flex-shrink-0
sm:overflow-y-auto
sm:border-b-0
sm:border-l
sm:border-l-gray-200
`}
>
{getSidebarWidgetContent()}
<div
className={clsx(
'w-full border-b border-b-gray-200 bg-gray-25 px-6 py-8 sm:h-full sm:w-[23.75rem] sm:flex-shrink-0 sm:overflow-y-auto sm:border-b-0 sm:border-t sm:border-gray-200',
{
'border-b-warning-400': isEditMode,
},
)}
>
{getSidebarWidgetContent()}
</div>
</div>
</div>
<ExitEditModeModal
isOpen={isCancelModalOpen}
onClose={toggleOffCancelModal}
/>
</>
);
};

Expand Down
Loading

0 comments on commit 49c736a

Please sign in to comment.