mirror of
https://github.com/SrIzan10/featheroom.git
synced 2026-06-06 00:56:49 +00:00
feat: support all attachment types
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import type { classroom_v1 } from '@googleapis/classroom'
|
||||
import { useLocalSearchParams } from 'expo-router'
|
||||
import { useEffect } from 'react'
|
||||
import { View } from 'react-native'
|
||||
@@ -40,13 +41,44 @@ export default function CourseWorkViewer() {
|
||||
{data?.materials && (
|
||||
<>
|
||||
<Text variant="headlineSmall">Attachments</Text>
|
||||
{data.materials.map((material) => (
|
||||
<SimpleAttachment
|
||||
key={material.driveFile!.driveFile!.id}
|
||||
title={material.driveFile!.driveFile!.title!}
|
||||
link={material.driveFile!.driveFile!.alternateLink!}
|
||||
/>
|
||||
))}
|
||||
{data.materials.map((material) => {
|
||||
// TODO: Move to classroom utils file
|
||||
const getAttachmentDetails = (
|
||||
material: classroom_v1.Schema$Material,
|
||||
) => {
|
||||
if (material.driveFile) {
|
||||
return {
|
||||
title: material.driveFile.driveFile!.title!,
|
||||
link: material.driveFile.driveFile!.alternateLink!,
|
||||
}
|
||||
}
|
||||
if (material.youtubeVideo) {
|
||||
return {
|
||||
title: material.youtubeVideo.title!,
|
||||
link: material.youtubeVideo.alternateLink!,
|
||||
}
|
||||
}
|
||||
if (material.link) {
|
||||
return {
|
||||
title: material.link.title || material.link.url,
|
||||
link: material.link.url!,
|
||||
}
|
||||
}
|
||||
if (material.form) {
|
||||
return {
|
||||
title: material.form.title!,
|
||||
link: material.form.formUrl!,
|
||||
}
|
||||
}
|
||||
return {
|
||||
title: 'Unknown Material Type',
|
||||
link: '#',
|
||||
}
|
||||
}
|
||||
|
||||
const { title, link } = getAttachmentDetails(material)
|
||||
return <SimpleAttachment key={link} title={title!} link={link} />
|
||||
})}
|
||||
</>
|
||||
)}
|
||||
</View>
|
||||
|
||||
Reference in New Issue
Block a user