Skip to content

Commit

Permalink
Fix video feedback front feedback (#276)
Browse files Browse the repository at this point in the history
* Fix registration ngo, add ro lang for validation

* Fix load dashboard on front user

* fix project view

* Fix article on home page
  • Loading branch information
gheorghelupu17 authored Aug 29, 2023
1 parent 7bb618b commit ddc555f
Show file tree
Hide file tree
Showing 27 changed files with 1,411 additions and 64 deletions.
5 changes: 4 additions & 1 deletion app/Concerns/MustSetInitialPassword.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@ protected static function bootMustSetInitialPassword(): void

static::created(function (self $user) {
if (! app()->runningInConsole()) {
$user->sendWelcomeNotification();
if (!empty($user->created_by))
{
$user->sendWelcomeNotification();
}
}
});
}
Expand Down
5 changes: 5 additions & 0 deletions app/Filament/Resources/UserResource/Pages/CreateUser.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,9 @@ public function form(Form $form): Form

]);
}
protected function mutateFormDataBeforeCreate(array $data): array
{
$data['created_by'] = auth()->id();
return $data;
}
}
10 changes: 4 additions & 6 deletions app/Http/Controllers/Auth/AuthenticatedSessionController.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,10 @@ public function store(LoginRequest $request): RedirectResponse
$request->authenticate();

$request->session()->regenerate();

$redirect = RouteServiceProvider::ONG;
match ($request->get('from', '')) {
'championship-page' => $redirect = RouteServiceProvider::CHAMPIONSHIP,
'ong' => $redirect = RouteServiceProvider::ONG,
default => $redirect = RouteServiceProvider::HOME,
$redirect = RouteServiceProvider::HOME;
$redirect = match ($request->get('from', '')) {
'championship-page' => RouteServiceProvider::CHAMPIONSHIP,
default => $redirect ,
};

return redirect()->intended($redirect);
Expand Down
9 changes: 7 additions & 2 deletions app/Http/Controllers/Auth/RegisteredUserController.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Notification;
use Inertia\Inertia;
use Inertia\Response;
Expand Down Expand Up @@ -66,7 +67,10 @@ public function store(RegistrationRequest $request): RedirectResponse
$ong = $data['ong'];
$organization = Organization::create($ong);
$organization->addMediaFromRequest('ong.logo')->toMediaCollection('organizationFilesLogo');
$organization->addMediaFromRequest('ong.statute')->toMediaCollection('organizationFilesStatute');
if ($request->hasFile('ong.statute'))
{
$organization->addMediaFromRequest('ong.statute')->toMediaCollection('organizationFilesStatute');
}
$organization->activityDomains()->attach($ong['activity_domains_ids']);
$organization->counties()->attach($ong['counties_ids']);
$adminUsers = User::whereRole(UserRole::bb_admin)->get();
Expand All @@ -78,7 +82,8 @@ public function store(RegistrationRequest $request): RedirectResponse

return redirect()->route('register')->with('success_message', ['message' => 'Contul a fost creat', 'usrid' => $user['id']]);
} catch(\Throwable $th) {
return redirect()->back()->with('error_message', 'Contul nu a fost creat');
Log::log('error', $th->getMessage());
return redirect()->back()->with('error_message', __('auth.failed'));
}
}

Expand Down
39 changes: 39 additions & 0 deletions app/Http/Controllers/DashboardController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?php

namespace App\Http\Controllers;

use App\Http\Resources\PageResource;
use Illuminate\Http\RedirectResponse;
use Inertia\Inertia;
use Inertia\Response;

class DashboardController extends Controller
{
public function __invoke(): Response|RedirectResponse
{
if (auth()->user()->isNgoAdmin()) {
return redirect()->route('admin.ong.edit');
}
if (auth()->user()->isDonor()) {
$profile = [
'description' => '<p>Mulțumim că ești alături de noi. Prin participarea ta activă la această inițiativă, ne arăți că ești preocupat de problemele sociale și că vrei să faci o diferență pozitivă în lumea în care trăim, iar contribuția ta este extrem de valoroasă.</p>
<p>Prin distribuirea informațiilor despre proiectele de pe Bursa Binelui și încurajând prietenii și familia să se alăture, devii un promotor important al inițiativei noastre.</p>
<p>Fiecare pas pe care îl facem împreună contează și, împreună, putem face o diferență semnificativă.</p>',
'donations_place' => '5%',
'donations_status' => [
'Ai donat către mai mult de 5 organizații',
'Volunariezi la 3 organizații',
'Ești abonat la newsletterul de bine',
'Ai distribuit de multiple ori informații utile',
],
];

return Inertia::render('Donor/Dashboard', [
'profile' => $profile,
'badges' => auth()->user()->badges
->map(fn ($badge) => $badge->only('image', 'title', 'description')),
]);
}
abort(403, 'You are not authorized to access this page.');
}
}
31 changes: 2 additions & 29 deletions app/Http/Controllers/HomeController.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,42 +4,15 @@

namespace App\Http\Controllers;

use App\Models\Article;
use App\Models\Project;
use Inertia\Inertia;

class HomeController extends Controller
{
public function index()
{
$articles = [
[
'id' => 1,
'img' => '/images/project_img.png',
'author' => 'Ion Popescu',
'name' => 'Importanța educației remediare în România în timpul pandemiei',
'team' => 'Echipa BCR',
'content' => 'Lorem ipsum dolor sit amet consectetur adipisicing elit. Architecto accusantium praesentium eius, ut atque fuga culpa, similique sequi cum eos quis dolorum.',
'date' => '15.02.2022',
],
[
'id' => 2,
'img' => '/images/project_img.png',
'author' => 'Ion Popescu',
'name' => 'Importanța educației remediare în România în timpul pandemiei',
'team' => 'Echipa BCR',
'content' => 'Lorem ipsum dolor sit amet consectetur adipisicing elit. Architecto accusantium praesentium eius, ut atque fuga culpa, similique sequi cum eos quis dolorum.',
'date' => '15.02.2022',
],
[
'id' => 3,
'img' => '/images/project_img.png',
'author' => 'Ion Popescu',
'name' => 'Importanța educației remediare în România în timpul pandemiei',
'team' => 'Echipa BCR',
'content' => 'Lorem ipsum dolor sit amet consectetur adipisicing elit. Architecto accusantium praesentium eius, ut atque fuga culpa, similique sequi cum eos quis dolorum.',
'date' => '15.02.2022',
],
];
$articles = Article::latest()->take(3)->get();

$bcr_projects = Project::publish()->paginate(9)->withQueryString();
$donate_projects = Project::publish()->paginate(9)->withQueryString();
Expand Down
4 changes: 0 additions & 4 deletions app/Http/Controllers/ProjectController.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,6 @@ public function index(Request $request)

public function item(Project $project)
{
if ($project->status !== ProjectStatus::approved) {
$this->authorize('view', $project);
}

return Inertia::render('Public/Projects/Project', [
'project' => $project,
]);
Expand Down
17 changes: 12 additions & 5 deletions app/Http/Requests/RegistrationRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,20 +35,27 @@ public function rules(): array
$rules['ong'] = ['array', 'required'];
$rules['ong.name'] = ['string', 'required'];
$rules['ong.description'] = ['string', 'required'];
$rules['ong.logo'] = ['file', 'required'];
$rules['ong.statute'] = ['file', 'required'];
$rules['ong.logo'] = ['required', 'file'];
$rules['ong.statute'] = ['required', 'file'];
$rules['ong.street_address'] = ['string', 'required'];
$rules['ong.cif'] = ['string', 'required'];
$rules['ong.contact_email'] = ['email', 'required'];
$rules['ong.contact_email'] = ['required', 'email'];
$rules['ong.contact_phone'] = ['string', 'required'];
$rules['ong.contact_person'] = ['string', 'required'];
$rules['ong.activity_domains_ids'] = ['array', 'required'];
$rules['ong.counties_ids'] = ['array', 'required'];
$rules['ong.volunteer'] = ['boolean'];
$rules['ong.why_volunteer'] = ['string'];
$rules['ong.website'] = ['string'];
$rules['ong.why_volunteer'] = ['string','nullable'];
$rules['ong.website'] = ['string','nullable'];
}

return $rules;
}
public function messages(): array
{
return [
'ong.activity_domains_ids' => __('custom_validation.activity_domains_ids'),
'ong.counties_ids' => __('custom_validation.counties_ids'),
];
}
}
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
"doctrine/dbal": "^3.6",
"fakerphp/faker": "^1.9",
"friendsofphp/php-cs-fixer": "^3.23",
"laravel-lang/common": "^4.0",
"laravel/breeze": "^1.23",
"laravel/pint": "^1.11",
"laravel/sail": "^1.23",
Expand Down
Loading

0 comments on commit ddc555f

Please sign in to comment.