Skip to content

Commit 63bc99d

Browse files
committed
feat: add loading state to invite form
1 parent efa4255 commit 63bc99d

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

apps/resplice/src/modules/invite/components/PhoneInviteForm.svelte

+4-1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
countryCode: 'US' as CountryCode
1313
}
1414
let formErrs: Record<string, string> = {}
15+
let isLoading = false
1516
1617
async function onInvite(_e: Event) {
1718
formErrs = {}
@@ -26,6 +27,7 @@
2627
2728
const { number } = parsePhoneNumber(phone.value, phone.countryCode)
2829
try {
30+
isLoading = true
2931
await protocol.invite.create({ name, value: { $case: 'phone', phone: number } })
3032
toast.new({
3133
type: toast.type.SUCCESS,
@@ -41,6 +43,7 @@
4143
// }
4244
// formErrs = {}
4345
} catch (err) {
46+
isLoading = false
4447
console.error(err)
4548
toast.new({
4649
type: toast.type.DANGER,
@@ -66,5 +69,5 @@
6669
<PhoneField name="phone" label="Enter Phone" bind:phone error={formErrs.phone} />
6770
</div>
6871

69-
<Button class="w-48" type="submit">Send</Button>
72+
<Button class="w-48" type="submit" {isLoading}>Send</Button>
7073
</form>

0 commit comments

Comments
 (0)