1+ import LoadingSnipper from "@/components/LoadingSnipper" ;
12import { Avatar , AvatarFallback , AvatarImage } from "@/components/ui/avatar" ;
23import { Badge } from "@/components/ui/badge" ;
34import { Button } from "@/components/ui/button" ;
@@ -27,6 +28,7 @@ import { FaCode, FaFileCode } from "react-icons/fa";
2728import { FiMessageSquare } from "react-icons/fi" ;
2829import { useDispatch , useSelector } from "react-redux" ;
2930import { useNavigate } from "react-router-dom" ;
31+ import { supportedLanguages } from "@/constants" ;
3032
3133const SnippetsPage = ( ) => {
3234 const { snippets, isLoading, error, totalPages, currentPage } = useSelector (
@@ -82,6 +84,7 @@ const SnippetsPage = () => {
8284 placeholder = "Search Templates..."
8385 />
8486 </ div >
87+
8588 < div className = "flex flex-col sm:flex-row gap-2" >
8689 < Select
8790 value = { languageFilter || "all" }
@@ -94,15 +97,12 @@ const SnippetsPage = () => {
9497 </ SelectTrigger >
9598 < SelectContent >
9699 < SelectGroup >
97- < SelectItem value = "all" > All Language</ SelectItem >
98- < SelectItem value = "Javascript" > Javascript</ SelectItem >
99- < SelectItem value = "Python" > Python</ SelectItem >
100- < SelectItem value = "C++" > C++</ SelectItem >
101- < SelectItem value = "Typescript" > Typescript</ SelectItem >
102- < SelectItem value = "Java" > Java</ SelectItem >
103- < SelectItem value = "SQL" > SQL</ SelectItem >
104- < SelectItem value = "PHP" > PHP</ SelectItem >
105- < SelectItem value = "CSS" > CSS</ SelectItem >
100+ < SelectItem value = "all" > All Languages</ SelectItem >
101+ { supportedLanguages . map ( ( language ) => (
102+ < SelectItem key = { language } value = { language } >
103+ { language }
104+ </ SelectItem >
105+ ) ) }
106106 </ SelectGroup >
107107 </ SelectContent >
108108 </ Select >
@@ -140,7 +140,9 @@ const SnippetsPage = () => {
140140 </ div >
141141 </ div >
142142
143- { snippets . length > 0 ? (
143+ { isLoading ? (
144+ < LoadingSnipper > { "Loading Snippet..." } </ LoadingSnipper >
145+ ) : snippets . length > 0 ? (
144146 < div className = "grid gap-6 md:grid-cols-2 " >
145147 { snippets . map ( ( snippet ) => (
146148 < Card key = { snippet . _id } className = "overflow-hidden" >
0 commit comments