Ensure per-row SSL for apex, business.*, and customer.* hosts.
Lock icon probes live TLS and issues only missing certs; toast z-index sits above modals; ssl-sync agent supports blocking wait. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
co-authored by
Cursor
parent
aeaad0f645
commit
0212148a73
@@ -692,23 +692,39 @@ export function BusinessesPage() {
|
||||
}
|
||||
}
|
||||
|
||||
const domainSubmitGenRef = useRef(0)
|
||||
|
||||
function closeDomainModal() {
|
||||
domainSubmitGenRef.current += 1
|
||||
setDomainSubmitting(false)
|
||||
setDomainOpen(false)
|
||||
setDomainBusiness(null)
|
||||
setDomainId(null)
|
||||
setDomainHost('')
|
||||
setDomainGitRepoUrl('')
|
||||
setDomainError('')
|
||||
}
|
||||
|
||||
async function submitDomain() {
|
||||
if (!domainBusiness) return
|
||||
const host = domainHost.trim()
|
||||
if (!host) return
|
||||
const gitRepoUrl = domainGitRepoUrl.trim()
|
||||
const businessId = domainBusiness.id
|
||||
const submitId = ++domainSubmitGenRef.current
|
||||
|
||||
setDomainSubmitting(true)
|
||||
setDomainError('')
|
||||
try {
|
||||
if (domainId) {
|
||||
const updated = (await updateBusinessDomain(domainBusiness.id, domainId, {
|
||||
const updated = (await updateBusinessDomain(businessId, domainId, {
|
||||
host,
|
||||
...(gitRepoUrl ? { gitRepoUrl } : {}),
|
||||
})) as {
|
||||
id: number
|
||||
host: string
|
||||
deploySlug?: string | null
|
||||
gitRepoUrl?: string | null
|
||||
provisionError?: string | null
|
||||
}
|
||||
setData((prev) => {
|
||||
@@ -716,7 +732,18 @@ export function BusinessesPage() {
|
||||
return {
|
||||
...prev,
|
||||
items: prev.items.map((item) =>
|
||||
item.id === domainBusiness.id ? { ...item, domain: host } : item,
|
||||
item.id === businessId
|
||||
? {
|
||||
...item,
|
||||
domain: host,
|
||||
...(gitRepoUrl && !updated.provisionError
|
||||
? {
|
||||
gitRepoUrl: updated.gitRepoUrl ?? gitRepoUrl,
|
||||
deploySlug: updated.deploySlug ?? item.deploySlug,
|
||||
}
|
||||
: {}),
|
||||
}
|
||||
: item,
|
||||
),
|
||||
}
|
||||
})
|
||||
@@ -732,7 +759,7 @@ export function BusinessesPage() {
|
||||
showToast(`Domain updated to "${host}".`, 'success')
|
||||
}
|
||||
} else {
|
||||
const created = (await addBusinessDomain(domainBusiness.id, {
|
||||
const created = (await addBusinessDomain(businessId, {
|
||||
host,
|
||||
isPrimary: true,
|
||||
...(gitRepoUrl ? { gitRepoUrl } : {}),
|
||||
@@ -741,6 +768,7 @@ export function BusinessesPage() {
|
||||
host: string
|
||||
sslEnabled: boolean
|
||||
deploySlug?: string | null
|
||||
gitRepoUrl?: string | null
|
||||
provisionError?: string | null
|
||||
}
|
||||
setData((prev) => {
|
||||
@@ -748,12 +776,18 @@ export function BusinessesPage() {
|
||||
return {
|
||||
...prev,
|
||||
items: prev.items.map((item) =>
|
||||
item.id === domainBusiness.id
|
||||
item.id === businessId
|
||||
? {
|
||||
...item,
|
||||
domainId: created.id,
|
||||
domain: created.host,
|
||||
sslEnabled: created.sslEnabled ?? false,
|
||||
...(gitRepoUrl && !created.provisionError
|
||||
? {
|
||||
gitRepoUrl: created.gitRepoUrl ?? gitRepoUrl,
|
||||
deploySlug: created.deploySlug ?? null,
|
||||
}
|
||||
: {}),
|
||||
}
|
||||
: item,
|
||||
),
|
||||
@@ -771,14 +805,20 @@ export function BusinessesPage() {
|
||||
showToast(`Domain "${host}" added.`, 'success')
|
||||
}
|
||||
}
|
||||
if (submitId !== domainSubmitGenRef.current) return
|
||||
setDomainOpen(false)
|
||||
setDomainBusiness(null)
|
||||
setDomainId(null)
|
||||
setDomainHost('')
|
||||
setDomainGitRepoUrl('')
|
||||
setDomainError('')
|
||||
} catch (err) {
|
||||
if (submitId !== domainSubmitGenRef.current) return
|
||||
setDomainError(err instanceof ApiError ? err.message : 'Unable to save domain.')
|
||||
} finally {
|
||||
setDomainSubmitting(false)
|
||||
if (submitId === domainSubmitGenRef.current) {
|
||||
setDomainSubmitting(false)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1270,19 +1310,18 @@ export function BusinessesPage() {
|
||||
<Modal
|
||||
open={domainOpen}
|
||||
title={domainId ? 'Edit domain' : 'Add domain'}
|
||||
onClose={() => {
|
||||
setDomainOpen(false)
|
||||
setDomainBusiness(null)
|
||||
setDomainId(null)
|
||||
setDomainGitRepoUrl('')
|
||||
setDomainError('')
|
||||
}}
|
||||
onClose={closeDomainModal}
|
||||
>
|
||||
{domainError ? (
|
||||
<p className={styles.alertError} role="alert">
|
||||
{domainError}
|
||||
</p>
|
||||
) : null}
|
||||
{domainSubmitting && domainGitRepoUrl.trim() ? (
|
||||
<p className={styles.helperText} role="status">
|
||||
Saving domain and setting up storefront on the websites server…
|
||||
</p>
|
||||
) : null}
|
||||
<div className={styles.field}>
|
||||
<label htmlFor="domain-host">Domain</label>
|
||||
<input
|
||||
@@ -1300,7 +1339,7 @@ export function BusinessesPage() {
|
||||
id="domain-git-repo"
|
||||
value={domainGitRepoUrl}
|
||||
onChange={(e) => setDomainGitRepoUrl(e.target.value)}
|
||||
placeholder="https://git.meshkee.com/Meshkee-Websites/oaktasty.git"
|
||||
placeholder="https://git.meshkee.com/Meshkee-Websites/oaktasty.git"
|
||||
disabled={domainSubmitting}
|
||||
autoComplete="off"
|
||||
spellCheck={false}
|
||||
@@ -1315,8 +1354,7 @@ export function BusinessesPage() {
|
||||
<button
|
||||
type="button"
|
||||
className={`${styles.btn} ${styles.btnGhost}`}
|
||||
onClick={() => setDomainOpen(false)}
|
||||
disabled={domainSubmitting}
|
||||
onClick={closeDomainModal}
|
||||
>
|
||||
Cancel
|
||||
</button>
|
||||
@@ -1326,7 +1364,7 @@ export function BusinessesPage() {
|
||||
onClick={() => void submitDomain()}
|
||||
disabled={domainSubmitting || !domainHost.trim()}
|
||||
>
|
||||
Save
|
||||
{domainSubmitting ? 'Saving…' : 'Save'}
|
||||
</button>
|
||||
</div>
|
||||
</Modal>
|
||||
|
||||
Reference in New Issue
Block a user