Skip to content

Commit

Permalink
Added date filtering to chart
Browse files Browse the repository at this point in the history
  • Loading branch information
thedanielforum committed Jul 8, 2022
1 parent 843c7aa commit 5ed86be
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 5 deletions.
20 changes: 16 additions & 4 deletions components/CategoryChart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import Dinero from "dinero.js";
import Loading from "components/Loading";

const GET_CATEGORY_CHART_DATA = gql`
query categoryChartData {
queryTransaction {
query categoryChartData($filter: TransactionFilter) {
queryTransaction(filter: $filter) {
id
amount
category {
Expand All @@ -19,13 +19,25 @@ const GET_CATEGORY_CHART_DATA = gql`
}
`;

const CategoryChart: React.FC = () => {
export interface CategoryChartProps {
dateStart?: Date;
dateEnd?: Date;
}

const CategoryChart: React.FC<CategoryChartProps> = (props) => {
const intl = useIntl();
const {
data: pieChartData,
loading,
error,
} = useQuery(GET_CATEGORY_CHART_DATA, {});
} = useQuery(GET_CATEGORY_CHART_DATA, {
variables: {
filter:
props.dateStart && props.dateEnd
? { date: { between: { min: props.dateStart, max: props.dateEnd } } }
: {},
},
});
if (error) {
console.error(error);
}
Expand Down
5 changes: 4 additions & 1 deletion pages/dashboard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,10 @@ const Dashboard: NextPage = () => {
</div>
</div>
<div className="flex flex-row justify-start">
<CategoryChart />
<CategoryChart
dateStart={dateStart.toJSDate()}
dateEnd={dateEnd.toJSDate()}
/>
</div>
</div>
<div className="w-1/2 ml-2 pt-2">
Expand Down

1 comment on commit 5ed86be

@vercel
Copy link

@vercel vercel bot commented on 5ed86be Jul 8, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

ikura – ./

ikura-git-main-zefhub.vercel.app
ikura-zefhub.vercel.app
ikura.vercel.app
www.ikura.app
ikura.app

Please sign in to comment.