You've already forked AstralRinth
forked from didirus/AstralRinth
* feat: start on tax compliance * feat: avarala1099 composable * fix: shouldShow should be managed on the page itself * refactor: move show logic to revenue page * feat: security practices rather than info * feat: withdraw page lock * fix: empty modal bug & lint issues * feat: hide behind feature flag * Use standard admonition components, make casing consistent * modal title * lint * feat: withdrawal check * feat: tax cap on withdrawals warning * feat: start on revenue page overhaul * feat: segment generation for bar * feat: tooltips and links * fix: tooltip border * feat: finish initial layout, start on withdraw modal * feat: start on withdrawal limit stage * feat: shade support for primary colors * feat: start on withdraw details stage * fix: convert swatches to hex * feat: payout method/region dropdown temporarily using multiselect * feat: fix modal open issues and use teleport dropdowns * feat: hide transactions section if there are no transactions * refactor: NavStack surfaces * feat: new dropdown component * feat: remove teleport dropdown modal in favour of new combobox component * fix: lint * refactor: dashboard sidebar layout * feat: cleanup * fix: niche bugs * fix: ComboBox styling * feat: first part of qa * feat: animate flash rather than tooltip * fix: lint * feat: qa border gradient * fix: seg hover flashes * feat: i18n * feat: i18n and final QA * fix: lint * feat: QA * fix: lint * fix: merge conflicts * fix: intl * fix: blue hover * fix: transfers page * feat: surface variables & gradients * feat: text vars * fix: lint * fix: intl * feat: stages * fix: lint * feat: region selection * feat: method selection btns * fix: flex col on transactions * feat: hook up method selection to ctx * feat: muralpay kyc stage info * wip: muralpay integration * Basic Mural Pay API bindings * Fix clippy * use dotenvy in muralpay example * Refactor payout creation code * wip: muralpay payout requests * Mural Pay payouts work * Fix clippy * feat: progress * fix: broken tax form stage logic * polish: tax form stage and method selection stage layout * add mural pay fees API * Work on payout fee API * Fees API for more payment methods * Fix CI * polish: muralpay qa * refactor: clean up combobox component * polish: change from critical -> warning admonition in MuralpayDetailsStage * Temporarily disable Venmo and PayPal methods from frontend * polish: clean up transaction component & page * polish: navbar qa, text color-contrast in chips type buttonstyled, mb on rev/index.vue page * fix: incorrectly using available balance as tax form withdraw limit after tax forms submitted * wip: counterparties * Start on counterparties and payment methods API * polish: combobox component * polish: fix broken scroll logic using a composable & web:fix * fix: lint * polish: various QA fixes * feat: hook up with backend (wip) * feat: draft muralpay rails dynamic logic * polish: modify rails to support backend changes * Mural Pay multiple methods when fetching * Don't send supported_countries to frontend * Mural Pay multiple methods when fetching * Don't send supported_countries to frontend * feat: fees & methods endpoint hookup * chore: remove duplicates fix * polish: qa changes + figma match * Add countries to muralpay fiat methods * Compile fix * Add exchange rate info to fees endpoint * Add fees to premium Tremendous options * polish: i18n and better document type dropdown -> id input labels * feat: tremendous * fix: lint & i18n * feat: reintroduce tin mismatch logic to index.vue * polish: qa * fix: i18n * feat: remove teleport dropdown menu - combobox should be used * fix: lint * fix: jsdoc * feat: checkbox for reward program terms * Add delivery email field to Tremendous payouts * Add Tremendous product category to payout methods * Add bank details API to muralpay * Fix CI * Fix CI * polish: qa changes * feat: i18n pass * feat: deduplicate methods endpoint & fix i18n issues * chore: deduplicate i18n strings into common-messages.ts * fix: lint * fix: i18n * feat: estimates * polish: more QA * Remove prepaid visa, compute fees properly for Tremendous methods * Add more details to Tremendous errors * feat: withdraw endpoint impl & internals refactor * Add more details to Tremendous errors * feat: completion stage * Add fees to Mural * feat: transactions page match figma * fix: i18n * polish: QA changes * polish: qa * Payout history route and bank details * polish: autofill and requirements checks * fix: i18n + lint * fix: fiat rail fees * polish: move scroll fade stuff into NewModal rather than just CreatorWithdrawModal * feat: simplify action btn logic & tax form error * fix: tax -> Tax form * Re-add legacy PayPal/Venmo options for US * feat: mobile responsiveness fixes for modal * fix: responsiveness issues * feat: navstack responsiveness * fix: responsiveness * move the mural bank details route * fix: generated state cleanup & bank details input * fix: lint & i18n * Add utoipa support to payout endpoints * address some PR comments * polish: qa * add CORS to new utoipa routes * feat: legacy paypal/venmo stage * polish: reset amount on back qa * revert: navstack mr changes * polish: loading indicator on method selection stage * fix: paypal modal doesnt reopen after auth * fix: lint & i18n * fix: paypal flow * polish: qa changes * fix: gitignore * polish: qa fixes * fix: payouts_available in payouts.rs * fix: bug when limit is zero * polish: qa changes * fix: qa stuff & muralpay sub-division fix * Immediately approve mural payouts * Add currency support to Tremendous payouts * Currency forex * add forex to tremendous fee request * polish: qa & currency support for paypal tremendous * polish: fx qa * feat: demo mode flag * fix: i18n & padding issues * polish: qa changes * fix: ml * Add Mural balance to bank balance info * polish: show warning for paypal international USD withdrawals + more currencies * Add more Tremendous currencies support * fix: colors on balance bars * fix: empty states * fix: pl-8 mobile issue * fix: hide see all * Transaction payouts available use the correct date * Address my own review comment * Address PR comments * Change Mural withdrawal limit to 3k * fix: empty state + paypal warning * maybe fix tremendous gift cards * Change how Mural minimum withdrawals are calculated * Tweak min/max withdrawal values * fix: segment brightness * fix: min & max for muralpay & legacy paypal * Fix some icon issues * more issues * fix user menu * fix: remove + network --------- Signed-off-by: Calum H. <contact@cal.engineer> Co-authored-by: Prospector <6166773+Prospector@users.noreply.github.com> Co-authored-by: aecsocket <aecsocket@tutanota.com> Co-authored-by: Alejandro González <me@alegon.dev>
967 lines
27 KiB
Vue
967 lines
27 KiB
Vue
<template>
|
|
<div v-if="user" class="experimental-styles-within">
|
|
<ModalCreation ref="modal_creation" />
|
|
<CollectionCreateModal ref="modal_collection_creation" />
|
|
<NewModal ref="editRoleModal" header="Edit role">
|
|
<div class="flex w-80 flex-col gap-4">
|
|
<div class="flex flex-col gap-2">
|
|
<Combobox v-model="selectedRole" :options="roleOptions" placeholder="Select a role" />
|
|
</div>
|
|
<div class="flex justify-end gap-2">
|
|
<ButtonStyled>
|
|
<button @click="cancelRoleEdit">
|
|
<XIcon />
|
|
{{ formatMessage(commonMessages.cancelButton) }}
|
|
</button>
|
|
</ButtonStyled>
|
|
<ButtonStyled color="brand">
|
|
<button
|
|
:disabled="!selectedRole || selectedRole === user.role || isSavingRole"
|
|
@click="saveRoleEdit"
|
|
>
|
|
<template v-if="isSavingRole">
|
|
<SpinnerIcon class="animate-spin" /> {{ formatMessage(messages.savingLabel) }}
|
|
</template>
|
|
<template v-else>
|
|
<SaveIcon /> {{ formatMessage(commonMessages.saveChangesButton) }}
|
|
</template>
|
|
</button>
|
|
</ButtonStyled>
|
|
</div>
|
|
</div>
|
|
</NewModal>
|
|
<NewModal v-if="auth.user && isStaff(auth.user)" ref="userDetailsModal" header="User details">
|
|
<div class="flex flex-col gap-3">
|
|
<div class="flex flex-col gap-1">
|
|
<span class="text-lg font-bold text-primary">{{
|
|
formatMessage(messages.emailLabel)
|
|
}}</span>
|
|
<div>
|
|
<span
|
|
v-tooltip="
|
|
user.email_verified
|
|
? formatMessage(messages.emailVerifiedTooltip)
|
|
: formatMessage(messages.emailNotVerifiedTooltip)
|
|
"
|
|
class="flex w-fit items-center gap-1"
|
|
>
|
|
<span>{{ user.email }}</span>
|
|
<CheckIcon v-if="user.email_verified" class="h-4 w-4 text-brand" />
|
|
<XIcon v-else class="h-4 w-4 text-red" />
|
|
</span>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="flex flex-col gap-1">
|
|
<span class="text-lg font-bold text-primary">{{
|
|
formatMessage(messages.authProvidersLabel)
|
|
}}</span>
|
|
<span>{{ user.auth_providers.join(', ') }}</span>
|
|
</div>
|
|
|
|
<div class="flex flex-col gap-1">
|
|
<span class="text-lg font-bold text-primary">{{
|
|
formatMessage(messages.paymentMethodsLabel)
|
|
}}</span>
|
|
<span>
|
|
<template v-if="user.payout_data?.paypal_address">
|
|
Paypal ({{ user.payout_data.paypal_address }} - {{ user.payout_data.paypal_country }})
|
|
</template>
|
|
<template v-if="user.payout_data?.paypal_address && user.payout_data?.venmo_address">
|
|
,
|
|
</template>
|
|
<template v-if="user.payout_data?.venmo_address">
|
|
Venmo ({{ user.payout_data.venmo_address }})
|
|
</template>
|
|
</span>
|
|
</div>
|
|
|
|
<div class="flex flex-col gap-1">
|
|
<span class="text-lg font-bold text-primary">{{
|
|
formatMessage(messages.hasPasswordLabel)
|
|
}}</span>
|
|
<span>
|
|
{{
|
|
user.has_password ? formatMessage(messages.yesLabel) : formatMessage(messages.noLabel)
|
|
}}
|
|
</span>
|
|
</div>
|
|
|
|
<div class="flex flex-col gap-1">
|
|
<span class="text-lg font-bold text-primary">{{
|
|
formatMessage(messages.hasTotpLabel)
|
|
}}</span>
|
|
<span>
|
|
{{ user.has_totp ? formatMessage(messages.yesLabel) : formatMessage(messages.noLabel) }}
|
|
</span>
|
|
</div>
|
|
</div>
|
|
</NewModal>
|
|
<div class="new-page sidebar" :class="{ 'alt-layout': cosmetics.leftContentLayout }">
|
|
<div class="normal-page__header py-4">
|
|
<ContentPageHeader>
|
|
<template #icon>
|
|
<Avatar :src="user.avatar_url" :alt="user.username" size="96px" circle />
|
|
</template>
|
|
<template #title>
|
|
<span class="flex items-center gap-2">
|
|
{{ user.username }}
|
|
<TagItem
|
|
v-if="isAdminViewing && isAffiliate"
|
|
:style="{
|
|
'--_color': 'var(--color-brand)',
|
|
'--_bg-color': 'var(--color-brand-highlight)',
|
|
}"
|
|
>
|
|
<AffiliateIcon /> Affiliate
|
|
</TagItem>
|
|
</span>
|
|
</template>
|
|
<template #summary>
|
|
{{
|
|
user.bio
|
|
? user.bio
|
|
: projects.length === 0
|
|
? formatMessage(messages.bioFallbackUser)
|
|
: formatMessage(messages.bioFallbackCreator)
|
|
}}
|
|
</template>
|
|
<template #stats>
|
|
<div
|
|
class="flex items-center gap-2 border-0 border-r border-solid border-divider pr-4 font-semibold"
|
|
>
|
|
<BoxIcon class="h-6 w-6 text-secondary" />
|
|
{{
|
|
formatMessage(messages.profileProjectsLabel, {
|
|
count: formatCompactNumber(projects?.length || 0),
|
|
})
|
|
}}
|
|
</div>
|
|
<div
|
|
v-tooltip="sumDownloads.toLocaleString()"
|
|
class="flex items-center gap-2 border-0 border-r border-solid border-divider pr-4 font-semibold"
|
|
>
|
|
<DownloadIcon class="h-6 w-6 text-secondary" />
|
|
{{
|
|
formatMessage(messages.profileDownloadsLabel, {
|
|
count: formatCompactNumber(sumDownloads),
|
|
})
|
|
}}
|
|
</div>
|
|
<div
|
|
v-tooltip="
|
|
formatMessage(commonMessages.dateAtTimeTooltip, {
|
|
date: new Date(user.created),
|
|
time: new Date(user.created),
|
|
})
|
|
"
|
|
class="flex items-center gap-2 font-semibold"
|
|
>
|
|
<CalendarIcon class="h-6 w-6 text-secondary" />
|
|
{{ formatMessage(messages.profileJoinedLabel) }}
|
|
{{ formatRelativeTime(user.created) }}
|
|
</div>
|
|
</template>
|
|
<template #actions>
|
|
<ButtonStyled size="large">
|
|
<NuxtLink v-if="auth.user && auth.user.id === user.id" to="/settings/profile">
|
|
<EditIcon aria-hidden="true" />
|
|
{{ formatMessage(commonMessages.editButton) }}
|
|
</NuxtLink>
|
|
</ButtonStyled>
|
|
<ButtonStyled size="large" circular type="transparent">
|
|
<OverflowMenu
|
|
:options="[
|
|
{
|
|
id: 'manage-projects',
|
|
action: () => navigateTo('/dashboard/projects'),
|
|
hoverOnly: true,
|
|
shown: auth.user && auth.user.id === user.id,
|
|
},
|
|
{ divider: true, shown: auth.user && auth.user.id === user.id },
|
|
{
|
|
id: 'report',
|
|
action: () => (auth.user ? reportUser(user.id) : navigateTo('/auth/sign-in')),
|
|
color: 'red',
|
|
hoverOnly: true,
|
|
shown: auth.user?.id !== user.id,
|
|
},
|
|
{ id: 'copy-id', action: () => copyId() },
|
|
{ id: 'copy-permalink', action: () => copyPermalink() },
|
|
{
|
|
divider: true,
|
|
shown: auth.user && isAdmin(auth.user),
|
|
},
|
|
{
|
|
id: 'open-billing',
|
|
action: () => navigateTo(`/admin/billing/${user.id}`),
|
|
shown: auth.user && isStaff(auth.user),
|
|
},
|
|
{
|
|
id: 'toggle-affiliate',
|
|
action: () => toggleAffiliate(user.id),
|
|
shown: isAdminViewing,
|
|
remainOnClick: true,
|
|
color: isAffiliate ? 'red' : 'orange',
|
|
},
|
|
{
|
|
id: 'open-info',
|
|
action: () => $refs.userDetailsModal.show(),
|
|
shown: auth.user && isStaff(auth.user),
|
|
},
|
|
{
|
|
id: 'edit-role',
|
|
action: () => openRoleEditModal(),
|
|
shown: auth.user && isAdmin(auth.user),
|
|
},
|
|
]"
|
|
aria-label="More options"
|
|
:dropdown-id="`${baseId}-more-options`"
|
|
>
|
|
<MoreVerticalIcon aria-hidden="true" />
|
|
<template #manage-projects>
|
|
<BoxIcon aria-hidden="true" />
|
|
{{ formatMessage(messages.profileManageProjectsButton) }}
|
|
</template>
|
|
<template #report>
|
|
<ReportIcon aria-hidden="true" />
|
|
{{ formatMessage(commonMessages.reportButton) }}
|
|
</template>
|
|
<template #copy-id>
|
|
<ClipboardCopyIcon aria-hidden="true" />
|
|
{{ formatMessage(commonMessages.copyIdButton) }}
|
|
</template>
|
|
<template #copy-permalink>
|
|
<ClipboardCopyIcon aria-hidden="true" />
|
|
{{ formatMessage(commonMessages.copyPermalinkButton) }}
|
|
</template>
|
|
<template #open-billing>
|
|
<CurrencyIcon aria-hidden="true" />
|
|
{{ formatMessage(messages.billingButton) }}
|
|
</template>
|
|
<template #open-info>
|
|
<InfoIcon aria-hidden="true" />
|
|
{{ formatMessage(messages.infoButton) }}
|
|
</template>
|
|
<template #toggle-affiliate>
|
|
<AffiliateIcon aria-hidden="true" />
|
|
{{
|
|
formatMessage(
|
|
isAffiliate ? messages.removeAffiliateButton : messages.setAffiliateButton,
|
|
)
|
|
}}
|
|
</template>
|
|
<template #edit-role>
|
|
<EditIcon aria-hidden="true" />
|
|
{{ formatMessage(messages.editRoleButton) }}
|
|
</template>
|
|
</OverflowMenu>
|
|
</ButtonStyled>
|
|
</template>
|
|
</ContentPageHeader>
|
|
</div>
|
|
<div class="normal-page__content">
|
|
<div v-if="navLinks.length >= 2" class="mb-4 max-w-full overflow-x-auto">
|
|
<NavTabs :links="navLinks" />
|
|
</div>
|
|
<div v-if="projects.length > 0">
|
|
<div
|
|
v-if="route.params.projectType !== 'collections'"
|
|
:class="'project-list display-mode--' + cosmetics.searchDisplayMode.user"
|
|
>
|
|
<ProjectCard
|
|
v-for="project in (route.params.projectType !== undefined
|
|
? projects.filter(
|
|
(x) =>
|
|
x.project_type ===
|
|
route.params.projectType.substr(0, route.params.projectType.length - 1),
|
|
)
|
|
: projects
|
|
)
|
|
.slice()
|
|
.sort((a, b) => b.downloads - a.downloads)"
|
|
:id="project.slug || project.id"
|
|
:key="project.id"
|
|
:name="project.title"
|
|
:display="cosmetics.searchDisplayMode.user"
|
|
:featured-image="project.gallery.find((element) => element.featured)?.url"
|
|
:description="project.description"
|
|
:created-at="project.published"
|
|
:updated-at="project.updated"
|
|
:downloads="project.downloads.toString()"
|
|
:follows="project.followers.toString()"
|
|
:icon-url="project.icon_url"
|
|
:categories="project.categories"
|
|
:client-side="project.client_side"
|
|
:server-side="project.server_side"
|
|
:status="
|
|
auth.user && (auth.user.id === user.id || tags.staffRoles.includes(auth.user.role))
|
|
? project.status
|
|
: null
|
|
"
|
|
:type="project.project_type"
|
|
:color="project.color"
|
|
/>
|
|
</div>
|
|
</div>
|
|
<div v-else-if="route.params.projectType !== 'collections'" class="error">
|
|
<UpToDate class="icon" />
|
|
<br />
|
|
<span v-if="auth.user && auth.user.id === user.id" class="preserve-lines text">
|
|
<IntlFormatted :message-id="messages.profileNoProjectsAuthLabel">
|
|
<template #create-link="{ children }">
|
|
<a class="link" @click.prevent="$refs.modal_creation.show()">
|
|
<component :is="() => children" />
|
|
</a>
|
|
</template>
|
|
</IntlFormatted>
|
|
</span>
|
|
<span v-else class="text">{{ formatMessage(messages.profileNoProjectsLabel) }}</span>
|
|
</div>
|
|
<div v-if="['collections'].includes(route.params.projectType)" class="collections-grid">
|
|
<nuxt-link
|
|
v-for="collection in collections.sort(
|
|
(a, b) => new Date(b.created) - new Date(a.created),
|
|
)"
|
|
:key="collection.id"
|
|
:to="`/collection/${collection.id}`"
|
|
class="card collection-item"
|
|
>
|
|
<div class="collection">
|
|
<Avatar :src="collection.icon_url" class="icon" />
|
|
<div class="details">
|
|
<h2 class="title">{{ collection.name }}</h2>
|
|
<div class="stats">
|
|
<LibraryIcon aria-hidden="true" />
|
|
{{ formatMessage(messages.collectionLabel) }}
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="description">
|
|
{{ collection.description }}
|
|
</div>
|
|
<div class="stat-bar">
|
|
<div class="stats">
|
|
<BoxIcon />
|
|
{{
|
|
`${$formatNumber(collection.projects?.length || 0, false)} project${
|
|
(collection.projects?.length || 0) !== 1 ? 's' : ''
|
|
}`
|
|
}}
|
|
</div>
|
|
<div class="stats">
|
|
<template v-if="collection.status === 'listed'">
|
|
<GlobeIcon />
|
|
<span> {{ formatMessage(commonMessages.publicLabel) }} </span>
|
|
</template>
|
|
<template v-else-if="collection.status === 'unlisted'">
|
|
<LinkIcon />
|
|
<span> {{ formatMessage(commonMessages.unlistedLabel) }} </span>
|
|
</template>
|
|
<template v-else-if="collection.status === 'private'">
|
|
<LockIcon />
|
|
<span> {{ formatMessage(commonMessages.privateLabel) }} </span>
|
|
</template>
|
|
<template v-else-if="collection.status === 'rejected'">
|
|
<XIcon />
|
|
<span> {{ formatMessage(commonMessages.rejectedLabel) }} </span>
|
|
</template>
|
|
</div>
|
|
</div>
|
|
</nuxt-link>
|
|
</div>
|
|
<div
|
|
v-if="route.params.projectType === 'collections' && collections.length === 0"
|
|
class="error"
|
|
>
|
|
<UpToDate class="icon" />
|
|
<br />
|
|
<span v-if="auth.user && auth.user.id === user.id" class="preserve-lines text">
|
|
<IntlFormatted :message-id="messages.profileNoCollectionsAuthLabel">
|
|
<template #create-link="{ children }">
|
|
<a
|
|
class="link"
|
|
@click.prevent="(event) => $refs.modal_collection_creation.show(event)"
|
|
>
|
|
<component :is="() => children" />
|
|
</a>
|
|
</template>
|
|
</IntlFormatted>
|
|
</span>
|
|
<span v-else class="text">{{ formatMessage(messages.profileNoCollectionsLabel) }}</span>
|
|
</div>
|
|
</div>
|
|
<div class="normal-page__sidebar">
|
|
<div v-if="organizations.length > 0" class="card flex-card">
|
|
<h2 class="text-lg text-contrast">
|
|
{{ formatMessage(messages.profileOrganizations) }}
|
|
</h2>
|
|
<div class="flex flex-wrap gap-2">
|
|
<nuxt-link
|
|
v-for="org in sortedOrgs"
|
|
:key="org.id"
|
|
v-tooltip="org.name"
|
|
class="organization"
|
|
:to="`/organization/${org.slug}`"
|
|
>
|
|
<Avatar :src="org.icon_url" :alt="'Icon for ' + org.name" size="3rem" />
|
|
</nuxt-link>
|
|
</div>
|
|
</div>
|
|
<div v-if="badges.length > 0" class="card flex-card">
|
|
<h2 class="text-lg text-contrast">
|
|
{{ formatMessage(messages.profileBadges) }}
|
|
</h2>
|
|
<div class="flex flex-wrap gap-2">
|
|
<div v-for="badge in badges" :key="badge">
|
|
<StaffBadge v-if="badge === 'staff'" class="h-14 w-14" />
|
|
<ModBadge v-else-if="badge === 'mod'" class="h-14 w-14" />
|
|
<nuxt-link v-else-if="badge === 'plus'" to="/plus">
|
|
<PlusBadge class="h-14 w-14" />
|
|
</nuxt-link>
|
|
<TenMClubBadge v-else-if="badge === '10m-club'" class="h-14 w-14" />
|
|
<EarlyAdopterBadge v-else-if="badge === 'early-adopter'" class="h-14 w-14" />
|
|
<AlphaTesterBadge v-else-if="badge === 'alpha-tester'" class="h-14 w-14" />
|
|
<BetaTesterBadge v-else-if="badge === 'beta-tester'" class="h-14 w-14" />
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<AdPlaceholder v-if="!auth.user" />
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</template>
|
|
<script setup>
|
|
import {
|
|
AffiliateIcon,
|
|
BoxIcon,
|
|
CalendarIcon,
|
|
CheckIcon,
|
|
ClipboardCopyIcon,
|
|
CurrencyIcon,
|
|
DownloadIcon,
|
|
EditIcon,
|
|
GlobeIcon,
|
|
InfoIcon,
|
|
LibraryIcon,
|
|
LinkIcon,
|
|
LockIcon,
|
|
MoreVerticalIcon,
|
|
ReportIcon,
|
|
SaveIcon,
|
|
SpinnerIcon,
|
|
XIcon,
|
|
} from '@modrinth/assets'
|
|
import {
|
|
Avatar,
|
|
ButtonStyled,
|
|
Combobox,
|
|
commonMessages,
|
|
ContentPageHeader,
|
|
injectNotificationManager,
|
|
NewModal,
|
|
OverflowMenu,
|
|
TagItem,
|
|
useRelativeTime,
|
|
} from '@modrinth/ui'
|
|
import { isAdmin, UserBadge } from '@modrinth/utils'
|
|
import { IntlFormatted } from '@vintl/vintl/components'
|
|
|
|
import TenMClubBadge from '~/assets/images/badges/10m-club.svg?component'
|
|
import AlphaTesterBadge from '~/assets/images/badges/alpha-tester.svg?component'
|
|
import BetaTesterBadge from '~/assets/images/badges/beta-tester.svg?component'
|
|
import EarlyAdopterBadge from '~/assets/images/badges/early-adopter.svg?component'
|
|
import ModBadge from '~/assets/images/badges/mod.svg?component'
|
|
import PlusBadge from '~/assets/images/badges/plus.svg?component'
|
|
import StaffBadge from '~/assets/images/badges/staff.svg?component'
|
|
import UpToDate from '~/assets/images/illustrations/up_to_date.svg?component'
|
|
import AdPlaceholder from '~/components/ui/AdPlaceholder.vue'
|
|
import CollectionCreateModal from '~/components/ui/create/CollectionCreateModal.vue'
|
|
import ModalCreation from '~/components/ui/create/ProjectCreateModal.vue'
|
|
import NavTabs from '~/components/ui/NavTabs.vue'
|
|
import ProjectCard from '~/components/ui/ProjectCard.vue'
|
|
import { isStaff } from '~/helpers/users.js'
|
|
import { reportUser } from '~/utils/report-helpers.ts'
|
|
|
|
const data = useNuxtApp()
|
|
const route = useNativeRoute()
|
|
const auth = await useAuth()
|
|
const cosmetics = useCosmetics()
|
|
const tags = useGeneratedState()
|
|
const config = useRuntimeConfig()
|
|
|
|
const vintl = useVIntl()
|
|
const { formatMessage } = vintl
|
|
|
|
const formatCompactNumber = useCompactNumber(true)
|
|
|
|
const formatRelativeTime = useRelativeTime()
|
|
|
|
const { addNotification } = injectNotificationManager()
|
|
|
|
const baseId = useId()
|
|
|
|
const messages = defineMessages({
|
|
profileProjectsLabel: {
|
|
id: 'profile.label.projects',
|
|
defaultMessage: '{count} {count, plural, one {project} other {projects}}',
|
|
},
|
|
profileDownloadsLabel: {
|
|
id: 'profile.label.downloads',
|
|
defaultMessage: '{count} {count, plural, one {download} other {downloads}}',
|
|
},
|
|
profileJoinedLabel: {
|
|
id: 'profile.label.joined',
|
|
defaultMessage: 'Joined',
|
|
},
|
|
savingLabel: {
|
|
id: 'profile.label.saving',
|
|
defaultMessage: 'Saving...',
|
|
},
|
|
emailLabel: {
|
|
id: 'profile.details.label.email',
|
|
defaultMessage: 'Email',
|
|
},
|
|
emailVerifiedTooltip: {
|
|
id: 'profile.details.tooltip.email-verified',
|
|
defaultMessage: 'Email verified',
|
|
},
|
|
emailNotVerifiedTooltip: {
|
|
id: 'profile.details.tooltip.email-not-verified',
|
|
defaultMessage: 'Email not verified',
|
|
},
|
|
authProvidersLabel: {
|
|
id: 'profile.details.label.auth-providers',
|
|
defaultMessage: 'Auth providers',
|
|
},
|
|
paymentMethodsLabel: {
|
|
id: 'profile.details.label.payment-methods',
|
|
defaultMessage: 'Payment methods',
|
|
},
|
|
hasPasswordLabel: {
|
|
id: 'profile.details.label.has-password',
|
|
defaultMessage: 'Has password',
|
|
},
|
|
hasTotpLabel: {
|
|
id: 'profile.details.label.has-totp',
|
|
defaultMessage: 'Has TOTP',
|
|
},
|
|
yesLabel: {
|
|
id: 'profile.label.yes',
|
|
defaultMessage: 'Yes',
|
|
},
|
|
noLabel: {
|
|
id: 'profile.label.no',
|
|
defaultMessage: 'No',
|
|
},
|
|
bioFallbackUser: {
|
|
id: 'profile.bio.fallback.user',
|
|
defaultMessage: 'A Modrinth user.',
|
|
},
|
|
bioFallbackCreator: {
|
|
id: 'profile.bio.fallback.creator',
|
|
defaultMessage: 'A Modrinth creator.',
|
|
},
|
|
collectionLabel: {
|
|
id: 'profile.label.collection',
|
|
defaultMessage: 'Collection',
|
|
},
|
|
profileProjectsFollowersStats: {
|
|
id: 'profile.stats.projects-followers',
|
|
defaultMessage:
|
|
'{count, plural, one {<stat>{count}</stat> project follower} other {<stat>{count}</stat> project followers}}',
|
|
},
|
|
profileUserId: {
|
|
id: 'profile.user-id',
|
|
defaultMessage: 'User ID: {id}',
|
|
},
|
|
profileDetails: {
|
|
id: 'profile.label.details',
|
|
defaultMessage: 'Details',
|
|
},
|
|
profileOrganizations: {
|
|
id: 'profile.label.organizations',
|
|
defaultMessage: 'Organizations',
|
|
},
|
|
profileBadges: {
|
|
id: 'profile.label.badges',
|
|
defaultMessage: 'Badges',
|
|
},
|
|
profileManageProjectsButton: {
|
|
id: 'profile.button.manage-projects',
|
|
defaultMessage: 'Manage projects',
|
|
},
|
|
profileMetaDescription: {
|
|
id: 'profile.meta.description',
|
|
defaultMessage: "Download {username}'s projects on Modrinth",
|
|
},
|
|
profileMetaDescriptionWithBio: {
|
|
id: 'profile.meta.description-with-bio',
|
|
defaultMessage: "{bio} - Download {username}'s projects on Modrinth",
|
|
},
|
|
profileNoProjectsLabel: {
|
|
id: 'profile.label.no-projects',
|
|
defaultMessage: 'This user has no projects!',
|
|
},
|
|
profileNoProjectsAuthLabel: {
|
|
id: 'profile.label.no-projects-auth',
|
|
defaultMessage:
|
|
"You don't have any projects.\nWould you like to <create-link>create one</create-link>?",
|
|
},
|
|
profileNoCollectionsLabel: {
|
|
id: 'profile.label.no-collections',
|
|
defaultMessage: 'This user has no collections!',
|
|
},
|
|
profileNoCollectionsAuthLabel: {
|
|
id: 'profile.label.no-collections-auth',
|
|
defaultMessage:
|
|
"You don't have any collections.\nWould you like to <create-link>create one</create-link>?",
|
|
},
|
|
billingButton: {
|
|
id: 'profile.button.billing',
|
|
defaultMessage: 'Manage user billing',
|
|
},
|
|
infoButton: {
|
|
id: 'profile.button.info',
|
|
defaultMessage: 'View user details',
|
|
},
|
|
setAffiliateButton: {
|
|
id: 'profile.button.set-affiliate',
|
|
defaultMessage: 'Set as affiliate',
|
|
},
|
|
removeAffiliateButton: {
|
|
id: 'profile.button.remove-affiliate',
|
|
defaultMessage: 'Remove as affiliate',
|
|
},
|
|
affiliateLabel: {
|
|
id: 'profile.label.affiliate',
|
|
defaultMessage: 'Affiliate',
|
|
},
|
|
editRoleButton: {
|
|
id: 'profile.button.edit-role',
|
|
defaultMessage: 'Edit role',
|
|
},
|
|
userNotFoundError: {
|
|
id: 'profile.error.not-found',
|
|
defaultMessage: 'User not found',
|
|
},
|
|
})
|
|
|
|
let user, projects, organizations, collections, refreshUser
|
|
try {
|
|
;[
|
|
{ data: user, refresh: refreshUser },
|
|
{ data: projects },
|
|
{ data: organizations },
|
|
{ data: collections },
|
|
] = await Promise.all([
|
|
useAsyncData(`user/${route.params.id}`, () => useBaseFetch(`user/${route.params.id}`)),
|
|
useAsyncData(
|
|
`user/${route.params.id}/projects`,
|
|
() => useBaseFetch(`user/${route.params.id}/projects`),
|
|
{
|
|
transform: (projects) => {
|
|
for (const project of projects) {
|
|
project.categories = project.categories.concat(project.loaders)
|
|
project.project_type = data.$getProjectTypeForUrl(
|
|
project.project_type,
|
|
project.categories,
|
|
tags.value,
|
|
)
|
|
}
|
|
|
|
return projects
|
|
},
|
|
},
|
|
),
|
|
useAsyncData(`user/${route.params.id}/organizations`, () =>
|
|
useBaseFetch(`user/${route.params.id}/organizations`, {
|
|
apiVersion: 3,
|
|
}),
|
|
),
|
|
useAsyncData(`user/${route.params.id}/collections`, () =>
|
|
useBaseFetch(`user/${route.params.id}/collections`, { apiVersion: 3 }),
|
|
),
|
|
])
|
|
} catch {
|
|
throw createError({
|
|
fatal: true,
|
|
statusCode: 404,
|
|
message: formatMessage(messages.userNotFoundError),
|
|
})
|
|
}
|
|
|
|
const sortedOrgs = computed(() =>
|
|
organizations.value ? [...organizations.value].sort((a, b) => a.name.localeCompare(b.name)) : [],
|
|
)
|
|
|
|
if (!user.value) {
|
|
throw createError({
|
|
fatal: true,
|
|
statusCode: 404,
|
|
message: formatMessage(messages.userNotFoundError),
|
|
})
|
|
}
|
|
|
|
if (user.value.username !== route.params.id) {
|
|
await navigateTo(`/user/${user.value.username}`, { redirectCode: 301 })
|
|
}
|
|
|
|
const title = computed(() => `${user.value.username} - Modrinth`)
|
|
const description = computed(() =>
|
|
user.value.bio
|
|
? formatMessage(messages.profileMetaDescriptionWithBio, {
|
|
bio: user.value.bio,
|
|
username: user.value.username,
|
|
})
|
|
: formatMessage(messages.profileMetaDescription, { username: user.value.username }),
|
|
)
|
|
|
|
useSeoMeta({
|
|
title: () => title.value,
|
|
description: () => description.value,
|
|
ogTitle: () => title.value,
|
|
ogDescription: () => description.value,
|
|
ogImage: () => user.value.avatar_url ?? 'https://cdn.modrinth.com/placeholder.png',
|
|
})
|
|
|
|
const projectTypes = computed(() => {
|
|
const obj = {}
|
|
|
|
if (collections.value.length > 0) {
|
|
obj.collection = true
|
|
}
|
|
|
|
for (const project of projects.value) {
|
|
obj[project.project_type] = true
|
|
}
|
|
|
|
delete obj.project
|
|
|
|
return Object.keys(obj)
|
|
})
|
|
const sumDownloads = computed(() => {
|
|
let sum = 0
|
|
|
|
for (const project of projects.value) {
|
|
sum += project.downloads
|
|
}
|
|
|
|
return sum
|
|
})
|
|
|
|
const joinDate = computed(() => new Date(user.value.created))
|
|
const MODRINTH_BETA_END_DATE = new Date('2022-02-27T08:00:00.000Z')
|
|
const MODRINTH_ALPHA_END_DATE = new Date('2020-11-30T08:00:00.000Z')
|
|
|
|
const badges = computed(() => {
|
|
const badges = []
|
|
|
|
if (user.value.role === 'admin') {
|
|
badges.push('staff')
|
|
}
|
|
|
|
if (user.value.role === 'moderator') {
|
|
badges.push('mod')
|
|
}
|
|
|
|
if (isPermission(user.value.badges, 1 << 0)) {
|
|
badges.push('plus')
|
|
}
|
|
|
|
if (sumDownloads.value > 10000000) {
|
|
badges.push('10m-club')
|
|
}
|
|
|
|
if (
|
|
isPermission(user.value.badges, 1 << 1) ||
|
|
isPermission(user.value.badges, 1 << 2) ||
|
|
isPermission(user.value.badges, 1 << 3)
|
|
) {
|
|
badges.push('early-adopter')
|
|
}
|
|
|
|
if (isPermission(user.value.badges, 1 << 4) || joinDate.value < MODRINTH_ALPHA_END_DATE) {
|
|
badges.push('alpha-tester')
|
|
} else if (isPermission(user.value.badges, 1 << 4) || joinDate.value < MODRINTH_BETA_END_DATE) {
|
|
badges.push('beta-tester')
|
|
}
|
|
|
|
if (isPermission(user.value.badges, 1 << 5)) {
|
|
badges.push('contributor')
|
|
}
|
|
|
|
if (isPermission(user.value.badges, 1 << 6)) {
|
|
badges.push('translator')
|
|
}
|
|
|
|
return badges
|
|
})
|
|
|
|
async function copyId() {
|
|
await navigator.clipboard.writeText(user.value.id)
|
|
}
|
|
|
|
async function copyPermalink() {
|
|
await navigator.clipboard.writeText(`${config.public.siteUrl}/user/${user.value.id}`)
|
|
}
|
|
|
|
const isAffiliate = computed(() => user.value.badges & UserBadge.AFFILIATE)
|
|
const isAdminViewing = computed(() => isAdmin(auth.value.user))
|
|
|
|
async function toggleAffiliate(id) {
|
|
await useBaseFetch(`user/${id}`, {
|
|
method: 'PATCH',
|
|
body: { badges: user.value.badges ^ (1 << 7) },
|
|
})
|
|
refreshUser()
|
|
}
|
|
|
|
const navLinks = computed(() => [
|
|
{
|
|
label: formatMessage(commonMessages.allProjectType),
|
|
href: `/user/${user.value.username}`,
|
|
},
|
|
...projectTypes.value
|
|
.map((x) => {
|
|
return {
|
|
label: formatMessage(getProjectTypeMessage(x, true)),
|
|
href: `/user/${user.value.username}/${x}s`,
|
|
}
|
|
})
|
|
.slice()
|
|
.sort((a, b) => a.label.localeCompare(b.label)),
|
|
])
|
|
|
|
const selectedRole = ref(user.value.role)
|
|
const isSavingRole = ref(false)
|
|
|
|
const roleOptions = [
|
|
{ value: 'developer', label: 'Developer' },
|
|
{ value: 'moderator', label: 'Moderator' },
|
|
{ value: 'admin', label: 'Admin' },
|
|
]
|
|
|
|
const editRoleModal = useTemplateRef('editRoleModal')
|
|
|
|
const openRoleEditModal = () => {
|
|
selectedRole.value = user.value.role
|
|
editRoleModal.value?.show()
|
|
}
|
|
|
|
const cancelRoleEdit = () => {
|
|
selectedRole.value = user.value.role
|
|
editRoleModal.value?.hide()
|
|
}
|
|
|
|
function saveRoleEdit() {
|
|
if (!selectedRole.value || selectedRole.value === user.value.role) {
|
|
return
|
|
}
|
|
|
|
isSavingRole.value = true
|
|
|
|
useBaseFetch(`user/${user.value.id}`, {
|
|
method: 'PATCH',
|
|
body: {
|
|
role: selectedRole.value,
|
|
},
|
|
})
|
|
.then(() => {
|
|
user.value.role = selectedRole.value
|
|
|
|
editRoleModal.value?.hide()
|
|
})
|
|
.catch(() => {
|
|
console.error('Failed to update user role:', error)
|
|
|
|
addNotification({
|
|
type: 'error',
|
|
title: 'Failed to update role',
|
|
message: 'An error occurred while updating the user role. Please try again.',
|
|
})
|
|
})
|
|
.finally(() => {
|
|
isSavingRole.value = false
|
|
})
|
|
}
|
|
</script>
|
|
<script>
|
|
export default defineNuxtComponent({
|
|
methods: {},
|
|
})
|
|
</script>
|
|
|
|
<style lang="scss" scoped>
|
|
.collections-grid {
|
|
display: grid;
|
|
grid-template-columns: repeat(2, 1fr);
|
|
|
|
@media screen and (max-width: 800px) {
|
|
grid-template-columns: repeat(1, 1fr);
|
|
}
|
|
|
|
gap: var(--gap-md);
|
|
|
|
.collection-item {
|
|
display: flex;
|
|
flex-direction: column;
|
|
gap: var(--gap-md);
|
|
margin-bottom: 0px;
|
|
}
|
|
|
|
.description {
|
|
// Grow to take up remaining space
|
|
flex-grow: 1;
|
|
|
|
color: var(--color-text);
|
|
font-size: 16px;
|
|
}
|
|
|
|
.stat-bar {
|
|
display: flex;
|
|
align-items: center;
|
|
gap: var(--gap-md);
|
|
margin-top: auto;
|
|
}
|
|
|
|
.stats {
|
|
display: flex;
|
|
align-items: center;
|
|
gap: var(--gap-xs);
|
|
|
|
svg {
|
|
color: var(--color-secondary);
|
|
}
|
|
}
|
|
|
|
.collection {
|
|
display: grid;
|
|
grid-template-columns: auto 1fr;
|
|
gap: var(--gap-md);
|
|
|
|
.icon {
|
|
width: 100% !important;
|
|
height: 6rem !important;
|
|
max-width: unset !important;
|
|
max-height: unset !important;
|
|
aspect-ratio: 1 / 1;
|
|
object-fit: cover;
|
|
}
|
|
|
|
.details {
|
|
display: flex;
|
|
flex-direction: column;
|
|
gap: var(--gap-sm);
|
|
|
|
.title {
|
|
color: var(--color-contrast);
|
|
font-weight: 700;
|
|
font-size: var(--font-size-lg);
|
|
margin: 0;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
</style>
|