Skip to content

Commit 39ded40

Browse files
committed
Add new Votes page and update index.ts
A new `Votes.astro` file has been added for the Votes page that fetches and displays poll options. The `index.ts` file was updated to include this new page and its path has been added to the page paths in `ClubsFunctionGetPagePaths`. These changes are crucial to facilitate the display and functionality of voting in the application.
1 parent 3a3e2a4 commit 39ded40

File tree

3 files changed

+25
-28
lines changed

3 files changed

+25
-28
lines changed

src/Pages/Votes.astro

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
---
2-
import {Option} from '../types';
3-
import {ClubsPropsPages, Membership} from '@devprotocol/clubs-core';
4-
import Votes from '../components/Pages/Votes.vue';
5-
import type {OptionsDatabase} from '@devprotocol/clubs-plugin-posts';
2+
import { Option } from '../types'
3+
import { ClubsPropsPages, Membership } from '@devprotocol/clubs-core'
4+
import Votes from '../components/Pages/Votes.vue'
5+
import type { OptionsDatabase } from '@devprotocol/clubs-plugin-posts'
66
77
interface Props extends ClubsPropsPages {
88
options: Option[]
@@ -12,10 +12,7 @@ interface Props extends ClubsPropsPages {
1212
feeds: OptionsDatabase[]
1313
}
1414
15-
const {
16-
options,
17-
feeds
18-
} = Astro.props
15+
const { options, feeds } = Astro.props
1916
---
2017

2118
<Votes client:load options={options} feeds={feeds} />

src/components/Pages/Votes.vue

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
<script lang="ts" setup>
2-
3-
import type {Option} from '../../types.ts';
4-
import type {OptionsDatabase} from '@devprotocol/clubs-plugin-posts';
5-
import {decode} from '@devprotocol/clubs-core';
6-
import {onMounted, ref} from 'vue';
2+
import type { Option } from '../../types.ts'
3+
import type { OptionsDatabase } from '@devprotocol/clubs-plugin-posts'
4+
import { decode } from '@devprotocol/clubs-core'
5+
import { onMounted, ref } from 'vue'
76
87
type Props = {
98
options: Option[]
@@ -16,7 +15,7 @@ const error = ref('')
1615
const isLoading = ref(true)
1716
1817
const fetchPolls = async () => {
19-
// これでPollのFeedをとってくる
18+
// これでPollのFeedをとってくる
2019
// http://localhost:4321/api/devprotocol:clubs:plugin:posts/default-2/search/has:option/%23poll
2120
2221
const url = new URL(
@@ -46,7 +45,6 @@ onMounted(async () => {
4645
await fetchPolls()
4746
console.log('mounted', polls.value)
4847
})
49-
5048
</script>
5149

5250
<template>

src/index.ts

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
import type {
2-
ClubsFunctionGetApiPaths, ClubsFunctionGetPagePaths,
2+
ClubsFunctionGetApiPaths,
3+
ClubsFunctionGetPagePaths,
34
ClubsFunctionGetSlots,
45
ClubsFunctionPlugin,
56
ClubsPluginMeta,
67
} from '@devprotocol/clubs-core'
78
import { ClubsPluginCategory } from '@devprotocol/clubs-core'
8-
import {type OptionsDatabase, SlotName} from '@devprotocol/clubs-plugin-posts'
9+
import { type OptionsDatabase, SlotName } from '@devprotocol/clubs-plugin-posts'
910
import { votingHandler } from './ApiHandler'
1011
import Icon from './assets/images/Voting.png'
1112
import Preview1 from './assets/images/voting-preview01.png'
@@ -14,7 +15,7 @@ import Preview3 from './assets/images/voting-preview03.png'
1415
import Readme from './readme.astro'
1516
import AfterContentForm from './components/edit-after-content-form.astro'
1617
import AfterPostContent from './components/feed-after-post-content.astro'
17-
import type {UndefinedOr} from '@devprotocol/util-ts';
18+
import type { UndefinedOr } from '@devprotocol/util-ts'
1819
import Votes from './Pages/Votes.astro'
1920

2021
export const getSlots = (async () => {
@@ -54,14 +55,13 @@ export const getApiPaths = (async () => {
5455

5556
const getPagePaths = (async (
5657
options,
57-
{propertyAddress, adminRolePoints, rpcUrl},
58-
{getPluginConfigById}
58+
{ propertyAddress, adminRolePoints, rpcUrl },
59+
{ getPluginConfigById },
5960
) => {
60-
6161
const [postsPlugin] = getPluginConfigById('devprotocol:clubs:plugin:posts')
6262

6363
const feeds = postsPlugin?.options?.find(
64-
({key}: Readonly<{ readonly key: string }>) => key === 'feeds',
64+
({ key }: Readonly<{ key: string }>) => key === 'feeds',
6565
)?.value as UndefinedOr<readonly OptionsDatabase[]>
6666

6767
const props = {
@@ -72,13 +72,15 @@ const getPagePaths = (async (
7272
feeds,
7373
}
7474

75-
return [{
76-
paths: ["votes"],
77-
component: Votes,
78-
props: {
79-
...props
75+
return [
76+
{
77+
paths: ['votes'],
78+
component: Votes,
79+
props: {
80+
...props,
81+
},
8082
},
81-
}]
83+
]
8284
}) satisfies ClubsFunctionGetPagePaths
8385

8486
export default {

0 commit comments

Comments
 (0)