Skip to content

Commit e450db9

Browse files
Merge pull request #30 from devlopersabbir/sabbir
[fix 🐱‍🏍] improve codes & fix some mejor issues 🤞
2 parents 321b1c7 + 84d4350 commit e450db9

17 files changed

Lines changed: 128 additions & 127 deletions

File tree

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
---
22
name: Bug report
33
about: Create a report to help us improve
4-
title: ''
5-
labels: ''
6-
assignees: ''
7-
4+
title: ""
5+
labels: ""
6+
assignees: ""
87
---
98

109
**Describe the bug**
1110
A clear and concise description of what the bug is.
1211

1312
**To Reproduce**
1413
Steps to reproduce the behavior:
14+
1515
1. Go to '...'
1616
2. Click on '....'
1717
3. Scroll down to '....'
@@ -24,15 +24,17 @@ A clear and concise description of what you expected to happen.
2424
If applicable, add screenshots to help explain your problem.
2525

2626
**Desktop (please complete the following information):**
27-
- OS: [e.g. iOS]
28-
- Browser [e.g. chrome, safari]
29-
- Version [e.g. 22]
27+
28+
- OS: [e.g. iOS]
29+
- Browser [e.g. chrome, safari]
30+
- Version [e.g. 22]
3031

3132
**Smartphone (please complete the following information):**
32-
- Device: [e.g. iPhone6]
33-
- OS: [e.g. iOS8.1]
34-
- Browser [e.g. stock browser, safari]
35-
- Version [e.g. 22]
33+
34+
- Device: [e.g. iPhone6]
35+
- OS: [e.g. iOS8.1]
36+
- Browser [e.g. stock browser, safari]
37+
- Version [e.g. 22]
3638

3739
**Additional context**
3840
Add any other context about the problem here.

.github/ISSUE_TEMPLATE/feature_request.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
---
22
name: Feature request
33
about: Suggest an idea for this project
4-
title: ''
5-
labels: ''
6-
assignees: ''
7-
4+
title: ""
5+
labels: ""
6+
assignees: ""
87
---
98

109
**Is your feature request related to a problem? Please describe.**

package.json

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
11
{
22
"name": "finddevs",
33
"description": "Discover All Developers From The Programming World",
4-
"version": "0.2.0",
4+
"version": "1.2.1",
55
"private": false,
6+
"author": {
7+
"email": "devlopersabbir@gmail.com",
8+
"name": "Sabbir Hossain Shuvo",
9+
"url": "https://devlopersabbir.github.io"
10+
},
11+
"license": "MIT",
612
"scripts": {
713
"dev": "next dev",
814
"build": "next build",
@@ -12,7 +18,6 @@
1218
"introspect": "drizzle-kit introspect:pg",
1319
"push": "drizzle-kit push:pg",
1420
"generate": "drizzle-kit generate:pg",
15-
"migrate": "drizzle-kit migrate:pg",
1621
"drop": "drizzle-kit drop",
1722
"studio": "drizzle-kit studio --host localhost --port 3001 --verbose --config drizzle.config.ts",
1823
"seed": "cross-env DB_SEEDING=true tsx src/database/seed.ts"

src/app/layout.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export const metadata: Metadata = {
1818
icons: "/favicon/favicon.ico",
1919
authors: {
2020
name: "Sabbir Hossain Shuvo",
21-
url: "https://github.com/devlopersabbir",
21+
url: "https://devlopersabbir.github.io",
2222
},
2323
};
2424

src/components/contents/ProfileCard.tsx

Lines changed: 27 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -3,51 +3,54 @@ import { ArrowRight, MapPin } from "lucide-react";
33
import { Badge } from "../ui/badge";
44
import Link from "next/link";
55
import { Carousel, CarouselContent, CarouselItem } from "../ui/carousel";
6-
import { TNetwork, TUserSchema } from "@/types";
6+
import { TUserSchema } from "@/types";
77
import { Avatar, AvatarFallback, AvatarImage } from "../ui/avatar";
88
import { getIconComponent } from "@/constants";
99

10-
const ProfileCard = ({
11-
description,
12-
location,
13-
name,
14-
portfolio,
15-
skill,
16-
profileImage,
17-
social,
18-
}: TUserSchema) => {
10+
type User = {
11+
id: number;
12+
uuid: string | null;
13+
createdAt: Date;
14+
updatedAt: Date;
15+
};
16+
type Props = {
17+
profile: TUserSchema & User;
18+
};
19+
const ProfileCard = ({ profile }: Props) => {
1920
return (
2021
<Card className="w-full backdrop-blur-3xl shadow flex flex-col dark:bg-zinc-700 border-none transition-all ease-out duration-300">
2122
{/* header */}
2223
<CardHeader className="flex justify-between items-stretch flex-row lg:gap-4 md:gap-2 gap-1 overflow-hidden">
2324
<Avatar className="lg:w-24 md:w-20 w-16 lg:h-24 md:h-20 h-16 object-cover transition-all ease-out duration-300">
2425
<AvatarImage
25-
src={profileImage}
26+
src={profile.profileImage}
2627
className="object-fill"
27-
alt="profile photo"
28+
alt={profile.name}
2829
/>
29-
<AvatarFallback>{name.substring(0, 2).toUpperCase()}</AvatarFallback>
30+
<AvatarFallback>
31+
{profile.name.substring(0, 2).toUpperCase()}
32+
</AvatarFallback>
3033
</Avatar>
3134
<div className="flex-start w-full overflow-hidden flex-col lg:gap-1 gap-0.5">
3235
<h2 className="lg:text-2xl md:text-xl sm:text-lg text-base font-semibold text-gray-700 dark:text-zinc-200 ">
33-
{name}
36+
{profile.name}
3437
</h2>
3538
<p className="flex-center lg:gap-2 md:gap-1 gap-0 lg:text-xl md:text-lg sm:text-base text-xs">
3639
<MapPin size={16} />
37-
{location}
40+
{profile.location}
3841
</p>
3942
<Carousel className="w-full lg:mt-1.5 md:mt-0.5 mt-0">
4043
<CarouselContent
4144
id="skills"
4245
className="flex justify-start items-center"
4346
>
44-
{skill.map((sk: string, index: number) => (
45-
<CarouselItem key={index} className="w-auto basis-[-29-px]">
47+
{profile.skills.map((skill: string, i: number) => (
48+
<CarouselItem key={i} className="w-auto basis-[-29-px]">
4649
<Badge
4750
variant="secondary"
4851
className="lg:text-sm text-xs cursor-all-scroll select-none"
4952
>
50-
{sk}
53+
{skill}
5154
</Badge>
5255
</CarouselItem>
5356
))}
@@ -57,7 +60,8 @@ const ProfileCard = ({
5760

5861
<div>
5962
<Link
60-
href={portfolio ?? "https://github.com/devlopersabbir"}
63+
href={profile.portfolio ?? "https://github.com/devlopersabbir"}
64+
target="_blank"
6165
className="hover:underline text-green-600 flex gap-2 font-semibold"
6266
>
6367
<span className="lg:text-lg md:text-md sm:text-base text-xs">
@@ -70,16 +74,16 @@ const ProfileCard = ({
7074

7175
<CardContent>
7276
<p className="font-thin lg:text-lg md:text-base text-xs">
73-
{description}
77+
{profile.description}
7478
</p>
7579
<div className="flex-start mt-3 gap-4">
76-
{social?.map((net: TNetwork, i: number) => (
80+
{profile.social?.map((social, i) => (
7781
<Link
7882
key={i}
79-
href={net.link}
83+
href={social.link}
8084
className="group scale-100 duration-300 ease-out bg-red-600 hover:bg-transparent rounded-md hover:rounded-full p-1.5 text-white"
8185
>
82-
{getIconComponent(net.network as string)}
86+
{getIconComponent(social.network)}
8387
</Link>
8488
))}
8589
</div>

src/components/contents/ProfileGrid.tsx

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,17 @@ const ProfileGrid = async ({ page, searchParams }: Props) => {
1515
const currentPage = parseInt(page); // like 1
1616
const itemPerPage = 5; // we want to show 5 item in per pages
1717
const offset = (currentPage - 1) * itemPerPage; // (1 - 1) * 3 = 0
18-
const searchSkills = searchParams ? searchParams.toLowerCase().split(/[\s,]+/) : []; // regular expression to accept inputs separated by comma, space or both
18+
const searchSkills = searchParams
19+
? searchParams.toLowerCase().split(/[\s,]+/)
20+
: []; // regular expression to accept inputs separated by comma, space or both
1921

2022
// In order to get rid of the "error: operator does not exist: json @> json" I mannually cast the skills column to JSONB
21-
const skillsCondition = searchSkills.length > 0
22-
? sql.raw(`lower("skills"::text)::JSONB @> '${JSON.stringify(searchSkills.map(skill => skill.toLowerCase()))}'::JSONB`)
23-
: undefined;
23+
const skillsCondition =
24+
searchSkills.length > 0
25+
? sql.raw(
26+
`lower("skills"::text)::JSONB @> '${JSON.stringify(searchSkills.map((skill) => skill.toLowerCase()))}'::JSONB`,
27+
)
28+
: undefined;
2429

2530
const [lengths, profiles] = await Promise.all([
2631
db.select({ count: sql<number>`count(*)` }).from(users),
@@ -33,7 +38,7 @@ const ProfileGrid = async ({ page, searchParams }: Props) => {
3338
ilike(users.name, `%${searchParams}%`),
3439
ilike(users.location, `%${searchParams}%`),
3540
ilike(users.description, `%${searchParams}%`),
36-
skillsCondition
41+
skillsCondition,
3742
),
3843
)
3944
.limit(itemPerPage)
@@ -48,24 +53,14 @@ const ProfileGrid = async ({ page, searchParams }: Props) => {
4853

4954
const count = lengths[0].count;
5055
return (
51-
<div className="lg:mt-32 mt-[10rem] mb-8 border-t-orange-500 lg:ml-[20rem] px-4 lg:px-6 overflow-y-scroll relative">
56+
<div className="lg:mt-32 mt-[10rem] mb-8 border-t-orange-500 lg:ml-[20rem] px-4 lg:px-6 relative">
5257
<Search />
5358
<div className="flex-center flex-col gap-3">
5459
{count <= 0 || profiles.length === 0 ? (
5560
<Notfound />
5661
) : (
57-
profiles.map((item, index: number) => (
58-
<ProfileCard
59-
key={index}
60-
role={item.role}
61-
description={item.description}
62-
location={item.location}
63-
name={item.name}
64-
portfolio={item.portfolio as string}
65-
skill={item.skills}
66-
profileImage={item.profileImage as string}
67-
social={item.social as any}
68-
/>
62+
profiles.map((profile, i) => (
63+
<ProfileCard key={i} profile={profile} />
6964
))
7065
)}
7166
</div>

src/components/forms/CreateProfile.tsx

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
"use client";
22

33
import { Input } from "../ui/input";
4-
import { Facebook, Github, Linkedin, UploadCloud } from "lucide-react";
4+
import { UploadCloud } from "lucide-react";
5+
import { Facebook, Github, Linkedin } from "lucide-react";
56
import {
67
Form,
78
FormControl,
@@ -113,8 +114,9 @@ const CreateProfile = ({
113114
width={160}
114115
height={160}
115116
alt="profile photo"
117+
objectFit="cover"
116118
priority
117-
className="rounded-full object-contain"
119+
className="rounded-full object-cover"
118120
/>
119121
) : (
120122
<div className="flex-center w-full h-full rounded-full border-2 bg-zinc-100">
@@ -129,7 +131,7 @@ const CreateProfile = ({
129131
)}
130132
</div>
131133
)}
132-
<FormControl className="w-40 h-40 border-2 border-red-400 absolute rounded-full opacity-0">
134+
<FormControl className="w-40 h-40 border-2 border-red-400 absolute rounded-full opacity-0 cursor-pointer">
133135
<Input
134136
type="file"
135137
accept="image/*"
@@ -212,19 +214,19 @@ const CreateProfile = ({
212214
</FormLabel>
213215
{networks.map((net: TNetwork, i: number) => (
214216
<div className="relative flex-center" key={i}>
215-
{net.network === "Github" ? (
217+
{net.network === "GitHub" ? (
216218
<Github className="absolute left-2" />
217219
) : net.network === "Facebook" ? (
218220
<Facebook className="absolute left-2" />
219-
) : net.network === "Linkedin" ? (
221+
) : net.network === "LinkedIn" ? (
220222
<Linkedin className="absolute left-2" />
221223
) : null}
222224
<Input
223225
type="url"
224226
className="pl-10"
225227
id="link"
226228
onChange={(e) => {
227-
const newSocial = [...(field.value as any)];
229+
const newSocial = [...field.value];
228230
newSocial[i] = {
229231
network: net.network,
230232
link: e.target.value,
@@ -242,7 +244,7 @@ const CreateProfile = ({
242244
name="description"
243245
render={({ field }) => (
244246
<FormItem>
245-
<FormLabel className="font-semibold">About your self</FormLabel>
247+
<FormLabel className="font-semibold">About yourself</FormLabel>
246248
<FormControl>
247249
<Textarea
248250
placeholder="Tell us a little bit about yourself"

src/constants/getIconComponents.tsx

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,26 @@
1-
import { Network } from "@/utils";
2-
import { FacebookIcon, GithubIcon, LinkedinIcon } from "lucide-react";
31
import React from "react";
2+
import { Facebook, Github, Linkedin } from "lucide-react";
3+
import { TNet } from "@/types";
44

5-
export const getIconComponent = (network: string) => {
5+
export const getIconComponent = (network: TNet) => {
66
switch (network) {
7-
case Network.Facebook:
7+
case "Facebook":
88
return (
9-
<FacebookIcon
9+
<Facebook
1010
size={25}
1111
className="group-hover:scale-125 group-hover:text-rose-600 group-hover:rotate-[360deg] duration-300 ease-out"
1212
/>
1313
);
14-
case Network.Github:
14+
case "GitHub":
1515
return (
16-
<GithubIcon
16+
<Github
1717
size={25}
1818
className="group-hover:scale-125 group-hover:text-rose-600 group-hover:rotate-[360deg] duration-300 ease-out"
1919
/>
2020
);
21-
case Network.Linkedin:
21+
case "LinkedIn":
2222
return (
23-
<LinkedinIcon
23+
<Linkedin
2424
size={25}
2525
className="group-hover:scale-125 group-hover:text-rose-600 group-hover:rotate-[360deg] duration-300 ease-out"
2626
/>

src/constants/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@ import { TNetwork } from "@/types";
22

33
export const networks: TNetwork[] = [
44
{
5-
network: "Github",
5+
network: "GitHub",
66
link: "",
77
},
88
{
99
network: "Facebook",
1010
link: "",
1111
},
1212
{
13-
network: "Linkedin",
13+
network: "LinkedIn",
1414
link: "",
1515
},
1616
];

src/database/faker.ts

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { faker } from "@faker-js/faker";
2-
import { users } from "@/schemas/user";
32
import { User } from "@/schemas/user";
43

54
const generateUser = (id: number): User => ({
@@ -18,10 +17,7 @@ const generateUser = (id: number): User => ({
1817
],
1918
3
2019
),
21-
role:
22-
id === 1
23-
? "SYSTEM_ADMIN"
24-
: faker.helpers.arrayElement(["DEVELOPER", "ADMIN"]),
20+
role: faker.helpers.arrayElement(["DEVELOPER", "ADMIN"]),
2521
description: faker.lorem.paragraph(),
2622
social: [
2723
{ network: "LinkedIn", link: faker.internet.url() },
@@ -33,6 +29,6 @@ const generateUser = (id: number): User => ({
3329
updatedAt: faker.date.recent(),
3430
});
3531

36-
export const usersData: User[] = Array.from({ length: 15 }, (_, index) =>
37-
generateUser(index + 1)
32+
export const usersData: User[] = Array.from({ length: 10 }).map((_, i) =>
33+
generateUser(i + 1)
3834
);

0 commit comments

Comments
 (0)