Skip to content

Commit 19138dc

Browse files
2 parents c6d3483 + 82c4b55 commit 19138dc

File tree

5 files changed

+62
-56
lines changed

5 files changed

+62
-56
lines changed

Diff for: frontend/src/components/category-pill.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export default function CategoryPill({ category, disabled, selected = false }: C
2020
return (
2121
<span
2222
className={twMerge(
23-
'cursor-pointer rounded-3xl px-3 py-1 text-xs font-medium text-light-primary/80 dark:text-dark-primary/80 ',
23+
'cursor-pointer rounded-3xl px-3 py-1 text-xs font-medium text-light-primary/80 dark:text-dark-primary/80 overflow-hidden whitespace-nowrap truncate',
2424
disabled ? disabledColor : getSelectedColor(selected)
2525
)}
2626
>

Diff for: frontend/src/components/post-card.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ export default function PostCard({ post, testId = 'postcard' }: { post: Post } &
3434
<p className="line-clamp-2 text-sm text-light-description dark:text-dark-description">
3535
{post.description}
3636
</p>
37-
<div className="mt-4 flex flex-wrap gap-2">
38-
{post.categories.map((category, index) => (
37+
<div className="mt-4 flex gap-2">
38+
{post.categories.slice(0, 3).map((category, index) => (
3939
<CategoryPill key={`${category}-${index}`} category={category} />
4040
))}
4141
</div>

Diff for: frontend/src/pages/signin-page.tsx

+29-26
Original file line numberDiff line numberDiff line change
@@ -10,51 +10,51 @@ import { toast } from 'react-toastify';
1010
import { AxiosError, isAxiosError } from 'axios';
1111
import axiosInstance from '@/helpers/axios-instance';
1212
import userState from '@/utils/user-state';
13-
13+
import ThemeToggle from '@/components/theme-toggle-button';
1414
function signin() {
1515
const navigate = useNavigate();
1616
const {
1717
register,
1818
handleSubmit,
1919
formState: { errors, isSubmitting },
2020
reset,
21-
setError
21+
setError,
2222
} = useForm<TSignInSchema>({ resolver: zodResolver(signInSchema) });
2323

2424
const onSubmit = async (data: FieldValues) => {
2525
try {
26-
const response = axiosInstance.post('/api/auth/email-password/signin',
27-
data
28-
);
26+
const response = axiosInstance.post('/api/auth/email-password/signin', data);
2927

3028
toast.promise(response, {
3129
pending: 'Checking credentials ...',
3230
success: {
3331
render({ data }) {
3432
const userId = data?.data?.data?.user?._id;
3533
const userRole = data?.data?.data?.user?.role;
36-
userState.setUser({ _id: userId, role: userRole })
37-
reset()
38-
navigate('/')
39-
return data?.data?.message
34+
userState.setUser({ _id: userId, role: userRole });
35+
reset();
36+
navigate('/');
37+
return data?.data?.message;
4038
},
4139
},
4240
error: {
4341
render({ data }) {
4442
if (data instanceof AxiosError) {
4543
if (data?.response?.data?.message.includes('User')) {
46-
setError('userNameOrEmail',{ type: 'manual', message: data?.response?.data?.message});
44+
setError('userNameOrEmail', {
45+
type: 'manual',
46+
message: data?.response?.data?.message,
47+
});
4748
} else {
48-
setError("password",{ type: 'manual', message: data?.response?.data?.message});
49+
setError('password', { type: 'manual', message: data?.response?.data?.message });
4950
}
5051
}
51-
return "Signin failed"
52+
return 'Signin failed';
5253
},
5354
},
54-
}
55-
)
55+
});
5656

57-
return (await response).data
57+
return (await response).data;
5858
} catch (error) {
5959
if (isAxiosError(error)) {
6060
console.error(error.response?.data?.message);
@@ -65,12 +65,15 @@ function signin() {
6565
};
6666

6767
return (
68-
<div className="m-4 flex-grow cursor-default bg-white py-4">
69-
<div className="mb-4 flex justify-center">
68+
<div className="flex-grow cursor-default bg-white py-4 dark:bg-dark-card">
69+
<div className="m-4 mb-4 flex justify-center">
7070
<div className="flex w-full items-center justify-center">
71-
<h2 className="w-3/4 text-center text-lg font-bold text-black sm:text-xl">
71+
<h2 className="w-3/4 pl-48 text-center text-lg font-bold text-black dark:text-dark-primary sm:text-xl">
7272
Sign in to WanderLust
7373
</h2>
74+
<div className="flex items-center justify-end px-4 sm:px-20">
75+
<ThemeToggle />
76+
</div>
7477
</div>
7578
</div>
7679
<div className="m-2 mt-8 flex flex-col items-center justify-center gap-2">
@@ -80,7 +83,7 @@ function signin() {
8083
{...register('userNameOrEmail')}
8184
type="text"
8285
placeholder="Username or Email"
83-
className="w-full rounded-lg bg-zinc-100 p-3 font-normal placeholder:text-sm placeholder:text-neutral-500"
86+
className="w-full rounded-lg bg-zinc-100 p-3 font-normal placeholder:text-sm dark:bg-dark-field dark:text-dark-textInField"
8487
/>
8588
{errors.userNameOrEmail && (
8689
<p className="p-3 text-xs text-red-500">{`${errors.userNameOrEmail.message}`}</p>
@@ -92,7 +95,7 @@ function signin() {
9295
{...register('password')}
9396
type="password"
9497
placeholder="Password"
95-
className="w-full rounded-lg bg-zinc-100 p-3 font-normal placeholder:text-sm placeholder:text-neutral-500"
98+
className="w-full rounded-lg bg-zinc-100 p-3 font-normal placeholder:text-sm dark:bg-dark-field dark:text-dark-textInField"
9699
/>
97100
{errors.password && (
98101
<p className="p-3 text-xs text-red-500">{`${errors.password.message}`}</p>
@@ -102,12 +105,12 @@ function signin() {
102105
<button
103106
disabled={isSubmitting}
104107
type="submit"
105-
className="flex w-full items-center justify-center rounded-lg bg-neutral-800 p-3 text-base font-medium text-light disabled:bg-neutral-600 sm:text-lg sm:font-semibold"
108+
className="flex w-full items-center justify-center rounded-lg bg-neutral-800 p-3 text-base font-medium text-light disabled:bg-neutral-600 dark:bg-dark-button sm:text-lg sm:font-semibold"
106109
>
107110
Log In
108111
</button>
109112
</form>
110-
<div className="mt-2 flex w-5/6 flex-col items-center justify-center gap-4 text-center text-sm font-normal sm:text-base">
113+
<div className="mt-2 flex w-5/6 flex-col items-center justify-center gap-4 text-center text-sm font-normal dark:text-dark-primary sm:text-base">
111114
<p>
112115
Don't have an account?
113116
<Link to={'/signup'} className="text-blue-600 hover:text-blue-500">
@@ -121,18 +124,18 @@ function signin() {
121124

122125
<Link
123126
to={'/google-auth'}
124-
className="flex w-full items-center justify-center space-x-2 rounded-lg border-2 border-b-4 border-gray-300 p-3 text-center hover:bg-gray-50 md:w-3/4 lg:w-2/5"
127+
className="flex w-full items-center justify-center space-x-2 rounded-lg border-2 border-b-4 border-gray-300 p-3 text-center hover:bg-gray-50 dark:border-gray-700 dark:hover:bg-gray-700 md:w-3/4 lg:w-2/5"
125128
>
126129
<img className="h-4 w-6 pl-1 sm:h-5 sm:w-10" src={AddGoogleIcon} />
127-
<span className="text-sm sm:text-base">Continue with Google</span>
130+
<span className="text-sm dark:text-dark-primary sm:text-base">Continue with Google</span>
128131
</Link>
129132

130133
<Link
131134
to={'/github-auth'}
132-
className="flex w-full items-center justify-center space-x-2 rounded-lg border-2 border-b-4 border-gray-300 p-3 text-center hover:bg-gray-50 md:w-3/4 lg:w-2/5"
135+
className="flex w-full items-center justify-center space-x-2 rounded-lg border-2 border-b-4 border-gray-300 p-3 text-center hover:bg-gray-50 dark:border-gray-700 dark:hover:bg-gray-700 md:w-3/4 lg:w-2/5"
133136
>
134137
<img className="h-4 w-6 sm:h-5 sm:w-10" src={AddGithubIcon} />
135-
<span className="text-sm sm:text-base">Continue with Github</span>
138+
<span className="text-sm dark:text-dark-primary sm:text-base">Continue with Github</span>
136139
</Link>
137140
</div>
138141
</div>

Diff for: frontend/src/pages/signup-page.tsx

+27-27
Original file line numberDiff line numberDiff line change
@@ -10,48 +10,46 @@ import { toast } from 'react-toastify';
1010
import { AxiosError, isAxiosError } from 'axios';
1111
import axiosInstance from '@/helpers/axios-instance';
1212
import userState from '@/utils/user-state';
13-
13+
import ThemeToggle from '@/components/theme-toggle-button';
1414
function signup() {
1515
const navigate = useNavigate();
1616
const {
1717
register,
1818
handleSubmit,
1919
formState: { errors, isSubmitting },
2020
reset,
21-
setError
21+
setError,
2222
} = useForm<TSignUpSchema>({ resolver: zodResolver(signUpSchema) });
2323

2424
const onSubmit = async (data: FieldValues) => {
2525
try {
26-
const res = axiosInstance.post('/api/auth/email-password/signup', data)
26+
const res = axiosInstance.post('/api/auth/email-password/signup', data);
2727
toast.promise(res, {
2828
pending: 'Creating account ...',
2929
success: {
3030
render({ data }) {
3131
const userId = data?.data?.data?.user?._id;
3232
const userRole = data?.data?.data?.user?.role;
33-
userState.setUser({ _id: userId, role: userRole })
34-
reset()
35-
navigate('/')
36-
return data?.data?.message
33+
userState.setUser({ _id: userId, role: userRole });
34+
reset();
35+
navigate('/');
36+
return data?.data?.message;
3737
},
3838
},
3939
error: {
4040
render({ data }) {
4141
if (data instanceof AxiosError) {
4242
if (data?.response?.data?.message.includes('Username')) {
43-
setError('userName',{ type: 'manual', message: data?.response?.data?.message });
43+
setError('userName', { type: 'manual', message: data?.response?.data?.message });
4444
} else {
45-
setError('email',{ type: 'manual', message: data?.response?.data?.message });
45+
setError('email', { type: 'manual', message: data?.response?.data?.message });
4646
}
4747
}
48-
return "Signup failed"
48+
return 'Signup failed';
4949
},
5050
},
51-
}
52-
)
53-
return (await res).data
54-
51+
});
52+
return (await res).data;
5553
} catch (error) {
5654
if (isAxiosError(error)) {
5755
console.error(error.response?.data?.message);
@@ -61,14 +59,16 @@ function signup() {
6159
}
6260
};
6361

64-
6562
return (
66-
<div className="m-4 flex-grow cursor-default bg-white py-4">
67-
<div className="mb-4 flex justify-center">
63+
<div className="flex-grow cursor-default bg-white py-4 dark:bg-dark-card">
64+
<div className="m-4 mb-4 flex justify-center">
6865
<div className="flex w-full items-center justify-center">
69-
<h2 className="w-3/4 text-center text-lg font-bold text-black sm:text-xl">
66+
<h2 className="w-3/4 pl-48 text-center text-lg font-bold text-black dark:text-dark-primary sm:text-xl">
7067
Sign up to WanderLust
7168
</h2>
69+
<div className="flex items-center justify-end px-4 sm:px-20">
70+
<ThemeToggle />
71+
</div>
7272
</div>
7373
</div>
7474
<div className="m-2 mt-8 flex flex-col items-center justify-center gap-2">
@@ -78,7 +78,7 @@ function signup() {
7878
{...register('userName')}
7979
type="text"
8080
placeholder="Username"
81-
className="w-full rounded-lg bg-zinc-100 p-3 font-normal placeholder:text-sm placeholder:text-neutral-500"
81+
className="dark:placholder w-full rounded-lg bg-zinc-100 p-3 font-normal placeholder:text-sm dark:bg-dark-field dark:text-dark-textInField"
8282
/>
8383
{errors.userName && (
8484
<p className="p-3 text-xs text-red-500">{`${errors.userName.message}`}</p>
@@ -89,7 +89,7 @@ function signup() {
8989
{...register('fullName')}
9090
type="text"
9191
placeholder="Name"
92-
className="w-full rounded-lg bg-zinc-100 p-3 font-normal placeholder:text-sm placeholder:text-neutral-500"
92+
className="w-full rounded-lg bg-zinc-100 p-3 font-normal placeholder:text-sm dark:bg-dark-field dark:text-dark-textInField"
9393
/>
9494
{errors.fullName && (
9595
<p className="p-3 text-xs text-red-500">{`${errors.fullName.message}`}</p>
@@ -100,7 +100,7 @@ function signup() {
100100
{...register('email')}
101101
type="email"
102102
placeholder="Email"
103-
className="w-full rounded-lg bg-zinc-100 p-3 font-normal placeholder:text-sm placeholder:text-neutral-500"
103+
className="w-full rounded-lg bg-zinc-100 p-3 font-normal placeholder:text-sm dark:bg-dark-field dark:text-dark-textInField"
104104
/>
105105
{errors.email && (
106106
<p className="p-3 text-xs text-red-500">{`${errors.email.message}`}</p>
@@ -111,7 +111,7 @@ function signup() {
111111
{...register('password')}
112112
type="password"
113113
placeholder="Password"
114-
className="w-full rounded-lg bg-zinc-100 p-3 font-normal placeholder:text-sm placeholder:text-neutral-500"
114+
className="w-full rounded-lg bg-zinc-100 p-3 font-normal placeholder:text-sm dark:bg-dark-field dark:text-dark-textInField"
115115
/>
116116
{errors.password && (
117117
<p className="p-3 text-xs text-red-500">{`${errors.password.message}`}</p>
@@ -122,7 +122,7 @@ function signup() {
122122
{...register('confirmPassword')}
123123
type="password"
124124
placeholder="Confirm Password"
125-
className="w-full rounded-lg bg-zinc-100 p-3 font-normal placeholder:text-sm placeholder:text-neutral-500"
125+
className="w-full rounded-lg bg-zinc-100 p-3 font-normal placeholder:text-sm dark:bg-dark-field dark:text-dark-textInField"
126126
/>
127127
{errors.confirmPassword && (
128128
<p className="p-3 text-xs text-red-500">{`${errors.confirmPassword.message}`}</p>
@@ -131,12 +131,12 @@ function signup() {
131131
<button
132132
disabled={isSubmitting}
133133
type="submit"
134-
className="flex w-full items-center justify-center rounded-lg bg-neutral-800 p-3 text-base font-medium text-light disabled:bg-neutral-600 sm:text-lg sm:font-semibold"
134+
className="flex w-full items-center justify-center rounded-lg bg-neutral-800 p-3 text-base font-medium text-light disabled:bg-neutral-600 dark:bg-dark-button sm:text-lg sm:font-semibold"
135135
>
136136
Sign Up
137137
</button>
138138
</form>
139-
<div className="mt-2 flex w-5/6 flex-col items-center justify-center gap-4 text-center text-sm font-normal sm:text-base">
139+
<div className="mt-2 flex w-5/6 flex-col items-center justify-center gap-4 text-center text-sm font-normal dark:text-dark-primary sm:text-base">
140140
<p>
141141
Already have an account?
142142
<Link to={'/signin'} className="text-blue-600 hover:text-blue-500">
@@ -150,15 +150,15 @@ function signup() {
150150

151151
<Link
152152
to={'/google-auth'}
153-
className="flex w-full items-center justify-center space-x-2 rounded-lg border-2 border-b-4 border-gray-300 p-3 text-center hover:bg-gray-50 md:w-3/4 lg:w-2/5"
153+
className="flex w-full items-center justify-center space-x-2 rounded-lg border-2 border-b-4 border-gray-300 p-3 text-center hover:bg-gray-50 dark:border-gray-700 dark:text-dark-primary dark:hover:bg-gray-700 md:w-3/4 lg:w-2/5"
154154
>
155155
<img className="h-4 w-6 pl-1 sm:h-5 sm:w-10" src={AddGoogleIcon} />
156156
<span className="text-sm sm:text-base">Continue with Google</span>
157157
</Link>
158158

159159
<Link
160160
to={'/github-auth'}
161-
className="flex w-full items-center justify-center space-x-2 rounded-lg border-2 border-b-4 border-gray-300 p-3 text-center hover:bg-gray-50 md:w-3/4 lg:w-2/5"
161+
className="flex w-full items-center justify-center space-x-2 rounded-lg border-2 border-b-4 border-gray-300 p-3 text-center hover:bg-gray-50 dark:border-gray-700 dark:text-dark-primary dark:hover:bg-gray-700 md:w-3/4 lg:w-2/5"
162162
>
163163
<img className="h-4 w-6 sm:h-5 sm:w-10" src={AddGithubIcon} />
164164
<span className="text-sm sm:text-base">Continue with Github</span>

Diff for: frontend/tailwind.config.js

+3
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ export default {
1717
title: colors.slate[50],
1818
description: colors.slate[400],
1919
info: colors.slate[500],
20+
field: colors.slate[900],
21+
button: colors.slate[700],
22+
textInField: colors.slate[50]
2023
},
2124
light: {
2225
DEFAULT: colors.slate[50],

0 commit comments

Comments
 (0)