#4 - cr fix
This commit is contained in:
parent
5d580a71d0
commit
e59ae4a855
@ -55,4 +55,4 @@ GOOGLE_CLIENT_ID=
|
|||||||
GOOGLE_CLIENT_SECRET=
|
GOOGLE_CLIENT_SECRET=
|
||||||
GOOGLE_REDIRECT=
|
GOOGLE_REDIRECT=
|
||||||
|
|
||||||
USER_EMAIL=
|
LOCAL_EMAIL_FOR_LOGIN_VIA_GOOGLE=
|
||||||
|
@ -12,5 +12,6 @@ module.exports = {
|
|||||||
indent: ['error', 4],
|
indent: ['error', 4],
|
||||||
'vue/html-indent': ['error', 4],
|
'vue/html-indent': ['error', 4],
|
||||||
'vue/multi-word-component-names': 'off',
|
'vue/multi-word-component-names': 'off',
|
||||||
}
|
'comma-dangle': ['error', 'always-multiline'],
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
@ -4,7 +4,7 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace Toby\Enums;
|
namespace Toby\Enums;
|
||||||
|
|
||||||
enum FormOfEmployment: string
|
enum EmploymentForm: string
|
||||||
{
|
{
|
||||||
case EMPLOYMENT_CONTRACT = "employment_contract";
|
case EMPLOYMENT_CONTRACT = "employment_contract";
|
||||||
case COMMISSION_CONTRACT = "commission_contract";
|
case COMMISSION_CONTRACT = "commission_contract";
|
||||||
@ -18,10 +18,10 @@ enum FormOfEmployment: string
|
|||||||
|
|
||||||
public static function casesToSelect(): array
|
public static function casesToSelect(): array
|
||||||
{
|
{
|
||||||
$cases = collect(FormOfEmployment::cases());
|
$cases = collect(EmploymentForm::cases());
|
||||||
|
|
||||||
return $cases->map(
|
return $cases->map(
|
||||||
fn(FormOfEmployment $enum) => [
|
fn(EmploymentForm $enum) => [
|
||||||
"label" => $enum->label(),
|
"label" => $enum->label(),
|
||||||
"value" => $enum->value,
|
"value" => $enum->value,
|
||||||
],
|
],
|
@ -4,7 +4,6 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace Toby\Helpers;
|
namespace Toby\Helpers;
|
||||||
|
|
||||||
use Illuminate\Support\Arr;
|
|
||||||
use Illuminate\Support\Facades\Storage;
|
use Illuminate\Support\Facades\Storage;
|
||||||
use Illuminate\Support\Str;
|
use Illuminate\Support\Str;
|
||||||
use LasseRafn\InitialAvatarGenerator\InitialAvatar;
|
use LasseRafn\InitialAvatarGenerator\InitialAvatar;
|
||||||
@ -30,17 +29,18 @@ class UserAvatarGenerator
|
|||||||
protected function generate(User $user): SVG
|
protected function generate(User $user): SVG
|
||||||
{
|
{
|
||||||
return $this->generator->rounded()
|
return $this->generator->rounded()
|
||||||
->background($this->getRandomColor())
|
->background($this->getColor($user->name))
|
||||||
->color("#F4F8FD")
|
->color("#F4F8FD")
|
||||||
->smooth()
|
->smooth()
|
||||||
|
->fontSize(0.33)
|
||||||
->generateSvg($user->name);
|
->generateSvg($user->name);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function getRandomColor(): string
|
protected function getColor(string $name): string
|
||||||
{
|
{
|
||||||
$colors = config("colors");
|
$colors = config("colors");
|
||||||
|
|
||||||
return Arr::random($colors);
|
return $colors[strlen($name) % count($colors)];
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function generateUuid(): string
|
protected function generateUuid(): string
|
||||||
|
@ -7,7 +7,7 @@ namespace Toby\Http\Controllers;
|
|||||||
use Illuminate\Http\RedirectResponse;
|
use Illuminate\Http\RedirectResponse;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Inertia\Response;
|
use Inertia\Response;
|
||||||
use Toby\Enums\FormOfEmployment;
|
use Toby\Enums\EmploymentForm;
|
||||||
use Toby\Http\Requests\UserRequest;
|
use Toby\Http\Requests\UserRequest;
|
||||||
use Toby\Http\Resources\UserFormDataResource;
|
use Toby\Http\Resources\UserFormDataResource;
|
||||||
use Toby\Http\Resources\UserResource;
|
use Toby\Http\Resources\UserResource;
|
||||||
@ -33,7 +33,7 @@ class UserController extends Controller
|
|||||||
public function create(): Response
|
public function create(): Response
|
||||||
{
|
{
|
||||||
return inertia("Users/Create", [
|
return inertia("Users/Create", [
|
||||||
"employmentForms" => FormOfEmployment::casesToSelect(),
|
"employmentForms" => EmploymentForm::casesToSelect(),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -50,7 +50,7 @@ class UserController extends Controller
|
|||||||
{
|
{
|
||||||
return inertia("Users/Edit", [
|
return inertia("Users/Edit", [
|
||||||
"user" => new UserFormDataResource($user),
|
"user" => new UserFormDataResource($user),
|
||||||
"employmentForms" => FormOfEmployment::casesToSelect(),
|
"employmentForms" => EmploymentForm::casesToSelect(),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7,7 +7,7 @@ namespace Toby\Http\Requests;
|
|||||||
use Illuminate\Foundation\Http\FormRequest;
|
use Illuminate\Foundation\Http\FormRequest;
|
||||||
use Illuminate\Validation\Rule;
|
use Illuminate\Validation\Rule;
|
||||||
use Illuminate\Validation\Rules\Enum;
|
use Illuminate\Validation\Rules\Enum;
|
||||||
use Toby\Enums\FormOfEmployment;
|
use Toby\Enums\EmploymentForm;
|
||||||
|
|
||||||
class UserRequest extends FormRequest
|
class UserRequest extends FormRequest
|
||||||
{
|
{
|
||||||
@ -16,7 +16,7 @@ class UserRequest extends FormRequest
|
|||||||
return [
|
return [
|
||||||
"name" => ["required", "min:3", "max: 150"],
|
"name" => ["required", "min:3", "max: 150"],
|
||||||
"email" => ["required", "email", Rule::unique("users", "email")->ignore($this->user)],
|
"email" => ["required", "email", Rule::unique("users", "email")->ignore($this->user)],
|
||||||
"employmentForm" => ["required", new Enum(FormOfEmployment::class)],
|
"employmentForm" => ["required", new Enum(EmploymentForm::class)],
|
||||||
"employmentDate" => ["required", "date"],
|
"employmentDate" => ["required", "date"],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
@ -8,6 +8,8 @@ use Illuminate\Http\Resources\Json\JsonResource;
|
|||||||
|
|
||||||
class UserResource extends JsonResource
|
class UserResource extends JsonResource
|
||||||
{
|
{
|
||||||
|
public static $wrap = false;
|
||||||
|
|
||||||
public function toArray($request): array
|
public function toArray($request): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
@ -16,7 +18,7 @@ class UserResource extends JsonResource
|
|||||||
"email" => $this->email,
|
"email" => $this->email,
|
||||||
"role" => "Human Resources Manager",
|
"role" => "Human Resources Manager",
|
||||||
"avatar" => asset($this->avatar),
|
"avatar" => asset($this->avatar),
|
||||||
"trashed" => $this->trashed(),
|
"deleted" => $this->trashed(),
|
||||||
"employmentForm" => $this->employment_form->label(),
|
"employmentForm" => $this->employment_form->label(),
|
||||||
"employmentDate" => $this->employment_date->toDisplayString(),
|
"employmentDate" => $this->employment_date->toDisplayString(),
|
||||||
];
|
];
|
||||||
|
@ -10,14 +10,14 @@ use Illuminate\Database\Eloquent\SoftDeletes;
|
|||||||
use Illuminate\Foundation\Auth\User as Authenticatable;
|
use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||||
use Illuminate\Notifications\Notifiable;
|
use Illuminate\Notifications\Notifiable;
|
||||||
use Illuminate\Support\Carbon;
|
use Illuminate\Support\Carbon;
|
||||||
use Toby\Enums\FormOfEmployment;
|
use Toby\Enums\EmploymentForm;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @property int $id
|
* @property int $id
|
||||||
* @property string $name
|
* @property string $name
|
||||||
* @property string $email
|
* @property string $email
|
||||||
* @property string $avatar
|
* @property string $avatar
|
||||||
* @property FormOfEmployment $employment_form
|
* @property EmploymentForm $employment_form
|
||||||
* @property Carbon $employment_date
|
* @property Carbon $employment_date
|
||||||
*/
|
*/
|
||||||
class User extends Authenticatable
|
class User extends Authenticatable
|
||||||
@ -35,7 +35,7 @@ class User extends Authenticatable
|
|||||||
];
|
];
|
||||||
|
|
||||||
protected $casts = [
|
protected $casts = [
|
||||||
"employment_form" => FormOfEmployment::class,
|
"employment_form" => EmploymentForm::class,
|
||||||
"employment_date" => "datetime",
|
"employment_date" => "datetime",
|
||||||
];
|
];
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@ namespace Database\Factories;
|
|||||||
|
|
||||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||||
use Illuminate\Support\Str;
|
use Illuminate\Support\Str;
|
||||||
use Toby\Enums\FormOfEmployment;
|
use Toby\Enums\EmploymentForm;
|
||||||
|
|
||||||
class UserFactory extends Factory
|
class UserFactory extends Factory
|
||||||
{
|
{
|
||||||
@ -15,7 +15,7 @@ class UserFactory extends Factory
|
|||||||
return [
|
return [
|
||||||
"name" => "{$this->faker->firstName} {$this->faker->lastName}",
|
"name" => "{$this->faker->firstName} {$this->faker->lastName}",
|
||||||
"email" => $this->faker->unique()->safeEmail(),
|
"email" => $this->faker->unique()->safeEmail(),
|
||||||
"employment_form" => $this->faker->randomElement(FormOfEmployment::cases()),
|
"employment_form" => $this->faker->randomElement(EmploymentForm::cases()),
|
||||||
"employment_date" => $this->faker->dateTimeBetween("2020-10-27"),
|
"employment_date" => $this->faker->dateTimeBetween("2020-10-27"),
|
||||||
"remember_token" => Str::random(10),
|
"remember_token" => Str::random(10),
|
||||||
];
|
];
|
||||||
|
@ -13,7 +13,7 @@ class DatabaseSeeder extends Seeder
|
|||||||
{
|
{
|
||||||
User::factory(35)->create();
|
User::factory(35)->create();
|
||||||
User::factory([
|
User::factory([
|
||||||
"email" => env("USER_EMAIL"),
|
"email" => env("LOCAL_EMAIL_FOR_LOGIN_VIA_GOOGLE"),
|
||||||
])->create();
|
])->create();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -291,7 +291,7 @@ export default {
|
|||||||
name: 'Payroll',
|
name: 'Payroll',
|
||||||
href: '#',
|
href: '#',
|
||||||
iconForeground: 'text-yellow-700',
|
iconForeground: 'text-yellow-700',
|
||||||
iconBackground: 'bg-yellow-50'
|
iconBackground: 'bg-yellow-50',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
icon: ReceiptRefundIcon,
|
icon: ReceiptRefundIcon,
|
||||||
|
@ -80,7 +80,7 @@ export default {
|
|||||||
errors: {
|
errors: {
|
||||||
type: Object,
|
type: Object,
|
||||||
default: () => ({oauth: null}),
|
default: () => ({oauth: null}),
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
@ -201,6 +201,6 @@ export default {
|
|||||||
}))
|
}))
|
||||||
.post('/users');
|
.post('/users');
|
||||||
},
|
},
|
||||||
}
|
},
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
@ -205,6 +205,6 @@ export default {
|
|||||||
}))
|
}))
|
||||||
.put(`/users/${this.user.id}`);
|
.put(`/users/${this.user.id}`);
|
||||||
},
|
},
|
||||||
}
|
},
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
@ -71,7 +71,7 @@
|
|||||||
<tr
|
<tr
|
||||||
v-for="user in users.data"
|
v-for="user in users.data"
|
||||||
:key="user.id"
|
:key="user.id"
|
||||||
:class="{ 'bg-red-50': user.trashed, 'hover:bg-blumilk-25': !user.trashed }"
|
:class="{ 'bg-red-50': user.deleted, 'hover:bg-blumilk-25': !user.deleted }"
|
||||||
>
|
>
|
||||||
<td class="px-4 py-4 whitespace-nowrap text-sm text-gray-500">
|
<td class="px-4 py-4 whitespace-nowrap text-sm text-gray-500">
|
||||||
<div class="flex">
|
<div class="flex">
|
||||||
@ -125,7 +125,7 @@
|
|||||||
>
|
>
|
||||||
<MenuItems class="origin-top-right absolute right-0 mt-2 w-56 z-10 rounded-md shadow-lg bg-white ring-1 ring-black ring-opacity-5 focus:outline-none">
|
<MenuItems class="origin-top-right absolute right-0 mt-2 w-56 z-10 rounded-md shadow-lg bg-white ring-1 ring-black ring-opacity-5 focus:outline-none">
|
||||||
<div
|
<div
|
||||||
v-if="!user.trashed"
|
v-if="!user.deleted"
|
||||||
class="py-1"
|
class="py-1"
|
||||||
>
|
>
|
||||||
<MenuItem
|
<MenuItem
|
||||||
@ -295,6 +295,6 @@ export default {
|
|||||||
return {
|
return {
|
||||||
search,
|
search,
|
||||||
};
|
};
|
||||||
}
|
},
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
@ -40,7 +40,7 @@
|
|||||||
class="rounded-full flex text-sm ring-2 ring-white ring-opacity-20 focus:outline-none focus:ring-opacity-100"
|
class="rounded-full flex text-sm ring-2 ring-white ring-opacity-20 focus:outline-none focus:ring-opacity-100"
|
||||||
dusk="user-menu"
|
dusk="user-menu"
|
||||||
>
|
>
|
||||||
<span class="sr-only">Open user menu</span>
|
<span class="sr-only">{{ user.avatar }}</span>
|
||||||
<img
|
<img
|
||||||
class="h-8 w-8 rounded-full"
|
class="h-8 w-8 rounded-full"
|
||||||
:src="user.avatar"
|
:src="user.avatar"
|
||||||
@ -241,7 +241,7 @@ import {
|
|||||||
PopoverOverlay,
|
PopoverOverlay,
|
||||||
PopoverPanel,
|
PopoverPanel,
|
||||||
TransitionChild,
|
TransitionChild,
|
||||||
TransitionRoot
|
TransitionRoot,
|
||||||
} from '@headlessui/vue';
|
} from '@headlessui/vue';
|
||||||
import {BellIcon, MenuIcon, XIcon} from '@heroicons/vue/outline';
|
import {BellIcon, MenuIcon, XIcon} from '@heroicons/vue/outline';
|
||||||
import {computed} from 'vue';
|
import {computed} from 'vue';
|
||||||
@ -284,7 +284,7 @@ export default {
|
|||||||
navigation,
|
navigation,
|
||||||
userNavigation,
|
userNavigation,
|
||||||
};
|
};
|
||||||
}
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
@ -33,6 +33,6 @@ Flatpickr.setDefaults({
|
|||||||
dateFormat: 'Y-m-d',
|
dateFormat: 'Y-m-d',
|
||||||
enableTime: false,
|
enableTime: false,
|
||||||
altFormat: 'j F Y',
|
altFormat: 'j F Y',
|
||||||
altInput: true
|
altInput: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@ use Illuminate\Support\Carbon;
|
|||||||
use Illuminate\Support\Facades\Storage;
|
use Illuminate\Support\Facades\Storage;
|
||||||
use Inertia\Testing\AssertableInertia as Assert;
|
use Inertia\Testing\AssertableInertia as Assert;
|
||||||
use Tests\TestCase;
|
use Tests\TestCase;
|
||||||
use Toby\Enums\FormOfEmployment;
|
use Toby\Enums\EmploymentForm;
|
||||||
use Toby\Models\User;
|
use Toby\Models\User;
|
||||||
|
|
||||||
class UserTest extends TestCase
|
class UserTest extends TestCase
|
||||||
@ -90,7 +90,7 @@ class UserTest extends TestCase
|
|||||||
->post("/users", [
|
->post("/users", [
|
||||||
"name" => "John Doe",
|
"name" => "John Doe",
|
||||||
"email" => "john.doe@example.com",
|
"email" => "john.doe@example.com",
|
||||||
"employmentForm" => FormOfEmployment::B2B_CONTRACT->value,
|
"employmentForm" => EmploymentForm::B2B_CONTRACT->value,
|
||||||
"employmentDate" => Carbon::now()->toDateTimeString(),
|
"employmentDate" => Carbon::now()->toDateTimeString(),
|
||||||
])
|
])
|
||||||
->assertSessionHasNoErrors();
|
->assertSessionHasNoErrors();
|
||||||
@ -98,7 +98,7 @@ class UserTest extends TestCase
|
|||||||
$this->assertDatabaseHas("users", [
|
$this->assertDatabaseHas("users", [
|
||||||
"name" => "John Doe",
|
"name" => "John Doe",
|
||||||
"email" => "john.doe@example.com",
|
"email" => "john.doe@example.com",
|
||||||
"employment_form" => FormOfEmployment::B2B_CONTRACT->value,
|
"employment_form" => EmploymentForm::B2B_CONTRACT->value,
|
||||||
"employment_date" => Carbon::now()->toDateTimeString(),
|
"employment_date" => Carbon::now()->toDateTimeString(),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
@ -121,7 +121,7 @@ class UserTest extends TestCase
|
|||||||
->put("/users/{$user->id}", [
|
->put("/users/{$user->id}", [
|
||||||
"name" => "John Doe",
|
"name" => "John Doe",
|
||||||
"email" => "john.doe@example.com",
|
"email" => "john.doe@example.com",
|
||||||
"employmentForm" => FormOfEmployment::B2B_CONTRACT->value,
|
"employmentForm" => EmploymentForm::B2B_CONTRACT->value,
|
||||||
"employmentDate" => Carbon::now()->toDateTimeString(),
|
"employmentDate" => Carbon::now()->toDateTimeString(),
|
||||||
])
|
])
|
||||||
->assertSessionHasNoErrors();
|
->assertSessionHasNoErrors();
|
||||||
@ -129,7 +129,7 @@ class UserTest extends TestCase
|
|||||||
$this->assertDatabaseHas("users", [
|
$this->assertDatabaseHas("users", [
|
||||||
"name" => "John Doe",
|
"name" => "John Doe",
|
||||||
"email" => "john.doe@example.com",
|
"email" => "john.doe@example.com",
|
||||||
"employment_form" => FormOfEmployment::B2B_CONTRACT->value,
|
"employment_form" => EmploymentForm::B2B_CONTRACT->value,
|
||||||
"employment_date" => Carbon::now()->toDateTimeString(),
|
"employment_date" => Carbon::now()->toDateTimeString(),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user