@@ -2,7 +2,7 @@ import React, { useRef, useState } from "react";
2
2
import { View } from "react-native" ;
3
3
import { useRouter } from "expo-router" ;
4
4
import { useForm } from "@tanstack/react-form" ;
5
- import { useMutation } from "@tanstack/react-query" ;
5
+ import { useMutation , useQuery } from "@tanstack/react-query" ;
6
6
import { toast } from "sonner-native" ;
7
7
8
8
import type { ConstsTypes } from "@1up/consts" ;
@@ -12,21 +12,28 @@ import { ImagePickerUploader } from "~/components/ui/image-picker-uploader";
12
12
import { Text } from "~/components/ui/text" ;
13
13
import { Textarea } from "~/components/ui/textarea" ;
14
14
import { trpc } from "~/utils/api" ;
15
+ import { Button } from "../ui/button" ;
15
16
import { LogStepWrapper } from "./logStepWrapper" ;
16
17
18
+ // Use the proper type from consts
19
+ type TrackableParentType = ConstsTypes [ "TRACKABLE" ] [ "TYPES" ] [ "KEY" ] ;
20
+ type TrackableSubType = ConstsTypes [ "TRACKABLE" ] [ "SUB_TYPES" ] [ "KEY" ] ;
21
+
17
22
// Lookup data for different trackable types
18
23
interface TrackableOptions {
19
24
textAreaPlaceholders : string [ ] ;
20
25
generalName : string ;
21
26
textAreaLabel : string ;
22
27
tipText : string ;
23
28
title : string ;
29
+ new : {
30
+ name : string ;
31
+ description : string ;
32
+ icon : string ;
33
+ subType : TrackableSubType ;
34
+ } [ ] ;
24
35
}
25
36
26
- // Use the proper type from consts
27
- type TrackableParentType = ConstsTypes [ "TRACKABLE" ] [ "TYPES" ] [ "KEY" ] ;
28
- type TrackableSubType = ConstsTypes [ "TRACKABLE" ] [ "SUB_TYPES" ] [ "KEY" ] ;
29
-
30
37
const trackableLookup : Record < TrackableParentType , TrackableOptions > = {
31
38
consumption : {
32
39
textAreaPlaceholders : [
@@ -41,6 +48,26 @@ const trackableLookup: Record<TrackableParentType, TrackableOptions> = {
41
48
tipText :
42
49
"Be as detailed as possible about the components and size of this meal/drink." ,
43
50
title : "Food & Drink" ,
51
+ new : [
52
+ {
53
+ name : "Nom npm" ,
54
+ description : "Log your food and drink" ,
55
+ icon : "🍽️" ,
56
+ subType : "consumption.parent.other" ,
57
+ } ,
58
+ {
59
+ name : "Lala" ,
60
+ description : "Log your food and drink" ,
61
+ icon : "🍽️" ,
62
+ subType : "consumption.parent.other" ,
63
+ } ,
64
+ {
65
+ name : "ooooo" ,
66
+ description : "Log your food and drink" ,
67
+ icon : "🍽️" ,
68
+ subType : "consumption.parent.other" ,
69
+ } ,
70
+ ] ,
44
71
} ,
45
72
activity : {
46
73
textAreaPlaceholders : [
@@ -55,6 +82,7 @@ const trackableLookup: Record<TrackableParentType, TrackableOptions> = {
55
82
tipText :
56
83
"Include details like duration, intensity, and any other relevant information." ,
57
84
title : "Physical Activity" ,
85
+ new : [ ] ,
58
86
} ,
59
87
medication : {
60
88
textAreaPlaceholders : [
@@ -68,6 +96,7 @@ const trackableLookup: Record<TrackableParentType, TrackableOptions> = {
68
96
textAreaLabel : "What medication did you take?" ,
69
97
tipText : "Include details like dosage, frequency, and any side effects." ,
70
98
title : "Medication" ,
99
+ new : [ ] ,
71
100
} ,
72
101
supplement : {
73
102
textAreaPlaceholders : [
@@ -82,6 +111,7 @@ const trackableLookup: Record<TrackableParentType, TrackableOptions> = {
82
111
tipText :
83
112
"Include details like dosage, brand if relevant, and when you took it." ,
84
113
title : "Supplement" ,
114
+ new : [ ] ,
85
115
} ,
86
116
energy : {
87
117
textAreaPlaceholders : [
@@ -96,6 +126,7 @@ const trackableLookup: Record<TrackableParentType, TrackableOptions> = {
96
126
tipText :
97
127
"Note any patterns or factors that might be affecting your energy levels." ,
98
128
title : "Energy" ,
129
+ new : [ ] ,
99
130
} ,
100
131
blood : {
101
132
textAreaPlaceholders : [
@@ -109,6 +140,7 @@ const trackableLookup: Record<TrackableParentType, TrackableOptions> = {
109
140
textAreaLabel : "What blood metric are you logging?" ,
110
141
tipText : "Include specific measurements, units, and context if available." ,
111
142
title : "Blood Reading" ,
143
+ new : [ ] ,
112
144
} ,
113
145
body : {
114
146
textAreaPlaceholders : [
@@ -122,6 +154,7 @@ const trackableLookup: Record<TrackableParentType, TrackableOptions> = {
122
154
textAreaLabel : "What would you like to record about your body?" ,
123
155
tipText : "Include specific measurements with units where applicable." ,
124
156
title : "Body" ,
157
+ new : [ ] ,
125
158
} ,
126
159
sleep : {
127
160
textAreaPlaceholders : [
@@ -136,6 +169,7 @@ const trackableLookup: Record<TrackableParentType, TrackableOptions> = {
136
169
tipText :
137
170
"Include details about duration, quality, and any factors affecting your sleep." ,
138
171
title : "Sleep" ,
172
+ new : [ ] ,
139
173
} ,
140
174
mind : {
141
175
textAreaPlaceholders : [
@@ -150,6 +184,7 @@ const trackableLookup: Record<TrackableParentType, TrackableOptions> = {
150
184
tipText :
151
185
"Share details about your mental wellbeing, practices, or observations." ,
152
186
title : "Mind" ,
187
+ new : [ ] ,
153
188
} ,
154
189
symptom : {
155
190
textAreaPlaceholders : [
@@ -164,6 +199,7 @@ const trackableLookup: Record<TrackableParentType, TrackableOptions> = {
164
199
tipText :
165
200
"Include details about severity, duration, and any potential triggers." ,
166
201
title : "Symptom" ,
202
+ new : [ ] ,
167
203
} ,
168
204
custom : {
169
205
textAreaPlaceholders : [
@@ -177,6 +213,7 @@ const trackableLookup: Record<TrackableParentType, TrackableOptions> = {
177
213
textAreaLabel : "What would you like to log?" ,
178
214
tipText : "Add any relevant details that you want to track." ,
179
215
title : "Custom Log" ,
216
+ new : [ ] ,
180
217
} ,
181
218
} ;
182
219
@@ -209,6 +246,17 @@ export const TrackableLogStep = ({
209
246
} : TrackableLogStepProps ) => {
210
247
const lookupValues = getLookupValues ( trackableParentType ) ;
211
248
249
+ // get user profile
250
+ const {
251
+ data : parentTrackableTypes ,
252
+ // isLoading: parentTrackableTypesLoading,
253
+ // error: parentTrackableTypesError,
254
+ } = useQuery (
255
+ trpc . log . getTrackableParentTypes . queryOptions ( {
256
+ trackableParentType,
257
+ } ) ,
258
+ ) ;
259
+
212
260
// Text related
213
261
const [ placeholder ] = useState (
214
262
lookupValues . textAreaPlaceholders [
@@ -348,6 +396,33 @@ export const TrackableLogStep = ({
348
396
onSubmit = { handleSubmit }
349
397
submitting = { isFormSubmitting }
350
398
/>
399
+
400
+ < Text className = "text-sand-11 text-sm" >
401
+ Existing TRACKERS { parentTrackableTypes ?. length }
402
+ </ Text >
403
+ { parentTrackableTypes ?. map ( ( trackable ) => (
404
+ < Text key = { trackable . id } className = "text-sand-11 text-sm" >
405
+ { trackable . name }
406
+ </ Text >
407
+ ) ) }
408
+
409
+ { lookupValues . new . length > 0 && (
410
+ < Text className = "text-sand-11 text-sm" >
411
+ Track something new with a template
412
+ </ Text >
413
+ ) }
414
+ { lookupValues . new . map ( ( newTrackable ) => (
415
+ < Button
416
+ variant = { "outline" }
417
+ size = { "sm" }
418
+ key = { newTrackable . name }
419
+ onPress = { ( ) => {
420
+ console . log ( "pressed" ) ;
421
+ } }
422
+ >
423
+ < Text > { newTrackable . name } </ Text >
424
+ </ Button >
425
+ ) ) }
351
426
</ View >
352
427
</ LogStepWrapper >
353
428
) ;
0 commit comments