Skip to content

Commit

Permalink
Fix typescript errors
Browse files Browse the repository at this point in the history
  • Loading branch information
edwardsph committed Aug 2, 2024
1 parent 85a5b6f commit d3b28aa
Show file tree
Hide file tree
Showing 9 changed files with 14 additions and 7 deletions.
1 change: 1 addition & 0 deletions api/accessGrant.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
import type { AccessGrant, AccessGrantGroup } from "@/types/accessGrant";
import { makeApiRequest } from "./apiRequest";

export const getAccessGrants = async (): Promise<AccessGrantGroup[]> => {
Expand Down
3 changes: 1 addition & 2 deletions api/files.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@ export const postFile = async (file: FileObject): Promise<void> => {
const formData = new FormData();
formData.append("file", {
name: file.name,
type:
file.contentType || mime.getType(file.name) || "application/octet-stream",
type: file.type || mime.getType(file.name) || "application/octet-stream",
uri: file.uri,
} as unknown as Blob);

Expand Down
7 changes: 4 additions & 3 deletions app/(tabs)/accesses/[webId].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import { faEllipsis } from "@fortawesome/free-solid-svg-icons/faEllipsis";
import WebIdDisplay from "@/components/common/WebIdDisplay";
import ConfirmModal from "@/components/common/ConfirmModal";
import Loading from "@/components/LoadingButton";
import type { AccessGrant, AccessGrantGroup } from "@/types/accessGrant";

interface AccessGrantProps {}

Expand All @@ -63,7 +64,7 @@ const Page: React.FC<AccessGrantProps> = () => {
onSuccess: async () => {
setModalVisible(false);
setUpdating(false);
if (selectedRequest.items.length <= 1) {
if (selectedRequest && selectedRequest.items.length <= 1) {
navigation.goBack();
} else {
// eslint-disable-next-line no-console
Expand All @@ -83,7 +84,7 @@ const Page: React.FC<AccessGrantProps> = () => {

useLayoutEffect(() => {
navigation.setOptions({
headerTitle: selectedRequest.ownerName,
headerTitle: selectedRequest?.ownerName,
headerLeft: () => (
<TouchableOpacity
onPress={() => navigation.goBack()}
Expand All @@ -96,7 +97,7 @@ const Page: React.FC<AccessGrantProps> = () => {
<TouchableOpacity
onPress={() => {
setSelectedAG(undefined);
setSelectedWebId(selectedRequest.webId);
setSelectedWebId(selectedRequest?.webId);
bottomSheetModalRef.current?.present();
}}
>
Expand Down
1 change: 1 addition & 0 deletions app/(tabs)/accesses/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import { useQuery } from "@tanstack/react-query";
import { StyleSheet, View } from "react-native";
import WebIdAccessGrantList from "@/components/accessGrants/WebIdAccessGrantList";
import useRefreshOnFocus from "@/hooks/useRefreshOnFocus";
import type { AccessGrantGroup } from "@/types/accessGrant";

export default function AccessGrantScreen() {
const {
Expand Down
2 changes: 1 addition & 1 deletion app/(tabs)/home/download.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ const Page: React.FC<FileDetailProps> = () => {
mutation.mutate({
uri: uri as string,
name: fileName,
contentType,
type: contentType as string,
});
goBack();
};
Expand Down
1 change: 1 addition & 0 deletions components/accessGrants/AccessGrantList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import React from "react";
import { FlatList } from "react-native";
import AccessGrantCard from "@/components/accessGrants/AccessGrantCard";
import type { AccessGrant, AccessGrantGroup } from "@/types/accessGrant";

interface AccessGrantListProps {
data: AccessGrantGroup;
Expand Down
1 change: 1 addition & 0 deletions components/accessGrants/WebIdAccessGrantList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import { FlatList, StyleSheet, View } from "react-native";
import WebIdAccessGrantCard from "@/components/accessGrants/WebIdAccessGrantCard";
import { ThemedText } from "@/components/ThemedText";
import { Colors } from "@/constants/Colors";
import type { AccessGrantGroup } from "@/types/accessGrant";
import Loading from "../LoadingButton";

interface WebIdAccessGrantListProps
Expand Down
1 change: 1 addition & 0 deletions components/accessGrants/modal/BottomModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import { Colors } from "@/constants/Colors";
import { ThemedText } from "@/components/ThemedText";
import IconResourceName from "@/components/common/IconResourceName";
import WebIdDisplay from "@/components/common/WebIdDisplay";
import type { AccessGrant, AccessGrantGroup } from "@/types/accessGrant";

interface BottomModalProps {
accessGrant?: AccessGrant;
Expand Down
4 changes: 3 additions & 1 deletion components/files/BottomModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import * as Sharing from "expo-sharing";
import * as FileSystem from "expo-file-system";
import QRCode from "react-native-qrcode-svg";
import { formatResourceName } from "@/utils/fileUtils";
import type { UserInfo } from "@/constants/user";
import { ThemedText } from "../ThemedText";
import ConfirmModal from "../common/ConfirmModal";

Expand Down Expand Up @@ -67,7 +68,8 @@ const BottomModal: React.FC<BottomModalProps> = ({
const fr = new FileReader();
fr.onload = async () => {
const fileUri = `${FileSystem.documentDirectory}/${fileName}`;
await FileSystem.writeAsStringAsync(fileUri, fr.result?.split(",")[1], {
const result = fr.result as string;
await FileSystem.writeAsStringAsync(fileUri, result?.split(",")[1], {
encoding: FileSystem.EncodingType.Base64,
});
await Sharing.shareAsync(fileUri);
Expand Down

0 comments on commit d3b28aa

Please sign in to comment.