From debfbfc9418e769821f230a1e3fabf4e44bed10b Mon Sep 17 00:00:00 2001 From: arslan Date: Tue, 22 Oct 2024 22:28:55 +0500 Subject: [PATCH 1/3] fixed bug#2432 Filter options sorted alphabetically --- apps/www/app/templates/client.tsx | 178 +++++++++++++++--------------- 1 file changed, 89 insertions(+), 89 deletions(-) diff --git a/apps/www/app/templates/client.tsx b/apps/www/app/templates/client.tsx index 085050ebb..f27556959 100644 --- a/apps/www/app/templates/client.tsx +++ b/apps/www/app/templates/client.tsx @@ -46,25 +46,25 @@ export function TemplatesClient() { const languages = Object.values(templates).reduce( (acc, { language }) => { - if (!acc[language]) { - acc[language] = 0; - } - acc[language]++; - return acc; + if (!acc[language]) { + acc[language] = 0; + } + acc[language]++; + return acc; }, {} as Record, ); const frameworks = Object.values(templates).reduce( (acc, { framework }) => { - if (!framework) { - return acc; - } - if (!acc[framework]) { - acc[framework] = 0; - } - acc[framework]++; + if (!framework) { return acc; + } + if (!acc[framework]) { + acc[framework] = 0; + } + acc[framework]++; + return acc; }, {} as Record, ); @@ -79,24 +79,24 @@ export function TemplatesClient() { () => Object.entries(templates).reduce( (acc, [id, template]) => { - if ( - fields.frameworks.length > 0 && + if ( + fields.frameworks.length > 0 && (!template.framework || !fields.frameworks.includes(template.framework)) - ) { - return acc; - } + ) { + return acc; + } if (fields.languages.length > 0 && !fields.languages.includes(template.language)) { - return acc; - } - if ( - fields.search && - !template.title.toLowerCase().includes(fields.search.toLowerCase()) && + return acc; + } + if ( + fields.search && + !template.title.toLowerCase().includes(fields.search.toLowerCase()) && !template.description.toLowerCase().includes(fields.search.toLowerCase()) - ) { - return acc; - } - acc[id] = template; + ) { return acc; + } + acc[id] = template; + return acc; }, {} as typeof templates, ), @@ -216,42 +216,42 @@ export function TemplatesClient() { {Object.entries(languages).map(([language, occurences]) => ( - { - return ( - - - { + return ( + + + { - return checked + onCheckedChange={(checked) => { + return checked ? field.onChange([...field.value, language]) - : field.onChange( - field.value?.filter( + : field.onChange( + field.value?.filter( (value: string) => value !== language, ), - ); - }} - /> - - + ); + }} + /> + + {language} - - {occurences} - - - - ); - }} - /> + + {occurences} + + + + ); + }} + /> ))} @@ -276,43 +276,43 @@ export function TemplatesClient() { - {Object.entries(frameworks).map(([framework, occurences]) => ( - { - return ( - - - a[0].localeCompare(b[0])).map(([framework, occurences]) => ( + { + return ( + + + { - return checked + onCheckedChange={(checked) => { + return checked ? field.onChange([...field.value, framework]) - : field.onChange( - field.value?.filter( + : field.onChange( + field.value?.filter( (value: string) => value !== framework, ), - ); - }} - /> - - + ); + }} + /> + + {framework} - - {occurences} - - - - ); - }} - /> - ))} + + {occurences} + + + + ); + }} + /> + ))} From 2bb4d3e6c3a095012350fc2dc91e94367f5c3f61 Mon Sep 17 00:00:00 2001 From: "autofix-ci[bot]" <114827586+autofix-ci[bot]@users.noreply.github.com> Date: Mon, 28 Oct 2024 13:18:20 +0000 Subject: [PATCH 2/3] [autofix.ci] apply automated fixes --- apps/www/app/templates/client.tsx | 128 +++++++++++++++--------------- 1 file changed, 65 insertions(+), 63 deletions(-) diff --git a/apps/www/app/templates/client.tsx b/apps/www/app/templates/client.tsx index f27556959..4ae9a409d 100644 --- a/apps/www/app/templates/client.tsx +++ b/apps/www/app/templates/client.tsx @@ -46,25 +46,25 @@ export function TemplatesClient() { const languages = Object.values(templates).reduce( (acc, { language }) => { - if (!acc[language]) { - acc[language] = 0; - } - acc[language]++; - return acc; + if (!acc[language]) { + acc[language] = 0; + } + acc[language]++; + return acc; }, {} as Record, ); const frameworks = Object.values(templates).reduce( (acc, { framework }) => { - if (!framework) { + if (!framework) { + return acc; + } + if (!acc[framework]) { + acc[framework] = 0; + } + acc[framework]++; return acc; - } - if (!acc[framework]) { - acc[framework] = 0; - } - acc[framework]++; - return acc; }, {} as Record, ); @@ -79,24 +79,24 @@ export function TemplatesClient() { () => Object.entries(templates).reduce( (acc, [id, template]) => { - if ( - fields.frameworks.length > 0 && + if ( + fields.frameworks.length > 0 && (!template.framework || !fields.frameworks.includes(template.framework)) - ) { - return acc; - } + ) { + return acc; + } if (fields.languages.length > 0 && !fields.languages.includes(template.language)) { - return acc; - } - if ( - fields.search && - !template.title.toLowerCase().includes(fields.search.toLowerCase()) && + return acc; + } + if ( + fields.search && + !template.title.toLowerCase().includes(fields.search.toLowerCase()) && !template.description.toLowerCase().includes(fields.search.toLowerCase()) - ) { + ) { + return acc; + } + acc[id] = template; return acc; - } - acc[id] = template; - return acc; }, {} as typeof templates, ), @@ -216,42 +216,42 @@ export function TemplatesClient() { {Object.entries(languages).map(([language, occurences]) => ( - { - return ( - - - { + return ( + + + { - return checked + onCheckedChange={(checked) => { + return checked ? field.onChange([...field.value, language]) - : field.onChange( - field.value?.filter( + : field.onChange( + field.value?.filter( (value: string) => value !== language, ), - ); - }} - /> - - + ); + }} + /> + + {language} - - {occurences} - - - - ); - }} - /> + + {occurences} + + + + ); + }} + /> ))} @@ -276,7 +276,9 @@ export function TemplatesClient() { - {Object.entries(frameworks).sort((a, b) => a[0].localeCompare(b[0])).map(([framework, occurences]) => ( + {Object.entries(frameworks) + .sort((a, b) => a[0].localeCompare(b[0])) + .map(([framework, occurences]) => ( { return checked - ? field.onChange([...field.value, framework]) + ? field.onChange([...field.value, framework]) : field.onChange( field.value?.filter( - (value: string) => value !== framework, - ), + (value: string) => value !== framework, + ), ); }} /> - {framework} + {framework} {occurences} From 81aaa53878f35f2927ce82af2cf6fd04ee903fff Mon Sep 17 00:00:00 2001 From: Arslan-Muhammad Date: Thu, 7 Nov 2024 21:36:26 +0500 Subject: [PATCH 3/3] languages sorted alphabetically --- apps/www/app/templates/client.tsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/apps/www/app/templates/client.tsx b/apps/www/app/templates/client.tsx index 4ae9a409d..1b9b438fe 100644 --- a/apps/www/app/templates/client.tsx +++ b/apps/www/app/templates/client.tsx @@ -215,7 +215,9 @@ export function TemplatesClient() { - {Object.entries(languages).map(([language, occurences]) => ( + {Object.entries(languages) + .sort((a, b) => a[0].localeCompare(b[0])) + .map(([language, occurences]) => (