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

Intro Course Developer Profile Instructor View #256

Merged
merged 10 commits into from
Mar 13, 2025
Merged
6 changes: 6 additions & 0 deletions clients/intro_course_developer_component/routes/index.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { DeveloperProfilesLecturerPage } from '../src/introCourse/pages/DeveloperProfilesLecturer/DeveloperProfilesLecturerPage'
import { TutorImportPage } from '../src/introCourse/pages/TutorImport/TutorImportPage'
import { IntroCourseDataShell } from '../src/introCourse/IntroCourseDataShell'
import { IntroCoursePage } from '../src/introCourse/IntroCoursePage'
Expand All @@ -15,6 +16,11 @@ const routes: ExtendedRouteObject[] = [
),
requiredPermissions: [Role.PROMPT_ADMIN, Role.COURSE_LECTURER, Role.COURSE_STUDENT], // empty means no permissions required
},
{
path: '/developer-profiles',
element: <DeveloperProfilesLecturerPage />,
requiredPermissions: [Role.PROMPT_ADMIN, Role.COURSE_LECTURER],
},
{
path: '/tutors',
element: <TutorImportPage />,
Expand Down
5 changes: 5 additions & 0 deletions clients/intro_course_developer_component/sidebar/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ const sidebarItems: SidebarMenuItemProps = {
goToPath: '',
requiredPermissions: [Role.PROMPT_ADMIN, Role.COURSE_LECTURER, Role.COURSE_STUDENT],
subitems: [
{
title: 'Developer Profiles',
goToPath: '/developer-profiles',
requiredPermissions: [Role.PROMPT_ADMIN, Role.COURSE_LECTURER],
},
{
title: 'Tutor Import',
goToPath: '/tutors',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
export type DeveloperProfile = {
coursePhaseID: string
courseParticipationID: string
appleID: string
gitLabUsername: string
hasMacBook: boolean
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
export type PostDeveloperProfile = {
appleID: string
gitLabUsername: string
hasMacBook: boolean
iPhoneUUID?: string
iPadUUID?: string
appleWatchUUID?: string
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { DeveloperProfile } from '../../interfaces/DeveloperProfile'
import { PostDeveloperProfile } from '../../interfaces/PostDeveloperProfile'
import { introCourseAxiosInstance } from '../introCourseServerConfig'

export const postDeveloperProfile = async (
coursePhaseID: string,
developerProfile: DeveloperProfile,
developerProfile: PostDeveloperProfile,
): Promise<void> => {
try {
return await introCourseAxiosInstance.post(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { PostDeveloperProfile } from '../../interfaces/PostDeveloperProfile'
import { introCourseAxiosInstance } from '../introCourseServerConfig'

export const updateDeveloperProfile = async (
coursePhaseID: string,
courseParticipationID: string,
developerProfile: PostDeveloperProfile,
): Promise<void> => {
try {
return await introCourseAxiosInstance.put(
`intro-course/api/course_phase/${coursePhaseID}/developer_profile/${courseParticipationID}`,
developerProfile,
{
headers: {
'Content-Type': 'application/json-path+json',
},
},
)
} catch (err) {
console.error(err)
throw err
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { DeveloperProfile } from '../../interfaces/DeveloperProfile'
import { introCourseAxiosInstance } from '../introCourseServerConfig'

export const getAllDeveloperProfiles = async (
coursePhaseID: string,
): Promise<DeveloperProfile[]> => {
try {
return (
await introCourseAxiosInstance.get(
`intro-course/api/course_phase/${coursePhaseID}/developer_profile`,
)
).data
} catch (err) {
console.error(err)
throw err
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useForm } from 'react-hook-form'
import { zodResolver } from '@hookform/resolvers/zod'
import type { DeveloperProfile } from '../../interfaces/DeveloperProfile'
import type { PostDeveloperProfile } from '../../interfaces/PostDeveloperProfile'
import { Button } from '@/components/ui/button'
import {
Form,
Expand All @@ -18,11 +18,12 @@ import { GitLabHelperDialog } from './components/GitLabHelperDialog'
import { AppleIDHelperDialog } from './components/AppleIDHelperDialog'
import IOSUUIDDialog from './components/IOSUUIDDialog'
import { useScreenSize } from '@/hooks/useScreenSize'
import { DeveloperProfile } from '../../interfaces/DeveloperProfile'

interface DeveloperProfileFormProps {
developerProfile?: DeveloperProfile
status?: string
onSubmit: (developerProfile: DeveloperProfile) => void
onSubmit: (developerProfile: PostDeveloperProfile) => void
}

export const DeveloperProfileForm = ({
Expand Down Expand Up @@ -55,7 +56,7 @@ export const DeveloperProfileForm = ({
})

const handleSubmit = (values: DeveloperFormValues) => {
const submittedProfile: DeveloperProfile = {
const submittedProfile: PostDeveloperProfile = {
appleID: values.appleID,
gitLabUsername: values.gitLabUsername,
hasMacBook: values.hasMacBook,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { DeveloperProfile } from '../../interfaces/DeveloperProfile'
import { DeveloperProfileForm } from './DeveloperProfileForm'
import { useIntroCourseStore } from '../../zustand/useIntroCourseStore'
import { useState } from 'react'
Expand All @@ -7,6 +6,7 @@ import { AlertCircle, CheckCircle } from 'lucide-react'
import { useMutation, useQueryClient } from '@tanstack/react-query'
import { postDeveloperProfile } from '../../network/mutations/postDeveloperProfile'
import { useParams } from 'react-router-dom'
import { PostDeveloperProfile } from '../../interfaces/PostDeveloperProfile'

interface DeveloperProfilePageProps {
onContinue: () => void
Expand All @@ -21,7 +21,7 @@ export const DeveloperProfilePage = ({ onContinue }: DeveloperProfilePageProps):
)

const mutation = useMutation({
mutationFn: (devProfile: DeveloperProfile) => {
mutationFn: (devProfile: PostDeveloperProfile) => {
return postDeveloperProfile(phaseId ?? '', devProfile)
},
onSuccess: () => {
Expand All @@ -33,17 +33,13 @@ export const DeveloperProfilePage = ({ onContinue }: DeveloperProfilePageProps):
},
})

const submitDeveloperProfile = (newDevProfile: DeveloperProfile) => {
mutation.mutate(newDevProfile)
}

return (
<div>
{currState === 'input' && (
<DeveloperProfileForm
developerProfile={developerProfile}
onSubmit={(profile) => {
submitDeveloperProfile(profile)
mutation.mutate(profile)
}}
/>
)}
Expand Down
Loading
Loading