Skip to content

Commit 3241453

Browse files
committed
more fixes and improvements to the dashboard
1 parent 01141cd commit 3241453

File tree

3 files changed

+27
-43
lines changed

3 files changed

+27
-43
lines changed

src/lib/server/stripe.server.ts

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -169,26 +169,15 @@ export async function createAccount(
169169
}
170170

171171
export async function getOnboardingLink(baseURL: string, scripter: Scripter) {
172-
const account = await getAccount(scripter)
173-
174172
let accountLink: Stripe.Response<Stripe.AccountLink>
175173

176174
try {
177-
if (!account!.tos_acceptance || !account!.tos_acceptance.date) {
178-
accountLink = await stripe.accountLinks.create({
179-
account: account!.id,
180-
refresh_url: baseURL + "/api/stripe/connect/reauth",
181-
return_url: baseURL + "/api/stripe/connect/return",
182-
type: "account_onboarding"
183-
})
184-
} else {
185-
accountLink = await stripe.accountLinks.create({
186-
account: account!.id,
187-
refresh_url: baseURL + "/api/stripe/connect/reauth",
188-
return_url: baseURL + "/api/stripe/connect/return",
189-
type: "account_update"
190-
})
191-
}
175+
accountLink = await stripe.accountLinks.create({
176+
account: scripter.stripe,
177+
refresh_url: baseURL + "/api/stripe/connect/reauth",
178+
return_url: baseURL + "/api/stripe/connect/return",
179+
type: "account_onboarding"
180+
})
192181
} catch (err) {
193182
console.error(err)
194183
return

src/routes/dashboard/[slug]/stripe/+page.server.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ export const actions = {
5757
return { form }
5858
},
5959

60-
updateStripe: async ({
60+
onboardStripe: async ({
6161
locals: { supabaseServer, user, getProfile },
6262
url: { origin },
6363
params: { slug }

src/routes/dashboard/[slug]/stripe/+page.svelte

Lines changed: 20 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -109,31 +109,26 @@
109109
</button>
110110
</form>
111111
{:else}
112-
<div class="flex justify-around">
113-
<form method="POST" action="?/displayName" class="my-32 flex place-items-center" use:dbaEnhance>
114-
<div class="my-4">
115-
<label for="dba">Invoice display name:</label>
116-
<input class="my-2 input" name="dba" id="dba" bind:value={$dbaForm.dba} />
117-
{#if $dbaErrors.dba}
118-
<div
119-
class="max-h-24 overflow-x-hidden overflow-y-scroll rounded-md bg-surface-700 text-error-500"
120-
>
121-
{#each $dbaErrors.dba as err (err)}
122-
{err}
123-
{/each}
124-
</div>
125-
{/if}
126-
</div>
127-
<button class="mx-4 mt-6 btn h-10 preset-filled-secondary-500">Update</button>
128-
</form>
112+
<form method="POST" action="?/displayName" class="mx-auto my-32 flex justify-center" use:dbaEnhance>
113+
<div class="my-4">
114+
<label for="dba">Invoice display name:</label>
115+
<input class="my-2 input" name="dba" id="dba" bind:value={$dbaForm.dba} />
116+
{#if $dbaErrors.dba}
117+
<div
118+
class="max-h-24 overflow-x-hidden overflow-y-scroll rounded-md bg-surface-700 text-error-500"
119+
>
120+
{#each $dbaErrors.dba as err (err)}
121+
{err}
122+
{/each}
123+
</div>
124+
{/if}
125+
</div>
126+
<button class="mx-4 mt-6 btn h-10 preset-filled-secondary-500">Update</button>
127+
</form>
129128

130-
<form method="POST" action="?/updateStripe" class="my-32 block place-items-center">
131-
<div class="my-4 grid">
132-
<span>Account information</span>
133-
<button class="my-2 btn h-10 preset-filled-secondary-500"> Update stripe connected account </button>
134-
</div>
135-
</form>
136-
</div>
129+
<form method="POST" action="?/onboardStripe" class="flex justify-center">
130+
<button class="my-2 btn h-10 preset-filled-secondary-500"> Update stripe connected account </button>
131+
</form>
137132

138133
{#if account}
139134
{#if account.requirements?.currently_due && account.requirements?.currently_due.length > 0}
@@ -153,7 +148,7 @@
153148
</div>
154149
{/if}
155150

156-
<form method="POST" action="?/stripeDashboard" class="my-32 block place-items-center">
151+
<form method="POST" action="?/stripeDashboard" class="flex justify-center">
157152
<button class="my-2 btn h-10 preset-filled-secondary-500"> Stripe Dashboard </button>
158153
</form>
159154
{/if}

0 commit comments

Comments
 (0)