-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add review / refactor regional congfiguration / various fixes
- Loading branch information
Showing
50 changed files
with
1,172 additions
and
369 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import axios from "axios"; | ||
|
||
export default class TimezoneService { | ||
constructor() { | ||
this.timezone = null; | ||
} | ||
|
||
async configureTimezone() { | ||
this.timezone = Intl.DateTimeFormat().resolvedOptions().timeZone; | ||
axios.post('https://localhost/set/browser/timezone', { | ||
timezone: this.timezone | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
import { Controller } from '@hotwired/stimulus'; | ||
|
||
export default class extends Controller { | ||
static targets = ['star'] | ||
|
||
connect() { | ||
this.stars = this.starTargets; | ||
this.currentRating = this.getRating(); | ||
} | ||
handleStarHover = (event) => { | ||
const starIndex = this.stars.indexOf(event.target); | ||
const currentRating = this.currentRating; | ||
|
||
this.dispatchEvent('hover', { starIndex, currentRating }); | ||
}; | ||
|
||
getRating() { | ||
// Get the current rating from the data-action attribute | ||
const dataAction = this.element.dataset.action.split('|'); | ||
const actionType = dataAction[0]; | ||
const actionData = dataAction[1]; | ||
|
||
if (actionType === 'prevent') { | ||
// Extract the rating from the data-action-name attribute | ||
const rating = actionData.split('(')[1].split(')')[0]; | ||
return Number(rating); | ||
} | ||
} | ||
|
||
hover(event) { | ||
const starIndex = event.detail.starIndex; | ||
const currentRating = event.detail.currentRating; | ||
|
||
if (starIndex < currentRating) { | ||
// Increase the current rating | ||
this.currentRating++; | ||
this.updateStarsColor(); | ||
} else if (starIndex === currentRating) { | ||
// Highlight the current rating | ||
this.highlightStar(starIndex); | ||
} else { | ||
// Decrement the current rating | ||
this.currentRating--; | ||
this.updateStarsColor(); | ||
} | ||
} | ||
|
||
updateStarsColor() { | ||
for (let i = 0; i < this.currentRating; i++) { | ||
this.stars[i].classList.add('bi-star-fill'); | ||
this.stars[i].classList.remove('bi-star'); | ||
} | ||
|
||
for (let i = this.currentRating; i < this.stars.length; i++) { | ||
this.stars[i].classList.add('bi-star'); | ||
this.stars[i].classList.remove('bi-star-fill'); | ||
} | ||
} | ||
|
||
highlightStar(index) { | ||
this.stars[index].classList.add('bi-star-fill'); | ||
this.stars[index].classList.remove('bi-star'); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
src/Controller/Controller/RegionalConfigurationController.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Controller\Controller; | ||
|
||
use App\Entity\User; | ||
use App\Form\Filter\RegionFilterType; | ||
use App\Model\RegionalConfiguration; | ||
use App\Repository\UserRepository; | ||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; | ||
use Symfony\Component\HttpFoundation\Request; | ||
use Symfony\Component\HttpFoundation\Response; | ||
use Symfony\Component\Routing\Annotation\Route; | ||
use Symfony\Component\Security\Http\Attribute\CurrentUser; | ||
|
||
#[Route('/region')] | ||
class RegionalConfigurationController extends AbstractController | ||
{ | ||
public function __construct( | ||
private readonly RegionalConfiguration $regionalSetting, | ||
private readonly UserRepository $userRepository, | ||
) { | ||
} | ||
|
||
#[Route(path: '/', name: '_app_regional_settings', methods: ['GET', 'POST'])] | ||
public function index(Request $request, #[CurrentUser] null|User $user): Response | ||
{ | ||
$session = $request->getSession(); | ||
$regionForm = $this->createForm(RegionFilterType::class, $this->regionalSetting, [ | ||
'request' => $request, | ||
]); | ||
$regionForm->handleRequest($request); | ||
if ($regionForm->isSubmitted() && $regionForm->isValid()) { | ||
if ($user instanceof User) { | ||
$user->setLocale($regionForm->get('locale')->getData()); | ||
$user->setCurrency($regionForm->get('currency')->getData()); | ||
$user->setCountry($regionForm->get('region')->getData()); | ||
$user->setTimezone($regionForm->get('timezone')->getData()); | ||
$this->userRepository->save(entity: $user, flush: true); | ||
} | ||
|
||
$this->regionalSetting->setLocale($regionForm->get('locale')->getData()); | ||
$this->regionalSetting->setCurrency($regionForm->get('currency')->getData()); | ||
$this->regionalSetting->setRegion($regionForm->get('region')->getData()); | ||
$this->regionalSetting->setTimezone($regionForm->get('timezone')->getData()); | ||
|
||
$session->set('_locale', $regionForm->get('locale')->getData()); | ||
$session->set('_currency', $regionForm->get('currency')->getData()); | ||
$session->set('_region', $regionForm->get('region')->getData()); | ||
$session->set('_timezone', $regionForm->get('timezone')->getData()); | ||
|
||
return $this->redirectToRoute('events'); | ||
} | ||
|
||
return $this->render('regional-settings/form.html.twig', [ | ||
'regionForm' => $regionForm->createView(), | ||
]); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,14 +11,10 @@ | |
use App\Security\CustomAuthenticator; | ||
use App\Security\EmailVerifier; | ||
use App\Service\AvatarService\AvatarService; | ||
use App\Service\EmailEventService\EmailEventService; | ||
use App\Service\EmailService\EmailToUserConnectorService; | ||
use Doctrine\ORM\EntityManagerInterface; | ||
use Symfony\Bridge\Twig\Mime\TemplatedEmail; | ||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; | ||
use Symfony\Component\HttpFoundation\Request; | ||
use Symfony\Component\HttpFoundation\Response; | ||
use Symfony\Component\Mime\Address; | ||
use Symfony\Component\PasswordHasher\Hasher\UserPasswordHasherInterface; | ||
use Symfony\Component\Routing\Annotation\Route; | ||
use Symfony\Component\Security\Http\Authentication\UserAuthenticatorInterface; | ||
|
@@ -28,10 +24,8 @@ | |
class RegistrationController extends AbstractController | ||
{ | ||
public function __construct( | ||
private readonly EmailVerifier $emailVerifier, | ||
private readonly AvatarService $avatarService, | ||
private readonly EmailEventService $emailEventService, | ||
private readonly EmailToUserConnectorService $emailToUserConnectorService, | ||
private readonly AvatarService $avatarService, | ||
private readonly EmailVerifier $emailVerifier | ||
) { | ||
} | ||
|
||
|
@@ -56,20 +50,6 @@ public function register(Request $request, UserPasswordHasherInterface $userPass | |
$entityManager->persist($user); | ||
$entityManager->flush(); | ||
|
||
$this->emailEventService->process(user: $user); | ||
$this->emailToUserConnectorService->connect(user: $user); | ||
|
||
// generate a signed url and email it to the user | ||
$this->emailVerifier->sendEmailConfirmation( | ||
'app_verify_email', | ||
$user, | ||
(new TemplatedEmail()) | ||
->from(new Address('[email protected]', 'Event Point')) | ||
->to($user->getEmail()) | ||
->subject('Please Confirm your Email') | ||
->htmlTemplate('email/confirmation_email.html.twig') | ||
); | ||
|
||
return $userAuthenticator->authenticateUser( | ||
$user, | ||
$authenticator, | ||
|
@@ -102,7 +82,6 @@ public function verifyUserEmail(Request $request, TranslatorInterface $translato | |
$this->emailVerifier->handleEmailConfirmation($request, $user); | ||
} catch (VerifyEmailExceptionInterface $exception) { | ||
$this->addFlash('verify_email_error', $translator->trans($exception->getReason(), [], 'VerifyEmailBundle')); | ||
|
||
return $this->redirectToRoute('app_register'); | ||
} | ||
|
||
|
Oops, something went wrong.