Skip to content

Commit ec20de7

Browse files
committed
Changed how galleries are viewed and created.
1 parent 652de35 commit ec20de7

File tree

2 files changed

+43
-259
lines changed

2 files changed

+43
-259
lines changed

backend/app/seed_data.py

Lines changed: 39 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,13 @@
1414

1515
def seed_data() -> None:
1616
with Session(engine) as session:
17-
# Get the default organization
17+
# Get the admin organization (created during init_db)
1818
organization = session.exec(
19-
select(Organization).where(Organization.name == "Default Organization")
19+
select(Organization).where(Organization.name == "Admin Organization")
2020
).first()
2121

2222
if not organization:
23-
logger.error("Default organization not found! Run init_db first.")
23+
logger.error("Admin organization not found! Run initial_data.py first.")
2424
return
2525

2626
logger.info(f"Using organization: {organization.name}")
@@ -112,101 +112,69 @@ def seed_data() -> None:
112112
session.refresh(project1)
113113
session.refresh(project2)
114114
session.refresh(project3)
115+
session.refresh(project4)
115116
session.refresh(project5)
116117

117118
logger.info("Created 5 sample projects")
118119

119-
# Create sample galleries
120+
# Create one gallery per project
120121
gallery1 = Gallery(
121-
name="Engagement Shoot",
122-
date=today - timedelta(days=10),
123-
photo_count=87,
124-
photographer="Alice Johnson",
125-
status="published",
126-
cover_image_url="https://images.unsplash.com/photo-1519741497674-611481863552?w=400&h=300&fit=crop",
122+
name=f"{project1.name} - Gallery",
123+
date=project1.start_date,
124+
photo_count=0,
125+
photographer=None,
126+
status="draft",
127+
cover_image_url=None,
127128
project_id=project1.id,
128129
)
129130
session.add(gallery1)
130131

131132
gallery2 = Gallery(
132-
name="Wedding Day - Ceremony",
133-
date=today - timedelta(days=3),
134-
photo_count=234,
135-
photographer="Alice Johnson",
136-
status="processing",
137-
cover_image_url="https://images.unsplash.com/photo-1606800052052-a08af7148866?w=400&h=300&fit=crop",
138-
project_id=project1.id,
133+
name=f"{project2.name} - Gallery",
134+
date=project2.start_date,
135+
photo_count=0,
136+
photographer=None,
137+
status="draft",
138+
cover_image_url=None,
139+
project_id=project2.id,
139140
)
140141
session.add(gallery2)
141142

142143
gallery3 = Gallery(
143-
name="Wedding Day - Reception",
144-
date=today - timedelta(days=3),
145-
photo_count=198,
146-
photographer="Bob Smith",
147-
status="processing",
148-
cover_image_url="https://images.unsplash.com/photo-1464366400600-7168b8af9bc3?w=400&h=300&fit=crop",
149-
project_id=project1.id,
144+
name=f"{project3.name} - Gallery",
145+
date=project3.start_date,
146+
photo_count=0,
147+
photographer=None,
148+
status="draft",
149+
cover_image_url=None,
150+
project_id=project3.id,
150151
)
151152
session.add(gallery3)
152153

153154
gallery4 = Gallery(
154-
name="Smartphone Collection - White BG",
155-
date=today - timedelta(days=3),
156-
photo_count=52,
157-
photographer="Charlie Davis",
158-
status="published",
159-
cover_image_url="https://images.unsplash.com/photo-1511707171634-5f897ff02aa9?w=400&h=300&fit=crop",
160-
project_id=project2.id,
155+
name=f"{project4.name} - Gallery",
156+
date=project4.start_date,
157+
photo_count=0,
158+
photographer=None,
159+
status="draft",
160+
cover_image_url=None,
161+
project_id=project4.id,
161162
)
162163
session.add(gallery4)
163164

164165
gallery5 = Gallery(
165-
name="Lifestyle Shots",
166-
date=today - timedelta(days=3),
167-
photo_count=48,
168-
photographer="Charlie Davis",
169-
status="published",
170-
cover_image_url="https://images.unsplash.com/photo-1556656793-08538906a9f8?w=400&h=300&fit=crop",
171-
project_id=project2.id,
172-
)
173-
session.add(gallery5)
174-
175-
gallery6 = Gallery(
176-
name="Mood Board & References",
177-
date=today,
178-
photo_count=15,
179-
photographer="Alice Johnson",
166+
name=f"{project5.name} - Gallery",
167+
date=project5.start_date,
168+
photo_count=0,
169+
photographer=None,
180170
status="draft",
181-
cover_image_url="https://images.unsplash.com/photo-1542744173-8e7e53415bb0?w=400&h=300&fit=crop",
182-
project_id=project3.id,
183-
)
184-
session.add(gallery6)
185-
186-
gallery7 = Gallery(
187-
name="Menu Items - Appetizers",
188-
date=today - timedelta(days=20),
189-
photo_count=45,
190-
photographer="David Lee",
191-
status="published",
192-
cover_image_url="https://images.unsplash.com/photo-1504674900247-0877df9cc836?w=400&h=300&fit=crop",
193-
project_id=project5.id,
194-
)
195-
session.add(gallery7)
196-
197-
gallery8 = Gallery(
198-
name="Menu Items - Main Courses",
199-
date=today - timedelta(days=18),
200-
photo_count=52,
201-
photographer="David Lee",
202-
status="published",
203-
cover_image_url="https://images.unsplash.com/photo-1546069901-ba9599a7e63c?w=400&h=300&fit=crop",
171+
cover_image_url=None,
204172
project_id=project5.id,
205173
)
206-
session.add(gallery8)
174+
session.add(gallery5)
207175

208176
session.commit()
209-
logger.info("Created 8 sample galleries")
177+
logger.info("Created 5 galleries (one per project)")
210178
logger.info("Sample data seeding complete!")
211179

212180

Lines changed: 4 additions & 188 deletions
Original file line numberDiff line numberDiff line change
@@ -1,193 +1,9 @@
1-
import {
2-
Badge,
3-
Box,
4-
Card,
5-
Container,
6-
EmptyState,
7-
Flex,
8-
Grid,
9-
Heading,
10-
Stack,
11-
Text,
12-
VStack,
13-
} from "@chakra-ui/react"
14-
import { useQuery } from "@tanstack/react-query"
15-
import { createFileRoute, Link } from "@tanstack/react-router"
16-
import { FiCalendar, FiImage, FiUser } from "react-icons/fi"
17-
18-
import { GalleriesService } from "@/client"
19-
import type { GalleryPublic } from "@/client"
20-
21-
function getGalleriesQueryOptions() {
22-
return {
23-
queryFn: () => GalleriesService.readGalleries({ skip: 0, limit: 100 }),
24-
queryKey: ["galleries"],
25-
}
26-
}
1+
import { createFileRoute, Outlet } from "@tanstack/react-router"
272

283
export const Route = createFileRoute("/_layout/galleries")({
29-
component: Galleries,
4+
component: GalleriesLayout,
305
})
316

32-
function getStatusColor(status: string) {
33-
switch (status) {
34-
case "draft":
35-
return "gray"
36-
case "processing":
37-
return "orange"
38-
case "published":
39-
return "green"
40-
default:
41-
return "gray"
42-
}
43-
}
44-
45-
function getStatusLabel(status: string) {
46-
return status.charAt(0).toUpperCase() + status.slice(1)
47-
}
48-
49-
function Galleries() {
50-
const { data, isLoading } = useQuery({
51-
...getGalleriesQueryOptions(),
52-
})
53-
54-
const galleries = data?.data ?? []
55-
56-
if (isLoading) {
57-
return (
58-
<Container maxW="full" p={6}>
59-
<Text>Loading galleries...</Text>
60-
</Container>
61-
)
62-
}
63-
64-
if (galleries.length === 0) {
65-
return (
66-
<Container maxW="full" p={6}>
67-
<Heading size="2xl" mb={6}>
68-
Galleries
69-
</Heading>
70-
<EmptyState.Root>
71-
<EmptyState.Content>
72-
<EmptyState.Indicator>
73-
<FiImage size={48} />
74-
</EmptyState.Indicator>
75-
<VStack textAlign="center">
76-
<EmptyState.Title>No galleries yet</EmptyState.Title>
77-
<EmptyState.Description>
78-
Galleries will appear here as you work on projects
79-
</EmptyState.Description>
80-
</VStack>
81-
</EmptyState.Content>
82-
</EmptyState.Root>
83-
</Container>
84-
)
85-
}
86-
87-
return (
88-
<Container maxW="full" p={6}>
89-
<Stack gap={6}>
90-
{/* Header */}
91-
<Box>
92-
<Heading size="2xl" mb={2}>
93-
Galleries
94-
</Heading>
95-
<Text color="fg.muted">Browse all photo galleries from your projects</Text>
96-
</Box>
97-
98-
{/* Gallery Grid */}
99-
<Grid
100-
templateColumns={{
101-
base: "1fr",
102-
md: "repeat(2, 1fr)",
103-
lg: "repeat(3, 1fr)",
104-
}}
105-
gap={6}
106-
>
107-
{galleries.map((gallery: GalleryPublic) => (
108-
<Link
109-
key={gallery.id}
110-
to="/galleries/$galleryId"
111-
params={{ galleryId: gallery.id }}
112-
style={{ textDecoration: "none", color: "inherit" }}
113-
>
114-
<Card.Root
115-
overflow="hidden"
116-
transition="all 0.2s"
117-
_hover={{
118-
transform: "translateY(-4px)",
119-
boxShadow: "lg",
120-
cursor: "pointer",
121-
}}
122-
>
123-
{/* Gallery Cover Image */}
124-
<Box
125-
h="200px"
126-
bg="gray.200"
127-
backgroundImage={gallery.cover_image_url ? `url(${gallery.cover_image_url})` : undefined}
128-
backgroundSize="cover"
129-
backgroundPosition="center"
130-
position="relative"
131-
>
132-
<Box
133-
position="absolute"
134-
top={2}
135-
right={2}
136-
bg="blackAlpha.700"
137-
px={2}
138-
py={1}
139-
borderRadius="md"
140-
>
141-
<Flex alignItems="center" gap={1}>
142-
<FiImage color="white" size={14} />
143-
<Text fontSize="sm" fontWeight="semibold" color="white">
144-
{gallery.photo_count}
145-
</Text>
146-
</Flex>
147-
</Box>
148-
<Badge
149-
position="absolute"
150-
top={2}
151-
left={2}
152-
colorScheme={getStatusColor(gallery.status || 'pending')}
153-
>
154-
{getStatusLabel(gallery.status || 'pending')}
155-
</Badge>
156-
</Box>
157-
158-
{/* Gallery Info */}
159-
<Card.Body>
160-
<Stack gap={2}>
161-
<Heading size="md" mb={1}>
162-
{gallery.name}
163-
</Heading>
164-
<Flex
165-
justifyContent="space-between"
166-
alignItems="center"
167-
pt={2}
168-
fontSize="xs"
169-
color="fg.muted"
170-
>
171-
{gallery.photographer && (
172-
<Flex alignItems="center" gap={1}>
173-
<FiUser size={12} />
174-
<Text>{gallery.photographer}</Text>
175-
</Flex>
176-
)}
177-
{gallery.date && (
178-
<Flex alignItems="center" gap={1}>
179-
<FiCalendar size={12} />
180-
<Text>{gallery.date}</Text>
181-
</Flex>
182-
)}
183-
</Flex>
184-
</Stack>
185-
</Card.Body>
186-
</Card.Root>
187-
</Link>
188-
))}
189-
</Grid>
190-
</Stack>
191-
</Container>
192-
)
7+
function GalleriesLayout() {
8+
return <Outlet />
1939
}

0 commit comments

Comments
 (0)