Skip to content

Instantly share code, notes, and snippets.

Avatar
🎖️
Never give up!

Waldo Lavaut waldothedeveloper

🎖️
Never give up!
View GitHub Profile
View gist:c4716444871e8b3b064e1262752d3003
import { useMemo, useState } from "react";
import { chatFetchers } from "../../utils/chatFetchers";
import { selectedConversation } from "../../components/shared/selectedConversation";
import { useAddSMSParticipant } from "./useAddSMSParticipant";
import { useCreateAccessToken } from "./useCreateAccessToken";
import { useCreateConversation } from "./useCreateConversation";
import { useDeliveryReceipt } from "./useDeliveryReceipt";
import { useInitializeConversationClient } from "./useInitializeConversationClient";
import { useJoinAndLeaveConversations } from "./useJoinAndLeaveConversations";
View gist:c100cb1e6eec39f0e0f7b38c6b2b81f8
import { useEffect, useState } from "react";
export const useSendAndReceiveMessages = (selectedConversation) => {
const [conversationMessage, setConversationMessage] = useState({
newMessage: ``,
messages: [],
conversationProxy: null,
loadingState: `initializing`,
});
View fetchManyThings.js
useEffect(() => {
if (userInfo.requestConversation) {
if (userInfo.sid) {
setCreateOrGetConversation((oldData) => {
return {
...oldData,
selectedConversationSid: userInfo.sid,
};
});
View useForgotPassword.js
import { getAuth, sendPasswordResetEmail } from "firebase/auth";
import { useEffect, useState } from "react";
import { app } from "../../utils/firebaseConfig";
import { navigate } from "gatsby";
import { validEmailRegex } from "./validateEmailHelper";
const auth = getAuth(app);
auth.languageCode = `es`;
View forgotPasswordForm.test.js
import { render, screen } from "@testing-library/react";
import { ForgotPasswordForm } from "../authentication/forgotPasswordForm";
import React from "react";
import userEvent from "@testing-library/user-event";
jest.mock(`gatsby-plugin-image`, () => {
const React = require(`react`);
const plugin = jest.requireActual(`gatsby-plugin-image`);
View forgotPasswordForm.js
import { LockClosedIcon, LockOpenIcon } from "@heroicons/react/solid";
import { Link } from "gatsby";
import Notifications from "../notifications";
import React from "react";
import { StaticImage } from "gatsby-plugin-image";
import { useForgotPassword } from "../../hooks/authentication/useForgotPassword";
export const ForgotPasswordForm = () => {
const {
View forgotPasswordForm.js
import { LockClosedIcon, LockOpenIcon } from "@heroicons/react/solid";
import { Link } from "gatsby";
import Notifications from "../notifications";
import React from "react";
import { StaticImage } from "gatsby-plugin-image";
import { useForgotPassword } from "../../hooks/authentication/useForgotPassword";
export const ForgotPasswordForm = () => {
const {
View Status.js
import Error from "./error";
// import { MatchWord } from "../utils/matchWord";
import React from "react";
import { convertBytes } from "../utils/convertBytes";
import { displayLocaleDates } from "../utils/displayLocaleDates";
import { getTimeRemaining } from "../utils/getTimeRemaining";
import { useStatus } from "../hooks/useStatus";
export default function Status() {
const { data, isError, isLoading } = useStatus(2);
View tasks.js
import { Headers } from "node-fetch";
import { classifyTaks } from "../../utils/classifyTaks";
import fetch from "node-fetch";
export default async function fetchTasks(req, res) {
const url = `http://localhost:3000/api/${req.params.id}`;
// ! IMPORTANT: A .env file should be used here for the api-key value, but for the sake of this example, I'm using a hardcoded value.
const headers = new Headers();
headers.append("api-key", "globus");
View gist:8ca70aa26470923a26618b2939a5f128
import { Card } from "./card";
import React from "react";
import { StaticImage } from "gatsby-plugin-image";
export const StaticImages = () => {
return (
<div className="my-0 w-full h-full self-end relative overflow-hidden">
{/* background color image for xl devices only */}
<div className="hidden xl:block xl:absolute xl:inset-0 xl:w-full xl:mt-20">
<StaticImage
imgStyle={{