implement wihslist and secret santa

This commit is contained in:
tylen 2025-11-24 17:24:41 +02:00
parent 06e146f1c4
commit 4ecf62faff

View File

@ -1,7 +1,7 @@
import CenteredContainer from "./ChildrenContainer"; import CenteredContainer from "./ChildrenContainer";
import useFetchUser from "../utils/fetchUser.tsx" import useFetchUser from "../utils/fetchUser.tsx"
import type { SantaInfo } from "../types/index"; import type { SantaInfo } from "../types/index";
import { useEffect, useState } from "react"; import { useState } from "react";
import { useNotification } from "../NotificationContext.tsx"; import { useNotification } from "../NotificationContext.tsx";
function SecretSanta() { function SecretSanta() {
@ -27,18 +27,25 @@ function SecretSanta() {
} }
} }
useEffect(() => {
fetchSecretSanta()
}, [])
return ( return (
<> <>
<CenteredContainer> <CenteredContainer>
<h2>Secret Santa</h2> <h2>Secret Santa</h2>
<p className="mainText"> <p className="mainText">
Тут вы сможете узнать кому вы дарите свой подарок, а так же увидеть его вишлист, если он его добавит. Вы тоже сможете добавить свой вишлист, если захотите, чтобы ваш санта его видел! {santaInfo ? (
<br/><br/> <>
<h3>Добавить свой вишлист</h3> <p>Вы санта для Пятки: <b>{santaInfo.santa_to}</b></p>
{santaInfo.wishlist ? (
<h4>Пятка оставила вам <a href={santaInfo.wishlist}>вишлист</a></h4>
) : (
<h4>Пятка не оставила вам вишлист, используйте свое воображение. Либо ждите, пока добавит...</h4>
)}
</>
) : (
<button type="submit" onClick={fetchSecretSanta}>Показать чей я Санта!</button>
)}
<hr style={{ color: 'white'}}/>
<b>Добавить свой вишлист</b>
<form onSubmit={handleSubmit}> <form onSubmit={handleSubmit}>
<div> <div>
<label> <label>
@ -50,17 +57,13 @@ function SecretSanta() {
required required
/> />
</label> </label>
</div> <button type="submit" style={{ margin: '20px 0.5em' }}>
<button type="submit">
{'Отправить'} {'Отправить'}
</button> </button>
</div>
</form> </form>
<p>Вы санта для Пятки: <b>{santaInfo?.santa_to}</b></p>
{santaInfo?.wishlist ? (
<h4>Пятка оставила вам <a href={santaInfo.wishlist}>вишлсит</a></h4>
): (
<h4>Пятка не оставила вам вишлист, используйте свое воображение. Либо ждите пока добавит....</h4>
)}
</p> </p>
</CenteredContainer> </CenteredContainer>
</> </>