All files / app/components result.component.ts

100% Statements 11/11
100% Branches 4/4
100% Functions 4/4
100% Lines 11/11

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      1x 17x 17x 17x     17x 17x       17x 11x 11x 11x         3x        
import { Component, OnInit } from '@angular/core';
import { CommonModule } from '@angular/common';
import { ActivatedRoute, Router } from '@angular/router';
 
@Component({
  selector: 'app-result',
  standalone: true,
  imports: [CommonModule],
  template: `
    <div class="result-container">
      <div class="result-content">
        <!-- Celebration Animation -->
        <div class="celebration" *ngIf="isWinner">
          <div class="confetti">🎉</div>
          <div class="confetti">🎊</div>
          <div class="confetti">✨</div>
        </div>
 
        <!-- Main Result -->
        <h1 class="result-title" *ngIf="isWinner">Félicitations !</h1>
        <h1 class="result-title error-title" *ngIf="!isWinner">Code non valide</h1>
        <p class="result-subtitle" *ngIf="isWinner">Vous avez gagné un lot exceptionnel.</p>
 
        <!-- Prize Description -->
        <div class="prize-box" *ngIf="isWinner">
          <h2 class="prize-title">Votre lot : Un coffret cadeau Thé Tip Top</h2>
          <p class="prize-description">
            Vous avez remporté notre coffret cadeau exclusif, comprenant une sélection de nos meilleurs thés, 
            une théière en porcelaine fine et des accessoires élégants. Une expérience de dégustation inoubliable vous attend.
          </p>
        </div>
 
        <!-- Claim Instructions -->
        <div class="instructions-box" *ngIf="isWinner">
          <h3 class="instructions-title">Comment réclamer votre lot ?</h3>
          <p class="instructions-text">
            Veuillez contacter notre service client à l'adresse 
            <a href="mailto:service&#64;thetiptop.com" class="email-link">service&#64;thetiptop.com</a> 
            dans les 7 jours suivant cette annonce. Indiquez votre nom complet et l'adresse de livraison 
            pour recevoir votre coffret.
          </p>
        </div>
 
        <!-- Error Message -->
        <div class="error-box" *ngIf="!isWinner">
          <p class="error-description">
            {{ message || 'Le code que vous avez saisi n\'est pas valide ou a déjà été utilisé. Veuillez vérifier votre code et réessayer.' }}
          </p>
        </div>
 
        <!-- Action Button -->
        <button class="action-btn" (click)="goHome()">
          Retour à l'accueil
        </button>
      </div>
    </div>
  `,
  styles: [`
    .result-container {
      min-height: 80vh;
      background: var(--very-light-green);
      display: flex;
      align-items: center;
      justify-content: center;
      padding: 2rem;
    }
 
    .result-content {
      text-align: center;
      max-width: 600px;
      width: 100%;
    }
 
    .celebration {
      position: relative;
      margin-bottom: 2rem;
    }
 
    .confetti {
      position: absolute;
      font-size: 2rem;
      animation: confetti-fall 3s ease-in-out infinite;
    }
 
    .confetti:nth-child(1) {
      left: 20%;
      animation-delay: 0s;
    }
 
    .confetti:nth-child(2) {
      left: 50%;
      animation-delay: 0.5s;
    }
 
    .confetti:nth-child(3) {
      left: 80%;
      animation-delay: 1s;
    }
 
    .result-title {
      font-size: 3rem;
      font-weight: 700;
      color: var(--dark-gray);
      margin-bottom: 1rem;
    }
 
    .result-title.error-title {
      color: var(--red, #e74c3c);
      font-size: 2.5rem;
    }
 
    .result-subtitle {
      font-size: 1.2rem;
      color: var(--dark-gray);
      margin-bottom: 2rem;
      opacity: 0.8;
    }
 
    .prize-box {
      background: var(--light-green);
      border-radius: 16px;
      padding: 2rem;
      margin-bottom: 2rem;
      box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    }
 
    .prize-title {
      color: var(--orange);
      font-size: 1.5rem;
      font-weight: 700;
      margin-bottom: 1rem;
    }
 
    .prize-description {
      color: var(--dark-gray);
      line-height: 1.6;
      font-size: 1rem;
    }
 
    .instructions-box {
      background: var(--light-green);
      border-radius: 16px;
      padding: 2rem;
      margin-bottom: 2rem;
      box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    }
 
    .instructions-title {
      color: var(--dark-gray);
      font-size: 1.3rem;
      font-weight: 700;
      margin-bottom: 1rem;
    }
 
    .instructions-text {
      color: var(--dark-gray);
      line-height: 1.6;
      font-size: 1rem;
    }
 
    .email-link {
      color: var(--secondary-green);
      text-decoration: none;
      font-weight: 600;
    }
 
    .email-link:hover {
      text-decoration: underline;
    }
 
    .error-box {
      background: rgba(231, 76, 60, 0.1);
      border: 1px solid rgba(231, 76, 60, 0.3);
      border-radius: 16px;
      padding: 2rem;
      margin-bottom: 2rem;
    }
 
    .error-title {
      color: var(--red);
      font-size: 1.5rem;
      font-weight: 700;
      margin-bottom: 1rem;
    }
 
    .error-description {
      color: var(--dark-gray);
      line-height: 1.6;
      font-size: 1rem;
    }
 
    .action-btn {
      background: var(--secondary-green);
      color: white;
      border: none;
      padding: 1.2rem 3rem;
      border-radius: 12px;
      font-size: 1.2rem;
      font-weight: 600;
      cursor: pointer;
      transition: all 0.3s ease;
    }
 
    .action-btn:hover {
      background: #45a049;
      transform: translateY(-2px);
      box-shadow: 0 6px 20px rgba(76, 175, 80, 0.3);
    }
 
    /* Animations */
    @keyframes confetti-fall {
      0% {
        transform: translateY(-100px) rotate(0deg);
        opacity: 1;
      }
      100% {
        transform: translateY(100px) rotate(360deg);
        opacity: 0;
      }
    }
 
    /* Responsive */
    @media (max-width: 768px) {
      .result-container {
        padding: 1rem;
        min-height: 70vh;
      }
 
      .result-title {
        font-size: 2.5rem;
      }
 
      .result-subtitle {
        font-size: 1.1rem;
      }
 
      .prize-box,
      .instructions-box,
      .error-box {
        padding: 1.5rem;
      }
 
      .prize-title,
      .instructions-title,
      .error-title {
        font-size: 1.3rem;
      }
 
      .action-btn {
        padding: 1rem 2rem;
        font-size: 1.1rem;
      }
    }
 
    @media (max-width: 480px) {
      .result-title {
        font-size: 2rem;
      }
 
      .prize-box,
      .instructions-box,
      .error-box {
        padding: 1.2rem;
      }
    }
  `]
})
export class ResultComponent implements OnInit {
  isWinner = false;
  code = '';
  message = '';
 
  constructor(
    private route: ActivatedRoute,
    private router: Router
  ) {}
 
  ngOnInit() {
    this.route.queryParams.subscribe(params => {
      this.code = params['code'] || '';
      this.message = params['message'] || '';
      this.isWinner = params['isWinner'] === 'true';
    });
  }
 
  goHome() {
    this.router.navigate(['/']);
  }
}