@@ -19,6 +19,8 @@ import {
1919} from "../../../api/teacher/teacher.api" ;
2020import { useMyProfileQuery } from "../../../features/teachers/query/useMyProfileQuery" ;
2121import { useUpdateMyProfileMutation } from "../../../features/teachers/mutations/useUpdateMyProfileMutation" ;
22+ import { useUpdateMyPublishMutation } from "../../../features/teachers/mutations/useUpdateMyPublishMutation" ;
23+
2224import { useRegularStudentsQuery } from "../../../features/appointments/query/useRegularStudentsQuery" ;
2325import { useModalStore } from "../../../store/modals.store" ;
2426import { queryKeys } from "../../../features/queryKeys" ;
@@ -35,9 +37,40 @@ export interface TimeSlot {
3537 hour : number ;
3638}
3739
40+ const teacherStatusUi : Record < string , { label : string ; className : string } > = {
41+ draft : {
42+ label : "Draft" ,
43+ className : "bg-yellow-500/20 text-yellow-300 border border-yellow-500/40" ,
44+ } ,
45+ pending : {
46+ label : "Pending Review" ,
47+ className : "bg-purple-500/20 text-purple-300 border border-purple-500/40" ,
48+ } ,
49+ active : {
50+ label : "Approved" ,
51+ className :
52+ "bg-emerald-500/20 text-emerald-300 border border-emerald-500/40" ,
53+ } ,
54+ rejected : {
55+ label : "Rejected" ,
56+ className : "bg-red-500/20 text-red-300 border border-red-500/40" ,
57+ } ,
58+ blocked : {
59+ label : "Blocked" ,
60+ className : "bg-gray-500/20 text-gray-200 border border-gray-500/40" ,
61+ } ,
62+ } ;
63+
3864export const TeacherProfile = ( ) => {
3965 const { data : profile , isLoading } = useMyProfileQuery ( ) ;
4066 const updateProfileMutation = useUpdateMyProfileMutation ( ) ;
67+
68+ const { mutate : updatePublish , isPending : isPublishPending } =
69+ useUpdateMyPublishMutation ( ) ;
70+
71+ const handlePublishToggle = ( nextPublic : boolean ) =>
72+ updatePublish ( { isPublic : nextPublic } ) ;
73+
4174 const { data : regularStudentsData } = useRegularStudentsQuery ( ) ;
4275 const openModal = useModalStore ( ( s ) => s . open ) ;
4376 const queryClient = useQueryClient ( ) ;
@@ -415,9 +448,48 @@ export const TeacherProfile = () => {
415448 return (
416449 < div className = "px-4 sm:px-6 lg:px-10 flex flex-col" >
417450 < div className = "pt-6 sm:pt-8 lg:pt-10 flex-1" >
418- < h1 className = "text-3xl sm:text-4xl lg:text-5xl font-bold bg-gradient-to-r from-[#7C86F7] to-[#E879F9] bg-clip-text text-transparent mb-8 sm:mb-10 lg:mb-12" >
419- My profile
420- </ h1 >
451+ < div className = "mb-8 sm:mb-10 lg:mb-12 flex flex-col gap-4 sm:flex-row sm:items-center sm:justify-between" >
452+ < h1 className = "text-3xl sm:text-4xl lg:text-5xl font-bold bg-gradient-to-r from-[#7C86F7] to-[#E879F9] bg-clip-text text-transparent" >
453+ My profile
454+ </ h1 >
455+ < label
456+ htmlFor = "teacher-visibility-toggle"
457+ className = { `flex items-center gap-3 ${
458+ isPublishPending ? "opacity-70" : ""
459+ } `}
460+ >
461+ < span className = "text-red-400 text-sm" > Private profile</ span >
462+ < input
463+ id = "teacher-visibility-toggle"
464+ type = "checkbox"
465+ className = "peer sr-only"
466+ checked = { Boolean ( profile ?. isPublic ) }
467+ disabled = { isPublishPending }
468+ onChange = { ( e ) => handlePublishToggle ( e . target . checked ) }
469+ />
470+ < span
471+ className = "relative h-7 w-14 cursor-pointer rounded-full bg-red-500 transition-colors duration-200
472+ peer-checked:bg-green-500 peer-disabled:cursor-not-allowed
473+ after:absolute after:left-1 after:top-1 after:h-5 after:w-5 after:rounded-full after:bg-white after:shadow
474+ after:transition-transform after:duration-200 peer-checked:after:translate-x-7"
475+ aria-hidden = "true"
476+ />
477+ < span className = "text-green-400 text-sm" > Public profile</ span >
478+ </ label >
479+ </ div >
480+ < div className = "mb-6 sm:mb-8" >
481+ < span
482+ className = { `inline-flex items-center rounded-full px-3 py-1 text-xs sm:text-sm font-medium ${
483+ teacherStatusUi [ profile ?. status ?? "draft" ] ?. className ??
484+ "bg-light-500/20 text-light-100 border border-light-500/40"
485+ } `}
486+ >
487+ Account status:{ " " }
488+ { teacherStatusUi [ profile ?. status ?? "draft" ] ?. label ??
489+ profile ?. status ??
490+ "Draft" }
491+ </ span >
492+ </ div >
421493 < div className = "flex flex-col lg:flex-row gap-6 lg:gap-12" >
422494 < ProfileAvatar avatarUrl = { profile ?. profileImageUrl } />
423495 < div className = "flex-1 space-y-4 sm:space-y-6" >
0 commit comments