@learnpack/learnpack 5.0.172 → 5.0.178

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (33) hide show
  1. package/README.md +13 -13
  2. package/lib/commands/serve.js +42 -2
  3. package/lib/creatorDist/assets/index-BvrB0WCf.js +32991 -0
  4. package/{src/creatorDist/assets/index-C_YTggyk.css → lib/creatorDist/assets/index-CrWESWmj.css} +43 -11
  5. package/lib/creatorDist/index.html +2 -2
  6. package/lib/utils/api.js +1 -0
  7. package/lib/utils/readDocuments.d.ts +0 -0
  8. package/lib/utils/readDocuments.js +1 -0
  9. package/oclif.manifest.json +1 -1
  10. package/package.json +3 -1
  11. package/src/commands/serve.ts +56 -2
  12. package/src/creator/src/App.tsx +51 -33
  13. package/src/creator/src/components/ConsumablesManager.tsx +1 -0
  14. package/src/creator/src/components/FileUploader.tsx +64 -52
  15. package/src/creator/src/components/Login.tsx +172 -82
  16. package/src/creator/src/components/ResumeCourseModal.tsx +38 -0
  17. package/src/creator/src/components/StepWizard.tsx +12 -10
  18. package/src/creator/src/components/TurnstileChallenge.tsx +2 -7
  19. package/src/creator/src/components/syllabus/ContentIndex.tsx +1 -0
  20. package/src/creator/src/components/syllabus/SyllabusEditor.tsx +54 -20
  21. package/src/creator/src/utils/constants.ts +1 -0
  22. package/src/creator/src/utils/lib.ts +55 -0
  23. package/src/creator/src/utils/rigo.ts +11 -4
  24. package/src/creator/src/utils/store.ts +22 -1
  25. package/src/creatorDist/assets/index-BvrB0WCf.js +32991 -0
  26. package/{lib/creatorDist/assets/index-C_YTggyk.css → src/creatorDist/assets/index-CrWESWmj.css} +43 -11
  27. package/src/creatorDist/index.html +2 -2
  28. package/src/utils/api.ts +1 -0
  29. package/src/utils/readDocuments.ts +0 -0
  30. package/lib/creatorDist/assets/index-CCvMFC6N.js +0 -83701
  31. package/lib/creatorDist/assets/pdf.worker-DSVOJ9H9.js +0 -56037
  32. package/src/creatorDist/assets/index-CCvMFC6N.js +0 -83701
  33. package/src/creatorDist/assets/pdf.worker-DSVOJ9H9.js +0 -56037
@@ -1,7 +1,7 @@
1
1
  import React, { useState, useEffect } from "react"
2
2
  import { useShallow } from "zustand/react/shallow"
3
3
  import useStore from "../../utils/store"
4
- import { interactiveCreation } from "../../utils/rigo"
4
+ import { publicInteractiveCreation } from "../../utils/rigo"
5
5
  import {
6
6
  parseLesson,
7
7
  // useConsumableCall,
@@ -28,6 +28,27 @@ import { RIGO_FLOAT_GIT } from "../../utils/constants"
28
28
 
29
29
  const SyllabusEditor: React.FC = () => {
30
30
  const navigate = useNavigate()
31
+
32
+ const {
33
+ history,
34
+ auth,
35
+ setAuth,
36
+ push,
37
+ uploadedFiles,
38
+ cleanHistory,
39
+ formState,
40
+ } = useStore(
41
+ useShallow((state) => ({
42
+ history: state.history,
43
+ auth: state.auth,
44
+ setAuth: state.setAuth,
45
+ push: state.push,
46
+ uploadedFiles: state.uploadedFiles,
47
+ cleanHistory: state.cleanHistory,
48
+ formState: state.formState,
49
+ }))
50
+ )
51
+
31
52
  const [messages, setMessages] = useState<TMessage[]>([
32
53
  {
33
54
  type: "assistant",
@@ -43,26 +64,35 @@ const SyllabusEditor: React.FC = () => {
43
64
  const [showLoginModal, setShowLoginModal] = useState(false)
44
65
  const [isThinking, setIsThinking] = useState(false)
45
66
 
46
- const { history, auth, setAuth, push, uploadedFiles, cleanHistory } =
47
- useStore(
48
- useShallow((state) => ({
49
- history: state.history,
50
- auth: state.auth,
51
- setAuth: state.setAuth,
52
- push: state.push,
53
- uploadedFiles: state.uploadedFiles,
54
- cleanHistory: state.cleanHistory,
55
- }))
56
- )
57
-
58
67
  const syllabus = history[history.length - 1]
59
68
 
60
69
  useEffect(() => {
61
70
  if (!syllabus) {
62
71
  navigate("/creator", { replace: true })
72
+ } else {
63
73
  }
64
74
  }, [syllabus, navigate])
65
75
 
76
+ useEffect(() => {
77
+ console.log(formState.description, "DESCRIPTION")
78
+
79
+ if (formState.description) {
80
+ setMessages((prevMessages) => {
81
+ if (prevMessages.length === 0 || prevMessages[0].type !== "user") {
82
+ // Si no hay mensajes o el primero no es de usuario, lo agrego al inicio
83
+ return [
84
+ { type: "user", content: formState.description },
85
+ ...prevMessages,
86
+ ]
87
+ } else {
88
+ // Si el primero ya es de usuario, lo reemplazo y mantengo el resto
89
+ const [, ...rest] = prevMessages
90
+ return [{ type: "user", content: formState.description }, ...rest]
91
+ }
92
+ })
93
+ }
94
+ }, [formState.description])
95
+
66
96
  useEffect(() => {
67
97
  ;(async () => {
68
98
  const { token } = checkParams(["token"])
@@ -74,6 +104,7 @@ const SyllabusEditor: React.FC = () => {
74
104
  userId: user.id,
75
105
  rigoToken: user.rigobot.key,
76
106
  user,
107
+ publicToken: "",
77
108
  })
78
109
  }
79
110
  }
@@ -108,19 +139,22 @@ const SyllabusEditor: React.FC = () => {
108
139
  { type: "assistant", content: "" },
109
140
  ])
110
141
 
111
- const res = await interactiveCreation({
112
- courseInfo: `${JSON.stringify(syllabus.courseInfo)}
142
+ const res = await publicInteractiveCreation(
143
+ {
144
+ courseInfo: `${JSON.stringify(syllabus.courseInfo)}
113
145
  ${
114
146
  uploadedFiles.length > 0 &&
115
147
  "The user has uploaded files, take them in consideration while generating the course structure." +
116
148
  JSON.stringify(uploadedFiles)
117
149
  }
118
150
  `,
119
- prevInteractions:
120
- messages
121
- .map((message) => `${message.type}: ${message.content}`)
122
- .join("\n") + `\nUSER: ${prompt}`,
123
- })
151
+ prevInteractions:
152
+ messages
153
+ .map((message) => `${message.type}: ${message.content}`)
154
+ .join("\n") + `\nUSER: ${prompt}`,
155
+ },
156
+ auth.publicToken
157
+ )
124
158
 
125
159
  const lessons: Lesson[] = res.parsed.listOfSteps.map((step: any) =>
126
160
  parseLesson(step, syllabus.lessons)
@@ -1,4 +1,5 @@
1
1
  export const RIGOBOT_HOST = "https://rigobot.herokuapp.com"
2
+ // export const RIGOBOT_HOST = "https://rigobot-test-cca7d841c9d8.herokuapp.com"
2
3
  export const BREATHECODE_HOST = "https://breathecode.herokuapp.com"
3
4
 
4
5
  export const RIGO_FLOAT_GIT =
@@ -364,3 +364,58 @@ export const reWriteTitle = async (title: string, token: string) => {
364
364
  return `${title} ${Math.random().toString(36).substring(2, 6)}`
365
365
  }
366
366
  }
367
+
368
+ export async function registerUserWithFormData(
369
+ firstName: string,
370
+ lastName: string,
371
+ email: string
372
+ ): Promise<any> {
373
+ const formData = new FormData()
374
+ formData.append("1_first_name", firstName)
375
+ formData.append("1_last_name", lastName)
376
+ formData.append("1_email", email)
377
+
378
+ // Puedes modificar este objeto para agregar info real de tracking si la tienes.
379
+ const conversionArray = [
380
+ "$K1",
381
+ {
382
+ user_agent: navigator.userAgent,
383
+ landing_url: "www.learnpack.co/my-tutorials",
384
+ conversion_url: "app.learnpack.co/login",
385
+ translations: "$undefined",
386
+ utm_placement: "$undefined",
387
+ utm_referrer: "$undefined",
388
+ utm_medium: "$undefined",
389
+ utm_source: "$undefined",
390
+ utm_term: "$undefined",
391
+ utm_content: "$undefined",
392
+ utm_campaign: "$undefined",
393
+ internal_cta_placement: "$undefined",
394
+ internal_cta_content: "$undefined",
395
+ internal_cta_campaign: "$undefined",
396
+ },
397
+ ]
398
+
399
+ formData.append("0", JSON.stringify(conversionArray))
400
+
401
+ try {
402
+ const response = await axios.post(
403
+ "https://www.learnpack.co/register",
404
+ formData,
405
+ {
406
+ headers: {
407
+ "Content-Type": "multipart/form-data",
408
+ },
409
+ }
410
+ )
411
+ return response.data
412
+ } catch (error: any) {
413
+ // Manejo de errores básico
414
+ console.error(error, "ERROR REGISTERING IN LEARNPACK")
415
+ return {
416
+ success: false,
417
+ message: error?.response?.data?.detail || "Registration error",
418
+ data: error?.response?.data || null,
419
+ }
420
+ }
421
+ }
@@ -7,8 +7,9 @@ type TInteractiveCreationInputs = {
7
7
  prevInteractions: string
8
8
  }
9
9
 
10
- export const interactiveCreation = async (
11
- inputs: TInteractiveCreationInputs
10
+ export const publicInteractiveCreation = async (
11
+ inputs: TInteractiveCreationInputs,
12
+ publicToken: string
12
13
  ): Promise<any | null> => {
13
14
  try {
14
15
  const response = await axios.post(
@@ -21,6 +22,7 @@ export const interactiveCreation = async (
21
22
  {
22
23
  headers: {
23
24
  "Content-Type": "application/json",
25
+ Authorization: `Bearer ${publicToken}`,
24
26
  },
25
27
  }
26
28
  )
@@ -28,6 +30,7 @@ export const interactiveCreation = async (
28
30
  return response.data
29
31
  } catch (error: unknown) {
30
32
  const err = error as AxiosError
33
+ console.log("error", err)
31
34
 
32
35
  if (err.response?.status === 403) {
33
36
  toast.error("You've reached the limit. Please log in to continue.")
@@ -54,9 +57,13 @@ export const isHuman = async (token: string) => {
54
57
  }
55
58
  )
56
59
 
57
- return response.status === 200
60
+ return {
61
+ human: response.status === 200,
62
+ message: response.data.message,
63
+ token: response.data.public_access_token,
64
+ }
58
65
  } catch (error) {
59
66
  console.error(error)
60
- return false
67
+ return { human: false, message: error, token: null }
61
68
  }
62
69
  }
@@ -23,6 +23,7 @@ type Auth = {
23
23
  rigoToken: string
24
24
  userId: string
25
25
  user: any
26
+ publicToken: string
26
27
  }
27
28
  export type Syllabus = {
28
29
  lessons: Lesson[]
@@ -41,6 +42,8 @@ export type UploadedFile = {
41
42
  type Store = {
42
43
  auth: Auth
43
44
  formState: FormState
45
+ setFormState: (formState: Partial<FormState>) => void
46
+ resetFormState: () => void
44
47
  setAuth: (auth: Auth) => void
45
48
  // syllabus: Syllabus
46
49
  planToRedirect: string
@@ -53,7 +56,6 @@ type Store = {
53
56
  undo: () => void
54
57
  push: (syllabus: Syllabus) => void
55
58
  // setSyllabus: (syllabus: Partial<Syllabus>) => void
56
- setFormState: (formState: Partial<FormState>) => void
57
59
  consumables: Consumables
58
60
  setConsumables: (consumables: Partial<Consumables>) => void
59
61
  mode: "student" | "teacher"
@@ -68,6 +70,7 @@ const useStore = create<Store>()(
68
70
  rigoToken: "",
69
71
  userId: "",
70
72
  user: null,
73
+ publicToken: "",
71
74
  },
72
75
  planToRedirect: "learnpack-creator",
73
76
  setPlanToRedirect: (planToRedirect: string) => set({ planToRedirect }),
@@ -89,6 +92,24 @@ const useStore = create<Store>()(
89
92
  },
90
93
  setFormState: (formState: Partial<FormState>) =>
91
94
  set((state) => ({ formState: { ...state.formState, ...formState } })),
95
+ resetFormState: () =>
96
+ set({
97
+ formState: {
98
+ currentStep: "description",
99
+ description: "",
100
+ duration: 0,
101
+ targetAudience: "",
102
+ hasContentIndex: false,
103
+ contentIndex: "",
104
+ isCompleted: false,
105
+ variables: [
106
+ "description",
107
+ "duration",
108
+ "hasContentIndex",
109
+ "verifyHuman",
110
+ ],
111
+ },
112
+ }),
92
113
 
93
114
  setUploadedFiles: (uploadedFiles) =>
94
115
  set(() => ({