-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
358 additions
and
147 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<template> | ||
<v-btn | ||
elevation="2" | ||
variant="outlined" | ||
color="primary" | ||
density="compact" | ||
size="small" | ||
> | ||
Invite to Curate | ||
<v-menu | ||
location="bottom" | ||
:close-on-content-click="false" | ||
activator="parent" | ||
> | ||
<v-list density="compact" max-height="200px"> | ||
<template v-if="data"> | ||
<template v-for="curation in data.curations" :key="curation.id"> | ||
<CollaborateMenuItem | ||
:address="props.address" | ||
:curation="curation" | ||
/> | ||
</template> | ||
</template> | ||
</v-list> | ||
</v-menu> | ||
</v-btn> | ||
</template> | ||
|
||
<script setup lang="ts"> | ||
import { useAuthStore } from '~/stores/auth' | ||
const props = defineProps<{ address: string }>() | ||
const abc = useArtByCity() | ||
const auth = useAuthStore() | ||
const { | ||
data | ||
} = useLazyAsyncData(`curations-from-${auth.address}`, async () => { | ||
if (!auth.address) { return { curations: [] } } | ||
return await abc.curations.createdBy(auth.address) | ||
}) | ||
</script> |
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,130 @@ | ||
<template> | ||
<v-list-item | ||
v-if="!pending && !hasError && isCollaborative" | ||
:disabled="pending" | ||
> | ||
<template #prepend> | ||
<v-list-item-action start> | ||
<v-hover #="{ isHovering, props }"> | ||
<v-btn | ||
v-bind="props" | ||
icon | ||
variant="plain" | ||
density="compact" | ||
:loading="loading" | ||
@click="onCurationActionClicked" | ||
> | ||
<v-icon size="x-small">{{ curationActionIcon(isHovering) }}</v-icon> | ||
</v-btn> | ||
</v-hover> | ||
</v-list-item-action> | ||
</template> | ||
|
||
<v-list-item-title> | ||
{{ curationTitle }} | ||
</v-list-item-title> | ||
|
||
<template #append> | ||
<v-list-item-action end> | ||
<v-btn | ||
icon | ||
variant="plain" | ||
density="compact" | ||
:to="`/curations/${props.curation.id}`" | ||
> | ||
<v-icon>mdi-arrow-right</v-icon> | ||
</v-btn> | ||
</v-list-item-action> | ||
</template> | ||
</v-list-item> | ||
</template> | ||
|
||
<script setup lang="ts"> | ||
import { | ||
CollaborativeWhitelistCurationState | ||
} from '@artbycity/sdk/dist/web/curation' | ||
import ArdbTransaction from 'ardb/lib/models/transaction' | ||
const props = defineProps<{ | ||
address: string, | ||
curation: ArdbTransaction | ||
}>() | ||
const abc = useArtByCity() | ||
const hasError = ref(false) | ||
const loading = ref(false) | ||
const { | ||
data: state, | ||
pending, | ||
refresh | ||
} = useLazyAsyncData(`curation-state-${props.curation.id}`, async () => { | ||
try { | ||
const contract = abc | ||
.curations | ||
.get<CollaborativeWhitelistCurationState>(props.curation.id) | ||
const { cachedValue: { state } } = await contract.readState() | ||
return state | ||
} catch (error) { | ||
hasError.value = true | ||
console.error( | ||
`Error reading curation state for ${props.curation.id}`, | ||
error | ||
) | ||
} | ||
}) | ||
const curationTitle = computed(() => { | ||
if (state.value) { | ||
return state.value.title | ||
} | ||
const title = props.curation.tags.find(tag => tag.name === 'Title')?.value | ||
return title || props.curation.id | ||
}) | ||
const isInCuration = computed(() => { | ||
if (!state.value) { return false } | ||
return state.value.roles.curator.includes(props.address) | ||
}) | ||
const isCollaborative = computed(() => { | ||
if (!state.value) { return false } | ||
if (!state.value.roles) { return false } | ||
return 'roles' in state.value && 'curator' in state.value.roles | ||
}) | ||
const curationActionIcon = (isHovering?: boolean) => { | ||
return isInCuration.value | ||
? isHovering | ||
? 'mdi-minus' | ||
: 'mdi-check' | ||
: 'mdi-plus' | ||
} | ||
const onCurationActionClicked = debounce(async () => { | ||
loading.value = true | ||
const addOrRemove = isInCuration.value ? 'removeCurator' : 'addCurator' | ||
try { | ||
const curation = abc | ||
.curations | ||
.get<CollaborativeWhitelistCurationState>(props.curation.id) | ||
await curation.connect('use_wallet').writeInteraction({ | ||
function: addOrRemove, | ||
address: props.address | ||
}) | ||
await refresh() | ||
} catch (error) { | ||
hasError.value = true | ||
console.error( | ||
`Error ${addOrRemove} ${props.address} for curation ${props.curation.id}` | ||
) | ||
} | ||
loading.value = false | ||
}) | ||
</script> |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,12 @@ | ||
<template> | ||
<v-btn disabled justify="center"> | ||
<v-btn | ||
disabled | ||
elevation="2" | ||
variant="outlined" | ||
color="primary" | ||
density="compact" | ||
size="small" | ||
> | ||
Edit Profile | ||
</v-btn> | ||
</template> | ||
|
||
|
||
<style> | ||
</style> | ||
|
||
|
||
<script setup lang="ts"> | ||
</script> |
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 |
---|---|---|
@@ -1,15 +1,16 @@ | ||
<template> | ||
<v-btn disabled justify="center"> | ||
<v-btn | ||
disabled | ||
elevation="2" | ||
variant="outlined" | ||
color="primary" | ||
density="compact" | ||
size="small" | ||
> | ||
Tip | ||
</v-btn> | ||
</template> | ||
|
||
<style> | ||
</style> | ||
|
||
<script setup lang="ts"> | ||
defineProps<{ address: string }>() | ||
</script> |
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
Oops, something went wrong.