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({ |
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
| [ | |
| { | |
| "$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
| 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
| 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
| 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
| import { useContext, useState } from "react"; | |
| import PageContainer from "../components/PageContainer.component"; | |
| import { UserContext } from "../contexts/user.context"; | |
| import { gql, request } from "graphql-request"; | |
| import { GRAPHQL_ENDPOINT } from "../realm/constants"; | |
| import ExpenseForm from "../components/ExpenseForm.component"; | |
| import { useParams, useNavigate } from "react-router-dom"; | |
| import { useMutation, useQuery } from "react-query"; | |
| const EditExpense = () => { |
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, useState } from "react"; | |
| import PageContainer from "../components/PageContainer.component"; | |
| import { UserContext } from "../contexts/user.context"; | |
| import { gql, request } from "graphql-request"; | |
| import { GRAPHQL_ENDPOINT } from "../realm/constants"; | |
| import ExpenseForm from "../components/ExpenseForm.component"; | |
| import { useNavigate } from "react-router-dom"; | |
| import { useMutation } from "react-query"; | |
| const CreateExpense = () => { |
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, useState } from "react"; | |
| import { Button, Grid } from "@mui/material"; | |
| import request, { gql } from "graphql-request"; | |
| import { formatISO, subMonths, endOfToday, startOfDay, endOfDay } from "date-fns"; | |
| import { UserContext } from "../contexts/user.context"; | |
| import { GRAPHQL_ENDPOINT } from "../realm/constants"; | |
| import PageContainer from "../components/PageContainer.component"; | |
| import CustomDatePicker from "../components/CustomDatePicker.component"; | |
| import ModeAnalytics from "../components/ModeAnalytics.component"; | |
| import CategoryAnalytics from "../components/CategoryAnalytics.component"; |
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 { useQuery } from 'react-query'; | |
| const Home = () => { | |
| const { user } = useContext(UserContext); |
NewerOlder