da4ce99755
* Add dev target for TheoremOne * Restrict signups to theoremone.co emails * Add new indices * Forbid reads from unauthenticated users * Client-side render pages that need auth These pages are now client-side rendered: - /home - /leaderboards - /market/... - /fold/... * Hide 404 for private Manifolds * Brand instance for TheoremOne * Hide "Add Funds" and "Personalize your feed" * "M$" => "T$" * Hide Discord & About Page too * Update placeholders for teams * Update firestore.indexes.json * Switch /analytics to propz * Migrate per-env code into common/ * More migrations to PROJECT_ID * Conditionally use SSG depending on public vs private instance * Fix props to be empty object * Move more logic into access * Spin out config files for each environment * Generify most of the customizable brand stuff * Move IS_PRIVATE_MANIFOLD to access.ts * Rename access.ts to envs/constants.ts * Add "dev:dev" alias * Rever firestore rules to existing settings * Fixes according to James's review
38 lines
954 B
TypeScript
38 lines
954 B
TypeScript
import { ENV_CONFIG } from '../envs/constants'
|
|
|
|
const formatter = new Intl.NumberFormat('en-US', {
|
|
style: 'currency',
|
|
currency: 'USD',
|
|
maximumFractionDigits: 0,
|
|
minimumFractionDigits: 0,
|
|
})
|
|
|
|
export function formatMoney(amount: number) {
|
|
return (
|
|
ENV_CONFIG.moneyMoniker + ' ' + formatter.format(amount).replace('$', '')
|
|
)
|
|
}
|
|
|
|
export function formatWithCommas(amount: number) {
|
|
return formatter.format(amount).replace('$', '')
|
|
}
|
|
|
|
export function formatPercent(zeroToOne: number) {
|
|
return Math.round(zeroToOne * 100) + '%'
|
|
}
|
|
|
|
export function toCamelCase(words: string) {
|
|
const camelCase = words
|
|
.split(' ')
|
|
.map((word) => word.trim())
|
|
.filter((word) => word)
|
|
.map((word, index) =>
|
|
index === 0 ? word : word[0].toLocaleUpperCase() + word.substring(1)
|
|
)
|
|
.join('')
|
|
|
|
// Remove non-alpha-numeric-underscore chars.
|
|
const regex = /(?:^|\s)(?:[a-z0-9_]+)/gi
|
|
return (camelCase.match(regex) || [])[0] ?? ''
|
|
}
|