Skip to content

Commit fe73b5a

Browse files
committed
fix: resolve syntax error in customize page
1 parent 2133d85 commit fe73b5a

4 files changed

Lines changed: 15 additions & 55 deletions

File tree

app/customize/page.tsx

Lines changed: 3 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -83,52 +83,8 @@ export default function CustomizePage(): ReactElement {
8383
}
8484
}, []);
8585

86-
// ── buildQueryParams ──────────────────────────────────────────────────────
87-
88-
const buildQueryParams = useCallback((): string => {
89-
const params = new URLSearchParams();
90-
91-
if (hasUsername) {
92-
params.set('user', trimmedUsername);
93-
}
94-
95-
if (skipsCustomColors) {
96-
// Virtual themes always emit theme=<name> and skip custom color params.
97-
params.set('theme', theme);
98-
} else {
99-
const hasCustomColors = bgHex || accentHex || textHex;
100-
101-
// Custom hex colors take priority over theme
102-
if (!hasCustomColors) {
103-
params.set('theme', theme);
104-
}
105-
if (bgHex) params.set('bg', stripHash(bgHex));
106-
if (accentHex) params.set('accent', stripHash(accentHex));
107-
if (textHex) params.set('text', stripHash(textHex));
108-
}
109-
110-
if (scale !== 'linear') params.set('scale', scale);
111-
if (speed !== '8s') params.set('speed', speed);
112-
if (font) params.set('font', font);
113-
if (year) params.set('year', year);
114-
if (radius !== 8) params.set('radius', radius.toString());
115-
if (size !== 'medium') params.set('size', size);
116-
117-
if (hideTitle) params.set('hide_title', 'true');
118-
if (hideBackground) params.set('hide_background', 'true');
119-
if (hideStats) params.set('hide_stats', 'true');
120-
if (viewMode !== 'default') params.set('view', viewMode);
121-
if (deltaFormat !== 'percent') params.set('delta_format', deltaFormat);
122-
if (badgeWidth !== '') params.set('width', badgeWidth.toString());
123-
if (badgeHeight !== '') params.set('height', badgeHeight.toString());
124-
if (grace !== 1) params.set('grace', grace.toString());
125-
if (language !== 'en') params.set('lang', language);
126-
if (timezone !== 'UTC') params.set('tz', timezone);
127-
128-
return params.toString();
129-
}, [
130-
hasUsername,
131-
trimmedUsername,
86+
const queryString = buildQueryParams({
87+
username,
13288
theme,
13389
bgHex,
13490
accentHex,
@@ -149,9 +105,7 @@ export default function CustomizePage(): ReactElement {
149105
grace,
150106
language,
151107
timezone,
152-
]);
153-
154-
const queryString = buildQueryParams();
108+
});
155109
const previewSrc = `/api/streak?${queryString}`;
156110
const exportSnippet = getExportSnippet(exportFormat, queryString);
157111

app/customize/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ export interface CustomizeOptions {
8585
badgeHeight: number | '';
8686
grace: number;
8787
language: Language;
88+
timezone: Timezone;
8889
}
8990
export const TIMEZONES = [
9091
{ value: 'UTC', label: 'UTC (Default)' },

app/customize/utils.test.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
import { describe, it, expect } from 'vitest';
2-
import { stripHash, isValidHex, buildQueryParams } from './utils';
2+
import {
3+
stripHash,
4+
isValidHex,
5+
buildQueryParams,
6+
getExportSnippet,
7+
getPlaceholderSnippet,
8+
} from './utils';
39
import type { CustomizeOptions } from './types';
4-
import { describe, expect, it } from 'vitest';
5-
import { getExportSnippet, getPlaceholderSnippet } from './utils';
610

711
describe('Export Snippet utilities', () => {
812
const EXPECTED_BASE_URL = 'https://commitpulse.vercel.app/api/streak';
@@ -112,6 +116,7 @@ describe('Export Snippet utilities', () => {
112116
badgeHeight: '',
113117
grace: 1,
114118
language: 'en',
119+
timezone: 'UTC',
115120
};
116121

117122
it('returns minimal params with default values', () => {
@@ -179,10 +184,11 @@ describe('Export Snippet utilities', () => {
179184
badgeHeight: 400,
180185
grace: 2,
181186
language: 'es' as const,
187+
timezone: 'America/New_York' as const,
182188
};
183189
const result = buildQueryParams(options);
184190
expect(result).toBe(
185-
'user=testuser&theme=dark&scale=log&speed=4s&font=fira&year=2023&radius=12&size=large&hide_title=true&hide_background=true&hide_stats=true&view=monthly&delta_format=absolute&width=600&height=400&grace=2&lang=es'
191+
'user=testuser&theme=dark&scale=log&speed=4s&font=fira&year=2023&radius=12&size=large&hide_title=true&hide_background=true&hide_stats=true&view=monthly&delta_format=absolute&width=600&height=400&grace=2&lang=es&tz=America%2FNew_York'
186192
);
187193
});
188194
});

app/customize/utils.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
import type { CustomizeOptions, ExportFormat } from './types';
2-
const BADGE_BASE_URL = 'https://commitpulse.vercel.app/api/streak';
3-
import type { ExportFormat } from './types';
42

53
const BADGE_BASE_URL = `${process.env.NEXT_PUBLIC_SITE_URL ?? 'https://commitpulse.vercel.app'}/api/streak`;
64

@@ -113,6 +111,7 @@ export function buildQueryParams(options: CustomizeOptions): string {
113111
if (options.badgeHeight !== '') params.set('height', options.badgeHeight.toString());
114112
if (options.grace !== 1) params.set('grace', options.grace.toString());
115113
if (options.language !== 'en') params.set('lang', options.language);
114+
if (options.timezone !== 'UTC') params.set('tz', options.timezone);
116115

117116
return params.toString();
118117
}

0 commit comments

Comments
 (0)