Skip to content

Commit 6d0d9b8

Browse files
hh
1 parent 9f35ec9 commit 6d0d9b8

12 files changed

Lines changed: 396 additions & 304 deletions

File tree

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ server/changeStreamHandler.js
4141

4242
.vscode
4343
/rift
44-
prompt.md
4544
/.gpteng
4645
repomix-output.*
4746
/public/*

hooks/useSorting.ts

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -5,48 +5,48 @@ export type SortConfig = {
55
direction: 'ascending' | 'descending';
66
};
77

8-
export const useSorting = <T extends Record<string, any>>(data: T[]) => {
9-
const [sortConfig, setSortConfig] = useState<SortConfig>({
10-
key: null,
11-
direction: 'ascending'
12-
});
8+
export const useSorting = <T extends Record<string, any>>( data: T[] ) => {
9+
const [ sortConfig, setSortConfig ] = useState<SortConfig>( {
10+
key: null,
11+
direction: 'ascending'
12+
} );
1313

14-
const handleSort = (key: string) => {
14+
const handleSort = ( key: string ) => {
1515
let direction = 'ascending';
16-
if (sortConfig.key === key && sortConfig.direction === 'ascending') {
16+
if ( sortConfig.key === key && sortConfig.direction === 'ascending' ) {
1717
direction = 'descending';
1818
}
19-
setSortConfig( {key, direction: null});
19+
setSortConfig( { key, direction: "descending" } );
2020
};
2121

22-
const sortedData = useMemo(() => {
23-
if (!sortConfig.key) return data;
24-
25-
return [...data].sort((a, b) => {
26-
const valueA = a[sortConfig.key!];
27-
const valueB = b[sortConfig.key!];
28-
29-
const isNumericA = !isNaN(parseFloat(valueA));
30-
const isNumericB = !isNaN(parseFloat(valueB));
31-
32-
if (isNumericA && isNumericB) {
33-
const numericA = parseFloat(valueA);
34-
const numericB = parseFloat(valueB);
35-
return sortConfig.direction === 'ascending'
36-
? numericA - numericB
22+
const sortedData = useMemo( () => {
23+
if ( !sortConfig.key ) return data;
24+
25+
return [ ...data ].sort( ( a, b ) => {
26+
const valueA = a[ sortConfig.key! ];
27+
const valueB = b[ sortConfig.key! ];
28+
29+
const isNumericA = !isNaN( parseFloat( valueA ) );
30+
const isNumericB = !isNaN( parseFloat( valueB ) );
31+
32+
if ( isNumericA && isNumericB ) {
33+
const numericA = parseFloat( valueA );
34+
const numericB = parseFloat( valueB );
35+
return sortConfig.direction === 'ascending'
36+
? numericA - numericB
3737
: numericB - numericA;
3838
}
39-
40-
if (isNumericA) return sortConfig.direction === 'ascending' ? -1 : 1;
41-
if (isNumericB) return sortConfig.direction === 'descending' ? 1 : -1;
42-
43-
const result = String(valueA || '').localeCompare(String(valueB || ''));
39+
40+
if ( isNumericA ) return sortConfig.direction === 'ascending' ? -1 : 1;
41+
if ( isNumericB ) return sortConfig.direction === 'descending' ? 1 : -1;
42+
43+
const result = String( valueA || '' ).localeCompare( String( valueB || '' ) );
4444
return sortConfig.direction === 'ascending' ? result : -result;
45-
});
46-
}, [data, sortConfig]);
45+
} );
46+
}, [ data, sortConfig ] );
4747

48-
const getSortIcon = (key: string) => {
49-
if (sortConfig.key !== key) return null;
48+
const getSortIcon = ( key: string ) => {
49+
if ( sortConfig.key !== key ) return null;
5050
return sortConfig.direction === 'ascending' ? '▲' : '▼';
5151
};
5252

jsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"compilerOptions": {
3-
"jsx": "react",
3+
"jsx": "preserve",
44
"paths": {
55
"@/*": [
66
"./*"

middleware.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,9 +154,8 @@ export function middleware( request: NextRequest ) {
154154
}
155155

156156
export const config = {
157-
runtime: "nodejs",
158157
matcher: [
159158
"/yugioh/my-collection",
160159
"/api/Yugioh/:path*",
161-
],
160+
]
162161
};

next.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/** @type {import('next').NextConfig} */
22
const nextConfig = {
33
reactStrictMode: true,
4-
productionBrowserSourceMaps: false,
4+
productionBrowserSourceMaps: true,
55

66
async headers() {
77
return [

0 commit comments

Comments
 (0)