From 258da483236b0bdc628c5b06707bcde14837ae87 Mon Sep 17 00:00:00 2001
From: Harshal Dulera <111957198+harshaldulera@users.noreply.github.com>
Date: Sun, 8 Dec 2024 04:19:31 +0530
Subject: [PATCH] feat: add axios and update dependencies
---
package.json | 1 +
packages/nextjs/app/layout.tsx | 6 +-
packages/nextjs/components/StepComponent.tsx | 2 +-
packages/nextjs/context/FitnessContext.tsx | 59 ++++++++++----------
yarn.lock | 3 +-
5 files changed, 35 insertions(+), 36 deletions(-)
diff --git a/package.json b/package.json
index df7f1e2..b1d2eef 100644
--- a/package.json
+++ b/package.json
@@ -61,6 +61,7 @@
"@apollo/experimental-nextjs-app-support": "^0.11.7",
"@ethereum-attestation-service/eas-sdk": "^2.7.0",
"@graphprotocol/graph-cli": "^0.91.1",
+ "axios": "^1.7.9",
"ethereum-blockies": "^0.1.1",
"framer-motion": "^11.13.1",
"graphql": "^16.9.0",
diff --git a/packages/nextjs/app/layout.tsx b/packages/nextjs/app/layout.tsx
index 4fae581..3b20cce 100644
--- a/packages/nextjs/app/layout.tsx
+++ b/packages/nextjs/app/layout.tsx
@@ -87,10 +87,10 @@ const TokenHandler = ({ children }: { children: React.ReactNode }) => {
return <>{children}>;
};
-const MomentumApp = ({ children }: { children: React.ReactNode }) => {
+const ScaffoldEthApp = ({ children }: { children: React.ReactNode }) => {
return (
-
+
@@ -109,4 +109,4 @@ const MomentumApp = ({ children }: { children: React.ReactNode }) => {
);
};
-export default MomentumApp;
+export default ScaffoldEthApp;
\ No newline at end of file
diff --git a/packages/nextjs/components/StepComponent.tsx b/packages/nextjs/components/StepComponent.tsx
index 9721c28..27e1feb 100644
--- a/packages/nextjs/components/StepComponent.tsx
+++ b/packages/nextjs/components/StepComponent.tsx
@@ -48,4 +48,4 @@ const StepComponent: FC = ({ totalSteps = 6000 }) => {
);
};
-export default StepComponent;
+export default StepComponent;
\ No newline at end of file
diff --git a/packages/nextjs/context/FitnessContext.tsx b/packages/nextjs/context/FitnessContext.tsx
index 51a6abb..5370477 100644
--- a/packages/nextjs/context/FitnessContext.tsx
+++ b/packages/nextjs/context/FitnessContext.tsx
@@ -1,16 +1,14 @@
"use client";
-import { createContext, useCallback, useContext, useState } from "react";
-import axios from "axios";
+import { createContext, useContext, useState, useCallback } from 'react';
+import axios from 'axios';
interface FitnessContextType {
fitnessData: any;
- setFitnessData: (data: any) => void; // Add this line
+ setFitnessData: (data: any) => void; // Add this line
fetchFitnessData: () => Promise;
accessToken: string | null;
setAccessToken: (token: string | null) => void;
- refreshToken: string | null;
- setRefreshToken: (token: string | null) => void;
}
const FitnessContext = createContext(undefined);
@@ -18,7 +16,6 @@ const FitnessContext = createContext(undefined);
export function FitnessProvider({ children }: { children: React.ReactNode }) {
const [fitnessData, setFitnessData] = useState(null);
const [accessToken, setAccessToken] = useState(null);
- const [refreshToken, setRefreshToken] = useState(null);
const fetchFitnessData = useCallback(async () => {
if (!accessToken) return;
@@ -28,41 +25,41 @@ export function FitnessProvider({ children }: { children: React.ReactNode }) {
const endOfDay = new Date(now.setHours(23, 59, 59, 999)).getTime();
const data = {
- aggregateBy: [
- {
- dataTypeName: "com.google.step_count.delta",
- },
- ],
+ aggregateBy: [{
+ dataTypeName: "com.google.step_count.delta"
+ }],
startTimeMillis: startOfDay,
endTimeMillis: endOfDay,
bucketByTime: {
- durationMillis: 86400000,
- },
+ durationMillis: 86400000
+ }
};
try {
- const response = await axios.post("https://www.googleapis.com/fitness/v1/users/me/dataset:aggregate", data, {
- headers: {
- Authorization: `Bearer ${accessToken}`,
- "Content-Type": "application/json",
- },
- });
+ const response = await axios.post(
+ 'https://www.googleapis.com/fitness/v1/users/me/dataset:aggregate',
+ data,
+ {
+ headers: {
+ 'Authorization': `Bearer ${accessToken}`,
+ 'Content-Type': 'application/json'
+ }
+ }
+ );
setFitnessData(response.data);
} catch (error) {
- console.error("Error fetching fitness data:", error);
+ console.error('Error fetching fitness data:', error);
}
}, [accessToken]);
return (
-
+
{children}
);
@@ -71,7 +68,7 @@ export function FitnessProvider({ children }: { children: React.ReactNode }) {
export function useFitness() {
const context = useContext(FitnessContext);
if (context === undefined) {
- throw new Error("useFitness must be used within a FitnessProvider");
+ throw new Error('useFitness must be used within a FitnessProvider');
}
return context;
-}
+}
\ No newline at end of file
diff --git a/yarn.lock b/yarn.lock
index 5cb23da..5659421 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -7326,7 +7326,7 @@ __metadata:
languageName: node
linkType: hard
-"axios@npm:^1.6.7":
+"axios@npm:^1.6.7, axios@npm:^1.7.9":
version: 1.7.9
resolution: "axios@npm:1.7.9"
dependencies:
@@ -17542,6 +17542,7 @@ __metadata:
"@ethereum-attestation-service/eas-sdk": ^2.7.0
"@graphprotocol/graph-cli": ^0.91.1
"@types/ethereum-blockies": ^0
+ axios: ^1.7.9
ethereum-blockies: ^0.1.1
framer-motion: ^11.13.1
graphql: ^16.9.0