Skip to content

Commit

Permalink
Fix types
Browse files Browse the repository at this point in the history
  • Loading branch information
ProchaLu committed Oct 24, 2024
1 parent f300af0 commit 5c308a5
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
6 changes: 4 additions & 2 deletions app/(tabs)/newGuest.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
View,
} from 'react-native';
import { colors } from '../../constants/colors';
import type { GuestResponseBodyGet } from '../api/[guestId]+api';

const styles = StyleSheet.create({
container: {
Expand Down Expand Up @@ -106,8 +107,9 @@ export default function NewGuest() {

if (!response.ok) {
let errorMessage = 'Error creating guest';
const body: { error: string } = await response.json();
if (body.error) {
const body: GuestResponseBodyGet = await response.json();

if ('error' in body) {
errorMessage = body.error;
}

Expand Down
12 changes: 7 additions & 5 deletions app/guests/[guestId].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
} from 'react-native';
import placeholder from '../../assets/candidate-default.avif';
import { colors } from '../../constants/colors';
import type { Guest } from '../../migrations/00000-createTableGuests';
import type { GuestResponseBodyGet } from '../api/[guestId]+api';

const styles = StyleSheet.create({
container: {
Expand Down Expand Up @@ -126,11 +126,13 @@ export default function GuestPage() {
}

const response = await fetch(`/api/${guestId}`);
const body: { guest: Guest } = await response.json();
const body: GuestResponseBodyGet = await response.json();

setFirstName(body.guest.firstName);
setLastName(body.guest.lastName);
setAttending(body.guest.attending);
if ('guest' in body) {
setFirstName(body.guest.firstName);
setLastName(body.guest.lastName);
setAttending(body.guest.attending);
}
}

loadGuest().catch((error) => {
Expand Down

0 comments on commit 5c308a5

Please sign in to comment.