Skip to content

Instantly share code, notes, and snippets.

export const API_CONFIG = {
BASE_URL: import.meta.env.VITE_API_URL || 'http://localhost:8000/api',
TIMEOUT: 10000,
};
export const PRODUCT_STATUS = {
ACTIVE: 'active',
INACTIVE: 'inactive',
OUT_OF_STOCK: 'out_of_stock'
};
export const API_CONFIG = {
BASE_URL: import.meta.env.VITE_API_URL || 'http://localhost:8000/api',
TIMEOUT: 10000,
};
export const PRODUCT_STATUS = {
ACTIVE: 'active',
INACTIVE: 'inactive',
OUT_OF_STOCK: 'out_of_stock'
};
export const validateProduct = (product) => {
const errors = {};
if (!product.name || product.name.trim() === '') {
errors.name = 'Product name is required';
}
if (!product.price || product.price <= 0) {
errors.price = 'Price must be greater than 0';
}
export const Input = ({
label,
type = 'text',
value,
onChange,
placeholder,
error,
required = false,
...props
}) => {
import { useState, useEffect } from 'react';
import { productAPI } from '../services/api';
export const useProducts = () => {
const [products, setProducts] = useState([]);
const [loading, setLoading] = useState(false);
const [error, setError] = useState(null);
const fetchProducts = async () => {
setLoading(true);
const API_BASE_URL = import.meta.env.VITE_API_URL || 'http://localhost:8000/api';
const handleResponse = async (response) => {
if (!response.ok) {
const error = await response.json();
throw new Error(error.message || 'API request failed');
}
return response.json();
};
@wcapitalcodes
wcapitalcodes / AuthenticationTest.php
Created January 27, 2026 02:17
The authentication test script
<?php
use App\Models\User;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Foundation\Testing\WithFaker;
use Illuminate\Support\Facades\Hash;
use Tests\TestCase;
class AuthenticationTest extends TestCase
{