Skip to content

Instantly share code, notes, and snippets.

View sourabhbagrecha's full-sized avatar
🎯
Focusing

Sourabh Bagrecha sourabhbagrecha

🎯
Focusing
View GitHub Profile
const { useMutation } = require("react-query");
const useAuthedMutation = (...options) => {
const mutation = useMutation(...options);
if (mutation?.error?.response?.status === 401) {
// Insert custom access-token refresh logic here. For now, we are
// just refreshing the page here, so as to redirect them to the
// login page since their token is now expired.
window.location.reload();
}
const { useQuery } = require("react-query");
const useAuthedQuery = (...options) => {
const query = useQuery(...options);
if (query?.error?.response?.status === 401) {
// Insert custom access-token refresh logic here. For now, we are
// just refreshing the page here, so as to redirect them to the
// login page since their token is now expired.
window.location.reload();
}
import { useContext } from 'react';
import request, { gql } from 'graphql-request';
import PageContainer from "../components/PageContainer.component";
import { UserContext } from '../contexts/user.context';
import { GRAPHQL_ENDPOINT } from '../realm/constants';
import ExpenseCard from '../components/ExpenseCard.component';
import useAuthedQuery from '../hooks/useAuthedQuery';
const Home = () => {
const { user } = useContext(UserContext);
[
{
"$group": {
"_id": "$batsman",
"total_runs": {
"$sum": "$batsman_runs"
}
}
},
{
[
{
"$match": {
"extra_runs": { "$gt": 0 }
}
},
{
"$group": {
"_id": "$extras_type",
"runs": {
const mongoose = require("mongoose");
const claimSchema = mongoose.Schema({
billed_insurances: [
{ type: mongoose.Schema.Types.ObjectId, ref: "Insurance" },
],
});
const Claim = mongoose.model("Claim", claimSchema);
const insuranceSchema = mongoose.Schema({