Skip to content

Commit

Permalink
add search function
Browse files Browse the repository at this point in the history
  • Loading branch information
Yanni8 committed Apr 9, 2024
1 parent 569f0c5 commit 0d1df17
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 6 deletions.
4 changes: 2 additions & 2 deletions resources/js/Components/SetPreview.vue
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<template>
<div @click="reroute" class="w-[30rem] min-h-28 mr-4 border border-gray-500 p-4 rounded-lg m-4 hover:scale-110 cursor-pointer">
<div @click="reroute" class="w-[30rem] max-h-32 min-h-32 relative mr-4 border border-gray-500 p-4 rounded-lg m-4 hover:scale-110 cursor-pointer">
<h1 class="font-bold text-xl">{{ set.title }}</h1>
<h2>{{ set.description }}</h2>
<span class="text-sm italic">Last Update {{ updatedAt }}</span>
<span class="text-sm italic mt-auto absolute bottom-3 right-3">Last Update {{ updatedAt }}</span>
</div>
</template>
<script>
Expand Down
11 changes: 11 additions & 0 deletions resources/js/Pages/Auth/PasswordReset.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<template>
<div class="flex items-center justify-center">
<h1 class="rainbow">Password Reset</h1>
</div>
</template>
<script>
export default {
name: "PasswordReset",
};
</script>
<style></style>
9 changes: 6 additions & 3 deletions resources/js/Pages/Index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<div class="h-[1px] bg-[#333333] w-full mt-4"></div>
<div class="mt-8">
<input
@keypress.prevent.enter="search"
@keydown="search"
placeholder="Search"
v-model="query"
class="bg-[#333333] px-4 py-2 rounded-3xl w-[40rem]"
Expand All @@ -21,7 +21,7 @@
</div>
<div class="mt-12 flex flex-wrap items-center justify-start">
<set-preview
v-for="set in sets"
v-for="set in previewSets"
:key="set.id"
:set="set"
></set-preview>
Expand Down Expand Up @@ -60,12 +60,15 @@ export default {
data() {
return {
query: "",
previewSets: this.sets,
};
},
methods: {
search() {
console.log("searching...", this.sets);
this.previewSets = this.sets.filter((set) =>
set.title.toLowerCase().includes(this.query.toLowerCase())
);
},
redirect() {
window.location = "/import";
Expand Down
7 changes: 6 additions & 1 deletion routes/web.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
if (Auth::check()){
$user = Auth::user();

$sets = DB::table("sets")->where("user_id", $user->id)->limit(20)->get();
$sets = DB::table("sets")->where("user_id", $user->id)->get();

return Inertia::render('Index', [
"userName" => "{$user->first_name} {$user->last_name}",
Expand Down Expand Up @@ -62,4 +62,9 @@

Route::get("/train/{set}", [SetController::class, 'train']);

Route::get("/passwordreset", function () {
return Inertia::render("Auth/PasswordReset", [
]);
});

require __DIR__.'/auth.php';

0 comments on commit 0d1df17

Please sign in to comment.