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>
237 lines
6.9 KiB
JavaScript
237 lines
6.9 KiB
JavaScript
import { getProjectTypeForUrlShorthand } from '~/helpers/projects.js'
|
||
|
||
export default defineNuxtPlugin((nuxtApp) => {
|
||
const tagStore = useGeneratedState()
|
||
|
||
nuxtApp.provide('formatNumber', formatNumber)
|
||
nuxtApp.provide('capitalizeString', capitalizeString)
|
||
nuxtApp.provide('formatMoney', formatMoney)
|
||
nuxtApp.provide('formatVersion', (versionsArray) => formatVersions(tagStore, versionsArray))
|
||
nuxtApp.provide('orElse', (first, otherwise) => first ?? otherwise)
|
||
nuxtApp.provide('external', () => {
|
||
const cosmeticsStore = useCosmetics().value
|
||
|
||
return cosmeticsStore.externalLinksNewTab ? '_blank' : ''
|
||
})
|
||
|
||
/*
|
||
Only use on the complete list of versions for a project, partial lists will generate
|
||
the wrong version slugs
|
||
*/
|
||
nuxtApp.provide('computeVersions', (versions, members) => {
|
||
const visitedVersions = []
|
||
const returnVersions = []
|
||
|
||
const authorMembers = {}
|
||
|
||
for (const version of versions.sort(
|
||
(a, b) => nuxtApp.$dayjs(a.date_published) - nuxtApp.$dayjs(b.date_published),
|
||
)) {
|
||
if (visitedVersions.includes(version.version_number)) {
|
||
visitedVersions.push(version.version_number)
|
||
version.displayUrlEnding = version.id
|
||
} else {
|
||
visitedVersions.push(version.version_number)
|
||
version.displayUrlEnding = version.version_number
|
||
}
|
||
version.primaryFile = version.files.find((file) => file.primary) ?? version.files[0]
|
||
|
||
if (!version.primaryFile) {
|
||
version.primaryFile = {
|
||
hashes: {
|
||
sha1: '',
|
||
sha512: '',
|
||
},
|
||
url: '#',
|
||
filename: 'unknown',
|
||
primary: false,
|
||
size: 0,
|
||
file_type: null,
|
||
}
|
||
}
|
||
|
||
version.author = authorMembers[version.author_id]
|
||
if (!version.author) {
|
||
version.author = members.find((x) => x.user.id === version.author_id)
|
||
authorMembers[version.author_id] = version.author
|
||
}
|
||
|
||
returnVersions.push(version)
|
||
}
|
||
|
||
return returnVersions
|
||
.reverse()
|
||
.map((version, index) => {
|
||
const nextVersion = returnVersions[index + 1]
|
||
if (nextVersion && version.changelog && nextVersion.changelog === version.changelog) {
|
||
return { duplicate: true, ...version }
|
||
} else {
|
||
return { duplicate: false, ...version }
|
||
}
|
||
})
|
||
.sort((a, b) => nuxtApp.$dayjs(b.date_published) - nuxtApp.$dayjs(a.date_published))
|
||
})
|
||
nuxtApp.provide('getProjectTypeForDisplay', (type, categories) => {
|
||
if (type === 'mod') {
|
||
const isPlugin = categories.some((category) => {
|
||
return tagStore.value.loaderData.allPluginLoaders.includes(category)
|
||
})
|
||
const isMod = categories.some((category) => {
|
||
return tagStore.value.loaderData.modLoaders.includes(category)
|
||
})
|
||
const isDataPack = categories.some((category) => {
|
||
return tagStore.value.loaderData.dataPackLoaders.includes(category)
|
||
})
|
||
|
||
if (isMod && isPlugin && isDataPack) {
|
||
return 'mod, plugin, and data pack'
|
||
} else if (isMod && isPlugin) {
|
||
return 'mod and plugin'
|
||
} else if (isMod && isDataPack) {
|
||
return 'mod and data pack'
|
||
} else if (isPlugin && isDataPack) {
|
||
return 'plugin and data pack'
|
||
} else if (isDataPack) {
|
||
return 'data pack'
|
||
} else if (isPlugin) {
|
||
return 'plugin'
|
||
}
|
||
}
|
||
|
||
return type
|
||
})
|
||
nuxtApp.provide('getProjectTypeForUrl', (type, loaders, tags) =>
|
||
getProjectTypeForUrlShorthand(type, loaders, tags),
|
||
)
|
||
nuxtApp.provide('cycleValue', cycleValue)
|
||
nuxtApp.provide('sortedCategories', () => {
|
||
return tagStore.value.categories.slice().sort((a, b) => {
|
||
const headerCompare = a.header.localeCompare(b.header)
|
||
if (headerCompare !== 0) {
|
||
return headerCompare
|
||
}
|
||
if (a.header === 'resolutions' && b.header === 'resolutions') {
|
||
return a.name.replace(/\D/g, '') - b.name.replace(/\D/g, '')
|
||
} else if (a.header === 'performance impact' && b.header === 'performance impact') {
|
||
const x = ['potato', 'low', 'medium', 'high', 'screenshot']
|
||
|
||
return x.indexOf(a.name) - x.indexOf(b.name)
|
||
}
|
||
return 0
|
||
})
|
||
})
|
||
})
|
||
export const formatNumber = (number, abbreviate = true) => {
|
||
const x = +number
|
||
if (x >= 1000000 && abbreviate) {
|
||
return (x / 1000000).toFixed(2).toString() + 'M'
|
||
} else if (x >= 10000 && abbreviate) {
|
||
return (x / 1000).toFixed(1).toString() + 'k'
|
||
} else {
|
||
return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ',')
|
||
}
|
||
}
|
||
|
||
export const formatMoney = (number, abbreviate = false) => {
|
||
number = Math.floor(number * 100) / 100
|
||
const x = +number
|
||
if (x >= 1000000 && abbreviate) {
|
||
return '$' + (x / 1000000).toFixed(2).toString() + 'M'
|
||
} else if (x >= 10000 && abbreviate) {
|
||
return '$' + (x / 1000).toFixed(2).toString() + 'k'
|
||
} else {
|
||
return (
|
||
'$' +
|
||
x
|
||
.toFixed(2)
|
||
.toString()
|
||
.replace(/\B(?=(\d{3})+(?!\d))/g, ',')
|
||
)
|
||
}
|
||
}
|
||
|
||
export const capitalizeString = (name) => {
|
||
return name ? name.charAt(0).toUpperCase() + name.slice(1) : name
|
||
}
|
||
|
||
export const formatVersions = (tag, versionArray) => {
|
||
const allVersions = tag.value.gameVersions.slice().reverse()
|
||
const allReleases = allVersions.filter((x) => x.version_type === 'release')
|
||
|
||
const intervals = []
|
||
let currentInterval = 0
|
||
|
||
for (let i = 0; i < versionArray.length; i++) {
|
||
const index = allVersions.findIndex((x) => x.version === versionArray[i])
|
||
const releaseIndex = allReleases.findIndex((x) => x.version === versionArray[i])
|
||
|
||
if (i === 0) {
|
||
intervals.push([[versionArray[i], index, releaseIndex]])
|
||
} else {
|
||
const intervalBase = intervals[currentInterval]
|
||
|
||
if (
|
||
(index - intervalBase[intervalBase.length - 1][1] === 1 ||
|
||
releaseIndex - intervalBase[intervalBase.length - 1][2] === 1) &&
|
||
(allVersions[intervalBase[0][1]].version_type === 'release' ||
|
||
allVersions[index].version_type !== 'release')
|
||
) {
|
||
intervalBase[1] = [versionArray[i], index, releaseIndex]
|
||
} else {
|
||
currentInterval += 1
|
||
intervals[currentInterval] = [[versionArray[i], index, releaseIndex]]
|
||
}
|
||
}
|
||
}
|
||
|
||
const newIntervals = []
|
||
for (let i = 0; i < intervals.length; i++) {
|
||
const interval = intervals[i]
|
||
|
||
if (interval.length === 2 && interval[0][2] !== -1 && interval[1][2] === -1) {
|
||
let lastSnapshot = null
|
||
for (let j = interval[1][1]; j > interval[0][1]; j--) {
|
||
if (allVersions[j].version_type === 'release') {
|
||
newIntervals.push([
|
||
interval[0],
|
||
[
|
||
allVersions[j].version,
|
||
j,
|
||
allReleases.findIndex((x) => x.version === allVersions[j].version),
|
||
],
|
||
])
|
||
|
||
if (lastSnapshot !== null && lastSnapshot !== j + 1) {
|
||
newIntervals.push([[allVersions[lastSnapshot].version, lastSnapshot, -1], interval[1]])
|
||
} else {
|
||
newIntervals.push([interval[1]])
|
||
}
|
||
|
||
break
|
||
} else {
|
||
lastSnapshot = j
|
||
}
|
||
}
|
||
} else {
|
||
newIntervals.push(interval)
|
||
}
|
||
}
|
||
|
||
const output = []
|
||
|
||
for (const interval of newIntervals) {
|
||
if (interval.length === 2) {
|
||
output.push(`${interval[0][0]}–${interval[1][0]}`)
|
||
} else {
|
||
output.push(interval[0][0])
|
||
}
|
||
}
|
||
|
||
return (output.length === 0 ? versionArray : output).join(', ')
|
||
}
|
||
|
||
export const cycleValue = (value, values) => {
|
||
const index = values.indexOf(value) + 1
|
||
return values[index % values.length]
|
||
}
|