Fetch full Discord and Twitter urls from API

This commit is contained in:
Kalle (Sendou)
2021-10-25 21:49:11 +03:00
parent 568380cc73
commit 0ea8d96827

View File

@@ -29,8 +29,27 @@ export async function findTournamentByNameForUrl({
},
});
return tournaments.find(
const result = tournaments.find(
(tournament) =>
tournament.organizer.nameForUrl === organizationNameForUrl.toLowerCase()
);
if (!result) return result;
result.organizer.twitter = twitterToUrl(result.organizer.twitter);
result.organizer.discordInvite = discordInviteToUrl(
result.organizer.discordInvite
);
return result;
}
function twitterToUrl(twitter: string | null) {
if (!twitter) return twitter;
return `https://twitter.com/${twitter}`;
}
function discordInviteToUrl(discordInvite: string) {
return `https://discord.com/invite/${discordInvite}`;
}