Skip to content

Commit 648c805

Browse files
committed
the ui of edit and addd look pretty good now
1 parent 83208f8 commit 648c805

File tree

16 files changed

+979
-265
lines changed

16 files changed

+979
-265
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
ALTER TABLE "events" ALTER COLUMN "description" DROP NOT NULL;--> statement-breakpoint
2+
ALTER TABLE "events" ALTER COLUMN "venue" DROP NOT NULL;--> statement-breakpoint
3+
ALTER TABLE "events" ALTER COLUMN "date" DROP NOT NULL;
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
ALTER TABLE "events" RENAME COLUMN "image" TO "image_data";--> statement-breakpoint
2+
ALTER TABLE "events" ADD COLUMN "image_mime_type" varchar(100);
Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
{
2+
"id": "ad736958-666e-4bf8-bfa7-589187e6b44a",
3+
"prevId": "4518ee12-206e-490c-ade5-179ba41f07e6",
4+
"version": "7",
5+
"dialect": "postgresql",
6+
"tables": {
7+
"public.events": {
8+
"name": "events",
9+
"schema": "",
10+
"columns": {
11+
"id": {
12+
"name": "id",
13+
"type": "uuid",
14+
"primaryKey": true,
15+
"notNull": true,
16+
"default": "gen_random_uuid()"
17+
},
18+
"slug": {
19+
"name": "slug",
20+
"type": "varchar(255)",
21+
"primaryKey": false,
22+
"notNull": true
23+
},
24+
"title": {
25+
"name": "title",
26+
"type": "varchar(255)",
27+
"primaryKey": false,
28+
"notNull": true
29+
},
30+
"description": {
31+
"name": "description",
32+
"type": "text",
33+
"primaryKey": false,
34+
"notNull": false
35+
},
36+
"venue": {
37+
"name": "venue",
38+
"type": "varchar(255)",
39+
"primaryKey": false,
40+
"notNull": false
41+
},
42+
"date": {
43+
"name": "date",
44+
"type": "timestamp",
45+
"primaryKey": false,
46+
"notNull": false
47+
},
48+
"time": {
49+
"name": "time",
50+
"type": "varchar(50)",
51+
"primaryKey": false,
52+
"notNull": false
53+
},
54+
"image": {
55+
"name": "image",
56+
"type": "bytea",
57+
"primaryKey": false,
58+
"notNull": false
59+
},
60+
"created_at": {
61+
"name": "created_at",
62+
"type": "timestamp",
63+
"primaryKey": false,
64+
"notNull": true,
65+
"default": "now()"
66+
},
67+
"updated_at": {
68+
"name": "updated_at",
69+
"type": "timestamp",
70+
"primaryKey": false,
71+
"notNull": true,
72+
"default": "now()"
73+
}
74+
},
75+
"indexes": {},
76+
"foreignKeys": {},
77+
"compositePrimaryKeys": {},
78+
"uniqueConstraints": {
79+
"events_slug_unique": {
80+
"name": "events_slug_unique",
81+
"nullsNotDistinct": false,
82+
"columns": [
83+
"slug"
84+
]
85+
}
86+
},
87+
"policies": {},
88+
"checkConstraints": {},
89+
"isRLSEnabled": false
90+
}
91+
},
92+
"enums": {},
93+
"schemas": {},
94+
"sequences": {},
95+
"roles": {},
96+
"policies": {},
97+
"views": {},
98+
"_meta": {
99+
"columns": {},
100+
"schemas": {},
101+
"tables": {}
102+
}
103+
}
Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
{
2+
"id": "25705929-cb65-4049-b6f1-7643afc54626",
3+
"prevId": "ad736958-666e-4bf8-bfa7-589187e6b44a",
4+
"version": "7",
5+
"dialect": "postgresql",
6+
"tables": {
7+
"public.events": {
8+
"name": "events",
9+
"schema": "",
10+
"columns": {
11+
"id": {
12+
"name": "id",
13+
"type": "uuid",
14+
"primaryKey": true,
15+
"notNull": true,
16+
"default": "gen_random_uuid()"
17+
},
18+
"slug": {
19+
"name": "slug",
20+
"type": "varchar(255)",
21+
"primaryKey": false,
22+
"notNull": true
23+
},
24+
"title": {
25+
"name": "title",
26+
"type": "varchar(255)",
27+
"primaryKey": false,
28+
"notNull": true
29+
},
30+
"description": {
31+
"name": "description",
32+
"type": "text",
33+
"primaryKey": false,
34+
"notNull": false
35+
},
36+
"venue": {
37+
"name": "venue",
38+
"type": "varchar(255)",
39+
"primaryKey": false,
40+
"notNull": false
41+
},
42+
"date": {
43+
"name": "date",
44+
"type": "timestamp",
45+
"primaryKey": false,
46+
"notNull": false
47+
},
48+
"time": {
49+
"name": "time",
50+
"type": "varchar(50)",
51+
"primaryKey": false,
52+
"notNull": false
53+
},
54+
"image_data": {
55+
"name": "image_data",
56+
"type": "bytea",
57+
"primaryKey": false,
58+
"notNull": false
59+
},
60+
"image_mime_type": {
61+
"name": "image_mime_type",
62+
"type": "varchar(100)",
63+
"primaryKey": false,
64+
"notNull": false
65+
},
66+
"created_at": {
67+
"name": "created_at",
68+
"type": "timestamp",
69+
"primaryKey": false,
70+
"notNull": true,
71+
"default": "now()"
72+
},
73+
"updated_at": {
74+
"name": "updated_at",
75+
"type": "timestamp",
76+
"primaryKey": false,
77+
"notNull": true,
78+
"default": "now()"
79+
}
80+
},
81+
"indexes": {},
82+
"foreignKeys": {},
83+
"compositePrimaryKeys": {},
84+
"uniqueConstraints": {
85+
"events_slug_unique": {
86+
"name": "events_slug_unique",
87+
"nullsNotDistinct": false,
88+
"columns": [
89+
"slug"
90+
]
91+
}
92+
},
93+
"policies": {},
94+
"checkConstraints": {},
95+
"isRLSEnabled": false
96+
}
97+
},
98+
"enums": {},
99+
"schemas": {},
100+
"sequences": {},
101+
"roles": {},
102+
"policies": {},
103+
"views": {},
104+
"_meta": {
105+
"columns": {},
106+
"schemas": {},
107+
"tables": {}
108+
}
109+
}

drizzle/migrations/meta/_journal.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,20 @@
88
"when": 1758033961329,
99
"tag": "0000_ordinary_doctor_faustus",
1010
"breakpoints": true
11+
},
12+
{
13+
"idx": 1,
14+
"version": "7",
15+
"when": 1758693572190,
16+
"tag": "0001_small_thunderbolt",
17+
"breakpoints": true
18+
},
19+
{
20+
"idx": 2,
21+
"version": "7",
22+
"when": 1758694663525,
23+
"tag": "0002_wakeful_jasper_sitwell",
24+
"breakpoints": true
1125
}
1226
]
1327
}

package-lock.json

Lines changed: 22 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@
2020
"release:major": "standard-version --release-as major",
2121
"bundlesize": "bundlesize",
2222
"Docker-build": "docker build -t nextjs_tempalate .",
23-
"Docker-run": "docker run -p 3000:3000 nextjs_tempalate"
23+
"Docker-run": "docker run -p 3000:3000 nextjs_tempalate",
24+
"seed": "tsx src/lib/db/seed.ts"
2425
},
2526
"dependencies": {
2627
"@neondatabase/serverless": "^1.0.1",
@@ -32,6 +33,7 @@
3233
"firebase-admin": "^13.5.0",
3334
"lucide-react": "^0.542.0",
3435
"next": "15.5.2",
36+
"node-fetch": "^2.7.0",
3537
"pg": "^8.16.3",
3638
"pino": "^9.9.0",
3739
"prom-client": "^15.1.3",
@@ -66,6 +68,7 @@
6668
"standard-version": "^9.5.0",
6769
"tailwindcss": "^4",
6870
"ts-jest": "^29.4.1",
71+
"tsx": "^4.20.5",
6972
"typescript": "^5"
7073
}
7174
}

scripts/test-image-upload.js

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
const fs = require('fs');
2+
const FormData = require('form-data');
3+
const fetch = require('node-fetch');
4+
const path = require('path');
5+
6+
// Test image path - using a sample image from the public directory
7+
const testImagePath = path.join(__dirname, '../public/codecompass.png');
8+
const API_BASE_URL = 'http://localhost:3000/api';
9+
10+
async function testImageUpload() {
11+
try {
12+
console.log('Starting image upload test...');
13+
14+
// 1. Create a new event with an image
15+
const formData = new FormData();
16+
formData.append('title', 'Test Event with Image');
17+
formData.append('description', 'This is a test event with an image');
18+
formData.append('venue', 'Test Venue');
19+
formData.append('date', new Date().toISOString());
20+
formData.append('time', '15:00');
21+
formData.append('image', fs.createReadStream(testImagePath));
22+
23+
console.log('Creating new event with image...');
24+
const createResponse = await fetch(`${API_BASE_URL}/events`, {
25+
method: 'POST',
26+
body: formData,
27+
});
28+
29+
if (!createResponse.ok) {
30+
const error = await createResponse.text();
31+
throw new Error(`Failed to create event: ${error}`);
32+
}
33+
34+
const createdEvent = await createResponse.json();
35+
console.log('✅ Event created successfully:', createdEvent.id);
36+
console.log('Event image data:', createdEvent.imageData ? 'Image exists' : 'No image');
37+
38+
// 2. Get the created event
39+
console.log('\nFetching created event...');
40+
const getResponse = await fetch(`${API_BASE_URL}/events/${createdEvent.id}`);
41+
42+
if (!getResponse.ok) {
43+
throw new Error('Failed to fetch created event');
44+
}
45+
46+
const fetchedEvent = await getResponse.json();
47+
console.log('✅ Event retrieved successfully');
48+
console.log('Fetched event image data:', fetchedEvent.imageData ? 'Image exists' : 'No image');
49+
50+
// 3. Get all events
51+
console.log('\nFetching all events...');
52+
const getAllResponse = await fetch(`${API_BASE_URL}/events`);
53+
54+
if (!getAllResponse.ok) {
55+
throw new Error('Failed to fetch all events');
56+
}
57+
58+
const allEvents = await getAllResponse.json();
59+
console.log(`✅ Retrieved ${allEvents.length} events`);
60+
console.log('First event image data:', allEvents[0]?.imageData ? 'Image exists' : 'No image');
61+
62+
console.log('\n✅ All tests passed successfully!');
63+
console.log('You can check the event data in your database or via the API endpoints.');
64+
65+
} catch (error) {
66+
console.error('❌ Test failed:', error.message);
67+
process.exit(1);
68+
}
69+
}
70+
71+
testImageUpload();

0 commit comments

Comments
 (0)