Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TKD-66 - Implementar tela para contratação de Work (Contractor) #59

Merged
merged 7 commits into from
Oct 12, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<?php

namespace App\Http\Controllers\User\Contractor;
namespace App\Http\Controllers\User\Contractor\Work;

use App\Http\Controllers\Controller;
use App\Models\Work;
use Illuminate\Http\Request;
use Inertia\Response;

class ShowWorksController extends Controller
class ListWorksController extends Controller
{
/**
* Handle the incoming request.
Expand All @@ -25,6 +25,6 @@ public function __invoke(Request $request): Response
])
->get();

return inertia('User/Contractor/Works/Show', compact('works'));
return inertia('User/Contractor/Works/List', compact('works'));
}
}
31 changes: 31 additions & 0 deletions app/Http/Controllers/User/Contractor/Work/ShowWorksController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php

namespace App\Http\Controllers\User\Contractor\Work;

use App\Http\Controllers\Controller;
use App\Models\Work;
use Illuminate\Http\Request;
use Inertia\Response;

class ShowWorksController extends Controller
{
/**
* Handle the incoming request.
*
* @param \Illuminate\Http\Request $request
* @return \Inertia\Response
*/
public function __invoke(string $workUuid, Request $request): Response
{
$work = Work::with([
'specialties',
'unity',
'worker.user',
'specialties',
])
->where('uuid', $workUuid)
->firstOrFail();

return inertia('User/Contractor/Works/Show', compact('work'));
}
}
2 changes: 1 addition & 1 deletion resources/js/Components/Headers/AuthHeader.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import ItemX from '../Menus/Items/ItemX.vue';

const dashboardRoute = 'dashboard';
const myWorksRoute = 'user.worker.my-works.show';
const worksRoute = 'works.show';
const worksRoute = 'works.list';

const isDashboardRoute = computed(() => (route().current() === dashboardRoute));
const isMyWorksRoute = computed(() => (route().current() === myWorksRoute));
Expand Down
64 changes: 64 additions & 0 deletions resources/js/Pages/User/Contractor/Works/List.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
<script setup>
import AuthLayout from '../../../../Layouts/AuthLayout.vue';
import BadgeGroup from '../../../../Components/Badges/BadgeGroup.vue';
import Link from '../../../../Components/Links/Link.vue';

defineProps({
works: {
type: Array,
default: [],
},
});
</script>

<template>
<AuthLayout title="Works">
<template #main>
<div class="flex">
<!-- Page Content -->
<div class="w-full px-5">
<div class="font-bold text-lg">Works</div>

<!-- Works List -->
<div class="mt-5 border rounded w-full overflow-x-auto" v-if="works.length">
<div class="min-w-xl">
<div class="grid grid-flow-col grid-cols-12 gap-2 px-5 py-3 border-b">
<span class="col-span-3 font-bold" title="Work Name">Name</span>
<span class="col-span-2 font-bold" title="Work Slug">Slug</span>
<span class="col-span-3 font-bold" title="Work Specialties">Specialties</span>
<span class="col-span-1 font-bold" title="Work Unity">Unity</span>
<span class="col-span-1 font-bold" title="Work Time">Time</span>
<span class="col-span-2 font-bold" title="Work Price">Price</span>
</div>
<div class="grid grid-flow-col grid-cols-12 gap-2 px-5 py-3 h-20 hover:bg-gray-300 border-b last:border-none"
v-for="(work) in works"
>
<div class="col-span-3 flex items-center overflow-y-auto">
<Link class="min-w-fit break-words text-ellipsis"
:href="route('works.show', { workUuid: work.uuid })"
:title="work.name"
>{{ work.name }}</Link>
</div>
<div class="col-span-2 flex items-center overflow-y-auto">
<span class="min-w-fit break-words text-ellipsis" :title="work.slug">{{ work.slug }}</span>
</div>
<div class="col-span-3 overflow-y-auto">
<BadgeGroup :badges="work.specialties" />
</div>
<div class="col-span-1 flex items-center">
<span :title="work.unity ? work.unity.name : ''">{{ work.unity ? work.unity.type : '' }}</span>
</div>
<div class="col-span-1 flex items-center">
<span :title="work.time">{{ work.time }}</span>
</div>
<div class="col-span-2 flex items-center">
<span class="px-3 py-1 border border-blue-200 rounded-full bg-blue-200" :title="`R$ ${work.price}`.replace('.', ',')">{{ `R$ ${work.price}`.replace('.', ',') }}</span>
</div>
</div>
</div>
</div>
</div>
</div>
</template>
</AuthLayout>
</template>
85 changes: 56 additions & 29 deletions resources/js/Pages/User/Contractor/Works/Show.vue
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
<script setup>
import { ImageOff } from 'mdue';
import AuthLayout from '../../../../Layouts/AuthLayout.vue';
import BadgeGroup from '../../../../Components/Badges/BadgeGroup.vue';

defineProps({
works: {
type: Array,
default: [],
},
work: Object,
});
</script>

Expand All @@ -16,39 +14,68 @@ defineProps({
<div class="flex">
<!-- Page Content -->
<div class="w-full px-5">
<div class="font-bold text-lg">Works</div>
<div class="flex items-center">
<div class="font-bold text-lg" :title="work.name">{{ work.name }}</div>
<div>
<em class="ml-1 font-medium text-sm text-gray-500" :title="work.slug">({{ work.slug }})</em>
</div>
</div>

<!-- Works List -->
<div class="mt-5 border rounded w-full overflow-x-auto" v-if="works.length">
<div class="min-w-xl">
<div class="grid grid-flow-col grid-cols-12 gap-2 px-5 py-3 border-b">
<span class="col-span-3 font-bold" title="Work Name">Name</span>
<span class="col-span-2 font-bold" title="Work Slug">Slug</span>
<span class="col-span-3 font-bold" title="Work Specialties">Specialties</span>
<span class="col-span-1 font-bold" title="Work Unity">Unity</span>
<span class="col-span-1 font-bold" title="Work Time">Time</span>
<span class="col-span-2 font-bold" title="Work Price">Price</span>
<div class="mt-5 p-5 border rounded w-full overflow-x-auto">
<!-- Future image carousel -->
<div class="flex items-center justify-center w-full rounded h-40 md:h-60 lg:h-72 xl:h-80 bg-gray-400" title="No image">
<ImageOff class="text-lg"/>
</div>

<div class="mt-3">
<span class="font-bold text-sm">Worker</span>
<div class="mt-1">
{{ work.worker.user.name }}
</div>
</div>

<div class="mt-3" v-if="work.specialties.length">
<span class="font-bold text-sm">Work specialties</span>
<div class="rounded border p-3 mt-1 h-32 max-w-lg overflow-y-auto">
<BadgeGroup :badges="work.specialties"/>
</div>
<div class="grid grid-flow-col grid-cols-12 gap-2 px-5 py-3 h-20 hover:bg-gray-300 border-b last:border-none"
v-for="(work) in works"
>
<div class="col-span-3 flex items-center overflow-y-auto">
<span class="min-w-fit break-words text-ellipsis" :title="work.name">{{ work.name }}</span>
</div>

<div class="grid grid-cols-2 md:grid-cols-3 gap-3 mt-3">
<div v-if="work.unity">
<div class="flex items-center" title="Work unity reference">
<span class="font-bold text-sm">Unity</span>
<div>
<em class="ml-1 text-xs">(reference)</em>
</div>
</div>
<div class="col-span-2 flex items-center overflow-y-auto">
<span class="min-w-fit break-words text-ellipsis" :title="work.slug">{{ work.slug }}</span>
<div class="mt-1">
<span>{{ work.unity.type }} ({{ work.unity.name }})</span>
</div>
<div class="col-span-3 overflow-y-auto">
<BadgeGroup :badges="work.specialties" />
</div>

<div v-if="work.time">
<div class="flex items-center" title="Work time reference">
<span class="font-bold text-sm">Time</span>
<div>
<em class="ml-1 text-xs">(reference)</em>
</div>
</div>
<div class="col-span-1 flex items-center">
<span :title="work.unity ? work.unity.name : ''">{{ work.unity ? work.unity.type : '' }}</span>
<div class="mt-1">
<span>{{ work.time }}</span>
</div>
<div class="col-span-1 flex items-center">
<span :title="work.time">{{ work.time }}</span>
</div>

<div v-if="work.price">
<div class="flex items-center" title="Work price reference">
<span class="font-bold text-sm">Price</span>
<div>
<em class="ml-1 text-xs">(reference)</em>
</div>
</div>
<div class="col-span-2 flex items-center">
<span class="px-3 py-1 border border-blue-200 rounded-full bg-blue-200" :title="`R$ ${work.price}`.replace('.', ',')">{{ `R$ ${work.price}`.replace('.', ',') }}</span>
<div class="mt-1">
<span>{{ `R$ ${work.price}`.replace('.', ',') }}</span>
</div>
</div>
</div>
Expand Down
8 changes: 6 additions & 2 deletions routes/web/user.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
<?php

use App\Http\Controllers\User\Contractor\ShowWorksController;
use App\Http\Controllers\User\Contractor\Work\{
ListWorksController,
ShowWorksController
};
use App\Http\Controllers\User\Profile\Worker\Certifications\{
DestroyCertificationsController,
ShowCertificationsController,
Expand Down Expand Up @@ -50,6 +53,7 @@
});

Route::prefix('/works')->name('works')->middleware('contractor-profile')->group(function () {
Route::get('', ShowWorksController::class)->name('.show');
Route::get('', ListWorksController::class)->name('.list');
Route::get('{workUuid}', ShowWorksController::class)->name('.show');
});
});
2 changes: 2 additions & 0 deletions storage/app/public/.gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
*
!.gitignore
!profile-photos/
!works/
3 changes: 3 additions & 0 deletions storage/app/public/works/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
*
!.gitignore
!photos/
3 changes: 3 additions & 0 deletions storage/app/public/works/photos/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
*
!.gitignore
!default-work-image.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.