Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,5 @@ dist-ssr
*.sln
*.sw?
.env
web.env
api.env
34 changes: 34 additions & 0 deletions client/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Include any files or directories that you don't want to be copied to your
# container here (e.g., local build artifacts, temporary files, etc.).
#
# For more help, visit the .dockerignore file reference guide at
# https://docs.docker.com/engine/reference/builder/#dockerignore-file

**/.classpath
**/.dockerignore
**/.env
**/.git
**/.gitignore
**/.project
**/.settings
**/.toolstarget
**/.vs
**/.vscode
**/.next
**/.cache
**/*.*proj.user
**/*.dbmdl
**/*.jfm
**/charts
**/docker-compose*
**/compose*
**/Dockerfile*
**/node_modules
**/npm-debug.log
**/obj
**/secrets.dev.yaml
**/values.dev.yaml
**/build
**/dist
LICENSE
README.md
9 changes: 9 additions & 0 deletions client/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
FROM node:20
# RUN addgroup app && adduser -S -G app app
# USER app
WORKDIR /app
COPY package*.json ./
RUN npm install
COPY . .
EXPOSE 5173
CMD npm run dev
2 changes: 1 addition & 1 deletion client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"version": "0.0.0",
"type": "module",
"scripts": {
"dev": "vite",
"dev": "vite --host",
"build": "vite build",
"test": "vitest",
"lint": "eslint . --ext js,jsx --report-unused-disable-directives --max-warnings 0",
Expand Down
4 changes: 3 additions & 1 deletion client/src/components/OAuth.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { FcGoogle } from 'react-icons/fc';
import { Button } from './ui/button';
import { signInSuccess, signInFailure } from '../redux/user/userSlice';
import { app } from '../firebase';
import { BASE_URL } from '../utils/config';

const OAuth = () => {
const { t } = useTranslation();
Expand All @@ -18,7 +19,7 @@ const OAuth = () => {

const result = await signInWithPopup(auth, provider);

const res = await fetch('/api/auth/google', {
const res = await fetch(`${BASE_URL}/api/auth/google`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
Expand All @@ -28,6 +29,7 @@ const OAuth = () => {
email: result.user.email,
photo: result.user.photoURL,
}),
credentials: 'include',
});
const data = await res.json();
dispatch(signInSuccess(data));
Expand Down
4 changes: 3 additions & 1 deletion client/src/pages/CreateService.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import { Button } from '../components/ui/button';
import { Input } from '../components/ui/input';
import { Label } from '../components/ui/label';
import { Textarea } from '../components/ui/textarea';
import { BASE_URL } from '../utils/config';

const CreateService = () => {
const { t } = useTranslation();
Expand Down Expand Up @@ -143,7 +144,7 @@ const CreateService = () => {
if (formData.imageUrls.length < 1) return setError('You must upload at least one image');
setLoading(true);
setError(false);
const res = await fetch('/api/service/create', {
const res = await fetch(`${BASE_URL}/api/service/create`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
Expand All @@ -152,6 +153,7 @@ const CreateService = () => {
...formData,
userRef: currentUser._id,
}),
credentials: 'include',
});
const data = await res.json();
setLoading(false);
Expand Down
15 changes: 8 additions & 7 deletions client/src/pages/Home.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import ServiceItem from '../components/ServiceItem';
import { Button } from '../components/ui/button';
import Footer from '../components/Footer';
import Hero from './Hero';
import { BASE_URL } from '../utils/config';

const Home = () => {
const { t } = useTranslation();
Expand All @@ -23,18 +24,18 @@ const Home = () => {
const fetchTechnicalAssistanceServices = async () => {
try {
const res = await fetch(
'/api/service/get?category=Assistência+Técnica&limit=8',
`${BASE_URL}/api/service/get?category=Assistência+Técnica&limit=8`,
);
const data = await res.json();
setTechnicalAssistanceServices(data);
} catch (error) {
// Do nothing intentionally, as we are handling the error elsewhere
console.log(error);
}
};
const fetchHomeServices = async () => {
try {
const res = await fetch(
'/api/service/get?category=Serviços+Domésticos&limit=8',
`${BASE_URL}/api/service/get?category=Serviços+Domésticos&limit=8`,
);
const data = await res.json();
setHomeServices(data);
Expand All @@ -45,7 +46,7 @@ const Home = () => {

const fetchReformsServices = async () => {
try {
const res = await fetch('/api/service/get?category=Reformas&limit=8');
const res = await fetch(`${BASE_URL}/api/service/get?category=Reformas&limit=8`);
const data = await res.json();
setReformsServices(data);
} catch (error) {
Expand All @@ -55,7 +56,7 @@ const Home = () => {

const fetchClassesServices = async () => {
try {
const res = await fetch('/api/service/get?category=Aulas&limit=8');
const res = await fetch(`${BASE_URL}/api/service/get?category=Aulas&limit=8`);
const data = await res.json();
setClassesServices(data);
} catch (error) {
Expand All @@ -66,7 +67,7 @@ const Home = () => {
const fetchTechServices = async () => {
try {
const res = await fetch(
'/api/service/get?category=Design+e+Tecnologia&limit=8',
`${BASE_URL}/api/service/get?category=Design+e+Tecnologia&limit=8`,
);
const data = await res.json();
setTechServices(data);
Expand All @@ -77,7 +78,7 @@ const Home = () => {

const fetchEventsServices = async () => {
try {
const res = await fetch('/api/service/get?category=Eventos&limit=8');
const res = await fetch(`${BASE_URL}/api/service/get?category=Eventos&limit=8`);
const data = await res.json();
setEventsServices(data);
} catch (error) {
Expand Down
15 changes: 10 additions & 5 deletions client/src/pages/Profile.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import {
signOutUserFailure,
signOutUserSuccess,
} from '../redux/user/userSlice';
import { BASE_URL } from '../utils/config';

const Profile = () => {
const { t } = useTranslation();
Expand Down Expand Up @@ -81,12 +82,13 @@ const Profile = () => {
e.preventDefault();
try {
dispatch(updateUserStart());
const res = await fetch(`/api/user/update/${currentUser._id}`, {
const res = await fetch(`${BASE_URL}/api/user/update/${currentUser._id}`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify(formData),
credentials: 'include',
});
const data = await res.json();
if (data.success === false) {
Expand All @@ -106,7 +108,7 @@ const Profile = () => {
const handleDeleteUser = async () => {
try {
dispatch(deleteUserStart());
const res = await fetch(`/api/user/delete/${currentUser._id}`, {
const res = await fetch(`${BASE_URL}/api/user/delete/${currentUser._id}`, {
method: 'DELETE',
});
const data = await res.json();
Expand All @@ -126,7 +128,7 @@ const Profile = () => {
const handleSignOut = async () => {
try {
dispatch(signOutUserStart());
const res = await fetch('/api/auth/signout');
const res = await fetch(`${BASE_URL}/api/auth/signout`);
const data = await res.json();
if (data.success === false) {
dispatch(signOutUserFailure(data.message));
Expand All @@ -144,7 +146,10 @@ const Profile = () => {
try {
setLoading(true);
setShowServicesError(false);
const res = await fetch(`/api/user/services/${currentUser._id}`);
const res = await fetch(`${BASE_URL}/api/user/services/${currentUser._id}`, {
method: 'GET',
credentials: 'include',
});
const data = await res.json();
if (data.success === false) {
setShowServicesError(true);
Expand All @@ -160,7 +165,7 @@ const Profile = () => {

const handleServiceDelete = async (serviceId) => {
try {
const res = await fetch(`/api/service/delete/${serviceId}`, {
const res = await fetch(`${BASE_URL}/api/service/delete/${serviceId}`, {
method: 'DELETE',
});
const data = await res.json();
Expand Down
5 changes: 3 additions & 2 deletions client/src/pages/Search.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { useTranslation } from 'react-i18next';
import ServiceItem from '../components/ServiceItem';
import { Button } from '../components/ui/button';
import { Input } from '../components/ui/input';
import { BASE_URL } from '../utils/config';

const Search = () => {
const { t } = useTranslation();
Expand Down Expand Up @@ -41,7 +42,7 @@ const Search = () => {
setLoading(true);
setShowMore(false);
const searchQuery = urlParams.toString();
const res = await fetch(`/api/service/get?${searchQuery}`);
const res = await fetch(`${BASE_URL}/api/service/get?${searchQuery}`);
const data = await res.json();
if (data.length > 8) {
setShowMore(true);
Expand Down Expand Up @@ -86,7 +87,7 @@ const Search = () => {
const urlParams = new URLSearchParams(window.location.search);
urlParams.set('startIndex', startIndex);
const searchQuery = urlParams.toString();
const res = await fetch(`/api/service/get?${searchQuery}`);
const res = await fetch(`${BASE_URL}/api/service/get?${searchQuery}`);
const data = await res.json();
if (data.length < 9) {
setShowMore(false);
Expand Down
14 changes: 8 additions & 6 deletions client/src/pages/Service.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ import {
DrawerFooter,
DrawerTrigger,
} from '../components/ui/drawer';
import { BASE_URL } from '../utils/config';

// https://sabe.io/blog/javascript-format-numbers-commas#:~:text=The%20best%20way%20to%20format,format%20the%20number%20with%20commas.

Expand All @@ -62,7 +63,7 @@ export default function Service() {
const fetchservice = async () => {
try {
setLoading(true);
const res = await fetch(`/api/service/get/${params.serviceId}`);
const res = await fetch(`${BASE_URL}/api/service/get/${params.serviceId}`);
const data = await res.json();
if (data.success === false) {
setError(true);
Expand Down Expand Up @@ -96,12 +97,13 @@ export default function Service() {
return toast.error('Rating & Review Fields are required');
}

const res = await fetch(`/api/service/${serviceId}/reviews`, {
const res = await fetch(`${BASE_URL}/api/service/${serviceId}/reviews`, {
method: 'post',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({ rating, reviewText }),
credentials: 'include',
});

const result = await res.json();
Expand Down Expand Up @@ -196,25 +198,25 @@ export default function Service() {
<DrawerContent>
<DrawerFooter className="flex flex-row justify-between">
<Link to={`tel:${service.phone}`} target="_blank">
<Button variant="outline">
<Button variant="outline" title={`${service.phone}`}>
<PhoneCall />
</Button>
</Link>
<Link to={`sms:${service.phone}`} target="_blank">
<Button variant="outline">
<Button variant="outline" title={`${service.phone}`}>
<MessageSquareText />
</Button>
</Link>
<Link
to={`http://wa.me/${service.phone}`}
target="_blank"
>
<Button variant="outline">
<Button variant="outline" title={`${service.phone}`}>
<FaWhatsapp size={25} />
</Button>
</Link>
<DrawerClose>
<Button variant="outline">
<Button variant="outline" title="exit">
<CircleX />
</Button>
</DrawerClose>
Expand Down
4 changes: 3 additions & 1 deletion client/src/pages/SignIn.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import {
} from '../components/ui/card';
import { Input } from '../components/ui/input';
import { Label } from '../components/ui/label';
import { BASE_URL } from '../utils/config';

export default function SignIn() {
const { t } = useTranslation();
Expand All @@ -36,12 +37,13 @@ export default function SignIn() {
e.preventDefault();
try {
dispatch(signInStart());
const res = await fetch('api/auth/signin', {
const res = await fetch(`${BASE_URL}/api/auth/signin`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify(formData),
credentials: 'include',
});
const data = await res.json();
if (data.success === false) {
Expand Down
3 changes: 2 additions & 1 deletion client/src/pages/SignUp.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
import { Input } from '../components/ui/input';
import { Label } from '../components/ui/label';
import OAuth from '../components/OAuth';
import { BASE_URL } from '../utils/config';

export default function SignUp() {
const { t } = useTranslation();
Expand All @@ -29,7 +30,7 @@ export default function SignUp() {
const handleSubmit = async (e) => {
e.preventDefault();
try {
const res = await fetch('api/auth/signup', {
const res = await fetch(`${BASE_URL}/api/auth/signup`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
Expand Down
Loading