Skip to content

Commit

Permalink
Merge pull request #310 from IT-Academy-BCN/266-fe-rename-and-reorgan…
Browse files Browse the repository at this point in the history
…ise-files-and-folders-structure

[FE] Refactor:  #266 fe rename and reorganise files and folders structure
  • Loading branch information
tomi-casabona authored Oct 15, 2024
2 parents 2d088b7 + bca8620 commit 4361349
Show file tree
Hide file tree
Showing 139 changed files with 2,663 additions and 2,541 deletions.
52 changes: 26 additions & 26 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -1,36 +1,36 @@
{
"extends": [
"airbnb",
"airbnb-typescript",
"airbnb/hooks",
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"prettier"
"airbnb",
"airbnb-typescript",
"airbnb/hooks",
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"prettier"
],
"plugins": ["@typescript-eslint"],
"parserOptions": {
"parser": "@typescript-eslint/parser",
"project": "./tsconfig.json"
"parser": "@typescript-eslint/parser",
"project": "./tsconfig.json"
},
"rules": {
"react/react-in-jsx-scope": 0,
"no-unused-vars": 2,
"@typescript-eslint/no-unused-vars": 2,
"import/prefer-default-export": 0,
"react/function-component-definition": 0,
"react/jsx-props-no-spreading": 0,
"react/require-default-props": 0,
"react/prop-types": 0
"no-param-reassign": "off",
"react/react-in-jsx-scope": 0,
"no-unused-vars": 2,
"@typescript-eslint/no-unused-vars": 2,
"import/prefer-default-export": 0,
"react/function-component-definition": 0,
"react/jsx-props-no-spreading": 0,
"react/require-default-props": 0,
"react/prop-types": 0
},
"ignorePatterns": [
"node_modules",
"dist",
"build",
"coverage",
"public",
"scripts",
"vite.config.ts",
"tailwind.config.js",
"postcss.config.js"
"node_modules",
"dist",
"build",
"coverage",
"public",
"scripts",
"vite.config.ts"
]
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -41,19 +41,19 @@ class StudentCollaborationAnnotation
* example="e6b4432b-d2f8-4e06-b727-6ecaf40e6e0e"
* ),
* @OA\Property(
* property="collaboration_name",
* property="name",
* type="string",
* description="Name of the collaboration",
* example="Project X"
* ),
* @OA\Property(
* property="collaboration_description",
* property="description",
* type="string",
* description="Description of the collaboration",
* example="A collaborative project on topic Y"
* ),
* @OA\Property(
* property="collaboration_quantity",
* property="quantity",
* type="integer",
* description="Quantity of the collaboration",
* example=3
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class StudentDetailAnnotation
* @OA\Items(
* type="object",
* @OA\Property(property="id", type="integer", example=4),
* @OA\Property(property="tag_name", type="string", example="HTML&CSS")
* @OA\Property(property="name", type="string", example="HTML&CSS")
* )
* ),
* @OA\Property(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
use OpenApi\Annotations as OA;

class TagDetailAnnotation
{
{
/**
* @OA\Get(
* path="/tags/{tagId}",
Expand Down Expand Up @@ -38,7 +38,7 @@ class TagDetailAnnotation
* property="data",
* type="object",
* @OA\Property(property="id", type="integer", example=1),
* @OA\Property(property="tag_name", type="string", example="Laravel"),
* @OA\Property(property="name", type="string", example="Laravel"),
* @OA\Property(property="created_at", type="string", format="date-time", example="2024-01-25T12:34:56Z"),
* @OA\Property(property="updated_at", type="string", format="date-time", example="2024-01-25T12:34:56Z"),
* )
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class TagListAnnotation
* @OA\Items(
* type="object",
* @OA\Property(property="id", type="integer", example=1),
* @OA\Property(property="tag_name", type="string", example="Laravel"),
* @OA\Property(property="name", type="string", example="Laravel"),
* )
* )
* )
Expand Down
10 changes: 5 additions & 5 deletions app/Annotations/OpenApi/Controllers/Tag/TagStoreAnnotation.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ class TagStoreAnnotation
* description="Creates a new tag and saves it in the database.",
* @OA\RequestBody(
* required=true,
* description="New Tag name.
* description="New Tag.
- Tag field is **required**, must be a **string**, **less than 75 characters** and **unique** on database",
- Name field is **required**, must be a **string**, **less than 75 characters** and **unique** on database",
* @OA\JsonContent(
* type="object",
* @OA\Property(
* property="tag_name",
* property="name",
* type="string",
* example="Laravel"),
* )
Expand All @@ -37,7 +37,7 @@ class TagStoreAnnotation
* property="tag",
* type="object",
* @OA\Property(property="id", type="integer", example=1),
* @OA\Property(property="tag_name", type="string", example="New Tag Name")
* @OA\Property(property="name", type="string", example="New Tag")
* )
* )
* ),
Expand All @@ -53,7 +53,7 @@ class TagStoreAnnotation
* property="errors",
* type="object",
* @OA\Property(
* property="tag_name",
* property="name",
* type="array",
* @OA\Items(
* type="string",
Expand Down
12 changes: 6 additions & 6 deletions app/Annotations/OpenApi/Controllers/Tag/TagUpdateAnnotation.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ class TagUpdateAnnotation
* required=true,
* description="New Tag name.
- Tag field is **required**, must be a **string**, **less than 75 characters** and **unique** on database",
- Name field is **required**, must be a **string**, **less than 75 characters** and **unique** on database",
* @OA\JsonContent(
* type="object",
* @OA\Property(
* property="tag_name",
* property="name",
* type="string",
* example="Updated Tag"),
* ),
Expand All @@ -44,7 +44,7 @@ class TagUpdateAnnotation
* type="object",
* @OA\Property(property="tag", type="object",
* @OA\Property(property="id", type="integer", example=1),
* @OA\Property(property="tag_name", type="string", example="Laravel"),
* @OA\Property(property="name", type="string", example="Laravel"),
* ),
* ),
* ),
Expand All @@ -66,10 +66,10 @@ class TagUpdateAnnotation
* description="Validation error.",
* @OA\JsonContent(
* type="object",
* @OA\Property(property="message", type="string", example="El camp tag name és obligatori."),
* @OA\Property(property="message", type="string", example="El camp name és obligatori."),
* @OA\Property(property="errors", type="object",
* @OA\Property(property="tag_name", type="array",
* @OA\Items(type="string", example="El camp tag name és obligatori.")
* @OA\Property(property="name", type="array",
* @OA\Items(type="string", example="El camp name és obligatori.")
* ),
* ),
* ),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class CollaborationAnnotation {

/**
* @OA\Property(
* property="collaboration_name",
* property="name",
* description="Collaboration Name",
* type="string"
* )
Expand Down
2 changes: 1 addition & 1 deletion app/Annotations/OpenApi/Models/Tag/TagAnnotation.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
* @var int
*
* @OA\Property(
* property="tag_name",
* property="name",
* description="Tag Name",
* type="string",
* format="int64"
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Requests/Tag/TagStoreRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public function authorize(): bool
public function rules(): array
{
return [
'tag_name' => 'required|string|max:75|unique:tags',
'name' => 'required|string|max:75|unique:tags',
];
}
protected function failedValidation(Validator $validator): void
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Requests/Tag/TagUpdateRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public function rules(): array
$tagId = $this->route('tagId');
if (Tag::find($tagId)) {
return [
'tag_name' => 'required|string|max:75|unique:tags,tag_name,' . $tagId,
'name' => 'required|string|max:75|unique:tags,name,' . $tagId,
];
}
return [];
Expand Down
6 changes: 3 additions & 3 deletions app/Http/Resources/CollaborationCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ public function toArray(Request $request): array
'collaborations' => $this->collection->map(function ($collaboration) {
return [
'uuid' => $collaboration->id,
'collaboration_name' => $collaboration->collaboration_name,
'collaboration_description' => $collaboration->collaboration_description,
'collaboration_quantity' => $collaboration->collaboration_quantity,
'name' => $collaboration->name,
'description' => $collaboration->description,
'quantity' => $collaboration->quantity,
];
})->toArray()
];
Expand Down
1 change: 0 additions & 1 deletion app/Http/Resources/ProjectCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ public function toArray(Request $request): array
'tags' => $project->tags->map(function ($tag) {
return [
'id' => $tag->id,
// Right now the correct name of the property is tag_name, but it should be renamed to name.
'name' => $tag->name,
];
}),
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Resources/Tag/TagResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public function toArray(Request $request): array
{
return [
'id' => $this->id,
'tag_name' => $this->tag_name,
'name' => $this->name,
];
}
}
2 changes: 1 addition & 1 deletion app/Models/Tag.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class Tag extends Model
use HasFactory;

protected $fillable = [
'tag_name',
'name',
];

/**
Expand Down
2 changes: 1 addition & 1 deletion app/Service/Student/StudentDetailService.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ private function getFormattedTags(Student $student): array
return $student->tags->map(function ($tag) {
return [
'id' => $tag->id,
'name' => $tag->tag_name
'name' => $tag->name
];
})->toArray();
}
Expand Down
4 changes: 2 additions & 2 deletions app/Service/Student/StudentListService.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public function getResumes(?array $specializations, ?array $tags = null): Collec
if ($tags != null) {
$query->whereHas('student.tags', function ($query) use ($tags) {
foreach ($tags as $tag) {
$tagId = Tag::where('tag_name', $tag)->value('id');
$tagId = Tag::where('name', $tag)->value('id');
if ($tagId) {
$query->where('tag_id', $tagId);
}
Expand Down Expand Up @@ -70,7 +70,7 @@ private function getMappedTags($resume): array
->map(function ($tag) {
return [
'id' => $tag->id,
'name' => $tag->tag_name,
'name' => $tag->name,
];
})
->toArray();
Expand Down
2 changes: 1 addition & 1 deletion app/Service/Tag/TagDetailService.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public function getTagDetailsById(int $tagId): array
$tag = $this->getTag($tagId);
return [
'id' => $tag->id,
'tag_name' => $tag->tag_name,
'name' => $tag->name,
'created_at' => $tag->created_at,
'updated_at' => $tag->updated_at,
];
Expand Down
6 changes: 3 additions & 3 deletions database/factories/CollaborationFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ class CollaborationFactory extends Factory
public function definition()
{
return [
'collaboration_name' => $this->faker->sentence($this->faker->numberBetween(1, 5)),
'collaboration_description' => $this->faker->paragraph($nbSentences = 3, $variableNbSentences = true),
'collaboration_quantity' => $this->faker->numberBetween(1, 10),
'name' => $this->faker->sentence($this->faker->numberBetween(1, 5)),
'description' => $this->faker->paragraph($nbSentences = 3, $variableNbSentences = true),
'quantity' => $this->faker->numberBetween(1, 10),
];
}
}
Expand Down
2 changes: 1 addition & 1 deletion database/factories/TagFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class TagFactory extends Factory
public function definition(): array
{
return [
'tag_name' => $this->faker->unique()->randomElement($this->tagNames),
'name' => $this->faker->unique()->randomElement($this->tagNames),
];
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration {
public function up(): void
{
Schema::table('tags', function (Blueprint $table) {
$table->renameColumn('tag_name', 'name');
});
}

public function down(): void
{
Schema::table('tags', function (Blueprint $table) {
$table->renameColumn('name', 'tag_name');
});
}
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration {
public function up(): void
{
Schema::table('collaborations', function (Blueprint $table) {
$table->renameColumn('collaboration_name', 'name');
$table->renameColumn('collaboration_description', 'description');
$table->renameColumn('collaboration_quantity', 'quantity');
});
}

public function down(): void
{
Schema::table('collaborations', function (Blueprint $table) {
$table->renameColumn('name', 'collaboration_name');
$table->renameColumn('description', 'collaboration_description');
$table->renameColumn('quantity', 'collaboration_quantity');
});
}
};
Loading

0 comments on commit 4361349

Please sign in to comment.