sendou.ink/prisma/queries/getUserByIdentifier.ts
Kalle af3a654595
Customize profile colors (#603)
* Variables rearranged

* Make patron.json empty again

* Fix styles.css

* Working prototype

* Table legible color

* UI furthened

* Set opaque theme color with custom colors

* Control Color Selector with buttons

* Show info if can't edit colors

* borzoic can also edit colors

* Add migration

* Can send colors to backend

* Edit existing colors

* Use new layering strat for footer

* useMutation custom hook

* Footer adjusted text color

* Reset style after profile visit

* Set squid color after page load

* Mutate user after color selection
2021-07-29 20:30:47 +03:00

66 lines
1.5 KiB
TypeScript

import { Prisma } from "@prisma/client";
import prisma from "prisma/client";
export type GetUserByIdentifierData = Prisma.PromiseReturnType<
typeof getUserByIdentifier
>;
export const getUserByIdentifier = (identifier: string) =>
prisma.user.findFirst({
where: {
// this is ok because the values are mutually exclusive
OR: [
{
discordId: identifier,
},
{
profile: {
customUrlPath: identifier.toLowerCase(),
},
},
{
// for some reason it doesn't like passing in id: undefined so using this as workaround
id: Number(identifier) || -1,
},
],
},
select: {
id: true,
discordId: true,
discordAvatar: true,
username: true,
discriminator: true,
patreonTier: true,
profile: {
select: {
bio: true,
country: true,
customUrlPath: true,
sensMotion: true,
sensStick: true,
twitchName: true,
twitterName: true,
weaponPool: true,
youtubeId: true,
colors: true,
},
},
player: {
select: {
switchAccountId: true,
},
},
freeAgentPost: {
select: { id: true },
},
team: {
select: { name: true, twitterName: true, nameForUrl: true },
},
salmonRunRecords: {
take: 1,
select: { id: true },
},
},
rejectOnNotFound: true,
});