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