Skip to content

Open-source download manager & offline media toolbox for YouTube, music, social media, learning platforms & 1,800+ sites. Built with Tauri 2.0, Rust & Svelte.

feat(estrategia-militares): add search functionality and update course type

Tonho3c6dac7c2890
diff --git a/src/routes/courses/estrategia-militares/+page.svelte b/src/routes/courses/estrategia-militares/+page.svelte
index c0494b70..2cd2b78b 100644
--- a/src/routes/courses/estrategia-militares/+page.svelte
+++ b/src/routes/courses/estrategia-militares/+page.svelte
@@ -12,6 +12,8 @@
type EstrategiaMilitaresCourse = {
id: string;
name: string;
+ slug: string;
+ goal_id: string;
};
let token = $state("");
@@ -101,6 +103,8 @@
currentPage = 1;
}
+ let searchQuery = $state("");
+
async function loadCourses() {
loadingCourses = true;
coursesError = "";
@@ -114,6 +118,20 @@
}
}
+ async function handleSearch() {
+ if (!searchQuery.trim()) return;
+ loadingCourses = true;
+ coursesError = "";
+ try {
+ courses = await invoke("estrategia_militares_search_courses", { query: searchQuery.trim() });
+ currentPage = 1;
+ } catch (e: any) {
+ coursesError = typeof e === "string" ? e : e.message ?? "Search failed";
+ } finally {
+ loadingCourses = false;
+ }
+ }
+
function getCourseDownloadStatus(courseId: string): "idle" | "downloading" | "complete" | "error" {
const item = downloads.get(Number(courseId) || 0);
if (!item) return "idle";
@@ -149,7 +167,7 @@
}
try {
- await invoke("start_estrategia_militares_download", {
+ await invoke("start_estrategia_militares_course_download", {
courseJson: JSON.stringify(course),
outputDir,
});
@@ -215,6 +233,18 @@
</div>
</div>
+ <form class="search-bar" onsubmit={(e) => { e.preventDefault(); handleSearch(); }}>
+ <input
+ class="input search-input"
+ type="text"
+ placeholder="Search courses (e.g. Marinha, Exercito, FAB...)"
+ bind:value={searchQuery}
+ />
+ <button class="button" type="submit" disabled={loadingCourses || !searchQuery.trim()}>
+ Search
+ </button>
+ </form>
+
{#if loadingCourses}
<div class="spinner-section">
<span class="spinner"></span>
@@ -319,6 +349,16 @@
{/if}
<style>
+ .search-bar {
+ display: flex;
+ gap: calc(var(--padding) / 2);
+ width: 100%;
+ }
+
+ .search-input {
+ flex: 1;
+ }
+
.back-link {
display: inline-flex;
align-items: center;