prettier fix
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import type { AdminProductVariant, StoreProduct } from "@medusajs/types";
|
||||
import type { AdminProductVariant, StoreProduct } from '@medusajs/types';
|
||||
|
||||
type Product = {
|
||||
metadata?: {
|
||||
@@ -11,15 +11,26 @@ type Product = {
|
||||
} | null;
|
||||
} | null;
|
||||
|
||||
export const getAnalysisElementMedusaProductIds = (products: (Pick<StoreProduct, 'metadata'> & { variant?: Pick<AdminProductVariant, 'metadata'> })[]) => {
|
||||
export const getAnalysisElementMedusaProductIds = (
|
||||
products: (Pick<StoreProduct, 'metadata'> & {
|
||||
variant?: Pick<AdminProductVariant, 'metadata'>;
|
||||
})[],
|
||||
) => {
|
||||
if (!products) {
|
||||
return [];
|
||||
}
|
||||
|
||||
const mapped = products
|
||||
.flatMap((product) => {
|
||||
const value = (product as Product)?.metadata?.analysisElementMedusaProductIds?.replaceAll("'", '"');
|
||||
const value_variant = (product as Product)?.variant?.metadata?.analysisElementMedusaProductIds?.replaceAll("'", '"');
|
||||
const value = (
|
||||
product as Product
|
||||
)?.metadata?.analysisElementMedusaProductIds?.replaceAll("'", '"');
|
||||
const value_variant = (
|
||||
product as Product
|
||||
)?.variant?.metadata?.analysisElementMedusaProductIds?.replaceAll(
|
||||
"'",
|
||||
'"',
|
||||
);
|
||||
|
||||
const result: string[] = [];
|
||||
try {
|
||||
@@ -27,14 +38,20 @@ export const getAnalysisElementMedusaProductIds = (products: (Pick<StoreProduct,
|
||||
result.push(...JSON.parse(value as string));
|
||||
}
|
||||
} catch (e) {
|
||||
console.error("Failed to parse analysisElementMedusaProductIds from analysis package variant, possibly invalid format", e);
|
||||
console.error(
|
||||
'Failed to parse analysisElementMedusaProductIds from analysis package variant, possibly invalid format',
|
||||
e,
|
||||
);
|
||||
}
|
||||
try {
|
||||
if (value_variant) {
|
||||
result.push(...JSON.parse(value_variant as string));
|
||||
}
|
||||
} catch (e) {
|
||||
console.error("Failed to parse analysisElementMedusaProductIds from analysis package, possibly invalid format", e);
|
||||
console.error(
|
||||
'Failed to parse analysisElementMedusaProductIds from analysis package, possibly invalid format',
|
||||
e,
|
||||
);
|
||||
}
|
||||
|
||||
return result;
|
||||
@@ -42,4 +59,4 @@ export const getAnalysisElementMedusaProductIds = (products: (Pick<StoreProduct,
|
||||
.filter(Boolean) as string[];
|
||||
|
||||
return [...new Set(mapped)];
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { createBrowserClient } from "@supabase/ssr";
|
||||
import { createBrowserClient } from '@supabase/ssr';
|
||||
|
||||
export const createClient = () =>
|
||||
createBrowserClient(
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { createServerClient } from "@supabase/ssr";
|
||||
import { type NextRequest, NextResponse } from "next/server";
|
||||
import { type NextRequest, NextResponse } from 'next/server';
|
||||
|
||||
import { createServerClient } from '@supabase/ssr';
|
||||
|
||||
export const updateSession = async (request: NextRequest) => {
|
||||
// This `try/catch` block is only here for the interactive tutorial.
|
||||
@@ -40,12 +41,12 @@ export const updateSession = async (request: NextRequest) => {
|
||||
const user = await supabase.auth.getUser();
|
||||
|
||||
// protected routes
|
||||
if (request.nextUrl.pathname.startsWith("/protected") && user.error) {
|
||||
return NextResponse.redirect(new URL("/sign-in", request.url));
|
||||
if (request.nextUrl.pathname.startsWith('/protected') && user.error) {
|
||||
return NextResponse.redirect(new URL('/sign-in', request.url));
|
||||
}
|
||||
|
||||
if (request.nextUrl.pathname === "/" && !user.error) {
|
||||
return NextResponse.redirect(new URL("/protected", request.url));
|
||||
if (request.nextUrl.pathname === '/' && !user.error) {
|
||||
return NextResponse.redirect(new URL('/protected', request.url));
|
||||
}
|
||||
|
||||
return response;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { createServerClient } from "@supabase/ssr";
|
||||
import { cookies } from "next/headers";
|
||||
import { cookies } from 'next/headers';
|
||||
|
||||
import { createServerClient } from '@supabase/ssr';
|
||||
|
||||
export const createClient = async () => {
|
||||
const cookieStore = await cookies();
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { redirect } from "next/navigation";
|
||||
import { redirect } from 'next/navigation';
|
||||
|
||||
/**
|
||||
* Redirects to a specified path with an encoded message as a query parameter.
|
||||
@@ -8,7 +8,7 @@ import { redirect } from "next/navigation";
|
||||
* @returns {never} This function doesn't return as it triggers a redirect.
|
||||
*/
|
||||
export function encodedRedirect(
|
||||
type: "error" | "success",
|
||||
type: 'error' | 'success',
|
||||
path: string,
|
||||
message: string,
|
||||
) {
|
||||
|
||||
Reference in New Issue
Block a user