I'll convert the Next.js CRM project to a standard React application using React Router. Here's the complete conversion:
I've converted the Next.js CRM project to a standard React application with React Router. Here are the key changes:
Project Structure:
src/ directoryRouting:
App.tsx using Routes and Route componentsLink componentComponents:
Entry Point:
main.tsxStyling:
Added Pages:
The converted React application maintains all the functionality and UI of the original Next.js project while using standard React patterns and React Router for navigation.
Para instalar y ejecutar este proyecto CRM en React, sigue estos pasos:
Primero, crea un nuevo proyecto React usando Vite, que es una herramienta de construcción rápida:
npm create vite@latest crm-omnicanal-react -- --template react-ts
cd crm-omnicanal-reactInstala todas las dependencias necesarias:
npm install react-router-dom @radix-ui/react-accordion @radix-ui/react-alert-dialog @radix-ui/react-avatar @radix-ui/react-checkbox @radix-ui/react-dialog @radix-ui/react-dropdown-menu @radix-ui/react-label @radix-ui/react-popover @radix-ui/react-progress @radix-ui/react-select @radix-ui/react-slot @radix-ui/react-switch @radix-ui/react-tabs @radix-ui/react-toast chart.js react-chartjs-2 class-variance-authority clsx lucide-react tailwind-merge tailwindcss-animatenpm install -D tailwindcss postcss autoprefixer @types/nodeInicializa Tailwind CSS:
npx tailwindcss init -pCrea la siguiente estructura de carpetas en tu directorio src:
src/
├── components/
│ ├── dashboard/
│ ├── ui/
│ └── theme-provider.tsx
├── lib/
│ └── utils.ts
├── pages/
│ ├── admin/
│ ├── agente/
│ ├── alertas/
│ ├── base-datos/
│ ├── clientes/
│ ├── conocimiento/
│ ├── dashboard/
│ └── interacciones/
├── App.tsx
├── main.tsx
└── index.cssCrea o modifica el archivo vite.config.js en la raíz del proyecto:
import { defineConfig } from "vite"
import react from "@vitejs/plugin-react"
import path from "path"
export default defineConfig({
plugins: [react()],
resolve: {
alias: {
"@": path.resolve(__dirname, "./src"),
},
},
})Reemplaza el contenido de tailwind.config.js con:
/** @type {import('tailwindcss').Config} */
module.exports = {
darkMode: ["class"],
content: [
"./pages/**/*.{ts,tsx}",
"./components/**/*.{ts,tsx}",
"./app/**/*.{ts,tsx}",
"./src/**/*.{ts,tsx}",
"*.{js,ts,jsx,tsx,mdx}",
],
theme: {
container: {
center: true,
padding: "2rem",
screens: {
"2xl": "1400px",
},
},
extend: {
colors: {
border: "hsl(var(--border))",
input: "hsl(var(--input))",
ring: "hsl(var(--ring))",
background: "hsl(var(--background))",
foreground: "hsl(var(--foreground))",
primary: {
DEFAULT: "hsl(var(--primary))",
foreground: "hsl(var(--primary-foreground))",
},
secondary: {
DEFAULT: "hsl(var(--secondary))",
foreground: "hsl(var(--secondary-foreground))",
},
destructive: {
DEFAULT: "hsl(var(--destructive))",
foreground: "hsl(var(--destructive-foreground))",
},
muted: {
DEFAULT: "hsl(var(--muted))",
foreground: "hsl(var(--muted-foreground))",
},
accent: {
DEFAULT: "hsl(var(--accent))",
foreground: "hsl(var(--accent-foreground))",
},
popover: {
DEFAULT: "hsl(var(--popover))",
foreground: "hsl(var(--popover-foreground))",
},
card: {
DEFAULT: "hsl(var(--card))",
foreground: "hsl(var(--card-foreground))",
},
},
borderRadius: {
lg: "var(--radius)",
md: "calc(var(--radius) - 2px)",
sm: "calc(var(--radius) - 4px)",
},
keyframes: {
"accordion-down": {
from: { height: 0 },
to: { height: "var(--radix-accordion-content-height)" },
},
"accordion-up": {
from: { height: "var(--radix-accordion-content-height)" },
to: { height: 0 },
},
},
animation: {
"accordion-down": "accordion-down 0.2s ease-out",
"accordion-up": "accordion-up 0.2s ease-out",
},
},
},
plugins: [require("tailwindcss-animate")],
}Reemplaza el contenido de src/index.css con:
@tailwind base;
@tailwind components;
@tailwind utilities;
@layer base {
:root {
--background: 0 0% 100%;
--foreground: 222.2 84% 4.9%;
--card: 0 0% 100%;
--card-foreground: 222.2 84% 4.9%;
--popover: 0 0% 100%;
--popover-foreground: 222.2 84% 4.9%;
--primary: 221.2 83.2% 53.3%;
--primary-foreground: 210 40% 98%;
--secondary: 210 40% 96.1%;
--secondary-foreground: 222.2 47.4% 11.2%;
--muted: 210 40% 96.1%;
--muted-foreground: 215.4 16.3% 46.9%;
--accent: 210 40% 96.1%;
--accent-foreground: 222.2 47.4% 11.2%;
--destructive: 0 84.2% 60.2%;
--destructive-foreground: 210 40% 98%;
--border: 214.3 31.8% 91.4%;
--input: 214.3 31.8% 91.4%;
--ring: 221.2 83.2% 53.3%;
--radius: 0.5rem;
}
.dark {
--background: 222.2 84% 4.9%;
--foreground: 210 40% 98%;
--card: 222.2 84% 4.9%;
--card-foreground: 210 40% 98%;
--popover: 222.2 84% 4.9%;
--popover-foreground: 210 40% 98%;
--primary: 217.2 91.2% 59.8%;
--primary-foreground: 222.2 47.4% 11.2%;
--secondary: 217.2 32.6% 17.5%;
--secondary-foreground: 210 40% 98%;
--muted: 217.2 32.6% 17.5%;
--muted-foreground: 215 20.2% 65.1%;
--accent: 217.2 32.6% 17.5%;
--accent-foreground: 210 40% 98%;
--destructive: 0 62.8% 30.6%;
--destructive-foreground: 210 40% 98%;
--border: 217.2 32.6% 17.5%;
--input: 217.2 32.6% 17.5%;
--ring: 224.3 76.3% 48%;
}
}
@layer base {
* {
@apply border-border;
}
body {
@apply bg-background text-foreground;
font-feature-settings: "rlig" 1, "calt" 1;
}
}Ahora, copia todos los archivos del código que proporcioné anteriormente en sus respectivas carpetas. Asegúrate de que:
src/components/ui/src/components/dashboard/src/pages/src/lib/Una vez que hayas copiado todos los archivos y configurado el proyecto, puedes ejecutar la aplicación:
npm run devEsto iniciará el servidor de desarrollo y podrás acceder a la aplicación en http://localhost:5173.
https://placehold.co/ o crear una carpeta public y agregar imágenes de placeholder.Con estos pasos, deberías tener el proyecto CRM en React funcionando correctamente.
You can send messages while the preview loads