This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[ | |
{ | |
"$group": { | |
"_id": "$batsman", | |
"total_runs": { | |
"$sum": "$batsman_runs" | |
} | |
} | |
}, | |
{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[ | |
{ | |
"$match": { | |
"extra_runs": { "$gt": 0 } | |
} | |
}, | |
{ | |
"$group": { | |
"_id": "$extras_type", | |
"runs": { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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({ |
OlderNewer