Skip to content

Instantly share code, notes, and snippets.

View xtiannyeto's full-sized avatar
🎯
Focusing

Christian Tonye xtiannyeto

🎯
Focusing
View GitHub Profile
@xtiannyeto
xtiannyeto / pokemonApi.tsx
Last active February 15, 2022 13:11
RTK query starter
import { createApi, fetchBaseQuery } from '@reduxjs/toolkit/query/react'
import { Pokemon } from './types'
// Define a service using a base URL and expected endpoints
export const pokemonApi = createApi({
reducerPath: 'pokemonApi',
baseQuery: fetchBaseQuery({ baseUrl: 'https://pokeapi.co/api/v2/' }),
endpoints: (builder) => ({
getPokemonByName: builder.query<Pokemon, string>({
query: (name) => `pokemon/${name}`,
@xtiannyeto
xtiannyeto / app.tsx
Last active October 15, 2021 16:03
app.tsx
import { Button, createTheme, ThemeProvider } from '@mui/material';
import React from 'react';
import './App.scss';
import styles from './style.module.scss';
function App() {
const theme = createTheme({
palette: {
primary: {
main: styles.colorPrimary
<template>
<button @click="signIn">login</button>
<button @click="signOut">log out</button>
<div>{{ user }}</div>
</template>
<script lang="ts">
import { defineComponent, onMounted, ref } from '@vue/runtime-core';
import { initFacebook, login, logout } from './FacebookAuth';
export default defineComponent({
@xtiannyeto
xtiannyeto / FacebookAuth.ts
Last active September 27, 2021 11:02
Encapsulate facebook-sdk-wra
export interface FaceBookResponse {
email: string;
name: string;
picture: string;
authResponse: any;
}
// import * as Facebook from 'fb-sdk-wrapper';
// eslint-disable-next-line @typescript-eslint/no-var-requires
import * as Facebook from 'fb-sdk-wrapper';
@xtiannyeto
xtiannyeto / GoogleAuth.vue
Last active September 25, 2021 19:56
Google Vue component
<template>
<button @click="signIn">login</button>
<button @click="signOut">log out</button>
<div>{{ user }}</div>
</template>
<script lang="ts">
import { defineComponent, onMounted, ref } from '@vue/runtime-core';
import { installGoogleAuth } from './GoogleAuth';
export default defineComponent({
@xtiannyeto
xtiannyeto / GoogleAuth.ts
Created September 20, 2021 12:18
Export a method which return an instance with any config
export async function installGoogleAuth(options: any): Promise<any> {
// set config
let GoogleAuthConfig: any = null;
const GoogleAuthDefaultConfig = {
scope: 'profile email'
};
let prompt = 'select_account';
if (typeof options === 'object') {
GoogleAuthConfig = Object.assign(GoogleAuthDefaultConfig, options);
if (options.scope) {
@xtiannyeto
xtiannyeto / GoogleAuth.ts
Created September 20, 2021 12:04
Encapsulate Gapi
const googleAuth = ((): any => {
const installClient = () => {
const apiUrl = 'https://apis.google.com/js/api.js';
return new Promise<void>((resolve) => {
const script: any = document.createElement('script');
script.src = apiUrl;
script.onreadystatechange = script.onload = () => {
if (!script.readyState || /loaded|complete/.test(script.readyState)) {
setTimeout(() => {