File size: 2,745 Bytes
f13098c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
from pathlib import Path

p = Path(r"C:\Users\dream\CCAI-Demo-Canvas-Upgrades\phd-advisor-frontend\src\pages\ChatPage.js")
c = p.read_text(encoding="utf-8")

close_div = "</" + "div>"

needle = f"""              placeholder={{
                replyingTo 
                  ? `Reply to ${{replyingTo.advisorName}}...`
                  : chatPlaceholder
              }}
            />
          {close_div}
        {close_div}
      {close_div}
    {close_div}
  );
}};

export default ChatPage;
"""

replacement = f"""              placeholder={{
                replyingTo 
                  ? `Reply to ${{replyingTo.advisorName}}...`
                  : chatPlaceholder
              }}
              showProfileButtons={{!userProfile || userProfile.completion_pct < 100}}
              onOpenOnboarding={{() => setShowOnboarding(true)}}
              onOpenProfileForm={{() => setShowProfileForm(true)}}
            />
          {close_div}
        {close_div}
      {close_div}

      {{showOnboarding && (
        <OnboardingChat
          authToken={{authToken}}
          userName={{user?.firstName}}
          onClose={{() => {{ setShowOnboarding(false); loadProfile(); }}}}
        />
      )}}

      {{showProfileForm && (
        <ProfileWalkthrough
          authToken={{authToken}}
          existingProfile={{userProfile}}
          onClose={{() => {{ setShowProfileForm(false); loadProfile(); }}}}
        />
      )}}

      {{showClearData && (
        <ClearDataModal
          authToken={{authToken}}
          onClose={{() => setShowClearData(false)}}
          onDataCleared={{({{ profile: clearedProfile, chats: clearedChats }}) => {{
            if (clearedProfile) {{
              setUserProfile(null);
              loadProfile();
            }}
            if (clearedChats) {{
              setMessages([]);
              setCurrentSessionId(null);
              setCurrentSessionTitle('');
              handleNewChat();
            }}
          }}}}
        />
      )}}

      {{showAccount && (
        <AccountModal
          user={{user}}
          authToken={{authToken}}
          onClose={{() => setShowAccount(false)}}
          onAccountUpdated={{(updated) => {{
            if (user) {{
              user.firstName = updated.firstName;
              user.lastName = updated.lastName;
              user.email = updated.email;
            }}
          }}}}
          onAccountDeleted={{() => {{
            setShowAccount(false);
            onSignOut();
          }}}}
        />
      )}}
    {close_div}
  );
}};

export default ChatPage;
"""

if needle not in c:
    raise SystemExit("needle not found in ChatPage.js")

p.write_text(c.replace(needle, replacement, 1), encoding="utf-8")
print("ok")