Skip to content

Instantly share code, notes, and snippets.

View alberpad's full-sized avatar

Alberto Padrón Guillén alberpad

View GitHub Profile
@alberpad
alberpad / withPaginador.tsx
Created May 13, 2019 17:43
Paginación de elementos en React con un HOC
import React from "react";
export interface IWithPaginatorProps {}
export interface IWithPaginatorState {
paginador: {
offset: number;
actual: number;
};
}
// Si me funciona
async beforeRouteEnter(from: Route, to: Route, next: any) {
next((vm: Login) => {
if (vm.isLogged === true) {
next('/secret');
}
});
}
// No me funciona
//En el módulo order.js modificar la db.collection así
db.collection('orders').doc(orderId).set({
oid: orderId,
products: data.products,
totalCost: data.totalCost,
customer_id: rootState.authModule.user.uid,
createdAt: moment(new Date).format("DD/MM/YYYY")
})
//Luego seguir como en el curso
@alberpad
alberpad / index.js
Created October 6, 2018 19:17
functions/index.js
const functions = require('firebase-functions');
const admin = require('firebase-admin');
admin.initializeApp();
exports.newOrder = functions.firestore
.document('orders/{orderId}')
.onCreate((snap, context)=> {
const order = snap.data();
return admin.firestore().collection('orders').doc(order.oid).get().then(snap => {
return admin.firestore().collection('messages').doc(order.oid).set(