mirror of
https://github.com/Sendouc/sendou.ink.git
synced 2026-04-25 15:56:19 -05:00
string util functions location consistency and comments
This commit is contained in:
parent
9d80b3b3d9
commit
1320ed9127
|
|
@ -16,8 +16,8 @@ import {
|
|||
import { t, Trans } from "@lingui/macro";
|
||||
import { useRouter } from "next/router";
|
||||
import { useState } from "react";
|
||||
import { makeNameUrlFriendly } from "utils/makeNameUrlFriendly";
|
||||
import { sendData } from "utils/postData";
|
||||
import { makeNameUrlFriendly } from "utils/strings";
|
||||
|
||||
const CreateNewTeamModal = () => {
|
||||
const router = useRouter();
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import { NextApiRequest, NextApiResponse } from "next";
|
||||
import prisma from "prisma/client";
|
||||
import { getMySession } from "utils/api";
|
||||
import { makeNameUrlFriendly } from "utils/makeNameUrlFriendly";
|
||||
import { makeNameUrlFriendly } from "utils/strings";
|
||||
import { teamSchema } from "utils/validators/team";
|
||||
import { v4 as uuidv4 } from "uuid";
|
||||
|
||||
|
|
|
|||
|
|
@ -1,3 +0,0 @@
|
|||
export function makeNameUrlFriendly(name: string) {
|
||||
return name.trim().replace(/\s\s+/g, " ").toLowerCase().replace(/ /g, "-");
|
||||
}
|
||||
|
|
@ -13,6 +13,9 @@ export const getLocalizedMonthYearString = (
|
|||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Return medal emoji for top 3, otherwise returns the number as string.
|
||||
*/
|
||||
export const getRankingString = (ranking: number) => {
|
||||
switch (ranking) {
|
||||
case 1:
|
||||
|
|
@ -27,8 +30,18 @@ export const getRankingString = (ranking: number) => {
|
|||
}
|
||||
};
|
||||
|
||||
export function makeNameUrlFriendly(name: string) {
|
||||
return name.trim().replace(/\s\s+/g, " ").toLowerCase().replace(/ /g, "-");
|
||||
}
|
||||
|
||||
// User attributes - should be virtuals in future if support gets added to Prisma
|
||||
|
||||
/**
|
||||
* Takes user object and returns the formatted username morphing it with the Discord discriminator.
|
||||
* @example
|
||||
* // returns "Sendou#0043"
|
||||
* getFullUsername({username: "Sendou", discriminator: "0043"})
|
||||
*/
|
||||
export const getFullUsername = ({
|
||||
username,
|
||||
discriminator,
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user