Skip to content

Instantly share code, notes, and snippets.

View dueka's full-sized avatar

Ekanem David dueka

View GitHub Profile
@dueka
dueka / gist:5488169c00aec32f9daf977da04e8e20
Created January 13, 2021 06:54
Custom react hook to fetch data from an API
export const useInvestmentTypes = () => {
const [investmentTypesData, setInvestmentTypesData] = useState([]);
const token = selectToken.data.token;
const [loading, setLoading] = useState(false);
const [error, setError] = useState(null);
const fetchInvestmentsTypes = useCallback(() => {
const fetchInvestmentTypesData = async () => {
const req = async () => {
try {
@dueka
dueka / gist:ad66b7ed0ad418c9047a332b23659a89
Created August 3, 2021 14:07
custom hook for retrieving investment details
export const useInvestmentDetails = (id) => {
const [currentInvestment, setCurrentInvestment] = useState([]);
const token = selectToken;
const [loading, setLoading] = useState(false);
const [error, setError] = useState(null);
const fetchInvestmentDetails = useCallback(() => {
const fetcInvestmentData = async () => {
const req = async () => {
try {
import React, { useState } from "react";
import { Formik, Form } from "formik";
import * as Yup from "yup";
import InputField from "../../components/InputField";
import "./Login.scss";
import { withRouter, Link } from "react-router-dom";
import { useDispatch } from "react-redux";
import { setUser } from "../../redux/ducks/user";
import axios from "axios";
import Cookies from "js-cookie";
@dueka
dueka / gist:77736662ff91c3fc868e0380bc0df723
Created August 16, 2021 17:19
This describes the transactionService and viewTransactions for paginated transactions.
export const getAllTransactions = async (params) => {
const token = selectToken;
return await axiosWithAuth(token)
.get("/treasury/transactions?include=source,beneficiary,bank", { params })
.catch(function (error) {
if (error.response.status === 401) {
logout();
}
});
@dueka
dueka / data.ts
Last active December 5, 2021 18:02
import faker from "faker";
const rand = () => Math.floor(Math.random() * 10) + 2;
const messages = [
{
id: "1",
body: "Cursus turpis massa tincidunt dui. Non pulvinar neque laoreet suspendisse interdum consectetur libero id. Quis varius quam quisque id diam vel quam. Aenean sed adipiscing ",
},
{
id: "2",
import { ChildDataProps, graphql } from "@apollo/react-hoc";
import { useQuery, gql } from "@apollo/client";
import ProjectsColumn from "./ProjectsColumn";
import { useState } from "react";
interface ProjectProps {
location: any;
history: any;
}
// SPDX-License-Identifier: GPL-3.0
/**
!Disclaimer!
These contracts have been used to create tutorials,
and was created for the purpose to teach people
how to create smart contracts on the blockchain.
please review this code on your own before using any of
the following code for production.
*/
@dueka
dueka / createRandomData.ts
Created February 22, 2023 16:50
Create random data
interface IData {
name?: string;
department?: string;
teamlead?: string;
role?: string;
location?: string;
lga?: string;
country?: string;
due_date?: string;
children?: JSX.Element | JSX.Element[];
@dueka
dueka / TranscribeOutput.tsx
Created April 29, 2023 14:51
TranscribeOutput.tsx
import React from 'react';
import {Text, View, StyleSheet} from 'react-native';
const TranscribedOutput = ({transcribedText, interimTranscribedText}: any) => {
if (transcribedText.length === 0 && interimTranscribedText.length === 0) {
return <Text>...</Text>;
}
return (
<View style={styles.box}>
@dueka
dueka / App.tsx
Created April 29, 2023 14:52
App.tsx
import React, {useRef, useState, useEffect} from 'react';
import {
SafeAreaView,
ScrollView,
StyleSheet,
Text,
View,
Switch,
ActivityIndicator,
} from 'react-native';