Skip to content

Instantly share code, notes, and snippets.

View cvega21's full-sized avatar
🎯
Focusing

Christian Vega-Munguia cvega21

🎯
Focusing
View GitHub Profile
const getTogglProjectData = async (since: string, until: string, pageNum = 1) => {
const reportData = await axiosClient.get(`/reports/api/v2/details`, {
params: {
'user_agent': process.env.USER_AGENT,
'workspace_id': process.env.WORKSPACE_ID,
'project_ids': process.env.PROJECT_ID,
'since': since,
'until': until,
'page': pageNum
}})
@cvega21
cvega21 / ProjectsPage.tsx
Last active August 25, 2021 01:06
Projects page
interface ProjectType {
[key: string]: string;
}
interface ProjectData {
projects: ProjectType;
projectsMetadata: ProjectType;
}
interface ProjectsProps {
@cvega21
cvega21 / App.tsx
Created August 24, 2021 04:39
Keep portfolio data as app-level state
function App() {
const [projectsData, setProjectsData] = useState({projects: {placeholder: ''}, projectsMetadata: {placeholder: ''}});
...
useEffect(() => {
const getProjects = async () => {
let firebaseReq = await database.ref(`/`).once('value');
let firebaseJSON = await firebaseReq.val();
setProjectsData(firebaseJSON);
}
@cvega21
cvega21 / getDailyData.ts
Last active August 25, 2021 01:08
Project Data - Firebase Scheduled Function
interface projectsTimeInterface {
[key: string]: number
}
interface togglRecordInterface {
[key: string]: number | string | null | boolean | Array<string>
}
exports.getDailyData = functions.pubsub.schedule('0 4 * * *')
.timeZone('America/Mexico_City')
@cvega21
cvega21 / .json
Last active August 24, 2021 03:17
Toggl API Data Snippet
{
"total_count":2,
"per_page":50,
...
"data":[
{
...
"description":"tegin tööd",
"start":"2013-05-20T06:55:04",
"end":"2013-05-20T10:55:04",