Skip to content

Commit ed882c6

Browse files
committed
No syntax errors
1 parent ec3bcaa commit ed882c6

File tree

14 files changed

+217
-153
lines changed

14 files changed

+217
-153
lines changed

CONTRIBUTING.md

Lines changed: 48 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,51 @@
1-
# CONTRIBUTORS GUIDE
1+
# Contributing to Learn.tg
22

3+
Thank you for your interest in contributing to Learn.tg! 🎯
34

4-
## Run the server backend
5-
Please check instructions in [servidor/README.md](servidor/README.md)
5+
## 📋 Code of Conduct
6+
By participating in this project, you agree to maintain a respectful and collaborative environment.
67

7-
## Run the client frontend
8-
Please check instructions in [packages/nextjs-app/README.md](packages/nextjs-app/README.md)
8+
## 🚀 Development Setup
9+
10+
### Backend (Rails Server)
11+
See instructions in [servidor/README.md](servidor/README.md)
12+
13+
### Frontend (Next.js App)
14+
See instructions in [packages/nextjs-app/README.md](packages/nextjs-app/README.md)
15+
16+
## 🔄 Contributing Process
17+
18+
1. **Fork** the repository
19+
2. **Create a branch** from `main`: `git checkout -b feature/my-feature`
20+
3. **Make your changes** following the style guides
21+
4. **Run tests**: `make syntax` and `npm test`
22+
5. **Commit** with clear messages: `git commit -m "feat: add feature X"`
23+
6. **Push** and create a **Pull Request**
24+
25+
## 📝 Code Standards
26+
27+
- **TypeScript**:
28+
- Use explicit types, avoid `any` when possible
29+
- Don´t use ; at the end of the lines
30+
- **Tests**: Include tests for new functionality
31+
- **Commits**: Use [Conventional Commits](https://conventionalcommits.org/): `feat:`, `fix:`, `docs:`
32+
- **Linting**: Code must pass `make syntax` without errors
33+
34+
## 🐛 Reporting Bugs
35+
36+
1. Check that no similar issue exists
37+
2. Include steps to reproduce the problem
38+
3. Specify browser/Node.js versions
39+
4. Attach logs or screenshots if relevant
40+
41+
## 💡 Suggesting Features
42+
43+
1. Open an issue describing the feature
44+
2. Explain the use case and benefits
45+
3. Discuss implementation before starting to code
46+
47+
## ❓ Getting Help
48+
49+
- **Issues**: For bugs and suggestions
50+
- **Discussions**: For general questions
51+
- **Documentation**: Check README files for each component

packages/nextjs-app/Makefile

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,15 @@ all:
33
pnpm i
44
pnpm build
55

6-
dev:
7-
./bin/dev
8-
96
syntax:
107
pnpm typecheck
118

9+
test:
10+
pnpm test
11+
12+
dev:
13+
./bin/dev
14+
1215
prod:
1316
pnpm build
1417
./bin/start > prod.log 2>&1 &

packages/nextjs-app/app/[lang]/[pathPrefix]/[pathSuffix]/page.tsx

Lines changed: 24 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
"use client"
22

3-
import axios from 'axios';
3+
import axios from 'axios'
44

5-
import { ClaimSDK, IdentitySDK } from '@goodsdks/citizen-sdk';
6-
import { type PublicClient, type WalletClient } from 'viem';
7-
import { Session } from "next-auth";
5+
import { ClaimSDK, IdentitySDK } from '@goodsdks/citizen-sdk'
6+
import { type PublicClient, type WalletClient } from 'viem'
87
import { useSession, getCsrfToken } from "next-auth/react"
9-
import { use, useEffect, useState } from 'react'
8+
import { use, useEffect, useState, useCallback } from 'react'
109
import Link from 'next/link'
1110
import remarkDirective from 'remark-directive'
1211
import remarkFrontmatter from 'remark-frontmatter'
@@ -15,7 +14,7 @@ import remarkParse from 'remark-parse'
1514
import remarkRehype from 'remark-rehype'
1615
import rehypeStringify from 'rehype-stringify'
1716
import {unified} from 'unified'
18-
import { usePublicClient, useWalletClient } from 'wagmi';
17+
import { usePublicClient, useWalletClient } from 'wagmi'
1918
import { useAccount } from 'wagmi'
2019

2120
import { remarkFillInTheBlank } from '@/lib/remarkFillInTheBlank.mjs'
@@ -30,7 +29,7 @@ export default function Page({params} : {
3029
}) {
3130

3231
const { address } = useAccount()
33-
const { data: session } = useSession();
32+
const { data: session } = useSession()
3433

3534
const [course, setCourse] = useState({
3635
conBilletera: false,
@@ -39,10 +38,10 @@ export default function Page({params} : {
3938
titulo: "",
4039
sinBilletera: false,
4140
})
42-
const [guideNumber, setGuideNumber] = useState(0);
41+
const [guideNumber, setGuideNumber] = useState(0)
4342
const [myGuide, setMyGuide] = useState({
4443
titulo: "",
45-
});
44+
})
4645
const [coursePath, setCoursePath] = useState("")
4746
const [nextGuidePath, setNextGuidePath] = useState("")
4847
const [previousGuidePath, setPreviousGuidePath] = useState("")
@@ -59,7 +58,7 @@ export default function Page({params} : {
5958
const configurar = async () => {
6059
setIsClient(true)
6160
setCoursePath(`/${lang}/${pathPrefix}`)
62-
const url = `${process.env.NEXT_PUBLIC_API_BUSCA_CURSOS_URL}?` +
61+
let url = `${process.env.NEXT_PUBLIC_API_BUSCA_CURSOS_URL}?` +
6362
`filtro[busprefijoRuta]=/${pathPrefix}&` +
6463
`filtro[busidioma]=${lang}`
6564
const csrfToken = await getCsrfToken()
@@ -102,7 +101,7 @@ export default function Page({params} : {
102101
let gnumber = 0
103102
for(let g=0; g < dcurso.guias.length; g++) {
104103
if (dcurso.guias[g].sufijoRuta == (pathSuffix)) {
105-
setGuideNumber(g + 1);
104+
setGuideNumber(g + 1)
106105
gnumber = g + 1
107106
setMyGuide(dcurso.guias[g])
108107
}
@@ -149,42 +148,42 @@ export default function Page({params} : {
149148
}
150149
})
151150
.catch(error => {
152-
console.error(error);
151+
console.error(error)
153152
})
154153
}
155154
})
156155
.catch(error => {
157-
console.error(error);
156+
console.error(error)
158157
})
159158
}
160159
})
161160
.catch(error => {
162-
console.error(error);
161+
console.error(error)
163162
})
164163
}
165164
configurar()
166165
}, [session, address])
167166

168-
169167
const parameters = use(params)
170168
const { lang, pathPrefix, pathSuffix } = parameters
171169

172170

173-
const htmlDeMd = (md: string) => {
171+
const htmlDeMd = useCallback((md: string) => {
174172
const processor = unified()
175173
.use(remarkParse)
176174
.use(remarkGfm)
177175
.use(remarkDirective)
178176
.use(remarkFrontmatter)
179177
.use(remarkFillInTheBlank, { url: `${pathSuffix}/test` })
178+
// @ts-ignore
180179
.use(remarkRehype, { allowDangerousHtml: true })
181180
.use(rehypeStringify, { allowDangerousHtml: true })
182181
const html = processor.processSync(md).toString()
183182

184183
// Save questions
185184
localStorage.setItem(
186185
'fillInTheBlank',
187-
JSON.stringify( window.fillInTheBlank || [] )
186+
JSON.stringify( (window as Window & { fillInTheBlank?: any[] }).fillInTheBlank || [] )
188187
)
189188

190189
// Agregamos estilo
@@ -232,17 +231,17 @@ export default function Page({params} : {
232231
)
233232

234233
return html_con_tailwind
235-
}
234+
}, [pathSuffix])
236235

237-
const publicClient = usePublicClient();
238-
const { data: walletClient } = useWalletClient();
236+
const publicClient = usePublicClient()
237+
const { data: walletClient } = useWalletClient()
239238
const identitySDK = process.env.NEXT_PUBLIC_AUTH_URL == "https://learn.tg" ?
240239
new IdentitySDK({
241240
env: 'production',
242241
publicClient: publicClient as PublicClient,
243242
walletClient: walletClient as WalletClient
244243
}) :
245-
null;
244+
null
246245

247246
const claimUBI = async () => {
248247
if (!session || !address || session.address != address ||
@@ -256,36 +255,13 @@ export default function Page({params} : {
256255
walletClient,
257256
identitySDK,
258257
env: 'production',
259-
});
260-
261-
try {
262-
await claimSDK.claim();
263-
console.log('Claim successful');
264-
} catch (error) {
265-
console.error('Claim failed:', error);
266-
}
267-
}
268-
269-
270-
const claimUBI = async () => {
271-
272-
if (!session || !address || session.address != address ||
273-
!publicClient || !walletClient || !identitySDK) {
274-
return (<div>Works only with wallet connected</div>)
275-
}
276-
const claimSDK = new ClaimSDK({
277-
account: session.address,
278-
publicClient,
279-
walletClient,
280-
identitySDK,
281-
env: 'production',
282-
});
258+
})
283259

284260
try {
285-
await claimSDK.claim();
286-
console.log('Claim successful');
261+
await claimSDK.claim()
262+
console.log('Claim successful')
287263
} catch (error) {
288-
console.error('Claim failed:', error);
264+
console.error('Claim failed:', error)
289265
}
290266
}
291267

0 commit comments

Comments
 (0)