Skip to content

Commit

Permalink
Merge pull request #31 from holonauts/feat/list-applications
Browse files Browse the repository at this point in the history
Feat/list applications
  • Loading branch information
mattyg authored Feb 29, 2024
2 parents aed9521 + ca7378e commit 175dfa1
Show file tree
Hide file tree
Showing 7 changed files with 99 additions and 14 deletions.
8 changes: 8 additions & 0 deletions dnas/grant_pools/zomes/coordinator/grants/src/application.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
use crate::grant_pool_to_applications::{
add_application_for_grant_pool, AddApplicationForGrantPoolInput,
};
use grants_integrity::*;
use hdk::prelude::*;

#[hdk_extern]
pub fn create_application(application: Application) -> ExternResult<Record> {
let application_hash = create_entry(&EntryTypes::Application(application.clone()))?;
Expand All @@ -20,6 +24,10 @@ pub fn create_application(application: Application) -> ExternResult<Record> {
LinkTypes::MyApplications,
(),
)?;
add_application_for_grant_pool(AddApplicationForGrantPoolInput {
base_grant_pool_hash: application.grant_pool,
target_application_hash: record.action_address().clone(),
})?;
Ok(record)
}
#[hdk_extern]
Expand Down
7 changes: 1 addition & 6 deletions dnas/grant_pools/zomes/integrity/grants/src/grant_pool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,7 @@ pub struct AmountRange {
min: U256,
max: U256,
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq)]
pub struct AllowedERC20 {
token: Address,
decimals: u8,
}

#[hdk_entry_helper]
#[derive(Clone, PartialEq)]
pub struct GrantPool {
Expand All @@ -21,7 +17,6 @@ pub struct GrantPool {
pub application_template: ActionHash,
pub evaluation_template: ActionHash,
pub amount_range: AmountRange,
pub allowed_erc20: AllowedERC20,
pub evaluators: Vec<AgentPubKey>,
}
pub fn validate_create_grant_pool(
Expand Down
2 changes: 1 addition & 1 deletion ui/src/routes/grant-pools/[actionHashB64]/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
size="xs"
color="alternative"
class="px-2 py-1"
href={`${$page.url}/applications`}>Submitted Applications</Button
href={`${$page.url}/applications`}>Applications</Button
>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1,23 @@
VIEW ALL APPLICATIONS FOR GRANT POOL
<script lang="ts">
import ApplicationListItem from './ApplicationListItem.svelte';
import RecordList from '$lib/components/RecordList.svelte';
import { decodeHashFromBase64 } from '@holochain/client';
import { page } from '$app/stores';
$: actionHash = decodeHashFromBase64($page.params.actionHashB64);
</script>

<RecordList
entryType="Application"
callZomeRequest={{
cap_secret: null,
role_name: 'grant_pools',
zome_name: 'grants',
fn_name: 'get_applications_for_grant_pool',
payload: actionHash
}}
>
<svelte:fragment let:hash>
<ApplicationListItem applicationHash={hash} />
</svelte:fragment>
</RecordList>
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<script lang="ts">
import { encodeHashToBase64, type ActionHash } from '@holochain/client';
import RecordListItem from '$lib/components/RecordDetail.svelte';
import BaseLabelContent from '$lib/components/BaseLabelContent.svelte';
import { Card } from 'flowbite-svelte';
import { goto } from '$app/navigation';
import { ACCEPTED_TOKEN_DECIMALS, ACCEPTED_TOKEN_SYMBOL } from '$lib/config';
import BaseBadgeRecordTimestamp from '$lib/components/BaseBadgeRecordTimestamp.svelte';
import { formatUnits } from 'viem';
import { u256ToBigint } from '$lib/utils/u256';
import ProfileInline from '$lib/components/ProfileInline.svelte';
import BaseStatusBadge from '$lib/components/BaseStatusBadge.svelte';
import { page } from '$app/stores';
export let applicationHash: ActionHash;
</script>

<RecordListItem
callZomeRequest={{
cap_secret: null,
role_name: 'grant_pools',
zome_name: 'grants',
fn_name: 'get_latest_application',
payload: applicationHash
}}
>
<svelte:fragment let:record let:entry>
<Card
size="xl"
on:click={() =>
goto(
`/grant-pools/${$page.params.actionHashB64}/applications/${encodeHashToBase64(applicationHash)}`
)}
>
<div class="flex items-start justify-between">
<ProfileInline agentPubKey={record.signed_action.hashed.content.author} />

<div class="flex flex-col items-end justify-start">
<div>
<BaseStatusBadge status={entry.status} />
</div>
<div>
<BaseBadgeRecordTimestamp {record} />
</div>
</div>
</div>

<BaseLabelContent label="Requested Amount">
{formatUnits(u256ToBigint(entry.amount), ACCEPTED_TOKEN_DECIMALS)}
{ACCEPTED_TOKEN_SYMBOL}
</BaseLabelContent>
</Card>
</svelte:fragment>
</RecordListItem>
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@
import BaseBadgeRecordTimestamp from '$lib/components/BaseBadgeRecordTimestamp.svelte';
import BaseHeading from '$lib/components/BaseHeading.svelte';
import BaseBreadcrumbs from '$lib/components/BaseBreadcrumbs.svelte';
import ProfileInline from '$lib/components/ProfileInline.svelte';
$: actionHash = decodeHashFromBase64($page.params.actionHashB64);
$: applicationActionHashB64 = decodeHashFromBase64($page.params.applicationActionHashB64);
$: applicationActionHash = decodeHashFromBase64($page.params.applicationActionHashB64);
</script>

<RecordDetail
Expand All @@ -23,7 +24,7 @@
role_name: 'grant_pools',
zome_name: 'grants',
fn_name: 'get_latest_application',
payload: applicationActionHashB64
payload: applicationActionHash
}}
>
<svelte:fragment let:entry let:record>
Expand Down Expand Up @@ -68,6 +69,10 @@
</div>
</div>
</div>

<BaseLabelContent label="Applicant">
<ProfileInline agentPubKey={record.signed_action.hashed.hash} />
</BaseLabelContent>
<div class="mb-8">
{#each JSON.parse(entry.form_content) as field}
<BaseLabelContent label={field.name} class="mb-8">
Expand Down
9 changes: 5 additions & 4 deletions ui/src/routes/time-periods/CreateTimePeriod.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@
import dayjs from 'dayjs';
const dispatch = createEventDispatcher();
let startAt: Date;
let startAt: Date | undefined;
let endAt: Date;
$: isValid = startAt !== undefined && endAt !== undefined && endAt > startAt;
$: minEndAt = startAt ? startAt : new Date();
$: isValid = startAt && endAt && endAt > startAt;
async function createTimePeriod() {
const timePeriodEntry: TimePeriod = {
Expand Down Expand Up @@ -40,12 +41,12 @@

<div class="flex items-center justify-start space-x-8">
<div>
<DateInput bind:value={startAt} />
<DateInput min={new Date()} bind:value={startAt} />
<Label>Starts At</Label>
</div>

<div>
<DateInput bind:value={endAt} />
<DateInput min={minEndAt} bind:value={endAt} />
<Label>Ends At</Label>
</div>
</div>
Expand Down

0 comments on commit 175dfa1

Please sign in to comment.