flotilla/src/app/components/PinAdd.svelte

29 lines
719 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
2026-07-06 18:53:12 +00:00
const submit = async ({title, topics, value, content}: PinFormValues) => {
2026-06-23 23:30:54 +00:00
const params = referenceToPin(value)
if (!params) return "Please enter a valid URL or nostr link."
2026-07-06 18:53:12 +00:00
return createPin(url, {...params, boards: [address], title, topics, description: content})
2026-06-23 23:30:54 +00:00
}
</script>
<PinForm
{url}
heading="Add Link"
action="Add link"
successMessage="Link added!"
values={{value: reference}}
{submit} />