Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
73 changes: 41 additions & 32 deletions packages/ui/src/components/billing/ServersPurchase1Region.vue
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ const props = defineProps<{
request: Archon.Servers.v0.StockRequest,
) => Promise<number>
custom: boolean
hideRegionSelection?: boolean
currency: string
interval: ServerBillingInterval
availableProducts: Labrinth.Billing.Internal.Product[]
Expand Down Expand Up @@ -219,17 +220,20 @@ onMounted(() => {
if (b.ping <= 0) return -1
return a.ping - b.ping
})[0]?.region
selectedRegion.value = undefined
selectedRam.value = minRam.value
if (!props.hideRegionSelection) {
selectedRegion.value = undefined
}
checkingCustomStock.value = true
updateStock().then(() => {
const firstWithStock = sortedRegions.value.find(
(region) => currentStock.value[region.shortcode] > 0,
)
let stockedRegion = selectedRegion.value
if (!stockedRegion) {
stockedRegion =
bestPing.value && currentStock.value[bestPing.value] > 0
stockedRegion = props.hideRegionSelection
? firstWithStock?.shortcode
: bestPing.value && currentStock.value[bestPing.value] > 0
? bestPing.value
: firstWithStock?.shortcode
}
Expand All @@ -247,36 +251,41 @@ onMounted(() => {
Checking availability...
</ModalLoadingIndicator>
<template v-else>
<h2 class="mt-0 mb-4 text-xl font-bold text-contrast">
{{ formatMessage(messages.prompt) }}
</h2>
<div class="grid grid-cols-1 sm:grid-cols-2 gap-4">
<ServersRegionButton
v-for="region in visibleRegions"
:key="region.shortcode"
v-model="selectedRegion"
:region="region"
:out-of-stock="currentStock[region.shortcode] === 0"
:ping="pings.find((p) => p.region === region.shortcode)?.ping"
:best-ping="bestPing === region.shortcode"
/>
</div>
<div class="mt-3 text-sm">
<IntlFormatted :message-id="messages.regionUnsupported">
<template #link="{ children }">
<a
class="text-link"
target="_blank"
rel="noopener noreferrer"
href="https://surveys.modrinth.com/servers-region-waitlist"
>
<component :is="() => children" />
</a>
</template>
</IntlFormatted>
</div>
<template v-if="!hideRegionSelection">
<h2 class="mt-0 mb-4 text-xl font-bold text-contrast">
{{ formatMessage(messages.prompt) }}
</h2>
<div class="grid grid-cols-1 sm:grid-cols-2 gap-4">
<ServersRegionButton
v-for="region in visibleRegions"
:key="region.shortcode"
v-model="selectedRegion"
:region="region"
:out-of-stock="currentStock[region.shortcode] === 0"
:ping="pings.find((p) => p.region === region.shortcode)?.ping"
:best-ping="bestPing === region.shortcode"
/>
</div>
<div class="mt-3 text-sm">
<IntlFormatted :message-id="messages.regionUnsupported">
<template #link="{ children }">
<a
class="text-link"
target="_blank"
rel="noopener noreferrer"
href="https://surveys.modrinth.com/servers-region-waitlist"
>
<component :is="() => children" />
</a>
</template>
</IntlFormatted>
</div>
</template>
<template v-if="custom">
<h2 class="mt-4 mb-2 text-xl font-bold text-contrast">
<h2
class="mb-2 text-xl font-bold text-contrast"
:class="hideRegionSelection ? 'mt-0' : 'mt-4'"
>
{{ formatMessage(messages.customPrompt) }}
</h2>
<div>
Expand Down
Loading