diff --git a/client/src/config/env.ts b/client/src/config/env.ts
index d98aa344..ded48194 100644
--- a/client/src/config/env.ts
+++ b/client/src/config/env.ts
@@ -1,6 +1,6 @@
// Load environment variables from .env file
export const VITE_SERVER_DOMAIN =
- import.meta.env.VITE_SERVER_DOMAIN || 'https://code-a2z.onrender.com';
+ import.meta.env.VITE_SERVER_DOMAIN || 'https://code-a2z-server.vercel.app'; // https://code-a2z.onrender.com for production
// Token configuration
export const TOKEN_CONFIG = {
diff --git a/client/src/modules/project/components/project-content.tsx b/client/src/modules/project/components/project-content.tsx
index f6752826..c70dc97d 100644
--- a/client/src/modules/project/components/project-content.tsx
+++ b/client/src/modules/project/components/project-content.tsx
@@ -1,96 +1,161 @@
+import { useState } from 'react';
+import { Box, Typography, Button } from '@mui/material';
import { OutputBlockData } from '@editorjs/editorjs';
-const Img = ({ url, caption }: { url: string; caption: string }) => {
+const ParagraphBlock = ({ text }: { text: string }) => {
+ return ;
+};
+
+const HeaderBlock = ({ level, text }: { level: number; text: string }) => {
+ const Tag = level === 3 ? 'h3' : 'h2';
+ const size = level === 3 ? 'h5' : 'h4';
return (
-
-

- {caption.length ? (
-
- {caption}
-
- ) : (
- ''
- )}
-
+
);
};
-const Quote = ({ quote, caption }: { quote: string; caption: string }) => {
+const ImageBlock = ({ url, caption }: { url: string; caption: string }) => {
return (
-
-
{quote}
- {caption.length ? (
-
{caption}
- ) : (
- ''
+
+
+ {caption && (
+
+ {caption}
+
)}
-
+
);
};
-const List = ({
- style,
- items,
-}: {
- style: 'ordered' | 'unordered';
- items: string[];
-}) => {
+const QuoteBlock = ({ text, caption }: { text: string; caption: string }) => {
return (
-
- {items.map((listItem, i) => {
- return (
-
- );
- })}
-
+
+ {text}
+
+ {caption && (
+
+ {caption}
+
+ )}
+
);
};
-const ProjectContent = ({ block }: { block: OutputBlockData }) => {
- const { type, data } = block;
+const ListBlock = ({ style, items }: { style: string; items: string[] }) => {
+ const Tag = style === 'ordered' ? 'ol' : 'ul';
+ const styleType = style === 'ordered' ? 'decimal' : 'disc';
+ return (
+
+ {items.map((item, i) => (
+
+
+
+ ))}
+
+ );
+};
- if (type === 'paragraph') {
- return ;
- }
+const CodeBlock = ({ code, language }: { code: string; language: string }) => {
+ const codeText = code || '';
+ const [copied, setCopied] = useState(false);
- if (type === 'header') {
- if (data.level === 3) {
- return (
-
- );
+ const handleCopy = async () => {
+ try {
+ await navigator.clipboard.writeText(codeText);
+ setCopied(true);
+ setTimeout(() => setCopied(false), 2000);
+ } catch {
+ setCopied(false);
}
- return (
-
- );
- }
+ };
- if (type === 'image') {
- return
;
- }
+ return (
+
+ {language ? (
+
+ {language}
+
+ ) : null}
+
+
+ {codeText}
+
+
+ );
+};
- if (type === 'quote') {
- return
;
- }
+const ProjectContent = ({ block }: { block: OutputBlockData }) => {
+ const { type, data } = block || {};
- if (type === 'list') {
- return (
-
- );
+ switch (type) {
+ case 'paragraph':
+ return ;
+ case 'header':
+ return ;
+ case 'image':
+ return (
+
+ );
+ case 'quote':
+ return (
+
+ );
+ case 'list':
+ return ;
+ case 'code':
+ return (
+
+ );
+ default:
+ return null;
}
};
diff --git a/package.json b/package.json
index 81777c0d..b04731fc 100644
--- a/package.json
+++ b/package.json
@@ -56,7 +56,7 @@
"lint-staged": {
"client/src/**/*.{ts,tsx,js,jsx,css,html}": [
"prettier --write",
- "eslint --fix"
+ "eslint --config client/eslint.config.js --fix"
],
"server/**/*.js": [
"prettier --write",
diff --git a/server/src/config/env.js b/server/src/config/env.js
index a672393d..a257e3be 100644
--- a/server/src/config/env.js
+++ b/server/src/config/env.js
@@ -7,7 +7,9 @@ dotenv.config();
export const PORT = process.env.PORT || 8000;
export const SERVER_ENV = process.env.SERVER_ENV || 'development';
export const VITE_SERVER_DOMAIN =
- process.env.VITE_SERVER_DOMAIN || 'https://code-a2z-server.vercel.app';
+ process.env.VITE_SERVER_DOMAIN || 'http://localhost:8000';
+export const VITE_CLIENT_DOMAIN =
+ process.env.VITE_CLIENT_DOMAIN || 'http://localhost:5173';
// MongoDB Configuration
export const MONGODB_URL =
diff --git a/server/src/server.js b/server/src/server.js
index 0517b5ff..31650e16 100644
--- a/server/src/server.js
+++ b/server/src/server.js
@@ -24,8 +24,10 @@ server.use(express.json());
server.use(cookieParser());
server.use(
cors({
- origin: process.env.VITE_CLIENT_DOMAIN || 'http://localhost:5173',
+ origin: '*',
credentials: true,
+ methods: 'GET,POST,PUT,DELETE',
+ allowedHeaders: 'Content-Type,Authorization',
})
);