Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #35: Auto Scheduling Tasks #77

Closed
wants to merge 1 commit into from
Closed

Fix #35: Auto Scheduling Tasks #77

wants to merge 1 commit into from

Conversation

birdup000
Copy link
Owner

Resolves #35

The following modifications were applied:

<modification>
  <file>app/components/TaskForm.tsx</file>
  <operation>insert</operation>
  <target>1</target>
  <content>
    "use client";
  </content>
</modification>
<modification>
  <file>app/components/TaskForm.tsx</file>
  <operation>insert</operation>
  <target>import { TaskList, Task } from '../types/task';</target>
  <content>
    import { useAIAssistant } from '../hooks/useAIAssistant';
  </content>
</modification>
<modification>
  <file>app/components/TaskForm.tsx</file>
  <operation>insert</operation>
  <target>const TaskForm: React.FC&lt;TaskFormProps&gt; = ({ onSubmit, onCancel, lists }) =&gt; {</target>
  <content>
    const [isAutoScheduling, setIsAutoScheduling] = useState(false);
    const { generateTaskSuggestions } = useAIAssistant({
      backendUrl: typeof window !== 'undefined' ? localStorage.getItem('agixtapi') || '' : '',
      authToken: typeof window !== 'undefined' ? localStorage.getItem('agixtkey') || '' : '',
    });
  
    const handleAutoSchedule = async () => {
      setIsAutoScheduling(true);
      const suggestions = await generateTaskSuggestions(`Create a task with title: ${title}, description: ${description}`);
      if (suggestions &amp;&amp; suggestions.length &gt; 0) {
        const suggestion = suggestions[0];
        setTitle(suggestion.title);
        setDescription(suggestion.description);
        if (suggestion.priority) {
          setPriority(suggestion.priority);
        }
        if (suggestion.dueDate) {
          setDueDate(suggestion.dueDate);
        }
      }
      setIsAutoScheduling(false);
    };
  </content>
</modification>
<modification>
  <file>app/components/TaskForm.tsx</file>
  <operation>insert</operation>
  <target>        &lt;button
        type="submit"
        className="px-4 py-2 rounded-md bg-indigo-600 hover:bg-indigo-700 transition-colors"
      &gt;
        Create Task
      &lt;/button&gt;</target>
  <content>
      {isAutoScheduling &amp;&amp; (
        &lt;span className="text-gray-400 text-sm"&gt;AI thinking...&lt;/span&gt;
      )}
      &lt;button
        type="button"
        onClick={handleAutoSchedule}
        disabled={isAutoScheduling}
        className="px-4 py-2 rounded-md bg-green-600 hover:bg-green-700 transition-colors disabled:bg-gray-500"
      &gt;
        AI Schedule
      &lt;/button&gt;
  </content>
</modification>

@birdup000 birdup000 closed this Dec 26, 2024
@birdup000 birdup000 deleted the issue-35 branch December 27, 2024 23:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Auto Scheduling Tasks
1 participant