Compare commits
4 Commits
326b30161b
...
feature/lo
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
75c7c28f73 | ||
|
|
99fdaaa05a | ||
|
|
e589ff02f0 | ||
|
|
da4b765b14 |
@@ -21,6 +21,10 @@ jobs:
|
|||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: bun install --frozen-lockfile
|
run: bun install --frozen-lockfile
|
||||||
|
|
||||||
|
- name: Generate route tree
|
||||||
|
working-directory: packages/admin
|
||||||
|
run: bunx @tanstack/router-cli generate
|
||||||
|
|
||||||
- name: Lint
|
- name: Lint
|
||||||
run: bun run lint
|
run: bun run lint
|
||||||
|
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ COPY packages/admin ./packages/admin
|
|||||||
COPY package.json ./
|
COPY package.json ./
|
||||||
COPY tsconfig.base.json ./
|
COPY tsconfig.base.json ./
|
||||||
WORKDIR /app/packages/admin
|
WORKDIR /app/packages/admin
|
||||||
|
RUN bunx @tanstack/router-cli generate
|
||||||
RUN bun run build
|
RUN bun run build
|
||||||
|
|
||||||
FROM nginx:alpine
|
FROM nginx:alpine
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ import { posMutations, posKeys, type Transaction } from '@/api/pos'
|
|||||||
import { Button } from '@/components/ui/button'
|
import { Button } from '@/components/ui/button'
|
||||||
import { Separator } from '@/components/ui/separator'
|
import { Separator } from '@/components/ui/separator'
|
||||||
import { Input } from '@/components/ui/input'
|
import { Input } from '@/components/ui/input'
|
||||||
import { Label } from '@/components/ui/label'
|
|
||||||
import { Popover, PopoverContent, PopoverTrigger } from '@/components/ui/popover'
|
import { Popover, PopoverContent, PopoverTrigger } from '@/components/ui/popover'
|
||||||
import { X, Banknote, CreditCard, FileText, Ban, UserRound, Tag } from 'lucide-react'
|
import { X, Banknote, CreditCard, FileText, Ban, UserRound, Tag } from 'lucide-react'
|
||||||
import { toast } from 'sonner'
|
import { toast } from 'sonner'
|
||||||
|
|||||||
@@ -100,7 +100,6 @@ function useStoreLogo(companyId?: string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function POSReceipt({ data, size = 'thermal', footerText, config }: POSReceiptProps) {
|
export function POSReceipt({ data, size = 'thermal', footerText, config }: POSReceiptProps) {
|
||||||
const { transaction: txn, company, location } = data
|
|
||||||
const isThermal = size === 'thermal'
|
const isThermal = size === 'thermal'
|
||||||
|
|
||||||
if (!isThermal) {
|
if (!isThermal) {
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ import { Route as AuthenticatedFilesIndexRouteImport } from './routes/_authentic
|
|||||||
import { Route as AuthenticatedAccountsIndexRouteImport } from './routes/_authenticated/accounts/index'
|
import { Route as AuthenticatedAccountsIndexRouteImport } from './routes/_authenticated/accounts/index'
|
||||||
import { Route as AuthenticatedRolesNewRouteImport } from './routes/_authenticated/roles/new'
|
import { Route as AuthenticatedRolesNewRouteImport } from './routes/_authenticated/roles/new'
|
||||||
import { Route as AuthenticatedRolesRoleIdRouteImport } from './routes/_authenticated/roles/$roleId'
|
import { Route as AuthenticatedRolesRoleIdRouteImport } from './routes/_authenticated/roles/$roleId'
|
||||||
|
import { Route as AuthenticatedReportsDailyRouteImport } from './routes/_authenticated/reports/daily'
|
||||||
import { Route as AuthenticatedRepairsTemplatesRouteImport } from './routes/_authenticated/repairs/templates'
|
import { Route as AuthenticatedRepairsTemplatesRouteImport } from './routes/_authenticated/repairs/templates'
|
||||||
import { Route as AuthenticatedRepairsNewRouteImport } from './routes/_authenticated/repairs/new'
|
import { Route as AuthenticatedRepairsNewRouteImport } from './routes/_authenticated/repairs/new'
|
||||||
import { Route as AuthenticatedRepairsTicketIdRouteImport } from './routes/_authenticated/repairs/$ticketId'
|
import { Route as AuthenticatedRepairsTicketIdRouteImport } from './routes/_authenticated/repairs/$ticketId'
|
||||||
@@ -152,6 +153,12 @@ const AuthenticatedRolesRoleIdRoute =
|
|||||||
path: '/roles/$roleId',
|
path: '/roles/$roleId',
|
||||||
getParentRoute: () => AuthenticatedRoute,
|
getParentRoute: () => AuthenticatedRoute,
|
||||||
} as any)
|
} as any)
|
||||||
|
const AuthenticatedReportsDailyRoute =
|
||||||
|
AuthenticatedReportsDailyRouteImport.update({
|
||||||
|
id: '/reports/daily',
|
||||||
|
path: '/reports/daily',
|
||||||
|
getParentRoute: () => AuthenticatedRoute,
|
||||||
|
} as any)
|
||||||
const AuthenticatedRepairsTemplatesRoute =
|
const AuthenticatedRepairsTemplatesRoute =
|
||||||
AuthenticatedRepairsTemplatesRouteImport.update({
|
AuthenticatedRepairsTemplatesRouteImport.update({
|
||||||
id: '/repairs/templates',
|
id: '/repairs/templates',
|
||||||
@@ -344,6 +351,7 @@ export interface FileRoutesByFullPath {
|
|||||||
'/repairs/$ticketId': typeof AuthenticatedRepairsTicketIdRoute
|
'/repairs/$ticketId': typeof AuthenticatedRepairsTicketIdRoute
|
||||||
'/repairs/new': typeof AuthenticatedRepairsNewRoute
|
'/repairs/new': typeof AuthenticatedRepairsNewRoute
|
||||||
'/repairs/templates': typeof AuthenticatedRepairsTemplatesRoute
|
'/repairs/templates': typeof AuthenticatedRepairsTemplatesRoute
|
||||||
|
'/reports/daily': typeof AuthenticatedReportsDailyRoute
|
||||||
'/roles/$roleId': typeof AuthenticatedRolesRoleIdRoute
|
'/roles/$roleId': typeof AuthenticatedRolesRoleIdRoute
|
||||||
'/roles/new': typeof AuthenticatedRolesNewRoute
|
'/roles/new': typeof AuthenticatedRolesNewRoute
|
||||||
'/accounts/': typeof AuthenticatedAccountsIndexRoute
|
'/accounts/': typeof AuthenticatedAccountsIndexRoute
|
||||||
@@ -391,6 +399,7 @@ export interface FileRoutesByTo {
|
|||||||
'/repairs/$ticketId': typeof AuthenticatedRepairsTicketIdRoute
|
'/repairs/$ticketId': typeof AuthenticatedRepairsTicketIdRoute
|
||||||
'/repairs/new': typeof AuthenticatedRepairsNewRoute
|
'/repairs/new': typeof AuthenticatedRepairsNewRoute
|
||||||
'/repairs/templates': typeof AuthenticatedRepairsTemplatesRoute
|
'/repairs/templates': typeof AuthenticatedRepairsTemplatesRoute
|
||||||
|
'/reports/daily': typeof AuthenticatedReportsDailyRoute
|
||||||
'/roles/$roleId': typeof AuthenticatedRolesRoleIdRoute
|
'/roles/$roleId': typeof AuthenticatedRolesRoleIdRoute
|
||||||
'/roles/new': typeof AuthenticatedRolesNewRoute
|
'/roles/new': typeof AuthenticatedRolesNewRoute
|
||||||
'/accounts': typeof AuthenticatedAccountsIndexRoute
|
'/accounts': typeof AuthenticatedAccountsIndexRoute
|
||||||
@@ -441,6 +450,7 @@ export interface FileRoutesById {
|
|||||||
'/_authenticated/repairs/$ticketId': typeof AuthenticatedRepairsTicketIdRoute
|
'/_authenticated/repairs/$ticketId': typeof AuthenticatedRepairsTicketIdRoute
|
||||||
'/_authenticated/repairs/new': typeof AuthenticatedRepairsNewRoute
|
'/_authenticated/repairs/new': typeof AuthenticatedRepairsNewRoute
|
||||||
'/_authenticated/repairs/templates': typeof AuthenticatedRepairsTemplatesRoute
|
'/_authenticated/repairs/templates': typeof AuthenticatedRepairsTemplatesRoute
|
||||||
|
'/_authenticated/reports/daily': typeof AuthenticatedReportsDailyRoute
|
||||||
'/_authenticated/roles/$roleId': typeof AuthenticatedRolesRoleIdRoute
|
'/_authenticated/roles/$roleId': typeof AuthenticatedRolesRoleIdRoute
|
||||||
'/_authenticated/roles/new': typeof AuthenticatedRolesNewRoute
|
'/_authenticated/roles/new': typeof AuthenticatedRolesNewRoute
|
||||||
'/_authenticated/accounts/': typeof AuthenticatedAccountsIndexRoute
|
'/_authenticated/accounts/': typeof AuthenticatedAccountsIndexRoute
|
||||||
@@ -491,6 +501,7 @@ export interface FileRouteTypes {
|
|||||||
| '/repairs/$ticketId'
|
| '/repairs/$ticketId'
|
||||||
| '/repairs/new'
|
| '/repairs/new'
|
||||||
| '/repairs/templates'
|
| '/repairs/templates'
|
||||||
|
| '/reports/daily'
|
||||||
| '/roles/$roleId'
|
| '/roles/$roleId'
|
||||||
| '/roles/new'
|
| '/roles/new'
|
||||||
| '/accounts/'
|
| '/accounts/'
|
||||||
@@ -538,6 +549,7 @@ export interface FileRouteTypes {
|
|||||||
| '/repairs/$ticketId'
|
| '/repairs/$ticketId'
|
||||||
| '/repairs/new'
|
| '/repairs/new'
|
||||||
| '/repairs/templates'
|
| '/repairs/templates'
|
||||||
|
| '/reports/daily'
|
||||||
| '/roles/$roleId'
|
| '/roles/$roleId'
|
||||||
| '/roles/new'
|
| '/roles/new'
|
||||||
| '/accounts'
|
| '/accounts'
|
||||||
@@ -587,6 +599,7 @@ export interface FileRouteTypes {
|
|||||||
| '/_authenticated/repairs/$ticketId'
|
| '/_authenticated/repairs/$ticketId'
|
||||||
| '/_authenticated/repairs/new'
|
| '/_authenticated/repairs/new'
|
||||||
| '/_authenticated/repairs/templates'
|
| '/_authenticated/repairs/templates'
|
||||||
|
| '/_authenticated/reports/daily'
|
||||||
| '/_authenticated/roles/$roleId'
|
| '/_authenticated/roles/$roleId'
|
||||||
| '/_authenticated/roles/new'
|
| '/_authenticated/roles/new'
|
||||||
| '/_authenticated/accounts/'
|
| '/_authenticated/accounts/'
|
||||||
@@ -752,6 +765,13 @@ declare module '@tanstack/react-router' {
|
|||||||
preLoaderRoute: typeof AuthenticatedRolesRoleIdRouteImport
|
preLoaderRoute: typeof AuthenticatedRolesRoleIdRouteImport
|
||||||
parentRoute: typeof AuthenticatedRoute
|
parentRoute: typeof AuthenticatedRoute
|
||||||
}
|
}
|
||||||
|
'/_authenticated/reports/daily': {
|
||||||
|
id: '/_authenticated/reports/daily'
|
||||||
|
path: '/reports/daily'
|
||||||
|
fullPath: '/reports/daily'
|
||||||
|
preLoaderRoute: typeof AuthenticatedReportsDailyRouteImport
|
||||||
|
parentRoute: typeof AuthenticatedRoute
|
||||||
|
}
|
||||||
'/_authenticated/repairs/templates': {
|
'/_authenticated/repairs/templates': {
|
||||||
id: '/_authenticated/repairs/templates'
|
id: '/_authenticated/repairs/templates'
|
||||||
path: '/repairs/templates'
|
path: '/repairs/templates'
|
||||||
@@ -1004,6 +1024,7 @@ interface AuthenticatedRouteChildren {
|
|||||||
AuthenticatedRepairsTicketIdRoute: typeof AuthenticatedRepairsTicketIdRoute
|
AuthenticatedRepairsTicketIdRoute: typeof AuthenticatedRepairsTicketIdRoute
|
||||||
AuthenticatedRepairsNewRoute: typeof AuthenticatedRepairsNewRoute
|
AuthenticatedRepairsNewRoute: typeof AuthenticatedRepairsNewRoute
|
||||||
AuthenticatedRepairsTemplatesRoute: typeof AuthenticatedRepairsTemplatesRoute
|
AuthenticatedRepairsTemplatesRoute: typeof AuthenticatedRepairsTemplatesRoute
|
||||||
|
AuthenticatedReportsDailyRoute: typeof AuthenticatedReportsDailyRoute
|
||||||
AuthenticatedRolesRoleIdRoute: typeof AuthenticatedRolesRoleIdRoute
|
AuthenticatedRolesRoleIdRoute: typeof AuthenticatedRolesRoleIdRoute
|
||||||
AuthenticatedRolesNewRoute: typeof AuthenticatedRolesNewRoute
|
AuthenticatedRolesNewRoute: typeof AuthenticatedRolesNewRoute
|
||||||
AuthenticatedAccountsIndexRoute: typeof AuthenticatedAccountsIndexRoute
|
AuthenticatedAccountsIndexRoute: typeof AuthenticatedAccountsIndexRoute
|
||||||
@@ -1047,6 +1068,7 @@ const AuthenticatedRouteChildren: AuthenticatedRouteChildren = {
|
|||||||
AuthenticatedRepairsTicketIdRoute: AuthenticatedRepairsTicketIdRoute,
|
AuthenticatedRepairsTicketIdRoute: AuthenticatedRepairsTicketIdRoute,
|
||||||
AuthenticatedRepairsNewRoute: AuthenticatedRepairsNewRoute,
|
AuthenticatedRepairsNewRoute: AuthenticatedRepairsNewRoute,
|
||||||
AuthenticatedRepairsTemplatesRoute: AuthenticatedRepairsTemplatesRoute,
|
AuthenticatedRepairsTemplatesRoute: AuthenticatedRepairsTemplatesRoute,
|
||||||
|
AuthenticatedReportsDailyRoute: AuthenticatedReportsDailyRoute,
|
||||||
AuthenticatedRolesRoleIdRoute: AuthenticatedRolesRoleIdRoute,
|
AuthenticatedRolesRoleIdRoute: AuthenticatedRolesRoleIdRoute,
|
||||||
AuthenticatedRolesNewRoute: AuthenticatedRolesNewRoute,
|
AuthenticatedRolesNewRoute: AuthenticatedRolesNewRoute,
|
||||||
AuthenticatedAccountsIndexRoute: AuthenticatedAccountsIndexRoute,
|
AuthenticatedAccountsIndexRoute: AuthenticatedAccountsIndexRoute,
|
||||||
|
|||||||
@@ -1,8 +1,13 @@
|
|||||||
import { useState } from 'react'
|
import { useState, useEffect } from 'react'
|
||||||
import { createFileRoute, useRouter, redirect } from '@tanstack/react-router'
|
import { createFileRoute, useRouter, redirect } from '@tanstack/react-router'
|
||||||
import { useAuthStore } from '@/stores/auth.store'
|
import { useAuthStore } from '@/stores/auth.store'
|
||||||
import { login } from '@/api/auth'
|
import { login } from '@/api/auth'
|
||||||
|
|
||||||
|
interface Branding {
|
||||||
|
name: string | null
|
||||||
|
hasLogo: boolean
|
||||||
|
}
|
||||||
|
|
||||||
export const Route = createFileRoute('/login')({
|
export const Route = createFileRoute('/login')({
|
||||||
beforeLoad: () => {
|
beforeLoad: () => {
|
||||||
const { token } = useAuthStore.getState()
|
const { token } = useAuthStore.getState()
|
||||||
@@ -20,6 +25,14 @@ function LoginPage() {
|
|||||||
const [password, setPassword] = useState('')
|
const [password, setPassword] = useState('')
|
||||||
const [error, setError] = useState('')
|
const [error, setError] = useState('')
|
||||||
const [loading, setLoading] = useState(false)
|
const [loading, setLoading] = useState(false)
|
||||||
|
const [branding, setBranding] = useState<Branding | null>(null)
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
fetch('/v1/store/branding')
|
||||||
|
.then((r) => r.ok ? r.json() : null)
|
||||||
|
.then((data) => { if (data) setBranding(data) })
|
||||||
|
.catch(() => {})
|
||||||
|
}, [])
|
||||||
|
|
||||||
async function handleSubmit(e: React.FormEvent) {
|
async function handleSubmit(e: React.FormEvent) {
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
@@ -48,8 +61,16 @@ function LoginPage() {
|
|||||||
style={{ backgroundColor: '#131c2e', borderColor: '#1e2d45' }}
|
style={{ backgroundColor: '#131c2e', borderColor: '#1e2d45' }}
|
||||||
>
|
>
|
||||||
<div className="text-center mb-8">
|
<div className="text-center mb-8">
|
||||||
<h1 className="text-3xl font-bold" style={{ color: '#d8dfe9' }}>LunarFront</h1>
|
{branding?.hasLogo ? (
|
||||||
<p className="text-sm mt-1" style={{ color: '#6b7a8d' }}>Small Business Management</p>
|
<img src="/v1/store/logo" alt={branding.name ?? 'Store'} className="max-h-14 max-w-[220px] object-contain mx-auto" />
|
||||||
|
) : (
|
||||||
|
<h1 className="text-3xl font-bold" style={{ color: '#d8dfe9' }}>{branding?.name ?? 'LunarFront'}</h1>
|
||||||
|
)}
|
||||||
|
{branding?.name ? (
|
||||||
|
<p className="text-[10px] mt-2" style={{ color: '#4a5568' }}>Powered by <span style={{ color: '#6b7a8d' }}>LunarFront</span></p>
|
||||||
|
) : (
|
||||||
|
<p className="text-sm mt-1" style={{ color: '#6b7a8d' }}>Small Business Management</p>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
<form onSubmit={handleSubmit} className="space-y-4">
|
<form onSubmit={handleSubmit} className="space-y-4">
|
||||||
<div className="space-y-2">
|
<div className="space-y-2">
|
||||||
|
|||||||
@@ -1,9 +1,43 @@
|
|||||||
import type { FastifyPluginAsync } from 'fastify'
|
import type { FastifyPluginAsync } from 'fastify'
|
||||||
import { eq } from 'drizzle-orm'
|
import { eq } from 'drizzle-orm'
|
||||||
import { companies, locations } from '../../db/schema/stores.js'
|
import { companies, locations } from '../../db/schema/stores.js'
|
||||||
|
import { files } from '../../db/schema/files.js'
|
||||||
import { ValidationError } from '../../lib/errors.js'
|
import { ValidationError } from '../../lib/errors.js'
|
||||||
|
|
||||||
export const storeRoutes: FastifyPluginAsync = async (app) => {
|
export const storeRoutes: FastifyPluginAsync = async (app) => {
|
||||||
|
// --- Public branding (no auth — used on login page) ---
|
||||||
|
|
||||||
|
app.get('/store/branding', async (_request, reply) => {
|
||||||
|
const [store] = await app.db.select({
|
||||||
|
name: companies.name,
|
||||||
|
logoFileId: companies.logoFileId,
|
||||||
|
}).from(companies).limit(1)
|
||||||
|
if (!store) return reply.send({ name: null, hasLogo: false })
|
||||||
|
return reply.send({ name: store.name, hasLogo: !!store.logoFileId })
|
||||||
|
})
|
||||||
|
|
||||||
|
app.get('/store/logo', async (_request, reply) => {
|
||||||
|
const [store] = await app.db.select({ logoFileId: companies.logoFileId }).from(companies).limit(1)
|
||||||
|
if (!store?.logoFileId) return reply.status(404).send({ error: { message: 'No logo configured', statusCode: 404 } })
|
||||||
|
|
||||||
|
const [file] = await app.db.select().from(files).where(eq(files.id, store.logoFileId)).limit(1)
|
||||||
|
if (!file) return reply.status(404).send({ error: { message: 'Logo file not found', statusCode: 404 } })
|
||||||
|
|
||||||
|
try {
|
||||||
|
const data = await app.storage.get(file.path)
|
||||||
|
const ext = file.path.split('.').pop()?.toLowerCase()
|
||||||
|
const contentTypeMap: Record<string, string> = {
|
||||||
|
jpg: 'image/jpeg', jpeg: 'image/jpeg', png: 'image/png', webp: 'image/webp', svg: 'image/svg+xml',
|
||||||
|
}
|
||||||
|
return reply
|
||||||
|
.header('Content-Type', contentTypeMap[ext ?? ''] ?? 'application/octet-stream')
|
||||||
|
.header('Cache-Control', 'public, max-age=3600')
|
||||||
|
.send(data)
|
||||||
|
} catch {
|
||||||
|
return reply.status(404).send({ error: { message: 'Logo file not readable', statusCode: 404 } })
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
// --- Company / Store Settings ---
|
// --- Company / Store Settings ---
|
||||||
|
|
||||||
app.get('/store', { preHandler: [app.authenticate, app.requirePermission('settings.view')] }, async (request, reply) => {
|
app.get('/store', { preHandler: [app.authenticate, app.requirePermission('settings.view')] }, async (request, reply) => {
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { eq, and, sql, gte, lt } from 'drizzle-orm'
|
import { eq, and, gte, lt } from 'drizzle-orm'
|
||||||
import type { PostgresJsDatabase } from 'drizzle-orm/postgres-js'
|
import type { PostgresJsDatabase } from 'drizzle-orm/postgres-js'
|
||||||
import { transactions, drawerSessions, drawerAdjustments, registers } from '../db/schema/pos.js'
|
import { transactions, drawerSessions, drawerAdjustments, registers } from '../db/schema/pos.js'
|
||||||
import { locations } from '../db/schema/stores.js'
|
import { locations } from '../db/schema/stores.js'
|
||||||
|
|||||||
Reference in New Issue
Block a user