feat: initial commit — backend API + student cabinet frontend

- Go backend: auth (JWT), points earn/spend, QR token generation,
  partners, admin grant/stats endpoints with chi router
- Next.js 14 frontend: login, student dashboard, transaction history,
  QR display, partners list
- PostgreSQL migrations (4 tables), Redis cache, Docker Compose
- CORS middleware, role-based route protection, Zustand auth store

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
emil
2026-05-01 10:03:27 +03:00
co-authored by Claude Sonnet 4.6
commit 50b3c4198a
80 changed files with 10579 additions and 0 deletions
+29
View File
@@ -0,0 +1,29 @@
import type { TransactionType } from '@/lib/types';
const TYPE_LABELS: Record<TransactionType, string> = {
earn: 'Начисление',
spend: 'Списание',
admin_grant: 'Начисление',
expire: 'Сгорание',
};
const TYPE_CLASSES: Record<TransactionType, string> = {
earn: 'bg-green-900/50 text-green-400',
spend: 'bg-red-900/50 text-red-400',
admin_grant: 'bg-blue-900/50 text-blue-400',
expire: 'bg-gray-700 text-gray-400',
};
interface BadgeProps {
type: TransactionType;
}
export function Badge({ type }: BadgeProps) {
return (
<span
className={`inline-flex shrink-0 items-center rounded-full px-2 py-0.5 text-xs font-medium ${TYPE_CLASSES[type]}`}
>
{TYPE_LABELS[type]}
</span>
);
}
+36
View File
@@ -0,0 +1,36 @@
import { type ButtonHTMLAttributes } from 'react';
type Variant = 'primary' | 'secondary' | 'ghost';
interface ButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> {
variant?: Variant;
isLoading?: boolean;
}
const VARIANT_CLASSES: Record<Variant, string> = {
primary: 'bg-blue-600 text-white hover:bg-blue-500 disabled:bg-blue-800 disabled:text-blue-400',
secondary: 'bg-gray-700 text-gray-200 hover:bg-gray-600 disabled:opacity-50',
ghost: 'bg-transparent text-blue-400 hover:bg-gray-700 disabled:opacity-50',
};
export function Button({
variant = 'primary',
isLoading = false,
disabled,
children,
className = '',
...props
}: ButtonProps) {
return (
<button
disabled={disabled ?? isLoading}
className={`inline-flex items-center justify-center gap-2 rounded-lg px-4 py-2 text-sm font-medium transition-colors focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2 focus:ring-offset-gray-900 ${VARIANT_CLASSES[variant]} ${className}`}
{...props}
>
{isLoading && (
<span className="h-4 w-4 animate-spin rounded-full border-2 border-current border-t-transparent" />
)}
{children}
</button>
);
}
+16
View File
@@ -0,0 +1,16 @@
import { type HTMLAttributes } from 'react';
interface CardProps extends HTMLAttributes<HTMLDivElement> {
children: React.ReactNode;
}
export function Card({ children, className = '', ...props }: CardProps) {
return (
<div
className={`rounded-2xl bg-gray-800 p-6 shadow-sm ring-1 ring-gray-700 ${className}`}
{...props}
>
{children}
</div>
);
}
+23
View File
@@ -0,0 +1,23 @@
import { type InputHTMLAttributes, useId } from 'react';
interface InputProps extends InputHTMLAttributes<HTMLInputElement> {
label: string;
error?: string;
}
export function Input({ label, error, className = '', ...props }: InputProps) {
const id = useId();
return (
<div className="flex flex-col gap-1">
<label htmlFor={id} className="text-sm font-medium text-gray-300">
{label}
</label>
<input
id={id}
className={`rounded-lg border bg-gray-700 px-3 py-2 text-sm text-white placeholder-gray-500 outline-none transition-colors focus:ring-2 ${error ? 'border-red-500 focus:border-red-500 focus:ring-red-800' : 'border-gray-600 focus:border-blue-500 focus:ring-blue-900'} ${className}`}
{...props}
/>
{error && <p className="text-xs text-red-400">{error}</p>}
</div>
);
}
+20
View File
@@ -0,0 +1,20 @@
interface SpinnerProps {
size?: 'sm' | 'md' | 'lg';
className?: string;
}
const SIZE_CLASSES = {
sm: 'h-4 w-4 border-2',
md: 'h-8 w-8 border-2',
lg: 'h-12 w-12 border-4',
};
export function Spinner({ size = 'md', className = '' }: SpinnerProps) {
return (
<div
role="status"
aria-label="Загрузка"
className={`animate-spin rounded-full border-blue-600 border-t-transparent ${SIZE_CLASSES[size]} ${className}`}
/>
);
}
+5
View File
@@ -0,0 +1,5 @@
export { Button } from './Button';
export { Input } from './Input';
export { Card } from './Card';
export { Badge } from './Badge';
export { Spinner } from './Spinner';