Convert string to number

This commit is contained in:
Filip Sodić 2025-04-28 22:52:20 +02:00
parent 5c39bcd874
commit 36aa5dfe14
2 changed files with 4 additions and 4 deletions

View File

@ -42,7 +42,7 @@ export default function DemoAppPage() {
function NewTaskForm({ handleCreateTask }: { handleCreateTask: typeof createTask }) {
const [description, setDescription] = useState<string>('');
const [todaysHours, setTodaysHours] = useState<string>('8');
const [todaysHours, setTodaysHours] = useState<number>(8);
const [response, setResponse] = useState<GeneratedSchedule | null>({
mainTasks: [
{
@ -186,7 +186,7 @@ function NewTaskForm({ handleCreateTask }: { handleCreateTask: typeof createTask
max={24}
className='min-w-[7rem] text-gray-800/90 text-center font-medium rounded-md border border-gray-200 bg-yellow-50 hover:bg-yellow-100 shadow-md focus:outline-none focus:border-transparent focus:shadow-none duration-200 ease-in-out hover:shadow-none'
value={todaysHours}
onChange={(e) => setTodaysHours(e.currentTarget.value)}
onChange={(e) => setTodaysHours(+e.currentTarget.value)}
/>
</div>
</div>

View File

@ -25,7 +25,7 @@ function setUpOpenAi(): OpenAI {
//#region Actions
const generateGptResponseInputSchema = z.object({
hours: z.string().regex(/^\d+(\.\d+)?$/, 'Hours must be a number'),
hours: z.number(),
});
type GenerateGptResponseInput = z.infer<typeof generateGptResponseInputSchema>;
@ -206,7 +206,7 @@ export const getAllTasksByUser: GetAllTasksByUser<void, Task[]> = async (_args,
};
//#endregion
async function generateScheduleWithGpt(tasks: Task[], hours: string): Promise<GeneratedSchedule | null> {
async function generateScheduleWithGpt(tasks: Task[], hours: number): Promise<GeneratedSchedule | null> {
const parsedTasks = tasks.map(({ description, time }) => ({
description,
time,