Skip to content

Prettier #1382

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Sep 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions app.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<template>
<!DOCTYPE html>
<!doctype html>
<Html lang="en">
<title>Nuxt 3 Woocommerce</title>
<title>Nuxt 3 Woocommerce</title>
<Body
class="antialiased duration-300 transition-colors text-gray-800 bg-white"
>
Expand Down
16 changes: 9 additions & 7 deletions components/Cart/CartContents.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
<h2 class="mt-64 text-3xl text-center">Loading cart...</h2>
</div>
<div v-else-if="error">
<h2 class="mt-64 text-3xl text-center text-red-500">Error loading cart. Please try again.</h2>
<h2 class="mt-64 text-3xl text-center text-red-500">
Error loading cart. Please try again.
</h2>
</div>
<div v-else-if="cartItems.length">
<h1 class="h-10 p-6 text-3xl font-bold text-center">Cart</h1>
Expand All @@ -29,15 +31,15 @@
* @module CartContents
* @returns {Object} The Vue.js component object.
*/
import { computed, ref, onMounted } from 'vue';
import { computed, ref, onMounted } from "vue";
import { useCart } from "@/store/useCart";
import CommonButton from '@/components/common/CommonButton.vue';
import CommonButton from "@/components/common/CommonButton.vue";

const props = defineProps({
showCheckoutButton: {
type: Boolean,
default: false
}
default: false,
},
});

const cart = useCart();
Expand All @@ -55,7 +57,7 @@ const handleRemoveProduct = async (key) => {
try {
await cart.removeProductFromCart(key);
} catch (error) {
console.error('Error removing product from cart:', error);
console.error("Error removing product from cart:", error);
// Optionally, you can add a user-friendly notification here
// without exposing the error details
}
Expand All @@ -65,7 +67,7 @@ onMounted(async () => {
try {
await cart.refetch();
} catch (err) {
console.error('Error fetching cart:', err);
console.error("Error fetching cart:", err);
error.value = err;
} finally {
isLoading.value = false;
Expand Down
2 changes: 1 addition & 1 deletion components/Cart/CartItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
* @emits CartItem#remove - Emitted when the remove button is clicked.
*/

import { ref } from 'vue';
import { ref } from "vue";
import { formatPrice } from "@/utils/functions";

const isRemoving = ref(false);
Expand Down
9 changes: 5 additions & 4 deletions components/Layout/LayoutMobileMenu.vue
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@
</NuxtLink>
</li>
<li class="text-xl linkStyle">
<NuxtLink to="/search" @click="displayMobileMenu"> Search </NuxtLink>
<NuxtLink to="/search" @click="displayMobileMenu">
Search
</NuxtLink>
</li>
</ul>
</div>
Expand All @@ -50,7 +52,7 @@
</template>

<script setup>
import { ref } from 'vue'
import { ref } from "vue";

const expandedMenu = useState("expandedMenu", () => false);
const mobileMenu = ref(null);
Expand All @@ -61,10 +63,9 @@ const displayMobileMenu = () => {
</script>

<style scoped>

.mobile-menu {
top: 0;
bottom: 80px;
bottom: 80px;
max-height: calc(100vh - 80px);
}

Expand Down
4 changes: 2 additions & 2 deletions components/Products/ProductsSingleProduct.vue
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ watch(
dataValue.product?.variations?.nodes[0].databaseId;
}
},
{ immediate: true }
{ immediate: true },
);

/**
Expand All @@ -127,7 +127,7 @@ const addProductToCart = async (product) => {
await cart.addToCart(product);
toast.value.show();
} catch (error) {
console.error('Error adding product to cart:', error);
console.error("Error adding product to cart:", error);
// You might want to show an error message to the user here
}
};
Expand Down
12 changes: 6 additions & 6 deletions components/common/Toast.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,17 @@
</template>

<script setup>
import { ref, watch } from 'vue';
import { ref, watch } from "vue";

const props = defineProps({
message: {
type: String,
default: 'Product added to cart'
default: "Product added to cart",
},
duration: {
type: Number,
default: 3000
}
default: 3000,
},
});

const isVisible = ref(false);
Expand All @@ -45,7 +45,7 @@ defineExpose({ show });
}

.toast-content {
background-color: #4CAF50;
background-color: #4caf50;
color: white;
padding: 16px;
border-radius: 4px;
Expand All @@ -68,4 +68,4 @@ defineExpose({ show });
opacity: 1;
transform: translateX(0);
}
</style>
</style>
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"preview": "nuxt preview",
"postinstall": "nuxt prepare",
"format": "prettier --write \"**/*.{js,ts,vue}\"",
"refresh": "rm -rf node_modules && rm pnpm-lock.yaml && pnpm i && npm run format"
"refresh": "rm -rf node_modules && rm pnpm-lock.yaml && pnpm i && pnpm run format"
},
"devDependencies": {
"@playwright/test": "^1.47.1",
Expand Down
2 changes: 1 addition & 1 deletion plugins/apollo.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ export default defineNuxtPlugin((nuxtApp) => {
cache,
defaultOptions: {
watchQuery: {
fetchPolicy: 'cache-and-network',
fetchPolicy: "cache-and-network",
},
},
});
Expand Down
8 changes: 4 additions & 4 deletions plugins/cartUpdater.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { useCart } from '@/store/useCart';
import { useCart } from "@/store/useCart";

export default defineNuxtPlugin((nuxtApp) => {
nuxtApp.hook('app:created', () => {
nuxtApp.hook("app:created", () => {
const cart = useCart();

// Refetch cart data on initial load
cart.refetch();

Expand All @@ -13,4 +13,4 @@ export default defineNuxtPlugin((nuxtApp) => {
next();
});
});
});
});
Loading