690402:2240 fix dashboard
This commit is contained in:
@@ -10,7 +10,7 @@ import { format } from 'date-fns';
|
||||
import Link from 'next/link';
|
||||
|
||||
interface CirculationStatusCardProps {
|
||||
correspondenceUuid: string;
|
||||
correspondencePublicId: string;
|
||||
}
|
||||
|
||||
const ROUTING_STATUS_META: Record<string, { icon: React.ElementType; color: string; label: string }> = {
|
||||
@@ -86,8 +86,8 @@ function CirculationItem({ circ }: { circ: Circulation }) {
|
||||
);
|
||||
}
|
||||
|
||||
export function CirculationStatusCard({ correspondenceUuid }: CirculationStatusCardProps) {
|
||||
const { data, isLoading } = useCirculationsByCorrespondence(correspondenceUuid);
|
||||
export function CirculationStatusCard({ correspondencePublicId }: CirculationStatusCardProps) {
|
||||
const { data, isLoading } = useCirculationsByCorrespondence(correspondencePublicId);
|
||||
|
||||
const circulations: Circulation[] = Array.isArray(data)
|
||||
? data
|
||||
@@ -122,7 +122,7 @@ export function CirculationStatusCard({ correspondenceUuid }: CirculationStatusC
|
||||
))
|
||||
)}
|
||||
|
||||
<Link href={`/circulation/new?correspondenceUuid=${correspondenceUuid}`}>
|
||||
<Link href={`/circulation/new?correspondencePublicId=${correspondencePublicId}`}>
|
||||
<Button variant="outline" size="sm" className="w-full h-8 text-xs mt-1">
|
||||
<GitBranch className="h-3 w-3 mr-1.5" />
|
||||
New Circulation
|
||||
|
||||
@@ -416,7 +416,7 @@ export function CorrespondenceDetail({ data, selectedRevisionId }: Correspondenc
|
||||
</Card>
|
||||
|
||||
{/* Circulations */}
|
||||
<CirculationStatusCard correspondenceUuid={data.publicId} />
|
||||
<CirculationStatusCard correspondencePublicId={data.publicId} />
|
||||
|
||||
{/* Tags */}
|
||||
<TagManager
|
||||
|
||||
@@ -356,6 +356,12 @@ export function CorrespondenceForm({
|
||||
}
|
||||
|
||||
const fetchPreview = async () => {
|
||||
// Don't preview or change number in edit mode
|
||||
if (uuid) {
|
||||
setPreview(null);
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
const res = await numberingApi.previewNumber({
|
||||
projectId,
|
||||
@@ -387,29 +393,21 @@ export function CorrespondenceForm({
|
||||
readOnly
|
||||
className="bg-muted font-mono font-bold text-lg w-full"
|
||||
/>
|
||||
{preview && preview.number !== initialData.correspondenceNumber && (
|
||||
<span className="text-xs text-amber-600 font-semibold whitespace-nowrap px-2">Start Change Detected</span>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* Preview Section */}
|
||||
{preview && (
|
||||
{/* Preview Section - Only for New Documents */}
|
||||
{preview && !uuid && (
|
||||
<div
|
||||
className={`p-4 rounded-md border ${preview.number !== initialData?.correspondenceNumber ? 'bg-amber-50 border-amber-200' : 'bg-muted border-border'}`}
|
||||
className="p-4 rounded-md border bg-muted border-border"
|
||||
>
|
||||
<p className="text-sm font-semibold mb-1 flex items-center gap-2">
|
||||
{initialData?.correspondenceNumber ? 'New Document Number (Preview)' : 'Document Number Preview'}
|
||||
{preview.number !== initialData?.correspondenceNumber && initialData?.correspondenceNumber && (
|
||||
<span className="text-[10px] bg-amber-100 text-amber-700 px-2 py-0.5 rounded-full border border-amber-200">
|
||||
Will Update
|
||||
</span>
|
||||
)}
|
||||
Document Number Preview
|
||||
</p>
|
||||
<div className="flex items-center gap-3">
|
||||
<span
|
||||
className={`text-xl font-bold font-mono tracking-wide ${preview.number !== initialData?.correspondenceNumber ? 'text-amber-700' : 'text-primary'}`}
|
||||
className="text-xl font-bold font-mono tracking-wide text-primary"
|
||||
>
|
||||
{preview.number}
|
||||
</span>
|
||||
@@ -419,11 +417,6 @@ export function CorrespondenceForm({
|
||||
</span>
|
||||
)}
|
||||
</div>
|
||||
{preview.number !== initialData?.correspondenceNumber && initialData?.correspondenceNumber && (
|
||||
<p className="text-xs text-muted-foreground mt-2">
|
||||
* The document number will be regenerated because critical fields were changed.
|
||||
</p>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ import { GlobalSearch } from './global-search';
|
||||
import { NotificationsDropdown } from './notifications-dropdown';
|
||||
import { MobileSidebar } from './sidebar';
|
||||
import { ThemeToggle } from './theme-toggle';
|
||||
import { ProjectSwitcher } from './project-switcher';
|
||||
|
||||
export function Header() {
|
||||
return (
|
||||
@@ -18,6 +19,7 @@ export function Header() {
|
||||
</div>
|
||||
|
||||
<div className="flex items-center gap-4">
|
||||
<ProjectSwitcher />
|
||||
<ThemeToggle />
|
||||
<NotificationsDropdown />
|
||||
<UserMenu />
|
||||
|
||||
@@ -0,0 +1,68 @@
|
||||
// File: components/layout/project-switcher.tsx
|
||||
'use client';
|
||||
|
||||
import * as React from 'react';
|
||||
import { useProjects } from '@/hooks/use-projects';
|
||||
import { useProjectStore } from '@/lib/stores/project-store';
|
||||
import {
|
||||
Select,
|
||||
SelectContent,
|
||||
SelectItem,
|
||||
SelectTrigger,
|
||||
SelectValue,
|
||||
} from '@/components/ui/select';
|
||||
import { Building2 } from 'lucide-react';
|
||||
import { Skeleton } from '@/components/ui/skeleton';
|
||||
|
||||
export function ProjectSwitcher() {
|
||||
const { data: projects, isLoading } = useProjects({ isActive: true });
|
||||
const { selectedProjectId, setSelectedProjectId } = useProjectStore();
|
||||
|
||||
React.useEffect(() => {
|
||||
// Auto-select if there's only one project
|
||||
if (projects && projects.length === 1 && selectedProjectId !== projects[0].publicId) {
|
||||
setSelectedProjectId(projects[0].publicId);
|
||||
}
|
||||
}, [projects, selectedProjectId, setSelectedProjectId]);
|
||||
|
||||
if (isLoading) {
|
||||
return <Skeleton className="h-9 w-[200px] lg:w-[250px]" />;
|
||||
}
|
||||
|
||||
// If user has no projects, don't show the switcher
|
||||
if (!projects || projects.length === 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// If user has exactly one project, show it as text (no dropdown needed)
|
||||
if (projects.length === 1) {
|
||||
return (
|
||||
<div className="flex h-9 items-center px-3 py-2 text-sm border rounded-md bg-muted/50 w-[200px] lg:w-[250px]">
|
||||
<Building2 className="h-4 w-4 mr-2 opacity-50 flex-shrink-0" />
|
||||
<span className="truncate font-medium">{projects[0].projectName}</span>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<Select
|
||||
value={selectedProjectId || 'global'}
|
||||
onValueChange={(value) => setSelectedProjectId(value === 'global' ? null : value)}
|
||||
>
|
||||
<SelectTrigger className="w-[200px] lg:w-[250px] h-9">
|
||||
<div className="flex items-center gap-2 truncate">
|
||||
<Building2 className="h-4 w-4 opacity-50 flex-shrink-0" />
|
||||
<SelectValue placeholder="Select Project..." className="truncate" />
|
||||
</div>
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
<SelectItem value="global">All Projects (Global)</SelectItem>
|
||||
{projects.map((project) => (
|
||||
<SelectItem key={project.publicId} value={project.publicId}>
|
||||
{project.projectName}
|
||||
</SelectItem>
|
||||
))}
|
||||
</SelectContent>
|
||||
</Select>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user