-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add itheum coalition category management
- Loading branch information
Showing
5 changed files
with
117 additions
and
1 deletion.
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
62 changes: 62 additions & 0 deletions
62
src/extensions/itheum/src/coalition/_CategoriesSection.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,62 @@ | ||
import React, { useState } from 'react' | ||
import { CoalitionInfo } from '../types' | ||
import { Contracts } from '../contracts' | ||
import { useApp } from '../../../../shared/hooks/useApp' | ||
import { AppSection } from '../../../../shared/ui/elements' | ||
import { capitalizeFirstLetter } from '@peerme/core-ts' | ||
import { Button, Input } from '@peerme/web-ui' | ||
|
||
type Props = { | ||
info: CoalitionInfo | ||
className?: string | ||
} | ||
|
||
export function _CategoriesSection(props: Props) { | ||
const app = useApp() | ||
const [name, setName] = useState('') | ||
|
||
const handleAdd = () => | ||
app.requestProposalAction( | ||
Contracts(app.config).AddCategory.Address, | ||
Contracts(app.config).AddCategory.Endpoint, | ||
0, | ||
[name], | ||
[] | ||
) | ||
|
||
const handleRemove = (name: string) => | ||
app.requestProposalAction( | ||
Contracts(app.config).RemoveCategory.Address, | ||
Contracts(app.config).RemoveCategory.Endpoint, | ||
0, | ||
[name], | ||
[] | ||
) | ||
|
||
return ( | ||
<div className={props.className}> | ||
<AppSection | ||
title="Create Category" | ||
description="Data Providers can delegate their data to existing categories." | ||
className="mb-4" | ||
> | ||
<Input placeholder="Category name ..." value={name} onChange={(val) => setName(val)} /> | ||
{name.length > 0 && ( | ||
<Button onClick={handleAdd} color="blue" className="mt-4"> | ||
Create | ||
</Button> | ||
)} | ||
</AppSection> | ||
<AppSection title="Our Categories"> | ||
<ul> | ||
{props.info.categories.map((category) => ( | ||
<li key={category} className="flex items-center justify-between"> | ||
<span>{capitalizeFirstLetter(category)}</span> | ||
<button onClick={() => handleRemove(category)}>Remove</button> | ||
</li> | ||
))} | ||
</ul> | ||
</AppSection> | ||
</div> | ||
) | ||
} |
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
17 changes: 17 additions & 0 deletions
17
src/extensions/itheum/src/previews/coalition/AddCategoryActionPreview.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,17 @@ | ||
import React from 'react' | ||
import { ProposalAction } from '@peerme/core-ts' | ||
import { ActionPreviewHighlight } from '../../../../../shared/ui/elements' | ||
|
||
type Props = { | ||
action: ProposalAction | ||
} | ||
|
||
export function AddCategoryActionPreview(props: Props) { | ||
const category = props.action.arguments[0] as string | ||
|
||
return ( | ||
<ActionPreviewHighlight> | ||
create a new category for our Data Coalition: <strong>{category}</strong> | ||
</ActionPreviewHighlight> | ||
) | ||
} |
17 changes: 17 additions & 0 deletions
17
src/extensions/itheum/src/previews/coalition/RemoveCategoryActionPreview.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,17 @@ | ||
import React from 'react' | ||
import { ProposalAction } from '@peerme/core-ts' | ||
import { ActionPreviewHighlight } from '../../../../../shared/ui/elements' | ||
|
||
type Props = { | ||
action: ProposalAction | ||
} | ||
|
||
export function RemoveCategoryActionPreview(props: Props) { | ||
const category = props.action.arguments[0] as string | ||
|
||
return ( | ||
<ActionPreviewHighlight> | ||
remove the category <strong>{category}</strong> from our Data Coalition. | ||
</ActionPreviewHighlight> | ||
) | ||
} |
3cae431
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
extensions-dev – ./
extensions-dev.vercel.app
extensions-dev-git-main-vleap.vercel.app
extensions-dev.peerme.io
extensions-dev-vleap.vercel.app