Skip to content

Commit

Permalink
Small fixes (#253)
Browse files Browse the repository at this point in the history
  • Loading branch information
umaar authored Sep 27, 2023
1 parent cacd6b8 commit 1eb300f
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 131 deletions.
92 changes: 38 additions & 54 deletions nextjs-start/firebase.json
Original file line number Diff line number Diff line change
@@ -1,56 +1,40 @@
{
"emulators": {
"auth": {
"port": 9099
},
"functions": {
"port": 5001
},
"firestore": {
"port": 8080
},
"database": {
"port": 9000
},
"storage": {
"port": 9199
},
"ui": {
"enabled": true
},
"singleProjectMode": true,
"hosting": {
"port": 5000
}
},
"functions": [
{
"source": "functions",
"codebase": "default",
"ignore": [
"node_modules",
".git",
"firebase-debug.log",
"firebase-debug.*.log"
]
}
],
"firestore": {
"rules": "firestore.rules",
"indexes": "firestore.indexes.json"
},
"hosting": {
"source": ".",
"ignore": [
"firebase.json",
"**/.*",
"**/node_modules/**"
],
"frameworksBackend": {
"region": "us-central1"
}
},
"storage": {
"rules": "storage.rules"
}
"emulators": {
"auth": {
"port": 9099
},
"functions": {
"port": 5001
},
"firestore": {
"port": 8080
},
"database": {
"port": 9000
},
"storage": {
"port": 9199
},
"ui": {
"enabled": true
},
"singleProjectMode": true,
"hosting": {
"port": 5000
}
},
"firestore": {
"rules": "firestore.rules",
"indexes": "firestore.indexes.json"
},
"hosting": {
"source": ".",
"ignore": ["firebase.json", "**/.*", "**/node_modules/**"],
"frameworksBackend": {
"region": "us-central1"
}
},
"storage": {
"rules": "storage.rules"
}
}
1 change: 0 additions & 1 deletion nextjs-start/functions/.gitignore

This file was deleted.

19 changes: 0 additions & 19 deletions nextjs-start/functions/index.js

This file was deleted.

23 changes: 0 additions & 23 deletions nextjs-start/functions/package.json

This file was deleted.

13 changes: 2 additions & 11 deletions nextjs-start/src/app/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,6 @@ import { getFirestore } from "firebase/firestore";
// This is a next.js server action, an alpha feature, so
// use with caution
// https://nextjs.org/docs/app/building-your-application/data-fetching/server-actions
export async function handleReviewFormSubmission(data) {
const { app } = await getAuthenticatedAppForUser();
const db = getFirestore(app);

await addReviewToRestaurant(db, data.get("restaurantId"), {
text: data.get("text"),
rating: data.get("rating"),

// This came from a hidden form field
userId: data.get("userId"),
});
}
// Replace the function below
export async function handleReviewFormSubmission(data) {}
27 changes: 4 additions & 23 deletions nextjs-start/src/lib/firebase/storage.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,8 @@ import { storage } from "@/src/lib/firebase/firebase";

import { updateRestaurantImageReference } from "@/src/lib/firebase/firestore";

export async function updateRestaurantImage(restaurantId, image) {
try {
if (!restaurantId)
throw new Error("No restaurant ID has been provided.");
// Replace the two functions below
export async function updateRestaurantImage(restaurantId, image) {}

if (!image || !image.name)
throw new Error("A valid image has not been provided.");

const publicImageUrl = await uploadImage(restaurantId, image);
await updateRestaurantImageReference(restaurantId, publicImageUrl);

return publicImageUrl;
} catch (error) {
console.error("Error processing request:", error);
}
}

async function uploadImage(restaurantId, image) {
const filePath = `images/${restaurantId}/${image.name}`;
const newImageRef = ref(storage, filePath);
await uploadBytesResumable(newImageRef, image);

return await getDownloadURL(newImageRef);
}
async function uploadImage(restaurantId, image) {}
// Replace the two functions above

0 comments on commit 1eb300f

Please sign in to comment.