Skip to content

Instantly share code, notes, and snippets.

View ArtifactyNight's full-sized avatar

Night ArtifactyNight

View GitHub Profile
---
description: ORPC Client with Tanstack Query usage patterns for Next.js applications
globs: *.ts,*.tsx
---
# ORPC Client with Tanstack Query Usage
## Client Setup and Configuration
### Basic Client Setup
import crypto from "crypto";
// Types based on OpenAPI specification
export interface BeamCheckoutConfig {
merchantId: string;
secretKey: string;
publishableKey?: string;
baseUrl?: string;
}
import axios, { isAxiosError } from "axios";
const BASE_URL = process.env.MANYPAY_BASE_URL as string;
export interface CreatePaymentResponse {
ffpReferenceNo: string;
referenceNo: string;
qrcode: string;
resultCode: string;
resultMessage: string;
@ArtifactyNight
ArtifactyNight / file-input.tsx
Created November 14, 2024 17:28
awesome simple shadcn/ui file input
"use client";
import { Input } from "@/components/ui/input";
import { X } from "lucide-react";
import React, { useEffect, useRef, useState } from "react";
interface FileInputProps extends React.InputHTMLAttributes<HTMLInputElement> {
defaultImageUrl?: string;
}
@ArtifactyNight
ArtifactyNight / responsive-modal.tsx
Last active November 10, 2024 07:07
Credenza reusable component
import { cn } from "@/lib/utils";
import { VisuallyHidden } from "@radix-ui/react-visually-hidden";
import {
Credenza,
CredenzaBody,
CredenzaContent,
CredenzaDescription,
CredenzaFooter,
CredenzaHeader,
CredenzaTitle,
@ArtifactyNight
ArtifactyNight / Dockerfile
Last active December 12, 2024 13:31
Dockerfile for bun, next.js and prisma
# syntax=docker/dockerfile:1.4
# Base image with Bun runtime
FROM oven/bun:latest AS base
WORKDIR /app
# Install dependencies only when needed
FROM base AS deps
WORKDIR /app
@ArtifactyNight
ArtifactyNight / use-image-uploader.ts
Last active August 14, 2024 16:59
Custom image uploader hooks for React! (powered by m1r.ai)
import { useState } from 'react';
const useImageUploader = () => {
const [isUploading, setIsUploading] = useState(false);
const uploadFile = async (file: File) => {
setIsUploading(true);
if (!file.type.startsWith('image/')) {
throw new Error('ไฟล์ต้องเป็นรูปภาพเท่านั้น');