Skip to content
Merged
Show file tree
Hide file tree
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
22 changes: 22 additions & 0 deletions apps/frontend/src/composables/affiliates.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
export const useAffiliates = () => {
const affiliateCookie = useCookie('mrs_afl', {
maxAge: 60 * 60 * 24 * 7, // 7 days
sameSite: 'lax',
secure: true,
httpOnly: false,
path: '/',
})

const setAffiliateCode = (code: string) => {
affiliateCookie.value = code
}

const getAffiliateCode = (): string | undefined => {
return affiliateCookie.value || undefined
}

return {
setAffiliateCode,
getAffiliateCode,
}
}
32 changes: 29 additions & 3 deletions apps/frontend/src/layouts/default.vue
Original file line number Diff line number Diff line change
Expand Up @@ -455,6 +455,12 @@
link: '/admin/user_email',
shown: isAdmin(auth.user),
},
{
id: 'affiliates',
color: 'primary',
link: '/admin/affiliates',
shown: isAdmin(auth.user),
},
{
id: 'servers-notices',
color: 'primary',
Expand All @@ -478,15 +484,20 @@
<ReportIcon aria-hidden="true" /> {{ formatMessage(messages.reports) }}
</template>
<template #user-lookup>
<UserIcon aria-hidden="true" /> {{ formatMessage(messages.lookupByEmail) }}
<UserSearchIcon aria-hidden="true" /> {{ formatMessage(messages.lookupByEmail) }}
</template>
<template #file-lookup>
<FileIcon aria-hidden="true" /> {{ formatMessage(messages.fileLookup) }}
</template>
<template #servers-notices>
<IssuesIcon aria-hidden="true" /> {{ formatMessage(messages.manageServerNotices) }}
</template>
<template #servers-nodes> <ServerIcon aria-hidden="true" /> Server Nodes </template>
<template #affiliates>
<AffiliateIcon aria-hidden="true" /> {{ formatMessage(messages.manageAffiliates) }}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just be prepared to fix this for me in the creator rev frontend PR cos it will cause a big merge conflict lol

</template>
<template #servers-nodes>
<ServerIcon aria-hidden="true" /> Credit server nodes
</template>
</OverflowMenu>
</ButtonStyled>
<ButtonStyled type="transparent">
Expand Down Expand Up @@ -563,6 +574,10 @@
<template #organizations>
<OrganizationIcon aria-hidden="true" /> {{ formatMessage(messages.organizations) }}
</template>
<template #affiliate-links>
<AffiliateIcon aria-hidden="true" />
{{ formatMessage(commonMessages.affiliateLinksButton) }}
</template>
<template #revenue>
<CurrencyIcon aria-hidden="true" /> {{ formatMessage(messages.revenue) }}
</template>
Expand Down Expand Up @@ -850,6 +865,7 @@
</template>
<script setup>
import {
AffiliateIcon,
ArrowBigUpDashIcon,
BellIcon,
BlueskyIcon,
Expand Down Expand Up @@ -891,6 +907,7 @@ import {
SunIcon,
TwitterIcon,
UserIcon,
UserSearchIcon,
XIcon,
} from '@modrinth/assets'
import {
Expand All @@ -903,7 +920,7 @@ import {
OverflowMenu,
PagewideBanner,
} from '@modrinth/ui'
import { isAdmin, isStaff } from '@modrinth/utils'
import { isAdmin, isStaff, UserBadge } from '@modrinth/utils'
import { IntlFormatted } from '@vintl/vintl/components'

import TextLogo from '~/components/brand/TextLogo.vue'
Expand Down Expand Up @@ -1159,6 +1176,10 @@ const messages = defineMessages({
id: 'layout.action.manage-server-notices',
defaultMessage: 'Manage server notices',
},
manageAffiliates: {
id: 'layout.action.manage-affiliates',
defaultMessage: 'Manage affiliate links',
},
newProject: {
id: 'layout.action.new-project',
defaultMessage: 'New project',
Expand Down Expand Up @@ -1336,6 +1357,11 @@ const userMenuOptions = computed(() => {
id: 'organizations',
link: '/dashboard/organizations',
},
{
id: 'affiliate-links',
link: '/dashboard/affiliate-links',
shown: auth.value.user.badges & UserBadge.AFFILIATE,
},
{
id: 'revenue',
link: '/dashboard/revenue',
Expand Down
33 changes: 33 additions & 0 deletions apps/frontend/src/locales/en-US/index.json
Original file line number Diff line number Diff line change
Expand Up @@ -566,6 +566,27 @@
"create.project.visibility-unlisted": {
"message": "Unlisted"
},
"dashboard.affiliate-links.create.button": {
"message": "Create affiliate link"
},
"dashboard.affiliate-links.error.title": {
"message": "Error loading affiliate links"
},
"dashboard.affiliate-links.header": {
"message": "Your affiliate links"
},
"dashboard.affiliate-links.revoke-confirm.body": {
"message": "This will permanently revoke the affiliate code `{id}` and any existing links with this code that have been shared will no longer be valid."
},
"dashboard.affiliate-links.revoke-confirm.button": {
"message": "Revoke"
},
"dashboard.affiliate-links.revoke-confirm.title": {
"message": "Are you sure you want to revoke your ''{title}'' affiliate link?"
},
"dashboard.affiliate-links.search": {
"message": "Search affiliate links..."
},
"dashboard.collections.button.create-new": {
"message": "Create new"
},
Expand Down Expand Up @@ -869,6 +890,9 @@
"layout.action.lookup-by-email": {
"message": "Lookup by email"
},
"layout.action.manage-affiliates": {
"message": "Manage affiliate links"
},
"layout.action.manage-server-notices": {
"message": "Manage server notices"
},
Expand Down Expand Up @@ -1130,6 +1154,12 @@
"profile.button.manage-projects": {
"message": "Manage projects"
},
"profile.button.remove-affiliate": {
"message": "Remove as affiliate"
},
"profile.button.set-affiliate": {
"message": "Set as affiliate"
},
"profile.details.label.auth-providers": {
"message": "Auth providers"
},
Expand All @@ -1154,6 +1184,9 @@
"profile.error.not-found": {
"message": "User not found"
},
"profile.label.affiliate": {
"message": "Affiliate"
},
"profile.label.badges": {
"message": "Badges"
},
Expand Down
Loading