Skip to content

Commit

Permalink
Merge pull request #14 from Hoang-Nguyen-Huy/feat/fetch-api
Browse files Browse the repository at this point in the history
refactor: 💡 up default image to firebase storgae
  • Loading branch information
Hoang-Nguyen-Huy authored Oct 26, 2024
2 parents 460a952 + 07805ab commit fe79778
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 6 deletions.
6 changes: 5 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,8 @@ VITE_FIREBASE_API_KEY=your_api_key
VITE_FIREBASE_AUTH_DOMAIN=your_auth_domain
VITE_FIREBASE_PROJECT_ID=your_project_id
VITE_FIREBASE_STORAGE_BUCKET=your_storage_bucket
VITE_API_BASE_URL=https://your-mockapi-url.com
VITE_FIREBASE_MESSAGING_SENDER_ID=your_messaging_sender_id
VITE_FIREBASE_APP_ID=your_app_id
VITE_FIREBASE_MEASUREMENT_ID=your_measurement_id
VITE_API_BASE_URL=https://your-mockapi-url.com
DEFAULT_IMAGE=your_default_image
1 change: 1 addition & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ jobs:
VITE_FIREBASE_APP_ID: ${{ secrets.FIREBASE_APP_ID }}
VITE_FIREBASE_MEASUREMENT_ID: ${{ secrets.FIREBASE_MEASUREMENT_ID }}
VITE_API_BASE_URL: ${{ secrets.API_BASE_URL }}
DEFAULT_IMAGE: ${{ secrets.DEFAULT_IMAGE }}

- name: Upload production-ready build files
uses: actions/upload-artifact@v4
Expand Down
4 changes: 1 addition & 3 deletions src/components/Dashboard.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,10 @@ import {
import { useFormik } from "formik";
import * as Yup from "yup";
import { ref, uploadBytes, getDownloadURL } from "firebase/storage";
import { storage } from "../firebase";
import { DEFAULT_IMAGE, storage } from "../firebase";
import { categories } from "../OrchidCategory";
import { countries } from "../OrchidOrigin";

export const DEFAULT_IMAGE = "src/assets/images/image.jpg";

const validationSchema = Yup.object({
name: Yup.string().required("Name is required"),
rating: Yup.number().min(0).max(5).required("Rating is required"),
Expand Down
2 changes: 1 addition & 1 deletion src/components/MainContent/OrchidCard.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { useNavigate } from "react-router-dom";
import { motion } from "framer-motion";
import { useContext } from "react";
import { ThemeContext } from "../../themes/ThemeContext";
import { DEFAULT_IMAGE } from "../Dashboard";
import { DEFAULT_IMAGE } from "../../firebase";

const MotionCard = motion(Card);

Expand Down
2 changes: 1 addition & 1 deletion src/components/OrchidDetail.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import { AspectRatio } from "@mui/joy";
import { motion } from "framer-motion";
import { RelatedOrchidsSlider } from "./RelatedOrchidSlider";
import { getOrchidById } from "../apis/OrchidsApi";
import { DEFAULT_IMAGE } from "./Dashboard";
import { DEFAULT_IMAGE } from "../firebase";

const MotionBox = motion(Box);

Expand Down
2 changes: 2 additions & 0 deletions src/firebase.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,5 @@ const app = initializeApp(firebaseConfig);
export const analytics = getAnalytics(app);
export const auth = getAuth();
export const storage = getStorage(app);

export const DEFAULT_IMAGE = import.meta.env.DEFAULT_IMAGE;

0 comments on commit fe79778

Please sign in to comment.