Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion apps/cli/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@c0upons/cli",
"version": "1.10.0",
"version": "1.10.1",
"description": "c0upons CLI — search, submit, and manage coupons from the terminal",
"type": "module",
"bin": {
Expand Down
89 changes: 88 additions & 1 deletion apps/web/app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,48 @@ async function getTrendingCoupons(): Promise<Coupon[]> {
}
}

/**
* The newest coupons, so a deal is on the homepage the hour it lands instead of
* waiting for votes. Grocery weekly-ad prices (source 'flipp') are left out:
* they arrive by the hundreds every few minutes and would be all this showed.
*/
async function getJustAdded(): Promise<Coupon[]> {
try {
const db = getDb();
const today = new Date().toISOString().slice(0, 10);
return await db.sql`
SELECT c.*, s.name AS store_name, s.slug AS store_slug, s.logo_url AS store_logo
FROM coupons c
JOIN stores s ON s.id = c.store_id
WHERE (c.source IS NULL OR c.source <> 'flipp')
AND (c.expiry_date IS NULL OR c.expiry_date = '' OR c.expiry_date >= ${today})
ORDER BY c.id DESC
LIMIT 8
`;
} catch {
return [];
}
}

/** Codes software founders list on PeerPush (lib/peerpush-sync.ts, read daily), newest deal first. */
async function getPeerpushDeals(): Promise<Coupon[]> {
try {
const db = getDb();
const today = new Date().toISOString().slice(0, 10);
return await db.sql`
SELECT c.*, s.name AS store_name, s.slug AS store_slug, s.logo_url AS store_logo
FROM coupons c
JOIN stores s ON s.id = c.store_id
WHERE c.source = 'peerpush'
AND (c.expiry_date IS NULL OR c.expiry_date = '' OR c.expiry_date >= ${today})
ORDER BY c.created_at DESC, c.id DESC
LIMIT 8
`;
} catch {
return [];
}
}

async function getTopStores(): Promise<StoreWithCount[]> {
try {
const db = getDb();
Expand Down Expand Up @@ -116,8 +158,10 @@ export async function generateMetadata(): Promise<Metadata> {
}

export default async function HomePage() {
const [coupons, stores, stats] = await Promise.all([
const [coupons, justAdded, peerpush, stores, stats] = await Promise.all([
getTrendingCoupons(),
getJustAdded(),
getPeerpushDeals(),
getTopStores(),
getStats(),
]);
Expand Down Expand Up @@ -190,6 +234,49 @@ export default async function HomePage() {
)}
</section>

{/* Just added */}
{justAdded.length > 0 && (
<section>
<div className="flex items-center justify-between mb-5">
<div>
<h2 className="text-xl font-bold text-gray-900">Just Added</h2>
<p className="text-sm text-gray-500 mt-0.5">The newest codes, before anyone has voted on them</p>
</div>
</div>
<div className="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-4">
{justAdded.map((c) => (
<CouponCard key={c.id} coupon={c} />
))}
</div>
</section>
)}

{/* Software deals from PeerPush */}
{peerpush.length > 0 && (
<section>
<div className="flex items-center justify-between mb-5">
<div>
<h2 className="text-xl font-bold text-gray-900">Software Deals</h2>
<p className="text-sm text-gray-500 mt-0.5">
Codes founders list on{' '}
<a href="https://peerpush.com/deals" className="hover:underline" rel="noopener">
PeerPush
</a>
, refreshed daily
</p>
</div>
<Link href="/search?q=PeerPush" className="text-sm font-medium text-orange-500 hover:text-orange-600 transition-colors">
View all →
</Link>
</div>
<div className="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-4">
{peerpush.map((c) => (
<CouponCard key={c.id} coupon={c} />
))}
</div>
</section>
)}

{/* Top Stores */}
<section>
<div className="flex items-center justify-between mb-5">
Expand Down
2 changes: 1 addition & 1 deletion apps/web/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@c0upons/web",
"version": "1.10.0",
"version": "1.10.1",
"private": true,
"type": "module",
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion apps/web/public/cli/c0upons
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

set -euo pipefail

VERSION="1.10.0"
VERSION="1.10.1"
BASE_URL="${C0UPONS_API:-https://c0upons.com/api}"
# Website root (for login + share links). Defaults to BASE_URL without /api.
WEB_URL="${C0UPONS_WEB:-${BASE_URL%/api}}"
Expand Down
4 changes: 2 additions & 2 deletions bun.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "c0upons",
"version": "1.10.0",
"version": "1.10.1",
"private": true,
"type": "module",
"packageManager": "bun@1.4.4",
Expand Down
Loading