chore: prettier format pass on branch files
Auto-format all files modified during the documents-hub-split feature branch that were not yet aligned with the project's Prettier config (single quotes, semicolons, trailing commas). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -428,10 +428,7 @@ type SystemRootName = (typeof SYSTEM_ROOT_NAMES)[number];
|
||||
* can't race two inserts of the same root. Re-SELECTs on conflict so
|
||||
* the return shape is always populated.
|
||||
*/
|
||||
export async function ensureSystemRoots(
|
||||
portId: string,
|
||||
userId: string,
|
||||
): Promise<DocumentFolder[]> {
|
||||
export async function ensureSystemRoots(portId: string, userId: string): Promise<DocumentFolder[]> {
|
||||
// Try to insert all three; collect existing ids on conflict.
|
||||
const values = SYSTEM_ROOT_NAMES.map((name) => ({
|
||||
portId,
|
||||
@@ -443,13 +440,16 @@ export async function ensureSystemRoots(
|
||||
createdBy: userId,
|
||||
}));
|
||||
|
||||
await db.insert(documentFolders).values(values).onConflictDoNothing({
|
||||
target: [
|
||||
documentFolders.portId,
|
||||
sql`COALESCE(${documentFolders.parentId}, '__root__')`,
|
||||
sql`LOWER(${documentFolders.name})`,
|
||||
],
|
||||
});
|
||||
await db
|
||||
.insert(documentFolders)
|
||||
.values(values)
|
||||
.onConflictDoNothing({
|
||||
target: [
|
||||
documentFolders.portId,
|
||||
sql`COALESCE(${documentFolders.parentId}, '__root__')`,
|
||||
sql`LOWER(${documentFolders.name})`,
|
||||
],
|
||||
});
|
||||
|
||||
// Re-SELECT — the rows that already existed are not in `.returning()`
|
||||
// when ON CONFLICT DO NOTHING is used. SELECT is the authoritative
|
||||
@@ -457,9 +457,7 @@ export async function ensureSystemRoots(
|
||||
const rows = await db
|
||||
.select()
|
||||
.from(documentFolders)
|
||||
.where(
|
||||
and(eq(documentFolders.portId, portId), eq(documentFolders.entityType, 'root')),
|
||||
);
|
||||
.where(and(eq(documentFolders.portId, portId), eq(documentFolders.entityType, 'root')));
|
||||
|
||||
// Preserve SYSTEM_ROOT_NAMES order for callers (stable test assertions
|
||||
// and a stable UI render order).
|
||||
@@ -879,8 +877,7 @@ async function assertNotSystemManaged(
|
||||
});
|
||||
if (!folder) throw new NotFoundError('Folder');
|
||||
if (folder.systemManaged) {
|
||||
const verb =
|
||||
action === 'rename' ? 'renamed' : action === 'move' ? 'moved' : 'deleted';
|
||||
const verb = action === 'rename' ? 'renamed' : action === 'move' ? 'moved' : 'deleted';
|
||||
throw new ConflictError(`System folders can't be ${verb}`);
|
||||
}
|
||||
return folder;
|
||||
@@ -1009,10 +1006,7 @@ describe('document-folders service · syncEntityFolderName', () => {
|
||||
});
|
||||
|
||||
it('renames the entity subfolder when the entity is renamed', async () => {
|
||||
await db
|
||||
.update(clients)
|
||||
.set({ firstName: 'Jonathan' })
|
||||
.where(eq(clients.id, clientId));
|
||||
await db.update(clients).set({ firstName: 'Jonathan' }).where(eq(clients.id, clientId));
|
||||
await syncEntityFolderName(portId, 'client', clientId, TEST_USER_ID);
|
||||
const folder = await db.query.documentFolders.findFirst({
|
||||
where: and(eq(documentFolders.entityType, 'client'), eq(documentFolders.entityId, clientId)),
|
||||
@@ -1052,10 +1046,7 @@ describe('document-folders service · syncEntityFolderName', () => {
|
||||
await ensureEntityFolder(portId, 'client', collider!.id, TEST_USER_ID);
|
||||
|
||||
// Rename John → Jane (collision with the other Smith, Jane).
|
||||
await db
|
||||
.update(clients)
|
||||
.set({ firstName: 'Jane' })
|
||||
.where(eq(clients.id, clientId));
|
||||
await db.update(clients).set({ firstName: 'Jane' }).where(eq(clients.id, clientId));
|
||||
await syncEntityFolderName(portId, 'client', clientId, TEST_USER_ID);
|
||||
|
||||
const folder = await db.query.documentFolders.findFirst({
|
||||
@@ -1115,9 +1106,7 @@ export async function syncEntityFolderName(
|
||||
|
||||
for (let attempt = 0; attempt < 50; attempt += 1) {
|
||||
const candidate =
|
||||
attempt === 0
|
||||
? `${baseName}${targetSuffix}`
|
||||
: `${baseName} (${attempt + 1})${targetSuffix}`;
|
||||
attempt === 0 ? `${baseName}${targetSuffix}` : `${baseName} (${attempt + 1})${targetSuffix}`;
|
||||
if (candidate === folder.name) return; // No-op rename.
|
||||
try {
|
||||
const [updated] = await db
|
||||
@@ -1692,9 +1681,12 @@ interface ResolvedOwner {
|
||||
* linked interest's primary entity. Returns null when no owner is
|
||||
* resolvable (signed PDF will land at root).
|
||||
*/
|
||||
async function resolveDocumentOwner(
|
||||
doc: { clientId: string | null; companyId: string | null; yachtId: string | null; interestId: string | null },
|
||||
): Promise<ResolvedOwner | null> {
|
||||
async function resolveDocumentOwner(doc: {
|
||||
clientId: string | null;
|
||||
companyId: string | null;
|
||||
yachtId: string | null;
|
||||
interestId: string | null;
|
||||
}): Promise<ResolvedOwner | null> {
|
||||
if (doc.clientId) return { entityType: 'client', entityId: doc.clientId };
|
||||
if (doc.companyId) return { entityType: 'company', entityId: doc.companyId };
|
||||
if (doc.yachtId) return { entityType: 'yacht', entityId: doc.yachtId };
|
||||
@@ -1853,24 +1845,40 @@ describe('files service · listFilesAggregatedByEntity', () => {
|
||||
await db.delete(documentFolders).where(eq(documentFolders.portId, portId));
|
||||
await ensureSystemRoots(portId, TEST_USER_ID);
|
||||
|
||||
const [c] = await db.insert(clients).values({
|
||||
portId, firstName: 'John', lastName: 'Smith',
|
||||
email: `john-${crypto.randomUUID()}@example.com`,
|
||||
}).returning();
|
||||
const [c] = await db
|
||||
.insert(clients)
|
||||
.values({
|
||||
portId,
|
||||
firstName: 'John',
|
||||
lastName: 'Smith',
|
||||
email: `john-${crypto.randomUUID()}@example.com`,
|
||||
})
|
||||
.returning();
|
||||
clientId = c!.id;
|
||||
|
||||
const [co] = await db.insert(companies).values({
|
||||
portId, name: 'Smith Marine LLC',
|
||||
}).returning();
|
||||
const [co] = await db
|
||||
.insert(companies)
|
||||
.values({
|
||||
portId,
|
||||
name: 'Smith Marine LLC',
|
||||
})
|
||||
.returning();
|
||||
companyId = co!.id;
|
||||
|
||||
const [y] = await db.insert(yachts).values({
|
||||
portId, name: 'MV Serenity', currentOwnerType: 'client', currentOwnerId: clientId,
|
||||
}).returning();
|
||||
const [y] = await db
|
||||
.insert(yachts)
|
||||
.values({
|
||||
portId,
|
||||
name: 'MV Serenity',
|
||||
currentOwnerType: 'client',
|
||||
currentOwnerId: clientId,
|
||||
})
|
||||
.returning();
|
||||
yachtId = y!.id;
|
||||
|
||||
await db.insert(companyMemberships).values({
|
||||
companyId, clientId,
|
||||
companyId,
|
||||
clientId,
|
||||
});
|
||||
|
||||
clientFolderId = (await ensureEntityFolder(portId, 'client', clientId, TEST_USER_ID)).id;
|
||||
@@ -1885,19 +1893,22 @@ describe('files service · listFilesAggregatedByEntity', () => {
|
||||
folderId: string;
|
||||
filename: string;
|
||||
}) {
|
||||
const [row] = await db.insert(files).values({
|
||||
portId,
|
||||
clientId: opts.clientId ?? null,
|
||||
companyId: opts.companyId ?? null,
|
||||
yachtId: opts.yachtId ?? null,
|
||||
folderId: opts.folderId,
|
||||
filename: opts.filename,
|
||||
originalName: opts.filename,
|
||||
mimeType: 'application/pdf',
|
||||
storagePath: `test/${crypto.randomUUID()}`,
|
||||
storageBucket: 'test',
|
||||
uploadedBy: TEST_USER_ID,
|
||||
}).returning();
|
||||
const [row] = await db
|
||||
.insert(files)
|
||||
.values({
|
||||
portId,
|
||||
clientId: opts.clientId ?? null,
|
||||
companyId: opts.companyId ?? null,
|
||||
yachtId: opts.yachtId ?? null,
|
||||
folderId: opts.folderId,
|
||||
filename: opts.filename,
|
||||
originalName: opts.filename,
|
||||
mimeType: 'application/pdf',
|
||||
storagePath: `test/${crypto.randomUUID()}`,
|
||||
storageBucket: 'test',
|
||||
uploadedBy: TEST_USER_ID,
|
||||
})
|
||||
.returning();
|
||||
return row!;
|
||||
}
|
||||
|
||||
@@ -1934,14 +1945,24 @@ describe('files service · listFilesAggregatedByEntity', () => {
|
||||
|
||||
it('snapshots are file-FK-based — yacht transfer does not move historical files', async () => {
|
||||
const file = await insertFile({
|
||||
yachtId, clientId, folderId: yachtFolderId, filename: 'Historic.pdf',
|
||||
yachtId,
|
||||
clientId,
|
||||
folderId: yachtFolderId,
|
||||
filename: 'Historic.pdf',
|
||||
});
|
||||
// Transfer the yacht to a different owner.
|
||||
const [mary] = await db.insert(clients).values({
|
||||
portId, firstName: 'Mary', lastName: 'Brown',
|
||||
email: `mary-${crypto.randomUUID()}@example.com`,
|
||||
}).returning();
|
||||
await db.update(yachts).set({ currentOwnerType: 'client', currentOwnerId: mary!.id })
|
||||
const [mary] = await db
|
||||
.insert(clients)
|
||||
.values({
|
||||
portId,
|
||||
firstName: 'Mary',
|
||||
lastName: 'Brown',
|
||||
email: `mary-${crypto.randomUUID()}@example.com`,
|
||||
})
|
||||
.returning();
|
||||
await db
|
||||
.update(yachts)
|
||||
.set({ currentOwnerType: 'client', currentOwnerId: mary!.id })
|
||||
.where(eq(yachts.id, yachtId));
|
||||
|
||||
// John's view still shows the file (via DIRECTLY ATTACHED or FROM YACHT).
|
||||
@@ -1957,10 +1978,15 @@ describe('files service · listFilesAggregatedByEntity', () => {
|
||||
|
||||
it('rejects cross-port leakage with defense-in-depth port filter', async () => {
|
||||
const otherPort = await setupTestPort();
|
||||
const [otherClient] = await db.insert(clients).values({
|
||||
portId: otherPort, firstName: 'Other', lastName: 'Port',
|
||||
email: `other-${crypto.randomUUID()}@example.com`,
|
||||
}).returning();
|
||||
const [otherClient] = await db
|
||||
.insert(clients)
|
||||
.values({
|
||||
portId: otherPort,
|
||||
firstName: 'Other',
|
||||
lastName: 'Port',
|
||||
email: `other-${crypto.randomUUID()}@example.com`,
|
||||
})
|
||||
.returning();
|
||||
// Try to query the other port's client from our port — should return empty.
|
||||
const result = await listFilesAggregatedByEntity(portId, 'client', otherClient!.id);
|
||||
expect(result.groups.flatMap((g) => g.files)).toHaveLength(0);
|
||||
@@ -2041,9 +2067,11 @@ export async function listFilesAggregatedByEntity(
|
||||
|
||||
// DIRECTLY ATTACHED — files whose own FK matches the requested entity.
|
||||
const directColumn =
|
||||
entityType === 'client' ? files.clientId
|
||||
: entityType === 'company' ? files.companyId
|
||||
: files.yachtId;
|
||||
entityType === 'client'
|
||||
? files.clientId
|
||||
: entityType === 'company'
|
||||
? files.companyId
|
||||
: files.yachtId;
|
||||
const direct = await fetchGroupRows(portId, eq(directColumn, entityId), GROUP_LIMIT);
|
||||
if (direct.rows.length > 0) {
|
||||
groups.push({
|
||||
@@ -2169,7 +2197,10 @@ async function collectRelatedEntities(
|
||||
and(
|
||||
eq(yachts.portId, portId),
|
||||
eq(yachts.currentOwnerType, 'company'),
|
||||
inArray(yachts.currentOwnerId, memberCompanies.map((c) => c.id)),
|
||||
inArray(
|
||||
yachts.currentOwnerId,
|
||||
memberCompanies.map((c) => c.id),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
@@ -2228,10 +2259,7 @@ async function collectRelatedEntities(
|
||||
? [
|
||||
{
|
||||
id: owner.id,
|
||||
name: `${owner.lastName ?? ''}, ${owner.firstName ?? ''}`.replace(
|
||||
/^,\s*|,\s*$/,
|
||||
'',
|
||||
),
|
||||
name: `${owner.lastName ?? ''}, ${owner.firstName ?? ''}`.replace(/^,\s*|,\s*$/, ''),
|
||||
},
|
||||
]
|
||||
: [],
|
||||
@@ -2310,10 +2338,7 @@ Append to `src/lib/services/documents.service.ts` — reuses the same `collectRe
|
||||
Then append to `src/lib/services/documents.service.ts`:
|
||||
|
||||
```typescript
|
||||
import {
|
||||
collectRelatedEntities,
|
||||
type AggregatedFileGroup,
|
||||
} from '@/lib/services/files';
|
||||
import { collectRelatedEntities, type AggregatedFileGroup } from '@/lib/services/files';
|
||||
|
||||
export interface AggregatedWorkflowGroup {
|
||||
label: string;
|
||||
@@ -2339,9 +2364,11 @@ export async function listInflightWorkflowsAggregatedByEntity(
|
||||
const groups: AggregatedWorkflowGroup[] = [];
|
||||
|
||||
const directColumn =
|
||||
entityType === 'client' ? documents.clientId
|
||||
: entityType === 'company' ? documents.companyId
|
||||
: documents.yachtId;
|
||||
entityType === 'client'
|
||||
? documents.clientId
|
||||
: entityType === 'company'
|
||||
? documents.companyId
|
||||
: documents.yachtId;
|
||||
|
||||
const direct = await fetchWorkflowGroupRows(portId, eq(directColumn, entityId));
|
||||
if (direct.rows.length > 0) {
|
||||
@@ -2432,22 +2459,35 @@ describe('documents service · listInflightWorkflowsAggregatedByEntity', () => {
|
||||
portId = await setupTestPort();
|
||||
await db.delete(documentFolders).where(eq(documentFolders.portId, portId));
|
||||
await ensureSystemRoots(portId, TEST_USER_ID);
|
||||
const [c] = await db.insert(clients).values({
|
||||
portId, firstName: 'John', lastName: 'Smith',
|
||||
email: `john-${crypto.randomUUID()}@example.com`,
|
||||
}).returning();
|
||||
const [c] = await db
|
||||
.insert(clients)
|
||||
.values({
|
||||
portId,
|
||||
firstName: 'John',
|
||||
lastName: 'Smith',
|
||||
email: `john-${crypto.randomUUID()}@example.com`,
|
||||
})
|
||||
.returning();
|
||||
clientId = c!.id;
|
||||
});
|
||||
|
||||
it('returns in-flight workflows in DIRECTLY ATTACHED group', async () => {
|
||||
const { documents: documentsTable } = await import('@/lib/db/schema/documents');
|
||||
await db.insert(documentsTable).values({
|
||||
portId, clientId, title: 'EOI', documentType: 'eoi',
|
||||
status: 'sent', createdBy: TEST_USER_ID,
|
||||
portId,
|
||||
clientId,
|
||||
title: 'EOI',
|
||||
documentType: 'eoi',
|
||||
status: 'sent',
|
||||
createdBy: TEST_USER_ID,
|
||||
});
|
||||
await db.insert(documentsTable).values({
|
||||
portId, clientId, title: 'Old signed EOI', documentType: 'eoi',
|
||||
status: 'completed', createdBy: TEST_USER_ID,
|
||||
portId,
|
||||
clientId,
|
||||
title: 'Old signed EOI',
|
||||
documentType: 'eoi',
|
||||
status: 'completed',
|
||||
createdBy: TEST_USER_ID,
|
||||
});
|
||||
const result = await listInflightWorkflowsAggregatedByEntity(portId, 'client', clientId);
|
||||
const direct = result.groups.find((g) => g.label === 'DIRECTLY ATTACHED');
|
||||
@@ -2476,18 +2516,17 @@ Append to `src/lib/services/files.ts`:
|
||||
* Returns the mutated insert payload so callers can keep their
|
||||
* single-insert flow.
|
||||
*/
|
||||
export async function applyEntityFkFromFolder<T extends {
|
||||
clientId?: string | null;
|
||||
companyId?: string | null;
|
||||
yachtId?: string | null;
|
||||
folderId?: string | null;
|
||||
}>(portId: string, payload: T): Promise<T> {
|
||||
export async function applyEntityFkFromFolder<
|
||||
T extends {
|
||||
clientId?: string | null;
|
||||
companyId?: string | null;
|
||||
yachtId?: string | null;
|
||||
folderId?: string | null;
|
||||
},
|
||||
>(portId: string, payload: T): Promise<T> {
|
||||
if (!payload.folderId) return payload;
|
||||
const folder = await db.query.documentFolders.findFirst({
|
||||
where: and(
|
||||
eq(documentFolders.id, payload.folderId),
|
||||
eq(documentFolders.portId, portId),
|
||||
),
|
||||
where: and(eq(documentFolders.id, payload.folderId), eq(documentFolders.portId, portId)),
|
||||
columns: { systemManaged: true, entityType: true, entityId: true },
|
||||
});
|
||||
if (!folder || !folder.systemManaged || !folder.entityType || !folder.entityId) {
|
||||
@@ -2521,10 +2560,15 @@ describe('files service · applyEntityFkFromFolder', () => {
|
||||
beforeEach(async () => {
|
||||
portId = await setupTestPort();
|
||||
await ensureSystemRoots(portId, TEST_USER_ID);
|
||||
const [c] = await db.insert(clients).values({
|
||||
portId, firstName: 'A', lastName: 'B',
|
||||
email: `a-${crypto.randomUUID()}@example.com`,
|
||||
}).returning();
|
||||
const [c] = await db
|
||||
.insert(clients)
|
||||
.values({
|
||||
portId,
|
||||
firstName: 'A',
|
||||
lastName: 'B',
|
||||
email: `a-${crypto.randomUUID()}@example.com`,
|
||||
})
|
||||
.returning();
|
||||
clientId = c!.id;
|
||||
folderId = (await ensureEntityFolder(portId, 'client', clientId, TEST_USER_ID)).id;
|
||||
});
|
||||
@@ -2540,9 +2584,15 @@ describe('files service · applyEntityFkFromFolder', () => {
|
||||
});
|
||||
|
||||
it('is a no-op for non-system folders', async () => {
|
||||
const [user] = await db.insert(documentFolders).values({
|
||||
portId, parentId: null, name: 'My templates', createdBy: TEST_USER_ID,
|
||||
}).returning();
|
||||
const [user] = await db
|
||||
.insert(documentFolders)
|
||||
.values({
|
||||
portId,
|
||||
parentId: null,
|
||||
name: 'My templates',
|
||||
createdBy: TEST_USER_ID,
|
||||
})
|
||||
.returning();
|
||||
const out = await applyEntityFkFromFolder(portId, { folderId: user!.id, clientId: null });
|
||||
expect(out.clientId).toBeUndefined();
|
||||
});
|
||||
@@ -2767,20 +2817,41 @@ import { describe, it, expect, beforeEach } from 'vitest';
|
||||
it('hides completed workflows when folderId is set', async () => {
|
||||
const portId = await setupTestPort();
|
||||
await ensureSystemRoots(portId, TEST_USER_ID);
|
||||
const [folder] = await db.insert(documentFolders).values({
|
||||
portId, parentId: null, name: 'Deals 2026', createdBy: TEST_USER_ID,
|
||||
}).returning();
|
||||
const [folder] = await db
|
||||
.insert(documentFolders)
|
||||
.values({
|
||||
portId,
|
||||
parentId: null,
|
||||
name: 'Deals 2026',
|
||||
createdBy: TEST_USER_ID,
|
||||
})
|
||||
.returning();
|
||||
await db.insert(documents).values([
|
||||
{
|
||||
portId, folderId: folder!.id, title: 'In flight',
|
||||
documentType: 'eoi', status: 'sent', createdBy: TEST_USER_ID,
|
||||
portId,
|
||||
folderId: folder!.id,
|
||||
title: 'In flight',
|
||||
documentType: 'eoi',
|
||||
status: 'sent',
|
||||
createdBy: TEST_USER_ID,
|
||||
},
|
||||
{
|
||||
portId, folderId: folder!.id, title: 'Done',
|
||||
documentType: 'eoi', status: 'completed', createdBy: TEST_USER_ID,
|
||||
portId,
|
||||
folderId: folder!.id,
|
||||
title: 'Done',
|
||||
documentType: 'eoi',
|
||||
status: 'completed',
|
||||
createdBy: TEST_USER_ID,
|
||||
},
|
||||
]);
|
||||
const result = await listDocuments(portId, { folderId: folder!.id, page: 1, limit: 50, sort: 'createdAt', order: 'desc', tab: 'all' });
|
||||
const result = await listDocuments(portId, {
|
||||
folderId: folder!.id,
|
||||
page: 1,
|
||||
limit: 50,
|
||||
sort: 'createdAt',
|
||||
order: 'desc',
|
||||
tab: 'all',
|
||||
});
|
||||
expect(result.data.map((d) => d.title)).toEqual(['In flight']);
|
||||
});
|
||||
```
|
||||
@@ -2859,51 +2930,79 @@ describe('backfill-document-folders · idempotency + isolation', () => {
|
||||
beforeEach(async () => {
|
||||
portId = await setupTestPort();
|
||||
await db.delete(documentFolders).where(eq(documentFolders.portId, portId));
|
||||
const [c] = await db.insert(clients).values({
|
||||
portId, firstName: 'John', lastName: 'Smith',
|
||||
email: `john-${crypto.randomUUID()}@example.com`,
|
||||
}).returning();
|
||||
const [c] = await db
|
||||
.insert(clients)
|
||||
.values({
|
||||
portId,
|
||||
firstName: 'John',
|
||||
lastName: 'Smith',
|
||||
email: `john-${crypto.randomUUID()}@example.com`,
|
||||
})
|
||||
.returning();
|
||||
clientId = c!.id;
|
||||
});
|
||||
|
||||
it('creates system roots and entity subfolders for entities with attached files', async () => {
|
||||
await db.insert(files).values({
|
||||
portId, clientId, filename: 'a.pdf', originalName: 'a.pdf',
|
||||
storagePath: `test/${crypto.randomUUID()}`, storageBucket: 'test',
|
||||
portId,
|
||||
clientId,
|
||||
filename: 'a.pdf',
|
||||
originalName: 'a.pdf',
|
||||
storagePath: `test/${crypto.randomUUID()}`,
|
||||
storageBucket: 'test',
|
||||
uploadedBy: TEST_USER_ID,
|
||||
});
|
||||
await runBackfill({ portId });
|
||||
const roots = await db.select().from(documentFolders).where(
|
||||
and(eq(documentFolders.portId, portId), eq(documentFolders.entityType, 'root')),
|
||||
);
|
||||
const roots = await db
|
||||
.select()
|
||||
.from(documentFolders)
|
||||
.where(and(eq(documentFolders.portId, portId), eq(documentFolders.entityType, 'root')));
|
||||
expect(roots.map((r) => r.name).sort()).toEqual(['Clients', 'Companies', 'Yachts']);
|
||||
const sub = await db.select().from(documentFolders).where(
|
||||
and(eq(documentFolders.entityType, 'client'), eq(documentFolders.entityId, clientId)),
|
||||
);
|
||||
const sub = await db
|
||||
.select()
|
||||
.from(documentFolders)
|
||||
.where(and(eq(documentFolders.entityType, 'client'), eq(documentFolders.entityId, clientId)));
|
||||
expect(sub).toHaveLength(1);
|
||||
});
|
||||
|
||||
it('sets files.folder_id from entity FKs', async () => {
|
||||
const [file] = await db.insert(files).values({
|
||||
portId, clientId, filename: 'a.pdf', originalName: 'a.pdf',
|
||||
storagePath: `test/${crypto.randomUUID()}`, storageBucket: 'test',
|
||||
uploadedBy: TEST_USER_ID,
|
||||
}).returning();
|
||||
const [file] = await db
|
||||
.insert(files)
|
||||
.values({
|
||||
portId,
|
||||
clientId,
|
||||
filename: 'a.pdf',
|
||||
originalName: 'a.pdf',
|
||||
storagePath: `test/${crypto.randomUUID()}`,
|
||||
storageBucket: 'test',
|
||||
uploadedBy: TEST_USER_ID,
|
||||
})
|
||||
.returning();
|
||||
await runBackfill({ portId });
|
||||
const updated = await db.query.files.findFirst({ where: eq(files.id, file!.id) });
|
||||
expect(updated?.folderId).not.toBeNull();
|
||||
});
|
||||
|
||||
it('copies entity FKs from completed workflows onto signed files', async () => {
|
||||
const [signedFile] = await db.insert(files).values({
|
||||
portId, // NOTE: no clientId — legacy completion left it blank
|
||||
filename: 'signed.pdf', originalName: 'signed.pdf',
|
||||
storagePath: `test/${crypto.randomUUID()}`, storageBucket: 'test',
|
||||
uploadedBy: 'system',
|
||||
}).returning();
|
||||
const [signedFile] = await db
|
||||
.insert(files)
|
||||
.values({
|
||||
portId, // NOTE: no clientId — legacy completion left it blank
|
||||
filename: 'signed.pdf',
|
||||
originalName: 'signed.pdf',
|
||||
storagePath: `test/${crypto.randomUUID()}`,
|
||||
storageBucket: 'test',
|
||||
uploadedBy: 'system',
|
||||
})
|
||||
.returning();
|
||||
await db.insert(documents).values({
|
||||
portId, clientId, signedFileId: signedFile!.id, title: 'EOI',
|
||||
documentType: 'eoi', status: 'completed', createdBy: TEST_USER_ID,
|
||||
portId,
|
||||
clientId,
|
||||
signedFileId: signedFile!.id,
|
||||
title: 'EOI',
|
||||
documentType: 'eoi',
|
||||
status: 'completed',
|
||||
createdBy: TEST_USER_ID,
|
||||
});
|
||||
await runBackfill({ portId });
|
||||
const updated = await db.query.files.findFirst({ where: eq(files.id, signedFile!.id) });
|
||||
@@ -2913,30 +3012,52 @@ describe('backfill-document-folders · idempotency + isolation', () => {
|
||||
|
||||
it('is idempotent — second run produces the same result', async () => {
|
||||
await db.insert(files).values({
|
||||
portId, clientId, filename: 'a.pdf', originalName: 'a.pdf',
|
||||
storagePath: `test/${crypto.randomUUID()}`, storageBucket: 'test',
|
||||
portId,
|
||||
clientId,
|
||||
filename: 'a.pdf',
|
||||
originalName: 'a.pdf',
|
||||
storagePath: `test/${crypto.randomUUID()}`,
|
||||
storageBucket: 'test',
|
||||
uploadedBy: TEST_USER_ID,
|
||||
});
|
||||
await runBackfill({ portId });
|
||||
const after1 = await db.select().from(documentFolders).where(eq(documentFolders.portId, portId));
|
||||
const after1 = await db
|
||||
.select()
|
||||
.from(documentFolders)
|
||||
.where(eq(documentFolders.portId, portId));
|
||||
await runBackfill({ portId });
|
||||
const after2 = await db.select().from(documentFolders).where(eq(documentFolders.portId, portId));
|
||||
const after2 = await db
|
||||
.select()
|
||||
.from(documentFolders)
|
||||
.where(eq(documentFolders.portId, portId));
|
||||
expect(after2).toHaveLength(after1.length);
|
||||
});
|
||||
|
||||
it('respects port isolation — does not touch other ports', async () => {
|
||||
const otherPort = await setupTestPort();
|
||||
const [otherClient] = await db.insert(clients).values({
|
||||
portId: otherPort, firstName: 'Other', lastName: 'Port',
|
||||
email: `other-${crypto.randomUUID()}@example.com`,
|
||||
}).returning();
|
||||
const [otherClient] = await db
|
||||
.insert(clients)
|
||||
.values({
|
||||
portId: otherPort,
|
||||
firstName: 'Other',
|
||||
lastName: 'Port',
|
||||
email: `other-${crypto.randomUUID()}@example.com`,
|
||||
})
|
||||
.returning();
|
||||
await db.insert(files).values({
|
||||
portId: otherPort, clientId: otherClient!.id, filename: 'b.pdf',
|
||||
originalName: 'b.pdf', storagePath: `test/${crypto.randomUUID()}`,
|
||||
storageBucket: 'test', uploadedBy: TEST_USER_ID,
|
||||
portId: otherPort,
|
||||
clientId: otherClient!.id,
|
||||
filename: 'b.pdf',
|
||||
originalName: 'b.pdf',
|
||||
storagePath: `test/${crypto.randomUUID()}`,
|
||||
storageBucket: 'test',
|
||||
uploadedBy: TEST_USER_ID,
|
||||
});
|
||||
await runBackfill({ portId }); // only this port
|
||||
const otherRoots = await db.select().from(documentFolders).where(eq(documentFolders.portId, otherPort));
|
||||
const otherRoots = await db
|
||||
.select()
|
||||
.from(documentFolders)
|
||||
.where(eq(documentFolders.portId, otherPort));
|
||||
expect(otherRoots).toHaveLength(0);
|
||||
});
|
||||
});
|
||||
@@ -3009,11 +3130,13 @@ export async function runBackfill(opts: BackfillOptions = {}): Promise<void> {
|
||||
);
|
||||
for (const d of completedDocs) {
|
||||
if (!d.signedFileId) continue;
|
||||
const owner =
|
||||
d.clientId ? ({ type: 'client', id: d.clientId } as const)
|
||||
: d.companyId ? ({ type: 'company', id: d.companyId } as const)
|
||||
: d.yachtId ? ({ type: 'yacht', id: d.yachtId } as const)
|
||||
: null;
|
||||
const owner = d.clientId
|
||||
? ({ type: 'client', id: d.clientId } as const)
|
||||
: d.companyId
|
||||
? ({ type: 'company', id: d.companyId } as const)
|
||||
: d.yachtId
|
||||
? ({ type: 'yacht', id: d.yachtId } as const)
|
||||
: null;
|
||||
if (!owner) continue;
|
||||
await tx
|
||||
.update(files)
|
||||
@@ -3030,8 +3153,8 @@ export async function runBackfill(opts: BackfillOptions = {}): Promise<void> {
|
||||
owner.type === 'client'
|
||||
? files.clientId
|
||||
: owner.type === 'company'
|
||||
? files.companyId
|
||||
: files.yachtId,
|
||||
? files.companyId
|
||||
: files.yachtId,
|
||||
),
|
||||
),
|
||||
);
|
||||
@@ -3043,11 +3166,13 @@ export async function runBackfill(opts: BackfillOptions = {}): Promise<void> {
|
||||
.from(files)
|
||||
.where(and(eq(files.portId, portId), isNull(files.folderId)));
|
||||
for (const f of fileRows) {
|
||||
const owner: { type: EntityType; id: string } | null =
|
||||
f.clientId ? { type: 'client', id: f.clientId }
|
||||
: f.companyId ? { type: 'company', id: f.companyId }
|
||||
: f.yachtId ? { type: 'yacht', id: f.yachtId }
|
||||
: null;
|
||||
const owner: { type: EntityType; id: string } | null = f.clientId
|
||||
? { type: 'client', id: f.clientId }
|
||||
: f.companyId
|
||||
? { type: 'company', id: f.companyId }
|
||||
: f.yachtId
|
||||
? { type: 'yacht', id: f.yachtId }
|
||||
: null;
|
||||
if (!owner) continue;
|
||||
try {
|
||||
const folder = await ensureEntityFolder(portId, owner.type, owner.id, systemUser);
|
||||
@@ -3172,8 +3297,7 @@ export function useAggregatedFiles(
|
||||
) {
|
||||
return useQuery<{ data: { groups: AggregatedGroup<AggregatedFile>[] } }>({
|
||||
queryKey: ['files', 'aggregated', entityType, entityId],
|
||||
queryFn: () =>
|
||||
apiFetch(`/api/v1/files?entityType=${entityType}&entityId=${entityId}`),
|
||||
queryFn: () => apiFetch(`/api/v1/files?entityType=${entityType}&entityId=${entityId}`),
|
||||
enabled: Boolean(entityType && entityId),
|
||||
staleTime: 10_000,
|
||||
});
|
||||
@@ -3186,8 +3310,7 @@ export function useAggregatedWorkflows(
|
||||
) {
|
||||
return useQuery<{ data: { groups: AggregatedGroup<AggregatedWorkflow>[] } }>({
|
||||
queryKey: ['documents', 'aggregated', entityType, entityId],
|
||||
queryFn: () =>
|
||||
apiFetch(`/api/v1/documents?entityType=${entityType}&entityId=${entityId}`),
|
||||
queryFn: () => apiFetch(`/api/v1/documents?entityType=${entityType}&entityId=${entityId}`),
|
||||
enabled: Boolean(entityType && entityId),
|
||||
staleTime: 10_000,
|
||||
});
|
||||
@@ -3434,7 +3557,10 @@ export function SigningDetailsDialog({ documentId, open, onOpenChange }: Props)
|
||||
</h5>
|
||||
<ul className="divide-y rounded border bg-muted/30">
|
||||
{data.data.signers.map((s) => (
|
||||
<li key={s.id} className="flex items-center justify-between gap-2 px-3 py-2 text-xs">
|
||||
<li
|
||||
key={s.id}
|
||||
className="flex items-center justify-between gap-2 px-3 py-2 text-xs"
|
||||
>
|
||||
<div className="min-w-0">
|
||||
<span className="font-medium">{s.signerName}</span>
|
||||
<span className="ml-2 text-muted-foreground">{s.signerEmail}</span>
|
||||
@@ -3536,8 +3662,10 @@ import { Lock } from 'lucide-react';
|
||||
>
|
||||
{/* existing chevron + folder icon */}
|
||||
<span className="truncate">{node.name}</span>
|
||||
{node.systemManaged ? <Lock className="ml-1 h-3 w-3 text-muted-foreground" aria-label="System folder" /> : null}
|
||||
</button>
|
||||
{node.systemManaged ? (
|
||||
<Lock className="ml-1 h-3 w-3 text-muted-foreground" aria-label="System folder" />
|
||||
) : null}
|
||||
</button>;
|
||||
```
|
||||
|
||||
Read the actual existing template first — the file is ~160 lines, copy its current row JSX and patch in the lock icon + archived muted class. Do not invent props or rewrite the structure.
|
||||
@@ -3548,15 +3676,13 @@ The actions menu shows Create / Rename / Move / Delete buttons or menu items key
|
||||
|
||||
```tsx
|
||||
// Find the selected folder in the tree
|
||||
const selected = selectedFolderId
|
||||
? findInTree(tree, selectedFolderId)
|
||||
: null;
|
||||
const selected = selectedFolderId ? findInTree(tree, selectedFolderId) : null;
|
||||
const isSystem = selected?.systemManaged ?? false;
|
||||
|
||||
// Disable Rename + Move + Delete buttons (or hide them) when isSystem:
|
||||
<Button disabled={isSystem || pending} onClick={handleRename}>
|
||||
Rename
|
||||
</Button>
|
||||
</Button>;
|
||||
// + a tooltip explaining "System folders can't be renamed/moved/deleted"
|
||||
```
|
||||
|
||||
@@ -3576,18 +3702,20 @@ function findInTree(tree: FolderNode[], id: string): FolderNode | null {
|
||||
Wrap each disabled button in a `<Tooltip>` (from `@/components/ui/tooltip`) explaining why when `isSystem`:
|
||||
|
||||
```tsx
|
||||
{isSystem ? (
|
||||
<Tooltip>
|
||||
<TooltipTrigger asChild>
|
||||
<span>
|
||||
<Button disabled>Rename</Button>
|
||||
</span>
|
||||
</TooltipTrigger>
|
||||
<TooltipContent>System folders can't be renamed.</TooltipContent>
|
||||
</Tooltip>
|
||||
) : (
|
||||
<Button onClick={handleRename}>Rename</Button>
|
||||
)}
|
||||
{
|
||||
isSystem ? (
|
||||
<Tooltip>
|
||||
<TooltipTrigger asChild>
|
||||
<span>
|
||||
<Button disabled>Rename</Button>
|
||||
</span>
|
||||
</TooltipTrigger>
|
||||
<TooltipContent>System folders can't be renamed.</TooltipContent>
|
||||
</Tooltip>
|
||||
) : (
|
||||
<Button onClick={handleRename}>Rename</Button>
|
||||
);
|
||||
}
|
||||
```
|
||||
|
||||
- [ ] **Step 4: Verify type + visual sanity in dev**
|
||||
@@ -3742,10 +3870,7 @@ import { ClipboardSignature, FileText, Eye } from 'lucide-react';
|
||||
|
||||
import { AggregatedSection } from './aggregated-section';
|
||||
import { SigningDetailsDialog } from './signing-details-dialog';
|
||||
import {
|
||||
useAggregatedFiles,
|
||||
useAggregatedWorkflows,
|
||||
} from '@/hooks/use-aggregated-listing';
|
||||
import { useAggregatedFiles, useAggregatedWorkflows } from '@/hooks/use-aggregated-listing';
|
||||
import { StatusPill } from '@/components/ui/status-pill';
|
||||
|
||||
interface Props {
|
||||
@@ -3879,7 +4004,9 @@ return (
|
||||
|
||||
{selectedFolderId === undefined ? (
|
||||
<HubRootView portSlug={portSlug} />
|
||||
) : selectedFolder?.entityType && selectedFolder.entityType !== 'root' && selectedFolder.entityId ? (
|
||||
) : selectedFolder?.entityType &&
|
||||
selectedFolder.entityType !== 'root' &&
|
||||
selectedFolder.entityId ? (
|
||||
<EntityFolderView
|
||||
portSlug={portSlug}
|
||||
entityType={selectedFolder.entityType as 'client' | 'company' | 'yacht'}
|
||||
@@ -4069,7 +4196,7 @@ grep -rln 'deploy' docs/ | head -5
|
||||
|
||||
If a runbook exists, add a step **after** the migration step:
|
||||
|
||||
```markdown
|
||||
````markdown
|
||||
### Documents hub split (Wave 11.B+)
|
||||
|
||||
Run after the `0051_documents_hub_split.sql` migration applies:
|
||||
@@ -4077,9 +4204,11 @@ Run after the `0051_documents_hub_split.sql` migration applies:
|
||||
```bash
|
||||
pnpm db:backfill:doc-folders
|
||||
```
|
||||
````
|
||||
|
||||
Idempotent — safe to re-run if the deploy is interrupted.
|
||||
```
|
||||
|
||||
````
|
||||
|
||||
If no runbook exists, add the step to the README or a fresh `docs/deploy.md`. Don't create a docs file unless one exists or is the obvious home — the user-facing repo conventions matter more than perfect docs.
|
||||
|
||||
@@ -4092,7 +4221,7 @@ PGPASSWORD=changeme psql -h localhost -p 5434 -U crm -d port_nimara_crm \
|
||||
-f src/lib/db/migrations/0051_documents_hub_split.sql
|
||||
# Run backfill:
|
||||
pnpm db:backfill:doc-folders
|
||||
```
|
||||
````
|
||||
|
||||
Expected: zero errors, system roots populated, file folder_ids set.
|
||||
|
||||
@@ -4145,7 +4274,10 @@ test('open client entity folder, see aggregated groups, view signing details', a
|
||||
await page.getByRole('button', { name: /Smith, John/ }).click();
|
||||
await expect(page.getByText(/DIRECTLY ATTACHED/i)).toBeVisible();
|
||||
await expect(page.getByRole('button', { name: /view signing details/i })).toBeVisible();
|
||||
await page.getByRole('button', { name: /view signing details/i }).first().click();
|
||||
await page
|
||||
.getByRole('button', { name: /view signing details/i })
|
||||
.first()
|
||||
.click();
|
||||
await expect(page.getByRole('dialog', { name: /Signing details/i })).toBeVisible();
|
||||
});
|
||||
```
|
||||
|
||||
@@ -163,7 +163,6 @@ if (require.main === module) {
|
||||
}
|
||||
runBackfill({ portId })
|
||||
.then(() => {
|
||||
// eslint-disable-next-line no-console
|
||||
console.log('Backfill complete');
|
||||
process.exit(0);
|
||||
})
|
||||
|
||||
@@ -36,26 +36,19 @@ export default async function PortalDocumentsPage() {
|
||||
<div className="space-y-6">
|
||||
<div>
|
||||
<h1 className="text-2xl font-semibold text-gray-900">Documents</h1>
|
||||
<p className="text-sm text-gray-500 mt-1">
|
||||
Your contracts, EOIs, and signed agreements
|
||||
</p>
|
||||
<p className="text-sm text-gray-500 mt-1">Your contracts, EOIs, and signed agreements</p>
|
||||
</div>
|
||||
|
||||
{documents.length === 0 ? (
|
||||
<div className="bg-white rounded-lg border p-12 text-center">
|
||||
<FileText className="h-10 w-10 text-gray-300 mx-auto mb-3" />
|
||||
<p className="text-gray-500 font-medium">No documents on file</p>
|
||||
<p className="text-sm text-gray-400 mt-1">
|
||||
Documents shared with you will appear here.
|
||||
</p>
|
||||
<p className="text-sm text-gray-400 mt-1">Documents shared with you will appear here.</p>
|
||||
</div>
|
||||
) : (
|
||||
<div className="space-y-3">
|
||||
{documents.map((doc) => (
|
||||
<div
|
||||
key={doc.id}
|
||||
className="bg-white rounded-lg border p-5"
|
||||
>
|
||||
<div key={doc.id} className="bg-white rounded-lg border p-5">
|
||||
<div className="flex items-start gap-4">
|
||||
<FileText className="h-5 w-5 text-gray-400 mt-0.5 flex-shrink-0" />
|
||||
<div className="flex-1 min-w-0">
|
||||
@@ -89,7 +82,11 @@ export default async function PortalDocumentsPage() {
|
||||
: 'text-gray-500'
|
||||
}
|
||||
>
|
||||
{signer.status === 'signed' ? '✓' : signer.status === 'declined' ? '✗' : '○'}
|
||||
{signer.status === 'signed'
|
||||
? '✓'
|
||||
: signer.status === 'declined'
|
||||
? '✗'
|
||||
: '○'}
|
||||
</span>
|
||||
<span className="text-gray-700">{signer.signerName}</span>
|
||||
<span className="text-gray-400 capitalize">
|
||||
|
||||
@@ -8,13 +8,7 @@ import { listRelationships, createRelationship } from '@/lib/services/clients.se
|
||||
|
||||
const createRelationshipSchema = z.object({
|
||||
clientBId: z.string().min(1),
|
||||
relationshipType: z.enum([
|
||||
'referred_by',
|
||||
'broker_for',
|
||||
'family_member',
|
||||
'same_vessel',
|
||||
'custom',
|
||||
]),
|
||||
relationshipType: z.enum(['referred_by', 'broker_for', 'family_member', 'same_vessel', 'custom']),
|
||||
description: z.string().optional(),
|
||||
});
|
||||
|
||||
|
||||
@@ -3,11 +3,7 @@ import { NextResponse } from 'next/server';
|
||||
import { withAuth, withPermission } from '@/lib/api/helpers';
|
||||
import { parseBody } from '@/lib/api/route-helpers';
|
||||
import { errorResponse } from '@/lib/errors';
|
||||
import {
|
||||
getClientById,
|
||||
updateClient,
|
||||
archiveClient,
|
||||
} from '@/lib/services/clients.service';
|
||||
import { getClientById, updateClient, archiveClient } from '@/lib/services/clients.service';
|
||||
import { updateClientSchema } from '@/lib/validators/clients';
|
||||
|
||||
export const GET = withAuth(
|
||||
|
||||
@@ -3,11 +3,7 @@ import { NextResponse } from 'next/server';
|
||||
import { withAuth, withPermission } from '@/lib/api/helpers';
|
||||
import { parseBody } from '@/lib/api/route-helpers';
|
||||
import { errorResponse } from '@/lib/errors';
|
||||
import {
|
||||
getTemplateById,
|
||||
updateTemplate,
|
||||
deleteTemplate,
|
||||
} from '@/lib/services/document-templates';
|
||||
import { getTemplateById, updateTemplate, deleteTemplate } from '@/lib/services/document-templates';
|
||||
import { updateTemplateSchema } from '@/lib/validators/document-templates';
|
||||
|
||||
export const GET = withAuth(
|
||||
|
||||
@@ -3,14 +3,8 @@ import { NextResponse } from 'next/server';
|
||||
import { withAuth, withPermission } from '@/lib/api/helpers';
|
||||
import { parseQuery, parseBody } from '@/lib/api/route-helpers';
|
||||
import { errorResponse } from '@/lib/errors';
|
||||
import {
|
||||
listTemplates,
|
||||
createTemplate,
|
||||
} from '@/lib/services/document-templates';
|
||||
import {
|
||||
listTemplatesSchema,
|
||||
createTemplateSchema,
|
||||
} from '@/lib/validators/document-templates';
|
||||
import { listTemplates, createTemplate } from '@/lib/services/document-templates';
|
||||
import { listTemplatesSchema, createTemplateSchema } from '@/lib/validators/document-templates';
|
||||
|
||||
export const GET = withAuth(
|
||||
withPermission('documents', 'view', async (req, ctx) => {
|
||||
|
||||
@@ -3,11 +3,7 @@ import { NextResponse } from 'next/server';
|
||||
import { withAuth, withPermission } from '@/lib/api/helpers';
|
||||
import { parseBody } from '@/lib/api/route-helpers';
|
||||
import { errorResponse } from '@/lib/errors';
|
||||
import {
|
||||
getExpenseById,
|
||||
updateExpense,
|
||||
archiveExpense,
|
||||
} from '@/lib/services/expenses';
|
||||
import { getExpenseById, updateExpense, archiveExpense } from '@/lib/services/expenses';
|
||||
import { updateExpenseSchema } from '@/lib/validators/expenses';
|
||||
|
||||
export const GET = withAuth(
|
||||
|
||||
@@ -50,7 +50,12 @@ export function TemplateVersionHistory({
|
||||
}, [fetchVersions]);
|
||||
|
||||
async function handleRollback(version: number) {
|
||||
if (!confirm(`Roll back to version ${version}? This will create a new version ${currentVersion + 1}.`)) return;
|
||||
if (
|
||||
!confirm(
|
||||
`Roll back to version ${version}? This will create a new version ${currentVersion + 1}.`,
|
||||
)
|
||||
)
|
||||
return;
|
||||
|
||||
setRollingBack(version);
|
||||
setError(null);
|
||||
@@ -70,9 +75,7 @@ export function TemplateVersionHistory({
|
||||
|
||||
if (loading) {
|
||||
return (
|
||||
<div className="py-4 text-center text-sm text-muted-foreground">
|
||||
Loading version history…
|
||||
</div>
|
||||
<div className="py-4 text-center text-sm text-muted-foreground">Loading version history…</div>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -81,8 +84,7 @@ export function TemplateVersionHistory({
|
||||
<div className="flex flex-col items-center gap-2 rounded-md border border-dashed p-6 text-center">
|
||||
<Clock className="h-6 w-6 text-muted-foreground" />
|
||||
<p className="text-sm text-muted-foreground">
|
||||
No previous versions found. Versions are saved whenever you update the
|
||||
template content.
|
||||
No previous versions found. Versions are saved whenever you update the template content.
|
||||
</p>
|
||||
</div>
|
||||
);
|
||||
@@ -91,28 +93,21 @@ export function TemplateVersionHistory({
|
||||
return (
|
||||
<div className="space-y-3">
|
||||
{error && (
|
||||
<p className="rounded bg-destructive/10 px-3 py-2 text-sm text-destructive">
|
||||
{error}
|
||||
</p>
|
||||
<p className="rounded bg-destructive/10 px-3 py-2 text-sm text-destructive">{error}</p>
|
||||
)}
|
||||
|
||||
<p className="text-sm text-muted-foreground">
|
||||
Current version: <strong>v{currentVersion}</strong>. Click Restore to
|
||||
roll back to a previous version (creates a new version).
|
||||
Current version: <strong>v{currentVersion}</strong>. Click Restore to roll back to a
|
||||
previous version (creates a new version).
|
||||
</p>
|
||||
|
||||
<div className="divide-y rounded-md border">
|
||||
{versions.map((v) => (
|
||||
<div
|
||||
key={v.auditLogId}
|
||||
className="flex items-center justify-between px-4 py-3"
|
||||
>
|
||||
<div key={v.auditLogId} className="flex items-center justify-between px-4 py-3">
|
||||
<div className="space-y-0.5">
|
||||
<div className="flex items-center gap-2">
|
||||
<Badge variant="outline">v{v.version}</Badge>
|
||||
<span className="text-sm font-medium">
|
||||
Version {v.version}
|
||||
</span>
|
||||
<span className="text-sm font-medium">Version {v.version}</span>
|
||||
</div>
|
||||
<p className="text-xs text-muted-foreground">
|
||||
Saved{' '}
|
||||
|
||||
@@ -53,7 +53,9 @@ export function QueueOverview({ queues }: QueueOverviewProps) {
|
||||
onKeyDown={(e) => e.key === 'Enter' && handleQueueClick(queue.name)}
|
||||
>
|
||||
<CardHeader className="p-3 pb-0">
|
||||
<CardTitle className="text-xs font-semibold capitalize truncate">{queue.name}</CardTitle>
|
||||
<CardTitle className="text-xs font-semibold capitalize truncate">
|
||||
{queue.name}
|
||||
</CardTitle>
|
||||
</CardHeader>
|
||||
<CardContent className="p-3 pt-2">
|
||||
<div className="grid grid-cols-2 gap-x-2 gap-y-1">
|
||||
|
||||
@@ -90,29 +90,20 @@ export function TagList() {
|
||||
{
|
||||
accessorKey: 'createdAt',
|
||||
header: 'Created',
|
||||
cell: ({ row }) =>
|
||||
new Date(row.original.createdAt).toLocaleDateString(),
|
||||
cell: ({ row }) => new Date(row.original.createdAt).toLocaleDateString(),
|
||||
},
|
||||
{
|
||||
id: 'actions',
|
||||
header: '',
|
||||
cell: ({ row }) => (
|
||||
<div className="flex items-center justify-end gap-1">
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="sm"
|
||||
onClick={() => handleEditTag(row.original)}
|
||||
>
|
||||
<Button variant="ghost" size="sm" onClick={() => handleEditTag(row.original)}>
|
||||
<Pencil className="h-4 w-4" />
|
||||
<span className="sr-only">Edit</span>
|
||||
</Button>
|
||||
<ConfirmationDialog
|
||||
trigger={
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="sm"
|
||||
className="text-destructive hover:text-destructive"
|
||||
>
|
||||
<Button variant="ghost" size="sm" className="text-destructive hover:text-destructive">
|
||||
<Trash2 className="h-4 w-4" />
|
||||
<span className="sr-only">Delete</span>
|
||||
</Button>
|
||||
@@ -158,12 +149,7 @@ export function TagList() {
|
||||
}
|
||||
/>
|
||||
|
||||
<TagForm
|
||||
open={formOpen}
|
||||
onOpenChange={setFormOpen}
|
||||
tag={editingTag}
|
||||
onSuccess={fetchTags}
|
||||
/>
|
||||
<TagForm open={formOpen} onOpenChange={setFormOpen} tag={editingTag} onSuccess={fetchTags} />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -93,10 +93,7 @@ export function WebhookEventSelector({ selected, onChange }: WebhookEventSelecto
|
||||
checked={selected.includes(event)}
|
||||
onCheckedChange={() => toggle(event)}
|
||||
/>
|
||||
<Label
|
||||
htmlFor={`event-${event}`}
|
||||
className="text-xs font-mono cursor-pointer"
|
||||
>
|
||||
<Label htmlFor={`event-${event}`} className="text-xs font-mono cursor-pointer">
|
||||
{event}
|
||||
</Label>
|
||||
</div>
|
||||
|
||||
@@ -28,11 +28,7 @@ export function WebhookSecretDisplay({ plaintext, masked }: WebhookSecretDisplay
|
||||
<strong>Copy this secret now.</strong> It will not be shown again.
|
||||
</div>
|
||||
<div className="flex items-center gap-2">
|
||||
<Input
|
||||
readOnly
|
||||
value={plaintext}
|
||||
className="font-mono text-sm"
|
||||
/>
|
||||
<Input readOnly value={plaintext} className="font-mono text-sm" />
|
||||
<Button type="button" variant="outline" size="sm" onClick={copySecret}>
|
||||
{copied ? 'Copied!' : 'Copy'}
|
||||
</Button>
|
||||
@@ -43,12 +39,10 @@ export function WebhookSecretDisplay({ plaintext, masked }: WebhookSecretDisplay
|
||||
|
||||
return (
|
||||
<div className="flex items-center gap-2">
|
||||
<Input
|
||||
readOnly
|
||||
value={masked}
|
||||
className="font-mono text-sm text-muted-foreground"
|
||||
/>
|
||||
<span className="text-xs text-muted-foreground">Use "Regenerate" to get a new secret</span>
|
||||
<Input readOnly value={masked} className="font-mono text-sm text-muted-foreground" />
|
||||
<span className="text-xs text-muted-foreground">
|
||||
Use "Regenerate" to get a new secret
|
||||
</span>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -135,7 +135,11 @@ export function DocumentsHub({ portSlug }: DocumentsHubProps) {
|
||||
entityId={selectedFolder!.entityId!}
|
||||
/>
|
||||
) : (
|
||||
<FlatFolderListing key={selectedFolderId ?? 'root'} portSlug={portSlug} folderId={selectedFolderId} />
|
||||
<FlatFolderListing
|
||||
key={selectedFolderId ?? 'root'}
|
||||
portSlug={portSlug}
|
||||
folderId={selectedFolderId}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -21,12 +21,7 @@ import {
|
||||
import { Input } from '@/components/ui/input';
|
||||
import { Label } from '@/components/ui/label';
|
||||
import { ConfirmationDialog } from '@/components/shared/confirmation-dialog';
|
||||
import {
|
||||
Tooltip,
|
||||
TooltipContent,
|
||||
TooltipProvider,
|
||||
TooltipTrigger,
|
||||
} from '@/components/ui/tooltip';
|
||||
import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from '@/components/ui/tooltip';
|
||||
import { toastError } from '@/lib/api/toast-error';
|
||||
import {
|
||||
useCreateFolder,
|
||||
|
||||
@@ -147,7 +147,10 @@ function FolderRow({
|
||||
)}
|
||||
<span className="truncate">{node.name}</span>
|
||||
{node.systemManaged ? (
|
||||
<Lock className="ml-1 h-3 w-3 shrink-0 text-muted-foreground" aria-label="System folder" />
|
||||
<Lock
|
||||
className="ml-1 h-3 w-3 shrink-0 text-muted-foreground"
|
||||
aria-label="System folder"
|
||||
/>
|
||||
) : null}
|
||||
</button>
|
||||
</div>
|
||||
|
||||
@@ -83,9 +83,7 @@ export function SigningProgress({ documentId, signers }: SigningProgressProps) {
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
{idx < sorted.length - 1 && (
|
||||
<div className="mb-6 h-0.5 w-8 flex-shrink-0 bg-border" />
|
||||
)}
|
||||
{idx < sorted.length - 1 && <div className="mb-6 h-0.5 w-8 flex-shrink-0 bg-border" />}
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
|
||||
@@ -98,12 +98,7 @@ export function EmailDraftButton({
|
||||
|
||||
return (
|
||||
<>
|
||||
<Button
|
||||
variant="outline"
|
||||
size="sm"
|
||||
onClick={handleGenerateDraft}
|
||||
disabled={isLoading}
|
||||
>
|
||||
<Button variant="outline" size="sm" onClick={handleGenerateDraft} disabled={isLoading}>
|
||||
{isLoading ? (
|
||||
<>
|
||||
<Loader2 className="mr-1.5 h-3.5 w-3.5 animate-spin" />
|
||||
@@ -117,17 +112,13 @@ export function EmailDraftButton({
|
||||
)}
|
||||
</Button>
|
||||
|
||||
{error && (
|
||||
<p className="text-xs text-destructive mt-1">{error}</p>
|
||||
)}
|
||||
{error && <p className="text-xs text-destructive mt-1">{error}</p>}
|
||||
|
||||
<Sheet open={sheetOpen} onOpenChange={setSheetOpen}>
|
||||
<SheetContent side="right" className="w-full max-w-lg flex flex-col">
|
||||
<SheetHeader>
|
||||
<SheetTitle>Generated Email Draft</SheetTitle>
|
||||
<SheetDescription>
|
||||
Review and edit the draft before sending.
|
||||
</SheetDescription>
|
||||
<SheetDescription>Review and edit the draft before sending.</SheetDescription>
|
||||
</SheetHeader>
|
||||
|
||||
{draft && (
|
||||
|
||||
@@ -1,6 +1,16 @@
|
||||
'use client';
|
||||
|
||||
import { Download, Eye, FileText, Film, Image, MoreHorizontal, Pencil, Sheet, Trash2 } from 'lucide-react';
|
||||
import {
|
||||
Download,
|
||||
Eye,
|
||||
FileText,
|
||||
Film,
|
||||
Image,
|
||||
MoreHorizontal,
|
||||
Pencil,
|
||||
Sheet,
|
||||
Trash2,
|
||||
} from 'lucide-react';
|
||||
import { format } from 'date-fns';
|
||||
|
||||
import { Button } from '@/components/ui/button';
|
||||
|
||||
@@ -3,12 +3,7 @@
|
||||
import { useEffect, useState } from 'react';
|
||||
import { ExternalLink } from 'lucide-react';
|
||||
|
||||
import {
|
||||
Dialog,
|
||||
DialogContent,
|
||||
DialogHeader,
|
||||
DialogTitle,
|
||||
} from '@/components/ui/dialog';
|
||||
import { Dialog, DialogContent, DialogHeader, DialogTitle } from '@/components/ui/dialog';
|
||||
import { apiFetch } from '@/lib/api/client';
|
||||
|
||||
interface FilePreviewDialogProps {
|
||||
@@ -99,11 +94,7 @@ export function FilePreviewDialog({
|
||||
)}
|
||||
|
||||
{!loading && !error && previewUrl && isPdf && (
|
||||
<iframe
|
||||
src={previewUrl}
|
||||
title={fileName ?? 'PDF Preview'}
|
||||
className="h-full w-full"
|
||||
/>
|
||||
<iframe src={previewUrl} title={fileName ?? 'PDF Preview'} className="h-full w-full" />
|
||||
)}
|
||||
</div>
|
||||
</DialogContent>
|
||||
|
||||
@@ -55,13 +55,19 @@ export function PipelineCard({
|
||||
|
||||
<div className="flex items-center justify-between gap-2">
|
||||
{leadCategory && (
|
||||
<Badge variant={(LEAD_CATEGORY_COLORS[leadCategory] as 'default' | 'secondary' | 'destructive' | 'outline') ?? 'secondary'}>
|
||||
<Badge
|
||||
variant={
|
||||
(LEAD_CATEGORY_COLORS[leadCategory] as
|
||||
| 'default'
|
||||
| 'secondary'
|
||||
| 'destructive'
|
||||
| 'outline') ?? 'secondary'
|
||||
}
|
||||
>
|
||||
{leadCategory.replace(/_/g, ' ')}
|
||||
</Badge>
|
||||
)}
|
||||
<span className="text-xs text-muted-foreground ml-auto">
|
||||
{daysInStage}d
|
||||
</span>
|
||||
<span className="text-xs text-muted-foreground ml-auto">{daysInStage}d</span>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
|
||||
@@ -38,10 +38,7 @@ export function PipelineColumn({ stage, label, items }: PipelineColumnProps) {
|
||||
</div>
|
||||
|
||||
<div className="flex flex-col gap-2 overflow-y-auto max-h-[calc(100vh-220px)]">
|
||||
<SortableContext
|
||||
items={items.map((i) => i.id)}
|
||||
strategy={verticalListSortingStrategy}
|
||||
>
|
||||
<SortableContext items={items.map((i) => i.id)} strategy={verticalListSortingStrategy}>
|
||||
{items.map((item) => (
|
||||
<PipelineCard
|
||||
key={item.id}
|
||||
|
||||
@@ -81,16 +81,11 @@ export function RecommendationList({ interestId }: RecommendationListProps) {
|
||||
{recommendations.map((rec) => {
|
||||
const score = rec.matchScore ? Math.round(parseFloat(rec.matchScore)) : 0;
|
||||
return (
|
||||
<div
|
||||
key={rec.id}
|
||||
className="border rounded-lg p-3 flex items-center gap-4"
|
||||
>
|
||||
<div key={rec.id} className="border rounded-lg p-3 flex items-center gap-4">
|
||||
<div className="flex-1 min-w-0">
|
||||
<div className="flex items-center gap-2 mb-1">
|
||||
<span className="text-sm font-medium">{rec.mooringNumber}</span>
|
||||
{rec.area && (
|
||||
<span className="text-xs text-muted-foreground">{rec.area}</span>
|
||||
)}
|
||||
{rec.area && <span className="text-xs text-muted-foreground">{rec.area}</span>}
|
||||
<Badge
|
||||
variant={rec.source === 'ai' ? 'secondary' : 'outline'}
|
||||
className="text-xs"
|
||||
|
||||
@@ -70,9 +70,7 @@ export function getInvoiceColumns({
|
||||
id: 'clientName',
|
||||
accessorKey: 'clientName',
|
||||
header: 'Client',
|
||||
cell: ({ getValue }) => (
|
||||
<span className="font-medium">{getValue() as string}</span>
|
||||
),
|
||||
cell: ({ getValue }) => <span className="font-medium">{getValue() as string}</span>,
|
||||
},
|
||||
{
|
||||
id: 'total',
|
||||
@@ -96,10 +94,7 @@ export function getInvoiceColumns({
|
||||
const status = (getValue() as string) ?? 'draft';
|
||||
const colorClass = STATUS_COLORS[status] ?? STATUS_COLORS.draft;
|
||||
return (
|
||||
<Badge
|
||||
variant="outline"
|
||||
className={`capitalize text-xs border ${colorClass}`}
|
||||
>
|
||||
<Badge variant="outline" className={`capitalize text-xs border ${colorClass}`}>
|
||||
{status}
|
||||
</Badge>
|
||||
);
|
||||
@@ -111,8 +106,7 @@ export function getInvoiceColumns({
|
||||
header: 'Due Date',
|
||||
cell: ({ row }) => {
|
||||
const due = row.original.dueDate;
|
||||
const isOverdue =
|
||||
row.original.status === 'sent' && due < today;
|
||||
const isOverdue = row.original.status === 'sent' && due < today;
|
||||
return (
|
||||
<span
|
||||
className={`text-sm ${isOverdue ? 'text-red-600 font-medium' : 'text-muted-foreground'}`}
|
||||
@@ -162,18 +156,14 @@ export function getInvoiceColumns({
|
||||
Send
|
||||
</DropdownMenuItem>
|
||||
)}
|
||||
{(invoice.status === 'sent' || invoice.status === 'overdue') &&
|
||||
onRecordPayment && (
|
||||
<DropdownMenuItem onClick={() => onRecordPayment(invoice)}>
|
||||
<CreditCard className="mr-2 h-3.5 w-3.5" />
|
||||
Record Payment
|
||||
</DropdownMenuItem>
|
||||
)}
|
||||
{(invoice.status === 'sent' || invoice.status === 'overdue') && onRecordPayment && (
|
||||
<DropdownMenuItem onClick={() => onRecordPayment(invoice)}>
|
||||
<CreditCard className="mr-2 h-3.5 w-3.5" />
|
||||
Record Payment
|
||||
</DropdownMenuItem>
|
||||
)}
|
||||
{invoice.status === 'draft' && onDelete && (
|
||||
<DropdownMenuItem
|
||||
className="text-destructive"
|
||||
onClick={() => onDelete(invoice)}
|
||||
>
|
||||
<DropdownMenuItem className="text-destructive" onClick={() => onDelete(invoice)}>
|
||||
<Trash2 className="mr-2 h-3.5 w-3.5" />
|
||||
Delete
|
||||
</DropdownMenuItem>
|
||||
|
||||
@@ -12,11 +12,17 @@ interface InvoicePdfPreviewProps {
|
||||
pdfFileId?: string | null;
|
||||
}
|
||||
|
||||
export function InvoicePdfPreview({ invoiceId, pdfFileId: initialPdfFileId }: InvoicePdfPreviewProps) {
|
||||
export function InvoicePdfPreview({
|
||||
invoiceId,
|
||||
pdfFileId: initialPdfFileId,
|
||||
}: InvoicePdfPreviewProps) {
|
||||
const queryClient = useQueryClient();
|
||||
const [pdfFileId, setPdfFileId] = useState(initialPdfFileId);
|
||||
|
||||
const { data: previewData, isLoading: previewLoading } = useQuery<{ url: string; mimeType: string }>({
|
||||
const { data: previewData, isLoading: previewLoading } = useQuery<{
|
||||
url: string;
|
||||
mimeType: string;
|
||||
}>({
|
||||
queryKey: ['file-preview', pdfFileId],
|
||||
queryFn: () => apiFetch(`/api/v1/files/${pdfFileId}/preview`),
|
||||
enabled: !!pdfFileId,
|
||||
@@ -24,7 +30,9 @@ export function InvoicePdfPreview({ invoiceId, pdfFileId: initialPdfFileId }: In
|
||||
|
||||
const regenerateMutation = useMutation({
|
||||
mutationFn: () =>
|
||||
apiFetch<{ data?: { id?: string } }>(`/api/v1/invoices/${invoiceId}/generate-pdf`, { method: 'POST' }),
|
||||
apiFetch<{ data?: { id?: string } }>(`/api/v1/invoices/${invoiceId}/generate-pdf`, {
|
||||
method: 'POST',
|
||||
}),
|
||||
onSuccess: (data) => {
|
||||
const fileId = data?.data?.id;
|
||||
if (fileId) {
|
||||
|
||||
@@ -33,9 +33,7 @@ export function PortalCard({
|
||||
<div className="flex-1 min-w-0">
|
||||
<p className="text-sm text-gray-500">{title}</p>
|
||||
<p className="text-2xl font-semibold text-gray-900 mt-0.5">{value}</p>
|
||||
{description && (
|
||||
<p className="text-xs text-gray-400 mt-1">{description}</p>
|
||||
)}
|
||||
{description && <p className="text-xs text-gray-400 mt-1">{description}</p>}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
|
||||
@@ -24,11 +24,7 @@ export function PortalHeader({ portName, portLogoUrl, clientName }: PortalHeader
|
||||
<div className="max-w-5xl mx-auto px-4 sm:px-6 h-16 flex items-center justify-between">
|
||||
<div className="flex items-center gap-3">
|
||||
{portLogoUrl ? (
|
||||
<img
|
||||
src={portLogoUrl}
|
||||
alt={portName}
|
||||
className="h-8 w-auto object-contain"
|
||||
/>
|
||||
<img src={portLogoUrl} alt={portName} className="h-8 w-auto object-contain" />
|
||||
) : (
|
||||
<div className="h-8 w-8 rounded bg-[#1e2844] flex items-center justify-center">
|
||||
<span className="text-white text-xs font-bold">
|
||||
|
||||
@@ -129,10 +129,7 @@ export function GenerateReportForm() {
|
||||
</p>
|
||||
)}
|
||||
|
||||
<Button
|
||||
type="submit"
|
||||
disabled={!reportType || !name.trim() || mutation.isPending}
|
||||
>
|
||||
<Button type="submit" disabled={!reportType || !name.trim() || mutation.isPending}>
|
||||
{mutation.isPending ? 'Queuing...' : 'Generate Report'}
|
||||
</Button>
|
||||
</form>
|
||||
|
||||
@@ -22,11 +22,7 @@ export function ReportStatusBadge({ status }: ReportStatusBadgeProps) {
|
||||
</Badge>
|
||||
);
|
||||
case 'ready':
|
||||
return (
|
||||
<Badge className="bg-green-600 text-white hover:bg-green-700">
|
||||
Ready
|
||||
</Badge>
|
||||
);
|
||||
return <Badge className="bg-green-600 text-white hover:bg-green-700">Ready</Badge>;
|
||||
case 'failed':
|
||||
return <Badge variant="destructive">Failed</Badge>;
|
||||
default:
|
||||
|
||||
@@ -54,7 +54,9 @@ export function ArchiveConfirmDialog({
|
||||
onConfirm();
|
||||
}}
|
||||
disabled={isLoading}
|
||||
className={isArchived ? '' : 'bg-destructive text-destructive-foreground hover:bg-destructive/90'}
|
||||
className={
|
||||
isArchived ? '' : 'bg-destructive text-destructive-foreground hover:bg-destructive/90'
|
||||
}
|
||||
>
|
||||
{isLoading && <Loader2 className="mr-2 h-4 w-4 animate-spin" />}
|
||||
{action}
|
||||
|
||||
@@ -20,10 +20,7 @@ interface EmptyStateProps {
|
||||
export function EmptyState({ icon: Icon, title, description, action, className }: EmptyStateProps) {
|
||||
return (
|
||||
<div
|
||||
className={cn(
|
||||
'flex flex-col items-center justify-center text-center py-16 px-4',
|
||||
className,
|
||||
)}
|
||||
className={cn('flex flex-col items-center justify-center text-center py-16 px-4', className)}
|
||||
>
|
||||
{Icon && (
|
||||
<div className="w-12 h-12 rounded-full bg-muted flex items-center justify-center mb-4">
|
||||
@@ -31,9 +28,7 @@ export function EmptyState({ icon: Icon, title, description, action, className }
|
||||
</div>
|
||||
)}
|
||||
<h3 className="text-base font-semibold text-foreground mb-1">{title}</h3>
|
||||
{description && (
|
||||
<p className="text-sm text-muted-foreground max-w-sm mb-4">{description}</p>
|
||||
)}
|
||||
{description && <p className="text-sm text-muted-foreground max-w-sm mb-4">{description}</p>}
|
||||
{action && (
|
||||
<Button onClick={action.onClick} size="sm">
|
||||
{action.label}
|
||||
|
||||
@@ -15,10 +15,7 @@ export function TagBadge({ name, color, className }: TagBadgeProps) {
|
||||
className,
|
||||
)}
|
||||
>
|
||||
<span
|
||||
className="h-2 w-2 rounded-full shrink-0"
|
||||
style={{ backgroundColor: color }}
|
||||
/>
|
||||
<span className="h-2 w-2 rounded-full shrink-0" style={{ backgroundColor: color }} />
|
||||
{name}
|
||||
</span>
|
||||
);
|
||||
|
||||
@@ -1,24 +1,20 @@
|
||||
"use client"
|
||||
'use client';
|
||||
|
||||
import * as React from "react"
|
||||
import * as AccordionPrimitive from "@radix-ui/react-accordion"
|
||||
import { ChevronDown } from "lucide-react"
|
||||
import * as React from 'react';
|
||||
import * as AccordionPrimitive from '@radix-ui/react-accordion';
|
||||
import { ChevronDown } from 'lucide-react';
|
||||
|
||||
import { cn } from "@/lib/utils"
|
||||
import { cn } from '@/lib/utils';
|
||||
|
||||
const Accordion = AccordionPrimitive.Root
|
||||
const Accordion = AccordionPrimitive.Root;
|
||||
|
||||
const AccordionItem = React.forwardRef<
|
||||
React.ElementRef<typeof AccordionPrimitive.Item>,
|
||||
React.ComponentPropsWithoutRef<typeof AccordionPrimitive.Item>
|
||||
>(({ className, ...props }, ref) => (
|
||||
<AccordionPrimitive.Item
|
||||
ref={ref}
|
||||
className={cn("border-b", className)}
|
||||
{...props}
|
||||
/>
|
||||
))
|
||||
AccordionItem.displayName = "AccordionItem"
|
||||
<AccordionPrimitive.Item ref={ref} className={cn('border-b', className)} {...props} />
|
||||
));
|
||||
AccordionItem.displayName = 'AccordionItem';
|
||||
|
||||
const AccordionTrigger = React.forwardRef<
|
||||
React.ElementRef<typeof AccordionPrimitive.Trigger>,
|
||||
@@ -28,8 +24,8 @@ const AccordionTrigger = React.forwardRef<
|
||||
<AccordionPrimitive.Trigger
|
||||
ref={ref}
|
||||
className={cn(
|
||||
"flex flex-1 items-center justify-between py-4 text-sm font-medium transition-all hover:underline text-left [&[data-state=open]>svg]:rotate-180",
|
||||
className
|
||||
'flex flex-1 items-center justify-between py-4 text-sm font-medium transition-all hover:underline text-left [&[data-state=open]>svg]:rotate-180',
|
||||
className,
|
||||
)}
|
||||
{...props}
|
||||
>
|
||||
@@ -37,8 +33,8 @@ const AccordionTrigger = React.forwardRef<
|
||||
<ChevronDown className="h-4 w-4 shrink-0 text-muted-foreground transition-transform duration-200" />
|
||||
</AccordionPrimitive.Trigger>
|
||||
</AccordionPrimitive.Header>
|
||||
))
|
||||
AccordionTrigger.displayName = AccordionPrimitive.Trigger.displayName
|
||||
));
|
||||
AccordionTrigger.displayName = AccordionPrimitive.Trigger.displayName;
|
||||
|
||||
const AccordionContent = React.forwardRef<
|
||||
React.ElementRef<typeof AccordionPrimitive.Content>,
|
||||
@@ -49,9 +45,9 @@ const AccordionContent = React.forwardRef<
|
||||
className="overflow-hidden text-sm data-[state=closed]:animate-accordion-up data-[state=open]:animate-accordion-down"
|
||||
{...props}
|
||||
>
|
||||
<div className={cn("pb-4 pt-0", className)}>{children}</div>
|
||||
<div className={cn('pb-4 pt-0', className)}>{children}</div>
|
||||
</AccordionPrimitive.Content>
|
||||
))
|
||||
AccordionContent.displayName = AccordionPrimitive.Content.displayName
|
||||
));
|
||||
AccordionContent.displayName = AccordionPrimitive.Content.displayName;
|
||||
|
||||
export { Accordion, AccordionItem, AccordionTrigger, AccordionContent }
|
||||
export { Accordion, AccordionItem, AccordionTrigger, AccordionContent };
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
"use client"
|
||||
'use client';
|
||||
|
||||
import * as React from "react"
|
||||
import * as AlertDialogPrimitive from "@radix-ui/react-alert-dialog"
|
||||
import * as React from 'react';
|
||||
import * as AlertDialogPrimitive from '@radix-ui/react-alert-dialog';
|
||||
|
||||
import { cn } from "@/lib/utils"
|
||||
import { buttonVariants } from "@/components/ui/button"
|
||||
import { cn } from '@/lib/utils';
|
||||
import { buttonVariants } from '@/components/ui/button';
|
||||
|
||||
const AlertDialog = AlertDialogPrimitive.Root
|
||||
const AlertDialog = AlertDialogPrimitive.Root;
|
||||
|
||||
const AlertDialogTrigger = AlertDialogPrimitive.Trigger
|
||||
const AlertDialogTrigger = AlertDialogPrimitive.Trigger;
|
||||
|
||||
const AlertDialogPortal = AlertDialogPrimitive.Portal
|
||||
const AlertDialogPortal = AlertDialogPrimitive.Portal;
|
||||
|
||||
const AlertDialogOverlay = React.forwardRef<
|
||||
React.ElementRef<typeof AlertDialogPrimitive.Overlay>,
|
||||
@@ -18,14 +18,14 @@ const AlertDialogOverlay = React.forwardRef<
|
||||
>(({ className, ...props }, ref) => (
|
||||
<AlertDialogPrimitive.Overlay
|
||||
className={cn(
|
||||
"fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",
|
||||
className
|
||||
'fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0',
|
||||
className,
|
||||
)}
|
||||
{...props}
|
||||
ref={ref}
|
||||
/>
|
||||
))
|
||||
AlertDialogOverlay.displayName = AlertDialogPrimitive.Overlay.displayName
|
||||
));
|
||||
AlertDialogOverlay.displayName = AlertDialogPrimitive.Overlay.displayName;
|
||||
|
||||
const AlertDialogContent = React.forwardRef<
|
||||
React.ElementRef<typeof AlertDialogPrimitive.Content>,
|
||||
@@ -36,42 +36,27 @@ const AlertDialogContent = React.forwardRef<
|
||||
<AlertDialogPrimitive.Content
|
||||
ref={ref}
|
||||
className={cn(
|
||||
"fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",
|
||||
className
|
||||
'fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg',
|
||||
className,
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
</AlertDialogPortal>
|
||||
))
|
||||
AlertDialogContent.displayName = AlertDialogPrimitive.Content.displayName
|
||||
));
|
||||
AlertDialogContent.displayName = AlertDialogPrimitive.Content.displayName;
|
||||
|
||||
const AlertDialogHeader = ({
|
||||
className,
|
||||
...props
|
||||
}: React.HTMLAttributes<HTMLDivElement>) => (
|
||||
const AlertDialogHeader = ({ className, ...props }: React.HTMLAttributes<HTMLDivElement>) => (
|
||||
<div className={cn('flex flex-col space-y-2 text-center sm:text-left', className)} {...props} />
|
||||
);
|
||||
AlertDialogHeader.displayName = 'AlertDialogHeader';
|
||||
|
||||
const AlertDialogFooter = ({ className, ...props }: React.HTMLAttributes<HTMLDivElement>) => (
|
||||
<div
|
||||
className={cn(
|
||||
"flex flex-col space-y-2 text-center sm:text-left",
|
||||
className
|
||||
)}
|
||||
className={cn('flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2', className)}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
AlertDialogHeader.displayName = "AlertDialogHeader"
|
||||
|
||||
const AlertDialogFooter = ({
|
||||
className,
|
||||
...props
|
||||
}: React.HTMLAttributes<HTMLDivElement>) => (
|
||||
<div
|
||||
className={cn(
|
||||
"flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
AlertDialogFooter.displayName = "AlertDialogFooter"
|
||||
);
|
||||
AlertDialogFooter.displayName = 'AlertDialogFooter';
|
||||
|
||||
const AlertDialogTitle = React.forwardRef<
|
||||
React.ElementRef<typeof AlertDialogPrimitive.Title>,
|
||||
@@ -79,11 +64,11 @@ const AlertDialogTitle = React.forwardRef<
|
||||
>(({ className, ...props }, ref) => (
|
||||
<AlertDialogPrimitive.Title
|
||||
ref={ref}
|
||||
className={cn("text-lg font-semibold", className)}
|
||||
className={cn('text-lg font-semibold', className)}
|
||||
{...props}
|
||||
/>
|
||||
))
|
||||
AlertDialogTitle.displayName = AlertDialogPrimitive.Title.displayName
|
||||
));
|
||||
AlertDialogTitle.displayName = AlertDialogPrimitive.Title.displayName;
|
||||
|
||||
const AlertDialogDescription = React.forwardRef<
|
||||
React.ElementRef<typeof AlertDialogPrimitive.Description>,
|
||||
@@ -91,24 +76,19 @@ const AlertDialogDescription = React.forwardRef<
|
||||
>(({ className, ...props }, ref) => (
|
||||
<AlertDialogPrimitive.Description
|
||||
ref={ref}
|
||||
className={cn("text-sm text-muted-foreground", className)}
|
||||
className={cn('text-sm text-muted-foreground', className)}
|
||||
{...props}
|
||||
/>
|
||||
))
|
||||
AlertDialogDescription.displayName =
|
||||
AlertDialogPrimitive.Description.displayName
|
||||
));
|
||||
AlertDialogDescription.displayName = AlertDialogPrimitive.Description.displayName;
|
||||
|
||||
const AlertDialogAction = React.forwardRef<
|
||||
React.ElementRef<typeof AlertDialogPrimitive.Action>,
|
||||
React.ComponentPropsWithoutRef<typeof AlertDialogPrimitive.Action>
|
||||
>(({ className, ...props }, ref) => (
|
||||
<AlertDialogPrimitive.Action
|
||||
ref={ref}
|
||||
className={cn(buttonVariants(), className)}
|
||||
{...props}
|
||||
/>
|
||||
))
|
||||
AlertDialogAction.displayName = AlertDialogPrimitive.Action.displayName
|
||||
<AlertDialogPrimitive.Action ref={ref} className={cn(buttonVariants(), className)} {...props} />
|
||||
));
|
||||
AlertDialogAction.displayName = AlertDialogPrimitive.Action.displayName;
|
||||
|
||||
const AlertDialogCancel = React.forwardRef<
|
||||
React.ElementRef<typeof AlertDialogPrimitive.Cancel>,
|
||||
@@ -116,15 +96,11 @@ const AlertDialogCancel = React.forwardRef<
|
||||
>(({ className, ...props }, ref) => (
|
||||
<AlertDialogPrimitive.Cancel
|
||||
ref={ref}
|
||||
className={cn(
|
||||
buttonVariants({ variant: "outline" }),
|
||||
"mt-2 sm:mt-0",
|
||||
className
|
||||
)}
|
||||
className={cn(buttonVariants({ variant: 'outline' }), 'mt-2 sm:mt-0', className)}
|
||||
{...props}
|
||||
/>
|
||||
))
|
||||
AlertDialogCancel.displayName = AlertDialogPrimitive.Cancel.displayName
|
||||
));
|
||||
AlertDialogCancel.displayName = AlertDialogPrimitive.Cancel.displayName;
|
||||
|
||||
export {
|
||||
AlertDialog,
|
||||
@@ -138,4 +114,4 @@ export {
|
||||
AlertDialogDescription,
|
||||
AlertDialogAction,
|
||||
AlertDialogCancel,
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
"use client"
|
||||
'use client';
|
||||
|
||||
import * as React from "react"
|
||||
import * as AvatarPrimitive from "@radix-ui/react-avatar"
|
||||
import * as React from 'react';
|
||||
import * as AvatarPrimitive from '@radix-ui/react-avatar';
|
||||
|
||||
import { cn } from "@/lib/utils"
|
||||
import { cn } from '@/lib/utils';
|
||||
|
||||
const Avatar = React.forwardRef<
|
||||
React.ElementRef<typeof AvatarPrimitive.Root>,
|
||||
@@ -11,14 +11,11 @@ const Avatar = React.forwardRef<
|
||||
>(({ className, ...props }, ref) => (
|
||||
<AvatarPrimitive.Root
|
||||
ref={ref}
|
||||
className={cn(
|
||||
"relative flex h-10 w-10 shrink-0 overflow-hidden rounded-full",
|
||||
className
|
||||
)}
|
||||
className={cn('relative flex h-10 w-10 shrink-0 overflow-hidden rounded-full', className)}
|
||||
{...props}
|
||||
/>
|
||||
))
|
||||
Avatar.displayName = AvatarPrimitive.Root.displayName
|
||||
));
|
||||
Avatar.displayName = AvatarPrimitive.Root.displayName;
|
||||
|
||||
const AvatarImage = React.forwardRef<
|
||||
React.ElementRef<typeof AvatarPrimitive.Image>,
|
||||
@@ -26,11 +23,11 @@ const AvatarImage = React.forwardRef<
|
||||
>(({ className, ...props }, ref) => (
|
||||
<AvatarPrimitive.Image
|
||||
ref={ref}
|
||||
className={cn("aspect-square h-full w-full", className)}
|
||||
className={cn('aspect-square h-full w-full', className)}
|
||||
{...props}
|
||||
/>
|
||||
))
|
||||
AvatarImage.displayName = AvatarPrimitive.Image.displayName
|
||||
));
|
||||
AvatarImage.displayName = AvatarPrimitive.Image.displayName;
|
||||
|
||||
const AvatarFallback = React.forwardRef<
|
||||
React.ElementRef<typeof AvatarPrimitive.Fallback>,
|
||||
@@ -39,12 +36,12 @@ const AvatarFallback = React.forwardRef<
|
||||
<AvatarPrimitive.Fallback
|
||||
ref={ref}
|
||||
className={cn(
|
||||
"flex h-full w-full items-center justify-center rounded-full bg-muted",
|
||||
className
|
||||
'flex h-full w-full items-center justify-center rounded-full bg-muted',
|
||||
className,
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
))
|
||||
AvatarFallback.displayName = AvatarPrimitive.Fallback.displayName
|
||||
));
|
||||
AvatarFallback.displayName = AvatarPrimitive.Fallback.displayName;
|
||||
|
||||
export { Avatar, AvatarImage, AvatarFallback }
|
||||
export { Avatar, AvatarImage, AvatarFallback };
|
||||
|
||||
@@ -1,36 +1,32 @@
|
||||
import * as React from "react"
|
||||
import { cva, type VariantProps } from "class-variance-authority"
|
||||
import * as React from 'react';
|
||||
import { cva, type VariantProps } from 'class-variance-authority';
|
||||
|
||||
import { cn } from "@/lib/utils"
|
||||
import { cn } from '@/lib/utils';
|
||||
|
||||
const badgeVariants = cva(
|
||||
"inline-flex items-center rounded-md border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",
|
||||
'inline-flex items-center rounded-md border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2',
|
||||
{
|
||||
variants: {
|
||||
variant: {
|
||||
default:
|
||||
"border-transparent bg-primary text-primary-foreground shadow hover:bg-primary/80",
|
||||
default: 'border-transparent bg-primary text-primary-foreground shadow hover:bg-primary/80',
|
||||
secondary:
|
||||
"border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80",
|
||||
'border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80',
|
||||
destructive:
|
||||
"border-transparent bg-destructive text-destructive-foreground shadow hover:bg-destructive/80",
|
||||
outline: "text-foreground",
|
||||
'border-transparent bg-destructive text-destructive-foreground shadow hover:bg-destructive/80',
|
||||
outline: 'text-foreground',
|
||||
},
|
||||
},
|
||||
defaultVariants: {
|
||||
variant: "default",
|
||||
variant: 'default',
|
||||
},
|
||||
}
|
||||
)
|
||||
},
|
||||
);
|
||||
|
||||
export interface BadgeProps
|
||||
extends React.HTMLAttributes<HTMLDivElement>,
|
||||
VariantProps<typeof badgeVariants> {}
|
||||
extends React.HTMLAttributes<HTMLDivElement>, VariantProps<typeof badgeVariants> {}
|
||||
|
||||
function Badge({ className, variant, ...props }: BadgeProps) {
|
||||
return (
|
||||
<div className={cn(badgeVariants({ variant }), className)} {...props} />
|
||||
)
|
||||
return <div className={cn(badgeVariants({ variant }), className)} {...props} />;
|
||||
}
|
||||
|
||||
export { Badge, badgeVariants }
|
||||
export { Badge, badgeVariants };
|
||||
|
||||
@@ -1,108 +1,94 @@
|
||||
import * as React from "react"
|
||||
import { Slot } from "@radix-ui/react-slot"
|
||||
import { ChevronRight, MoreHorizontal } from "lucide-react"
|
||||
import * as React from 'react';
|
||||
import { Slot } from '@radix-ui/react-slot';
|
||||
import { ChevronRight, MoreHorizontal } from 'lucide-react';
|
||||
|
||||
import { cn } from "@/lib/utils"
|
||||
import { cn } from '@/lib/utils';
|
||||
|
||||
const Breadcrumb = React.forwardRef<
|
||||
HTMLElement,
|
||||
React.ComponentPropsWithoutRef<"nav"> & {
|
||||
separator?: React.ReactNode
|
||||
React.ComponentPropsWithoutRef<'nav'> & {
|
||||
separator?: React.ReactNode;
|
||||
}
|
||||
>(({ ...props }, ref) => <nav ref={ref} aria-label="breadcrumb" {...props} />)
|
||||
Breadcrumb.displayName = "Breadcrumb"
|
||||
>(({ ...props }, ref) => <nav ref={ref} aria-label="breadcrumb" {...props} />);
|
||||
Breadcrumb.displayName = 'Breadcrumb';
|
||||
|
||||
const BreadcrumbList = React.forwardRef<
|
||||
HTMLOListElement,
|
||||
React.ComponentPropsWithoutRef<"ol">
|
||||
>(({ className, ...props }, ref) => (
|
||||
<ol
|
||||
ref={ref}
|
||||
className={cn(
|
||||
"flex flex-wrap items-center gap-1.5 break-words text-sm text-muted-foreground sm:gap-2.5",
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
))
|
||||
BreadcrumbList.displayName = "BreadcrumbList"
|
||||
const BreadcrumbList = React.forwardRef<HTMLOListElement, React.ComponentPropsWithoutRef<'ol'>>(
|
||||
({ className, ...props }, ref) => (
|
||||
<ol
|
||||
ref={ref}
|
||||
className={cn(
|
||||
'flex flex-wrap items-center gap-1.5 break-words text-sm text-muted-foreground sm:gap-2.5',
|
||||
className,
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
),
|
||||
);
|
||||
BreadcrumbList.displayName = 'BreadcrumbList';
|
||||
|
||||
const BreadcrumbItem = React.forwardRef<
|
||||
HTMLLIElement,
|
||||
React.ComponentPropsWithoutRef<"li">
|
||||
>(({ className, ...props }, ref) => (
|
||||
<li
|
||||
ref={ref}
|
||||
className={cn("inline-flex items-center gap-1.5", className)}
|
||||
{...props}
|
||||
/>
|
||||
))
|
||||
BreadcrumbItem.displayName = "BreadcrumbItem"
|
||||
const BreadcrumbItem = React.forwardRef<HTMLLIElement, React.ComponentPropsWithoutRef<'li'>>(
|
||||
({ className, ...props }, ref) => (
|
||||
<li ref={ref} className={cn('inline-flex items-center gap-1.5', className)} {...props} />
|
||||
),
|
||||
);
|
||||
BreadcrumbItem.displayName = 'BreadcrumbItem';
|
||||
|
||||
const BreadcrumbLink = React.forwardRef<
|
||||
HTMLAnchorElement,
|
||||
React.ComponentPropsWithoutRef<"a"> & {
|
||||
asChild?: boolean
|
||||
React.ComponentPropsWithoutRef<'a'> & {
|
||||
asChild?: boolean;
|
||||
}
|
||||
>(({ asChild, className, ...props }, ref) => {
|
||||
const Comp = asChild ? Slot : "a"
|
||||
const Comp = asChild ? Slot : 'a';
|
||||
|
||||
return (
|
||||
<Comp
|
||||
ref={ref}
|
||||
className={cn("transition-colors hover:text-foreground", className)}
|
||||
className={cn('transition-colors hover:text-foreground', className)}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
})
|
||||
BreadcrumbLink.displayName = "BreadcrumbLink"
|
||||
);
|
||||
});
|
||||
BreadcrumbLink.displayName = 'BreadcrumbLink';
|
||||
|
||||
const BreadcrumbPage = React.forwardRef<
|
||||
HTMLSpanElement,
|
||||
React.ComponentPropsWithoutRef<"span">
|
||||
>(({ className, ...props }, ref) => (
|
||||
<span
|
||||
ref={ref}
|
||||
role="link"
|
||||
aria-disabled="true"
|
||||
aria-current="page"
|
||||
className={cn("font-normal text-foreground", className)}
|
||||
{...props}
|
||||
/>
|
||||
))
|
||||
BreadcrumbPage.displayName = "BreadcrumbPage"
|
||||
const BreadcrumbPage = React.forwardRef<HTMLSpanElement, React.ComponentPropsWithoutRef<'span'>>(
|
||||
({ className, ...props }, ref) => (
|
||||
<span
|
||||
ref={ref}
|
||||
role="link"
|
||||
aria-disabled="true"
|
||||
aria-current="page"
|
||||
className={cn('font-normal text-foreground', className)}
|
||||
{...props}
|
||||
/>
|
||||
),
|
||||
);
|
||||
BreadcrumbPage.displayName = 'BreadcrumbPage';
|
||||
|
||||
const BreadcrumbSeparator = ({
|
||||
children,
|
||||
className,
|
||||
...props
|
||||
}: React.ComponentProps<"li">) => (
|
||||
const BreadcrumbSeparator = ({ children, className, ...props }: React.ComponentProps<'li'>) => (
|
||||
<li
|
||||
role="presentation"
|
||||
aria-hidden="true"
|
||||
className={cn("[&>svg]:w-3.5 [&>svg]:h-3.5", className)}
|
||||
className={cn('[&>svg]:w-3.5 [&>svg]:h-3.5', className)}
|
||||
{...props}
|
||||
>
|
||||
{children ?? <ChevronRight />}
|
||||
</li>
|
||||
)
|
||||
BreadcrumbSeparator.displayName = "BreadcrumbSeparator"
|
||||
);
|
||||
BreadcrumbSeparator.displayName = 'BreadcrumbSeparator';
|
||||
|
||||
const BreadcrumbEllipsis = ({
|
||||
className,
|
||||
...props
|
||||
}: React.ComponentProps<"span">) => (
|
||||
const BreadcrumbEllipsis = ({ className, ...props }: React.ComponentProps<'span'>) => (
|
||||
<span
|
||||
role="presentation"
|
||||
aria-hidden="true"
|
||||
className={cn("flex h-9 w-9 items-center justify-center", className)}
|
||||
className={cn('flex h-9 w-9 items-center justify-center', className)}
|
||||
{...props}
|
||||
>
|
||||
<MoreHorizontal className="h-4 w-4" />
|
||||
<span className="sr-only">More</span>
|
||||
</span>
|
||||
)
|
||||
BreadcrumbEllipsis.displayName = "BreadcrumbElipssis"
|
||||
);
|
||||
BreadcrumbEllipsis.displayName = 'BreadcrumbElipssis';
|
||||
|
||||
export {
|
||||
Breadcrumb,
|
||||
@@ -112,4 +98,4 @@ export {
|
||||
BreadcrumbPage,
|
||||
BreadcrumbSeparator,
|
||||
BreadcrumbEllipsis,
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1,159 +1,123 @@
|
||||
"use client"
|
||||
'use client';
|
||||
|
||||
import * as React from "react"
|
||||
import {
|
||||
ChevronDownIcon,
|
||||
ChevronLeftIcon,
|
||||
ChevronRightIcon,
|
||||
} from "lucide-react"
|
||||
import { DayButton, DayPicker, getDefaultClassNames } from "react-day-picker"
|
||||
import * as React from 'react';
|
||||
import { ChevronDownIcon, ChevronLeftIcon, ChevronRightIcon } from 'lucide-react';
|
||||
import { DayButton, DayPicker, getDefaultClassNames } from 'react-day-picker';
|
||||
|
||||
import { cn } from "@/lib/utils"
|
||||
import { Button, buttonVariants } from "@/components/ui/button"
|
||||
import { cn } from '@/lib/utils';
|
||||
import { Button, buttonVariants } from '@/components/ui/button';
|
||||
|
||||
function Calendar({
|
||||
className,
|
||||
classNames,
|
||||
showOutsideDays = true,
|
||||
captionLayout = "label",
|
||||
buttonVariant = "ghost",
|
||||
captionLayout = 'label',
|
||||
buttonVariant = 'ghost',
|
||||
formatters,
|
||||
components,
|
||||
...props
|
||||
}: React.ComponentProps<typeof DayPicker> & {
|
||||
buttonVariant?: React.ComponentProps<typeof Button>["variant"]
|
||||
buttonVariant?: React.ComponentProps<typeof Button>['variant'];
|
||||
}) {
|
||||
const defaultClassNames = getDefaultClassNames()
|
||||
const defaultClassNames = getDefaultClassNames();
|
||||
|
||||
return (
|
||||
<DayPicker
|
||||
showOutsideDays={showOutsideDays}
|
||||
className={cn(
|
||||
"bg-background group/calendar p-3 [--cell-size:2rem] [[data-slot=card-content]_&]:bg-transparent [[data-slot=popover-content]_&]:bg-transparent",
|
||||
'bg-background group/calendar p-3 [--cell-size:2rem] [[data-slot=card-content]_&]:bg-transparent [[data-slot=popover-content]_&]:bg-transparent',
|
||||
String.raw`rtl:**:[.rdp-button\_next>svg]:rotate-180`,
|
||||
String.raw`rtl:**:[.rdp-button\_previous>svg]:rotate-180`,
|
||||
className
|
||||
className,
|
||||
)}
|
||||
captionLayout={captionLayout}
|
||||
formatters={{
|
||||
formatMonthDropdown: (date) =>
|
||||
date.toLocaleString("default", { month: "short" }),
|
||||
formatMonthDropdown: (date) => date.toLocaleString('default', { month: 'short' }),
|
||||
...formatters,
|
||||
}}
|
||||
classNames={{
|
||||
root: cn("w-fit", defaultClassNames.root),
|
||||
months: cn(
|
||||
"relative flex flex-col gap-4 md:flex-row",
|
||||
defaultClassNames.months
|
||||
),
|
||||
month: cn("flex w-full flex-col gap-4", defaultClassNames.month),
|
||||
root: cn('w-fit', defaultClassNames.root),
|
||||
months: cn('relative flex flex-col gap-4 md:flex-row', defaultClassNames.months),
|
||||
month: cn('flex w-full flex-col gap-4', defaultClassNames.month),
|
||||
nav: cn(
|
||||
"absolute inset-x-0 top-0 flex w-full items-center justify-between gap-1",
|
||||
defaultClassNames.nav
|
||||
'absolute inset-x-0 top-0 flex w-full items-center justify-between gap-1',
|
||||
defaultClassNames.nav,
|
||||
),
|
||||
button_previous: cn(
|
||||
buttonVariants({ variant: buttonVariant }),
|
||||
"h-[--cell-size] w-[--cell-size] select-none p-0 aria-disabled:opacity-50",
|
||||
defaultClassNames.button_previous
|
||||
'h-[--cell-size] w-[--cell-size] select-none p-0 aria-disabled:opacity-50',
|
||||
defaultClassNames.button_previous,
|
||||
),
|
||||
button_next: cn(
|
||||
buttonVariants({ variant: buttonVariant }),
|
||||
"h-[--cell-size] w-[--cell-size] select-none p-0 aria-disabled:opacity-50",
|
||||
defaultClassNames.button_next
|
||||
'h-[--cell-size] w-[--cell-size] select-none p-0 aria-disabled:opacity-50',
|
||||
defaultClassNames.button_next,
|
||||
),
|
||||
month_caption: cn(
|
||||
"flex h-[--cell-size] w-full items-center justify-center px-[--cell-size]",
|
||||
defaultClassNames.month_caption
|
||||
'flex h-[--cell-size] w-full items-center justify-center px-[--cell-size]',
|
||||
defaultClassNames.month_caption,
|
||||
),
|
||||
dropdowns: cn(
|
||||
"flex h-[--cell-size] w-full items-center justify-center gap-1.5 text-sm font-medium",
|
||||
defaultClassNames.dropdowns
|
||||
'flex h-[--cell-size] w-full items-center justify-center gap-1.5 text-sm font-medium',
|
||||
defaultClassNames.dropdowns,
|
||||
),
|
||||
dropdown_root: cn(
|
||||
"has-focus:border-ring border-input shadow-xs has-focus:ring-ring/50 has-focus:ring-[3px] relative rounded-md border",
|
||||
defaultClassNames.dropdown_root
|
||||
),
|
||||
dropdown: cn(
|
||||
"bg-popover absolute inset-0 opacity-0",
|
||||
defaultClassNames.dropdown
|
||||
'has-focus:border-ring border-input shadow-xs has-focus:ring-ring/50 has-focus:ring-[3px] relative rounded-md border',
|
||||
defaultClassNames.dropdown_root,
|
||||
),
|
||||
dropdown: cn('bg-popover absolute inset-0 opacity-0', defaultClassNames.dropdown),
|
||||
caption_label: cn(
|
||||
"select-none font-medium",
|
||||
captionLayout === "label"
|
||||
? "text-sm"
|
||||
: "[&>svg]:text-muted-foreground flex h-8 items-center gap-1 rounded-md pl-2 pr-1 text-sm [&>svg]:size-3.5",
|
||||
defaultClassNames.caption_label
|
||||
'select-none font-medium',
|
||||
captionLayout === 'label'
|
||||
? 'text-sm'
|
||||
: '[&>svg]:text-muted-foreground flex h-8 items-center gap-1 rounded-md pl-2 pr-1 text-sm [&>svg]:size-3.5',
|
||||
defaultClassNames.caption_label,
|
||||
),
|
||||
table: "w-full border-collapse",
|
||||
weekdays: cn("flex", defaultClassNames.weekdays),
|
||||
table: 'w-full border-collapse',
|
||||
weekdays: cn('flex', defaultClassNames.weekdays),
|
||||
weekday: cn(
|
||||
"text-muted-foreground flex-1 select-none rounded-md text-[0.8rem] font-normal",
|
||||
defaultClassNames.weekday
|
||||
),
|
||||
week: cn("mt-2 flex w-full", defaultClassNames.week),
|
||||
week_number_header: cn(
|
||||
"w-[--cell-size] select-none",
|
||||
defaultClassNames.week_number_header
|
||||
'text-muted-foreground flex-1 select-none rounded-md text-[0.8rem] font-normal',
|
||||
defaultClassNames.weekday,
|
||||
),
|
||||
week: cn('mt-2 flex w-full', defaultClassNames.week),
|
||||
week_number_header: cn('w-[--cell-size] select-none', defaultClassNames.week_number_header),
|
||||
week_number: cn(
|
||||
"text-muted-foreground select-none text-[0.8rem]",
|
||||
defaultClassNames.week_number
|
||||
'text-muted-foreground select-none text-[0.8rem]',
|
||||
defaultClassNames.week_number,
|
||||
),
|
||||
day: cn(
|
||||
"group/day relative aspect-square h-full w-full select-none p-0 text-center [&:first-child[data-selected=true]_button]:rounded-l-md [&:last-child[data-selected=true]_button]:rounded-r-md",
|
||||
defaultClassNames.day
|
||||
'group/day relative aspect-square h-full w-full select-none p-0 text-center [&:first-child[data-selected=true]_button]:rounded-l-md [&:last-child[data-selected=true]_button]:rounded-r-md',
|
||||
defaultClassNames.day,
|
||||
),
|
||||
range_start: cn(
|
||||
"bg-accent rounded-l-md",
|
||||
defaultClassNames.range_start
|
||||
),
|
||||
range_middle: cn("rounded-none", defaultClassNames.range_middle),
|
||||
range_end: cn("bg-accent rounded-r-md", defaultClassNames.range_end),
|
||||
range_start: cn('bg-accent rounded-l-md', defaultClassNames.range_start),
|
||||
range_middle: cn('rounded-none', defaultClassNames.range_middle),
|
||||
range_end: cn('bg-accent rounded-r-md', defaultClassNames.range_end),
|
||||
today: cn(
|
||||
"bg-accent text-accent-foreground rounded-md data-[selected=true]:rounded-none",
|
||||
defaultClassNames.today
|
||||
'bg-accent text-accent-foreground rounded-md data-[selected=true]:rounded-none',
|
||||
defaultClassNames.today,
|
||||
),
|
||||
outside: cn(
|
||||
"text-muted-foreground aria-selected:text-muted-foreground",
|
||||
defaultClassNames.outside
|
||||
'text-muted-foreground aria-selected:text-muted-foreground',
|
||||
defaultClassNames.outside,
|
||||
),
|
||||
disabled: cn(
|
||||
"text-muted-foreground opacity-50",
|
||||
defaultClassNames.disabled
|
||||
),
|
||||
hidden: cn("invisible", defaultClassNames.hidden),
|
||||
disabled: cn('text-muted-foreground opacity-50', defaultClassNames.disabled),
|
||||
hidden: cn('invisible', defaultClassNames.hidden),
|
||||
...classNames,
|
||||
}}
|
||||
components={{
|
||||
Root: ({ className, rootRef, ...props }) => {
|
||||
return (
|
||||
<div
|
||||
data-slot="calendar"
|
||||
ref={rootRef}
|
||||
className={cn(className)}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
return <div data-slot="calendar" ref={rootRef} className={cn(className)} {...props} />;
|
||||
},
|
||||
Chevron: ({ className, orientation, ...props }) => {
|
||||
if (orientation === "left") {
|
||||
return (
|
||||
<ChevronLeftIcon className={cn("size-4", className)} {...props} />
|
||||
)
|
||||
if (orientation === 'left') {
|
||||
return <ChevronLeftIcon className={cn('size-4', className)} {...props} />;
|
||||
}
|
||||
|
||||
if (orientation === "right") {
|
||||
return (
|
||||
<ChevronRightIcon
|
||||
className={cn("size-4", className)}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
if (orientation === 'right') {
|
||||
return <ChevronRightIcon className={cn('size-4', className)} {...props} />;
|
||||
}
|
||||
|
||||
return (
|
||||
<ChevronDownIcon className={cn("size-4", className)} {...props} />
|
||||
)
|
||||
return <ChevronDownIcon className={cn('size-4', className)} {...props} />;
|
||||
},
|
||||
DayButton: CalendarDayButton,
|
||||
WeekNumber: ({ children, ...props }) => {
|
||||
@@ -163,13 +127,13 @@ function Calendar({
|
||||
{children}
|
||||
</div>
|
||||
</td>
|
||||
)
|
||||
);
|
||||
},
|
||||
...components,
|
||||
}}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
function CalendarDayButton({
|
||||
@@ -178,12 +142,12 @@ function CalendarDayButton({
|
||||
modifiers,
|
||||
...props
|
||||
}: React.ComponentProps<typeof DayButton>) {
|
||||
const defaultClassNames = getDefaultClassNames()
|
||||
const defaultClassNames = getDefaultClassNames();
|
||||
|
||||
const ref = React.useRef<HTMLButtonElement>(null)
|
||||
const ref = React.useRef<HTMLButtonElement>(null);
|
||||
React.useEffect(() => {
|
||||
if (modifiers.focused) ref.current?.focus()
|
||||
}, [modifiers.focused])
|
||||
if (modifiers.focused) ref.current?.focus();
|
||||
}, [modifiers.focused]);
|
||||
|
||||
return (
|
||||
<Button
|
||||
@@ -201,13 +165,13 @@ function CalendarDayButton({
|
||||
data-range-end={modifiers.range_end}
|
||||
data-range-middle={modifiers.range_middle}
|
||||
className={cn(
|
||||
"data-[selected-single=true]:bg-primary data-[selected-single=true]:text-primary-foreground data-[range-middle=true]:bg-accent data-[range-middle=true]:text-accent-foreground data-[range-start=true]:bg-primary data-[range-start=true]:text-primary-foreground data-[range-end=true]:bg-primary data-[range-end=true]:text-primary-foreground group-data-[focused=true]/day:border-ring group-data-[focused=true]/day:ring-ring/50 flex aspect-square h-auto w-full min-w-[--cell-size] flex-col gap-1 font-normal leading-none data-[range-end=true]:rounded-md data-[range-middle=true]:rounded-none data-[range-start=true]:rounded-md group-data-[focused=true]/day:relative group-data-[focused=true]/day:z-10 group-data-[focused=true]/day:ring-[3px] [&>span]:text-xs [&>span]:opacity-70",
|
||||
'data-[selected-single=true]:bg-primary data-[selected-single=true]:text-primary-foreground data-[range-middle=true]:bg-accent data-[range-middle=true]:text-accent-foreground data-[range-start=true]:bg-primary data-[range-start=true]:text-primary-foreground data-[range-end=true]:bg-primary data-[range-end=true]:text-primary-foreground group-data-[focused=true]/day:border-ring group-data-[focused=true]/day:ring-ring/50 flex aspect-square h-auto w-full min-w-[--cell-size] flex-col gap-1 font-normal leading-none data-[range-end=true]:rounded-md data-[range-middle=true]:rounded-none data-[range-start=true]:rounded-md group-data-[focused=true]/day:relative group-data-[focused=true]/day:z-10 group-data-[focused=true]/day:ring-[3px] [&>span]:text-xs [&>span]:opacity-70',
|
||||
defaultClassNames.day,
|
||||
className
|
||||
className,
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
export { Calendar, CalendarDayButton }
|
||||
export { Calendar, CalendarDayButton };
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
"use client"
|
||||
'use client';
|
||||
|
||||
import * as React from "react"
|
||||
import * as CheckboxPrimitive from "@radix-ui/react-checkbox"
|
||||
import { Check } from "lucide-react"
|
||||
import * as React from 'react';
|
||||
import * as CheckboxPrimitive from '@radix-ui/react-checkbox';
|
||||
import { Check } from 'lucide-react';
|
||||
|
||||
import { cn } from "@/lib/utils"
|
||||
import { cn } from '@/lib/utils';
|
||||
|
||||
const Checkbox = React.forwardRef<
|
||||
React.ElementRef<typeof CheckboxPrimitive.Root>,
|
||||
@@ -13,18 +13,16 @@ const Checkbox = React.forwardRef<
|
||||
<CheckboxPrimitive.Root
|
||||
ref={ref}
|
||||
className={cn(
|
||||
"grid place-content-center peer h-4 w-4 shrink-0 rounded-sm border border-primary shadow focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground",
|
||||
className
|
||||
'grid place-content-center peer h-4 w-4 shrink-0 rounded-sm border border-primary shadow focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground',
|
||||
className,
|
||||
)}
|
||||
{...props}
|
||||
>
|
||||
<CheckboxPrimitive.Indicator
|
||||
className={cn("grid place-content-center text-current")}
|
||||
>
|
||||
<CheckboxPrimitive.Indicator className={cn('grid place-content-center text-current')}>
|
||||
<Check className="h-4 w-4" />
|
||||
</CheckboxPrimitive.Indicator>
|
||||
</CheckboxPrimitive.Root>
|
||||
))
|
||||
Checkbox.displayName = CheckboxPrimitive.Root.displayName
|
||||
));
|
||||
Checkbox.displayName = CheckboxPrimitive.Root.displayName;
|
||||
|
||||
export { Checkbox }
|
||||
export { Checkbox };
|
||||
|
||||
@@ -1,44 +1,43 @@
|
||||
"use client"
|
||||
'use client';
|
||||
|
||||
import * as React from "react"
|
||||
import * as DropdownMenuPrimitive from "@radix-ui/react-dropdown-menu"
|
||||
import { Check, ChevronRight, Circle } from "lucide-react"
|
||||
import * as React from 'react';
|
||||
import * as DropdownMenuPrimitive from '@radix-ui/react-dropdown-menu';
|
||||
import { Check, ChevronRight, Circle } from 'lucide-react';
|
||||
|
||||
import { cn } from "@/lib/utils"
|
||||
import { cn } from '@/lib/utils';
|
||||
|
||||
const DropdownMenu = DropdownMenuPrimitive.Root
|
||||
const DropdownMenu = DropdownMenuPrimitive.Root;
|
||||
|
||||
const DropdownMenuTrigger = DropdownMenuPrimitive.Trigger
|
||||
const DropdownMenuTrigger = DropdownMenuPrimitive.Trigger;
|
||||
|
||||
const DropdownMenuGroup = DropdownMenuPrimitive.Group
|
||||
const DropdownMenuGroup = DropdownMenuPrimitive.Group;
|
||||
|
||||
const DropdownMenuPortal = DropdownMenuPrimitive.Portal
|
||||
const DropdownMenuPortal = DropdownMenuPrimitive.Portal;
|
||||
|
||||
const DropdownMenuSub = DropdownMenuPrimitive.Sub
|
||||
const DropdownMenuSub = DropdownMenuPrimitive.Sub;
|
||||
|
||||
const DropdownMenuRadioGroup = DropdownMenuPrimitive.RadioGroup
|
||||
const DropdownMenuRadioGroup = DropdownMenuPrimitive.RadioGroup;
|
||||
|
||||
const DropdownMenuSubTrigger = React.forwardRef<
|
||||
React.ElementRef<typeof DropdownMenuPrimitive.SubTrigger>,
|
||||
React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.SubTrigger> & {
|
||||
inset?: boolean
|
||||
inset?: boolean;
|
||||
}
|
||||
>(({ className, inset, children, ...props }, ref) => (
|
||||
<DropdownMenuPrimitive.SubTrigger
|
||||
ref={ref}
|
||||
className={cn(
|
||||
"flex cursor-default select-none items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent data-[state=open]:bg-accent [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",
|
||||
inset && "pl-8",
|
||||
className
|
||||
'flex cursor-default select-none items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent data-[state=open]:bg-accent [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0',
|
||||
inset && 'pl-8',
|
||||
className,
|
||||
)}
|
||||
{...props}
|
||||
>
|
||||
{children}
|
||||
<ChevronRight className="ml-auto" />
|
||||
</DropdownMenuPrimitive.SubTrigger>
|
||||
))
|
||||
DropdownMenuSubTrigger.displayName =
|
||||
DropdownMenuPrimitive.SubTrigger.displayName
|
||||
));
|
||||
DropdownMenuSubTrigger.displayName = DropdownMenuPrimitive.SubTrigger.displayName;
|
||||
|
||||
const DropdownMenuSubContent = React.forwardRef<
|
||||
React.ElementRef<typeof DropdownMenuPrimitive.SubContent>,
|
||||
@@ -47,14 +46,13 @@ const DropdownMenuSubContent = React.forwardRef<
|
||||
<DropdownMenuPrimitive.SubContent
|
||||
ref={ref}
|
||||
className={cn(
|
||||
"z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 origin-[--radix-dropdown-menu-content-transform-origin]",
|
||||
className
|
||||
'z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 origin-[--radix-dropdown-menu-content-transform-origin]',
|
||||
className,
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
))
|
||||
DropdownMenuSubContent.displayName =
|
||||
DropdownMenuPrimitive.SubContent.displayName
|
||||
));
|
||||
DropdownMenuSubContent.displayName = DropdownMenuPrimitive.SubContent.displayName;
|
||||
|
||||
const DropdownMenuContent = React.forwardRef<
|
||||
React.ElementRef<typeof DropdownMenuPrimitive.Content>,
|
||||
@@ -65,33 +63,33 @@ const DropdownMenuContent = React.forwardRef<
|
||||
ref={ref}
|
||||
sideOffset={sideOffset}
|
||||
className={cn(
|
||||
"z-50 max-h-[var(--radix-dropdown-menu-content-available-height)] min-w-[8rem] overflow-y-auto overflow-x-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md",
|
||||
"data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 origin-[--radix-dropdown-menu-content-transform-origin]",
|
||||
className
|
||||
'z-50 max-h-[var(--radix-dropdown-menu-content-available-height)] min-w-[8rem] overflow-y-auto overflow-x-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md',
|
||||
'data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 origin-[--radix-dropdown-menu-content-transform-origin]',
|
||||
className,
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
</DropdownMenuPrimitive.Portal>
|
||||
))
|
||||
DropdownMenuContent.displayName = DropdownMenuPrimitive.Content.displayName
|
||||
));
|
||||
DropdownMenuContent.displayName = DropdownMenuPrimitive.Content.displayName;
|
||||
|
||||
const DropdownMenuItem = React.forwardRef<
|
||||
React.ElementRef<typeof DropdownMenuPrimitive.Item>,
|
||||
React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Item> & {
|
||||
inset?: boolean
|
||||
inset?: boolean;
|
||||
}
|
||||
>(({ className, inset, ...props }, ref) => (
|
||||
<DropdownMenuPrimitive.Item
|
||||
ref={ref}
|
||||
className={cn(
|
||||
"relative flex cursor-default select-none items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&>svg]:size-4 [&>svg]:shrink-0",
|
||||
inset && "pl-8",
|
||||
className
|
||||
'relative flex cursor-default select-none items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&>svg]:size-4 [&>svg]:shrink-0',
|
||||
inset && 'pl-8',
|
||||
className,
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
))
|
||||
DropdownMenuItem.displayName = DropdownMenuPrimitive.Item.displayName
|
||||
));
|
||||
DropdownMenuItem.displayName = DropdownMenuPrimitive.Item.displayName;
|
||||
|
||||
const DropdownMenuCheckboxItem = React.forwardRef<
|
||||
React.ElementRef<typeof DropdownMenuPrimitive.CheckboxItem>,
|
||||
@@ -100,8 +98,8 @@ const DropdownMenuCheckboxItem = React.forwardRef<
|
||||
<DropdownMenuPrimitive.CheckboxItem
|
||||
ref={ref}
|
||||
className={cn(
|
||||
"relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
|
||||
className
|
||||
'relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50',
|
||||
className,
|
||||
)}
|
||||
checked={checked}
|
||||
{...props}
|
||||
@@ -113,9 +111,8 @@ const DropdownMenuCheckboxItem = React.forwardRef<
|
||||
</span>
|
||||
{children}
|
||||
</DropdownMenuPrimitive.CheckboxItem>
|
||||
))
|
||||
DropdownMenuCheckboxItem.displayName =
|
||||
DropdownMenuPrimitive.CheckboxItem.displayName
|
||||
));
|
||||
DropdownMenuCheckboxItem.displayName = DropdownMenuPrimitive.CheckboxItem.displayName;
|
||||
|
||||
const DropdownMenuRadioItem = React.forwardRef<
|
||||
React.ElementRef<typeof DropdownMenuPrimitive.RadioItem>,
|
||||
@@ -124,8 +121,8 @@ const DropdownMenuRadioItem = React.forwardRef<
|
||||
<DropdownMenuPrimitive.RadioItem
|
||||
ref={ref}
|
||||
className={cn(
|
||||
"relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
|
||||
className
|
||||
'relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50',
|
||||
className,
|
||||
)}
|
||||
{...props}
|
||||
>
|
||||
@@ -136,26 +133,22 @@ const DropdownMenuRadioItem = React.forwardRef<
|
||||
</span>
|
||||
{children}
|
||||
</DropdownMenuPrimitive.RadioItem>
|
||||
))
|
||||
DropdownMenuRadioItem.displayName = DropdownMenuPrimitive.RadioItem.displayName
|
||||
));
|
||||
DropdownMenuRadioItem.displayName = DropdownMenuPrimitive.RadioItem.displayName;
|
||||
|
||||
const DropdownMenuLabel = React.forwardRef<
|
||||
React.ElementRef<typeof DropdownMenuPrimitive.Label>,
|
||||
React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Label> & {
|
||||
inset?: boolean
|
||||
inset?: boolean;
|
||||
}
|
||||
>(({ className, inset, ...props }, ref) => (
|
||||
<DropdownMenuPrimitive.Label
|
||||
ref={ref}
|
||||
className={cn(
|
||||
"px-2 py-1.5 text-sm font-semibold",
|
||||
inset && "pl-8",
|
||||
className
|
||||
)}
|
||||
className={cn('px-2 py-1.5 text-sm font-semibold', inset && 'pl-8', className)}
|
||||
{...props}
|
||||
/>
|
||||
))
|
||||
DropdownMenuLabel.displayName = DropdownMenuPrimitive.Label.displayName
|
||||
));
|
||||
DropdownMenuLabel.displayName = DropdownMenuPrimitive.Label.displayName;
|
||||
|
||||
const DropdownMenuSeparator = React.forwardRef<
|
||||
React.ElementRef<typeof DropdownMenuPrimitive.Separator>,
|
||||
@@ -163,24 +156,18 @@ const DropdownMenuSeparator = React.forwardRef<
|
||||
>(({ className, ...props }, ref) => (
|
||||
<DropdownMenuPrimitive.Separator
|
||||
ref={ref}
|
||||
className={cn("-mx-1 my-1 h-px bg-muted", className)}
|
||||
className={cn('-mx-1 my-1 h-px bg-muted', className)}
|
||||
{...props}
|
||||
/>
|
||||
))
|
||||
DropdownMenuSeparator.displayName = DropdownMenuPrimitive.Separator.displayName
|
||||
));
|
||||
DropdownMenuSeparator.displayName = DropdownMenuPrimitive.Separator.displayName;
|
||||
|
||||
const DropdownMenuShortcut = ({
|
||||
className,
|
||||
...props
|
||||
}: React.HTMLAttributes<HTMLSpanElement>) => {
|
||||
const DropdownMenuShortcut = ({ className, ...props }: React.HTMLAttributes<HTMLSpanElement>) => {
|
||||
return (
|
||||
<span
|
||||
className={cn("ml-auto text-xs tracking-widest opacity-60", className)}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
}
|
||||
DropdownMenuShortcut.displayName = "DropdownMenuShortcut"
|
||||
<span className={cn('ml-auto text-xs tracking-widest opacity-60', className)} {...props} />
|
||||
);
|
||||
};
|
||||
DropdownMenuShortcut.displayName = 'DropdownMenuShortcut';
|
||||
|
||||
export {
|
||||
DropdownMenu,
|
||||
@@ -198,4 +185,4 @@ export {
|
||||
DropdownMenuSubContent,
|
||||
DropdownMenuSubTrigger,
|
||||
DropdownMenuRadioGroup,
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
"use client"
|
||||
'use client';
|
||||
|
||||
import * as React from "react"
|
||||
import * as LabelPrimitive from "@radix-ui/react-label"
|
||||
import { Slot } from "@radix-ui/react-slot"
|
||||
import * as React from 'react';
|
||||
import * as LabelPrimitive from '@radix-ui/react-label';
|
||||
import { Slot } from '@radix-ui/react-slot';
|
||||
import {
|
||||
Controller,
|
||||
FormProvider,
|
||||
@@ -10,25 +10,25 @@ import {
|
||||
type ControllerProps,
|
||||
type FieldPath,
|
||||
type FieldValues,
|
||||
} from "react-hook-form"
|
||||
} from 'react-hook-form';
|
||||
|
||||
import { cn } from "@/lib/utils"
|
||||
import { Label } from "@/components/ui/label"
|
||||
import { cn } from '@/lib/utils';
|
||||
import { Label } from '@/components/ui/label';
|
||||
|
||||
const Form = FormProvider
|
||||
const Form = FormProvider;
|
||||
|
||||
type FormFieldContextValue<
|
||||
TFieldValues extends FieldValues = FieldValues,
|
||||
TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>
|
||||
TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>,
|
||||
> = {
|
||||
name: TName
|
||||
}
|
||||
name: TName;
|
||||
};
|
||||
|
||||
const FormFieldContext = React.createContext<FormFieldContextValue | null>(null)
|
||||
const FormFieldContext = React.createContext<FormFieldContextValue | null>(null);
|
||||
|
||||
const FormField = <
|
||||
TFieldValues extends FieldValues = FieldValues,
|
||||
TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>
|
||||
TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>,
|
||||
>({
|
||||
...props
|
||||
}: ControllerProps<TFieldValues, TName>) => {
|
||||
@@ -36,25 +36,25 @@ const FormField = <
|
||||
<FormFieldContext.Provider value={{ name: props.name }}>
|
||||
<Controller {...props} />
|
||||
</FormFieldContext.Provider>
|
||||
)
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
const useFormField = () => {
|
||||
const fieldContext = React.useContext(FormFieldContext)
|
||||
const itemContext = React.useContext(FormItemContext)
|
||||
const { getFieldState, formState } = useFormContext()
|
||||
const fieldContext = React.useContext(FormFieldContext);
|
||||
const itemContext = React.useContext(FormItemContext);
|
||||
const { getFieldState, formState } = useFormContext();
|
||||
|
||||
if (!fieldContext) {
|
||||
throw new Error("useFormField should be used within <FormField>")
|
||||
throw new Error('useFormField should be used within <FormField>');
|
||||
}
|
||||
|
||||
if (!itemContext) {
|
||||
throw new Error("useFormField should be used within <FormItem>")
|
||||
throw new Error('useFormField should be used within <FormItem>');
|
||||
}
|
||||
|
||||
const fieldState = getFieldState(fieldContext.name, formState)
|
||||
const fieldState = getFieldState(fieldContext.name, formState);
|
||||
|
||||
const { id } = itemContext
|
||||
const { id } = itemContext;
|
||||
|
||||
return {
|
||||
id,
|
||||
@@ -63,108 +63,103 @@ const useFormField = () => {
|
||||
formDescriptionId: `${id}-form-item-description`,
|
||||
formMessageId: `${id}-form-item-message`,
|
||||
...fieldState,
|
||||
}
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
type FormItemContextValue = {
|
||||
id: string
|
||||
}
|
||||
id: string;
|
||||
};
|
||||
|
||||
const FormItemContext = React.createContext<FormItemContextValue | null>(null)
|
||||
const FormItemContext = React.createContext<FormItemContextValue | null>(null);
|
||||
|
||||
const FormItem = React.forwardRef<
|
||||
HTMLDivElement,
|
||||
React.HTMLAttributes<HTMLDivElement>
|
||||
>(({ className, ...props }, ref) => {
|
||||
const id = React.useId()
|
||||
const FormItem = React.forwardRef<HTMLDivElement, React.HTMLAttributes<HTMLDivElement>>(
|
||||
({ className, ...props }, ref) => {
|
||||
const id = React.useId();
|
||||
|
||||
return (
|
||||
<FormItemContext.Provider value={{ id }}>
|
||||
<div ref={ref} className={cn("space-y-2", className)} {...props} />
|
||||
</FormItemContext.Provider>
|
||||
)
|
||||
})
|
||||
FormItem.displayName = "FormItem"
|
||||
return (
|
||||
<FormItemContext.Provider value={{ id }}>
|
||||
<div ref={ref} className={cn('space-y-2', className)} {...props} />
|
||||
</FormItemContext.Provider>
|
||||
);
|
||||
},
|
||||
);
|
||||
FormItem.displayName = 'FormItem';
|
||||
|
||||
const FormLabel = React.forwardRef<
|
||||
React.ElementRef<typeof LabelPrimitive.Root>,
|
||||
React.ComponentPropsWithoutRef<typeof LabelPrimitive.Root>
|
||||
>(({ className, ...props }, ref) => {
|
||||
const { error, formItemId } = useFormField()
|
||||
const { error, formItemId } = useFormField();
|
||||
|
||||
return (
|
||||
<Label
|
||||
ref={ref}
|
||||
className={cn(error && "text-destructive", className)}
|
||||
className={cn(error && 'text-destructive', className)}
|
||||
htmlFor={formItemId}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
})
|
||||
FormLabel.displayName = "FormLabel"
|
||||
);
|
||||
});
|
||||
FormLabel.displayName = 'FormLabel';
|
||||
|
||||
const FormControl = React.forwardRef<
|
||||
React.ElementRef<typeof Slot>,
|
||||
React.ComponentPropsWithoutRef<typeof Slot>
|
||||
>(({ ...props }, ref) => {
|
||||
const { error, formItemId, formDescriptionId, formMessageId } = useFormField()
|
||||
const { error, formItemId, formDescriptionId, formMessageId } = useFormField();
|
||||
|
||||
return (
|
||||
<Slot
|
||||
ref={ref}
|
||||
id={formItemId}
|
||||
aria-describedby={
|
||||
!error
|
||||
? `${formDescriptionId}`
|
||||
: `${formDescriptionId} ${formMessageId}`
|
||||
}
|
||||
aria-describedby={!error ? `${formDescriptionId}` : `${formDescriptionId} ${formMessageId}`}
|
||||
aria-invalid={!!error}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
})
|
||||
FormControl.displayName = "FormControl"
|
||||
);
|
||||
});
|
||||
FormControl.displayName = 'FormControl';
|
||||
|
||||
const FormDescription = React.forwardRef<
|
||||
HTMLParagraphElement,
|
||||
React.HTMLAttributes<HTMLParagraphElement>
|
||||
>(({ className, ...props }, ref) => {
|
||||
const { formDescriptionId } = useFormField()
|
||||
const { formDescriptionId } = useFormField();
|
||||
|
||||
return (
|
||||
<p
|
||||
ref={ref}
|
||||
id={formDescriptionId}
|
||||
className={cn("text-[0.8rem] text-muted-foreground", className)}
|
||||
className={cn('text-[0.8rem] text-muted-foreground', className)}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
})
|
||||
FormDescription.displayName = "FormDescription"
|
||||
);
|
||||
});
|
||||
FormDescription.displayName = 'FormDescription';
|
||||
|
||||
const FormMessage = React.forwardRef<
|
||||
HTMLParagraphElement,
|
||||
React.HTMLAttributes<HTMLParagraphElement>
|
||||
>(({ className, children, ...props }, ref) => {
|
||||
const { error, formMessageId } = useFormField()
|
||||
const body = error ? String(error?.message ?? "") : children
|
||||
const { error, formMessageId } = useFormField();
|
||||
const body = error ? String(error?.message ?? '') : children;
|
||||
|
||||
if (!body) {
|
||||
return null
|
||||
return null;
|
||||
}
|
||||
|
||||
return (
|
||||
<p
|
||||
ref={ref}
|
||||
id={formMessageId}
|
||||
className={cn("text-[0.8rem] font-medium text-destructive", className)}
|
||||
className={cn('text-[0.8rem] font-medium text-destructive', className)}
|
||||
{...props}
|
||||
>
|
||||
{body}
|
||||
</p>
|
||||
)
|
||||
})
|
||||
FormMessage.displayName = "FormMessage"
|
||||
);
|
||||
});
|
||||
FormMessage.displayName = 'FormMessage';
|
||||
|
||||
export {
|
||||
useFormField,
|
||||
@@ -175,4 +170,4 @@ export {
|
||||
FormDescription,
|
||||
FormMessage,
|
||||
FormField,
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1,26 +1,21 @@
|
||||
"use client"
|
||||
'use client';
|
||||
|
||||
import * as React from "react"
|
||||
import * as LabelPrimitive from "@radix-ui/react-label"
|
||||
import { cva, type VariantProps } from "class-variance-authority"
|
||||
import * as React from 'react';
|
||||
import * as LabelPrimitive from '@radix-ui/react-label';
|
||||
import { cva, type VariantProps } from 'class-variance-authority';
|
||||
|
||||
import { cn } from "@/lib/utils"
|
||||
import { cn } from '@/lib/utils';
|
||||
|
||||
const labelVariants = cva(
|
||||
"text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"
|
||||
)
|
||||
'text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70',
|
||||
);
|
||||
|
||||
const Label = React.forwardRef<
|
||||
React.ElementRef<typeof LabelPrimitive.Root>,
|
||||
React.ComponentPropsWithoutRef<typeof LabelPrimitive.Root> &
|
||||
VariantProps<typeof labelVariants>
|
||||
React.ComponentPropsWithoutRef<typeof LabelPrimitive.Root> & VariantProps<typeof labelVariants>
|
||||
>(({ className, ...props }, ref) => (
|
||||
<LabelPrimitive.Root
|
||||
ref={ref}
|
||||
className={cn(labelVariants(), className)}
|
||||
{...props}
|
||||
/>
|
||||
))
|
||||
Label.displayName = LabelPrimitive.Root.displayName
|
||||
<LabelPrimitive.Root ref={ref} className={cn(labelVariants(), className)} {...props} />
|
||||
));
|
||||
Label.displayName = LabelPrimitive.Root.displayName;
|
||||
|
||||
export { Label }
|
||||
export { Label };
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import * as React from "react"
|
||||
import * as NavigationMenuPrimitive from "@radix-ui/react-navigation-menu"
|
||||
import { cva } from "class-variance-authority"
|
||||
import { ChevronDown } from "lucide-react"
|
||||
import * as React from 'react';
|
||||
import * as NavigationMenuPrimitive from '@radix-ui/react-navigation-menu';
|
||||
import { cva } from 'class-variance-authority';
|
||||
import { ChevronDown } from 'lucide-react';
|
||||
|
||||
import { cn } from "@/lib/utils"
|
||||
import { cn } from '@/lib/utils';
|
||||
|
||||
const NavigationMenu = React.forwardRef<
|
||||
React.ElementRef<typeof NavigationMenuPrimitive.Root>,
|
||||
@@ -11,17 +11,14 @@ const NavigationMenu = React.forwardRef<
|
||||
>(({ className, children, ...props }, ref) => (
|
||||
<NavigationMenuPrimitive.Root
|
||||
ref={ref}
|
||||
className={cn(
|
||||
"relative z-10 flex max-w-max flex-1 items-center justify-center",
|
||||
className
|
||||
)}
|
||||
className={cn('relative z-10 flex max-w-max flex-1 items-center justify-center', className)}
|
||||
{...props}
|
||||
>
|
||||
{children}
|
||||
<NavigationMenuViewport />
|
||||
</NavigationMenuPrimitive.Root>
|
||||
))
|
||||
NavigationMenu.displayName = NavigationMenuPrimitive.Root.displayName
|
||||
));
|
||||
NavigationMenu.displayName = NavigationMenuPrimitive.Root.displayName;
|
||||
|
||||
const NavigationMenuList = React.forwardRef<
|
||||
React.ElementRef<typeof NavigationMenuPrimitive.List>,
|
||||
@@ -29,20 +26,17 @@ const NavigationMenuList = React.forwardRef<
|
||||
>(({ className, ...props }, ref) => (
|
||||
<NavigationMenuPrimitive.List
|
||||
ref={ref}
|
||||
className={cn(
|
||||
"group flex flex-1 list-none items-center justify-center space-x-1",
|
||||
className
|
||||
)}
|
||||
className={cn('group flex flex-1 list-none items-center justify-center space-x-1', className)}
|
||||
{...props}
|
||||
/>
|
||||
))
|
||||
NavigationMenuList.displayName = NavigationMenuPrimitive.List.displayName
|
||||
));
|
||||
NavigationMenuList.displayName = NavigationMenuPrimitive.List.displayName;
|
||||
|
||||
const NavigationMenuItem = NavigationMenuPrimitive.Item
|
||||
const NavigationMenuItem = NavigationMenuPrimitive.Item;
|
||||
|
||||
const navigationMenuTriggerStyle = cva(
|
||||
"group inline-flex h-9 w-max items-center justify-center rounded-md bg-background px-4 py-2 text-sm font-medium transition-colors hover:bg-accent hover:text-accent-foreground focus:bg-accent focus:text-accent-foreground focus:outline-none disabled:pointer-events-none disabled:opacity-50 data-[state=open]:text-accent-foreground data-[state=open]:bg-accent/50 data-[state=open]:hover:bg-accent data-[state=open]:focus:bg-accent"
|
||||
)
|
||||
'group inline-flex h-9 w-max items-center justify-center rounded-md bg-background px-4 py-2 text-sm font-medium transition-colors hover:bg-accent hover:text-accent-foreground focus:bg-accent focus:text-accent-foreground focus:outline-none disabled:pointer-events-none disabled:opacity-50 data-[state=open]:text-accent-foreground data-[state=open]:bg-accent/50 data-[state=open]:hover:bg-accent data-[state=open]:focus:bg-accent',
|
||||
);
|
||||
|
||||
const NavigationMenuTrigger = React.forwardRef<
|
||||
React.ElementRef<typeof NavigationMenuPrimitive.Trigger>,
|
||||
@@ -50,17 +44,17 @@ const NavigationMenuTrigger = React.forwardRef<
|
||||
>(({ className, children, ...props }, ref) => (
|
||||
<NavigationMenuPrimitive.Trigger
|
||||
ref={ref}
|
||||
className={cn(navigationMenuTriggerStyle(), "group", className)}
|
||||
className={cn(navigationMenuTriggerStyle(), 'group', className)}
|
||||
{...props}
|
||||
>
|
||||
{children}{" "}
|
||||
{children}{' '}
|
||||
<ChevronDown
|
||||
className="relative top-[1px] ml-1 h-3 w-3 transition duration-300 group-data-[state=open]:rotate-180"
|
||||
aria-hidden="true"
|
||||
/>
|
||||
</NavigationMenuPrimitive.Trigger>
|
||||
))
|
||||
NavigationMenuTrigger.displayName = NavigationMenuPrimitive.Trigger.displayName
|
||||
));
|
||||
NavigationMenuTrigger.displayName = NavigationMenuPrimitive.Trigger.displayName;
|
||||
|
||||
const NavigationMenuContent = React.forwardRef<
|
||||
React.ElementRef<typeof NavigationMenuPrimitive.Content>,
|
||||
@@ -69,33 +63,32 @@ const NavigationMenuContent = React.forwardRef<
|
||||
<NavigationMenuPrimitive.Content
|
||||
ref={ref}
|
||||
className={cn(
|
||||
"left-0 top-0 w-full data-[motion^=from-]:animate-in data-[motion^=to-]:animate-out data-[motion^=from-]:fade-in data-[motion^=to-]:fade-out data-[motion=from-end]:slide-in-from-right-52 data-[motion=from-start]:slide-in-from-left-52 data-[motion=to-end]:slide-out-to-right-52 data-[motion=to-start]:slide-out-to-left-52 md:absolute md:w-auto ",
|
||||
className
|
||||
'left-0 top-0 w-full data-[motion^=from-]:animate-in data-[motion^=to-]:animate-out data-[motion^=from-]:fade-in data-[motion^=to-]:fade-out data-[motion=from-end]:slide-in-from-right-52 data-[motion=from-start]:slide-in-from-left-52 data-[motion=to-end]:slide-out-to-right-52 data-[motion=to-start]:slide-out-to-left-52 md:absolute md:w-auto ',
|
||||
className,
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
))
|
||||
NavigationMenuContent.displayName = NavigationMenuPrimitive.Content.displayName
|
||||
));
|
||||
NavigationMenuContent.displayName = NavigationMenuPrimitive.Content.displayName;
|
||||
|
||||
const NavigationMenuLink = NavigationMenuPrimitive.Link
|
||||
const NavigationMenuLink = NavigationMenuPrimitive.Link;
|
||||
|
||||
const NavigationMenuViewport = React.forwardRef<
|
||||
React.ElementRef<typeof NavigationMenuPrimitive.Viewport>,
|
||||
React.ComponentPropsWithoutRef<typeof NavigationMenuPrimitive.Viewport>
|
||||
>(({ className, ...props }, ref) => (
|
||||
<div className={cn("absolute left-0 top-full flex justify-center")}>
|
||||
<div className={cn('absolute left-0 top-full flex justify-center')}>
|
||||
<NavigationMenuPrimitive.Viewport
|
||||
className={cn(
|
||||
"origin-top-center relative mt-1.5 h-[var(--radix-navigation-menu-viewport-height)] w-full overflow-hidden rounded-md border bg-popover text-popover-foreground shadow data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-90 md:w-[var(--radix-navigation-menu-viewport-width)]",
|
||||
className
|
||||
'origin-top-center relative mt-1.5 h-[var(--radix-navigation-menu-viewport-height)] w-full overflow-hidden rounded-md border bg-popover text-popover-foreground shadow data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-90 md:w-[var(--radix-navigation-menu-viewport-width)]',
|
||||
className,
|
||||
)}
|
||||
ref={ref}
|
||||
{...props}
|
||||
/>
|
||||
</div>
|
||||
))
|
||||
NavigationMenuViewport.displayName =
|
||||
NavigationMenuPrimitive.Viewport.displayName
|
||||
));
|
||||
NavigationMenuViewport.displayName = NavigationMenuPrimitive.Viewport.displayName;
|
||||
|
||||
const NavigationMenuIndicator = React.forwardRef<
|
||||
React.ElementRef<typeof NavigationMenuPrimitive.Indicator>,
|
||||
@@ -104,16 +97,15 @@ const NavigationMenuIndicator = React.forwardRef<
|
||||
<NavigationMenuPrimitive.Indicator
|
||||
ref={ref}
|
||||
className={cn(
|
||||
"top-full z-[1] flex h-1.5 items-end justify-center overflow-hidden data-[state=visible]:animate-in data-[state=hidden]:animate-out data-[state=hidden]:fade-out data-[state=visible]:fade-in",
|
||||
className
|
||||
'top-full z-[1] flex h-1.5 items-end justify-center overflow-hidden data-[state=visible]:animate-in data-[state=hidden]:animate-out data-[state=hidden]:fade-out data-[state=visible]:fade-in',
|
||||
className,
|
||||
)}
|
||||
{...props}
|
||||
>
|
||||
<div className="relative top-[60%] h-2 w-2 rotate-45 rounded-tl-sm bg-border shadow-md" />
|
||||
</NavigationMenuPrimitive.Indicator>
|
||||
))
|
||||
NavigationMenuIndicator.displayName =
|
||||
NavigationMenuPrimitive.Indicator.displayName
|
||||
));
|
||||
NavigationMenuIndicator.displayName = NavigationMenuPrimitive.Indicator.displayName;
|
||||
|
||||
export {
|
||||
navigationMenuTriggerStyle,
|
||||
@@ -125,4 +117,4 @@ export {
|
||||
NavigationMenuLink,
|
||||
NavigationMenuIndicator,
|
||||
NavigationMenuViewport,
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1,63 +1,50 @@
|
||||
import * as React from "react"
|
||||
import { ChevronLeft, ChevronRight, MoreHorizontal } from "lucide-react"
|
||||
import * as React from 'react';
|
||||
import { ChevronLeft, ChevronRight, MoreHorizontal } from 'lucide-react';
|
||||
|
||||
import { cn } from "@/lib/utils"
|
||||
import { ButtonProps, buttonVariants } from "@/components/ui/button"
|
||||
import { cn } from '@/lib/utils';
|
||||
import { ButtonProps, buttonVariants } from '@/components/ui/button';
|
||||
|
||||
const Pagination = ({ className, ...props }: React.ComponentProps<"nav">) => (
|
||||
const Pagination = ({ className, ...props }: React.ComponentProps<'nav'>) => (
|
||||
<nav
|
||||
role="navigation"
|
||||
aria-label="pagination"
|
||||
className={cn("mx-auto flex w-full justify-center", className)}
|
||||
className={cn('mx-auto flex w-full justify-center', className)}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
Pagination.displayName = "Pagination"
|
||||
);
|
||||
Pagination.displayName = 'Pagination';
|
||||
|
||||
const PaginationContent = React.forwardRef<
|
||||
HTMLUListElement,
|
||||
React.ComponentProps<"ul">
|
||||
>(({ className, ...props }, ref) => (
|
||||
<ul
|
||||
ref={ref}
|
||||
className={cn("flex flex-row items-center gap-1", className)}
|
||||
{...props}
|
||||
/>
|
||||
))
|
||||
PaginationContent.displayName = "PaginationContent"
|
||||
const PaginationContent = React.forwardRef<HTMLUListElement, React.ComponentProps<'ul'>>(
|
||||
({ className, ...props }, ref) => (
|
||||
<ul ref={ref} className={cn('flex flex-row items-center gap-1', className)} {...props} />
|
||||
),
|
||||
);
|
||||
PaginationContent.displayName = 'PaginationContent';
|
||||
|
||||
const PaginationItem = React.forwardRef<
|
||||
HTMLLIElement,
|
||||
React.ComponentProps<"li">
|
||||
>(({ className, ...props }, ref) => (
|
||||
<li ref={ref} className={cn("", className)} {...props} />
|
||||
))
|
||||
PaginationItem.displayName = "PaginationItem"
|
||||
const PaginationItem = React.forwardRef<HTMLLIElement, React.ComponentProps<'li'>>(
|
||||
({ className, ...props }, ref) => <li ref={ref} className={cn('', className)} {...props} />,
|
||||
);
|
||||
PaginationItem.displayName = 'PaginationItem';
|
||||
|
||||
type PaginationLinkProps = {
|
||||
isActive?: boolean
|
||||
} & Pick<ButtonProps, "size"> &
|
||||
React.ComponentProps<"a">
|
||||
isActive?: boolean;
|
||||
} & Pick<ButtonProps, 'size'> &
|
||||
React.ComponentProps<'a'>;
|
||||
|
||||
const PaginationLink = ({
|
||||
className,
|
||||
isActive,
|
||||
size = "icon",
|
||||
...props
|
||||
}: PaginationLinkProps) => (
|
||||
const PaginationLink = ({ className, isActive, size = 'icon', ...props }: PaginationLinkProps) => (
|
||||
<a
|
||||
aria-current={isActive ? "page" : undefined}
|
||||
aria-current={isActive ? 'page' : undefined}
|
||||
className={cn(
|
||||
buttonVariants({
|
||||
variant: isActive ? "outline" : "ghost",
|
||||
variant: isActive ? 'outline' : 'ghost',
|
||||
size,
|
||||
}),
|
||||
className
|
||||
className,
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
PaginationLink.displayName = "PaginationLink"
|
||||
);
|
||||
PaginationLink.displayName = 'PaginationLink';
|
||||
|
||||
const PaginationPrevious = ({
|
||||
className,
|
||||
@@ -66,45 +53,39 @@ const PaginationPrevious = ({
|
||||
<PaginationLink
|
||||
aria-label="Go to previous page"
|
||||
size="default"
|
||||
className={cn("gap-1 pl-2.5", className)}
|
||||
className={cn('gap-1 pl-2.5', className)}
|
||||
{...props}
|
||||
>
|
||||
<ChevronLeft className="h-4 w-4" />
|
||||
<span>Previous</span>
|
||||
</PaginationLink>
|
||||
)
|
||||
PaginationPrevious.displayName = "PaginationPrevious"
|
||||
);
|
||||
PaginationPrevious.displayName = 'PaginationPrevious';
|
||||
|
||||
const PaginationNext = ({
|
||||
className,
|
||||
...props
|
||||
}: React.ComponentProps<typeof PaginationLink>) => (
|
||||
const PaginationNext = ({ className, ...props }: React.ComponentProps<typeof PaginationLink>) => (
|
||||
<PaginationLink
|
||||
aria-label="Go to next page"
|
||||
size="default"
|
||||
className={cn("gap-1 pr-2.5", className)}
|
||||
className={cn('gap-1 pr-2.5', className)}
|
||||
{...props}
|
||||
>
|
||||
<span>Next</span>
|
||||
<ChevronRight className="h-4 w-4" />
|
||||
</PaginationLink>
|
||||
)
|
||||
PaginationNext.displayName = "PaginationNext"
|
||||
);
|
||||
PaginationNext.displayName = 'PaginationNext';
|
||||
|
||||
const PaginationEllipsis = ({
|
||||
className,
|
||||
...props
|
||||
}: React.ComponentProps<"span">) => (
|
||||
const PaginationEllipsis = ({ className, ...props }: React.ComponentProps<'span'>) => (
|
||||
<span
|
||||
aria-hidden
|
||||
className={cn("flex h-9 w-9 items-center justify-center", className)}
|
||||
className={cn('flex h-9 w-9 items-center justify-center', className)}
|
||||
{...props}
|
||||
>
|
||||
<MoreHorizontal className="h-4 w-4" />
|
||||
<span className="sr-only">More pages</span>
|
||||
</span>
|
||||
)
|
||||
PaginationEllipsis.displayName = "PaginationEllipsis"
|
||||
);
|
||||
PaginationEllipsis.displayName = 'PaginationEllipsis';
|
||||
|
||||
export {
|
||||
Pagination,
|
||||
@@ -114,4 +95,4 @@ export {
|
||||
PaginationPrevious,
|
||||
PaginationNext,
|
||||
PaginationEllipsis,
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
"use client"
|
||||
'use client';
|
||||
|
||||
import * as React from "react"
|
||||
import * as ProgressPrimitive from "@radix-ui/react-progress"
|
||||
import * as React from 'react';
|
||||
import * as ProgressPrimitive from '@radix-ui/react-progress';
|
||||
|
||||
import { cn } from "@/lib/utils"
|
||||
import { cn } from '@/lib/utils';
|
||||
|
||||
const Progress = React.forwardRef<
|
||||
React.ElementRef<typeof ProgressPrimitive.Root>,
|
||||
@@ -11,10 +11,7 @@ const Progress = React.forwardRef<
|
||||
>(({ className, value, ...props }, ref) => (
|
||||
<ProgressPrimitive.Root
|
||||
ref={ref}
|
||||
className={cn(
|
||||
"relative h-2 w-full overflow-hidden rounded-full bg-primary/20",
|
||||
className
|
||||
)}
|
||||
className={cn('relative h-2 w-full overflow-hidden rounded-full bg-primary/20', className)}
|
||||
{...props}
|
||||
>
|
||||
<ProgressPrimitive.Indicator
|
||||
@@ -22,7 +19,7 @@ const Progress = React.forwardRef<
|
||||
style={{ transform: `translateX(-${100 - (value || 0)}%)` }}
|
||||
/>
|
||||
</ProgressPrimitive.Root>
|
||||
))
|
||||
Progress.displayName = ProgressPrimitive.Root.displayName
|
||||
));
|
||||
Progress.displayName = ProgressPrimitive.Root.displayName;
|
||||
|
||||
export { Progress }
|
||||
export { Progress };
|
||||
|
||||
@@ -1,24 +1,18 @@
|
||||
"use client"
|
||||
'use client';
|
||||
|
||||
import * as React from "react"
|
||||
import * as RadioGroupPrimitive from "@radix-ui/react-radio-group"
|
||||
import { Circle } from "lucide-react"
|
||||
import * as React from 'react';
|
||||
import * as RadioGroupPrimitive from '@radix-ui/react-radio-group';
|
||||
import { Circle } from 'lucide-react';
|
||||
|
||||
import { cn } from "@/lib/utils"
|
||||
import { cn } from '@/lib/utils';
|
||||
|
||||
const RadioGroup = React.forwardRef<
|
||||
React.ElementRef<typeof RadioGroupPrimitive.Root>,
|
||||
React.ComponentPropsWithoutRef<typeof RadioGroupPrimitive.Root>
|
||||
>(({ className, ...props }, ref) => {
|
||||
return (
|
||||
<RadioGroupPrimitive.Root
|
||||
className={cn("grid gap-2", className)}
|
||||
{...props}
|
||||
ref={ref}
|
||||
/>
|
||||
)
|
||||
})
|
||||
RadioGroup.displayName = RadioGroupPrimitive.Root.displayName
|
||||
return <RadioGroupPrimitive.Root className={cn('grid gap-2', className)} {...props} ref={ref} />;
|
||||
});
|
||||
RadioGroup.displayName = RadioGroupPrimitive.Root.displayName;
|
||||
|
||||
const RadioGroupItem = React.forwardRef<
|
||||
React.ElementRef<typeof RadioGroupPrimitive.Item>,
|
||||
@@ -28,8 +22,8 @@ const RadioGroupItem = React.forwardRef<
|
||||
<RadioGroupPrimitive.Item
|
||||
ref={ref}
|
||||
className={cn(
|
||||
"aspect-square h-4 w-4 rounded-full border border-primary text-primary shadow focus:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50",
|
||||
className
|
||||
'aspect-square h-4 w-4 rounded-full border border-primary text-primary shadow focus:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50',
|
||||
className,
|
||||
)}
|
||||
{...props}
|
||||
>
|
||||
@@ -37,8 +31,8 @@ const RadioGroupItem = React.forwardRef<
|
||||
<Circle className="h-3.5 w-3.5 fill-primary" />
|
||||
</RadioGroupPrimitive.Indicator>
|
||||
</RadioGroupPrimitive.Item>
|
||||
)
|
||||
})
|
||||
RadioGroupItem.displayName = RadioGroupPrimitive.Item.displayName
|
||||
);
|
||||
});
|
||||
RadioGroupItem.displayName = RadioGroupPrimitive.Item.displayName;
|
||||
|
||||
export { RadioGroup, RadioGroupItem }
|
||||
export { RadioGroup, RadioGroupItem };
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
"use client"
|
||||
'use client';
|
||||
|
||||
import * as React from "react"
|
||||
import * as ScrollAreaPrimitive from "@radix-ui/react-scroll-area"
|
||||
import * as React from 'react';
|
||||
import * as ScrollAreaPrimitive from '@radix-ui/react-scroll-area';
|
||||
|
||||
import { cn } from "@/lib/utils"
|
||||
import { cn } from '@/lib/utils';
|
||||
|
||||
const ScrollArea = React.forwardRef<
|
||||
React.ElementRef<typeof ScrollAreaPrimitive.Root>,
|
||||
@@ -11,7 +11,7 @@ const ScrollArea = React.forwardRef<
|
||||
>(({ className, children, ...props }, ref) => (
|
||||
<ScrollAreaPrimitive.Root
|
||||
ref={ref}
|
||||
className={cn("relative overflow-hidden", className)}
|
||||
className={cn('relative overflow-hidden', className)}
|
||||
{...props}
|
||||
>
|
||||
<ScrollAreaPrimitive.Viewport className="h-full w-full rounded-[inherit]">
|
||||
@@ -20,29 +20,27 @@ const ScrollArea = React.forwardRef<
|
||||
<ScrollBar />
|
||||
<ScrollAreaPrimitive.Corner />
|
||||
</ScrollAreaPrimitive.Root>
|
||||
))
|
||||
ScrollArea.displayName = ScrollAreaPrimitive.Root.displayName
|
||||
));
|
||||
ScrollArea.displayName = ScrollAreaPrimitive.Root.displayName;
|
||||
|
||||
const ScrollBar = React.forwardRef<
|
||||
React.ElementRef<typeof ScrollAreaPrimitive.ScrollAreaScrollbar>,
|
||||
React.ComponentPropsWithoutRef<typeof ScrollAreaPrimitive.ScrollAreaScrollbar>
|
||||
>(({ className, orientation = "vertical", ...props }, ref) => (
|
||||
>(({ className, orientation = 'vertical', ...props }, ref) => (
|
||||
<ScrollAreaPrimitive.ScrollAreaScrollbar
|
||||
ref={ref}
|
||||
orientation={orientation}
|
||||
className={cn(
|
||||
"flex touch-none select-none transition-colors",
|
||||
orientation === "vertical" &&
|
||||
"h-full w-2.5 border-l border-l-transparent p-[1px]",
|
||||
orientation === "horizontal" &&
|
||||
"h-2.5 flex-col border-t border-t-transparent p-[1px]",
|
||||
className
|
||||
'flex touch-none select-none transition-colors',
|
||||
orientation === 'vertical' && 'h-full w-2.5 border-l border-l-transparent p-[1px]',
|
||||
orientation === 'horizontal' && 'h-2.5 flex-col border-t border-t-transparent p-[1px]',
|
||||
className,
|
||||
)}
|
||||
{...props}
|
||||
>
|
||||
<ScrollAreaPrimitive.ScrollAreaThumb className="relative flex-1 rounded-full bg-border" />
|
||||
</ScrollAreaPrimitive.ScrollAreaScrollbar>
|
||||
))
|
||||
ScrollBar.displayName = ScrollAreaPrimitive.ScrollAreaScrollbar.displayName
|
||||
));
|
||||
ScrollBar.displayName = ScrollAreaPrimitive.ScrollAreaScrollbar.displayName;
|
||||
|
||||
export { ScrollArea, ScrollBar }
|
||||
export { ScrollArea, ScrollBar };
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
"use client"
|
||||
'use client';
|
||||
|
||||
import * as React from "react"
|
||||
import * as SelectPrimitive from "@radix-ui/react-select"
|
||||
import { Check, ChevronDown, ChevronUp } from "lucide-react"
|
||||
import * as React from 'react';
|
||||
import * as SelectPrimitive from '@radix-ui/react-select';
|
||||
import { Check, ChevronDown, ChevronUp } from 'lucide-react';
|
||||
|
||||
import { cn } from "@/lib/utils"
|
||||
import { cn } from '@/lib/utils';
|
||||
|
||||
const Select = SelectPrimitive.Root
|
||||
const Select = SelectPrimitive.Root;
|
||||
|
||||
const SelectGroup = SelectPrimitive.Group
|
||||
const SelectGroup = SelectPrimitive.Group;
|
||||
|
||||
const SelectValue = SelectPrimitive.Value
|
||||
const SelectValue = SelectPrimitive.Value;
|
||||
|
||||
const SelectTrigger = React.forwardRef<
|
||||
React.ElementRef<typeof SelectPrimitive.Trigger>,
|
||||
@@ -19,8 +19,8 @@ const SelectTrigger = React.forwardRef<
|
||||
<SelectPrimitive.Trigger
|
||||
ref={ref}
|
||||
className={cn(
|
||||
"flex h-9 w-full items-center justify-between whitespace-nowrap rounded-md border border-input bg-transparent px-3 py-2 text-sm shadow-sm ring-offset-background data-[placeholder]:text-muted-foreground focus:outline-none focus:ring-1 focus:ring-ring disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",
|
||||
className
|
||||
'flex h-9 w-full items-center justify-between whitespace-nowrap rounded-md border border-input bg-transparent px-3 py-2 text-sm shadow-sm ring-offset-background data-[placeholder]:text-muted-foreground focus:outline-none focus:ring-1 focus:ring-ring disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1',
|
||||
className,
|
||||
)}
|
||||
{...props}
|
||||
>
|
||||
@@ -29,8 +29,8 @@ const SelectTrigger = React.forwardRef<
|
||||
<ChevronDown className="h-4 w-4 opacity-50" />
|
||||
</SelectPrimitive.Icon>
|
||||
</SelectPrimitive.Trigger>
|
||||
))
|
||||
SelectTrigger.displayName = SelectPrimitive.Trigger.displayName
|
||||
));
|
||||
SelectTrigger.displayName = SelectPrimitive.Trigger.displayName;
|
||||
|
||||
const SelectScrollUpButton = React.forwardRef<
|
||||
React.ElementRef<typeof SelectPrimitive.ScrollUpButton>,
|
||||
@@ -38,16 +38,13 @@ const SelectScrollUpButton = React.forwardRef<
|
||||
>(({ className, ...props }, ref) => (
|
||||
<SelectPrimitive.ScrollUpButton
|
||||
ref={ref}
|
||||
className={cn(
|
||||
"flex cursor-default items-center justify-center py-1",
|
||||
className
|
||||
)}
|
||||
className={cn('flex cursor-default items-center justify-center py-1', className)}
|
||||
{...props}
|
||||
>
|
||||
<ChevronUp className="h-4 w-4" />
|
||||
</SelectPrimitive.ScrollUpButton>
|
||||
))
|
||||
SelectScrollUpButton.displayName = SelectPrimitive.ScrollUpButton.displayName
|
||||
));
|
||||
SelectScrollUpButton.displayName = SelectPrimitive.ScrollUpButton.displayName;
|
||||
|
||||
const SelectScrollDownButton = React.forwardRef<
|
||||
React.ElementRef<typeof SelectPrimitive.ScrollDownButton>,
|
||||
@@ -55,30 +52,26 @@ const SelectScrollDownButton = React.forwardRef<
|
||||
>(({ className, ...props }, ref) => (
|
||||
<SelectPrimitive.ScrollDownButton
|
||||
ref={ref}
|
||||
className={cn(
|
||||
"flex cursor-default items-center justify-center py-1",
|
||||
className
|
||||
)}
|
||||
className={cn('flex cursor-default items-center justify-center py-1', className)}
|
||||
{...props}
|
||||
>
|
||||
<ChevronDown className="h-4 w-4" />
|
||||
</SelectPrimitive.ScrollDownButton>
|
||||
))
|
||||
SelectScrollDownButton.displayName =
|
||||
SelectPrimitive.ScrollDownButton.displayName
|
||||
));
|
||||
SelectScrollDownButton.displayName = SelectPrimitive.ScrollDownButton.displayName;
|
||||
|
||||
const SelectContent = React.forwardRef<
|
||||
React.ElementRef<typeof SelectPrimitive.Content>,
|
||||
React.ComponentPropsWithoutRef<typeof SelectPrimitive.Content>
|
||||
>(({ className, children, position = "popper", ...props }, ref) => (
|
||||
>(({ className, children, position = 'popper', ...props }, ref) => (
|
||||
<SelectPrimitive.Portal>
|
||||
<SelectPrimitive.Content
|
||||
ref={ref}
|
||||
className={cn(
|
||||
"relative z-50 max-h-[--radix-select-content-available-height] min-w-[8rem] overflow-y-auto overflow-x-hidden rounded-md border bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 origin-[--radix-select-content-transform-origin]",
|
||||
position === "popper" &&
|
||||
"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",
|
||||
className
|
||||
'relative z-50 max-h-[--radix-select-content-available-height] min-w-[8rem] overflow-y-auto overflow-x-hidden rounded-md border bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 origin-[--radix-select-content-transform-origin]',
|
||||
position === 'popper' &&
|
||||
'data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1',
|
||||
className,
|
||||
)}
|
||||
position={position}
|
||||
{...props}
|
||||
@@ -86,9 +79,9 @@ const SelectContent = React.forwardRef<
|
||||
<SelectScrollUpButton />
|
||||
<SelectPrimitive.Viewport
|
||||
className={cn(
|
||||
"p-1",
|
||||
position === "popper" &&
|
||||
"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"
|
||||
'p-1',
|
||||
position === 'popper' &&
|
||||
'h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]',
|
||||
)}
|
||||
>
|
||||
{children}
|
||||
@@ -96,8 +89,8 @@ const SelectContent = React.forwardRef<
|
||||
<SelectScrollDownButton />
|
||||
</SelectPrimitive.Content>
|
||||
</SelectPrimitive.Portal>
|
||||
))
|
||||
SelectContent.displayName = SelectPrimitive.Content.displayName
|
||||
));
|
||||
SelectContent.displayName = SelectPrimitive.Content.displayName;
|
||||
|
||||
const SelectLabel = React.forwardRef<
|
||||
React.ElementRef<typeof SelectPrimitive.Label>,
|
||||
@@ -105,11 +98,11 @@ const SelectLabel = React.forwardRef<
|
||||
>(({ className, ...props }, ref) => (
|
||||
<SelectPrimitive.Label
|
||||
ref={ref}
|
||||
className={cn("px-2 py-1.5 text-sm font-semibold", className)}
|
||||
className={cn('px-2 py-1.5 text-sm font-semibold', className)}
|
||||
{...props}
|
||||
/>
|
||||
))
|
||||
SelectLabel.displayName = SelectPrimitive.Label.displayName
|
||||
));
|
||||
SelectLabel.displayName = SelectPrimitive.Label.displayName;
|
||||
|
||||
const SelectItem = React.forwardRef<
|
||||
React.ElementRef<typeof SelectPrimitive.Item>,
|
||||
@@ -118,8 +111,8 @@ const SelectItem = React.forwardRef<
|
||||
<SelectPrimitive.Item
|
||||
ref={ref}
|
||||
className={cn(
|
||||
"relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-2 pr-8 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
|
||||
className
|
||||
'relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-2 pr-8 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50',
|
||||
className,
|
||||
)}
|
||||
{...props}
|
||||
>
|
||||
@@ -130,8 +123,8 @@ const SelectItem = React.forwardRef<
|
||||
</span>
|
||||
<SelectPrimitive.ItemText>{children}</SelectPrimitive.ItemText>
|
||||
</SelectPrimitive.Item>
|
||||
))
|
||||
SelectItem.displayName = SelectPrimitive.Item.displayName
|
||||
));
|
||||
SelectItem.displayName = SelectPrimitive.Item.displayName;
|
||||
|
||||
const SelectSeparator = React.forwardRef<
|
||||
React.ElementRef<typeof SelectPrimitive.Separator>,
|
||||
@@ -139,11 +132,11 @@ const SelectSeparator = React.forwardRef<
|
||||
>(({ className, ...props }, ref) => (
|
||||
<SelectPrimitive.Separator
|
||||
ref={ref}
|
||||
className={cn("-mx-1 my-1 h-px bg-muted", className)}
|
||||
className={cn('-mx-1 my-1 h-px bg-muted', className)}
|
||||
{...props}
|
||||
/>
|
||||
))
|
||||
SelectSeparator.displayName = SelectPrimitive.Separator.displayName
|
||||
));
|
||||
SelectSeparator.displayName = SelectPrimitive.Separator.displayName;
|
||||
|
||||
export {
|
||||
Select,
|
||||
@@ -156,4 +149,4 @@ export {
|
||||
SelectSeparator,
|
||||
SelectScrollUpButton,
|
||||
SelectScrollDownButton,
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1,31 +1,26 @@
|
||||
"use client"
|
||||
'use client';
|
||||
|
||||
import * as React from "react"
|
||||
import * as SeparatorPrimitive from "@radix-ui/react-separator"
|
||||
import * as React from 'react';
|
||||
import * as SeparatorPrimitive from '@radix-ui/react-separator';
|
||||
|
||||
import { cn } from "@/lib/utils"
|
||||
import { cn } from '@/lib/utils';
|
||||
|
||||
const Separator = React.forwardRef<
|
||||
React.ElementRef<typeof SeparatorPrimitive.Root>,
|
||||
React.ComponentPropsWithoutRef<typeof SeparatorPrimitive.Root>
|
||||
>(
|
||||
(
|
||||
{ className, orientation = "horizontal", decorative = true, ...props },
|
||||
ref
|
||||
) => (
|
||||
<SeparatorPrimitive.Root
|
||||
ref={ref}
|
||||
decorative={decorative}
|
||||
orientation={orientation}
|
||||
className={cn(
|
||||
"shrink-0 bg-border",
|
||||
orientation === "horizontal" ? "h-[1px] w-full" : "h-full w-[1px]",
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
)
|
||||
Separator.displayName = SeparatorPrimitive.Root.displayName
|
||||
>(({ className, orientation = 'horizontal', decorative = true, ...props }, ref) => (
|
||||
<SeparatorPrimitive.Root
|
||||
ref={ref}
|
||||
decorative={decorative}
|
||||
orientation={orientation}
|
||||
className={cn(
|
||||
'shrink-0 bg-border',
|
||||
orientation === 'horizontal' ? 'h-[1px] w-full' : 'h-full w-[1px]',
|
||||
className,
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
));
|
||||
Separator.displayName = SeparatorPrimitive.Root.displayName;
|
||||
|
||||
export { Separator }
|
||||
export { Separator };
|
||||
|
||||
@@ -1,19 +1,19 @@
|
||||
"use client"
|
||||
'use client';
|
||||
|
||||
import * as React from "react"
|
||||
import * as SheetPrimitive from "@radix-ui/react-dialog"
|
||||
import { cva, type VariantProps } from "class-variance-authority"
|
||||
import { X } from "lucide-react"
|
||||
import * as React from 'react';
|
||||
import * as SheetPrimitive from '@radix-ui/react-dialog';
|
||||
import { cva, type VariantProps } from 'class-variance-authority';
|
||||
import { X } from 'lucide-react';
|
||||
|
||||
import { cn } from "@/lib/utils"
|
||||
import { cn } from '@/lib/utils';
|
||||
|
||||
const Sheet = SheetPrimitive.Root
|
||||
const Sheet = SheetPrimitive.Root;
|
||||
|
||||
const SheetTrigger = SheetPrimitive.Trigger
|
||||
const SheetTrigger = SheetPrimitive.Trigger;
|
||||
|
||||
const SheetClose = SheetPrimitive.Close
|
||||
const SheetClose = SheetPrimitive.Close;
|
||||
|
||||
const SheetPortal = SheetPrimitive.Portal
|
||||
const SheetPortal = SheetPrimitive.Portal;
|
||||
|
||||
const SheetOverlay = React.forwardRef<
|
||||
React.ElementRef<typeof SheetPrimitive.Overlay>,
|
||||
@@ -21,49 +21,46 @@ const SheetOverlay = React.forwardRef<
|
||||
>(({ className, ...props }, ref) => (
|
||||
<SheetPrimitive.Overlay
|
||||
className={cn(
|
||||
"fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",
|
||||
className
|
||||
'fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0',
|
||||
className,
|
||||
)}
|
||||
{...props}
|
||||
ref={ref}
|
||||
/>
|
||||
))
|
||||
SheetOverlay.displayName = SheetPrimitive.Overlay.displayName
|
||||
));
|
||||
SheetOverlay.displayName = SheetPrimitive.Overlay.displayName;
|
||||
|
||||
const sheetVariants = cva(
|
||||
"fixed z-50 gap-4 bg-background p-6 shadow-lg transition ease-in-out data-[state=closed]:duration-300 data-[state=open]:duration-500 data-[state=open]:animate-in data-[state=closed]:animate-out",
|
||||
'fixed z-50 gap-4 bg-background p-6 shadow-lg transition ease-in-out data-[state=closed]:duration-300 data-[state=open]:duration-500 data-[state=open]:animate-in data-[state=closed]:animate-out',
|
||||
{
|
||||
variants: {
|
||||
side: {
|
||||
top: "inset-x-0 top-0 border-b data-[state=closed]:slide-out-to-top data-[state=open]:slide-in-from-top",
|
||||
top: 'inset-x-0 top-0 border-b data-[state=closed]:slide-out-to-top data-[state=open]:slide-in-from-top',
|
||||
bottom:
|
||||
"inset-x-0 bottom-0 border-t data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom",
|
||||
left: "inset-y-0 left-0 h-full w-3/4 border-r data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left sm:max-w-sm",
|
||||
'inset-x-0 bottom-0 border-t data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom',
|
||||
left: 'inset-y-0 left-0 h-full w-3/4 border-r data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left sm:max-w-sm',
|
||||
right:
|
||||
"inset-y-0 right-0 h-full w-3/4 border-l data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right sm:max-w-sm",
|
||||
'inset-y-0 right-0 h-full w-3/4 border-l data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right sm:max-w-sm',
|
||||
},
|
||||
},
|
||||
defaultVariants: {
|
||||
side: "right",
|
||||
side: 'right',
|
||||
},
|
||||
}
|
||||
)
|
||||
},
|
||||
);
|
||||
|
||||
interface SheetContentProps
|
||||
extends React.ComponentPropsWithoutRef<typeof SheetPrimitive.Content>,
|
||||
extends
|
||||
React.ComponentPropsWithoutRef<typeof SheetPrimitive.Content>,
|
||||
VariantProps<typeof sheetVariants> {}
|
||||
|
||||
const SheetContent = React.forwardRef<
|
||||
React.ElementRef<typeof SheetPrimitive.Content>,
|
||||
SheetContentProps
|
||||
>(({ side = "right", className, children, ...props }, ref) => (
|
||||
>(({ side = 'right', className, children, ...props }, ref) => (
|
||||
<SheetPortal>
|
||||
<SheetOverlay />
|
||||
<SheetPrimitive.Content
|
||||
ref={ref}
|
||||
className={cn(sheetVariants({ side }), className)}
|
||||
{...props}
|
||||
>
|
||||
<SheetPrimitive.Content ref={ref} className={cn(sheetVariants({ side }), className)} {...props}>
|
||||
<SheetPrimitive.Close className="absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-secondary">
|
||||
<X className="h-4 w-4" />
|
||||
<span className="sr-only">Close</span>
|
||||
@@ -71,36 +68,21 @@ const SheetContent = React.forwardRef<
|
||||
{children}
|
||||
</SheetPrimitive.Content>
|
||||
</SheetPortal>
|
||||
))
|
||||
SheetContent.displayName = SheetPrimitive.Content.displayName
|
||||
));
|
||||
SheetContent.displayName = SheetPrimitive.Content.displayName;
|
||||
|
||||
const SheetHeader = ({
|
||||
className,
|
||||
...props
|
||||
}: React.HTMLAttributes<HTMLDivElement>) => (
|
||||
const SheetHeader = ({ className, ...props }: React.HTMLAttributes<HTMLDivElement>) => (
|
||||
<div className={cn('flex flex-col space-y-2 text-center sm:text-left', className)} {...props} />
|
||||
);
|
||||
SheetHeader.displayName = 'SheetHeader';
|
||||
|
||||
const SheetFooter = ({ className, ...props }: React.HTMLAttributes<HTMLDivElement>) => (
|
||||
<div
|
||||
className={cn(
|
||||
"flex flex-col space-y-2 text-center sm:text-left",
|
||||
className
|
||||
)}
|
||||
className={cn('flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2', className)}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
SheetHeader.displayName = "SheetHeader"
|
||||
|
||||
const SheetFooter = ({
|
||||
className,
|
||||
...props
|
||||
}: React.HTMLAttributes<HTMLDivElement>) => (
|
||||
<div
|
||||
className={cn(
|
||||
"flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
SheetFooter.displayName = "SheetFooter"
|
||||
);
|
||||
SheetFooter.displayName = 'SheetFooter';
|
||||
|
||||
const SheetTitle = React.forwardRef<
|
||||
React.ElementRef<typeof SheetPrimitive.Title>,
|
||||
@@ -108,11 +90,11 @@ const SheetTitle = React.forwardRef<
|
||||
>(({ className, ...props }, ref) => (
|
||||
<SheetPrimitive.Title
|
||||
ref={ref}
|
||||
className={cn("text-lg font-semibold text-foreground", className)}
|
||||
className={cn('text-lg font-semibold text-foreground', className)}
|
||||
{...props}
|
||||
/>
|
||||
))
|
||||
SheetTitle.displayName = SheetPrimitive.Title.displayName
|
||||
));
|
||||
SheetTitle.displayName = SheetPrimitive.Title.displayName;
|
||||
|
||||
const SheetDescription = React.forwardRef<
|
||||
React.ElementRef<typeof SheetPrimitive.Description>,
|
||||
@@ -120,11 +102,11 @@ const SheetDescription = React.forwardRef<
|
||||
>(({ className, ...props }, ref) => (
|
||||
<SheetPrimitive.Description
|
||||
ref={ref}
|
||||
className={cn("text-sm text-muted-foreground", className)}
|
||||
className={cn('text-sm text-muted-foreground', className)}
|
||||
{...props}
|
||||
/>
|
||||
))
|
||||
SheetDescription.displayName = SheetPrimitive.Description.displayName
|
||||
));
|
||||
SheetDescription.displayName = SheetPrimitive.Description.displayName;
|
||||
|
||||
export {
|
||||
Sheet,
|
||||
@@ -137,4 +119,4 @@ export {
|
||||
SheetFooter,
|
||||
SheetTitle,
|
||||
SheetDescription,
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1,15 +1,7 @@
|
||||
import { cn } from "@/lib/utils"
|
||||
import { cn } from '@/lib/utils';
|
||||
|
||||
function Skeleton({
|
||||
className,
|
||||
...props
|
||||
}: React.HTMLAttributes<HTMLDivElement>) {
|
||||
return (
|
||||
<div
|
||||
className={cn("animate-pulse rounded-md bg-primary/10", className)}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
function Skeleton({ className, ...props }: React.HTMLAttributes<HTMLDivElement>) {
|
||||
return <div className={cn('animate-pulse rounded-md bg-primary/10', className)} {...props} />;
|
||||
}
|
||||
|
||||
export { Skeleton }
|
||||
export { Skeleton };
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
"use client"
|
||||
'use client';
|
||||
|
||||
import * as React from "react"
|
||||
import * as SliderPrimitive from "@radix-ui/react-slider"
|
||||
import * as React from 'react';
|
||||
import * as SliderPrimitive from '@radix-ui/react-slider';
|
||||
|
||||
import { cn } from "@/lib/utils"
|
||||
import { cn } from '@/lib/utils';
|
||||
|
||||
const Slider = React.forwardRef<
|
||||
React.ElementRef<typeof SliderPrimitive.Root>,
|
||||
@@ -11,10 +11,7 @@ const Slider = React.forwardRef<
|
||||
>(({ className, ...props }, ref) => (
|
||||
<SliderPrimitive.Root
|
||||
ref={ref}
|
||||
className={cn(
|
||||
"relative flex w-full touch-none select-none items-center",
|
||||
className
|
||||
)}
|
||||
className={cn('relative flex w-full touch-none select-none items-center', className)}
|
||||
{...props}
|
||||
>
|
||||
<SliderPrimitive.Track className="relative h-1.5 w-full grow overflow-hidden rounded-full bg-primary/20">
|
||||
@@ -22,7 +19,7 @@ const Slider = React.forwardRef<
|
||||
</SliderPrimitive.Track>
|
||||
<SliderPrimitive.Thumb className="block h-4 w-4 rounded-full border border-primary/50 bg-background shadow transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50" />
|
||||
</SliderPrimitive.Root>
|
||||
))
|
||||
Slider.displayName = SliderPrimitive.Root.displayName
|
||||
));
|
||||
Slider.displayName = SliderPrimitive.Root.displayName;
|
||||
|
||||
export { Slider }
|
||||
export { Slider };
|
||||
|
||||
@@ -1,31 +1,29 @@
|
||||
"use client"
|
||||
'use client';
|
||||
|
||||
import { useTheme } from "next-themes"
|
||||
import { Toaster as Sonner } from "sonner"
|
||||
import { useTheme } from 'next-themes';
|
||||
import { Toaster as Sonner } from 'sonner';
|
||||
|
||||
type ToasterProps = React.ComponentProps<typeof Sonner>
|
||||
type ToasterProps = React.ComponentProps<typeof Sonner>;
|
||||
|
||||
const Toaster = ({ ...props }: ToasterProps) => {
|
||||
const { theme = "system" } = useTheme()
|
||||
const { theme = 'system' } = useTheme();
|
||||
|
||||
return (
|
||||
<Sonner
|
||||
theme={theme as ToasterProps["theme"]}
|
||||
theme={theme as ToasterProps['theme']}
|
||||
className="toaster group"
|
||||
toastOptions={{
|
||||
classNames: {
|
||||
toast:
|
||||
"group toast group-[.toaster]:bg-background group-[.toaster]:text-foreground group-[.toaster]:border-border group-[.toaster]:shadow-lg",
|
||||
description: "group-[.toast]:text-muted-foreground",
|
||||
actionButton:
|
||||
"group-[.toast]:bg-primary group-[.toast]:text-primary-foreground",
|
||||
cancelButton:
|
||||
"group-[.toast]:bg-muted group-[.toast]:text-muted-foreground",
|
||||
'group toast group-[.toaster]:bg-background group-[.toaster]:text-foreground group-[.toaster]:border-border group-[.toaster]:shadow-lg',
|
||||
description: 'group-[.toast]:text-muted-foreground',
|
||||
actionButton: 'group-[.toast]:bg-primary group-[.toast]:text-primary-foreground',
|
||||
cancelButton: 'group-[.toast]:bg-muted group-[.toast]:text-muted-foreground',
|
||||
},
|
||||
}}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
export { Toaster }
|
||||
export { Toaster };
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
"use client"
|
||||
'use client';
|
||||
|
||||
import * as React from "react"
|
||||
import * as SwitchPrimitives from "@radix-ui/react-switch"
|
||||
import * as React from 'react';
|
||||
import * as SwitchPrimitives from '@radix-ui/react-switch';
|
||||
|
||||
import { cn } from "@/lib/utils"
|
||||
import { cn } from '@/lib/utils';
|
||||
|
||||
const Switch = React.forwardRef<
|
||||
React.ElementRef<typeof SwitchPrimitives.Root>,
|
||||
@@ -11,19 +11,19 @@ const Switch = React.forwardRef<
|
||||
>(({ className, ...props }, ref) => (
|
||||
<SwitchPrimitives.Root
|
||||
className={cn(
|
||||
"peer inline-flex h-5 w-9 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent shadow-sm transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input",
|
||||
className
|
||||
'peer inline-flex h-5 w-9 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent shadow-sm transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input',
|
||||
className,
|
||||
)}
|
||||
{...props}
|
||||
ref={ref}
|
||||
>
|
||||
<SwitchPrimitives.Thumb
|
||||
className={cn(
|
||||
"pointer-events-none block h-4 w-4 rounded-full bg-background shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-4 data-[state=unchecked]:translate-x-0"
|
||||
'pointer-events-none block h-4 w-4 rounded-full bg-background shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-4 data-[state=unchecked]:translate-x-0',
|
||||
)}
|
||||
/>
|
||||
</SwitchPrimitives.Root>
|
||||
))
|
||||
Switch.displayName = SwitchPrimitives.Root.displayName
|
||||
));
|
||||
Switch.displayName = SwitchPrimitives.Root.displayName;
|
||||
|
||||
export { Switch }
|
||||
export { Switch };
|
||||
|
||||
@@ -1,40 +1,31 @@
|
||||
import * as React from "react"
|
||||
import * as React from 'react';
|
||||
|
||||
import { cn } from "@/lib/utils"
|
||||
import { cn } from '@/lib/utils';
|
||||
|
||||
const Table = React.forwardRef<
|
||||
HTMLTableElement,
|
||||
React.HTMLAttributes<HTMLTableElement>
|
||||
>(({ className, ...props }, ref) => (
|
||||
<div className="relative w-full overflow-auto">
|
||||
<table
|
||||
ref={ref}
|
||||
className={cn("w-full caption-bottom text-sm", className)}
|
||||
{...props}
|
||||
/>
|
||||
</div>
|
||||
))
|
||||
Table.displayName = "Table"
|
||||
const Table = React.forwardRef<HTMLTableElement, React.HTMLAttributes<HTMLTableElement>>(
|
||||
({ className, ...props }, ref) => (
|
||||
<div className="relative w-full overflow-auto">
|
||||
<table ref={ref} className={cn('w-full caption-bottom text-sm', className)} {...props} />
|
||||
</div>
|
||||
),
|
||||
);
|
||||
Table.displayName = 'Table';
|
||||
|
||||
const TableHeader = React.forwardRef<
|
||||
HTMLTableSectionElement,
|
||||
React.HTMLAttributes<HTMLTableSectionElement>
|
||||
>(({ className, ...props }, ref) => (
|
||||
<thead ref={ref} className={cn("[&_tr]:border-b", className)} {...props} />
|
||||
))
|
||||
TableHeader.displayName = "TableHeader"
|
||||
<thead ref={ref} className={cn('[&_tr]:border-b', className)} {...props} />
|
||||
));
|
||||
TableHeader.displayName = 'TableHeader';
|
||||
|
||||
const TableBody = React.forwardRef<
|
||||
HTMLTableSectionElement,
|
||||
React.HTMLAttributes<HTMLTableSectionElement>
|
||||
>(({ className, ...props }, ref) => (
|
||||
<tbody
|
||||
ref={ref}
|
||||
className={cn("[&_tr:last-child]:border-0", className)}
|
||||
{...props}
|
||||
/>
|
||||
))
|
||||
TableBody.displayName = "TableBody"
|
||||
<tbody ref={ref} className={cn('[&_tr:last-child]:border-0', className)} {...props} />
|
||||
));
|
||||
TableBody.displayName = 'TableBody';
|
||||
|
||||
const TableFooter = React.forwardRef<
|
||||
HTMLTableSectionElement,
|
||||
@@ -42,29 +33,25 @@ const TableFooter = React.forwardRef<
|
||||
>(({ className, ...props }, ref) => (
|
||||
<tfoot
|
||||
ref={ref}
|
||||
className={cn(
|
||||
"border-t bg-muted/50 font-medium [&>tr]:last:border-b-0",
|
||||
className
|
||||
)}
|
||||
className={cn('border-t bg-muted/50 font-medium [&>tr]:last:border-b-0', className)}
|
||||
{...props}
|
||||
/>
|
||||
))
|
||||
TableFooter.displayName = "TableFooter"
|
||||
));
|
||||
TableFooter.displayName = 'TableFooter';
|
||||
|
||||
const TableRow = React.forwardRef<
|
||||
HTMLTableRowElement,
|
||||
React.HTMLAttributes<HTMLTableRowElement>
|
||||
>(({ className, ...props }, ref) => (
|
||||
<tr
|
||||
ref={ref}
|
||||
className={cn(
|
||||
"border-b transition-colors hover:bg-muted/50 data-[state=selected]:bg-muted",
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
))
|
||||
TableRow.displayName = "TableRow"
|
||||
const TableRow = React.forwardRef<HTMLTableRowElement, React.HTMLAttributes<HTMLTableRowElement>>(
|
||||
({ className, ...props }, ref) => (
|
||||
<tr
|
||||
ref={ref}
|
||||
className={cn(
|
||||
'border-b transition-colors hover:bg-muted/50 data-[state=selected]:bg-muted',
|
||||
className,
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
),
|
||||
);
|
||||
TableRow.displayName = 'TableRow';
|
||||
|
||||
const TableHead = React.forwardRef<
|
||||
HTMLTableCellElement,
|
||||
@@ -73,13 +60,13 @@ const TableHead = React.forwardRef<
|
||||
<th
|
||||
ref={ref}
|
||||
className={cn(
|
||||
"h-10 px-2 text-left align-middle font-medium text-muted-foreground [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]",
|
||||
className
|
||||
'h-10 px-2 text-left align-middle font-medium text-muted-foreground [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]',
|
||||
className,
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
))
|
||||
TableHead.displayName = "TableHead"
|
||||
));
|
||||
TableHead.displayName = 'TableHead';
|
||||
|
||||
const TableCell = React.forwardRef<
|
||||
HTMLTableCellElement,
|
||||
@@ -88,33 +75,20 @@ const TableCell = React.forwardRef<
|
||||
<td
|
||||
ref={ref}
|
||||
className={cn(
|
||||
"p-2 align-middle [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]",
|
||||
className
|
||||
'p-2 align-middle [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]',
|
||||
className,
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
))
|
||||
TableCell.displayName = "TableCell"
|
||||
));
|
||||
TableCell.displayName = 'TableCell';
|
||||
|
||||
const TableCaption = React.forwardRef<
|
||||
HTMLTableCaptionElement,
|
||||
React.HTMLAttributes<HTMLTableCaptionElement>
|
||||
>(({ className, ...props }, ref) => (
|
||||
<caption
|
||||
ref={ref}
|
||||
className={cn("mt-4 text-sm text-muted-foreground", className)}
|
||||
{...props}
|
||||
/>
|
||||
))
|
||||
TableCaption.displayName = "TableCaption"
|
||||
<caption ref={ref} className={cn('mt-4 text-sm text-muted-foreground', className)} {...props} />
|
||||
));
|
||||
TableCaption.displayName = 'TableCaption';
|
||||
|
||||
export {
|
||||
Table,
|
||||
TableHeader,
|
||||
TableBody,
|
||||
TableFooter,
|
||||
TableHead,
|
||||
TableRow,
|
||||
TableCell,
|
||||
TableCaption,
|
||||
}
|
||||
export { Table, TableHeader, TableBody, TableFooter, TableHead, TableRow, TableCell, TableCaption };
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
"use client"
|
||||
'use client';
|
||||
|
||||
import * as React from "react"
|
||||
import * as TabsPrimitive from "@radix-ui/react-tabs"
|
||||
import * as React from 'react';
|
||||
import * as TabsPrimitive from '@radix-ui/react-tabs';
|
||||
|
||||
import { cn } from "@/lib/utils"
|
||||
import { cn } from '@/lib/utils';
|
||||
|
||||
const Tabs = TabsPrimitive.Root
|
||||
const Tabs = TabsPrimitive.Root;
|
||||
|
||||
const TabsList = React.forwardRef<
|
||||
React.ElementRef<typeof TabsPrimitive.List>,
|
||||
@@ -14,13 +14,13 @@ const TabsList = React.forwardRef<
|
||||
<TabsPrimitive.List
|
||||
ref={ref}
|
||||
className={cn(
|
||||
"inline-flex h-9 items-center justify-center rounded-lg bg-muted p-1 text-muted-foreground",
|
||||
className
|
||||
'inline-flex h-9 items-center justify-center rounded-lg bg-muted p-1 text-muted-foreground',
|
||||
className,
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
))
|
||||
TabsList.displayName = TabsPrimitive.List.displayName
|
||||
));
|
||||
TabsList.displayName = TabsPrimitive.List.displayName;
|
||||
|
||||
const TabsTrigger = React.forwardRef<
|
||||
React.ElementRef<typeof TabsPrimitive.Trigger>,
|
||||
@@ -29,13 +29,13 @@ const TabsTrigger = React.forwardRef<
|
||||
<TabsPrimitive.Trigger
|
||||
ref={ref}
|
||||
className={cn(
|
||||
"inline-flex items-center justify-center whitespace-nowrap rounded-md px-3 py-1 text-sm font-medium ring-offset-background transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow",
|
||||
className
|
||||
'inline-flex items-center justify-center whitespace-nowrap rounded-md px-3 py-1 text-sm font-medium ring-offset-background transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow',
|
||||
className,
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
))
|
||||
TabsTrigger.displayName = TabsPrimitive.Trigger.displayName
|
||||
));
|
||||
TabsTrigger.displayName = TabsPrimitive.Trigger.displayName;
|
||||
|
||||
const TabsContent = React.forwardRef<
|
||||
React.ElementRef<typeof TabsPrimitive.Content>,
|
||||
@@ -44,12 +44,12 @@ const TabsContent = React.forwardRef<
|
||||
<TabsPrimitive.Content
|
||||
ref={ref}
|
||||
className={cn(
|
||||
"mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",
|
||||
className
|
||||
'mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2',
|
||||
className,
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
))
|
||||
TabsContent.displayName = TabsPrimitive.Content.displayName
|
||||
));
|
||||
TabsContent.displayName = TabsPrimitive.Content.displayName;
|
||||
|
||||
export { Tabs, TabsList, TabsTrigger, TabsContent }
|
||||
export { Tabs, TabsList, TabsTrigger, TabsContent };
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
"use client"
|
||||
'use client';
|
||||
|
||||
import * as React from "react"
|
||||
import * as TooltipPrimitive from "@radix-ui/react-tooltip"
|
||||
import * as React from 'react';
|
||||
import * as TooltipPrimitive from '@radix-ui/react-tooltip';
|
||||
|
||||
import { cn } from "@/lib/utils"
|
||||
import { cn } from '@/lib/utils';
|
||||
|
||||
const TooltipProvider = TooltipPrimitive.Provider
|
||||
const TooltipProvider = TooltipPrimitive.Provider;
|
||||
|
||||
const Tooltip = TooltipPrimitive.Root
|
||||
const Tooltip = TooltipPrimitive.Root;
|
||||
|
||||
const TooltipTrigger = TooltipPrimitive.Trigger
|
||||
const TooltipTrigger = TooltipPrimitive.Trigger;
|
||||
|
||||
const TooltipContent = React.forwardRef<
|
||||
React.ElementRef<typeof TooltipPrimitive.Content>,
|
||||
@@ -20,13 +20,13 @@ const TooltipContent = React.forwardRef<
|
||||
ref={ref}
|
||||
sideOffset={sideOffset}
|
||||
className={cn(
|
||||
"z-50 overflow-hidden rounded-md bg-primary px-3 py-1.5 text-xs text-primary-foreground animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 origin-[--radix-tooltip-content-transform-origin]",
|
||||
className
|
||||
'z-50 overflow-hidden rounded-md bg-primary px-3 py-1.5 text-xs text-primary-foreground animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 origin-[--radix-tooltip-content-transform-origin]',
|
||||
className,
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
</TooltipPrimitive.Portal>
|
||||
))
|
||||
TooltipContent.displayName = TooltipPrimitive.Content.displayName
|
||||
));
|
||||
TooltipContent.displayName = TooltipPrimitive.Content.displayName;
|
||||
|
||||
export { Tooltip, TooltipTrigger, TooltipContent, TooltipProvider }
|
||||
export { Tooltip, TooltipTrigger, TooltipContent, TooltipProvider };
|
||||
|
||||
@@ -41,8 +41,7 @@ export function useEntityOptions({
|
||||
|
||||
const { data, isLoading } = useQuery<unknown[]>({
|
||||
queryKey: ['entityOptions', endpoint, debouncedSearch],
|
||||
queryFn: () =>
|
||||
apiFetch<{ data: unknown[] }>(`${endpoint}${queryParams}`).then((r) => r.data),
|
||||
queryFn: () => apiFetch<{ data: unknown[] }>(`${endpoint}${queryParams}`).then((r) => r.data),
|
||||
enabled,
|
||||
});
|
||||
|
||||
|
||||
@@ -15,9 +15,9 @@ export function useSavedViews(entityType: string) {
|
||||
const { data: views = [] } = useQuery<SavedView[]>({
|
||||
queryKey,
|
||||
queryFn: () =>
|
||||
apiFetch<{ data: SavedView[] }>(
|
||||
`/api/v1/saved-views?entityType=${entityType}`,
|
||||
).then((r) => r.data),
|
||||
apiFetch<{ data: SavedView[] }>(`/api/v1/saved-views?entityType=${entityType}`).then(
|
||||
(r) => r.data,
|
||||
),
|
||||
});
|
||||
|
||||
const saveMutation = useMutation({
|
||||
@@ -34,8 +34,7 @@ export function useSavedViews(entityType: string) {
|
||||
});
|
||||
|
||||
const deleteMutation = useMutation({
|
||||
mutationFn: (viewId: string) =>
|
||||
apiFetch(`/api/v1/saved-views/${viewId}`, { method: 'DELETE' }),
|
||||
mutationFn: (viewId: string) => apiFetch(`/api/v1/saved-views/${viewId}`, { method: 'DELETE' }),
|
||||
onSuccess: () => queryClient.invalidateQueries({ queryKey }),
|
||||
});
|
||||
|
||||
|
||||
@@ -62,7 +62,10 @@ export async function processDocumensoPoll(): Promise<void> {
|
||||
await handleDocumentExpired({ documentId: doc.documensoId });
|
||||
}
|
||||
} catch (err) {
|
||||
logger.error({ err, documentId: doc.id, documensoId: doc.documensoId }, 'Documenso poll failed for document');
|
||||
logger.error(
|
||||
{ err, documentId: doc.id, documensoId: doc.documensoId },
|
||||
'Documenso poll failed for document',
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,10 +52,11 @@ export interface AuthContext {
|
||||
*/
|
||||
export type RouteParams = Record<string, string | string[]>;
|
||||
|
||||
export type RouteHandler<
|
||||
TParams extends RouteParams = Record<string, string>,
|
||||
T = unknown,
|
||||
> = (req: NextRequest, ctx: AuthContext, params: TParams) => Promise<NextResponse<T>>;
|
||||
export type RouteHandler<TParams extends RouteParams = Record<string, string>, T = unknown> = (
|
||||
req: NextRequest,
|
||||
ctx: AuthContext,
|
||||
params: TParams,
|
||||
) => Promise<NextResponse<T>>;
|
||||
|
||||
// ─── deepMerge ───────────────────────────────────────────────────────────────
|
||||
|
||||
@@ -104,10 +105,7 @@ export function deepMerge(
|
||||
*/
|
||||
export function withAuth<TParams extends RouteParams = Record<string, string>>(
|
||||
handler: RouteHandler<TParams>,
|
||||
): (
|
||||
req: NextRequest,
|
||||
routeContext: { params: Promise<TParams> },
|
||||
) => Promise<NextResponse> {
|
||||
): (req: NextRequest, routeContext: { params: Promise<TParams> }) => Promise<NextResponse> {
|
||||
return async (req, routeContext) => {
|
||||
// Mint or accept a request id BEFORE entering the ALS frame so every
|
||||
// log line + the response header reference the same value. Clients
|
||||
|
||||
@@ -15,7 +15,9 @@ import { files } from './documents';
|
||||
export const emailAccounts = pgTable(
|
||||
'email_accounts',
|
||||
{
|
||||
id: text('id').primaryKey().$defaultFn(() => crypto.randomUUID()),
|
||||
id: text('id')
|
||||
.primaryKey()
|
||||
.$defaultFn(() => crypto.randomUUID()),
|
||||
userId: text('user_id').notNull(), // references Better Auth user ID
|
||||
portId: text('port_id')
|
||||
.notNull()
|
||||
@@ -33,16 +35,15 @@ export const emailAccounts = pgTable(
|
||||
createdAt: timestamp('created_at', { withTimezone: true }).notNull().defaultNow(),
|
||||
updatedAt: timestamp('updated_at', { withTimezone: true }).notNull().defaultNow(),
|
||||
},
|
||||
(table) => [
|
||||
index('idx_ea_user').on(table.userId),
|
||||
index('idx_ea_port').on(table.portId),
|
||||
],
|
||||
(table) => [index('idx_ea_user').on(table.userId), index('idx_ea_port').on(table.portId)],
|
||||
);
|
||||
|
||||
export const emailThreads = pgTable(
|
||||
'email_threads',
|
||||
{
|
||||
id: text('id').primaryKey().$defaultFn(() => crypto.randomUUID()),
|
||||
id: text('id')
|
||||
.primaryKey()
|
||||
.$defaultFn(() => crypto.randomUUID()),
|
||||
portId: text('port_id')
|
||||
.notNull()
|
||||
.references(() => ports.id),
|
||||
@@ -53,16 +54,15 @@ export const emailThreads = pgTable(
|
||||
createdAt: timestamp('created_at', { withTimezone: true }).notNull().defaultNow(),
|
||||
updatedAt: timestamp('updated_at', { withTimezone: true }).notNull().defaultNow(),
|
||||
},
|
||||
(table) => [
|
||||
index('idx_et_client').on(table.clientId),
|
||||
index('idx_et_port').on(table.portId),
|
||||
],
|
||||
(table) => [index('idx_et_client').on(table.clientId), index('idx_et_port').on(table.portId)],
|
||||
);
|
||||
|
||||
export const emailMessages = pgTable(
|
||||
'email_messages',
|
||||
{
|
||||
id: text('id').primaryKey().$defaultFn(() => crypto.randomUUID()),
|
||||
id: text('id')
|
||||
.primaryKey()
|
||||
.$defaultFn(() => crypto.randomUUID()),
|
||||
threadId: text('thread_id')
|
||||
.notNull()
|
||||
.references(() => emailThreads.id, { onDelete: 'cascade' }),
|
||||
@@ -81,9 +81,9 @@ export const emailMessages = pgTable(
|
||||
},
|
||||
(table) => [
|
||||
index('idx_em_thread').on(table.threadId),
|
||||
uniqueIndex('idx_em_message_id').on(table.messageIdHeader).where(
|
||||
sql`${table.messageIdHeader} IS NOT NULL`
|
||||
),
|
||||
uniqueIndex('idx_em_message_id')
|
||||
.on(table.messageIdHeader)
|
||||
.where(sql`${table.messageIdHeader} IS NOT NULL`),
|
||||
],
|
||||
);
|
||||
|
||||
|
||||
@@ -31,7 +31,9 @@ export type PortBranding = {
|
||||
export const ports = pgTable(
|
||||
'ports',
|
||||
{
|
||||
id: text('id').primaryKey().$defaultFn(() => crypto.randomUUID()),
|
||||
id: text('id')
|
||||
.primaryKey()
|
||||
.$defaultFn(() => crypto.randomUUID()),
|
||||
name: text('name').notNull(),
|
||||
slug: text('slug').notNull(),
|
||||
logoUrl: text('logo_url'),
|
||||
|
||||
@@ -13,9 +13,7 @@ import { db } from './index';
|
||||
* return result;
|
||||
* });
|
||||
*/
|
||||
export async function withTransaction<T>(
|
||||
callback: (tx: typeof db) => Promise<T>,
|
||||
): Promise<T> {
|
||||
export async function withTransaction<T>(callback: (tx: typeof db) => Promise<T>): Promise<T> {
|
||||
return db.transaction(callback as unknown as Parameters<typeof db.transaction>[0]) as Promise<T>;
|
||||
}
|
||||
|
||||
|
||||
@@ -54,10 +54,7 @@ export function buildActivityInputs(
|
||||
data: ActivityData,
|
||||
portName?: string,
|
||||
): Record<string, string>[] {
|
||||
const summaryLines = [
|
||||
`Activity Summary (${data.logs.length} events)`,
|
||||
'─────────────────────',
|
||||
];
|
||||
const summaryLines = [`Activity Summary (${data.logs.length} events)`, '─────────────────────'];
|
||||
|
||||
const sortedSummary = Object.entries(data.summary).sort((a, b) => b[1] - a[1]);
|
||||
if (sortedSummary.length === 0) {
|
||||
|
||||
@@ -62,13 +62,12 @@ export function buildOccupancyInputs(
|
||||
|
||||
const breakdownLines = ['Berth Status Breakdown', '─────────────────────'];
|
||||
const allStatuses = ['available', 'under_offer', 'sold'];
|
||||
const unknownStatuses = Object.keys(data.statusCounts).filter(
|
||||
(s) => !allStatuses.includes(s),
|
||||
);
|
||||
const unknownStatuses = Object.keys(data.statusCounts).filter((s) => !allStatuses.includes(s));
|
||||
|
||||
for (const status of [...allStatuses, ...unknownStatuses]) {
|
||||
const cnt = data.statusCounts[status] ?? 0;
|
||||
const label = statusLabels[status] ?? status.replace(/_/g, ' ').replace(/\b\w/g, (c) => c.toUpperCase());
|
||||
const label =
|
||||
statusLabels[status] ?? status.replace(/_/g, ' ').replace(/\b\w/g, (c) => c.toUpperCase());
|
||||
const pct = data.totalBerths > 0 ? ((cnt / data.totalBerths) * 100).toFixed(1) : '0.0';
|
||||
breakdownLines.push(`${label}: ${cnt} berth(s) (${pct}%)`);
|
||||
}
|
||||
|
||||
@@ -541,10 +541,7 @@ async function fetchGroupRows(
|
||||
signedFromDocumentId: documents.id,
|
||||
})
|
||||
.from(files)
|
||||
.leftJoin(
|
||||
documents,
|
||||
and(eq(documents.signedFileId, files.id), eq(documents.portId, portId)),
|
||||
)
|
||||
.leftJoin(documents, and(eq(documents.signedFileId, files.id), eq(documents.portId, portId)))
|
||||
.where(and(eq(files.portId, portId), predicate))
|
||||
.orderBy(desc(files.createdAt))
|
||||
.limit(limit);
|
||||
|
||||
@@ -12,10 +12,7 @@ interface ScanResult {
|
||||
confidence: number;
|
||||
}
|
||||
|
||||
export async function scanReceipt(
|
||||
imageBuffer: Buffer,
|
||||
mimeType: string,
|
||||
): Promise<ScanResult> {
|
||||
export async function scanReceipt(imageBuffer: Buffer, mimeType: string): Promise<ScanResult> {
|
||||
try {
|
||||
const base64 = imageBuffer.toString('base64');
|
||||
const response = await openai.chat.completions.create({
|
||||
|
||||
@@ -7,10 +7,7 @@ import type { CreateSavedViewInput, UpdateSavedViewInput } from '@/lib/validator
|
||||
|
||||
export const savedViewsService = {
|
||||
async list(portId: string, userId: string, entityType?: string) {
|
||||
const conditions = [
|
||||
eq(savedViews.portId, portId),
|
||||
eq(savedViews.userId, userId),
|
||||
];
|
||||
const conditions = [eq(savedViews.portId, portId), eq(savedViews.userId, userId)];
|
||||
if (entityType) {
|
||||
conditions.push(eq(savedViews.entityType, entityType));
|
||||
}
|
||||
|
||||
@@ -14,8 +14,8 @@ export function generateStorageKey(
|
||||
|
||||
export function sanitizeFilename(name: string): string {
|
||||
return name
|
||||
.replace(/[/\\:]/g, '') // strip path chars
|
||||
.replace(/\x00/g, '') // strip null bytes
|
||||
.replace(/[/\\:]/g, '') // strip path chars
|
||||
.replace(/\x00/g, '') // strip null bytes
|
||||
.replace(/[\x01-\x1f\x7f]/g, '') // strip control chars
|
||||
.trim()
|
||||
.slice(0, 255);
|
||||
|
||||
@@ -26,9 +26,7 @@ export function QueryProvider({ children }: { children: ReactNode }) {
|
||||
return (
|
||||
<QueryClientProvider client={queryClient}>
|
||||
{children}
|
||||
{process.env.NODE_ENV === 'development' && (
|
||||
<ReactQueryDevtools initialIsOpen={false} />
|
||||
)}
|
||||
{process.env.NODE_ENV === 'development' && <ReactQueryDevtools initialIsOpen={false} />}
|
||||
</QueryClientProvider>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -5,7 +5,11 @@ interface PermissionsState {
|
||||
permissions: RolePermissions | null;
|
||||
isSuperAdmin: boolean;
|
||||
userId: string | null;
|
||||
setPermissions: (permissions: RolePermissions | null, isSuperAdmin: boolean, userId: string | null) => void;
|
||||
setPermissions: (
|
||||
permissions: RolePermissions | null,
|
||||
isSuperAdmin: boolean,
|
||||
userId: string | null,
|
||||
) => void;
|
||||
reset: () => void;
|
||||
}
|
||||
|
||||
@@ -13,7 +17,6 @@ export const usePermissionsStore = create<PermissionsState>()((set) => ({
|
||||
permissions: null,
|
||||
isSuperAdmin: false,
|
||||
userId: null,
|
||||
setPermissions: (permissions, isSuperAdmin, userId) =>
|
||||
set({ permissions, isSuperAdmin, userId }),
|
||||
setPermissions: (permissions, isSuperAdmin, userId) => set({ permissions, isSuperAdmin, userId }),
|
||||
reset: () => set({ permissions: null, isSuperAdmin: false, userId: null }),
|
||||
}));
|
||||
|
||||
@@ -44,7 +44,18 @@ export interface SortConfig<T extends string = string> {
|
||||
/** Filter configuration for list queries */
|
||||
export interface FilterConfig {
|
||||
field: string;
|
||||
operator: 'eq' | 'neq' | 'gt' | 'gte' | 'lt' | 'lte' | 'like' | 'in' | 'notIn' | 'isNull' | 'isNotNull';
|
||||
operator:
|
||||
| 'eq'
|
||||
| 'neq'
|
||||
| 'gt'
|
||||
| 'gte'
|
||||
| 'lt'
|
||||
| 'lte'
|
||||
| 'like'
|
||||
| 'in'
|
||||
| 'notIn'
|
||||
| 'isNull'
|
||||
| 'isNotNull';
|
||||
value: string | number | boolean | string[] | number[] | null;
|
||||
}
|
||||
|
||||
|
||||
@@ -22,9 +22,7 @@ test.describe('Documents hub — upload into entity folder', () => {
|
||||
await login(page, 'super_admin');
|
||||
});
|
||||
|
||||
test('file uploaded with clientId appears in the client entity folder view', async ({
|
||||
page,
|
||||
}) => {
|
||||
test('file uploaded with clientId appears in the client entity folder view', async ({ page }) => {
|
||||
const headers = await apiHeaders(page);
|
||||
|
||||
// 1. Create a client.
|
||||
@@ -157,9 +155,12 @@ test.describe('Documents hub — upload into entity folder', () => {
|
||||
}
|
||||
|
||||
// 3. List files for this client to discover the folder id.
|
||||
const listRes = await page.request.get(`/api/v1/files?entityType=client&entityId=${client.id}`, {
|
||||
headers,
|
||||
});
|
||||
const listRes = await page.request.get(
|
||||
`/api/v1/files?entityType=client&entityId=${client.id}`,
|
||||
{
|
||||
headers,
|
||||
},
|
||||
);
|
||||
if (!listRes.ok()) {
|
||||
test.skip(true, `File list returned ${listRes.status()} — folderId test skipped`);
|
||||
return;
|
||||
|
||||
@@ -78,16 +78,10 @@ test.describe('Visual regression', () => {
|
||||
await page.waitForLoadState('networkidle');
|
||||
|
||||
// Expand the Clients system root.
|
||||
const expandBtn = page
|
||||
.locator('aside')
|
||||
.getByRole('button', { name: 'Expand' })
|
||||
.first();
|
||||
const expandBtn = page.locator('aside').getByRole('button', { name: 'Expand' }).first();
|
||||
const hasExpand = await expandBtn.isVisible({ timeout: 5_000 }).catch(() => false);
|
||||
if (!hasExpand) {
|
||||
test.skip(
|
||||
true,
|
||||
'No expandable folder found in sidebar — hub-entity-folder baseline skipped',
|
||||
);
|
||||
test.skip(true, 'No expandable folder found in sidebar — hub-entity-folder baseline skipped');
|
||||
return;
|
||||
}
|
||||
await expandBtn.click();
|
||||
|
||||
@@ -195,9 +195,7 @@ describe('backfill-document-folders · runBackfill', () => {
|
||||
|
||||
it('does not create folders for a different port when only portId is supplied', async () => {
|
||||
const otherPort = await makePort();
|
||||
await db
|
||||
.delete(documentFolders)
|
||||
.where(eq(documentFolders.portId, otherPort.id));
|
||||
await db.delete(documentFolders).where(eq(documentFolders.portId, otherPort.id));
|
||||
|
||||
const otherClient = await makeClient({ portId: otherPort.id });
|
||||
|
||||
|
||||
@@ -267,10 +267,7 @@ describe('document-folders service · archive lifecycle', () => {
|
||||
await db.delete(documentFolders).where(eq(documentFolders.portId, portId));
|
||||
await ensureSystemRoots(portId, TEST_USER_ID);
|
||||
clientName = `John Smith ${crypto.randomUUID().slice(0, 6)}`;
|
||||
const [client] = await db
|
||||
.insert(clients)
|
||||
.values({ portId, fullName: clientName })
|
||||
.returning();
|
||||
const [client] = await db.insert(clients).values({ portId, fullName: clientName }).returning();
|
||||
clientId = client!.id;
|
||||
await ensureEntityFolder(portId, 'client', clientId, TEST_USER_ID);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user