-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfix_ts_errors.js
More file actions
34 lines (27 loc) · 886 Bytes
/
Copy pathfix_ts_errors.js
File metadata and controls
34 lines (27 loc) · 886 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
const fs = require('fs');
const pageTsxPath = 'frontend/app/dashboard/backgrounds/page.tsx';
let pageTsx = fs.readFileSync(pageTsxPath, 'utf8');
// 1. Fix toast import
pageTsx = pageTsx.replace(
/import \{ toast \} from "react-hot-toast"/,
'import { toast } from "sonner"'
);
// 2. Fix data types
pageTsx = pageTsx.replace(
/const data = await res\.json\(\)/,
'const data = (await res.json()) as any'
);
pageTsx = pageTsx.replace(
/const orderData = await orderRes\.json\(\)/,
'const orderData = (await orderRes.json()) as any'
);
pageTsx = pageTsx.replace(
/const verifyData = await verifyRes\.json\(\)/,
'const verifyData = (await verifyRes.json()) as any'
);
// 3. Fix getPrice call
pageTsx = pageTsx.replace(
/getPrice\(componentData\.price\)/g,
"`${getPrice('component').symbol}${getPrice('component').value}`"
);
fs.writeFileSync(pageTsxPath, pageTsx);