Skip to content

Commit

Permalink
Added the use case category in templates page
Browse files Browse the repository at this point in the history
  • Loading branch information
bitbrief committed Oct 10, 2024
1 parent b97201c commit 711c353
Show file tree
Hide file tree
Showing 4 changed files with 313 additions and 131 deletions.
13 changes: 13 additions & 0 deletions apps/dashboard/lib/templates-form.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export const schema = z.object({
search: z.string().optional(),
frameworks: z.array(z.string()),
languages: z.array(z.string()),
usecases: z.array(z.string()),
});

/**
Expand All @@ -24,6 +25,7 @@ export const getDefaulTemplatesFormValues = () => {
search: undefined,
frameworks: [],
languages: [],
usecases: [],
};
}

Expand All @@ -32,11 +34,13 @@ export const getDefaulTemplatesFormValues = () => {
const search = searchParams.get("search");
const frameworks = searchParams.getAll("framework");
const languages = searchParams.getAll("language");
const usecases = searchParams.getAll("usecase");

return {
search: search || undefined,
frameworks: frameworks.length > 0 ? frameworks : [],
languages: languages.length > 0 ? languages : [],
usecases: usecases.length > 0 ? usecases : [],
};
};

Expand All @@ -60,6 +64,15 @@ export const updateUrl = (values: TemplatesFormValues) => {
} else {
searchParams.delete("framework");
}

if(values.usecases) {
searchParams.delete("usecase");
values.usecases.forEach((usecase) => {
searchParams.append("usecase", usecase);
});
} else {
searchParams.delete("usecase");
}

if (values.languages) {
searchParams.delete("language");
Expand Down
Loading

0 comments on commit 711c353

Please sign in to comment.