flotilla/src/app/components/PinAdd.svelte

29 lines
688 B
Svelte
Raw Normal View History

2026-06-23 23:30:54 +00:00
<script lang="ts">
import PinForm, {type PinFormValues} from "@app/components/PinForm.svelte"
import {createPin, referenceToPin} from "@app/pinboards"
type Props = {
url: string
address: string
reference?: string
2026-06-23 23:30:54 +00:00
}
const {url, address, reference}: Props = $props()
2026-06-23 23:30:54 +00:00
const submit = async ({title, topics, value}: PinFormValues) => {
const params = referenceToPin(value)
if (!params) return "Please enter a valid URL or nostr link."
return createPin(url, {...params, boards: [address], title, topics})
}
</script>
<PinForm
{url}
heading="Add Link"
action="Add link"
successMessage="Link added!"
values={{value: reference}}
{submit} />