- add messages
This commit is contained in:
		| @@ -25,10 +25,12 @@ class ProjectController | |||||||
|     public function update(ProjectRequest $request, Project $project): RedirectResponse |     public function update(ProjectRequest $request, Project $project): RedirectResponse | ||||||
|     { |     { | ||||||
|         if ($this->projectRepository->update($project, $request->validated())) { |         if ($this->projectRepository->update($project, $request->validated())) { | ||||||
|             return back()->with('message', 'Zaktualizowano projekt!'); |             return back() | ||||||
|  |                 ->with('success', 'Zaktualizowano projekt!'); | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         return back()->withError(['message_error', 'Wystąpił błąd podczas aktualizacji!']); |         return back() | ||||||
|  |             ->with(['error', 'Wystąpił błąd podczas aktualizacji!']); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public function create(): InertiaResponse |     public function create(): InertiaResponse | ||||||
| @@ -42,10 +44,10 @@ class ProjectController | |||||||
|         if ($project = $this->projectRepository->create($validated)) { |         if ($project = $this->projectRepository->create($validated)) { | ||||||
|             return redirect() |             return redirect() | ||||||
|                 ->route('admin.project.update', compact('project')) |                 ->route('admin.project.update', compact('project')) | ||||||
|                 ->with('message', 'Utworzono projekt!'); |                 ->with('success', 'Utworzono projekt!'); | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         return back()->withError(['message_error', 'Wystąpił błąd podczas tworzenia!']); |         return back()->withError(['error', 'Wystąpił błąd podczas tworzenia!']); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public function delete(Project $project): InertiaResponse |     public function delete(Project $project): InertiaResponse | ||||||
| @@ -57,7 +59,9 @@ class ProjectController | |||||||
|     { |     { | ||||||
|         $title = $project->title; |         $title = $project->title; | ||||||
|         $project->delete(); |         $project->delete(); | ||||||
|         return redirect()->route('admin.home')->with('message', 'Usunięto projekt "'. $title .'"'); |         return redirect() | ||||||
|  |             ->route('admin.home') | ||||||
|  |             ->with('info', 'Usunięto projekt "'. $title .'"'); | ||||||
|     } |     } | ||||||
|  |  | ||||||
| } | } | ||||||
|   | |||||||
| @@ -1,5 +1,10 @@ | |||||||
| <script setup> | <script setup> | ||||||
|  | defineProps({ | ||||||
|  |     messages: { | ||||||
|  |         type: Object, | ||||||
|  |         default: {}, | ||||||
|  |     } | ||||||
|  | }); | ||||||
| </script> | </script> | ||||||
|  |  | ||||||
| <style lang="css" scoped> | <style lang="css" scoped> | ||||||
| @@ -27,6 +32,15 @@ | |||||||
|                 </nav> |                 </nav> | ||||||
|             </div> |             </div> | ||||||
|         </header> |         </header> | ||||||
|  |         <div  v-if="messages?.info" class="max-w-screen-lg mx-2 lg:mx-auto mt-2 px-2 py-3 rounded-md bg-yellow-100 text-yellow-600 text-center"> | ||||||
|  |             {{ messages.info }} | ||||||
|  |         </div> | ||||||
|  |         <div v-if="messages?.error" class="max-w-screen-lg mx-2 lg:mx-auto mt-2 px-2 py-3 rounded-md bg-red-100 text-red-600 text-center"> | ||||||
|  |             {{ messages.error }} | ||||||
|  |         </div> | ||||||
|  |         <div v-if="messages?.success" class="max-w-screen-lg mx-2 lg:mx-auto mt-2 px-2 py-3 rounded-md bg-green-100 text-green-600 text-center"> | ||||||
|  |             {{ messages?.success }} | ||||||
|  |         </div> | ||||||
|         <main class="max-w-screen-lg mx-2 lg:mx-auto mt-2 rounded-md bg-gray-50"> |         <main class="max-w-screen-lg mx-2 lg:mx-auto mt-2 rounded-md bg-gray-50"> | ||||||
|             <slot /> |             <slot /> | ||||||
|         </main> |         </main> | ||||||
|   | |||||||
| @@ -17,8 +17,8 @@ defineProps({ | |||||||
|             <li |             <li | ||||||
|                 v-for="(project, key) in projects" |                 v-for="(project, key) in projects" | ||||||
|                 :key="key" |                 :key="key" | ||||||
|  |                 class="flex items-center justify-between px-3 py-2 bg-white hover:bg-neutral-200" | ||||||
|             > |             > | ||||||
|                 <div class="flex items-center justify-between px-3 py-2 bg-white hover:bg-neutral-200"> |  | ||||||
|                 <InertiaLink :href="`/dashboard/project/${project.id}`">{{ project.title }}</InertiaLink> |                 <InertiaLink :href="`/dashboard/project/${project.id}`">{{ project.title }}</InertiaLink> | ||||||
|                 <div class="flex items-center gap-2"> |                 <div class="flex items-center gap-2"> | ||||||
|                     <InertiaLink |                     <InertiaLink | ||||||
| @@ -32,7 +32,6 @@ defineProps({ | |||||||
|                         :href="`/dashboard/project/${project.id}/delete`" |                         :href="`/dashboard/project/${project.id}/delete`" | ||||||
|                         title="Usuń projekt z listy"><FontAwesomeIcon :icon="['fas', 'trash']" /></InertiaLink> |                         title="Usuń projekt z listy"><FontAwesomeIcon :icon="['fas', 'trash']" /></InertiaLink> | ||||||
|                 </div> |                 </div> | ||||||
|                 </div> |  | ||||||
|             </li> |             </li> | ||||||
|         </ul> |         </ul> | ||||||
|         <div v-else> |         <div v-else> | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user