Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
cf529278bd | ||
|
|
31304c931d | ||
|
|
dc39113335 | ||
|
|
fed6b7c92f | ||
|
|
7a4c2f5015 | ||
|
|
76f7ed4f8d | ||
|
|
c210aec76f | ||
|
|
f1798c496b | ||
|
|
26bfdb5cb2 | ||
|
|
6bce33e9de | ||
|
|
9ae484d584 | ||
|
|
089995c84d | ||
|
|
615c084995 | ||
|
|
afbffe99a8 | ||
|
|
476f4390fe | ||
|
|
483e281acd | ||
|
|
0c0af0fd00 | ||
|
|
d9ccd7ff5f | ||
|
|
741dabd720 | ||
|
|
f4caf50f40 | ||
|
|
8e110244bb | ||
|
|
567bc306e1 | ||
|
|
1f42a5392b | ||
|
|
ac2dcef7a7 | ||
|
|
7b4280d4eb | ||
|
|
4031faf08b | ||
|
|
59598e29be | ||
|
|
51435f9257 | ||
|
|
2489aad0c8 | ||
|
|
f52d5bb5ef | ||
|
|
f0070d3557 | ||
|
|
cbe816fd17 | ||
|
|
cdc4645d92 | ||
|
|
60760d6101 | ||
|
|
4c52fa5043 | ||
|
|
f13e96c7c7 | ||
|
|
aa3d5f887d | ||
|
|
93bfc19e6e | ||
|
|
de0457c426 | ||
|
|
ef33591c2a | ||
|
|
551909aee7 | ||
|
|
bfec1752e0 | ||
|
|
0b3e9142b5 | ||
|
|
a99a610688 | ||
|
|
4a0087104c | ||
|
|
52c187dc2c | ||
|
|
f09b396826 | ||
|
|
094b25abdd | ||
|
|
3e5dc3f377 | ||
|
|
0a9b4874db | ||
|
|
33d9edc39f | ||
|
|
3789a2107a | ||
|
|
8c8fb946e1 | ||
|
|
165a24f5d0 | ||
|
|
8df5d54d14 | ||
|
|
0ffd8e8ad4 | ||
|
|
b9283136ba | ||
|
|
f31b92e0d3 | ||
|
|
42879b9d76 | ||
|
|
17fa90ab9d | ||
|
|
2374774577 | ||
|
|
7e6052d879 | ||
|
|
faa642f5d9 | ||
|
|
d4092a5a3e | ||
|
|
9b814151ff | ||
|
|
ee279cc9c2 | ||
|
|
5de0daa54a | ||
|
|
94beb74242 | ||
|
|
ab36d90796 | ||
|
|
1d9c6726b3 | ||
|
|
83ec6c9a2a | ||
|
|
c73f4bd35b | ||
|
|
3528df0571 | ||
|
|
368465b8f3 | ||
|
|
fdc79baf26 | ||
|
|
fa58184f21 | ||
|
|
78645e3cb0 | ||
|
|
712bdd02cd | ||
|
|
c1d7f5cd81 | ||
|
|
32607f32d8 | ||
|
|
1f6f280958 | ||
|
|
3457ac8282 | ||
|
|
7366c2a199 | ||
|
|
12440232da | ||
|
|
1aa367941e | ||
|
|
2252ac9547 | ||
|
|
9fbc09017b | ||
|
|
ec76ca981a | ||
|
|
b7ccc38b68 | ||
|
|
d627afdeaf | ||
|
|
cf2a29a863 | ||
|
|
8371f96388 | ||
|
|
6a825db608 | ||
|
|
16ae03e6e6 | ||
|
|
bda5aa4d50 | ||
|
|
4ebb1ad6c0 | ||
|
|
0e5d6a1270 | ||
|
|
75d80985ff | ||
|
|
ad6a0f6e90 | ||
|
|
5d256637ec | ||
|
|
77d3efc555 | ||
|
|
6966027096 | ||
|
|
400d70ff7e | ||
|
|
2ca3100b3c | ||
|
|
6c679596bd | ||
|
|
92de307017 | ||
|
|
2921cbdcbd | ||
|
|
0c04694c34 | ||
|
|
3d8fd6687d | ||
|
|
ce887d0846 | ||
|
|
0057972c2f | ||
|
|
da3bc1f534 | ||
|
|
62cb78859c | ||
|
|
5d98678d86 | ||
|
|
431b9eb0bb | ||
|
|
f3d6f6bd11 | ||
|
|
2271304044 | ||
|
|
66266d1b4b | ||
|
|
e713cc2857 | ||
|
|
96973f7884 | ||
|
|
c3fb0ec094 | ||
|
|
d9ce927d88 | ||
|
|
870151cdd3 | ||
|
|
7ff2f6a6d0 | ||
|
|
6ff9d3a6a7 | ||
|
|
138077fa75 | ||
|
|
2789f0e1d9 | ||
|
|
39702cec9f | ||
|
|
ee949da604 | ||
|
|
922b4df8b5 | ||
|
|
928d504b27 | ||
|
|
a189ce98a0 | ||
|
|
3d7c76496f | ||
|
|
c16a9d1785 | ||
|
|
d2dd44af4d | ||
|
|
c9382136ba | ||
|
|
bed8c79c0a | ||
|
|
15cd88c461 | ||
|
|
a65dcdee3b | ||
|
|
2dcc861317 | ||
|
|
d51d6a9c3f | ||
|
|
9986dfa956 | ||
|
|
e720c6c5dd | ||
|
|
a33b6354bf | ||
|
|
e67db45548 | ||
|
|
ec61d5e721 | ||
|
|
1cabe42d83 | ||
|
|
dd63f5ddd0 | ||
|
|
ffa77ad386 | ||
|
|
d77e3dc82b | ||
|
|
2c4c1cf403 | ||
|
|
3b304959a9 | ||
|
|
f32dee8e58 | ||
|
|
8c0ff638c3 | ||
|
|
6c3a11388b | ||
|
|
ac1eaca0df | ||
|
|
7768e7a9e3 | ||
|
|
d3d7292b80 | ||
|
|
a85e843863 | ||
|
|
59c8268232 | ||
|
|
7351cd5c53 | ||
|
|
97ae8366c0 | ||
|
|
7782983fef | ||
|
|
6b155d70b3 | ||
|
|
24aaf8661c | ||
|
|
4d089d004c | ||
|
|
281094fb7b | ||
|
|
06f8fec1ab | ||
|
|
e006cb1c5e | ||
|
|
c74690f68b | ||
|
|
5e232fd0af | ||
|
|
accbbe31d9 | ||
|
|
06844e4b81 | ||
|
|
b1996d153e | ||
|
|
b9ed209e5d | ||
|
|
ed5edefcc4 | ||
|
|
64455066a8 | ||
|
|
4acb8ad001 | ||
|
|
05ff869183 | ||
|
|
3a5a95cba9 | ||
|
|
880032bc28 | ||
|
|
24f0365513 | ||
|
|
b256e3b7dc | ||
|
|
f483dbe17e | ||
|
|
569b9df7f2 | ||
|
|
ae5a159d31 | ||
|
|
7f64c80b77 | ||
|
|
591127b5b6 | ||
|
|
1aa57e3e3e | ||
|
|
881e3b7775 | ||
|
|
8c1171846d | ||
|
|
a64146e227 | ||
|
|
22e6f365b0 | ||
|
|
fadaf6765c | ||
|
|
637a32314a | ||
|
|
59105c6d8a | ||
|
|
33a918d02b | ||
|
|
de7a0a85f6 | ||
|
|
8f91f480eb | ||
|
|
f66c8a8eb6 | ||
|
|
d4526487ed | ||
|
|
32341b0311 | ||
|
|
0f45a25b25 | ||
|
|
7099ad53c5 | ||
|
|
0f3beba354 | ||
|
|
260584bf89 | ||
|
|
a8132e9f13 | ||
|
|
ccc188a8c0 | ||
|
|
446bded5f9 | ||
|
|
c644c05933 | ||
|
|
53cca29b67 | ||
|
|
396519e5f9 | ||
|
|
dd2a0bc333 | ||
|
|
797887b23d | ||
|
|
8def3ee391 | ||
|
|
e118debc6b | ||
|
|
de13fa0b4a | ||
|
|
bf6deadbc0 | ||
|
|
46a4ac9c15 | ||
|
|
60012c63c3 | ||
|
|
c3122072da | ||
|
|
ab1df4d692 | ||
|
|
234717b23c | ||
|
|
9fd72c6ea4 | ||
|
|
9b70b09173 | ||
|
|
2b8487432f | ||
|
|
b4a5283547 | ||
|
|
69d6a77ff1 | ||
|
|
475a1c7052 | ||
|
|
c49a5e558f | ||
|
|
51791a3b34 | ||
|
|
2790026475 | ||
|
|
ed37808d33 | ||
|
|
f066aa88f0 | ||
|
|
3451f75b37 | ||
|
|
be3f6ba5d4 | ||
|
|
516ab77d58 | ||
|
|
6eaac7a745 | ||
|
|
ab9755ade5 | ||
|
|
e0504ea0c2 | ||
|
|
08459ac627 | ||
|
|
08c51473a7 | ||
|
|
a0e95aca3e | ||
|
|
4c3647fe30 | ||
|
|
4c907c8ba5 | ||
|
|
ae81344fe2 | ||
|
|
7390ae6116 | ||
|
|
090db4205a | ||
|
|
543db51291 | ||
|
|
8e93a0aba2 | ||
|
|
eab9565c7d | ||
|
|
dfb70cc5ce | ||
|
|
e89f00e2f9 | ||
|
|
9bc03eb46a | ||
|
|
3e43966357 | ||
|
|
b3cffe3008 | ||
|
|
8e1e8e3b7c | ||
|
|
639675c266 | ||
|
|
de08e5396a | ||
|
|
669fa6aa16 | ||
|
|
ba7146cca7 | ||
|
|
afb630d053 | ||
|
|
056f42b815 | ||
|
|
8426755db3 | ||
|
|
319f143327 | ||
|
|
04e45f3b83 | ||
|
|
6ae4fd1cdd | ||
|
|
da20be4558 | ||
|
|
b8ccef3fb5 | ||
|
|
2db242d43a | ||
|
|
ad3157807c | ||
|
|
efd87bf5cd | ||
|
|
7bf6ffe2f8 | ||
|
|
6a0125eeaf | ||
|
|
897e92d8f0 | ||
|
|
238127bc16 | ||
|
|
232804fb39 | ||
|
|
20654b2eff | ||
|
|
a7b8de3205 | ||
|
|
b7cd27be7e | ||
|
|
99655b0d84 | ||
|
|
6c4d03eb6b | ||
|
|
1f077cfdd2 | ||
|
|
60d1ec1364 | ||
|
|
1eb75b5782 | ||
|
|
457dd6679b | ||
|
|
bd4dceace6 | ||
|
|
b1a0edb474 | ||
|
|
4ae2905b48 | ||
|
|
59a5a4fde9 | ||
|
|
c83b626b9a | ||
|
|
9e271f8a3e | ||
|
|
d6a8fd3010 | ||
|
|
d5f1c7f163 | ||
|
|
016017ab30 | ||
|
|
23da5640c7 | ||
|
|
83a401bd15 | ||
|
|
5e846a8896 | ||
|
|
feef269015 | ||
|
|
d142979e49 | ||
|
|
feb901c9e8 | ||
|
|
fd65cfdc1c | ||
|
|
2c606d4fe7 | ||
|
|
347522a429 | ||
|
|
fdc4819c2e | ||
|
|
dea69e018e | ||
|
|
67048d7f4b | ||
|
|
5b01f2e9f4 | ||
|
|
ad0f51c405 | ||
|
|
901c6ab68e | ||
|
|
827ade852e | ||
|
|
55f332d28e | ||
|
|
71fc82a0e7 | ||
|
|
3c2128b9b7 | ||
|
|
f353e0c964 | ||
|
|
8341021ba5 | ||
|
|
86b7996d75 | ||
|
|
8e3f189e77 | ||
|
|
75e156ae07 | ||
|
|
294c3581f9 | ||
|
|
41cf8a5a44 | ||
|
|
adfe2a9fe1 | ||
|
|
9cf93d93c7 | ||
|
|
a3c418de46 | ||
|
|
8932c90c8a | ||
|
|
b3222f0f46 | ||
|
|
47d433eecb | ||
|
|
081cd66a8e | ||
|
|
2c94483cd9 | ||
|
|
2cf024fe3e | ||
|
|
219c71a99b | ||
|
|
5787d5fac3 | ||
|
|
7add68c780 | ||
|
|
4fdf38827d | ||
|
|
ded8e85c85 | ||
|
|
0d926d4b95 | ||
|
|
fd8c47cd95 | ||
|
|
ab50743c01 | ||
|
|
5a41d2e028 | ||
|
|
a7b9ce803b | ||
|
|
42a98f3435 | ||
|
|
c691f81ebb | ||
|
|
ef775c70fe | ||
|
|
a2e96cef5a | ||
|
|
56c9139d0c | ||
|
|
3c929f5c64 | ||
|
|
223cfe086c | ||
|
|
1c00dbdb85 | ||
|
|
70fbc02918 | ||
|
|
3d6597a246 | ||
|
|
eb7a5c7894 | ||
|
|
ed5376cb43 | ||
|
|
0f8ce7deea |
No files matched your search
@@ -0,0 +1,18 @@
|
||||
root = true
|
||||
|
||||
[*]
|
||||
charset = utf-8
|
||||
end_of_line = lf
|
||||
indent_size = 4
|
||||
indent_style = space
|
||||
insert_final_newline = true
|
||||
trim_trailing_whitespace = true
|
||||
|
||||
[*.md]
|
||||
trim_trailing_whitespace = false
|
||||
|
||||
[*.{yml,yaml}]
|
||||
indent_size = 2
|
||||
|
||||
[compose.yaml]
|
||||
indent_size = 4
|
||||
@@ -0,0 +1,11 @@
|
||||
* text=auto eol=lf
|
||||
|
||||
*.blade.php diff=html
|
||||
*.css diff=css
|
||||
*.html diff=html
|
||||
*.md diff=markdown
|
||||
*.php diff=php
|
||||
|
||||
/.github export-ignore
|
||||
CHANGELOG.md export-ignore
|
||||
.styleci.yml export-ignore
|
||||
@@ -1,29 +1,28 @@
|
||||
.env
|
||||
|
||||
# Logs
|
||||
logs
|
||||
*.log
|
||||
npm-debug.log*
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
||||
pnpm-debug.log*
|
||||
lerna-debug.log*
|
||||
|
||||
node_modules
|
||||
dist
|
||||
dist-ssr
|
||||
*.local
|
||||
|
||||
# Editor directories and files
|
||||
.vscode/*
|
||||
!.vscode/extensions.json
|
||||
.idea
|
||||
.DS_Store
|
||||
*.suo
|
||||
*.ntvs*
|
||||
*.njsproj
|
||||
*.sln
|
||||
*.sw?
|
||||
.env
|
||||
.env.backup
|
||||
.env.production
|
||||
.phpactor.json
|
||||
.phpunit.result.cache
|
||||
/.fleet
|
||||
/.idea
|
||||
/.nova
|
||||
/.phpunit.cache
|
||||
/.vscode
|
||||
/.zed
|
||||
/auth.json
|
||||
/node_modules
|
||||
/public/build
|
||||
/public/hot
|
||||
/public/storage
|
||||
/storage/*.key
|
||||
/storage/pail
|
||||
/vendor
|
||||
Homestead.json
|
||||
Homestead.yaml
|
||||
Thumbs.db
|
||||
|
||||
/public/**
|
||||
!/public/index.php
|
||||
|
||||
*storybook.log
|
||||
storybook-static
|
||||
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use \Illuminate\Http\JsonResponse;
|
||||
|
||||
class AuthController extends Controller
|
||||
{
|
||||
public function login(Request $request): JsonResponse
|
||||
{
|
||||
$credentials = $request->validate([
|
||||
'email' => ['required','email'],
|
||||
'password' => ['required'],
|
||||
]);
|
||||
|
||||
if (!Auth::attempt($credentials, remember: true)) {
|
||||
return response()->json(['message' => 'Invalid credentials'], 401);
|
||||
}
|
||||
|
||||
$request->session()->regenerate();
|
||||
return response()->json(['message' => 'ok']);
|
||||
}
|
||||
|
||||
public function logout(Request $request): JsonResponse
|
||||
{
|
||||
|
||||
Auth::guard('web')->logout();
|
||||
$request->session()->invalidate();
|
||||
$request->session()->regenerateToken();
|
||||
|
||||
return response()->json(['message' => 'ok']);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
|
||||
|
||||
abstract class Controller
|
||||
{
|
||||
use AuthorizesRequests;
|
||||
}
|
||||
@@ -0,0 +1,209 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Mail\EventParticipationCancelledMail;
|
||||
use App\Models\Event;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
use Illuminate\Support\Facades\Notification;
|
||||
use App\Models\Task;
|
||||
use App\Notifications\EventDeleted;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Support\Facades\Gate;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
|
||||
|
||||
class EventsController extends Controller
|
||||
{
|
||||
public function create(Request $request): JsonResponse
|
||||
{
|
||||
|
||||
|
||||
if (Gate::denies('create', Event::class)) {
|
||||
return response()->json(['message' => 'Forbidden'], 403);
|
||||
}
|
||||
|
||||
try {
|
||||
|
||||
Event::create([
|
||||
"name" => $request['name'],
|
||||
"description" => $request['description'],
|
||||
"start" => $request['start'],
|
||||
"end" => $request['end'],
|
||||
]);
|
||||
|
||||
return response()->json(['message' => 'Event created']);
|
||||
|
||||
} catch (\Exception $e) {
|
||||
Log::info($e->getMessage());
|
||||
return response()->json(['message' => "Server error"], 500);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function update(Request $request, int $id): JsonResponse {
|
||||
|
||||
if (Gate::denies('update', Event::class)) {
|
||||
return response()->json(['message' => 'Forbidden'], 403);
|
||||
}
|
||||
|
||||
try {
|
||||
|
||||
$event = Event::find($id);
|
||||
|
||||
$event->name = $request['name'];
|
||||
$event->description = $request['description'];
|
||||
$event->start = $request['start'];
|
||||
$event->end = $request['end'];
|
||||
$event->save();
|
||||
|
||||
return response()->json(["message" => "Event updated"]);
|
||||
|
||||
} catch (\Exception $e) {
|
||||
Log::info($e->getMessage());
|
||||
return response()->json(['message' => "Server error"], 500);
|
||||
}
|
||||
}
|
||||
|
||||
public function getEvents(Request $request): JsonResponse {
|
||||
try {
|
||||
$events = Event::with('tasks')->get();
|
||||
|
||||
return response()->json(['data' => $events]);
|
||||
|
||||
} catch (\Exception $e) {
|
||||
Log::info($e->getMessage());
|
||||
return response()->json(['message' => "Server error"], 500);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function delete(Request $request, int $id): JsonResponse
|
||||
{
|
||||
if (Gate::denies('delete', Event::class)) {
|
||||
return response()->json(['message' => 'Forbidden'], 403);
|
||||
}
|
||||
|
||||
try {
|
||||
$event = Event::with('tasks.users')->findOrFail($id);
|
||||
|
||||
if (Carbon::now()->lessThanOrEqualTo($event->end)) {
|
||||
$participants = $event->tasks
|
||||
->flatMap(fn($task) => $task->users)
|
||||
->unique('id');
|
||||
|
||||
if ($participants->isNotEmpty()) {
|
||||
Notification::send($participants, new EventDeleted($event));
|
||||
|
||||
foreach ($participants as $user) {
|
||||
if ($user->email_notifications) {
|
||||
Mail::to($user->email)->send(new EventParticipationCancelledMail([
|
||||
'name' => $user->name,
|
||||
'lastname' => $user->lastname,
|
||||
'eventName' => $event->name,
|
||||
'start' => $event->start,
|
||||
'end' => $event->end,
|
||||
]));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$event->delete();
|
||||
|
||||
return response()->json(['message' => 'Event deleted and participants notified']);
|
||||
|
||||
} catch (\Exception $e) {
|
||||
Log::error("Event delete error: " . $e->getMessage());
|
||||
return response()->json(['message' => 'Server error'], 500);
|
||||
}
|
||||
}
|
||||
|
||||
public function getEvent(Request $request, int $id): JsonResponse {
|
||||
try {
|
||||
|
||||
$event = Event::with(['tasks' => function ($query) {
|
||||
$query->withCount('users');
|
||||
}])->find($id);
|
||||
return response()->json([
|
||||
"id" => $event->id,
|
||||
"name" => $event->name,
|
||||
"description" => $event->description,
|
||||
"start" => $event->start,
|
||||
"end" => $event->end,
|
||||
"created_at" => $event->created_at,
|
||||
"updated_at" => $event->updated_at,
|
||||
"tasks" => $event->tasks,
|
||||
"event_photo_path" =>$event->event_photo_path,
|
||||
]);
|
||||
} catch (\Exception $e) {
|
||||
Log::info($e->getMessage());
|
||||
return response()->json(['message' => "Server error"], 500);
|
||||
}
|
||||
}
|
||||
|
||||
public function isUserAssigned(Request $request, int $id): JsonResponse
|
||||
{
|
||||
try {
|
||||
$task = Task::findOrFail($id);
|
||||
|
||||
$isAssigned = $task->users()
|
||||
->where('users.id', $request->user()->id)
|
||||
->exists();
|
||||
|
||||
return response()->json([
|
||||
'assigned' => $isAssigned
|
||||
], 200);
|
||||
|
||||
} catch (\Exception $e) {
|
||||
Log::error($e->getMessage());
|
||||
|
||||
return response()->json([
|
||||
'message' => 'Server error'
|
||||
], 500);
|
||||
}
|
||||
}
|
||||
|
||||
public function show(int $id)
|
||||
{
|
||||
$event = Event::findOrFail($id);
|
||||
|
||||
return response()->json([
|
||||
'event_photo_path' => $event->event_photo_path
|
||||
]);
|
||||
}
|
||||
|
||||
public function updatePhoto(Request $request, int $id)
|
||||
{
|
||||
$request->validate([
|
||||
'photo' => 'required|image|mimes:jpeg,png,jpg,gif|max:2048',
|
||||
]);
|
||||
$event = Event::findOrFail($id);
|
||||
$path = $request->file('photo')->store('event-photos', 'public');
|
||||
if ($event->event_photo_path) {
|
||||
Storage::disk('public')->delete($event->event_photo_path);
|
||||
}
|
||||
$event->update([
|
||||
'event_photo_path' => $path
|
||||
]);
|
||||
return response()->json([
|
||||
'event_photo_path' => $path
|
||||
]);
|
||||
}
|
||||
public function destroy(int $id)
|
||||
{
|
||||
$event = Event::findOrFail($id);
|
||||
if ($event->event_photo_path) {
|
||||
Storage::disk('public')->delete($event->event_photo_path);
|
||||
$event->update([
|
||||
'event_photo_path' => null
|
||||
]);
|
||||
}
|
||||
return response()->json([
|
||||
'message' => 'Photo supprimée'
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\User;
|
||||
use Carbon\Carbon;
|
||||
|
||||
class ExportController extends Controller
|
||||
{
|
||||
public function exportIcs($userId)
|
||||
{
|
||||
$user = User::with('tasks.event')->findOrFail($userId);
|
||||
|
||||
$lines = [
|
||||
'BEGIN:VCALENDAR',
|
||||
'VERSION:2.0',
|
||||
'PRODID:-//VotreApp//FR',
|
||||
];
|
||||
|
||||
$now = Carbon::now()->utc()->format('Ymd\THis\Z');
|
||||
|
||||
foreach ($user->tasks as $task) {
|
||||
|
||||
// On ignore les tâches sans dates
|
||||
if (!$task->start || !$task->end) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$uid = $task->id . '-' . $user->id . '@votreapp.local';
|
||||
|
||||
$dtstart = Carbon::parse($task->start)->utc()->format('Ymd\THis\Z');
|
||||
$dtend = Carbon::parse($task->end)->utc()->format('Ymd\THis\Z');
|
||||
|
||||
$summary = $this->escapeText($task->name);
|
||||
|
||||
$description = $this->escapeText(
|
||||
trim(
|
||||
($task->description ?? '') .
|
||||
($task->event ? "\nÉvénement: {$task->event->name}" : '')
|
||||
)
|
||||
);
|
||||
|
||||
$location = $this->escapeText($task->location ?? '');
|
||||
|
||||
$lines[] = 'BEGIN:VEVENT';
|
||||
$lines[] = 'UID:' . $uid;
|
||||
$lines[] = 'DTSTAMP:' . $now;
|
||||
$lines[] = 'DTSTART:' . $dtstart;
|
||||
$lines[] = 'DTEND:' . $dtend;
|
||||
$lines[] = 'SUMMARY:' . $summary;
|
||||
$lines[] = 'DESCRIPTION:' . $description;
|
||||
$lines[] = 'LOCATION:' . $location;
|
||||
$lines[] = 'END:VEVENT';
|
||||
}
|
||||
|
||||
$lines[] = 'END:VCALENDAR';
|
||||
|
||||
$content = implode("\r\n", $lines) . "\r\n";
|
||||
|
||||
return response($content, 200, [
|
||||
'Content-Type' => 'text/calendar; charset=utf-8',
|
||||
'Content-Disposition' => 'attachment; filename="agenda_user_' . $user->id . '.ics"',
|
||||
]);
|
||||
}
|
||||
|
||||
protected function escapeText($text)
|
||||
{
|
||||
$text = (string) $text;
|
||||
|
||||
return str_replace(
|
||||
["\\", "\r\n", "\n", "\r", ";", ","],
|
||||
["\\\\", "\\n", "\\n", "\\n", "\\;", "\\,"],
|
||||
$text
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class NotificationsController extends Controller
|
||||
{
|
||||
public function getNotifications(Request $request): JsonResponse
|
||||
{
|
||||
try {
|
||||
$notifications = $request->user()
|
||||
->notifications()
|
||||
->latest()
|
||||
->get();
|
||||
|
||||
return response()->json(['data' => $notifications]);
|
||||
} catch (\Exception $e) {
|
||||
Log::error($e->getMessage());
|
||||
return response()->json(['message' => 'Server error'], 500);
|
||||
}
|
||||
}
|
||||
|
||||
public function deleteNotification(Request $request, string $notificationId): JsonResponse
|
||||
{
|
||||
try {
|
||||
$notification = $request->user()->notifications()->findOrFail($notificationId);
|
||||
$notification->delete();
|
||||
|
||||
return response()->json(['message' => 'Notification supprimée avec succès']);
|
||||
} catch (\Exception $e) {
|
||||
Log::error($e->getMessage());
|
||||
return response()->json(['message' => 'Erreur lors de la suppression'], 500);
|
||||
}
|
||||
}
|
||||
|
||||
public function readNotifications(Request $request): JsonResponse
|
||||
{
|
||||
try {
|
||||
$request->user()->unreadNotifications->markAsRead();
|
||||
|
||||
return response()->json(['message' => 'Notifications marquées comme lues']);
|
||||
} catch (\Exception $e) {
|
||||
Log::error($e->getMessage());
|
||||
return response()->json(['message' => 'Server error'], 500);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Typesense\Client;
|
||||
use Exception;
|
||||
|
||||
class SearchController extends Controller
|
||||
{
|
||||
protected Client $client;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->client = new Client([
|
||||
'api_key' => config('app.typesense_api_key'),
|
||||
'nodes' => [
|
||||
[
|
||||
'host' => config('app.typesense_connection'),
|
||||
'port' => '8108',
|
||||
'protocol' => 'http',
|
||||
],
|
||||
],
|
||||
]);
|
||||
}
|
||||
|
||||
public function searchEvents(Request $request)
|
||||
{
|
||||
try {
|
||||
$query = $request->input('query', '');
|
||||
return response()->json(
|
||||
$this->client->collections['events']
|
||||
->documents
|
||||
->search([
|
||||
'q' => $query,
|
||||
'query_by' => 'name,description',
|
||||
])
|
||||
);
|
||||
} catch (Exception $e) {
|
||||
return response()->json([
|
||||
'error' => $e->getMessage()
|
||||
], 500);
|
||||
}
|
||||
}
|
||||
|
||||
public function searchUsers(Request $request)
|
||||
{
|
||||
try {
|
||||
$query = $request->input('query', '');
|
||||
return response()->json(
|
||||
$this->client->collections['users']
|
||||
->documents
|
||||
->search([
|
||||
'q' => $query,
|
||||
'query_by' => 'name,lastname',
|
||||
'filter_by' => 'validate:=true',
|
||||
])
|
||||
);
|
||||
} catch (Exception $e) {
|
||||
return response()->json([
|
||||
'error' => $e->getMessage()
|
||||
], 500);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,286 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Mail\TaskDateUpdateMail;
|
||||
use App\Mail\TaskParticipationCancelledMail;
|
||||
use App\Mail\VolunteerAssignToTaskMail;
|
||||
use App\Mail\VolunteerUnassignToTaskMail;
|
||||
use App\Notifications\TaskDateUpdated;
|
||||
use App\Notifications\TaskDeleted;
|
||||
use App\Notifications\VolunteerAssignedToTask;
|
||||
use App\Notifications\VolunteerUnassignedFromTask;
|
||||
use App\Models\Event;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
use Illuminate\Support\Facades\Notification;
|
||||
use App\Models\Task;
|
||||
use App\Models\User;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Gate;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use App\Services\FormatDate;
|
||||
|
||||
class TasksController extends Controller
|
||||
{
|
||||
public function create(Request $request): JsonResponse {
|
||||
|
||||
if(Gate::denies('create', Task::class)) {
|
||||
return response()->json(["message" => "Can't create task"], 403);
|
||||
}
|
||||
|
||||
try {
|
||||
|
||||
$event = Event::find($request["event_id"]);
|
||||
|
||||
$event->tasks()->create([
|
||||
"name" => $request["name"],
|
||||
"description" => $request["description"],
|
||||
"start" => $request["start"],
|
||||
"end" => $request["end"],
|
||||
"location" => $request["location"],
|
||||
"max_participants" => $request["max_participants"],
|
||||
]);
|
||||
|
||||
return response()->json(['message' => "Task created"], 200);
|
||||
|
||||
} catch(\Exception $e) {
|
||||
Log::info($e->getMessage());
|
||||
return response()->json(['message' => "Server error"], 500);
|
||||
}
|
||||
}
|
||||
|
||||
public function assignSelf(Request $request): JsonResponse
|
||||
{
|
||||
try {
|
||||
$task = Task::findOrFail($request["task_id"]);
|
||||
|
||||
if ($task->users()->count() >= $task->max_participants) {
|
||||
return response()->json(["message" => "Max participants reached"], 403);
|
||||
}
|
||||
|
||||
if ($task->users()->where('users.id', $request->user()->id)->exists()) {
|
||||
return response()->json(["message" => "Already registered"], 409);
|
||||
}
|
||||
|
||||
$task->users()->attach($request->user()->id);
|
||||
|
||||
return response()->json(['message' => "Task assigned"], 200);
|
||||
|
||||
} catch (\Throwable $e) {
|
||||
Log::error($e->getMessage());
|
||||
return response()->json(['message' => "Server error"], 500);
|
||||
}
|
||||
}
|
||||
|
||||
public function assignUser(Request $request, int $id): JsonResponse
|
||||
{
|
||||
if (Gate::denies('assignOther', Task::class)) {
|
||||
return response()->json(['message' => "Can't create task"], 403);
|
||||
}
|
||||
|
||||
try {
|
||||
$task = Task::findOrFail($request['task_id']);
|
||||
$event = Event::findOrFail($task->events_id);
|
||||
$user = User::findOrFail($id);
|
||||
|
||||
if ($task->users()->where('user_id', $id)->exists()) {
|
||||
return response()->json(['message' => 'User already assigned to this task'], 400);
|
||||
}
|
||||
|
||||
if ($task->max_participants === $task->users()->count()) {
|
||||
return response()->json(['message' => 'Max participants reached'], 403);
|
||||
}
|
||||
|
||||
$task->users()->attach($id);
|
||||
|
||||
if (Carbon::now()->lessThanOrEqualTo($task->end)) {
|
||||
$event = Event::findOrFail($task->events_id);
|
||||
$user->notify(new VolunteerAssignedToTask($task, $event));
|
||||
|
||||
if ($user->email_notifications) {
|
||||
Mail::to($user->email)->send(new VolunteerAssignToTaskMail([
|
||||
'name' => $user->name,
|
||||
'lastname' => $user->lastname,
|
||||
'taskName' => $task->name,
|
||||
'start' => $task->start,
|
||||
'end' => $task->end,
|
||||
'eventName' => $event->name,
|
||||
]));
|
||||
} }
|
||||
|
||||
return response()->json(['message' => 'Task assigned'], 200);
|
||||
|
||||
} catch (\Exception $e) {
|
||||
Log::error($e->getMessage());
|
||||
return response()->json(['message' => 'Server error'], 500);
|
||||
}
|
||||
}
|
||||
|
||||
public function getEventTasks(Request $request, int $id): JsonResponse {
|
||||
|
||||
try {
|
||||
|
||||
$event = Event::find($id);
|
||||
|
||||
return response()->json(['data' => $event->tasks()->get()]);
|
||||
|
||||
} catch(\Exception $e) {
|
||||
Log::info($e->getMessage());
|
||||
return response()->json(['message' => "Server error"], 500);
|
||||
}
|
||||
}
|
||||
|
||||
public function deleteTask(Request $request, int $id): JsonResponse
|
||||
{
|
||||
if (Gate::denies('delete', Task::class)) {
|
||||
return response()->json(['message' => "Can't delete task"], 403);
|
||||
}
|
||||
|
||||
try {
|
||||
$task = Task::with('users')->findOrFail($id);
|
||||
$event = Event::findOrFail($task->events_id);
|
||||
|
||||
if (Carbon::now()->lessThanOrEqualTo($task->end) && $task->users->isNotEmpty()) {
|
||||
Notification::send($task->users, new TaskDeleted($task, $event));
|
||||
|
||||
foreach ($task->users as $user) {
|
||||
if ($user->email_notifications) {
|
||||
Mail::to($user->email)->send(new TaskParticipationCancelledMail([
|
||||
'name' => $user->name,
|
||||
'lastname' => $user->lastname,
|
||||
'taskName' => $task->name,
|
||||
'start' => $event->start,
|
||||
'end' => $task->end,
|
||||
'eventName' => $event->name,
|
||||
]));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$task->delete();
|
||||
|
||||
return response()->json(['message' => 'Task deleted and participants notified'], 200);
|
||||
|
||||
} catch (\Exception $e) {
|
||||
Log::error($e->getMessage());
|
||||
return response()->json(['message' => 'Server error'], 500);
|
||||
}
|
||||
}
|
||||
|
||||
public function update(Request $request, int $id): JsonResponse
|
||||
{
|
||||
if (Gate::denies('update', Task::class)) {
|
||||
return response()->json(['message' => 'Forbidden'], 403);
|
||||
}
|
||||
|
||||
try {
|
||||
$task = Task::with('users')->findOrFail($id);
|
||||
|
||||
$datesChanged = $task->start !== $request['start'] || $task->end !== $request['end'];
|
||||
|
||||
if ($datesChanged && Carbon::now()->lessThanOrEqualTo($task->end)) {
|
||||
$event = Event::findOrFail($task->events_id);
|
||||
|
||||
Notification::send($task->users, new TaskDateUpdated(
|
||||
task: $task,
|
||||
event: $event,
|
||||
oldStart: FormatDate::formatDate($task->start),
|
||||
oldEnd: FormatDate::formatDate($task->end),
|
||||
newStart: FormatDate::formatDate($request['start']),
|
||||
newEnd: FormatDate::formatDate($request['end']),
|
||||
));
|
||||
|
||||
foreach ($task->users as $user) {
|
||||
if ($user->email_notifications) {
|
||||
Mail::to($user->email)->send(new TaskDateUpdateMail([
|
||||
'name' => $user->name,
|
||||
'lastname' => $user->lastname,
|
||||
'taskName' => $task->name,
|
||||
'oldStart' => FormatDate::formatDate($task->start),
|
||||
'oldEnd' => FormatDate::formatDate($task->end),
|
||||
'newStart' => $request['start'],
|
||||
'newEnd' => $request['end'],
|
||||
'eventName' => $event->name,
|
||||
]));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$task->update([
|
||||
'name' => $request['name'],
|
||||
'description' => $request['description'],
|
||||
'start' => $request['start'],
|
||||
'end' => $request['end'],
|
||||
'location' => $request['location'],
|
||||
'max_participants' => $request['max_participants'],
|
||||
]);
|
||||
|
||||
return response()->json(['message' => 'Task updated'], 200);
|
||||
|
||||
} catch (\Exception $e) {
|
||||
Log::error($e->getMessage());
|
||||
return response()->json(['message' => 'Server error'], 500);
|
||||
}
|
||||
}
|
||||
|
||||
public function unassignSelf(Request $request): JsonResponse {
|
||||
try {
|
||||
$task = Task::find($request["task_id"]);
|
||||
$userId = $request->user()->id;
|
||||
|
||||
if (!$task) {
|
||||
return response()->json(["message" => "Task not found"], 404);
|
||||
}
|
||||
|
||||
$task->users()->detach($userId);
|
||||
|
||||
return response()->json(['message' => "Successfully unassigned from task"], 200);
|
||||
|
||||
} catch (\Exception $e) {
|
||||
Log::error("UnassignSelf error: " . $e->getMessage());
|
||||
return response()->json(['message' => "Server error"], 500);
|
||||
}
|
||||
}
|
||||
|
||||
public function unassignUser(Request $request, int $id): JsonResponse
|
||||
{
|
||||
if (Gate::denies('unassignOther', Task::class)) {
|
||||
return response()->json(['message' => 'Unauthorized'], 403);
|
||||
}
|
||||
|
||||
try {
|
||||
$task = Task::findOrFail($request['task_id']);
|
||||
$user = User::findOrFail($id);
|
||||
|
||||
if (!$task->users()->where('user_id', $id)->exists()) {
|
||||
return response()->json(['message' => 'User is not assigned to this task'], 400);
|
||||
}
|
||||
|
||||
$task->users()->detach($id);
|
||||
|
||||
if (Carbon::now()->lessThanOrEqualTo($task->end)) {
|
||||
$event = Event::findOrFail($task->events_id);
|
||||
$user->notify(new VolunteerUnassignedFromTask($task, $event));
|
||||
|
||||
if ($user->email_notifications) {
|
||||
Mail::to($user->email)->send(new VolunteerUnassignToTaskMail([
|
||||
'name' => $user->name,
|
||||
'lastname' => $user->lastname,
|
||||
'taskName' => $task->name,
|
||||
'start' => $task->start,
|
||||
'end' => $task->end,
|
||||
'eventName' => $event->name,
|
||||
]));
|
||||
}
|
||||
}
|
||||
|
||||
return response()->json(['message' => 'User unassigned successfully'], 200);
|
||||
|
||||
} catch (\Exception $e) {
|
||||
Log::error("UnassignUser error: " . $e->getMessage());
|
||||
return response()->json(['message' => 'Server error'], 500);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,495 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Mail\EmailChangeConfirmedMail;
|
||||
use App\Mail\NotifyEmailChangeMail;
|
||||
use App\Mail\RegisterMail;
|
||||
use App\Mail\RequestEmailChangeMail;
|
||||
use App\Mail\UpdatePasswordMail;
|
||||
use App\Mail\UpdateRoleMail;
|
||||
use App\Notifications\VolunteerRoleUpdated;
|
||||
use App\Mail\CreateUserByAdminMail;
|
||||
use App\Mail\DeactivateAccountMail;
|
||||
use App\Mail\DeleteAccountMail;
|
||||
use App\Mail\ValidateMail;
|
||||
use Illuminate\Support\Facades\Notification;
|
||||
use App\Models\User;
|
||||
use App\Notifications\UserRegistered;
|
||||
use App\Services\GetRole;
|
||||
use Illuminate\Database\Eloquent\ModelNotFoundException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Gate;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use App\Services\UserService;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Pest\Support\Str;
|
||||
use Propaganistas\LaravelPhone\PhoneNumber;
|
||||
|
||||
class UserController extends Controller
|
||||
{
|
||||
public function me(Request $request): JsonResponse {
|
||||
try {
|
||||
return response()->json(UserService::getData($request->user()->id));
|
||||
} catch(\Exception $e) {
|
||||
Log::info($e->getMessage());
|
||||
return response()->json(['message' => "Server error"], 500);
|
||||
}
|
||||
}
|
||||
|
||||
public function create(Request $request): JsonResponse {
|
||||
|
||||
$request->validate([
|
||||
'phone' => ['required', 'phone:FR,national'],
|
||||
'email' => ['required', 'email:strict,rfc', 'unique:users,email'],
|
||||
]);
|
||||
|
||||
$phone = new PhoneNumber($request["phone"], 'FR');
|
||||
|
||||
$user = User::create([
|
||||
"name" => $request["name"],
|
||||
"email" => $request["email"],
|
||||
"password" => Hash::make($request["password"]),
|
||||
"lastname" => $request["lastname"],
|
||||
"validate" => 0,
|
||||
"phone" => $phone->formatInternational(),
|
||||
"web_notifications" => 1,
|
||||
"email_notifications" => 1,
|
||||
]);
|
||||
|
||||
$admins = User::whereIn('role', [1, 2])->get();
|
||||
Notification::sendNow($admins, new UserRegistered($user));
|
||||
|
||||
foreach ($admins as $admin) {
|
||||
if ($admin->email_notifications) {
|
||||
Mail::to($admin->email)->send(new RegisterMail([
|
||||
'adminName' => $admin->name,
|
||||
'adminLastname' => $admin->lastname,
|
||||
'userName' => $user->name,
|
||||
'userLastname' => $user->lastname,
|
||||
]));
|
||||
}
|
||||
}
|
||||
|
||||
return response()->json(['message' => 'User created successfully']);
|
||||
}
|
||||
|
||||
public function createUserByAdmin(Request $request): JsonResponse {
|
||||
|
||||
if(Gate::denies('createOther', $request->user())){
|
||||
return response()->json(["message" => "Can't create this user"], 403);
|
||||
}
|
||||
|
||||
$request->validate([
|
||||
'phone' => ['required', 'phone:FR,national'],
|
||||
'email' => ['required', 'email:strict,rfc', 'unique:users,email'],
|
||||
]);
|
||||
|
||||
$phone = new PhoneNumber($request["phone"], 'FR');
|
||||
|
||||
$password = Str::random(12);
|
||||
|
||||
$user = User::create([
|
||||
"name" => $request["name"],
|
||||
"email" => $request["email"],
|
||||
"password" => Hash::make($password),
|
||||
"lastname" => $request["lastname"],
|
||||
"validate" => 1,
|
||||
"role" => 3,
|
||||
"phone" => $phone->formatInternational(),
|
||||
"web_notifications" => 1,
|
||||
"email_notifications" => 1,
|
||||
]);
|
||||
|
||||
if ($user->email_notifications) {
|
||||
$data = [
|
||||
'name' => $user->name,
|
||||
'lastname' => $user->lastname,
|
||||
];
|
||||
Mail::to($user->email)->send(new CreateUserByAdminMail($data));
|
||||
}
|
||||
|
||||
return response()->json([
|
||||
'message' => 'User created successfully',
|
||||
"password" => $password,
|
||||
]);
|
||||
}
|
||||
|
||||
public function delete(Request $request): JsonResponse {
|
||||
try {
|
||||
$user = User::find($request->user()->id);
|
||||
|
||||
if ($user->email_notifications) {
|
||||
$data = [
|
||||
'name' => $user->name,
|
||||
'lastname' => $user->lastname,
|
||||
];
|
||||
Mail::to($user->email)->send(new DeleteAccountMail($data));
|
||||
}
|
||||
|
||||
$user->delete();
|
||||
return response()->json(['message' => 'User deleted successfully']);
|
||||
} catch(\Exception $e) {
|
||||
Log::info($e->getMessage());
|
||||
return response()->json(['message' => "Server error"], 500);
|
||||
}
|
||||
}
|
||||
|
||||
public function getUser(Request $request, int $id): JsonResponse {
|
||||
try {
|
||||
return response()->json(UserService::getData($id));
|
||||
} catch (ModelNotFoundException $e) {
|
||||
return response()->json(['message' => 'Utilisateur non trouvé'], 404);
|
||||
} catch (\Exception $e) {
|
||||
Log::info($e->getMessage());
|
||||
return response()->json(['message' => "Server error"], 500);
|
||||
}
|
||||
}
|
||||
|
||||
public function deleteById(Request $request, int $id): JsonResponse {
|
||||
|
||||
if(Gate::denies('deleteOther', $request->user())){
|
||||
return response()->json(["message" => "Can't delete this user"], 403);
|
||||
}
|
||||
|
||||
try {
|
||||
$user = User::find($id);
|
||||
|
||||
if ($user->email_notifications) {
|
||||
$data = [
|
||||
'name' => $user->name,
|
||||
'lastname' => $user->lastname,
|
||||
];
|
||||
Mail::to($user->email)->send(new DeleteAccountMail($data));
|
||||
}
|
||||
|
||||
$user->delete();
|
||||
return response()->json(['message' => 'User deleted successfully']);
|
||||
} catch(\Exception $e) {
|
||||
Log::info($e->getMessage());
|
||||
return response()->json(['message' => "Server error"], 500);
|
||||
}
|
||||
}
|
||||
|
||||
public function deactivate(Request $request, int $id): JsonResponse {
|
||||
$userToDeactivate = User::findOrFail($id);
|
||||
|
||||
if(Gate::denies('deactivate', $userToDeactivate)){
|
||||
return response()->json(["message" => "Can't delete this user"], 403);
|
||||
}
|
||||
|
||||
try {
|
||||
$userToDeactivate->update(['validate' => 0]);
|
||||
|
||||
if ($userToDeactivate->email_notifications) {
|
||||
$data = [
|
||||
'name' => $userToDeactivate->name,
|
||||
'lastname' => $userToDeactivate->lastname,
|
||||
];
|
||||
Mail::to($userToDeactivate->email)->send(new DeactivateAccountMail($data));
|
||||
}
|
||||
|
||||
return response()->json(['message' => 'User deactivated successfully']);
|
||||
} catch (ModelNotFoundException $e) {
|
||||
return response()->json(['message' => 'Utilisateur non trouvé'], 404);
|
||||
} catch (\Exception $e) {
|
||||
Log::info($e->getMessage());
|
||||
return response()->json(['message' => "Server error"], 500);
|
||||
}
|
||||
}
|
||||
|
||||
public function update(Request $request): JsonResponse {
|
||||
try {
|
||||
$phone = new PhoneNumber($request["phone"], 'FR');
|
||||
|
||||
$user = User::find($request->user()->id);
|
||||
$user->name = $request["name"];
|
||||
$user->lastname = $request["lastname"];
|
||||
$user->phone = $phone;
|
||||
$user->save();
|
||||
|
||||
return response()->json(['message' => 'User updated successfully']);
|
||||
} catch(\Exception $e) {
|
||||
Log::info($e->getMessage());
|
||||
return response()->json(['message' => "Server error"], 500);
|
||||
}
|
||||
}
|
||||
|
||||
public function validate(Request $request, int $id): JsonResponse {
|
||||
|
||||
if(Gate::denies('validate', $request->user())){
|
||||
return response()->json(["message" => "Can't validate this user"], 403);
|
||||
}
|
||||
|
||||
try {
|
||||
$user = User::find($id);
|
||||
|
||||
$user->validate = 1;
|
||||
$user->role = 3;
|
||||
$user->verified_at = now();
|
||||
$user->save();
|
||||
|
||||
if ($user->email_notifications) {
|
||||
$data = [
|
||||
'name' => $user->name,
|
||||
'lastname' => $user->lastname,
|
||||
];
|
||||
Mail::to($user->email)->send(new ValidateMail($data));
|
||||
}
|
||||
|
||||
return response()->json(['message' => 'User validated successfully']);
|
||||
} catch(\Exception $e) {
|
||||
Log::info($e->getMessage());
|
||||
return response()->json(['message' => "Server error"], 500);
|
||||
}
|
||||
}
|
||||
|
||||
public function addRole(Request $request, int $id): JsonResponse {
|
||||
|
||||
if(Gate::denies('addRole', $request->user())){
|
||||
return response()->json(["message" => "Can't add role to this user"], 403);
|
||||
}
|
||||
|
||||
try {
|
||||
$user = User::find($id);
|
||||
$user->role = $request['role'];
|
||||
$user->save();
|
||||
|
||||
$role = GetRole::getRole($request['role']);
|
||||
|
||||
$user->notify(new VolunteerRoleUpdated($role));
|
||||
|
||||
if ($user->email_notifications) {
|
||||
Mail::to($user->email)->send(new UpdateRoleMail([
|
||||
'name' => $user->name,
|
||||
'lastname' => $user->lastname,
|
||||
'role' => $role,
|
||||
]));
|
||||
}
|
||||
|
||||
return response()->json(['message' => 'User role added successfully']);
|
||||
} catch(\Exception $e) {
|
||||
Log::info($e->getMessage());
|
||||
return response()->json(['message' => "Server error"], 500);
|
||||
}
|
||||
}
|
||||
|
||||
public function getUsers(Request $request): JsonResponse {
|
||||
try {
|
||||
$users = User::where('validate', 1)
|
||||
->orderBy('verified_at', 'desc')
|
||||
->pluck('id');
|
||||
|
||||
return response()->json($users);
|
||||
} catch(\Exception $e) {
|
||||
Log::info($e->getMessage());
|
||||
return response()->json(['message' => "Server error"], 500);
|
||||
}
|
||||
}
|
||||
|
||||
public function getUserTasks(Request $request): JsonResponse {
|
||||
try {
|
||||
return response()->json(['data' => $request->user()->tasks]);
|
||||
} catch (\Exception $e) {
|
||||
Log::info($e->getMessage());
|
||||
return response()->json(['message' => "Server error"], 500);
|
||||
}
|
||||
}
|
||||
|
||||
public function getUserByIdTasks(Request $request, int $id): JsonResponse {
|
||||
try {
|
||||
return response()->json(['data' => User::find($id)->tasks]);
|
||||
} catch (\Exception $e) {
|
||||
Log::info($e->getMessage());
|
||||
return response()->json(['message' => "Server error"], 500);
|
||||
}
|
||||
}
|
||||
|
||||
public function getUserTaskById(Request $request, int $idTask): JsonResponse {
|
||||
try {
|
||||
return response()->json(['data' => $request->user()->tasks->find($idTask)]);
|
||||
} catch (\Exception $e) {
|
||||
Log::info($e->getMessage());
|
||||
return response()->json(['message' => "Server error"], 500);
|
||||
}
|
||||
}
|
||||
|
||||
public function getInvalidUsers(Request $request): JsonResponse {
|
||||
if(Gate::denies('getInvalidUsers', $request->user())){
|
||||
return response()->json(["message" => "Can't add role to this user"], 403);
|
||||
}
|
||||
|
||||
try {
|
||||
$users = User::where('validate', 0)->pluck('id');
|
||||
|
||||
return response()->json($users);
|
||||
} catch (\Exception $e) {
|
||||
Log::info($e->getMessage());
|
||||
return response()->json(['message' => "Server error"], 500);
|
||||
}
|
||||
}
|
||||
|
||||
public function toggleEmailNotifications(Request $request, int $id): JsonResponse {
|
||||
try {
|
||||
$user = User::findOrFail($id);
|
||||
$user->email_notifications = $user->email_notifications ? 0 : 1;
|
||||
$user->save();
|
||||
|
||||
return response()->json($user);
|
||||
} catch(\Exception $e){
|
||||
Log::info($e->getMessage());
|
||||
return response()->json(['message' => "Server error"], 500);
|
||||
}
|
||||
}
|
||||
|
||||
public function toggleWebNotifications(Request $request, int $id): JsonResponse {
|
||||
try {
|
||||
$user = User::findOrFail($id);
|
||||
$user->web_notifications = $user->web_notifications ? 0 : 1;
|
||||
$user->save();
|
||||
|
||||
return response()->json($user);
|
||||
} catch(\Exception $e){
|
||||
Log::info($e->getMessage());
|
||||
return response()->json(['message' => "Server error"], 500);
|
||||
}
|
||||
}
|
||||
|
||||
public function updatePassword(Request $request): JsonResponse {
|
||||
try {
|
||||
$request->validate([
|
||||
'current_password' => ['required'],
|
||||
'new_password' => ['required', 'confirmed'],
|
||||
]);
|
||||
|
||||
$user = $request->user();
|
||||
|
||||
if (!Hash::check($request['current_password'], $user->password)) {
|
||||
return response()->json(['message' => 'Mot de passe actuel incorrect'], 403);
|
||||
}
|
||||
|
||||
$user->password = Hash::make($request['new_password']);
|
||||
$user->save();
|
||||
|
||||
if ($user->email_notifications) {
|
||||
Mail::to($user->email)->send(new UpdatePasswordMail([
|
||||
'name' => $user->name,
|
||||
'lastname' => $user->lastname,
|
||||
]));
|
||||
}
|
||||
|
||||
return response()->json(['message' => 'Mot de passe mis à jour avec succès']);
|
||||
} catch (\Exception $e) {
|
||||
Log::error($e->getMessage());
|
||||
return response()->json(['message' => 'Server error'], 500);
|
||||
}
|
||||
}
|
||||
|
||||
public function requestEmailChange(Request $request): JsonResponse
|
||||
{
|
||||
try {
|
||||
$request->validate([
|
||||
'email' => ['required', 'email:strict,rfc', 'unique:users,email'],
|
||||
]);
|
||||
|
||||
$user = $request->user();
|
||||
|
||||
$token = \Str::random(64);
|
||||
|
||||
$user->pending_email = $request['email'];
|
||||
$user->email_change_token = hash('sha256', $token);
|
||||
$user->email_change_token_expires_at = now()->addHour();
|
||||
$user->save();
|
||||
|
||||
$data = [
|
||||
'name' => $user->name,
|
||||
'lastname' => $user->lastname,
|
||||
'token' => $token
|
||||
];
|
||||
Mail::to($user->email)->send(new NotifyEmailChangeMail($data));
|
||||
Mail::to($request['email'])->send(new RequestEmailChangeMail($data));
|
||||
|
||||
return response()->json(['message' => 'Un email de confirmation a été envoyé à votre nouvelle adresse.']);
|
||||
} catch (\Exception $e) {
|
||||
Log::error($e->getMessage());
|
||||
return response()->json(['message' => 'Server error'], 500);
|
||||
}
|
||||
}
|
||||
|
||||
public function confirmEmailChange(Request $request): JsonResponse
|
||||
{
|
||||
try {
|
||||
$request->validate([
|
||||
'token' => ['required', 'string'],
|
||||
]);
|
||||
|
||||
$user = User::where('email_change_token', hash('sha256', $request['token']))
|
||||
->where('email_change_token_expires_at', '>', now())
|
||||
->firstOrFail();
|
||||
|
||||
$newEmail = $user->pending_email;
|
||||
$oldEmail = $user->email;
|
||||
|
||||
$user->email = $newEmail;
|
||||
$user->pending_email = null;
|
||||
$user->email_change_token = null;
|
||||
$user->email_change_token_expires_at = null;
|
||||
$user->save();
|
||||
|
||||
$data = [
|
||||
'name' => $user->name,
|
||||
'lastname' => $user->lastname,
|
||||
'newEmail' => $newEmail
|
||||
];
|
||||
Mail::to($newEmail)->send(new EmailChangeConfirmedMail($data));
|
||||
Mail::to($oldEmail)->send(new EmailChangeConfirmedMail($data));
|
||||
|
||||
return response()->json(['message' => 'Email mis à jour avec succès']);
|
||||
} catch (ModelNotFoundException $e) {
|
||||
return response()->json(['message' => 'Token invalide ou expiré'], 400);
|
||||
} catch (\Exception $e) {
|
||||
Log::error($e->getMessage());
|
||||
return response()->json(['message' => 'Server error'], 500);
|
||||
}
|
||||
}
|
||||
|
||||
public function show(Request $request)
|
||||
{
|
||||
$user = $request->user();
|
||||
return response()->json(['profile_photo_path' => $user->profile_photo_path]);
|
||||
}
|
||||
|
||||
public function updatePhoto(Request $request)
|
||||
{
|
||||
$request->validate([
|
||||
'photo' => 'required|image|mimes:jpeg,png,jpg,gif|max:2048',
|
||||
]);
|
||||
|
||||
$user = $request->user();
|
||||
$path = $request->file('photo')->store('profile-photos', 'public');
|
||||
|
||||
// Supprimer l'ancienne photo si elle existe
|
||||
if ($user->profile_photo_path) {
|
||||
Storage::disk('public')->delete($user->profile_photo_path);
|
||||
}
|
||||
|
||||
$user->update(['profile_photo_path' => $path]);
|
||||
|
||||
return response()->json(['profile_photo_path' => $path]);
|
||||
}
|
||||
|
||||
public function destroy(Request $request)
|
||||
{
|
||||
$user = $request->user();
|
||||
|
||||
if ($user->profile_photo_path) {
|
||||
Storage::disk('public')->delete($user->profile_photo_path);
|
||||
$user->update(['profile_photo_path' => null]);
|
||||
}
|
||||
|
||||
return response()->json(['message' => 'Photo supprimée']);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
|
||||
namespace App\Mail;
|
||||
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Mail\Mailable;
|
||||
use Illuminate\Mail\Mailables\Content;
|
||||
use Illuminate\Mail\Mailables\Envelope;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
class CreateUserByAdminMail extends Mailable
|
||||
{
|
||||
use Queueable, SerializesModels;
|
||||
public $data;
|
||||
|
||||
/**
|
||||
* Create a new message instance.
|
||||
*/
|
||||
public function __construct($data)
|
||||
{
|
||||
$this->data = $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the message envelope.
|
||||
*/
|
||||
public function envelope(): Envelope
|
||||
{
|
||||
return new Envelope(
|
||||
subject: 'Compte créé - Comité des fêtes de Beaupont',
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the message content definition.
|
||||
*/
|
||||
public function content(): Content
|
||||
{
|
||||
return new Content(
|
||||
view: 'mails.createUserByAdmin',
|
||||
with: [
|
||||
'name' => $this->data['name'],
|
||||
'lastname' => $this->data['lastname'],
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the attachments for the message.
|
||||
*
|
||||
* @return array<int, \Illuminate\Mail\Mailables\Attachment>
|
||||
*/
|
||||
public function attachments(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
|
||||
namespace App\Mail;
|
||||
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Mail\Mailable;
|
||||
use Illuminate\Mail\Mailables\Content;
|
||||
use Illuminate\Mail\Mailables\Envelope;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
class DeactivateAccountMail extends Mailable
|
||||
{
|
||||
use Queueable, SerializesModels;
|
||||
public $data;
|
||||
|
||||
/**
|
||||
* Create a new message instance.
|
||||
*/
|
||||
public function __construct($data)
|
||||
{
|
||||
$this->data = $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the message envelope.
|
||||
*/
|
||||
public function envelope(): Envelope
|
||||
{
|
||||
return new Envelope(
|
||||
subject: 'Compte désactivé - Comité des fêtes de Beaupont',
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the message content definition.
|
||||
*/
|
||||
public function content(): Content
|
||||
{
|
||||
return new Content(
|
||||
view: 'mails.deactivateAccount',
|
||||
with: [
|
||||
'name' => $this->data['name'],
|
||||
'lastname' => $this->data['lastname'],
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the attachments for the message.
|
||||
*
|
||||
* @return array<int, \Illuminate\Mail\Mailables\Attachment>
|
||||
*/
|
||||
public function attachments(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
|
||||
namespace App\Mail;
|
||||
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Mail\Mailable;
|
||||
use Illuminate\Mail\Mailables\Content;
|
||||
use Illuminate\Mail\Mailables\Envelope;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
class DeleteAccountMail extends Mailable
|
||||
{
|
||||
use Queueable, SerializesModels;
|
||||
public $data;
|
||||
|
||||
/**
|
||||
* Create a new message instance.
|
||||
*/
|
||||
public function __construct($data)
|
||||
{
|
||||
$this->data = $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the message envelope.
|
||||
*/
|
||||
public function envelope(): Envelope
|
||||
{
|
||||
return new Envelope(
|
||||
subject: 'Compte supprimé - Comité des fêtes de Beaupont',
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the message content definition.
|
||||
*/
|
||||
public function content(): Content
|
||||
{
|
||||
return new Content(
|
||||
view: 'mails.deleteAccount',
|
||||
with: [
|
||||
'name' => $this->data['name'],
|
||||
'lastname' => $this->data['lastname'],
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the attachments for the message.
|
||||
*
|
||||
* @return array<int, \Illuminate\Mail\Mailables\Attachment>
|
||||
*/
|
||||
public function attachments(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
|
||||
namespace App\Mail;
|
||||
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Mail\Mailable;
|
||||
use Illuminate\Mail\Mailables\Content;
|
||||
use Illuminate\Mail\Mailables\Envelope;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
class EmailChangeConfirmedMail extends Mailable
|
||||
{
|
||||
use Queueable, SerializesModels;
|
||||
public $data;
|
||||
|
||||
/**
|
||||
* Create a new message instance.
|
||||
*/
|
||||
public function __construct($data)
|
||||
{
|
||||
$this->data = $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the message envelope.
|
||||
*/
|
||||
public function envelope(): Envelope
|
||||
{
|
||||
return new Envelope(
|
||||
subject: "Validation de changement d'adresse mail - Comité des fêtes de Beaupont",
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the message content definition.
|
||||
*/
|
||||
public function content(): Content
|
||||
{
|
||||
return new Content(
|
||||
view: 'mails.emailChangeConfirmed',
|
||||
with: [
|
||||
'name' => $this->data['name'],
|
||||
'lastname' => $this->data['lastname'],
|
||||
'newEmail' => $this->data['newEmail'],
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the attachments for the message.
|
||||
*
|
||||
* @return array<int, \Illuminate\Mail\Mailables\Attachment>
|
||||
*/
|
||||
public function attachments(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
<?php
|
||||
|
||||
namespace App\Mail;
|
||||
|
||||
use App\Services\FormatDate;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Mail\Mailable;
|
||||
use Illuminate\Mail\Mailables\Content;
|
||||
use Illuminate\Mail\Mailables\Envelope;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
class EventParticipationCancelledMail extends Mailable
|
||||
{
|
||||
use Queueable, SerializesModels;
|
||||
public $data;
|
||||
|
||||
/**
|
||||
* Create a new message instance.
|
||||
*/
|
||||
public function __construct($data)
|
||||
{
|
||||
$this->data = $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the message envelope.
|
||||
*/
|
||||
public function envelope(): Envelope
|
||||
{
|
||||
return new Envelope(
|
||||
subject: 'Evénement supprimé - Comité des fêtes de Beaupont',
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the message content definition.
|
||||
*/
|
||||
public function content(): Content
|
||||
{
|
||||
return new Content(
|
||||
view: 'mails.eventParticipationCancelled',
|
||||
with: [
|
||||
'name' => $this->data['name'],
|
||||
'lastname' => $this->data['lastname'],
|
||||
'eventName' => $this->data['eventName'],
|
||||
'start' => FormatDate::formatDate($this->data['start']),
|
||||
'end' => FormatDate::formatDate($this->data['end']),
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the attachments for the message.
|
||||
*
|
||||
* @return array<int, \Illuminate\Mail\Mailables\Attachment>
|
||||
*/
|
||||
public function attachments(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
|
||||
namespace App\Mail;
|
||||
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Mail\Mailable;
|
||||
use Illuminate\Mail\Mailables\Content;
|
||||
use Illuminate\Mail\Mailables\Envelope;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
class NotifyEmailChangeMail extends Mailable
|
||||
{
|
||||
use Queueable, SerializesModels;
|
||||
public $data;
|
||||
|
||||
/**
|
||||
* Create a new message instance.
|
||||
*/
|
||||
public function __construct($data)
|
||||
{
|
||||
$this->data = $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the message envelope.
|
||||
*/
|
||||
public function envelope(): Envelope
|
||||
{
|
||||
return new Envelope(
|
||||
subject: "Demande de changement d'adresse mail - Comité des fêtes de Beaupont",
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the message content definition.
|
||||
*/
|
||||
public function content(): Content
|
||||
{
|
||||
return new Content(
|
||||
view: 'mails.notifyEmailChange',
|
||||
with: [
|
||||
'name' => $this->data['name'],
|
||||
'lastname' => $this->data['lastname'],
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the attachments for the message.
|
||||
*
|
||||
* @return array<int, \Illuminate\Mail\Mailables\Attachment>
|
||||
*/
|
||||
public function attachments(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
|
||||
namespace App\Mail;
|
||||
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Mail\Mailable;
|
||||
use Illuminate\Mail\Mailables\Content;
|
||||
use Illuminate\Mail\Mailables\Envelope;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
class RegisterMail extends Mailable
|
||||
{
|
||||
use Queueable, SerializesModels;
|
||||
public $data;
|
||||
|
||||
/**
|
||||
* Create a new message instance.
|
||||
*/
|
||||
public function __construct($data)
|
||||
{
|
||||
$this->data = $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the message envelope.
|
||||
*/
|
||||
public function envelope(): Envelope
|
||||
{
|
||||
return new Envelope(
|
||||
subject: 'Nouvelle demande de validation - Comité des fêtes de Beaupont',
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the message content definition.
|
||||
*/
|
||||
public function content(): Content
|
||||
{
|
||||
return new Content(
|
||||
view: 'mails.register',
|
||||
with: [
|
||||
'adminName' => $this->data['adminName'],
|
||||
'adminLastname' => $this->data['adminLastname'],
|
||||
'userName' => $this->data['userName'],
|
||||
'userLastname' => $this->data['userLastname'],
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the attachments for the message.
|
||||
*
|
||||
* @return array<int, \Illuminate\Mail\Mailables\Attachment>
|
||||
*/
|
||||
public function attachments(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
|
||||
namespace App\Mail;
|
||||
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Mail\Mailable;
|
||||
use Illuminate\Mail\Mailables\Content;
|
||||
use Illuminate\Mail\Mailables\Envelope;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
class RequestEmailChangeMail extends Mailable
|
||||
{
|
||||
use Queueable, SerializesModels;
|
||||
public $data;
|
||||
|
||||
/**
|
||||
* Create a new message instance.
|
||||
*/
|
||||
public function __construct($data)
|
||||
{
|
||||
$this->data = $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the message envelope.
|
||||
*/
|
||||
public function envelope(): Envelope
|
||||
{
|
||||
return new Envelope(
|
||||
subject: "Demande de changement d'adresse mail - Comité des fêtes de Beaupont",
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the message content definition.
|
||||
*/
|
||||
public function content(): Content
|
||||
{
|
||||
return new Content(
|
||||
view: 'mails.requestEmailChange',
|
||||
with: [
|
||||
'name' => $this->data['name'],
|
||||
'lastname' => $this->data['lastname'],
|
||||
'token' => $this->data['token'],
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the attachments for the message.
|
||||
*
|
||||
* @return array<int, \Illuminate\Mail\Mailables\Attachment>
|
||||
*/
|
||||
public function attachments(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
<?php
|
||||
|
||||
namespace App\Mail;
|
||||
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Mail\Mailable;
|
||||
use Illuminate\Mail\Mailables\Content;
|
||||
use Illuminate\Mail\Mailables\Envelope;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
class TaskDateUpdateMail extends Mailable
|
||||
{
|
||||
use Queueable, SerializesModels;
|
||||
public $data;
|
||||
|
||||
/**
|
||||
* Create a new message instance.
|
||||
*/
|
||||
public function __construct($data)
|
||||
{
|
||||
$this->data = $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the message envelope.
|
||||
*/
|
||||
public function envelope(): Envelope
|
||||
{
|
||||
return new Envelope(
|
||||
subject: 'Date de tâche modifiée - Comité des fêtes de Beaupont',
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the message content definition.
|
||||
*/
|
||||
public function content(): Content
|
||||
{
|
||||
return new Content(
|
||||
view: 'mails.updateRole',
|
||||
with: [
|
||||
'name' => $this->data['name'],
|
||||
'lastname' => $this->data['lastname'],
|
||||
'taskName' => $this->data['taskName'],
|
||||
'oldStart' => $this->data['oldStart'],
|
||||
'oldEnd' => $this->data['oldEnd'],
|
||||
'newStart' => $this->data['newStart'],
|
||||
'newEnd' => $this->data['newEnd'],
|
||||
'eventName' => $this->data['eventName'],
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the attachments for the message.
|
||||
*
|
||||
* @return array<int, \Illuminate\Mail\Mailables\Attachment>
|
||||
*/
|
||||
public function attachments(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
<?php
|
||||
|
||||
namespace App\Mail;
|
||||
|
||||
use App\Services\FormatDate;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Mail\Mailable;
|
||||
use Illuminate\Mail\Mailables\Content;
|
||||
use Illuminate\Mail\Mailables\Envelope;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
class TaskParticipationCancelledMail extends Mailable
|
||||
{
|
||||
use Queueable, SerializesModels;
|
||||
public $data;
|
||||
|
||||
/**
|
||||
* Create a new message instance.
|
||||
*/
|
||||
public function __construct($data)
|
||||
{
|
||||
$this->data = $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the message envelope.
|
||||
*/
|
||||
public function envelope(): Envelope
|
||||
{
|
||||
return new Envelope(
|
||||
subject: 'Tâche supprimée - Comité des fêtes de Beaupont',
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the message content definition.
|
||||
*/
|
||||
public function content(): Content
|
||||
{
|
||||
return new Content(
|
||||
view: 'mails.taskParticipationCancelled',
|
||||
with: [
|
||||
'name' => $this->data['name'],
|
||||
'lastname' => $this->data['lastname'],
|
||||
'taskName' => $this->data['taskName'],
|
||||
'end' => FormatDate::formatDate($this->data['end']),
|
||||
'start' => FormatDate::formatDate($this->data['start']),
|
||||
'eventName' => $this->data['eventName'],
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the attachments for the message.
|
||||
*
|
||||
* @return array<int, \Illuminate\Mail\Mailables\Attachment>
|
||||
*/
|
||||
public function attachments(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
|
||||
namespace App\Mail;
|
||||
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Mail\Mailable;
|
||||
use Illuminate\Mail\Mailables\Content;
|
||||
use Illuminate\Mail\Mailables\Envelope;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
class UpdatePasswordMail extends Mailable
|
||||
{
|
||||
use Queueable, SerializesModels;
|
||||
public $data;
|
||||
|
||||
/**
|
||||
* Create a new message instance.
|
||||
*/
|
||||
public function __construct($data)
|
||||
{
|
||||
$this->data = $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the message envelope.
|
||||
*/
|
||||
public function envelope(): Envelope
|
||||
{
|
||||
return new Envelope(
|
||||
subject: 'Mot de passe mis à jour - Comité des fêtes de Beaupont',
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the message content definition.
|
||||
*/
|
||||
public function content(): Content
|
||||
{
|
||||
return new Content(
|
||||
view: 'mails.updatePassword',
|
||||
with: [
|
||||
'name' => $this->data['name'],
|
||||
'lastname' => $this->data['lastname'],
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the attachments for the message.
|
||||
*
|
||||
* @return array<int, \Illuminate\Mail\Mailables\Attachment>
|
||||
*/
|
||||
public function attachments(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
|
||||
namespace App\Mail;
|
||||
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Mail\Mailable;
|
||||
use Illuminate\Mail\Mailables\Content;
|
||||
use Illuminate\Mail\Mailables\Envelope;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
class UpdateRoleMail extends Mailable
|
||||
{
|
||||
use Queueable, SerializesModels;
|
||||
public $data;
|
||||
|
||||
/**
|
||||
* Create a new message instance.
|
||||
*/
|
||||
public function __construct($data)
|
||||
{
|
||||
$this->data = $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the message envelope.
|
||||
*/
|
||||
public function envelope(): Envelope
|
||||
{
|
||||
return new Envelope(
|
||||
subject: 'Rôle mis à jour - Comité des fêtes de Beaupont',
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the message content definition.
|
||||
*/
|
||||
public function content(): Content
|
||||
{
|
||||
return new Content(
|
||||
view: 'mails.updateRole',
|
||||
with: [
|
||||
'name' => $this->data['name'],
|
||||
'lastname' => $this->data['lastname'],
|
||||
'role' => $this->data['role'],
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the attachments for the message.
|
||||
*
|
||||
* @return array<int, \Illuminate\Mail\Mailables\Attachment>
|
||||
*/
|
||||
public function attachments(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
|
||||
namespace App\Mail;
|
||||
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Mail\Mailable;
|
||||
use Illuminate\Mail\Mailables\Content;
|
||||
use Illuminate\Mail\Mailables\Envelope;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
class ValidateMail extends Mailable
|
||||
{
|
||||
use Queueable, SerializesModels;
|
||||
public $data;
|
||||
|
||||
/**
|
||||
* Create a new message instance.
|
||||
*/
|
||||
public function __construct($data)
|
||||
{
|
||||
$this->data = $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the message envelope.
|
||||
*/
|
||||
public function envelope(): Envelope
|
||||
{
|
||||
return new Envelope(
|
||||
subject: 'Compte validé - Comité des fêtes de Beaupont',
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the message content definition.
|
||||
*/
|
||||
public function content(): Content
|
||||
{
|
||||
return new Content(
|
||||
view: 'mails.validate',
|
||||
with: [
|
||||
'name' => $this->data['name'],
|
||||
'lastname' => $this->data['lastname'],
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the attachments for the message.
|
||||
*
|
||||
* @return array<int, \Illuminate\Mail\Mailables\Attachment>
|
||||
*/
|
||||
public function attachments(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
<?php
|
||||
|
||||
namespace App\Mail;
|
||||
|
||||
use App\Services\FormatDate;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Mail\Mailable;
|
||||
use Illuminate\Mail\Mailables\Content;
|
||||
use Illuminate\Mail\Mailables\Envelope;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
class VolunteerAssignToTaskMail extends Mailable
|
||||
{
|
||||
use Queueable, SerializesModels;
|
||||
public $data;
|
||||
|
||||
/**
|
||||
* Create a new message instance.
|
||||
*/
|
||||
public function __construct($data)
|
||||
{
|
||||
$this->data = $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the message envelope.
|
||||
*/
|
||||
public function envelope(): Envelope
|
||||
{
|
||||
return new Envelope(
|
||||
subject: 'Assignation - Comité des fêtes de Beaupont',
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the message content definition.
|
||||
*/
|
||||
public function content(): Content
|
||||
{
|
||||
return new Content(
|
||||
view: 'mails.volunteerAssignToTask',
|
||||
with: [
|
||||
'name' => $this->data['name'],
|
||||
'lastname' => $this->data['lastname'],
|
||||
'taskName' => $this->data['taskName'],
|
||||
'start' => FormatDate::formatDate($this->data['start']),
|
||||
'end' => FormatDate::formatDate($this->data['end']),
|
||||
'eventName' => $this->data['eventName'],
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the attachments for the message.
|
||||
*
|
||||
* @return array<int, \Illuminate\Mail\Mailables\Attachment>
|
||||
*/
|
||||
public function attachments(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
<?php
|
||||
|
||||
namespace App\Mail;
|
||||
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Mail\Mailable;
|
||||
use Illuminate\Mail\Mailables\Content;
|
||||
use Illuminate\Mail\Mailables\Envelope;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use App\Services\FormatDate;
|
||||
|
||||
class VolunteerUnassignToTaskMail extends Mailable
|
||||
{
|
||||
use Queueable, SerializesModels;
|
||||
public $data;
|
||||
|
||||
/**
|
||||
* Create a new message instance.
|
||||
*/
|
||||
public function __construct($data)
|
||||
{
|
||||
$this->data = $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the message envelope.
|
||||
*/
|
||||
public function envelope(): Envelope
|
||||
{
|
||||
return new Envelope(
|
||||
subject: 'Désassignation - Comité des fêtes de Beaupont',
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the message content definition.
|
||||
*/
|
||||
public function content(): Content
|
||||
{
|
||||
return new Content(
|
||||
view: 'mails.volunteerUnassignToTask',
|
||||
with: [
|
||||
'name' => $this->data['name'],
|
||||
'lastname' => $this->data['lastname'],
|
||||
'taskName' => $this->data['taskName'],
|
||||
'start' => FormatDate::formatDate($this->data['start']),
|
||||
'end' => FormatDate::formatDate($this->data['end']),
|
||||
'eventName' => $this->data['eventName'],
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the attachments for the message.
|
||||
*
|
||||
* @return array<int, \Illuminate\Mail\Mailables\Attachment>
|
||||
*/
|
||||
public function attachments(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Event extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
protected $fillable = [
|
||||
"name",
|
||||
"description",
|
||||
"event_photo_path",
|
||||
'start',
|
||||
'end',
|
||||
];
|
||||
|
||||
public function tasks() {
|
||||
return $this->hasMany(Task::class, 'events_id');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Task extends Model
|
||||
{
|
||||
protected $fillable = [
|
||||
'name',
|
||||
'start',
|
||||
'end',
|
||||
'location',
|
||||
'description',
|
||||
'max_participants',
|
||||
];
|
||||
|
||||
public function event() {
|
||||
return $this->belongsTo(Event::class);
|
||||
}
|
||||
|
||||
public function users() {
|
||||
return $this->belongsToMany(User::class);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
// use Illuminate\Contracts\Auth\MustVerifyEmail;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||
use Illuminate\Notifications\Notifiable;
|
||||
|
||||
class User extends Authenticatable
|
||||
{
|
||||
/** @use HasFactory<\Database\Factories\UserFactory> */
|
||||
use HasFactory, Notifiable;
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*
|
||||
* @var list<string>
|
||||
*/
|
||||
protected $fillable = [
|
||||
'name',
|
||||
'lastname',
|
||||
'email',
|
||||
'password',
|
||||
'phone',
|
||||
'validate',
|
||||
'role',
|
||||
'verified_at',
|
||||
'profile_photo_path',
|
||||
'email_notifications',
|
||||
'web_notifications'
|
||||
];
|
||||
|
||||
/**
|
||||
* The attributes that should be hidden for serialization.
|
||||
*
|
||||
* @var list<string>
|
||||
*/
|
||||
protected $hidden = [
|
||||
'password',
|
||||
'remember_token',
|
||||
];
|
||||
|
||||
/**
|
||||
* Get the attributes that should be cast.
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'email_verified_at' => 'datetime',
|
||||
'password' => 'hashed',
|
||||
];
|
||||
}
|
||||
|
||||
public function tasks() {
|
||||
return $this->belongsToMany(Task::class);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
namespace App\Notifications;
|
||||
|
||||
use App\Mail\EventParticipationCancelledMail;
|
||||
use App\Models\Event;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Notifications\Notification;
|
||||
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
|
||||
use Illuminate\Notifications\Messages\BroadcastMessage;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
|
||||
class EventDeleted extends Notification implements ShouldBroadcast
|
||||
{
|
||||
use Queueable;
|
||||
|
||||
public function __construct(public Event $event) {}
|
||||
|
||||
public function via($notifiable): array
|
||||
{
|
||||
$channels = [];
|
||||
|
||||
if ($notifiable->web_notifications) {
|
||||
$channels[] = 'database';
|
||||
$channels[] = 'broadcast';
|
||||
}
|
||||
|
||||
return $channels;
|
||||
}
|
||||
|
||||
public function toDatabase($notifiable): array
|
||||
{
|
||||
return [
|
||||
'message' => "L'événement {$this->event->name} a été supprimé. Vous n'y participez donc plus.",
|
||||
'event_id' => $this->event->id,
|
||||
];
|
||||
}
|
||||
|
||||
public function toBroadcast($notifiable): BroadcastMessage
|
||||
{
|
||||
return new BroadcastMessage($this->toDatabase($notifiable));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
|
||||
namespace App\Notifications;
|
||||
|
||||
use App\Mail\TaskDateUpdateMail;
|
||||
use App\Models\Event;
|
||||
use App\Models\Task;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Notifications\Notification;
|
||||
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
|
||||
use Illuminate\Notifications\Messages\BroadcastMessage;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
|
||||
class TaskDateUpdated extends Notification implements ShouldBroadcast
|
||||
{
|
||||
use Queueable;
|
||||
|
||||
public function __construct(
|
||||
public Task $task,
|
||||
public Event $event,
|
||||
public string $oldStart,
|
||||
public string $oldEnd,
|
||||
public string $newStart,
|
||||
public string $newEnd,
|
||||
) {}
|
||||
|
||||
public function via($notifiable): array
|
||||
{
|
||||
$channels = [];
|
||||
|
||||
if ($notifiable->web_notifications) {
|
||||
$channels[] = 'database';
|
||||
$channels[] = 'broadcast';
|
||||
}
|
||||
|
||||
return $channels;
|
||||
}
|
||||
|
||||
public function toDatabase($notifiable): array
|
||||
{
|
||||
return [
|
||||
'message' => "La date de la tâche {$this->task->name} de l'événement {$this->event->name} a été mise à jour. Cette tâche aura maintenant lieu du {$this->newStart} au {$this->newEnd}.",
|
||||
'task_id' => $this->task->id,
|
||||
'event_id' => $this->event->id,
|
||||
'old_start' => $this->oldStart,
|
||||
'old_end' => $this->oldEnd,
|
||||
'new_start' => $this->newStart,
|
||||
'new_end' => $this->newEnd,
|
||||
];
|
||||
}
|
||||
|
||||
public function toBroadcast($notifiable): BroadcastMessage
|
||||
{
|
||||
return new BroadcastMessage($this->toDatabase($notifiable));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
namespace App\Notifications;
|
||||
|
||||
use App\Mail\TaskParticipationCancelledMail;
|
||||
use App\Models\Event;
|
||||
use App\Models\Task;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Notifications\Notification;
|
||||
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
|
||||
use Illuminate\Notifications\Messages\BroadcastMessage;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
|
||||
class TaskDeleted extends Notification implements ShouldBroadcast
|
||||
{
|
||||
use Queueable;
|
||||
|
||||
public function __construct(
|
||||
public Task $task,
|
||||
public Event $event,
|
||||
) {}
|
||||
|
||||
public function via($notifiable): array
|
||||
{
|
||||
$channels = [];
|
||||
|
||||
if ($notifiable->web_notifications) {
|
||||
$channels[] = 'database';
|
||||
$channels[] = 'broadcast';
|
||||
}
|
||||
|
||||
return $channels;
|
||||
}
|
||||
|
||||
public function toDatabase($notifiable): array
|
||||
{
|
||||
return [
|
||||
'message' => "La tâche {$this->task->name} pour l'événement {$this->event->name} a été supprimée. Vous n'y participez donc plus.",
|
||||
'task_id' => $this->task->id,
|
||||
'event_id' => $this->event->id,
|
||||
];
|
||||
}
|
||||
|
||||
public function toBroadcast($notifiable): BroadcastMessage
|
||||
{
|
||||
return new BroadcastMessage($this->toDatabase($notifiable));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
namespace App\Notifications;
|
||||
|
||||
use App\Models\User;
|
||||
use App\Mail\RegisterMail;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Notifications\Notification;
|
||||
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
|
||||
use Illuminate\Notifications\Messages\BroadcastMessage;
|
||||
use Illuminate\Notifications\Messages\MailMessage;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
|
||||
class UserRegistered extends Notification implements ShouldBroadcast
|
||||
{
|
||||
use Queueable;
|
||||
|
||||
public function __construct(public User $user) {}
|
||||
|
||||
public function via($notifiable): array
|
||||
{
|
||||
$channels = [];
|
||||
|
||||
if ($notifiable->web_notifications) {
|
||||
$channels[] = 'database';
|
||||
$channels[] = 'broadcast';
|
||||
}
|
||||
|
||||
return $channels;
|
||||
}
|
||||
|
||||
public function toDatabase($notifiable): array
|
||||
{
|
||||
return [
|
||||
'message' => "Nouvelle demande d'inscription : {$this->user->name} {$this->user->lastname}",
|
||||
'user_id' => $this->user->id,
|
||||
];
|
||||
}
|
||||
|
||||
public function toBroadcast($notifiable): BroadcastMessage
|
||||
{
|
||||
return new BroadcastMessage($this->toDatabase($notifiable));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
namespace App\Notifications;
|
||||
|
||||
use App\Mail\VolunteerAssignToTaskMail;
|
||||
use App\Models\Event;
|
||||
use App\Models\Task;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Notifications\Notification;
|
||||
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
|
||||
use Illuminate\Notifications\Messages\BroadcastMessage;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
|
||||
class VolunteerAssignedToTask extends Notification implements ShouldBroadcast
|
||||
{
|
||||
use Queueable;
|
||||
|
||||
public function __construct(
|
||||
public Task $task,
|
||||
public Event $event,
|
||||
) {}
|
||||
|
||||
public function via($notifiable): array
|
||||
{
|
||||
$channels = [];
|
||||
|
||||
if ($notifiable->web_notifications) {
|
||||
$channels[] = 'database';
|
||||
$channels[] = 'broadcast';
|
||||
}
|
||||
|
||||
return $channels;
|
||||
}
|
||||
|
||||
public function toDatabase($notifiable): array
|
||||
{
|
||||
return [
|
||||
'message' => "Vous avez été assigné à la tâche {$this->task->name} de l'événement {$this->event->name}.",
|
||||
'task_id' => $this->task->id,
|
||||
'event_id' => $this->event->id,
|
||||
];
|
||||
}
|
||||
|
||||
public function toBroadcast($notifiable): BroadcastMessage
|
||||
{
|
||||
return new BroadcastMessage($this->toDatabase($notifiable));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
namespace App\Notifications;
|
||||
|
||||
use App\Mail\UpdateRoleMail;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Notifications\Notification;
|
||||
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
|
||||
use Illuminate\Notifications\Messages\BroadcastMessage;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
|
||||
class VolunteerRoleUpdated extends Notification implements ShouldBroadcast
|
||||
{
|
||||
use Queueable;
|
||||
|
||||
public function __construct(public string $role) {}
|
||||
|
||||
public function via($notifiable): array
|
||||
{
|
||||
$channels = [];
|
||||
|
||||
if ($notifiable->web_notifications) {
|
||||
$channels[] = 'database';
|
||||
$channels[] = 'broadcast';
|
||||
}
|
||||
|
||||
return $channels;
|
||||
}
|
||||
|
||||
public function toDatabase($notifiable): array
|
||||
{
|
||||
return [
|
||||
'message' => "Votre rôle a changé pour : {$this->role}",
|
||||
'role' => $this->role,
|
||||
];
|
||||
}
|
||||
|
||||
public function toBroadcast($notifiable): BroadcastMessage
|
||||
{
|
||||
return new BroadcastMessage($this->toDatabase($notifiable));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
namespace App\Notifications;
|
||||
|
||||
use App\Mail\VolunteerUnassignToTaskMail;
|
||||
use App\Models\Event;
|
||||
use App\Models\Task;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Notifications\Notification;
|
||||
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
|
||||
use Illuminate\Notifications\Messages\BroadcastMessage;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
|
||||
class VolunteerUnassignedFromTask extends Notification implements ShouldBroadcast
|
||||
{
|
||||
use Queueable;
|
||||
|
||||
public function __construct(
|
||||
public Task $task,
|
||||
public Event $event,
|
||||
) {}
|
||||
|
||||
public function via($notifiable): array
|
||||
{
|
||||
$channels = [];
|
||||
|
||||
if ($notifiable->web_notifications) {
|
||||
$channels[] = 'database';
|
||||
$channels[] = 'broadcast';
|
||||
}
|
||||
|
||||
return $channels;
|
||||
}
|
||||
|
||||
public function toDatabase($notifiable): array
|
||||
{
|
||||
return [
|
||||
'message' => "Vous avez été désassigné de la tâche {$this->task->name} de l'événement {$this->event->name}.",
|
||||
'task_id' => $this->task->id,
|
||||
'event_id' => $this->event->id,
|
||||
];
|
||||
}
|
||||
|
||||
public function toBroadcast($notifiable): BroadcastMessage
|
||||
{
|
||||
return new BroadcastMessage($this->toDatabase($notifiable));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace App\Observers;
|
||||
|
||||
use App\Models\Event;
|
||||
use App\Services\TypesenseService;
|
||||
|
||||
class EventObserver
|
||||
{
|
||||
public function created(Event $event)
|
||||
{
|
||||
app(TypesenseService::class)->upsertEvent($event);
|
||||
}
|
||||
|
||||
public function updated(Event $event)
|
||||
{
|
||||
app(TypesenseService::class)->upsertEvent($event);
|
||||
}
|
||||
|
||||
public function deleted(Event $event)
|
||||
{
|
||||
app(TypesenseService::class)->deleteEvent($event->id);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace App\Observers;
|
||||
|
||||
use App\Models\User;
|
||||
use App\Services\TypesenseService;
|
||||
|
||||
class UserObserver
|
||||
{
|
||||
public function created(User $user)
|
||||
{
|
||||
app(TypesenseService::class)->upsertUser($user);
|
||||
}
|
||||
|
||||
public function updated(User $user)
|
||||
{
|
||||
app(TypesenseService::class)->upsertUser($user);
|
||||
}
|
||||
|
||||
public function deleted(User $user)
|
||||
{
|
||||
app(TypesenseService::class)->deleteUser($user->id);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace App\Policies;
|
||||
|
||||
use App\Models\Event;
|
||||
use App\Models\User;
|
||||
use Illuminate\Auth\Access\Response;
|
||||
|
||||
class EventsPolicy
|
||||
{
|
||||
public function create(User $user): bool
|
||||
{
|
||||
return $user->role === 1 || $user->role === 2;
|
||||
}
|
||||
|
||||
public function update(User $user): bool
|
||||
{
|
||||
return $user->role === 1 || $user->role === 2;
|
||||
}
|
||||
|
||||
public function delete(User $user): bool
|
||||
{
|
||||
return $user->role === 1 || $user->role === 2;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
namespace App\Policies;
|
||||
|
||||
use App\Models\Task;
|
||||
use App\Models\User;
|
||||
use Illuminate\Auth\Access\Response;
|
||||
|
||||
class TasksPolicy
|
||||
{
|
||||
public function create(User $user): bool
|
||||
{
|
||||
return $user->role === 1 || $user->role === 2;
|
||||
}
|
||||
|
||||
public function assignOther(User $user): bool
|
||||
{
|
||||
return $user->role === 1 || $user->role === 2;
|
||||
}
|
||||
|
||||
public function unassignOther(User $user): bool
|
||||
{
|
||||
return $user->role === 1 || $user->role === 2;
|
||||
}
|
||||
|
||||
public function delete(User $user): bool
|
||||
{
|
||||
return $user->role === 1 || $user->role === 2;
|
||||
}
|
||||
|
||||
public function update(User $user): bool
|
||||
{
|
||||
return $user->role === 1 || $user->role === 2;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace App\Policies;
|
||||
|
||||
use App\Models\User;
|
||||
use Illuminate\Auth\Access\Response;
|
||||
|
||||
class UsersPolicy
|
||||
{
|
||||
public function deleteOther(User $user): bool
|
||||
{
|
||||
return $user->role === 1 || $user->role === 2;
|
||||
}
|
||||
|
||||
public function createOther(User $user): bool {
|
||||
return $user->role === 1 || $user->role === 2;
|
||||
}
|
||||
|
||||
public function deactivate(User $user, User $userToDeactivate): bool
|
||||
{
|
||||
return in_array($user->role, [1, 2])
|
||||
&& $user->role < $userToDeactivate->role
|
||||
&& $user->id !== $userToDeactivate->id;
|
||||
}
|
||||
|
||||
public function validate(User $user): bool
|
||||
{
|
||||
return $user->role === 1 || $user->role === 2;
|
||||
}
|
||||
|
||||
public function addRole(User $user): bool
|
||||
{
|
||||
return $user->role === 1;
|
||||
}
|
||||
|
||||
public function getInvalidUsers(User $user) : bool
|
||||
{
|
||||
return $user->role === 1 || $user->role === 2;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
namespace App\Providers;
|
||||
|
||||
use App\Models\Event;
|
||||
use App\Models\User;
|
||||
use App\Observers\EventObserver;
|
||||
use App\Observers\UserObserver;
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
use Illuminate\Support\Facades\Route;
|
||||
|
||||
class AppServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* Register any application services.
|
||||
*/
|
||||
public function register(): void
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Bootstrap any application services.
|
||||
*/
|
||||
public function boot(): void
|
||||
{
|
||||
Route::middleware('web')->prefix('api')->group(base_path('routes/users.php'));
|
||||
Route::middleware('web')->prefix('api')->group(base_path('routes/auth.php'));
|
||||
Route::middleware('web')->prefix('api')->group(base_path('routes/events.php'));
|
||||
Route::middleware('web')->prefix('api')->group(base_path('routes/notifications.php'));
|
||||
Route::middleware('web')->prefix('api')->group(base_path('routes/channels.php'));
|
||||
User::observe(UserObserver::class);
|
||||
Event::observe(EventObserver::class);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
namespace App\Providers;
|
||||
|
||||
use Illuminate\Support\Facades\Broadcast;
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
|
||||
class BroadcastServiceProvider extends ServiceProvider
|
||||
{
|
||||
public function boot(): void
|
||||
{
|
||||
Broadcast::routes(['middleware' => ['web', 'auth:sanctum']]);
|
||||
|
||||
require base_path('routes/channels.php');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace App\Providers;
|
||||
|
||||
use App\Models\Event;
|
||||
use App\Models\Task;
|
||||
use App\Models\User;
|
||||
use App\Policies\EventsPolicy;
|
||||
use App\Policies\TasksPolicy;
|
||||
use App\Policies\UsersPolicy;
|
||||
use Illuminate\Support\Facades\Gate;
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
|
||||
class GateServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* Register services.
|
||||
*/
|
||||
public function register(): void
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Bootstrap services.
|
||||
*/
|
||||
public function boot(): void
|
||||
{
|
||||
Gate::policy(User::class, UsersPolicy::class);
|
||||
Gate::policy(Event::class, EventsPolicy::class);
|
||||
Gate::policy(Task::class, TasksPolicy::class);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace App\Services;
|
||||
|
||||
use Carbon\Carbon;
|
||||
|
||||
class FormatDate
|
||||
{
|
||||
public static function formatDate($date){
|
||||
return Carbon::parse($date)->format('d/m/Y, H:i');
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace App\Services;
|
||||
|
||||
class GetRole
|
||||
{
|
||||
public static function getRole($role)
|
||||
{
|
||||
$role = (int)$role;
|
||||
return match ($role) {
|
||||
1 => "Président",
|
||||
2 => "Gérant",
|
||||
3 => "Bénévole",
|
||||
default => "Utilisateur",
|
||||
};
|
||||
}
|
||||
|
||||
public static function GetAllRoles() {
|
||||
return [
|
||||
"Président",
|
||||
"Gérant",
|
||||
"Bénévole"
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,141 @@
|
||||
<?php
|
||||
|
||||
namespace App\Services;
|
||||
|
||||
use App\Models\User;
|
||||
use App\Models\Event;
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
use Typesense\Client;
|
||||
|
||||
class TypesenseService
|
||||
{
|
||||
protected Client $client;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->client = new Client([
|
||||
'api_key' => config('app.typesense_api_key'),
|
||||
'nodes' => [
|
||||
[
|
||||
'host' => config('app.typesense_connection'),
|
||||
'port' => '8108',
|
||||
'protocol' => 'http',
|
||||
],
|
||||
],
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
private function ensureCollectionsExist(): void
|
||||
{
|
||||
static $checked = false;
|
||||
|
||||
if ($checked) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
$collections = $this->client->collections->retrieve();
|
||||
$names = array_column($collections, 'name');
|
||||
|
||||
if (!in_array('events', $names)) {
|
||||
$this->client->collections->create([
|
||||
'name' => 'events',
|
||||
'fields' => [
|
||||
['name' => 'name', 'type' => 'string'],
|
||||
['name' => 'description', 'type' => 'string'],
|
||||
],
|
||||
]);
|
||||
}
|
||||
|
||||
if (!in_array('users', $names)) {
|
||||
$this->client->collections->create([
|
||||
'name' => 'users',
|
||||
'fields' => [
|
||||
['name' => 'name', 'type' => 'string'],
|
||||
['name' => 'lastname', 'type' => 'string'],
|
||||
['name' => 'validate', 'type' => 'bool'],
|
||||
],
|
||||
]);
|
||||
}
|
||||
|
||||
$checked = true;
|
||||
} catch (\Throwable $e) {
|
||||
report($e);
|
||||
}
|
||||
}
|
||||
|
||||
public function upsertEvent(Event $event): void
|
||||
{
|
||||
$this->ensureCollectionsExist();
|
||||
|
||||
try {
|
||||
$this->client->collections['events']
|
||||
->documents
|
||||
->upsert([
|
||||
'id' => (string) $event->id,
|
||||
'name' => $event->name,
|
||||
'description' => $event->description,
|
||||
]);
|
||||
} catch (\Throwable $e) {
|
||||
report($e);
|
||||
}
|
||||
}
|
||||
|
||||
public function deleteEvent(int $eventId): void
|
||||
{
|
||||
$this->ensureCollectionsExist();
|
||||
|
||||
try {
|
||||
$this->client->collections['events']
|
||||
->documents[(string) $eventId]
|
||||
->delete();
|
||||
} catch (\Throwable $e) {
|
||||
report($e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function upsertUser(User $user): void
|
||||
{
|
||||
$this->ensureCollectionsExist();
|
||||
|
||||
if (!$user->validate) {
|
||||
try {
|
||||
$this->client->collections['users']
|
||||
->documents[(string) $user->id]
|
||||
->retrieve();
|
||||
|
||||
$this->deleteUser($user->id);
|
||||
} catch (\Throwable $e) {
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
$this->client->collections['users']
|
||||
->documents
|
||||
->upsert([
|
||||
'id' => (string) $user->id,
|
||||
'name' => $user->name,
|
||||
'lastname' => $user->lastname,
|
||||
'validate' => true,
|
||||
]);
|
||||
} catch (\Throwable $e) {
|
||||
report($e);
|
||||
}
|
||||
}
|
||||
|
||||
public function deleteUser(int $userId): void
|
||||
{
|
||||
$this->ensureCollectionsExist();
|
||||
|
||||
try {
|
||||
$this->client->collections['users']
|
||||
->documents[(string) $userId]
|
||||
->delete();
|
||||
} catch (\Throwable $e) {
|
||||
report($e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace App\Services;
|
||||
use App\Models\User;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class UserService
|
||||
{
|
||||
public static function getData(int $id) : array {
|
||||
|
||||
$user = User::findOrFail($id);
|
||||
|
||||
return [
|
||||
"id" => $user->id,
|
||||
"name" => $user->name,
|
||||
"lastname" => $user->lastname,
|
||||
"email" => $user->email,
|
||||
"role" => GetRole::getRole($user->role),
|
||||
"isAdmin" => ($user->role === 1 || $user->role === 2),
|
||||
"phone" => $user->phone,
|
||||
"created_at" => $user->created_at,
|
||||
"updated_at" => $user->updated_at,
|
||||
"verfied_at" => $user->verfied_at,
|
||||
"validate" => $user->validate,
|
||||
"tasks" => $user->tasks,
|
||||
"profile_photo_path" => $user->profile_photo_path,
|
||||
"email_notifications" => $user->email_notifications,
|
||||
"web_notifications" => $user->web_notifications,
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
.env
|
||||
|
||||
# Logs
|
||||
logs
|
||||
*.log
|
||||
npm-debug.log*
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
||||
pnpm-debug.log*
|
||||
lerna-debug.log*
|
||||
|
||||
node_modules
|
||||
dist
|
||||
dist-ssr
|
||||
*.local
|
||||
|
||||
# Editor directories and files
|
||||
.vscode/*
|
||||
!.vscode/extensions.json
|
||||
../../.idea
|
||||
.DS_Store
|
||||
*.suo
|
||||
*.ntvs*
|
||||
*.njsproj
|
||||
*.sln
|
||||
*.sw?
|
||||
|
||||
*storybook.log
|
||||
storybook-static
|
||||
@@ -1,6 +1,6 @@
|
||||
import * as a11yAddonAnnotations from "@storybook/addon-a11y/preview";
|
||||
import { setProjectAnnotations } from '@storybook/react-vite';
|
||||
import * as projectAnnotations from './preview';
|
||||
import * as projectAnnotations from './preview.js';
|
||||
|
||||
// This is an important step to apply the right configuration when testing your stories.
|
||||
// More info at: https://storybook.js.org/docs/api/portable-stories/portable-stories-vitest#setprojectannotations
|
||||
@@ -8,6 +8,6 @@
|
||||
</head>
|
||||
<body>
|
||||
<div id="root"></div>
|
||||
<script type="module" src="/src/main.jsx"></script>
|
||||
<script type="module" src="/apps/frontend/srcs/frontend/src/main.jsx"></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,57 @@
|
||||
{
|
||||
"name": "sae-front",
|
||||
"private": true,
|
||||
"version": "0.0.0",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "vite",
|
||||
"build": "vite build",
|
||||
"lint": "eslint ../..",
|
||||
"preview": "vite preview",
|
||||
"storybook": "storybook dev -p 6006",
|
||||
"build-storybook": "storybook build",
|
||||
"test": "vitest"
|
||||
},
|
||||
"dependencies": {
|
||||
"@emotion/react": "^11.14.0",
|
||||
"@emotion/styled": "^11.14.1",
|
||||
"@floating-ui/react": "^0.27.16",
|
||||
"@mui/material": "^7.3.6",
|
||||
"bootstrap": "^5.3.8",
|
||||
"chart.js": "^4.5.1",
|
||||
"laravel-echo": "^2.2.7",
|
||||
"pusher-js": "^8.4.0",
|
||||
"react": "^19.1.1",
|
||||
"react-bootstrap": "^2.10.10",
|
||||
"react-chartjs-2": "^5.3.1",
|
||||
"react-dom": "^19.1.1",
|
||||
"react-router": "^7.9.4",
|
||||
"react-router-dom": "^7.10.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@chromatic-com/storybook": "^4.1.2",
|
||||
"@eslint/js": "^9.36.0",
|
||||
"@storybook/addon-a11y": "^10.0.6",
|
||||
"@storybook/addon-docs": "^10.0.6",
|
||||
"@storybook/addon-vitest": "^10.0.6",
|
||||
"@storybook/react-vite": "^10.0.6",
|
||||
"@types/node": "^25.0.10",
|
||||
"@types/react": "^19.2.10",
|
||||
"@types/react-dom": "^19.2.3",
|
||||
"@vitejs/plugin-react": "^5.0.4",
|
||||
"@vitest/browser-playwright": "^4.0.8",
|
||||
"@vitest/coverage-v8": "^4.0.8",
|
||||
"baseline-browser-mapping": "^2.9.7",
|
||||
"eslint": "^9.36.0",
|
||||
"eslint-plugin-react-hooks": "^5.2.0",
|
||||
"eslint-plugin-react-refresh": "^0.4.22",
|
||||
"eslint-plugin-storybook": "^10.0.6",
|
||||
"globals": "^16.4.0",
|
||||
"playwright": "^1.56.1",
|
||||
"prop-types": "^15.8.1",
|
||||
"storybook": "^10.0.6",
|
||||
"typescript": "^5.9.3",
|
||||
"vite": "^7.1.7",
|
||||
"vitest": "^4.0.8"
|
||||
}
|
||||
}
|
||||
|
Before Width: | Height: | Size: 578 B After Width: | Height: | Size: 578 B |
|
Before Width: | Height: | Size: 222 B After Width: | Height: | Size: 222 B |
|
Before Width: | Height: | Size: 79 KiB After Width: | Height: | Size: 79 KiB |
|
Before Width: | Height: | Size: 290 B After Width: | Height: | Size: 290 B |
|
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.1 KiB |
|
Before Width: | Height: | Size: 2.8 KiB After Width: | Height: | Size: 2.8 KiB |
|
Before Width: | Height: | Size: 4.3 KiB After Width: | Height: | Size: 4.3 KiB |
|
Before Width: | Height: | Size: 2.3 KiB After Width: | Height: | Size: 2.3 KiB |
|
Before Width: | Height: | Size: 1009 B After Width: | Height: | Size: 1009 B |
|
Before Width: | Height: | Size: 98 KiB After Width: | Height: | Size: 98 KiB |
|
Before Width: | Height: | Size: 50 KiB After Width: | Height: | Size: 50 KiB |
|
Before Width: | Height: | Size: 844 B After Width: | Height: | Size: 844 B |
|
Before Width: | Height: | Size: 4.0 KiB After Width: | Height: | Size: 4.0 KiB |
|
Before Width: | Height: | Size: 376 B After Width: | Height: | Size: 376 B |
|
Before Width: | Height: | Size: 320 B After Width: | Height: | Size: 320 B |
|
Before Width: | Height: | Size: 559 B After Width: | Height: | Size: 559 B |
|
Before Width: | Height: | Size: 475 B After Width: | Height: | Size: 475 B |
|
Before Width: | Height: | Size: 477 B After Width: | Height: | Size: 477 B |
|
Before Width: | Height: | Size: 1.5 KiB After Width: | Height: | Size: 1.5 KiB |
@@ -29,7 +29,9 @@ const Background = ({ children, className }: BackgroundProps) => {
|
||||
|
||||
useEffect(() => {
|
||||
const updateTheme = () => {
|
||||
setTheme(localStorage.getItem("theme") || "light");
|
||||
const t = localStorage.getItem("theme") || "light";
|
||||
setTheme(t);
|
||||
document.body.classList.toggle("dark", t === "dark");
|
||||
};
|
||||
|
||||
updateTheme();
|
||||
@@ -14,7 +14,11 @@
|
||||
position: relative;
|
||||
justify-content: space-between;
|
||||
}
|
||||
|
||||
.profileImg{
|
||||
width:40px;
|
||||
height:40px;
|
||||
border-radius: 50%;
|
||||
}
|
||||
|
||||
|
||||
.activeHeaderContent {
|
||||
@@ -12,6 +12,7 @@ import { AuthContext } from "../../contexts/Auth/AuthContext.js";
|
||||
import { PendingMembersContext } from "../../contexts/PendingMembers/PendingMembersContext";
|
||||
import Notification from "../../interfaces/notification.interface";
|
||||
|
||||
|
||||
function Header() {
|
||||
|
||||
const { update, user } = useContext(AuthContext)!;
|
||||
@@ -22,7 +23,9 @@ function Header() {
|
||||
const [mobileMenu, setMobileMenu] = useState<boolean>(false);
|
||||
const [notifications, setNotifications] = useState<Notification[]>([]);
|
||||
const notificationRef = useRef<HTMLDivElement>(null);
|
||||
|
||||
const profileImageUrl = user?.profile_photo_path
|
||||
? `${import.meta.env.VITE_API_URL}/storage/${user.profile_photo_path}`
|
||||
: "/person.svg";
|
||||
useEffect(() => {
|
||||
if (!user) return;
|
||||
|
||||
@@ -130,15 +133,21 @@ function Header() {
|
||||
<div className={styles.headerRightContent}>
|
||||
<button
|
||||
className={`${styles.bellBtn} ${notificationMenu ? styles.activeBellBtn : ""}`}
|
||||
onClick={() => {toggleNotificationMenu();}}
|
||||
onClick={() => { toggleNotificationMenu(); }}
|
||||
>
|
||||
<img className={styles.notificationsImg} src="/bell.svg" alt="notifications"/>
|
||||
<img className={styles.notificationsImg} src="/bell.svg" alt="notifications" />
|
||||
{unreadNotification && <span className={styles.notificationBadge}></span>}
|
||||
</button>
|
||||
|
||||
<Link to="/profile" className={styles.profileLink}>
|
||||
<img className={styles.profileImg} src="/person.svg" alt="profile"/>
|
||||
<img
|
||||
className={styles.profileImg}
|
||||
src={profileImageUrl}
|
||||
alt="profile"
|
||||
/>
|
||||
</Link>
|
||||
|
||||
|
||||
</div>
|
||||
</nav>
|
||||
|
||||