Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

se subio sl challeng one #44

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
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
106 changes: 106 additions & 0 deletions prueba-tecnica/Tilson-7523/challenge-one.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
// Crear una funcionalidad que dado un lista de transacciones, una categoria,
// un rango de fechas, devuelva la suma de todas las transacciones de esa categoria.

// 1. Entiendan muy bien el enunciado
// 2. Planear metalmente / rayar un pseudocódigo de como lo solucionarían
// 3. Hagan funcionalidades pequeñas
// 4. Hagan pase las pruebas (unit tests / console.logs)
// 5. Refactoricen (pongan el código más lindo / legible)

const transactions = [
{
id: 123,
sourceAccount: "my_account",
targetAccount: "coffee_shop",
amount: -30,
category: "eating_out",
time: "2018-03-01T12:34:00Z",
},
{
id: 124,
sourceAccount: "my_account",
targetAccount: "coffee_shop",
amount: -50,
category: "eating_out",
time: "2018-03-12T11:34:00Z",
},
{
id: 127,
sourceAccount: "my_account",
targetAccount: "restaurant",
amount: -100,
category: "eating_out",
time: "2019-03-23T11:51:00Z",
},
{
id: 125,
sourceAccount: "my_work",
targetAccount: "my_account",
amount: 1000,
category: "salary",
time: "2019-02-12T12:34:00Z",
},
{
id: 126,
sourceAccount: "my_work",
targetAccount: "my_account",
amount: 1100,
category: "salary",
time: "2019-05-12T12:34:00Z",
},
{
id: 129,
sourceAccount: "my_account",
targetAccount: "my_work",
amount: -100,
category: "salary",
time: "2019-05-12T12:35:00Z",
},
{
id: 128,
sourceAccount: "my_account",
targetAccount: "supermarket",
amount: -10,
category: "groceries",
time: "2019-01-23T12:51:00Z",
},
];


const filterByCategory = ({ category }) => {
return (transaction) => {
return transaction.category == category
}
}

const TWENTY_THREE_HOURS_IN_MS = 23 * 60 * 60 * 1000
const FIFTY_NINE_MINUTES_IN_MS = 59 * 60 * 1000
const FIFTY_NINE_SECONDS_IN_MS = 59 * 1000

const filterByDate = ({ startDate, endDate }) => {

const startTime = new Date(startDate).getTime()
const endTime = new Date(endDate).getTime() + TWENTY_THREE_HOURS_IN_MS + FIFTY_NINE_MINUTES_IN_MS + FIFTY_NINE_SECONDS_IN_MS
return (transaction) => {
const transactionTime = new Date(transaction.time).getTime()
if (transactionTime >= startTime && transactionTime <= endTime){
return true
}
return false
}
}

const sumAmount = (totalBalance, transaction) => {
return totalBalance + transaction.amount
}

function getSumTranscationsByCategory(transactions, category, startDate, endDate) {
return transactions
.filter(filterByCategory({ category }))
.filter(filterByDate({ startDate, endDate }))
.reduce(sumAmount, 0)

}

console.log(getSumTranscationsByCategory(
transactions, 'eating_out', '2018-03-01', '2018-03-12'))
21 changes: 21 additions & 0 deletions react-blogs/Tilson-7523/intro-a-react/.eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
module.exports = {
root: true,
env: { browser: true, es2020: true },
extends: [
'eslint:recommended',
'plugin:react/recommended',
'plugin:react/jsx-runtime',
'plugin:react-hooks/recommended',
],
ignorePatterns: ['dist', '.eslintrc.cjs'],
parserOptions: { ecmaVersion: 'latest', sourceType: 'module' },
settings: { react: { version: '18.2' } },
plugins: ['react-refresh'],
rules: {
'react-refresh/only-export-components': [
'warn',
{ allowConstantExport: true },
],
'react/prop-types': 'off'
},
}
24 changes: 24 additions & 0 deletions react-blogs/Tilson-7523/intro-a-react/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*

node_modules
dist
dist-ssr
*.local

# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
.DS_Store
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
8 changes: 8 additions & 0 deletions react-blogs/Tilson-7523/intro-a-react/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# React + Vite

This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules.

Currently, two official plugins are available:

- [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react/README.md) uses [Babel](https://babeljs.io/) for Fast Refresh
- [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react-swc) uses [SWC](https://swc.rs/) for Fast Refresh
22 changes: 22 additions & 0 deletions react-blogs/Tilson-7523/intro-a-react/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />

<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/jgthms/minireset.css@master/minireset.min.css">
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link
href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;600;700;800&family=Poppins:wght@300&display=swap"
rel="stylesheet">
<link rel="stylesheet" href="src/styles/main.scss">

<title>Undefined Shell Blog</title>
</head>
<body>
<div id="root"></div>
<script type="module" src="/src/main.jsx"></script>
</body>
</html>
Loading