flotilla/src/app/components/SignUpProfile.svelte

34 lines
1,017 B
Svelte
Raw Normal View History

2025-02-14 18:53:36 +00:00
<script lang="ts">
import type {Profile} from "@welshman/util"
2025-06-10 20:35:57 +00:00
import {PROFILE, createProfile, makeProfile, makeEvent} from "@welshman/util"
2025-04-11 18:51:15 +00:00
import {loginWithNip01, publishThunk} from "@welshman/app"
2025-02-14 18:53:36 +00:00
import Button from "@lib/components/Button.svelte"
import ProfileEditForm from "@app/components/ProfileEditForm.svelte"
import {INDEXER_RELAYS} from "@app/state"
type Props = {
secret: string
}
2025-04-11 18:51:15 +00:00
const {secret}: Props = $props()
2025-02-14 18:53:36 +00:00
2025-04-15 16:36:39 +00:00
const initialValues = {
profile: makeProfile(),
shouldBroadcast: true,
}
const onsubmit = ({profile, shouldBroadcast}: {profile: Profile; shouldBroadcast: boolean}) => {
2025-06-10 20:35:57 +00:00
const event = makeEvent(PROFILE, createProfile(profile))
2025-04-15 16:36:39 +00:00
const relays = shouldBroadcast ? INDEXER_RELAYS : []
2025-02-14 18:53:36 +00:00
2025-04-11 18:51:15 +00:00
loginWithNip01(secret)
2025-04-15 16:36:39 +00:00
publishThunk({event, relays})
2025-02-14 18:53:36 +00:00
}
</script>
2025-04-15 16:36:39 +00:00
<ProfileEditForm hideAddress {initialValues} {onsubmit}>
2025-02-14 18:53:36 +00:00
{#snippet footer()}
<Button type="submit" class="btn btn-primary">Create Account</Button>
{/snippet}
</ProfileEditForm>