Skip to content

Instantly share code, notes, and snippets.

View cdsandoval's full-sized avatar
🧑‍💻
Solving problems

Carlos Sandoval Montoya cdsandoval

🧑‍💻
Solving problems
View GitHub Profile
@cdsandoval
cdsandoval / CostCenterManagement.js
Created February 25, 2025 18:27
CostCenter Error
import Q, { forwardRef as J0, useImperativeHandle as K0, useState as ht, useMemo as Z0, useCallback as em, useRef as Cl } from "react";
import { useQuery as tm, QueryClient as rm, QueryClientProvider as am } from "@tanstack/react-query";
import { ToastContainer as nm } from "react-toastify";
import { useParams as um, useHistory as Df, HashRouter as im, Switch as om, Route as sm } from "react-router-dom";
import { Form as Mf, Card as Va, Skeleton as lm, Row as dm, Col as ar, Button as Er, Modal as fm, Upload as cm } from "antd";
import { useTranslation as cr } from "react-i18next";
import { e as Je, a as Oa } from "./axios.provider.js";
import { A as gt, i as vm, b as pm, O as mm } from "./index17.js";
import { S as Rl, T as Pa, L as _m } from "./UploadInput.module.js";
import { S as Xa, E as fr } from "./ToastsTemplates.js";
# GitHub Action that will run prettier on the whole repo and commit the changes to the PR.
name: Prettier
on:
pull_request:
branches: [main]
jobs:
prettier:
runs-on: ubuntu-latest
@cdsandoval
cdsandoval / useMemo.jsx
Last active February 8, 2024 11:24
useMemo
function Component(){
const [searchTerm, setSearchTerm] = React.useState("")
const filterWithGoodName = React.useMemo(() => {
return searchTerm.filter(.....)
}, [searchTerm])
return (
<input onSearch={setSearchTerm}/>
}
@cdsandoval
cdsandoval / helper.js
Last active June 9, 2023 17:55
Refactor ransack fiilter with search term
function buildSearchGroups(term, searchFields) {
const searchGroups = [];
if (term) {
const searchTermList = term.trim().split(' ');
searchTermList.forEach(searchTerm => {
const searchGroup = { m: 'or' };
searchFields.forEach(field => {
HOC is a function with a component that return a new component.
//geolocation.js
function withGeolocation(Component) {
function Geolocation() {
const [latitude, setLatitude] = React.useState(0);
const [longitude, setLongitude] = React.useState(0);
React.useEffect(() => {
@cdsandoval
cdsandoval / async fetch
Created June 23, 2019 06:21
How would you async fetch data for a React component
Using hooks with useEffect like this :
useState(async ()=>{
const response = await fetch(url);
const json = await response.json();
setData(json);
}
- with Classes using compenentDidMount or willMount :
@cdsandoval
cdsandoval / async fetch
Created June 23, 2019 06:21
How would you async fetch data for a React component
Using hooks with useEffect like this :
useState(async ()=>{
const response = await fetch(url);
const json = await response.json();
setData(json);
}
- with Classes using compenentDidMount or willMount :
@cdsandoval
cdsandoval / index.html
Created January 22, 2019 05:04
Calculadora de Tips
<!DOCTYPE html>
<html>
<head>
<title>Propinas</title>
<link rel="stylesheet" type="text/css" href="css/normalize.css" />
<link rel="stylesheet" type="text/css" href="css/styles.css" />
</head>
<body>
<div id="container">