diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/Widget.tsx | 7 | ||||
| -rw-r--r-- | src/api/api.ts | 1 | ||||
| -rw-r--r-- | src/components/app-sidebar.tsx | 8 | ||||
| -rw-r--r-- | src/components/site-header.tsx | 6 | ||||
| -rw-r--r-- | src/components/ui/sheet.tsx | 5 | ||||
| -rw-r--r-- | src/lib/utils.ts | 25 | ||||
| -rw-r--r-- | src/main.tsx | 3 | ||||
| -rw-r--r-- | src/models/appSlice.ts | 2 | ||||
| -rw-r--r-- | src/models/bucketSlice.ts | 4 | ||||
| -rw-r--r-- | src/models/cashoutMethodSlice.ts | 8 | ||||
| -rw-r--r-- | src/models/questionSlice.ts | 16 | ||||
| -rw-r--r-- | src/models/transactionHistorySlice.ts | 2 | ||||
| -rw-r--r-- | src/models/upkQuestionSlice.ts | 9 | ||||
| -rw-r--r-- | src/pages/CashoutMethods.tsx | 1 | ||||
| -rw-r--r-- | src/pages/Community.tsx | 9 | ||||
| -rw-r--r-- | src/pages/Demographics.tsx | 4 | ||||
| -rw-r--r-- | src/pages/Offerwall.tsx | 50 | ||||
| -rw-r--r-- | src/pages/Questions.tsx | 36 | ||||
| -rw-r--r-- | src/pages/Support.tsx | 38 | ||||
| -rw-r--r-- | src/pages/TaskAttemptHistory.tsx | 2 | ||||
| -rw-r--r-- | src/pages/TransactionHistory.tsx | 6 |
21 files changed, 119 insertions, 123 deletions
diff --git a/src/Widget.tsx b/src/Widget.tsx index 0fc0dca..192e4e0 100644 --- a/src/Widget.tsx +++ b/src/Widget.tsx @@ -1,4 +1,4 @@ -import React, {useEffect} from 'react' +import {useEffect} from 'react' import {AppSidebar} from "@/components/app-sidebar" import {SiteHeader} from "@/components/site-header" import {SidebarInset, SidebarProvider} from "@/components/ui/sidebar" @@ -32,6 +32,7 @@ import {setUpkAnswers} from "@/models/userUpkAnswerSlice.ts"; import {setMarketplaceAnswers} from "@/models/userMarketplaceAnswerSlice.ts"; import {setUserProfile} from "@/models/userProfileSlice.ts"; import {setTaskStatuses} from "@/models/taskStatusSlice.ts" +import {App} from "@/models/app.ts" import './index.css'; @@ -39,7 +40,7 @@ import './index.css'; const Widget = () => { const dispatch = useAppDispatch() - const app = useAppSelector(state => state.app) + const app: App = useAppSelector(state => state.app) useEffect(() => { // https://fsb.generalresearch.com/{product_id}/offerwall/37d1da64/?country @@ -96,7 +97,7 @@ const Widget = () => { .then(res => { dispatch(setWallet(res.data.wallet as UserWalletBalance)) }) - .catch(err => { + .catch(() => { // TODO: Wallet mode is likely off }) diff --git a/src/api/api.ts b/src/api/api.ts index 2663f6a..ecc9e6d 100644 --- a/src/api/api.ts +++ b/src/api/api.ts @@ -14,6 +14,7 @@ import type { Configuration } from './configuration'; +// @ts-ignore import type { AxiosPromise, AxiosInstance, RawAxiosRequestConfig } from 'axios'; import globalAxios from 'axios'; // Some imports not used depending on template conditions diff --git a/src/components/app-sidebar.tsx b/src/components/app-sidebar.tsx index 9a13aff..c60bf17 100644 --- a/src/components/app-sidebar.tsx +++ b/src/components/app-sidebar.tsx @@ -1,6 +1,6 @@ "use client" -import * as React from "react" +import React from "react" import {CircleDollarSign, SquareStack} from "lucide-react" import {NavMain} from "@/components/nav-main" @@ -14,9 +14,9 @@ import { SidebarMenu, SidebarMenuButton, SidebarMenuItem, - useSidebar, } from "@/components/ui/sidebar" import {useAppDispatch, useAppSelector} from "@/hooks.ts"; +import {App} from "@/models/app.ts" import {setPage} from "@/models/appSlice.ts"; import {Badge} from "@/components/ui/badge.tsx"; import {useSelector} from "react-redux"; @@ -24,13 +24,11 @@ import {selectCashoutMethods} from "@/models/cashoutMethodSlice.ts"; import {selectTransactionHistory} from "@/models/transactionHistorySlice.ts"; export function AppSidebar({...props}: React.ComponentProps<typeof Sidebar>) { - const app = useAppSelector(state => state.app) + const app: App = useAppSelector(state => state.app) const dispatch = useAppDispatch() const cashoutMethods = useSelector(selectCashoutMethods) const transactionHistory = useSelector(selectTransactionHistory) - const {isMobile} = useSidebar() - return ( <Sidebar collapsible="offcanvas" {...props}> <SidebarHeader> diff --git a/src/components/site-header.tsx b/src/components/site-header.tsx index 25b3e52..dca4996 100644 --- a/src/components/site-header.tsx +++ b/src/components/site-header.tsx @@ -1,11 +1,11 @@ import {Separator} from "@/components/ui/separator" import {SidebarTrigger} from "@/components/ui/sidebar" -import React from "react"; import {useAppSelector} from "@/hooks.ts"; +import {App} from "@/models/app.ts" import {Offerwall} from "@/pages/Offerwall.tsx"; const SiteHeader = () => { - const app = useAppSelector(state => state.app) + const app: App = useAppSelector(state => state.app) return ( <header @@ -22,7 +22,7 @@ const SiteHeader = () => { {app.currentPage === 'questions' && "Profiling Questions"} {app.currentPage === 'demographics' && "User Demographics"} {app.currentPage === 'task_attempts' && "Task Attempts"} - {app.currentPage === 'cashouts' && "Cashout Methods"} + {app.currentPage === 'cashout_methods' && "Cashout Methods"} {app.currentPage === 'transaction_history' && 'Transaction History'} </h1> diff --git a/src/components/ui/sheet.tsx b/src/components/ui/sheet.tsx index 6906f5b..c142665 100644 --- a/src/components/ui/sheet.tsx +++ b/src/components/ui/sheet.tsx @@ -58,8 +58,9 @@ function SheetContent({ className={cn( "bg-background data-[state=open]:animate-in data-[state=closed]:animate-out fixed z-50 flex flex-col gap-4 shadow-lg transition ease-in-out data-[state=closed]:duration-300 data-[state=open]:duration-500", side === "right" && - "data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right inset-y-0 right-0 h-full w-3/4 border-l sm:max-w-sm", - side === "left" && + // "data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right inset-y-0 right-0 h-full w-3/4 border-l sm:max-w-sm", + "inset-y-0 right-0 h-full w-1/2 border-l data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right", + side === "left" && "data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left inset-y-0 left-0 h-full w-3/4 border-r sm:max-w-sm", side === "top" && "data-[state=closed]:slide-out-to-top data-[state=open]:slide-in-from-top inset-x-0 top-0 h-auto border-b", diff --git a/src/lib/utils.ts b/src/lib/utils.ts index ed75d2f..9fc0e6d 100644 --- a/src/lib/utils.ts +++ b/src/lib/utils.ts @@ -1,6 +1,5 @@ import {type ClassValue, clsx} from "clsx" import {twMerge} from "tailwind-merge" -import React from "react"; export function cn(...inputs: ClassValue[]) { return twMerge(clsx(inputs)) @@ -40,4 +39,28 @@ export function titleCase(str: string): string { .split(" ") .map(word => word.charAt(0).toUpperCase() + word.slice(1)) .join(" "); +} + +export enum Status { + UNKNOWN = 0, + ENTER = 1, + INCOMPLETE = 2, + COMPLETE = 3 +} + +export enum AdjustmentTypes { + ac = "ADJUSTED_TO_COMPLETE", + af = "ADJUSTED_TO_FAIL", + pa = "PAYOUT_ADJUSTMENT" +} + +export enum Source { + g = "GRS", + c = "Cint", + // "a" + d = "Dynata", + // "et" "f" + i = "Innovate", + // "l" "m" "n" "o" "e" "r" "pr" "p" "rd" "h" "s" "t" "u" + w = "WXET", }
\ No newline at end of file diff --git a/src/main.tsx b/src/main.tsx index 678f9a0..3dfd07a 100644 --- a/src/main.tsx +++ b/src/main.tsx @@ -2,7 +2,6 @@ import {createRoot} from 'react-dom/client' import {Widget} from './Widget' import {App} from "@/models/app.ts" import {Provider} from 'react-redux' -import React from 'react' import {store} from './store' import {setApp} from "@/models/appSlice.ts"; @@ -27,7 +26,7 @@ import {setApp} from "@/models/appSlice.ts"; leaderboard: Boolean(currentScript?.getAttribute("data-leaderboard")) || false, currentPage: "offerwall" - } + } as App store.dispatch(setApp(settings)) // Avoid adding the widget multiple times diff --git a/src/models/appSlice.ts b/src/models/appSlice.ts index b8c41c6..f2e2535 100644 --- a/src/models/appSlice.ts +++ b/src/models/appSlice.ts @@ -2,7 +2,7 @@ import {createSlice, PayloadAction} from '@reduxjs/toolkit' import {App, Page} from "@/models/app.ts" -const initialState = {} +const initialState: App = {} as App const appSlice = createSlice({ name: 'app', diff --git a/src/models/bucketSlice.ts b/src/models/bucketSlice.ts index 1a15263..995c14a 100644 --- a/src/models/bucketSlice.ts +++ b/src/models/bucketSlice.ts @@ -21,9 +21,5 @@ const bucketSlice = createSlice({ export const {setBuckets, bucketAdded} = bucketSlice.actions; export default bucketSlice.reducer -export const selectBucketsStatus = (state: RootState) => state.buckets.status -export const selectBucketsError = (state: RootState) => state.buckets.error -export const selectAllBuckets = (state: RootState) => state.buckets - export const selectBucketById = (state: RootState, bucketId: string | null) => state.buckets.find(bucket => bucket.id === bucketId)
\ No newline at end of file diff --git a/src/models/cashoutMethodSlice.ts b/src/models/cashoutMethodSlice.ts index a6d0211..8e3a957 100644 --- a/src/models/cashoutMethodSlice.ts +++ b/src/models/cashoutMethodSlice.ts @@ -12,7 +12,7 @@ const cashoutMethodSlice = createSlice({ setCashoutMethods(state, action: PayloadAction<CashoutMethodOut[]>) { return action.payload; }, - redeem: { + // redeemMethod: { // let res = {'status': false, 'msg': ''}; // let cashout_method = this.collection.getCashoutMethod(); // let req_amt = +this.ui.amount.val(); @@ -61,7 +61,7 @@ const cashoutMethodSlice = createSlice({ // res["status"] = true; // return res; // }, - } + // } } }) @@ -73,6 +73,8 @@ export default cashoutMethodSlice.reducer export const selectCashoutMethods = (state: RootState) => state.cashoutMethods export const selectFixedCashoutMethods = (state: RootState) => + // @ts-ignore state.cashoutMethods.filter(cm => cm.data.value_type === "fixed") export const selectVariableCashoutMethods = (state: RootState) => - state.cashoutMethods.filter(cm => cm.data.value_type === "variable") + // @ts-ignore + state.cashoutMethods.filter(cm => cm.data.value_type === "variable")
\ No newline at end of file diff --git a/src/models/questionSlice.ts b/src/models/questionSlice.ts index 3ef2218..9cba93e 100644 --- a/src/models/questionSlice.ts +++ b/src/models/questionSlice.ts @@ -6,7 +6,7 @@ import {assert} from "@/lib/utils.ts" import {Selector} from "react-redux"; export interface ProfileQuestion extends UpkQuestion { - active: false + active: boolean } const initialState: ProfileQuestion[] = [] @@ -20,7 +20,11 @@ const questionSlice = createSlice({ // }, setQuestions(state, action: PayloadAction<ProfileQuestion[]>) { const existingIds = new Set(state.map(q => q.question_id)); - const newQuestions = action.payload.filter(q => !existingIds.has(q.question_id)); + const newQuestions = action.payload.filter(q => !existingIds.has(q.question_id)).map((q) => ({ + ...q, + active: false, + })); + state.push(...newQuestions); }, questionAdded(state, action: PayloadAction<ProfileQuestion>) { @@ -72,9 +76,9 @@ export const makeSelectQuestionsByIds = (ids: string[]) => export const selectActiveQuestion = (state: RootState) => state.questions.find(i => i.active) export const selectAnswers = (state: RootState) => state.answers -export const selectFirstAvailableQuestion = createSelector( +export const selectFirstAvailableQuestion: Selector<RootState, ProfileQuestion | null> = createSelector( [selectQuestions, selectAnswers], - (questions, answers): Selector<RootState, ProfileQuestion | null> => { + (questions, answers) => { /* This is used when the app loads up the Questions page and we need to find the first Question that we'll present to the Respondent. @@ -99,9 +103,9 @@ export const selectFirstAvailableQuestion = createSelector( } ) -export const selectNextAvailableQuestion = createSelector( +export const selectNextAvailableQuestion: Selector<RootState, ProfileQuestion | null> = createSelector( [selectQuestions, selectAnswers], - (questions, answers): Selector<RootState, ProfileQuestion | null> => { + (questions, answers) => { /* This takes the current active position and finds the next available question to answer. diff --git a/src/models/transactionHistorySlice.ts b/src/models/transactionHistorySlice.ts index 71bbf0d..9d6a9a0 100644 --- a/src/models/transactionHistorySlice.ts +++ b/src/models/transactionHistorySlice.ts @@ -18,7 +18,7 @@ const transactionHistorySlice = createSlice({ } }) -export const {setBuckets, bucketAdded} = transactionHistorySlice.actions; +export const {setBuckets, transactionAdded} = transactionHistorySlice.actions; export default transactionHistorySlice.reducer export const selectTransactionHistory = (state: RootState) => state.transactionHistory diff --git a/src/models/upkQuestionSlice.ts b/src/models/upkQuestionSlice.ts index b99f508..79bef09 100644 --- a/src/models/upkQuestionSlice.ts +++ b/src/models/upkQuestionSlice.ts @@ -10,7 +10,8 @@ const upkQuestionSlice = createSlice({ initialState, reducers: { setUpkQuestions(state, action: PayloadAction<QuestionInfo[]>) { - const existingIds = new Set(state.map(q => q.question_id)); + console.log("setUpkQuestions:", state) + const existingIds = new Set(state.map(q => q.property_id)); const newQuestions = action.payload.filter(q => !existingIds.has(q.property_id)); state.push(...newQuestions); }, @@ -20,8 +21,4 @@ const upkQuestionSlice = createSlice({ export const { setUpkQuestions, } = upkQuestionSlice.actions; -export default upkQuestionSlice.reducer - -// We need to fetch the next available Question that either doesn't have an Answer, or the Answer -// isn't Answer.completed -export const selectUpkQuestions = (state: RootState) => state.questions
\ No newline at end of file +export default upkQuestionSlice.reducer
\ No newline at end of file diff --git a/src/pages/CashoutMethods.tsx b/src/pages/CashoutMethods.tsx index 9cb0f20..806c455 100644 --- a/src/pages/CashoutMethods.tsx +++ b/src/pages/CashoutMethods.tsx @@ -116,6 +116,7 @@ const CashoutMethodPreview: React.FC<{ cashout_method: CashoutMethodOut }> = ({c const [open, setOpen] = useState(false) const renderContent = () => { + // @ts-ignore switch (cashout_method.data.value_type) { case 'fixed': return <FixedCashoutMethodPreview cashout_method={cashout_method}/> diff --git a/src/pages/Community.tsx b/src/pages/Community.tsx index 9b49608..9313eb2 100644 --- a/src/pages/Community.tsx +++ b/src/pages/Community.tsx @@ -1,8 +1,7 @@ import React, {useEffect, useState} from 'react' -import {Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle} from "@/components/ui/card.tsx"; -import {CashoutMethodsResponse, WalletApi} from "@/api" -import {CashoutMethodOut} from "@/api"; +import {Card, CardContent, CardHeader} from "@/components/ui/card.tsx"; +import {CashoutMethodOut, CashoutMethodsResponse, WalletApi} from "@/api" import {useAppSelector} from "@/hooks.ts"; const CashoutMethodPreview: React.FC<{ cashout_method: CashoutMethodOut }> = ({cashout_method}) => { @@ -16,7 +15,7 @@ const CashoutMethodPreview: React.FC<{ cashout_method: CashoutMethodOut }> = ({c </CardHeader> <CardContent> - <img className="blur-xs grayscale" src={cashout_method.imageUrl}/> + <img className="blur-xs grayscale" src={cashout_method.image_url}/> </CardContent> </Card> ) @@ -41,7 +40,7 @@ const CommunityPage = () => { <div className="grid grid-cols-3 gap-1 p-1"> { cashoutMethods.map((m, index) => { - return <CashoutMethodPreview key={index} cashout_method={m} />; + return <CashoutMethodPreview key={index} cashout_method={m}/>; }) } </div> diff --git a/src/pages/Demographics.tsx b/src/pages/Demographics.tsx index f1de290..2031511 100644 --- a/src/pages/Demographics.tsx +++ b/src/pages/Demographics.tsx @@ -6,14 +6,14 @@ import { formatDistanceToNow } from 'date-fns' import {Card, CardContent, CardHeader} from "@/components/ui/card"; import {Calendar, MapPin, User, PersonStanding} from "lucide-react"; -import {BucketTask, UserProfile} from "@/api"; +import {UserProfileKnowledge, UserProfile} from "@/api"; import {ColumnDef, flexRender, getCoreRowModel, useReactTable} from "@tanstack/react-table"; import {Table, TableBody, TableCell, TableHead, TableHeader, TableRow} from "@/components/ui/table.tsx"; import {useAppSelector} from "@/hooks.ts"; export const UpkGrid = () => { - const columns: ColumnDef<BucketTask>[] = [ + const columns: ColumnDef<UserProfileKnowledge>[] = [ { accessorKey: "property_label", header: "Label", diff --git a/src/pages/Offerwall.tsx b/src/pages/Offerwall.tsx index 19c4515..1af7500 100644 --- a/src/pages/Offerwall.tsx +++ b/src/pages/Offerwall.tsx @@ -21,7 +21,7 @@ import {Card, CardContent, CardFooter} from "@/components/ui/card.tsx"; import {makeSelectQuestionsByIds} from "@/models/questionSlice.ts" import {CheckIcon, MessageCircleQuestionIcon, XIcon} from "lucide-react" import {useAppDispatch, useAppSelector} from '@/hooks' -import {Sheet, SheetContent, SheetDescription, SheetHeader, SheetTitle, SheetTrigger,} from "@/components/ui/sheet" +import {Sheet, SheetContent, SheetDescription, SheetHeader , SheetTitle, SheetTrigger,} from "@/components/ui/sheet" import {ProfileQuestionFull} from "@/pages/Questions.tsx" import {Answer, selectAnswerForQuestion, submitAnswer} from "@/models/answerSlice.ts"; import {assert, formatCentsToUSD, formatSeconds} from "@/lib/utils.ts"; @@ -47,7 +47,8 @@ const BucketStatus: React.FC<SoftPairBucket> = ({bucket}) => { } } -const ContentsGrid: React.FC<SoftPairBucket> = ({bucket}) => { +type ContentsGridProps = { bucket: SoftPairBucket }; +const ContentsGrid: React.FC<ContentsGridProps> = ({bucket}) => { const columns: ColumnDef<BucketTask>[] = [ { @@ -113,7 +114,9 @@ const ContentsGrid: React.FC<SoftPairBucket> = ({bucket}) => { ) } -const ConditionalQuestions: React.FC<SoftPairBucket> = ({bucket}) => { + +type ConditionalQuestionsProps = { bucket: SoftPairBucket }; +const ConditionalQuestions: React.FC<ConditionalQuestionsProps> = ({bucket}) => { const dispatch = useAppDispatch() const questions = useSelector(makeSelectQuestionsByIds(bucket.missing_questions)) @@ -162,28 +165,35 @@ const ConditionalQuestions: React.FC<SoftPairBucket> = ({bucket}) => { Check Eligibility </Button> - <Sheet open={open} onOpenChange={setOpen}> + <Sheet + open={open} + onOpenChange={setOpen} + > <SheetContent side="right" - className="md:w-[900px], lg:w-[1000px] p-5"> - + className="p-5" + > <SheetHeader> - <SheetTitle>Bucket Questions</SheetTitle> + <SheetTitle> + Bucket Questions + </SheetTitle> <SheetDescription> This survey has some unanswered questions. Answer these to determine if you're eligible for the Survey Bucket </SheetDescription> </SheetHeader> - { - questions.map(q => { - return <ProfileQuestionFull - key={q.question_id} - question={q} - submitAnswerEvt={submitEvt} - className="mt-4 m-2"/> - }) - } + <div className="h-full overflow-y-auto pr-5"> + { + questions.map(q => { + return <ProfileQuestionFull + key={q.question_id} + question={q} + submitAnswerEvt={submitEvt} + /> + }) + } + </div> </SheetContent> </Sheet> @@ -191,13 +201,14 @@ const ConditionalQuestions: React.FC<SoftPairBucket> = ({bucket}) => { ) } -const CallToAction: React.FC<SoftPairBucket> = ({bucket}) => { +type CallToActionProps = { bucket: SoftPairBucket }; +const CallToAction: React.FC<CallToActionProps> = ({bucket}) => { switch (bucket.eligibility) { case "unconditional": return ( <div className="absolute bottom-2 left-1/2 transform -translate-x-1/2 w-[90%]"> <Link - href={bucket.uri} + href={bucket.uri.toString()} target="_blank" className="w-full h-8 cursor-pointer" > @@ -231,7 +242,8 @@ const CallToAction: React.FC<SoftPairBucket> = ({bucket}) => { } } -const ConditionalBucket: React.FC<SoftPairBucket> = ({bucket}) => { +type ConditionalBucketProps = { bucket: SoftPairBucket }; +const ConditionalBucket: React.FC<ConditionalBucketProps> = ({bucket}) => { const [tab, setTab] = useState("bucket_cta") const toggleTab = () => setTab(tab === "bucket_cta" ? "bucket_details" : "bucket_cta") diff --git a/src/pages/Questions.tsx b/src/pages/Questions.tsx index 06374b2..92b9505 100644 --- a/src/pages/Questions.tsx +++ b/src/pages/Questions.tsx @@ -1,10 +1,10 @@ -import React from 'react' import { BodySubmitProfilingQuestionsProductIdProfilingQuestionsPost, ProfilingQuestionsApiFactory, UpkQuestionChoice, - UserQuestionAnswerIn + UserQuestionAnswerIn, } from "@/api"; +import React from "react" import {Card, CardContent, CardFooter, CardHeader, CardTitle} from "@/components/ui/card.tsx"; import {useAppDispatch, useAppSelector} from "@/hooks.ts"; import {addAnswer, Answer, saveAnswer, selectAnswerForQuestion, submitAnswer} from "@/models/answerSlice.ts"; @@ -30,6 +30,7 @@ import { } from "@/models/questionSlice.ts"; import {assert} from "@/lib/utils.ts"; import {motion} from "framer-motion" +import {App} from "../models/app"; const TextEntry: React.FC<{ question: ProfileQuestion }> = ({question}) => { const dispatch = useAppDispatch() @@ -38,8 +39,9 @@ const TextEntry: React.FC<{ question: ProfileQuestion }> = ({question}) => { const answer: Answer | undefined = useSelector(selectAnswerForQuestion(question)); const error: Boolean = answer?.error_msg.length > 0 - const handleInputChange = (event: React.ChangeEvent<HTMLInputElement>) => { - dispatch(addAnswer({question: question, val: event.target.value})) + const handleInputChange = (event: React.KeyboardEvent<HTMLInputElement>) => { + const target = event.target as HTMLInputElement; + dispatch(addAnswer({question, val: target.value as string})) }; return ( @@ -119,7 +121,7 @@ export const ProfileQuestionFull: React.FC<{ // const selectAnswer = useMemo(() => selectAnswerForQuestion(question), [question]); // const answer: Answer = useSelector(selectAnswer); const answer: Answer | undefined = useSelector(selectAnswerForQuestion(question)); - const app = useAppSelector(state => state.app) + const app: App = useAppSelector(state => state.app) const provided_answer = answer?.values.length > 0 const error: Boolean = answer?.error_msg.length > 0 @@ -136,7 +138,7 @@ export const ProfileQuestionFull: React.FC<{ return ( - <Card className="@container/card relative overflow-hidden"> + <Card className="@container/card relative overflow-hidden my-4 p-5"> {answer && answer.processing && ( <motion.div className="absolute top-0 left-0 h-0.5 bg-gray-300" @@ -150,9 +152,9 @@ export const ProfileQuestionFull: React.FC<{ <Badge className="absolute top-2 right-2 h-5 min-w-5 rounded-full px-1 font-mono tabular-nums cursor-pointer" variant="outline" - title={`Currently ${(question.task_count ?? 0).toLocaleString()} surveys use this profiling question`} + title={`Currently ${(question.importance.task_count ?? 0).toLocaleString()} surveys use this profiling question`} > - {(question.task_count ?? 0).toLocaleString()} + {(question.importance?.task_count ?? 0).toLocaleString()} </Badge> <CardHeader> @@ -183,7 +185,7 @@ const PaginationIcon: React.FC<{ const answers = useAppSelector(state => state.answers) const completed: Boolean = Boolean(answers[question.question_id]?.complete) - const setQuestion = (evt) => { + const setQuestion = (evt: React.MouseEvent<HTMLAnchorElement>) => { if (completed) { evt.preventDefault() } else { @@ -197,7 +199,7 @@ const PaginationIcon: React.FC<{ href="#" title={question.question_text} isActive={question.active} - aria-disabled={completed} + aria-disabled={!!completed} onClick={setQuestion} className={clsx("cursor-pointer border border-gray-100", @@ -217,22 +219,24 @@ const QuestionsPage = () => { const dispatch = useAppDispatch() const questions = useSelector(selectQuestions) - const question = useSelector(selectFirstAvailableQuestion) + // @ts-ignore + const question: ProfileQuestion | null = useSelector(selectFirstAvailableQuestion) dispatch(setQuestionActive(question as ProfileQuestion)) // This is saved now, so that if they click next it's ready. It // cannot be done within the click handler. - const nextQuestion = useSelector(selectNextAvailableQuestion) + // @ts-ignore + const nextQuestion: ProfileQuestion | null = useSelector(selectNextAvailableQuestion) const answer: Answer | undefined = useSelector(selectAnswerForQuestion(question)); - const app = useAppSelector(state => state.app) + const app: App = useAppSelector(state => state.app) const clickNext = () => { // TODO: if nextQuestion was already submitted, skip it! if (nextQuestion) { // TS is not smart enough to know that the if statement above // prevents this from ever being null - dispatch(setQuestionActive(nextQuestion as ProfileQuestion)) + dispatch(setQuestionActive(nextQuestion)) } else { // What do we do now... no more questions left to do. } @@ -278,7 +282,7 @@ const QuestionsPage = () => { } as UserQuestionAnswerIn ] } - new ProfilingQuestionsApiFactory().submitProfilingQuestionsProductIdProfilingQuestionsPost(app.bpid, app.bpuid, body) + ProfilingQuestionsApiFactory().submitProfilingQuestionsProductIdProfilingQuestionsPost(app.bpid, app.bpuid, body) .then(res => { if (res.status == 200) { dispatch(saveAnswer({question: question})) @@ -318,7 +322,7 @@ const QuestionsPage = () => { key={question.question_id} question={question} submitAnswerEvt={submitAnswerEvt} - className="mt-4 mb-4"/> + /> </> ) } diff --git a/src/pages/Support.tsx b/src/pages/Support.tsx deleted file mode 100644 index 4746b77..0000000 --- a/src/pages/Support.tsx +++ /dev/null @@ -1,38 +0,0 @@ -import React, { useEffect } from 'react'; - -const ChatwootLoader = () => { - useEffect(() => { - const loadChatwoot = () => { - const BASE_URL = "https://chat.g-r-l.com"; - const script = document.createElement('script'); - script.src = `${BASE_URL}/packs/js/sdk.js`; - script.defer = true; - script.async = true; - - script.onload = () => { - if (window.chatwootSDK) { - window.chatwootSDK.run({ - websiteToken: 'dEEw3fcexQvnQ5tesJPKFjSb', - baseUrl: BASE_URL, - }); - } - }; - - document.body.appendChild(script); - }; - - loadChatwoot(); - - // Clean up script when the component unmounts - return () => { - const existingScript = document.querySelector(`script[src="https://app.chatwoot.com/packs/js/sdk.js"]`); - if (existingScript) { - document.body.removeChild(existingScript); - } - }; - }, []); - - return null; -}; - -export {ChatwootLoader};
\ No newline at end of file diff --git a/src/pages/TaskAttemptHistory.tsx b/src/pages/TaskAttemptHistory.tsx index 311c32e..0014893 100644 --- a/src/pages/TaskAttemptHistory.tsx +++ b/src/pages/TaskAttemptHistory.tsx @@ -14,7 +14,7 @@ export const TaskAttemptTable = () => { { accessorKey: "started", header: "Started", - cell: ({getValue}) => formatDistanceToNow(new Date(getValue()), {addSuffix: true}) + cell: ({getValue}) => formatDistanceToNow(new Date(getValue() as string), {addSuffix: true}) }, { accessorKey: "finished", diff --git a/src/pages/TransactionHistory.tsx b/src/pages/TransactionHistory.tsx index a99dd8b..6f30b14 100644 --- a/src/pages/TransactionHistory.tsx +++ b/src/pages/TransactionHistory.tsx @@ -1,7 +1,4 @@ import {useAppDispatch, useAppSelector} from "@/hooks.ts"; -import {Pagination, PaginationContent, PaginationItem, PaginationNext} from "@/components/ui/pagination.tsx"; -import React from "react"; -import {ProfileQuestionFull} from "@/pages/Questions.tsx"; const TransactionHistoryPage = () => { const dispatch = useAppDispatch() @@ -11,8 +8,7 @@ const TransactionHistoryPage = () => { return ( <> { - transactionHistory.map(th => { - + transactionHistory.map(() => { }) } </> |
