Add challenges background preference support: Extend site preferences and related components to include challengesBackground, update API and UI to handle new background image settings for challenges.
Some checks failed
Deploy with Docker Compose / deploy (push) Failing after 2m23s

This commit is contained in:
Julien Froidefond
2025-12-15 21:26:30 +01:00
parent 83446759fe
commit d3a4fa7cf5
25 changed files with 8373 additions and 12328 deletions

View File

@@ -19,6 +19,7 @@ export async function updateSitePreferences(data: {
homeBackground?: string | null;
eventsBackground?: string | null;
leaderboardBackground?: string | null;
challengesBackground?: string | null;
}) {
try {
await checkAdminAccess()();
@@ -27,12 +28,14 @@ export async function updateSitePreferences(data: {
homeBackground: data.homeBackground,
eventsBackground: data.eventsBackground,
leaderboardBackground: data.leaderboardBackground,
challengesBackground: data.challengesBackground,
});
revalidatePath("/admin");
revalidatePath("/");
revalidatePath("/events");
revalidatePath("/leaderboard");
revalidatePath("/challenges");
return { success: true, data: preferences };
} catch (error) {

View File

@@ -12,6 +12,7 @@ export async function GET() {
homeBackground: null,
eventsBackground: null,
leaderboardBackground: null,
challengesBackground: null,
});
}
@@ -19,6 +20,7 @@ export async function GET() {
homeBackground: sitePreferences.homeBackground,
eventsBackground: sitePreferences.eventsBackground,
leaderboardBackground: sitePreferences.leaderboardBackground,
challengesBackground: sitePreferences.challengesBackground,
});
} catch (error) {
console.error("Error fetching preferences:", error);
@@ -27,6 +29,7 @@ export async function GET() {
homeBackground: null,
eventsBackground: null,
leaderboardBackground: null,
challengesBackground: null,
},
{ status: 200 }
);

View File

@@ -14,8 +14,8 @@ export default async function ChallengesPage() {
}
const backgroundImage = await getBackgroundImage(
"home",
"/got-background.jpg"
"challenges",
"/got-2.jpg"
);
return (

View File

@@ -10,6 +10,7 @@ interface SitePreferences {
homeBackground: string | null;
eventsBackground: string | null;
leaderboardBackground: string | null;
challengesBackground: string | null;
}
interface BackgroundPreferencesProps {
@@ -20,6 +21,7 @@ const DEFAULT_IMAGES = {
home: "/got-2.jpg",
events: "/got-2.jpg",
leaderboard: "/leaderboard-bg.jpg",
challenges: "/got-2.jpg",
};
export default function BackgroundPreferences({
@@ -57,6 +59,10 @@ export default function BackgroundPreferences({
initialPreferences.leaderboardBackground,
DEFAULT_IMAGES.leaderboard
),
challengesBackground: getFormValue(
initialPreferences.challengesBackground,
DEFAULT_IMAGES.challenges
),
}),
[initialPreferences]
);
@@ -90,6 +96,10 @@ export default function BackgroundPreferences({
formData.leaderboardBackground,
DEFAULT_IMAGES.leaderboard
),
challengesBackground: getApiValue(
formData.challengesBackground,
DEFAULT_IMAGES.challenges
),
};
const result = await updateSitePreferences(apiData);
@@ -110,6 +120,10 @@ export default function BackgroundPreferences({
result.data.leaderboardBackground,
DEFAULT_IMAGES.leaderboard
),
challengesBackground: getFormValue(
result.data.challengesBackground,
DEFAULT_IMAGES.challenges
),
});
setIsEditing(false);
} else {
@@ -138,6 +152,10 @@ export default function BackgroundPreferences({
preferences.leaderboardBackground,
DEFAULT_IMAGES.leaderboard
),
challengesBackground: getFormValue(
preferences.challengesBackground,
DEFAULT_IMAGES.challenges
),
});
}
};
@@ -197,6 +215,16 @@ export default function BackgroundPreferences({
}
label="Background Leaderboard"
/>
<ImageSelector
value={formData.challengesBackground}
onChange={(url) =>
setFormData({
...formData,
challengesBackground: url,
})
}
label="Background Challenges"
/>
<div className="flex flex-col sm:flex-row gap-2 pt-4">
<Button onClick={handleSave} variant="success" size="md">
Enregistrer
@@ -376,6 +404,62 @@ export default function BackgroundPreferences({
);
})()}
</div>
<div className="flex flex-col sm:flex-row sm:items-center gap-2 sm:gap-4">
<span className="text-pixel-gold font-bold text-sm sm:text-base min-w-0 sm:min-w-[120px] flex-shrink-0">
Challenges:
</span>
{(() => {
const currentImage =
preferences?.challengesBackground &&
preferences.challengesBackground.trim() !== ""
? preferences.challengesBackground
: DEFAULT_IMAGES.challenges;
const isDefault =
!preferences?.challengesBackground ||
preferences.challengesBackground.trim() === "";
return (
<div className="flex items-center gap-2 sm:gap-3 min-w-0 flex-1">
<div className="relative w-16 h-10 sm:w-20 sm:h-12 rounded border border-pixel-gold/30 overflow-hidden bg-black/60 flex-shrink-0">
<img
src={currentImage}
alt="Challenges background"
className="w-full h-full object-cover"
onError={(e) => {
const target = e.currentTarget;
const currentSrc = target.src;
const fallbackSrc = "/got-2.jpg";
if (!currentSrc.includes(fallbackSrc)) {
target.src = fallbackSrc;
} else {
target.style.display = "none";
const fallbackDiv =
target.nextElementSibling as HTMLElement;
if (fallbackDiv) {
fallbackDiv.classList.remove("hidden");
}
}
}}
/>
<div className="absolute inset-0 flex items-center justify-center bg-black/60 text-gray-500 text-xs hidden">
No image
</div>
</div>
<div className="flex flex-col min-w-0 flex-1">
<span className="text-xs text-gray-400 truncate min-w-0">
{isDefault ? "Par défaut: " : ""}
{currentImage}
</span>
{isDefault && (
<span className="text-[10px] text-gray-500 italic">
(Image par défaut)
</span>
)}
</div>
</div>
);
})()}
</div>
</div>
)}
</Card>

View File

@@ -204,18 +204,28 @@ export default function ChallengesSection({
};
return (
<section
className="relative w-full min-h-screen flex flex-col items-center overflow-hidden pt-24 pb-16"
<section className="relative w-full min-h-screen flex flex-col items-center overflow-hidden pt-24 pb-16">
{/* Background Image */}
<div
className="absolute inset-0 bg-cover bg-center bg-no-repeat"
style={{
backgroundImage: `url(${backgroundImage})`,
backgroundSize: "cover",
backgroundPosition: "center",
backgroundRepeat: "no-repeat",
backgroundImage: `url('${backgroundImage}')`,
}}
>
<div className="absolute inset-0 bg-black/70 backdrop-blur-sm"></div>
{/* Dark overlay for readability */}
<div
className="absolute inset-0 bg-gradient-to-b"
style={{
background: `linear-gradient(to bottom,
color-mix(in srgb, var(--background) 70%, transparent),
color-mix(in srgb, var(--background) 60%, transparent),
color-mix(in srgb, var(--background) 80%, transparent)
)`,
}}
/>
</div>
<div className="relative z-10 w-full max-w-6xl mx-auto px-8 py-16">
<div className="relative z-10 w-full max-w-6xl mx-auto px-4 sm:px-8 py-16">
<SectionTitle variant="gradient" size="md" className="mb-8 text-center">
DÉFIS ENTRE JOUEURS
</SectionTitle>

View File

@@ -5,6 +5,7 @@ interface Preferences {
homeBackground: string | null;
eventsBackground: string | null;
leaderboardBackground: string | null;
challengesBackground: string | null;
}
export function usePreferences() {
@@ -21,6 +22,7 @@ export function usePreferences() {
homeBackground: null,
eventsBackground: null,
leaderboardBackground: null,
challengesBackground: null,
}
);
setLoading(false);
@@ -30,6 +32,7 @@ export function usePreferences() {
homeBackground: null,
eventsBackground: null,
leaderboardBackground: null,
challengesBackground: null,
});
setLoading(false);
});
@@ -39,7 +42,7 @@ export function usePreferences() {
}
export function useBackgroundImage(
page: "home" | "events" | "leaderboard",
page: "home" | "events" | "leaderboard" | "challenges",
defaultImage: string
) {
const { preferences } = usePreferences();

View File

@@ -1,7 +1,7 @@
import { sitePreferencesService } from "@/services/preferences/site-preferences.service";
export async function getBackgroundImage(
page: "home" | "events" | "leaderboard",
page: "home" | "events" | "leaderboard" | "challenges",
defaultImage: string
): Promise<string> {
return sitePreferencesService.getBackgroundImage(page, defaultImage);

View File

@@ -1,3 +1,4 @@
/* !!! This is code generated by Prisma. Do not edit directly. !!! */
/* eslint-disable */
// biome-ignore-all lint: generated file
@@ -12,42 +13,42 @@
* 🟢 You can import this file directly.
*/
import * as Prisma from "./internal/prismaNamespaceBrowser";
export { Prisma };
export * as $Enums from "./enums";
export * from "./enums";
import * as Prisma from './internal/prismaNamespaceBrowser'
export { Prisma }
export * as $Enums from './enums'
export * from './enums';
/**
* Model User
*
*/
export type User = Prisma.UserModel;
export type User = Prisma.UserModel
/**
* Model UserPreferences
*
*/
export type UserPreferences = Prisma.UserPreferencesModel;
export type UserPreferences = Prisma.UserPreferencesModel
/**
* Model Event
*
*/
export type Event = Prisma.EventModel;
export type Event = Prisma.EventModel
/**
* Model EventRegistration
*
*/
export type EventRegistration = Prisma.EventRegistrationModel;
export type EventRegistration = Prisma.EventRegistrationModel
/**
* Model EventFeedback
*
*/
export type EventFeedback = Prisma.EventFeedbackModel;
export type EventFeedback = Prisma.EventFeedbackModel
/**
* Model SitePreferences
*
*/
export type SitePreferences = Prisma.SitePreferencesModel;
export type SitePreferences = Prisma.SitePreferencesModel
/**
* Model Challenge
*
*/
export type Challenge = Prisma.ChallengeModel;
export type Challenge = Prisma.ChallengeModel

View File

@@ -1,3 +1,4 @@
/* !!! This is code generated by Prisma. Do not edit directly. !!! */
/* eslint-disable */
// biome-ignore-all lint: generated file
@@ -9,18 +10,18 @@
* 🟢 You can import this file directly.
*/
import * as process from "node:process";
import * as path from "node:path";
import { fileURLToPath } from "node:url";
globalThis["__dirname"] = path.dirname(fileURLToPath(import.meta.url));
import * as process from 'node:process'
import * as path from 'node:path'
import { fileURLToPath } from 'node:url'
globalThis['__dirname'] = path.dirname(fileURLToPath(import.meta.url))
import * as runtime from "@prisma/client/runtime/client";
import * as $Enums from "./enums";
import * as $Class from "./internal/class";
import * as Prisma from "./internal/prismaNamespace";
import * as runtime from "@prisma/client/runtime/client"
import * as $Enums from "./enums"
import * as $Class from "./internal/class"
import * as Prisma from "./internal/prismaNamespace"
export * as $Enums from "./enums";
export * from "./enums";
export * as $Enums from './enums'
export * from "./enums"
/**
* ## Prisma Client
*
@@ -34,48 +35,42 @@ export * from "./enums";
*
* Read more in our [docs](https://pris.ly/d/client).
*/
export const PrismaClient = $Class.getPrismaClientClass();
export type PrismaClient<
LogOpts extends Prisma.LogLevel = never,
OmitOpts extends Prisma.PrismaClientOptions["omit"] =
Prisma.PrismaClientOptions["omit"],
ExtArgs extends runtime.Types.Extensions.InternalArgs =
runtime.Types.Extensions.DefaultArgs,
> = $Class.PrismaClient<LogOpts, OmitOpts, ExtArgs>;
export { Prisma };
export const PrismaClient = $Class.getPrismaClientClass()
export type PrismaClient<LogOpts extends Prisma.LogLevel = never, OmitOpts extends Prisma.PrismaClientOptions["omit"] = Prisma.PrismaClientOptions["omit"], ExtArgs extends runtime.Types.Extensions.InternalArgs = runtime.Types.Extensions.DefaultArgs> = $Class.PrismaClient<LogOpts, OmitOpts, ExtArgs>
export { Prisma }
/**
* Model User
*
*/
export type User = Prisma.UserModel;
export type User = Prisma.UserModel
/**
* Model UserPreferences
*
*/
export type UserPreferences = Prisma.UserPreferencesModel;
export type UserPreferences = Prisma.UserPreferencesModel
/**
* Model Event
*
*/
export type Event = Prisma.EventModel;
export type Event = Prisma.EventModel
/**
* Model EventRegistration
*
*/
export type EventRegistration = Prisma.EventRegistrationModel;
export type EventRegistration = Prisma.EventRegistrationModel
/**
* Model EventFeedback
*
*/
export type EventFeedback = Prisma.EventFeedbackModel;
export type EventFeedback = Prisma.EventFeedbackModel
/**
* Model SitePreferences
*
*/
export type SitePreferences = Prisma.SitePreferencesModel;
export type SitePreferences = Prisma.SitePreferencesModel
/**
* Model Challenge
*
*/
export type Challenge = Prisma.ChallengeModel;
export type Challenge = Prisma.ChallengeModel

File diff suppressed because it is too large Load Diff

View File

@@ -1,3 +1,4 @@
/* !!! This is code generated by Prisma. Do not edit directly. !!! */
/* eslint-disable */
// biome-ignore-all lint: generated file
@@ -9,44 +10,45 @@
*/
export const Role = {
USER: "USER",
ADMIN: "ADMIN",
} as const;
USER: 'USER',
ADMIN: 'ADMIN'
} as const
export type Role = (typeof Role)[keyof typeof Role]
export type Role = (typeof Role)[keyof typeof Role];
export const EventType = {
ATELIER: "ATELIER",
KATA: "KATA",
PRESENTATION: "PRESENTATION",
LEARNING_HOUR: "LEARNING_HOUR",
} as const;
ATELIER: 'ATELIER',
KATA: 'KATA',
PRESENTATION: 'PRESENTATION',
LEARNING_HOUR: 'LEARNING_HOUR'
} as const
export type EventType = (typeof EventType)[keyof typeof EventType]
export type EventType = (typeof EventType)[keyof typeof EventType];
export const CharacterClass = {
WARRIOR: "WARRIOR",
MAGE: "MAGE",
ROGUE: "ROGUE",
RANGER: "RANGER",
PALADIN: "PALADIN",
ENGINEER: "ENGINEER",
MERCHANT: "MERCHANT",
SCHOLAR: "SCHOLAR",
BERSERKER: "BERSERKER",
NECROMANCER: "NECROMANCER",
} as const;
WARRIOR: 'WARRIOR',
MAGE: 'MAGE',
ROGUE: 'ROGUE',
RANGER: 'RANGER',
PALADIN: 'PALADIN',
ENGINEER: 'ENGINEER',
MERCHANT: 'MERCHANT',
SCHOLAR: 'SCHOLAR',
BERSERKER: 'BERSERKER',
NECROMANCER: 'NECROMANCER'
} as const
export type CharacterClass = (typeof CharacterClass)[keyof typeof CharacterClass]
export type CharacterClass =
(typeof CharacterClass)[keyof typeof CharacterClass];
export const ChallengeStatus = {
PENDING: "PENDING",
ACCEPTED: "ACCEPTED",
COMPLETED: "COMPLETED",
REJECTED: "REJECTED",
CANCELLED: "CANCELLED",
} as const;
PENDING: 'PENDING',
ACCEPTED: 'ACCEPTED',
COMPLETED: 'COMPLETED',
REJECTED: 'REJECTED',
CANCELLED: 'CANCELLED'
} as const
export type ChallengeStatus =
(typeof ChallengeStatus)[keyof typeof ChallengeStatus];
export type ChallengeStatus = (typeof ChallengeStatus)[keyof typeof ChallengeStatus]

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

View File

@@ -1,3 +1,4 @@
/* !!! This is code generated by Prisma. Do not edit directly. !!! */
/* eslint-disable */
// biome-ignore-all lint: generated file
@@ -14,185 +15,184 @@
* model files in the `model` directory!
*/
import * as runtime from "@prisma/client/runtime/index-browser";
import * as runtime from "@prisma/client/runtime/index-browser"
export type * from "../models";
export type * from "./prismaNamespace";
export type * from '../models'
export type * from './prismaNamespace'
export const Decimal = runtime.Decimal
export const Decimal = runtime.Decimal;
export const NullTypes = {
DbNull: runtime.NullTypes.DbNull as new (
secret: never
) => typeof runtime.DbNull,
JsonNull: runtime.NullTypes.JsonNull as new (
secret: never
) => typeof runtime.JsonNull,
AnyNull: runtime.NullTypes.AnyNull as new (
secret: never
) => typeof runtime.AnyNull,
};
DbNull: runtime.NullTypes.DbNull as (new (secret: never) => typeof runtime.DbNull),
JsonNull: runtime.NullTypes.JsonNull as (new (secret: never) => typeof runtime.JsonNull),
AnyNull: runtime.NullTypes.AnyNull as (new (secret: never) => typeof runtime.AnyNull),
}
/**
* Helper for filtering JSON entries that have `null` on the database (empty on the db)
*
* @see https://www.prisma.io/docs/concepts/components/prisma-client/working-with-fields/working-with-json-fields#filtering-on-a-json-field
*/
export const DbNull = runtime.DbNull;
export const DbNull = runtime.DbNull
/**
* Helper for filtering JSON entries that have JSON `null` values (not empty on the db)
*
* @see https://www.prisma.io/docs/concepts/components/prisma-client/working-with-fields/working-with-json-fields#filtering-on-a-json-field
*/
export const JsonNull = runtime.JsonNull;
export const JsonNull = runtime.JsonNull
/**
* Helper for filtering JSON entries that are `Prisma.DbNull` or `Prisma.JsonNull`
*
* @see https://www.prisma.io/docs/concepts/components/prisma-client/working-with-fields/working-with-json-fields#filtering-on-a-json-field
*/
export const AnyNull = runtime.AnyNull;
export const AnyNull = runtime.AnyNull
export const ModelName = {
User: "User",
UserPreferences: "UserPreferences",
Event: "Event",
EventRegistration: "EventRegistration",
EventFeedback: "EventFeedback",
SitePreferences: "SitePreferences",
Challenge: "Challenge",
} as const;
User: 'User',
UserPreferences: 'UserPreferences',
Event: 'Event',
EventRegistration: 'EventRegistration',
EventFeedback: 'EventFeedback',
SitePreferences: 'SitePreferences',
Challenge: 'Challenge'
} as const
export type ModelName = (typeof ModelName)[keyof typeof ModelName];
export type ModelName = (typeof ModelName)[keyof typeof ModelName]
/*
* Enums
*/
export const TransactionIsolationLevel = {
Serializable: "Serializable",
} as const;
Serializable: 'Serializable'
} as const
export type TransactionIsolationLevel = (typeof TransactionIsolationLevel)[keyof typeof TransactionIsolationLevel]
export type TransactionIsolationLevel =
(typeof TransactionIsolationLevel)[keyof typeof TransactionIsolationLevel];
export const UserScalarFieldEnum = {
id: "id",
email: "email",
password: "password",
username: "username",
role: "role",
score: "score",
level: "level",
hp: "hp",
maxHp: "maxHp",
xp: "xp",
maxXp: "maxXp",
avatar: "avatar",
createdAt: "createdAt",
updatedAt: "updatedAt",
bio: "bio",
characterClass: "characterClass",
} as const;
id: 'id',
email: 'email',
password: 'password',
username: 'username',
role: 'role',
score: 'score',
level: 'level',
hp: 'hp',
maxHp: 'maxHp',
xp: 'xp',
maxXp: 'maxXp',
avatar: 'avatar',
createdAt: 'createdAt',
updatedAt: 'updatedAt',
bio: 'bio',
characterClass: 'characterClass'
} as const
export type UserScalarFieldEnum = (typeof UserScalarFieldEnum)[keyof typeof UserScalarFieldEnum]
export type UserScalarFieldEnum =
(typeof UserScalarFieldEnum)[keyof typeof UserScalarFieldEnum];
export const UserPreferencesScalarFieldEnum = {
id: "id",
userId: "userId",
homeBackground: "homeBackground",
eventsBackground: "eventsBackground",
leaderboardBackground: "leaderboardBackground",
theme: "theme",
createdAt: "createdAt",
updatedAt: "updatedAt",
} as const;
id: 'id',
userId: 'userId',
homeBackground: 'homeBackground',
eventsBackground: 'eventsBackground',
leaderboardBackground: 'leaderboardBackground',
theme: 'theme',
createdAt: 'createdAt',
updatedAt: 'updatedAt'
} as const
export type UserPreferencesScalarFieldEnum = (typeof UserPreferencesScalarFieldEnum)[keyof typeof UserPreferencesScalarFieldEnum]
export type UserPreferencesScalarFieldEnum =
(typeof UserPreferencesScalarFieldEnum)[keyof typeof UserPreferencesScalarFieldEnum];
export const EventScalarFieldEnum = {
id: "id",
date: "date",
name: "name",
description: "description",
type: "type",
room: "room",
time: "time",
maxPlaces: "maxPlaces",
createdAt: "createdAt",
updatedAt: "updatedAt",
} as const;
id: 'id',
date: 'date',
name: 'name',
description: 'description',
type: 'type',
room: 'room',
time: 'time',
maxPlaces: 'maxPlaces',
createdAt: 'createdAt',
updatedAt: 'updatedAt'
} as const
export type EventScalarFieldEnum = (typeof EventScalarFieldEnum)[keyof typeof EventScalarFieldEnum]
export type EventScalarFieldEnum =
(typeof EventScalarFieldEnum)[keyof typeof EventScalarFieldEnum];
export const EventRegistrationScalarFieldEnum = {
id: "id",
userId: "userId",
eventId: "eventId",
createdAt: "createdAt",
} as const;
id: 'id',
userId: 'userId',
eventId: 'eventId',
createdAt: 'createdAt'
} as const
export type EventRegistrationScalarFieldEnum = (typeof EventRegistrationScalarFieldEnum)[keyof typeof EventRegistrationScalarFieldEnum]
export type EventRegistrationScalarFieldEnum =
(typeof EventRegistrationScalarFieldEnum)[keyof typeof EventRegistrationScalarFieldEnum];
export const EventFeedbackScalarFieldEnum = {
id: "id",
userId: "userId",
eventId: "eventId",
rating: "rating",
comment: "comment",
createdAt: "createdAt",
updatedAt: "updatedAt",
} as const;
id: 'id',
userId: 'userId',
eventId: 'eventId',
rating: 'rating',
comment: 'comment',
createdAt: 'createdAt',
updatedAt: 'updatedAt'
} as const
export type EventFeedbackScalarFieldEnum = (typeof EventFeedbackScalarFieldEnum)[keyof typeof EventFeedbackScalarFieldEnum]
export type EventFeedbackScalarFieldEnum =
(typeof EventFeedbackScalarFieldEnum)[keyof typeof EventFeedbackScalarFieldEnum];
export const SitePreferencesScalarFieldEnum = {
id: "id",
homeBackground: "homeBackground",
eventsBackground: "eventsBackground",
leaderboardBackground: "leaderboardBackground",
createdAt: "createdAt",
updatedAt: "updatedAt",
} as const;
id: 'id',
homeBackground: 'homeBackground',
eventsBackground: 'eventsBackground',
leaderboardBackground: 'leaderboardBackground',
challengesBackground: 'challengesBackground',
createdAt: 'createdAt',
updatedAt: 'updatedAt'
} as const
export type SitePreferencesScalarFieldEnum = (typeof SitePreferencesScalarFieldEnum)[keyof typeof SitePreferencesScalarFieldEnum]
export type SitePreferencesScalarFieldEnum =
(typeof SitePreferencesScalarFieldEnum)[keyof typeof SitePreferencesScalarFieldEnum];
export const ChallengeScalarFieldEnum = {
id: "id",
challengerId: "challengerId",
challengedId: "challengedId",
title: "title",
description: "description",
pointsReward: "pointsReward",
status: "status",
adminId: "adminId",
adminComment: "adminComment",
winnerId: "winnerId",
createdAt: "createdAt",
acceptedAt: "acceptedAt",
completedAt: "completedAt",
updatedAt: "updatedAt",
} as const;
id: 'id',
challengerId: 'challengerId',
challengedId: 'challengedId',
title: 'title',
description: 'description',
pointsReward: 'pointsReward',
status: 'status',
adminId: 'adminId',
adminComment: 'adminComment',
winnerId: 'winnerId',
createdAt: 'createdAt',
acceptedAt: 'acceptedAt',
completedAt: 'completedAt',
updatedAt: 'updatedAt'
} as const
export type ChallengeScalarFieldEnum = (typeof ChallengeScalarFieldEnum)[keyof typeof ChallengeScalarFieldEnum]
export type ChallengeScalarFieldEnum =
(typeof ChallengeScalarFieldEnum)[keyof typeof ChallengeScalarFieldEnum];
export const SortOrder = {
asc: "asc",
desc: "desc",
} as const;
asc: 'asc',
desc: 'desc'
} as const
export type SortOrder = (typeof SortOrder)[keyof typeof SortOrder]
export type SortOrder = (typeof SortOrder)[keyof typeof SortOrder];
export const NullsOrder = {
first: "first",
last: "last",
} as const;
first: 'first',
last: 'last'
} as const
export type NullsOrder = (typeof NullsOrder)[keyof typeof NullsOrder]
export type NullsOrder = (typeof NullsOrder)[keyof typeof NullsOrder];

View File

@@ -1,3 +1,4 @@
/* !!! This is code generated by Prisma. Do not edit directly. !!! */
/* eslint-disable */
// biome-ignore-all lint: generated file
@@ -7,11 +8,11 @@
*
* 🟢 You can import this file directly.
*/
export type * from "./models/User";
export type * from "./models/UserPreferences";
export type * from "./models/Event";
export type * from "./models/EventRegistration";
export type * from "./models/EventFeedback";
export type * from "./models/SitePreferences";
export type * from "./models/Challenge";
export type * from "./commonInputTypes";
export type * from './models/User'
export type * from './models/UserPreferences'
export type * from './models/Event'
export type * from './models/EventRegistration'
export type * from './models/EventFeedback'
export type * from './models/SitePreferences'
export type * from './models/Challenge'
export type * from './commonInputTypes'

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,17 @@
-- RedefineTables
PRAGMA defer_foreign_keys=ON;
PRAGMA foreign_keys=OFF;
CREATE TABLE "new_SitePreferences" (
"id" TEXT NOT NULL PRIMARY KEY DEFAULT 'global',
"homeBackground" TEXT,
"eventsBackground" TEXT,
"leaderboardBackground" TEXT,
"challengesBackground" TEXT,
"createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updatedAt" DATETIME NOT NULL
);
INSERT INTO "new_SitePreferences" ("createdAt", "eventsBackground", "homeBackground", "id", "leaderboardBackground", "updatedAt") SELECT "createdAt", "eventsBackground", "homeBackground", "id", "leaderboardBackground", "updatedAt" FROM "SitePreferences";
DROP TABLE "SitePreferences";
ALTER TABLE "new_SitePreferences" RENAME TO "SitePreferences";
PRAGMA foreign_keys=ON;
PRAGMA defer_foreign_keys=OFF;

View File

@@ -99,6 +99,7 @@ model SitePreferences {
homeBackground String?
eventsBackground String?
leaderboardBackground String?
challengesBackground String?
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
}

View File

@@ -6,6 +6,7 @@ export interface UpdateSitePreferencesInput {
homeBackground?: string | null;
eventsBackground?: string | null;
leaderboardBackground?: string | null;
challengesBackground?: string | null;
}
/**
@@ -36,6 +37,7 @@ export class SitePreferencesService {
homeBackground: null,
eventsBackground: null,
leaderboardBackground: null,
challengesBackground: null,
},
});
}
@@ -64,6 +66,10 @@ export class SitePreferencesService {
data.leaderboardBackground === ""
? null
: (data.leaderboardBackground ?? undefined),
challengesBackground:
data.challengesBackground === ""
? null
: (data.challengesBackground ?? undefined),
},
create: {
id: "global",
@@ -75,6 +81,10 @@ export class SitePreferencesService {
data.leaderboardBackground === ""
? null
: (data.leaderboardBackground ?? null),
challengesBackground:
data.challengesBackground === ""
? null
: (data.challengesBackground ?? null),
},
});
}
@@ -83,7 +93,7 @@ export class SitePreferencesService {
* Récupère l'image de fond pour une page donnée
*/
async getBackgroundImage(
page: "home" | "events" | "leaderboard",
page: "home" | "events" | "leaderboard" | "challenges",
defaultImage: string
): Promise<string> {
try {