diff --git a/app/Http/Controllers/DashboardController.php b/app/Http/Controllers/DashboardController.php new file mode 100644 index 0000000..2426abc --- /dev/null +++ b/app/Http/Controllers/DashboardController.php @@ -0,0 +1,13 @@ +validated(); + $connector = new SpoonacularConnector(); + $request = new FindRecipesByIngredients( + ingredients: array_map("trim", explode(",", $data['ingredients'])), + ranking: 2 + ); + + $response = $connector->send($request); + + return Inertia::render('Search/Recipes', [ + 'recipes' => $response->json(), + 'previousSearch' => $data['ingredients'] + ]); + } +} diff --git a/app/Http/Requests/RecipeSearchRequest.php b/app/Http/Requests/RecipeSearchRequest.php new file mode 100644 index 0000000..83a8537 --- /dev/null +++ b/app/Http/Requests/RecipeSearchRequest.php @@ -0,0 +1,20 @@ + ['required', 'string', 'min:3'] + ]; + } + + public function authorize(): bool + { + return true; + } +} diff --git a/package-lock.json b/package-lock.json index ffb336b..14cbddb 100644 --- a/package-lock.json +++ b/package-lock.json @@ -5,6 +5,8 @@ "packages": { "": { "devDependencies": { + "@headlessui/vue": "^1.7.22", + "@heroicons/vue": "^2.1.4", "@inertiajs/vue3": "^1.0.0", "@tailwindcss/forms": "^0.5.3", "@vitejs/plugin-vue": "^5.0.0", @@ -434,6 +436,32 @@ "node": ">=12" } }, + "node_modules/@headlessui/vue": { + "version": "1.7.22", + "resolved": "https://registry.npmjs.org/@headlessui/vue/-/vue-1.7.22.tgz", + "integrity": "sha512-Hoffjoolq1rY+LOfJ+B/OvkhuBXXBFgd8oBlN+l1TApma2dB0En0ucFZrwQtb33SmcCqd32EQd0y07oziXWNYg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@tanstack/vue-virtual": "^3.0.0-beta.60" + }, + "engines": { + "node": ">=10" + }, + "peerDependencies": { + "vue": "^3.2.0" + } + }, + "node_modules/@heroicons/vue": { + "version": "2.1.4", + "resolved": "https://registry.npmjs.org/@heroicons/vue/-/vue-2.1.4.tgz", + "integrity": "sha512-wykVSZ/fqEG49lIeHgFGT9TCvBw9THuRTtA/sPp7FVk3iBob/HcmitMcLDwtXOW82TXb38HeLRl1/pcElPeSdg==", + "dev": true, + "license": "MIT", + "peerDependencies": { + "vue": ">= 3" + } + }, "node_modules/@inertiajs/core": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/@inertiajs/core/-/core-1.2.0.tgz", @@ -819,6 +847,34 @@ "tailwindcss": ">=3.0.0 || >= 3.0.0-alpha.1" } }, + "node_modules/@tanstack/virtual-core": { + "version": "3.7.0", + "resolved": "https://registry.npmjs.org/@tanstack/virtual-core/-/virtual-core-3.7.0.tgz", + "integrity": "sha512-p0CWuqn+n8iZmsL7/l0Xg7kbyIKnHNqkEJkMDOkg4x3Ni3LohszmnJY8FPhTgG7Ad9ZFGcdKmn1R1mKUGEh9Xg==", + "dev": true, + "license": "MIT", + "funding": { + "type": "github", + "url": "https://github.com/sponsors/tannerlinsley" + } + }, + "node_modules/@tanstack/vue-virtual": { + "version": "3.7.0", + "resolved": "https://registry.npmjs.org/@tanstack/vue-virtual/-/vue-virtual-3.7.0.tgz", + "integrity": "sha512-RkSrajvJpV1RdJKgZnPgzyzVVx76QjPAu+spgdAms+SZRcSbYMUKlcjusnHjhszck5ngHXSXbSBp45ycF1nlDw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@tanstack/virtual-core": "3.7.0" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/tannerlinsley" + }, + "peerDependencies": { + "vue": "^2.7.0 || ^3.0.0" + } + }, "node_modules/@types/estree": { "version": "1.0.5", "resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.5.tgz", diff --git a/package.json b/package.json index 6a7057d..0142eba 100644 --- a/package.json +++ b/package.json @@ -6,6 +6,8 @@ "build": "vite build" }, "devDependencies": { + "@headlessui/vue": "^1.7.22", + "@heroicons/vue": "^2.1.4", "@inertiajs/vue3": "^1.0.0", "@tailwindcss/forms": "^0.5.3", "@vitejs/plugin-vue": "^5.0.0", diff --git a/resources/js/Components/Search/RecipeSearchForm.vue b/resources/js/Components/Search/RecipeSearchForm.vue new file mode 100644 index 0000000..8522ab4 --- /dev/null +++ b/resources/js/Components/Search/RecipeSearchForm.vue @@ -0,0 +1,45 @@ + + + + + diff --git a/resources/js/Components/Search/RecipeSearchResultCard.vue b/resources/js/Components/Search/RecipeSearchResultCard.vue new file mode 100644 index 0000000..76db090 --- /dev/null +++ b/resources/js/Components/Search/RecipeSearchResultCard.vue @@ -0,0 +1,43 @@ + + + + + diff --git a/resources/js/Pages/Dashboard.vue b/resources/js/Pages/Dashboard.vue index b8369b5..c973460 100644 --- a/resources/js/Pages/Dashboard.vue +++ b/resources/js/Pages/Dashboard.vue @@ -1,6 +1,9 @@