Skip to content

Instantly share code, notes, and snippets.

View gildembergleite's full-sized avatar

Gildemberg Leite gildembergleite

View GitHub Profile
# Server
API_LOCAL_BASE_URL=http://localhost:3000/api
API_BASE_URL=https://api.parceiros.sistematodos.com.br/v1/filiado
API_USER=mgm
API_PASSWORD=30TMwQ2bea7f
API_AUTH_BASE_URL=https://wallet-homolog.maistodos.com.br/api/v1/member-get-member/auth
API_AUTH_USER=cdt-mgm
API_AUTH_PASSWORD=5069g2zpz31qbhbysicbuncjfbmiimwgs9ex9nodll7i93afycdh7iffm259ggma
API_KEY=apikeyUNIzsmpFfh1sfleSCh-E1U_lV1mlNBKNiLbG2LXW__21Jmg8FuL3ciKpmskRl_hh3tmHzgjLQ3ahHz-dpM6yGg
FERNET_KEY=qltrY4rh25bHsAgGSqgh3EBhrHgELCtH4lrNzADxVK8=
@gildembergleite
gildembergleite / base-api-service.ts
Last active August 20, 2024 01:09
Base API with Fetch using OOP
export type RequestParams = Record<string, string | number>;
export type RequestHeaders = Record<string, string>;
export interface HttpClient {
request<T>(url: string, options: RequestOptions): Promise<T>;
}
export interface RequestOptions {
method?: string;
headers?: RequestHeaders;
@gildembergleite
gildembergleite / setting.json
Last active March 8, 2025 14:55
Minimalist VSCode Settings
{
"emulator.simulatorPath": "/Applications/Xcode.app/Contents/Developer/Applications/Simulator.app",
"update.mode": "manual",
"breadcrumbs.enabled": false,
"editor.defaultFormatter": "dbaeumer.vscode-eslint",
"emmet.syntaxProfiles": {
"javascript": "jsx"
},
"editor.fontSize": 16,
"javascript.suggest.autoImports": true,
@gildembergleite
gildembergleite / useHexToRgba.tsx
Created April 24, 2024 20:22
React Hook - Hex to RGBA
import { useState } from 'react'
function hexToRgba(hex: string, opacity: number) {
hex = hex.replace('#', '')
const r = parseInt(hex.substring(0, 2), 16)
const g = parseInt(hex.substring(2, 4), 16)
const b = parseInt(hex.substring(4, 6), 16)
return `rgba(${r}, ${g}, ${b}, ${opacity})`
}
@gildembergleite
gildembergleite / typography.tsx
Last active April 17, 2024 21:31
Typography with tailwind
import { HTMLAttributes } from 'react'
import { twMerge } from 'tailwind-merge'
export const Typography = {
H1: ({
children,
className,
...rest
}: HTMLAttributes<HTMLHeadingElement>) => (
<h1
@gildembergleite
gildembergleite / google-maps-instance.ts
Created March 12, 2024 11:55
Google Maps Intance with Heatmap Layer and Polylines with Markers
/* eslint-disable no-undef */
import { env } from '@/env'
import { buildColor } from '@/utils/build-color'
import { mapDarkStyle } from '@/utils/map-dark-style'
import { mapHiddenStyle } from '@/utils/map-hidden-style'
import { Loader, LoaderOptions } from '@googlemaps/js-api-loader'
import MarkerClusterer from '@googlemaps/markerclustererplus'
export class Map {
private mapInstance: google.maps.Map | null = null
@gildembergleite
gildembergleite / drawer.tsx
Last active February 2, 2024 13:21
shadcn/ui Drawer with Context API
'use client'
import * as React from 'react'
import { Drawer as DrawerPrimitive } from 'vaul'
import { cn } from '@/lib/utils/ui'
const DrawerContext = React.createContext<{
direction?: 'top' | 'bottom' | 'right' | 'left'
}>({})
@gildembergleite
gildembergleite / lifecyles.ts
Created January 26, 2024 12:21
afterCreate and afterUpdate - Strapi
import axios from "axios";
export default {
async afterCreate(event) {
const routeId = event.result.id;
const address = event.result.startingAddress;
const coordinates = await strapi
.service("api::route.route")
.getCoordinates(routeId);
async function handleEditClient(data: Client) {
const url = `${process.env.NEXT_PUBLIC_API_URL}/clients/${rowsIds[0]}`
const body = {
data: {
email: data.email,
name: data.name,
phone: data.phone,
address: {
cep: data.cep,
@gildembergleite
gildembergleite / strapi-server.ts
Created January 24, 2024 12:03
Check if the user is registered and active on strapi
export default (plugin) => {
plugin.controllers.user.userExists = async (ctx) => {
const baseUrl = '/api/user-exists/'
const username = ctx.request.url.slice(baseUrl.length).toLowerCase()
const response = await strapi.entityService.findMany('admin::user', {
filters: {
username: username,
isActive: true,
blocked: false
}