Skip to content

Commit 6a7d500

Browse files
committed
chore(dashboard): create learning circle api fixes
1 parent 7e6da47 commit 6a7d500

File tree

8 files changed

+163
-123
lines changed

8 files changed

+163
-123
lines changed

src/components/MuComponents/MuModal/MuModal.tsx

Lines changed: 24 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ interface ModalProps {
1111
type: "error" | "success";
1212
onDone?: any;
1313
body?: string;
14+
showButton?: Boolean;
1415
}
1516

1617
const MuModal: FC<ModalProps> = ({
@@ -20,7 +21,8 @@ const MuModal: FC<ModalProps> = ({
2021
children,
2122
type,
2223
onDone,
23-
body
24+
body,
25+
showButton = true
2426
}) => {
2527
if (!isOpen) {
2628
return null;
@@ -46,22 +48,27 @@ const MuModal: FC<ModalProps> = ({
4648
{title && <h1 className={styles.modalTitle}>{title}</h1>}
4749
{body && <p className={styles.modalText}>{body}</p>}
4850
<div className={styles.modalBody}>{children}</div>
49-
<div className={styles.btn_container}>
50-
<button
51-
type="button"
52-
className={styles.btn_cancel}
53-
onClick={onClose}
54-
>
55-
Cancel
56-
</button>
57-
<button
58-
type="submit"
59-
onClick={onDone} // Use the onDone prop here
60-
className={styles.btn_submit}
61-
>
62-
Done
63-
</button>
64-
</div>
51+
{
52+
showButton && (
53+
<div className={styles.btn_container}>
54+
<button
55+
type="button"
56+
className={styles.btn_cancel}
57+
onClick={onClose}
58+
>
59+
Cancel
60+
</button>
61+
<button
62+
type="submit"
63+
onClick={onDone} // Use the onDone prop here
64+
className={styles.btn_submit}
65+
>
66+
Done
67+
</button>
68+
</div>
69+
70+
)
71+
}
6572
</div>
6673
</div>
6774
);

src/modules/Dashboard/modules/LearningCircleV2/pages/landing/LearningCircleLanding.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ const LearningCircleLanding = () => {
4141
const navigate = useNavigate();
4242

4343
const handleModalOpen = (event: CircleMeetupInfo) => {
44-
setSelectedMeetup({...event, joiningUrl: "https://music.youtube.com/search?q=let+her+go"})
44+
setSelectedMeetup(event)
4545
setIsModalOpen(true)
4646
}
4747

@@ -94,12 +94,12 @@ const LearningCircleLanding = () => {
9494
{selectedMeetup?.meet_time && <p><strong>Time:</strong> {new Date(selectedMeetup?.meet_time).toLocaleTimeString()}</p>}
9595
{selectedMeetup?.attendee && <p><strong>Attendees:</strong> {Number(selectedMeetup?.attendee) || 10}</p> }
9696
{/* Display joining URL (if it's an online event) */}
97-
{selectedMeetup?.joiningUrl && (
97+
{selectedMeetup?.joiningUrl || selectedMeetup?.meet_place && (
9898
<div className={styles.joiningUrlSection}>
9999
<p><strong>Joining URL:</strong></p>
100100
<div className={styles.urlContainer}>
101101
<a
102-
href={selectedMeetup.joiningUrl}
102+
href={selectedMeetup.joiningUrl || selectedMeetup.meet_place}
103103
target="_blank"
104104
rel="noopener noreferrer"
105105
className={styles.copyButton}
@@ -109,7 +109,7 @@ const LearningCircleLanding = () => {
109109
<button
110110
className={styles.copyButton}
111111
onClick={() => {
112-
navigator.clipboard.writeText(selectedMeetup?.joiningUrl || "");
112+
navigator.clipboard.writeText(selectedMeetup?.joiningUrl || selectedMeetup.meet_place);
113113
alert("URL copied to clipboard!");
114114
}}
115115
>
@@ -122,10 +122,10 @@ const LearningCircleLanding = () => {
122122
</MuModal>
123123
<MuModal
124124
type="success"
125-
onDone={handleSubmit}
126125
onClose={() => setIsCreateModalOpen(false)}
127126
title="Create Learning Circle"
128127
isOpen={isCreateModalOpen}
128+
showButton={false}
129129
>
130130
<LearningCircleCreateForm setIsCreateModalOpen={setIsCreateModalOpen} />
131131
</MuModal>

src/modules/Dashboard/modules/LearningCircleV2/services/LearningCircleAPIs.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ export const getLearningCircleInfo = async (
244244

245245
export const createLearningCircle = async (
246246
params: LearningCircleCreate
247-
): Promise<boolean> => {
247+
): Promise<string |boolean> => {
248248
try {
249249
const response = await privateGateway.post(
250250
learningCircleRoutes.createLearningCircle,

src/modules/Dashboard/modules/LearningCircleV2/services/LearningCircleInterface.d.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ interface LearningCircleCreate {
1414

1515
interface LCMeetCreate {
1616
circle_id: string;
17+
description: string;
1718
coord_x: number;
1819
coord_y: number;
1920
meet_time: string;
@@ -22,6 +23,8 @@ interface LCMeetCreate {
2223
is_report_needed: boolean;
2324
report_description: string;
2425
meet_place: string;
26+
meet_link: string;
27+
mode: string
2528
}
2629

2730
interface LCMeetup {

src/modules/Dashboard/modules/LearningPaths/pages/LearningPathOne/LearningCircleCreateForm.tsx

Lines changed: 106 additions & 90 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { createLearningCircle, scheduleMeetup } from "../../../LearningCircleV2/
44
import { useNavigate } from "react-router-dom";
55

66

7-
const LearningCircleCreateForm = ({setIsCreateModalOpen}: {setIsCreateModalOpen: (type: boolean)=> void}) => {
7+
const LearningCircleCreateForm = ({ setIsCreateModalOpen }: { setIsCreateModalOpen: (type: boolean) => void }) => {
88
const [title, setTitle] = useState('');
99
const [description, setDescription] = useState('');
1010
const [meetingType, setMeetingType] = useState('online'); // default selection
@@ -15,117 +15,133 @@ const LearningCircleCreateForm = ({setIsCreateModalOpen}: {setIsCreateModalOpen:
1515
const navigate = useNavigate();
1616

1717

18-
const handleSubmit = (e: React.FormEvent<HTMLFormElement>) => {
18+
const handleSubmit = (e: React.FormEvent<HTMLFormElement>) => {
1919
e && e.preventDefault();
20-
const data = e.currentTarget.value
20+
// var lcId: string | boolean = '';
21+
const data = {
22+
title,
23+
description,
24+
meetingType,
25+
meetLink,
26+
location,
27+
time,
28+
org: import.meta.env.VITE_ORG_ID,
29+
ig: import.meta.env.VITE_IG_ID,
30+
is_recurring: false,
31+
recurrence_type: "weekly",
32+
recurrence: 1,
33+
}
2134
createLearningCircle(data).then(status => {
2235
// setIsLoading(false);
2336
if (status) {
24-
navigate("/dashboard/learningcircle/create-meetup/" + status);
25-
}
26-
});
27-
scheduleMeetup(data).then(status => {
28-
// setIsLoading(false);
29-
if (status) {
30-
// navigate(
31-
// `/dashboard/learningcircle/dashboard/${params.circle_id}`
32-
// );
37+
scheduleMeetup({ circle_id: status as string, title: data.title, description: data.description, meet_place: data.location || "Google Meet", meet_time: data.time, duration: 4, mode: data.location ? "offline" : "online", coord_x: 0, coord_y: 0, is_report_needed: false, report_description: '', meet_link: data.meetLink || "https://meet.google.com" }).then(status => {
38+
// setIsLoading(false);
39+
if (status) {
40+
// navigate(
41+
// `/dashboard/learningcircle/dashboard/${params.circle_id}`
42+
// );
43+
}
44+
});
3345
}
3446
});
3547
setIsCreateModalOpen(false);
36-
};
48+
};
3749

3850

39-
return(
51+
return (
4052
<form className={styles.form} onSubmit={handleSubmit}>
41-
{/* Title Field */}
42-
<div className={styles.formGroup}>
43-
<label htmlFor="title">Title of Learning Circle</label>
44-
<input
45-
id="title"
46-
type="text"
47-
placeholder="What are you going to learn?"
48-
value={title}
49-
onChange={(e) => setTitle(e.target.value)}
50-
className={styles.input}
51-
required
52-
/>
53-
</div>
54-
55-
{/* Description Field */}
56-
<div className={styles.formGroup}>
57-
<label htmlFor="description">Description</label>
58-
<textarea
59-
id="description"
60-
placeholder="Enter details about your learning circle..."
61-
value={description}
62-
onChange={(e) => setDescription(e.target.value)}
63-
className={styles.textarea}
64-
required
65-
/>
66-
</div>
67-
68-
{/* Online/Offline Selection */}
69-
<div className={styles.formGroup}>
70-
<label>Meeting Type</label>
71-
<div className={styles.radioGroup}>
72-
<div
73-
className={`${styles.radioCard} ${meetingType === 'online' ? styles.active : ''}`}
74-
onClick={() => setMeetingType('online')}
75-
>
76-
Online
77-
</div>
78-
<div
79-
className={`${styles.radioCard} ${meetingType === 'offline' ? styles.active : ''}`}
80-
onClick={() => setMeetingType('offline')}
81-
>
82-
Offline
83-
</div>
84-
</div>
85-
</div>
86-
87-
{/* Conditional Field for Meeting Link or Location */}
88-
{meetingType === 'online' ? (
53+
{/* Title Field */}
8954
<div className={styles.formGroup}>
90-
<label htmlFor="meetLink">Online Meeting Link</label>
55+
<label htmlFor="title">Title of Learning Circle</label>
9156
<input
92-
id="meetLink"
93-
type="url"
94-
placeholder="Enter meeting link"
95-
value={meetLink}
96-
onChange={(e) => setMeetLink(e.target.value)}
57+
id="title"
58+
type="text"
59+
placeholder="What are you going to learn?"
60+
value={title}
61+
onChange={(e) => setTitle(e.target.value)}
9762
className={styles.input}
9863
required
9964
/>
10065
</div>
101-
) : (
66+
67+
{/* Description Field */}
10268
<div className={styles.formGroup}>
103-
<label htmlFor="location">Location</label>
69+
<label htmlFor="description">Description</label>
70+
<textarea
71+
id="description"
72+
placeholder="Enter details about your learning circle..."
73+
value={description}
74+
onChange={(e) => setDescription(e.target.value)}
75+
className={styles.textarea}
76+
required
77+
/>
78+
</div>
79+
80+
{/* Online/Offline Selection */}
81+
<div className={styles.formGroup}>
82+
<label>Meeting Type</label>
83+
<div className={styles.radioGroup}>
84+
<div
85+
className={`${styles.radioCard} ${meetingType === 'online' ? styles.active : ''}`}
86+
onClick={() => setMeetingType('online')}
87+
>
88+
Online
89+
</div>
90+
<div
91+
className={`${styles.radioCard} ${meetingType === 'offline' ? styles.active : ''}`}
92+
onClick={() => setMeetingType('offline')}
93+
>
94+
Offline
95+
</div>
96+
</div>
97+
</div>
98+
99+
{/* Conditional Field for Meeting Link or Location */}
100+
{meetingType === 'online' ? (
101+
<div className={styles.formGroup}>
102+
<label htmlFor="meetLink">Online Meeting Link</label>
103+
<input
104+
id="meetLink"
105+
type="url"
106+
placeholder="Enter meeting link"
107+
value={meetLink}
108+
onChange={(e) => setMeetLink(e.target.value)}
109+
className={styles.input}
110+
required
111+
/>
112+
</div>
113+
) : (
114+
<div className={styles.formGroup}>
115+
<label htmlFor="location">Location</label>
116+
<input
117+
id="location"
118+
type="text"
119+
placeholder="Enter location"
120+
value={location}
121+
onChange={(e) => setLocation(e.target.value)}
122+
className={styles.input}
123+
required
124+
/>
125+
</div>
126+
)}
127+
128+
{/* Time Field */}
129+
<div className={styles.formGroup}>
130+
<label htmlFor="time">Time</label>
104131
<input
105-
id="location"
106-
type="text"
107-
placeholder="Enter location"
108-
value={location}
109-
onChange={(e) => setLocation(e.target.value)}
132+
id="time"
133+
type="datetime-local"
134+
value={time}
135+
onChange={(e) => setTime(e.target.value)}
110136
className={styles.input}
111137
required
112138
/>
113139
</div>
114-
)}
115-
116-
{/* Time Field */}
117-
<div className={styles.formGroup}>
118-
<label htmlFor="time">Time</label>
119-
<input
120-
id="time"
121-
type="datetime-local"
122-
value={time}
123-
onChange={(e) => setTime(e.target.value)}
124-
className={styles.input}
125-
required
126-
/>
127-
</div>
128-
</form>
140+
<div>
141+
<button type="button" onClick={() => setIsCreateModalOpen(false)} className={styles.submitButton2} style={{marginRight: "1rem"}}>Cancel</button>
142+
<button type="submit" className={styles.submitButton}>Submit</button>
143+
</div>
144+
</form>
129145
)
130146
}
131147

src/modules/Dashboard/modules/LearningPaths/pages/LearningPathOne/LearningCircleLanding.module.css

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,19 @@
191191
margin-bottom: 0.5rem;
192192
font-weight: 500;
193193
}
194+
195+
.submitButton{
196+
background-color: #007bff;
197+
padding: 1rem;
198+
color: white;
199+
border-radius: 10px;
200+
}
201+
202+
.submitButton2{
203+
border: 1px solid #007bff;
204+
padding: 1rem;
205+
border-radius: 10px;
206+
}
194207

195208
.input,
196209
.textarea {

src/modules/Dashboard/modules/LearningPaths/pages/LearningPathOne/LearningCircles.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,10 +106,11 @@ const LearningCircles = () => {
106106
</MuModal>
107107
<MuModal
108108
type="success"
109-
onDone={handleSubmit}
109+
// onDone={handleSubmit}
110110
onClose={() => setIsCreateModalOpen(false)}
111111
title="Create Learning Circle"
112112
isOpen={isCreateModalOpen}
113+
showButton={false}
113114
>
114115
<LearningCircleCreateForm setIsCreateModalOpen={setIsCreateModalOpen}/>
115116
</MuModal>

0 commit comments

Comments
 (0)