diff --git a/app/Http/Controllers/ProjectController.php b/app/Http/Controllers/ProjectController.php index b0af988b..2e03d470 100644 --- a/app/Http/Controllers/ProjectController.php +++ b/app/Http/Controllers/ProjectController.php @@ -12,6 +12,7 @@ use App\Http\Filters\ProjectStatusFilter; use App\Http\Filters\SearchFilter; use App\Http\Resources\Collections\ProjectCardCollection; +use App\Http\Resources\Project\ShowProjectResource; use App\Http\Sorts\ProjectDonationsCountSort; use App\Http\Sorts\ProjectDonationsSumSort; use App\Models\Project; @@ -70,9 +71,8 @@ protected function projectList(Request $request, string $view): Response public function show(Project $project) { // TODO: prevent display of unpublished projects - return Inertia::render('Public/Projects/Show', [ - 'project' => $project, + 'project' => new ShowProjectResource($project), ]); } diff --git a/app/Http/Resources/Project/ShowProjectResource.php b/app/Http/Resources/Project/ShowProjectResource.php index f6ba4ccd..31bdc6b4 100644 --- a/app/Http/Resources/Project/ShowProjectResource.php +++ b/app/Http/Resources/Project/ShowProjectResource.php @@ -15,10 +15,10 @@ public function toArray(Request $request): array { return [ 'id' => $this->id, - // 'type' => $this->type, 'name' => $this->name, 'slug' => $this->slug, 'counties' => $this->counties->pluck('name')->join(', '), + 'status' =>$this->visible_status, 'image' => $this->getFirstMediaUrl('preview'), 'target_budget' => $this->target_budget, 'gallery' => $this->getMedia('gallery')->map(function ($media) { @@ -43,6 +43,11 @@ public function toArray(Request $request): array 'videos' => '', 'external_links' => $this->external_links, 'categories' => $this->categories->pluck('name')->join(', '), + 'donations' => [ + 'target' => money_format($this->target_budget), + 'total' => money_format($this->total_donations), + 'percentage' => $this->percentage, + ], 'championship' => [ 'troffees_count' => 2, 'score' => 100, diff --git a/lang/ro.json b/lang/ro.json index 0e261b07..5c90f960 100644 --- a/lang/ro.json +++ b/lang/ro.json @@ -444,6 +444,12 @@ "navigation.volunteers": "Voluntari", "locales.ro": "Română", - "locales.en": "English" + "locales.en": "English", + "projects.status.open" : "Deschis", + "projects.status.close" : "Închis", + "projects.status.starting_soon" : "Incepe in curand", + "projects.status.ending_soon" : "Se incheie in curand" + + } diff --git a/resources/js/Pages/Public/Projects/Show.vue b/resources/js/Pages/Public/Projects/Show.vue index e309f1ad..138817a7 100644 --- a/resources/js/Pages/Public/Projects/Show.vue +++ b/resources/js/Pages/Public/Projects/Show.vue @@ -23,16 +23,16 @@ />
- {{ project.is_period_active ? $t('active') : $t('inactive') }} + {{ $t('projects.status.'+project.status)}}
-- {{ project.category }} + {{ project.categories }}
{{ project.total_donations }} {{ $t('currency') }}
-{{ project.target_budget }} {{ $t('currency') }}
+{{ project.donations.total }} {{ $t('currency') }}
+{{ project.donations.target }} {{ $t('currency') }}
- {{ project.donations.length }} {{ $t('donations') }} + {{ project.donations.total }} {{ $t('donations') }}
- {{ project.counties.map((county) => county.name).join(', ') }} + {{ project.counties}}