Primero
This commit is contained in:
@@ -0,0 +1,9 @@
|
|||||||
|
root = true
|
||||||
|
|
||||||
|
[*]
|
||||||
|
charset = utf-8
|
||||||
|
indent_style = space
|
||||||
|
indent_size = 2
|
||||||
|
end_of_line = lf
|
||||||
|
insert_final_newline = true
|
||||||
|
trim_trailing_whitespace = true
|
||||||
+63
@@ -0,0 +1,63 @@
|
|||||||
|
|
||||||
|
# Dependencies
|
||||||
|
node_modules/
|
||||||
|
|
||||||
|
# Build output
|
||||||
|
dist/
|
||||||
|
build/
|
||||||
|
|
||||||
|
# Environment variables
|
||||||
|
.env
|
||||||
|
.env.local
|
||||||
|
.env.development.local
|
||||||
|
.env.test.local
|
||||||
|
.env.production.local
|
||||||
|
|
||||||
|
# Keep example environment files
|
||||||
|
!.env.example
|
||||||
|
|
||||||
|
# Logs
|
||||||
|
logs/
|
||||||
|
*.log
|
||||||
|
npm-debug.log*
|
||||||
|
yarn-debug.log*
|
||||||
|
pnpm-debug.log*
|
||||||
|
|
||||||
|
# Cache
|
||||||
|
.cache/
|
||||||
|
.vite/
|
||||||
|
.eslintcache
|
||||||
|
*.tsbuildinfo
|
||||||
|
|
||||||
|
# Testing
|
||||||
|
coverage/
|
||||||
|
|
||||||
|
# System files
|
||||||
|
.DS_Store
|
||||||
|
Thumbs.db
|
||||||
|
Desktop.ini
|
||||||
|
|
||||||
|
# IDEs and editors
|
||||||
|
.vscode/*
|
||||||
|
!.vscode/extensions.json
|
||||||
|
!.vscode/settings.json
|
||||||
|
.idea/
|
||||||
|
*.swp
|
||||||
|
*.swo
|
||||||
|
|
||||||
|
# Debug
|
||||||
|
*.stackdump
|
||||||
|
|
||||||
|
# Temporary files
|
||||||
|
tmp/
|
||||||
|
temp/
|
||||||
|
|
||||||
|
# Package manager
|
||||||
|
.npm/
|
||||||
|
.pnpm-store/
|
||||||
|
|
||||||
|
# Vercel
|
||||||
|
.vercel/
|
||||||
|
|
||||||
|
# Netlify
|
||||||
|
.netlify/
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
out
|
||||||
|
dist
|
||||||
|
pnpm-lock.yaml
|
||||||
|
LICENSE.md
|
||||||
|
tsconfig.json
|
||||||
|
tsconfig.*.json
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
singleQuote: true
|
||||||
|
semi: false
|
||||||
|
printWidth: 100
|
||||||
|
trailingComma: none
|
||||||
Vendored
+3
@@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
"recommendations": ["dbaeumer.vscode-eslint"]
|
||||||
|
}
|
||||||
Vendored
+11
@@ -0,0 +1,11 @@
|
|||||||
|
{
|
||||||
|
"[typescript]": {
|
||||||
|
"editor.defaultFormatter": "esbenp.prettier-vscode"
|
||||||
|
},
|
||||||
|
"[javascript]": {
|
||||||
|
"editor.defaultFormatter": "esbenp.prettier-vscode"
|
||||||
|
},
|
||||||
|
"[json]": {
|
||||||
|
"editor.defaultFormatter": "esbenp.prettier-vscode"
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
# tienda-videojuegos
|
||||||
|
|
||||||
|
An Electron application with React and TypeScript
|
||||||
|
|
||||||
|
## Recommended IDE Setup
|
||||||
|
|
||||||
|
- [VSCode](https://code.visualstudio.com/) + [ESLint](https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint) + [Prettier](https://marketplace.visualstudio.com/items?itemName=esbenp.prettier-vscode)
|
||||||
|
|
||||||
|
## Project Setup
|
||||||
|
|
||||||
|
### Install
|
||||||
|
|
||||||
|
```bash
|
||||||
|
$ npm install
|
||||||
|
```
|
||||||
|
|
||||||
|
### Development
|
||||||
|
|
||||||
|
```bash
|
||||||
|
$ npm run dev
|
||||||
|
```
|
||||||
|
|
||||||
|
### Build
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# For windows
|
||||||
|
$ npm run build:win
|
||||||
|
|
||||||
|
# For macOS
|
||||||
|
$ npm run build:mac
|
||||||
|
|
||||||
|
# For Linux
|
||||||
|
$ npm run build:linux
|
||||||
|
```
|
||||||
@@ -0,0 +1,43 @@
|
|||||||
|
appId: com.electron.app
|
||||||
|
productName: tienda-videojuegos
|
||||||
|
directories:
|
||||||
|
buildResources: build
|
||||||
|
files:
|
||||||
|
- '!**/.vscode/*'
|
||||||
|
- '!src/*'
|
||||||
|
- '!electron.vite.config.{js,ts,mjs,cjs}'
|
||||||
|
- '!{.eslintcache,eslint.config.mjs,.prettierignore,.prettierrc.yaml,dev-app-update.yml,CHANGELOG.md,README.md}'
|
||||||
|
- '!{.env,.env.*,.npmrc,pnpm-lock.yaml}'
|
||||||
|
- '!{tsconfig.json,tsconfig.node.json,tsconfig.web.json}'
|
||||||
|
asarUnpack:
|
||||||
|
- resources/**
|
||||||
|
win:
|
||||||
|
executableName: tienda-videojuegos
|
||||||
|
nsis:
|
||||||
|
artifactName: ${name}-${version}-setup.${ext}
|
||||||
|
shortcutName: ${productName}
|
||||||
|
uninstallDisplayName: ${productName}
|
||||||
|
createDesktopShortcut: always
|
||||||
|
mac:
|
||||||
|
entitlementsInherit: build/entitlements.mac.plist
|
||||||
|
extendInfo:
|
||||||
|
- NSCameraUsageDescription: Application requests access to the device's camera.
|
||||||
|
- NSMicrophoneUsageDescription: Application requests access to the device's microphone.
|
||||||
|
- NSDocumentsFolderUsageDescription: Application requests access to the user's Documents folder.
|
||||||
|
- NSDownloadsFolderUsageDescription: Application requests access to the user's Downloads folder.
|
||||||
|
notarize: false
|
||||||
|
dmg:
|
||||||
|
artifactName: ${name}-${version}.${ext}
|
||||||
|
linux:
|
||||||
|
target:
|
||||||
|
- AppImage
|
||||||
|
- snap
|
||||||
|
- deb
|
||||||
|
maintainer: electronjs.org
|
||||||
|
category: Utility
|
||||||
|
appImage:
|
||||||
|
artifactName: ${name}-${version}.${ext}
|
||||||
|
npmRebuild: false
|
||||||
|
publish:
|
||||||
|
provider: generic
|
||||||
|
url: https://example.com/auto-updates
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
import { resolve } from 'path'
|
||||||
|
import { defineConfig } from 'electron-vite'
|
||||||
|
import react from '@vitejs/plugin-react'
|
||||||
|
|
||||||
|
export default defineConfig({
|
||||||
|
main: {},
|
||||||
|
preload: {},
|
||||||
|
renderer: {
|
||||||
|
resolve: {
|
||||||
|
alias: {
|
||||||
|
'@renderer': resolve('src/renderer/src')
|
||||||
|
}
|
||||||
|
},
|
||||||
|
plugins: [react()]
|
||||||
|
}
|
||||||
|
})
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
import { defineConfig } from 'eslint/config'
|
||||||
|
import tseslint from '@electron-toolkit/eslint-config-ts'
|
||||||
|
import eslintConfigPrettier from '@electron-toolkit/eslint-config-prettier'
|
||||||
|
import eslintPluginReact from 'eslint-plugin-react'
|
||||||
|
import eslintPluginReactHooks from 'eslint-plugin-react-hooks'
|
||||||
|
import eslintPluginReactRefresh from 'eslint-plugin-react-refresh'
|
||||||
|
|
||||||
|
export default defineConfig(
|
||||||
|
{ ignores: ['**/node_modules', '**/dist', '**/out'] },
|
||||||
|
tseslint.configs.recommended,
|
||||||
|
eslintPluginReact.configs.flat.recommended,
|
||||||
|
eslintPluginReact.configs.flat['jsx-runtime'],
|
||||||
|
{
|
||||||
|
settings: {
|
||||||
|
react: {
|
||||||
|
version: 'detect'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
files: ['**/*.{ts,tsx}'],
|
||||||
|
plugins: {
|
||||||
|
'react-hooks': eslintPluginReactHooks,
|
||||||
|
'react-refresh': eslintPluginReactRefresh
|
||||||
|
},
|
||||||
|
rules: {
|
||||||
|
...eslintPluginReactHooks.configs.recommended.rules,
|
||||||
|
...eslintPluginReactRefresh.configs.vite.rules
|
||||||
|
}
|
||||||
|
},
|
||||||
|
eslintConfigPrettier
|
||||||
|
)
|
||||||
@@ -0,0 +1,42 @@
|
|||||||
|
let electron = require("electron");
|
||||||
|
let path = require("path");
|
||||||
|
let _electron_toolkit_utils = require("@electron-toolkit/utils");
|
||||||
|
// resources/icon.png?asset
|
||||||
|
var icon_default = (0, path.join)(__dirname, "../../resources/icon.png");
|
||||||
|
// src/main/index.ts
|
||||||
|
function createWindow() {
|
||||||
|
const mainWindow = new electron.BrowserWindow({
|
||||||
|
width: 900,
|
||||||
|
height: 670,
|
||||||
|
show: false,
|
||||||
|
autoHideMenuBar: true,
|
||||||
|
...process.platform === "linux" ? { icon: icon_default } : {},
|
||||||
|
webPreferences: {
|
||||||
|
preload: (0, path.join)(__dirname, "../preload/index.js"),
|
||||||
|
sandbox: false
|
||||||
|
}
|
||||||
|
});
|
||||||
|
mainWindow.on("ready-to-show", () => {
|
||||||
|
mainWindow.show();
|
||||||
|
});
|
||||||
|
mainWindow.webContents.setWindowOpenHandler((details) => {
|
||||||
|
electron.shell.openExternal(details.url);
|
||||||
|
return { action: "deny" };
|
||||||
|
});
|
||||||
|
if (_electron_toolkit_utils.is.dev && process.env["ELECTRON_RENDERER_URL"]) mainWindow.loadURL(process.env["ELECTRON_RENDERER_URL"]);
|
||||||
|
else mainWindow.loadFile((0, path.join)(__dirname, "../renderer/index.html"));
|
||||||
|
}
|
||||||
|
electron.app.whenReady().then(() => {
|
||||||
|
_electron_toolkit_utils.electronApp.setAppUserModelId("com.electron");
|
||||||
|
electron.app.on("browser-window-created", (_, window) => {
|
||||||
|
_electron_toolkit_utils.optimizer.watchWindowShortcuts(window);
|
||||||
|
});
|
||||||
|
electron.ipcMain.on("ping", () => console.log("pong"));
|
||||||
|
createWindow();
|
||||||
|
electron.app.on("activate", function() {
|
||||||
|
if (electron.BrowserWindow.getAllWindows().length === 0) createWindow();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
electron.app.on("window-all-closed", () => {
|
||||||
|
if (process.platform !== "darwin") electron.app.quit();
|
||||||
|
});
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
let electron = require("electron");
|
||||||
|
let _electron_toolkit_preload = require("@electron-toolkit/preload");
|
||||||
|
// src/preload/index.ts
|
||||||
|
var api = {};
|
||||||
|
if (process.contextIsolated) try {
|
||||||
|
electron.contextBridge.exposeInMainWorld("electron", _electron_toolkit_preload.electronAPI);
|
||||||
|
electron.contextBridge.exposeInMainWorld("api", api);
|
||||||
|
} catch (error) {
|
||||||
|
console.error(error);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
window.electron = _electron_toolkit_preload.electronAPI;
|
||||||
|
window.api = api;
|
||||||
|
}
|
||||||
Generated
+8342
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,48 @@
|
|||||||
|
{
|
||||||
|
"name": "tienda-videojuegos",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"description": "An Electron application with React and TypeScript",
|
||||||
|
"main": "./out/main/index.js",
|
||||||
|
"author": "example.com",
|
||||||
|
"homepage": "https://electron-vite.org",
|
||||||
|
"scripts": {
|
||||||
|
"format": "prettier --write .",
|
||||||
|
"lint": "eslint --cache .",
|
||||||
|
"typecheck:node": "tsc --noEmit -p tsconfig.node.json --composite false",
|
||||||
|
"typecheck:web": "tsc --noEmit -p tsconfig.web.json --composite false",
|
||||||
|
"typecheck": "npm run typecheck:node && npm run typecheck:web",
|
||||||
|
"start": "electron-vite preview",
|
||||||
|
"dev": "electron-vite dev",
|
||||||
|
"build": "npm run typecheck && electron-vite build",
|
||||||
|
"postinstall": "install-electron && electron-builder install-app-deps",
|
||||||
|
"build:unpack": "npm run build && electron-builder --dir",
|
||||||
|
"build:win": "npm run build && electron-builder --win",
|
||||||
|
"build:mac": "electron-vite build && electron-builder --mac",
|
||||||
|
"build:linux": "electron-vite build && electron-builder --linux"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"@electron-toolkit/preload": "^3.0.2",
|
||||||
|
"@electron-toolkit/utils": "^4.0.0"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@electron-toolkit/eslint-config-prettier": "^3.0.1",
|
||||||
|
"@electron-toolkit/eslint-config-ts": "^4.0.0",
|
||||||
|
"@electron-toolkit/tsconfig": "^2.0.0",
|
||||||
|
"@types/node": "^24.19.2",
|
||||||
|
"@types/react": "^19.3.0",
|
||||||
|
"@types/react-dom": "^19.3.0",
|
||||||
|
"@vitejs/plugin-react": "^6.1.2",
|
||||||
|
"electron": "^44.7.2",
|
||||||
|
"electron-builder": "^26.15.3",
|
||||||
|
"electron-vite": "^6.0.0",
|
||||||
|
"eslint": "^9.39.5",
|
||||||
|
"eslint-plugin-react": "^7.37.5",
|
||||||
|
"eslint-plugin-react-hooks": "^7.1.1",
|
||||||
|
"eslint-plugin-react-refresh": "^0.5.7",
|
||||||
|
"prettier": "^3.9.10",
|
||||||
|
"react": "^19.3.0",
|
||||||
|
"react-dom": "^19.3.0",
|
||||||
|
"typescript": "^5.9.3",
|
||||||
|
"vite": "^8.3.4"
|
||||||
|
}
|
||||||
|
}
|
||||||
Binary file not shown.
|
After Width: | Height: | Size: 35 KiB |
@@ -0,0 +1,74 @@
|
|||||||
|
import { app, shell, BrowserWindow, ipcMain } from 'electron'
|
||||||
|
import { join } from 'path'
|
||||||
|
import { electronApp, optimizer, is } from '@electron-toolkit/utils'
|
||||||
|
import icon from '../../resources/icon.png?asset'
|
||||||
|
|
||||||
|
function createWindow(): void {
|
||||||
|
// Create the browser window.
|
||||||
|
const mainWindow = new BrowserWindow({
|
||||||
|
width: 900,
|
||||||
|
height: 670,
|
||||||
|
show: false,
|
||||||
|
autoHideMenuBar: true,
|
||||||
|
...(process.platform === 'linux' ? { icon } : {}),
|
||||||
|
webPreferences: {
|
||||||
|
preload: join(__dirname, '../preload/index.js'),
|
||||||
|
sandbox: false
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
mainWindow.on('ready-to-show', () => {
|
||||||
|
mainWindow.show()
|
||||||
|
})
|
||||||
|
|
||||||
|
mainWindow.webContents.setWindowOpenHandler((details) => {
|
||||||
|
shell.openExternal(details.url)
|
||||||
|
return { action: 'deny' }
|
||||||
|
})
|
||||||
|
|
||||||
|
// HMR for renderer base on electron-vite cli.
|
||||||
|
// Load the remote URL for development or the local html file for production.
|
||||||
|
if (is.dev && process.env['ELECTRON_RENDERER_URL']) {
|
||||||
|
mainWindow.loadURL(process.env['ELECTRON_RENDERER_URL'])
|
||||||
|
} else {
|
||||||
|
mainWindow.loadFile(join(__dirname, '../renderer/index.html'))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// This method will be called when Electron has finished
|
||||||
|
// initialization and is ready to create browser windows.
|
||||||
|
// Some APIs can only be used after this event occurs.
|
||||||
|
app.whenReady().then(() => {
|
||||||
|
// Set app user model id for windows
|
||||||
|
electronApp.setAppUserModelId('com.electron')
|
||||||
|
|
||||||
|
// Default open or close DevTools by F12 in development
|
||||||
|
// and ignore CommandOrControl + R in production.
|
||||||
|
// see https://github.com/alex8088/electron-toolkit/tree/master/packages/utils
|
||||||
|
app.on('browser-window-created', (_, window) => {
|
||||||
|
optimizer.watchWindowShortcuts(window)
|
||||||
|
})
|
||||||
|
|
||||||
|
// IPC test
|
||||||
|
ipcMain.on('ping', () => console.log('pong'))
|
||||||
|
|
||||||
|
createWindow()
|
||||||
|
|
||||||
|
app.on('activate', function () {
|
||||||
|
// On macOS it's common to re-create a window in the app when the
|
||||||
|
// dock icon is clicked and there are no other windows open.
|
||||||
|
if (BrowserWindow.getAllWindows().length === 0) createWindow()
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
// Quit when all windows are closed, except on macOS. There, it's common
|
||||||
|
// for applications and their menu bar to stay active until the user quits
|
||||||
|
// explicitly with Cmd + Q.
|
||||||
|
app.on('window-all-closed', () => {
|
||||||
|
if (process.platform !== 'darwin') {
|
||||||
|
app.quit()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
// In this file you can include the rest of your app's specific main process
|
||||||
|
// code. You can also put them in separate files and require them here.
|
||||||
Vendored
+8
@@ -0,0 +1,8 @@
|
|||||||
|
import { ElectronAPI } from '@electron-toolkit/preload'
|
||||||
|
|
||||||
|
declare global {
|
||||||
|
interface Window {
|
||||||
|
electron: ElectronAPI
|
||||||
|
api: unknown
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
import { contextBridge } from 'electron'
|
||||||
|
import { electronAPI } from '@electron-toolkit/preload'
|
||||||
|
|
||||||
|
// Custom APIs for renderer
|
||||||
|
const api = {}
|
||||||
|
|
||||||
|
// Use `contextBridge` APIs to expose Electron APIs to
|
||||||
|
// renderer only if context isolation is enabled, otherwise
|
||||||
|
// just add to the DOM global.
|
||||||
|
if (process.contextIsolated) {
|
||||||
|
try {
|
||||||
|
contextBridge.exposeInMainWorld('electron', electronAPI)
|
||||||
|
contextBridge.exposeInMainWorld('api', api)
|
||||||
|
} catch (error) {
|
||||||
|
console.error(error)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// @ts-ignore (define in dts)
|
||||||
|
window.electron = electronAPI
|
||||||
|
// @ts-ignore (define in dts)
|
||||||
|
window.api = api
|
||||||
|
}
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
<!doctype html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8" />
|
||||||
|
<title>Electron</title>
|
||||||
|
<!-- https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP -->
|
||||||
|
<meta
|
||||||
|
http-equiv="Content-Security-Policy"
|
||||||
|
content="default-src 'self'; script-src 'self'; style-src 'self' 'unsafe-inline'; img-src 'self' data: https:; connect-src 'self' https:"
|
||||||
|
/>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<div id="root"></div>
|
||||||
|
<script type="module" src="/src/main.tsx"></script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
import { useState } from 'react'
|
||||||
|
import Header from './components/Header'
|
||||||
|
import Sidebar from './components/Sidebar'
|
||||||
|
import Personal from './views/Personal'
|
||||||
|
import Inventario from './views/Inventario'
|
||||||
|
import Incidencias from './views/Incidencias'
|
||||||
|
import './styles/app.css'
|
||||||
|
|
||||||
|
function App() {
|
||||||
|
const [seccion, setSeccion] = useState<string>('Personal')
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div id="app-container">
|
||||||
|
<Header />
|
||||||
|
<div id="cuerpo">
|
||||||
|
<Sidebar seccion={seccion} onCambiar={setSeccion} />
|
||||||
|
<main id="panel_central">
|
||||||
|
{seccion === 'Personal' && <Personal />}
|
||||||
|
{seccion === 'Inventario' && <Inventario />}
|
||||||
|
{seccion === 'Incidencias' && <Incidencias />}
|
||||||
|
</main>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export default App
|
||||||
Binary file not shown.
|
After Width: | Height: | Size: 1.1 MiB |
@@ -0,0 +1,21 @@
|
|||||||
|
interface AssetCardProps {
|
||||||
|
nombre: string
|
||||||
|
precio: number
|
||||||
|
categoria: string
|
||||||
|
imagen: string
|
||||||
|
}
|
||||||
|
|
||||||
|
function AssetCard({ nombre, precio, categoria, imagen }: AssetCardProps) {
|
||||||
|
return (
|
||||||
|
<article className={precio > 50 ? 'tarjeta tarjeta-valor' : 'tarjeta'}>
|
||||||
|
<img src={imagen} alt={nombre} className="imagen-activo" />
|
||||||
|
<h3>{nombre}</h3>
|
||||||
|
<p>🏷️ {categoria}</p>
|
||||||
|
<p className="precio">{precio.toFixed(2)} $</p>
|
||||||
|
|
||||||
|
{precio > 50 && <span className="etiqueta-valor">⭐ Activo de Alto Valor</span>}
|
||||||
|
</article>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export default AssetCard
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
interface EmployeeCardProps {
|
||||||
|
nombre: string
|
||||||
|
correo: string
|
||||||
|
ciudad: string
|
||||||
|
}
|
||||||
|
|
||||||
|
function EmployeeCard({ nombre, correo, ciudad }: EmployeeCardProps) {
|
||||||
|
return (
|
||||||
|
<article className="tarjeta">
|
||||||
|
<h3>{nombre}</h3>
|
||||||
|
<p>✉️ {correo}</p>
|
||||||
|
<p>📍 {ciudad}</p>
|
||||||
|
</article>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export default EmployeeCard
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
import { useState } from 'react'
|
||||||
|
import logo from '../assets/logo.png'
|
||||||
|
|
||||||
|
function Header() {
|
||||||
|
const [hora, setHora] = useState<string>(() => new Date().toLocaleTimeString())
|
||||||
|
|
||||||
|
|
||||||
|
setInterval(() => {
|
||||||
|
setHora(new Date().toLocaleTimeString())
|
||||||
|
}, 1000)
|
||||||
|
|
||||||
|
return (
|
||||||
|
<header id="cabecera">
|
||||||
|
<div className="marca">
|
||||||
|
<img src={logo} alt="Logo Altairs" className="logo" />
|
||||||
|
<h1>Altaris</h1>
|
||||||
|
</div>
|
||||||
|
<span className="hora">{hora}</span>
|
||||||
|
</header>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export default Header
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
interface IncidentCardProps {
|
||||||
|
titulo: string
|
||||||
|
departamento: number
|
||||||
|
completada: boolean
|
||||||
|
}
|
||||||
|
|
||||||
|
function IncidentCard({ titulo, departamento, completada }: IncidentCardProps) {
|
||||||
|
return (
|
||||||
|
<article className={completada ? 'tarjeta incidencia-resuelta' : 'tarjeta incidencia-pendiente'}>
|
||||||
|
<div className="incidencia-cabecera">
|
||||||
|
<span className="icono-estado">{completada ? '✅' : '⚠️'}</span>
|
||||||
|
<span className="estado-texto">{completada ? 'Resuelta' : 'Pendiente'}</span>
|
||||||
|
</div>
|
||||||
|
<h3>{titulo}</h3>
|
||||||
|
<p>🏢 Departamento {departamento}</p>
|
||||||
|
</article>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export default IncidentCard
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
interface NavBtnProps {
|
||||||
|
titulo: string
|
||||||
|
activo: boolean
|
||||||
|
onClick: () => void
|
||||||
|
}
|
||||||
|
|
||||||
|
function NavBtn({ titulo, activo, onClick }: NavBtnProps) {
|
||||||
|
return (
|
||||||
|
<button className={activo ? 'nav-btn activo' : 'nav-btn'} onClick={onClick}>
|
||||||
|
{titulo}
|
||||||
|
</button>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export default NavBtn
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
import NavBtn from './NavBtn'
|
||||||
|
|
||||||
|
interface SidebarProps {
|
||||||
|
seccion: string
|
||||||
|
onCambiar: (nueva: string) => void
|
||||||
|
}
|
||||||
|
|
||||||
|
function Sidebar({ seccion, onCambiar }: SidebarProps) {
|
||||||
|
const secciones: string[] = ['Personal', 'Inventario', 'Incidencias']
|
||||||
|
|
||||||
|
return (
|
||||||
|
<aside id="sidebar">
|
||||||
|
{secciones.map((s) => (
|
||||||
|
<NavBtn
|
||||||
|
key={s}
|
||||||
|
titulo={s}
|
||||||
|
activo={seccion === s}
|
||||||
|
onClick={() => onCambiar(s)}
|
||||||
|
/>
|
||||||
|
))}
|
||||||
|
</aside>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export default Sidebar
|
||||||
Vendored
+1
@@ -0,0 +1 @@
|
|||||||
|
/// <reference types="vite/client" />
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
import React from 'react'
|
||||||
|
import ReactDOM from 'react-dom/client'
|
||||||
|
import App from './App'
|
||||||
|
|
||||||
|
ReactDOM.createRoot(document.getElementById('root') as HTMLElement).render(
|
||||||
|
<React.StrictMode>
|
||||||
|
<App />
|
||||||
|
</React.StrictMode>
|
||||||
|
)
|
||||||
@@ -0,0 +1,187 @@
|
|||||||
|
:root {
|
||||||
|
--fondo: #2b1d16;
|
||||||
|
--panel: #3a2a20;
|
||||||
|
--borde: #573a2e;
|
||||||
|
--acento: #c8a06c;
|
||||||
|
--acento2: #e6c590;
|
||||||
|
--texto: #f5ede3;
|
||||||
|
--texto-oscuro: #2b1d16;
|
||||||
|
}
|
||||||
|
|
||||||
|
* { box-sizing: border-box; }
|
||||||
|
|
||||||
|
html, body, #root {
|
||||||
|
margin: 0;
|
||||||
|
height: 100%;
|
||||||
|
font-family: system-ui, sans-serif;
|
||||||
|
background: var(--fondo);
|
||||||
|
color: var(--texto);
|
||||||
|
}
|
||||||
|
|
||||||
|
#app-container {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
height: 100vh;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Cabecera */
|
||||||
|
#cabecera {
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
align-items: center;
|
||||||
|
padding: 0 1.25rem;
|
||||||
|
height: 3.75rem;
|
||||||
|
background: var(--panel);
|
||||||
|
border-bottom: 0.125rem solid var(--acento);
|
||||||
|
}
|
||||||
|
|
||||||
|
.marca { display: flex; align-items: center; gap: 0.75rem; }
|
||||||
|
.marca h1 { margin: 0; font-size: 1.375rem; color: var(--acento); letter-spacing: 0.125rem; }
|
||||||
|
|
||||||
|
/* El logo tiene fondo blanco, así que lo recuadramos */
|
||||||
|
.logo {
|
||||||
|
height: 2.625rem;
|
||||||
|
width: 2.625rem;
|
||||||
|
object-fit: contain;
|
||||||
|
background: white;
|
||||||
|
border-radius: 50%;
|
||||||
|
padding: 0.125rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.hora { font-variant-numeric: tabular-nums; color: var(--acento2); }
|
||||||
|
|
||||||
|
/* Cuerpo y sidebar */
|
||||||
|
#cuerpo { display: flex; flex: 1; overflow: hidden; }
|
||||||
|
|
||||||
|
#sidebar {
|
||||||
|
width: 12.5rem;
|
||||||
|
padding: 1rem;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 0.625rem;
|
||||||
|
background: var(--panel);
|
||||||
|
border-right: 0.0625rem solid var(--borde);
|
||||||
|
}
|
||||||
|
|
||||||
|
.nav-btn {
|
||||||
|
padding: 0.75rem;
|
||||||
|
border: 0.0625rem solid var(--borde);
|
||||||
|
border-radius: 0.5rem;
|
||||||
|
background: transparent;
|
||||||
|
color: var(--texto);
|
||||||
|
cursor: pointer;
|
||||||
|
text-align: left;
|
||||||
|
transition: all 0.2s;
|
||||||
|
}
|
||||||
|
|
||||||
|
.nav-btn:hover { border-color: var(--acento); }
|
||||||
|
|
||||||
|
.nav-btn.activo {
|
||||||
|
background: var(--acento);
|
||||||
|
border-color: var(--acento);
|
||||||
|
color: var(--texto-oscuro);
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
|
||||||
|
#panel_central { flex: 1; padding: 1.25rem; overflow-y: auto; }
|
||||||
|
#panel_central h2 { color: var(--acento); }
|
||||||
|
|
||||||
|
/* Barra superior de cada vista */
|
||||||
|
.barra-superior {
|
||||||
|
display: flex;
|
||||||
|
gap: 0.75rem;
|
||||||
|
margin-bottom: 1.25rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.buscador {
|
||||||
|
flex: 1;
|
||||||
|
padding: 0.625rem 0.875rem;
|
||||||
|
border: 0.0625rem solid var(--borde);
|
||||||
|
border-radius: 0.5rem;
|
||||||
|
background: var(--panel);
|
||||||
|
color: var(--texto);
|
||||||
|
}
|
||||||
|
|
||||||
|
.buscador:focus { outline: none; border-color: var(--acento); }
|
||||||
|
|
||||||
|
.btn-cargar {
|
||||||
|
padding: 0.625rem 1.125rem;
|
||||||
|
border: none;
|
||||||
|
border-radius: 0.5rem;
|
||||||
|
background: var(--acento);
|
||||||
|
color: var(--texto-oscuro);
|
||||||
|
font-weight: bold;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-cargar:hover { filter: brightness(1.1); }
|
||||||
|
|
||||||
|
.mensaje { color: var(--acento2); }
|
||||||
|
.mensaje.error { color: #e8837a; }
|
||||||
|
|
||||||
|
/* Tarjetas */
|
||||||
|
.cuadricula {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: repeat(auto-fill, minmax(13.75rem, 1fr));
|
||||||
|
gap: 1rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tarjeta {
|
||||||
|
padding: 1rem;
|
||||||
|
background: var(--panel);
|
||||||
|
border: 0.0625rem solid var(--borde);
|
||||||
|
border-radius: 0.625rem;
|
||||||
|
transition: all 0.2s;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tarjeta:hover { border-color: var(--acento); transform: translateY(-0.1875rem); }
|
||||||
|
.tarjeta h3 { margin: 0 0 0.625rem; color: var(--acento2); }
|
||||||
|
.tarjeta p { margin: 0.25rem 0; font-size: 0.875rem; }
|
||||||
|
|
||||||
|
/* Inventario */
|
||||||
|
.imagen-activo {
|
||||||
|
width: 100%;
|
||||||
|
height: 8.75rem;
|
||||||
|
object-fit: contain;
|
||||||
|
background: white;
|
||||||
|
border-radius: 0.5rem;
|
||||||
|
margin-bottom: 0.625rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.precio { font-size: 1.125rem; font-weight: bold; color: var(--acento); }
|
||||||
|
|
||||||
|
.tarjeta-valor { border-color: var(--acento); border-width: 0.125rem; }
|
||||||
|
|
||||||
|
.etiqueta-valor {
|
||||||
|
display: inline-block;
|
||||||
|
margin-top: 0.5rem;
|
||||||
|
padding: 0.25rem 0.625rem;
|
||||||
|
border-radius: 62.5rem;
|
||||||
|
background: var(--acento);
|
||||||
|
color: var(--texto-oscuro);
|
||||||
|
font-size: 0.75rem;
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Incidencias */
|
||||||
|
.incidencia-cabecera {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 0.5rem;
|
||||||
|
margin-bottom: 0.625rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.icono-estado { font-size: 1.25rem; }
|
||||||
|
|
||||||
|
.estado-texto {
|
||||||
|
font-size: 0.75rem;
|
||||||
|
font-weight: bold;
|
||||||
|
text-transform: uppercase;
|
||||||
|
letter-spacing: 0.0625rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.incidencia-resuelta { background: #0d1d02; border-color: #8fb573; }
|
||||||
|
.incidencia-resuelta .estado-texto { color: #e7e7e7; }
|
||||||
|
|
||||||
|
.incidencia-pendiente { background: #3b2220; border-color: #d9776a; }
|
||||||
|
.incidencia-pendiente .estado-texto { color: #e8837a; }
|
||||||
@@ -0,0 +1,66 @@
|
|||||||
|
import { useState } from 'react'
|
||||||
|
import IncidentCard from '../components/IncidentCard'
|
||||||
|
|
||||||
|
// Solo los campos de la API que vamos a usar
|
||||||
|
interface Incidencia {
|
||||||
|
id: number
|
||||||
|
userId: number
|
||||||
|
title: string
|
||||||
|
completed: boolean
|
||||||
|
}
|
||||||
|
|
||||||
|
function Incidencias() {
|
||||||
|
const [incidencias, setIncidencias] = useState<Incidencia[]>([])
|
||||||
|
const [cargando, setCargando] = useState<boolean>(false)
|
||||||
|
const [error, setError] = useState<string>('')
|
||||||
|
|
||||||
|
const cargarIncidencias = async (): Promise<void> => {
|
||||||
|
setCargando(true)
|
||||||
|
setError('')
|
||||||
|
|
||||||
|
try {
|
||||||
|
const respuesta = await fetch('https://jsonplaceholder.typicode.com/todos?_limit=8')
|
||||||
|
|
||||||
|
if (!respuesta.ok) {
|
||||||
|
throw new Error(`Error en el servidor: ${respuesta.status}`)
|
||||||
|
}
|
||||||
|
|
||||||
|
const datos: Incidencia[] = await respuesta.json()
|
||||||
|
setIncidencias(datos)
|
||||||
|
} catch (e) {
|
||||||
|
if (e instanceof Error) {
|
||||||
|
setError(e.message)
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
setCargando(false)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<section>
|
||||||
|
<h2>Incidencias</h2>
|
||||||
|
|
||||||
|
<div className="barra-superior">
|
||||||
|
<button className="btn-cargar" onClick={cargarIncidencias}>
|
||||||
|
Cargar incidencias
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{cargando && <p className="mensaje">Cargando datos del servidor…</p>}
|
||||||
|
{error && <p className="mensaje error">{error}</p>}
|
||||||
|
|
||||||
|
<div className="cuadricula">
|
||||||
|
{incidencias.map((inc) => (
|
||||||
|
<IncidentCard
|
||||||
|
key={inc.id}
|
||||||
|
titulo={inc.title}
|
||||||
|
departamento={inc.userId}
|
||||||
|
completada={inc.completed}
|
||||||
|
/>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export default Incidencias
|
||||||
@@ -0,0 +1,68 @@
|
|||||||
|
import { useState } from 'react'
|
||||||
|
import AssetCard from '../components/AssetCard'
|
||||||
|
|
||||||
|
// Solo los campos de la API que vamos a usar
|
||||||
|
interface Activo {
|
||||||
|
id: number
|
||||||
|
title: string
|
||||||
|
price: number
|
||||||
|
category: string
|
||||||
|
image: string
|
||||||
|
}
|
||||||
|
|
||||||
|
function Inventario() {
|
||||||
|
const [activos, setActivos] = useState<Activo[]>([])
|
||||||
|
const [cargando, setCargando] = useState<boolean>(false)
|
||||||
|
const [error, setError] = useState<string>('')
|
||||||
|
|
||||||
|
const cargarActivos = async (): Promise<void> => {
|
||||||
|
setCargando(true)
|
||||||
|
setError('')
|
||||||
|
|
||||||
|
try {
|
||||||
|
const respuesta = await fetch('https://fakestoreapi.com/products?limit=6')
|
||||||
|
|
||||||
|
if (!respuesta.ok) {
|
||||||
|
throw new Error(`Error en el servidor: ${respuesta.status}`)
|
||||||
|
}
|
||||||
|
|
||||||
|
const datos: Activo[] = await respuesta.json()
|
||||||
|
setActivos(datos)
|
||||||
|
} catch (e) {
|
||||||
|
if (e instanceof Error) {
|
||||||
|
setError(e.message)
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
setCargando(false)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<section>
|
||||||
|
<h2>Inventario</h2>
|
||||||
|
|
||||||
|
<div className="barra-superior">
|
||||||
|
<button className="btn-cargar" onClick={cargarActivos}>
|
||||||
|
Cargar inventario
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{cargando && <p className="mensaje">Cargando datos del servidor…</p>}
|
||||||
|
{error && <p className="mensaje error">{error}</p>}
|
||||||
|
|
||||||
|
<div className="cuadricula">
|
||||||
|
{activos.map((activo) => (
|
||||||
|
<AssetCard
|
||||||
|
key={activo.id}
|
||||||
|
nombre={activo.title}
|
||||||
|
precio={activo.price}
|
||||||
|
categoria={activo.category}
|
||||||
|
imagen={activo.image}
|
||||||
|
/>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export default Inventario
|
||||||
@@ -0,0 +1,82 @@
|
|||||||
|
import { useState } from 'react'
|
||||||
|
import EmployeeCard from '../components/EmployeeCard'
|
||||||
|
|
||||||
|
// Solo definimos los campos de la API que vamos a usar
|
||||||
|
interface Empleado {
|
||||||
|
id: number
|
||||||
|
name: string
|
||||||
|
email: string
|
||||||
|
address: {
|
||||||
|
city: string
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function Personal() {
|
||||||
|
const [empleados, setEmpleados] = useState<Empleado[]>([])
|
||||||
|
const [cargando, setCargando] = useState<boolean>(false)
|
||||||
|
const [error, setError] = useState<string>('')
|
||||||
|
const [busqueda, setBusqueda] = useState<string>('')
|
||||||
|
|
||||||
|
const cargarEmpleados = async (): Promise<void> => {
|
||||||
|
setCargando(true)
|
||||||
|
setError('')
|
||||||
|
|
||||||
|
try {
|
||||||
|
const respuesta = await fetch('https://jsonplaceholder.typicode.com/users')
|
||||||
|
|
||||||
|
// fetch no entra al catch con un 404 o 500, hay que validarlo a mano
|
||||||
|
if (!respuesta.ok) {
|
||||||
|
throw new Error(`Error en el servidor: ${respuesta.status}`)
|
||||||
|
}
|
||||||
|
|
||||||
|
const datos: Empleado[] = await respuesta.json()
|
||||||
|
setEmpleados(datos)
|
||||||
|
} catch (e) {
|
||||||
|
if (e instanceof Error) {
|
||||||
|
setError(e.message)
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
setCargando(false)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Filtro en tiempo real por nombre
|
||||||
|
const empleadosFiltrados: Empleado[] = empleados.filter((emp) =>
|
||||||
|
emp.name.toLowerCase().includes(busqueda.toLowerCase())
|
||||||
|
)
|
||||||
|
|
||||||
|
return (
|
||||||
|
<section>
|
||||||
|
<h2>Personal</h2>
|
||||||
|
|
||||||
|
<div className="barra-superior">
|
||||||
|
<input
|
||||||
|
type="text"
|
||||||
|
className="buscador"
|
||||||
|
placeholder="Buscar empleado por nombre: "
|
||||||
|
value={busqueda}
|
||||||
|
onChange={(e) => setBusqueda(e.target.value)}
|
||||||
|
/>
|
||||||
|
<button className="btn-cargar" onClick={cargarEmpleados}>
|
||||||
|
Cargar personal
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{cargando && <p className="mensaje">Cargando datos del servidor…</p>}
|
||||||
|
{error && <p className="mensaje error">{error}</p>}
|
||||||
|
|
||||||
|
<div className="cuadricula">
|
||||||
|
{empleadosFiltrados.map((emp) => (
|
||||||
|
<EmployeeCard
|
||||||
|
key={emp.id}
|
||||||
|
nombre={emp.name}
|
||||||
|
correo={emp.email}
|
||||||
|
ciudad={emp.address.city}
|
||||||
|
/>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export default Personal
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
{
|
||||||
|
"files": [],
|
||||||
|
"references": [{ "path": "./tsconfig.node.json" }, { "path": "./tsconfig.web.json" }]
|
||||||
|
}
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
{
|
||||||
|
"extends": "@electron-toolkit/tsconfig/tsconfig.node.json",
|
||||||
|
"include": ["electron.vite.config.*", "src/main/**/*", "src/preload/**/*"],
|
||||||
|
"compilerOptions": {
|
||||||
|
"composite": true,
|
||||||
|
"types": ["electron-vite/node"]
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
{
|
||||||
|
"extends": "@electron-toolkit/tsconfig/tsconfig.web.json",
|
||||||
|
"include": [
|
||||||
|
"src/renderer/src/env.d.ts",
|
||||||
|
"src/renderer/src/**/*",
|
||||||
|
"src/renderer/src/**/*.tsx",
|
||||||
|
"src/preload/*.d.ts"
|
||||||
|
],
|
||||||
|
"compilerOptions": {
|
||||||
|
"composite": true,
|
||||||
|
"jsx": "react-jsx",
|
||||||
|
"baseUrl": ".",
|
||||||
|
"paths": {
|
||||||
|
"@renderer/*": [
|
||||||
|
"src/renderer/src/*"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user