Compare commits
35 Commits
keycloak2
...
fbafb8dcf4
| Author | SHA1 | Date | |
|---|---|---|---|
| fbafb8dcf4 | |||
| dfcfdb8f97 | |||
| d87d08aaea | |||
| c83694222d | |||
| c08fe26b36 | |||
| d3202a2cb2 | |||
| 2435e6f113 | |||
| 54856b0e45 | |||
| 95e72bb3f8 | |||
| 3d268b6061 | |||
| 5c6280ec42 | |||
| 0de9dcf7e3 | |||
| f3a6fb627c | |||
| c1746c6c20 | |||
| c6f56f6e11 | |||
| a6b246cdf3 | |||
| a705dea9cf | |||
| 8485d2e9a3 | |||
| c356f69656 | |||
| cacd23be40 | |||
| f8765dce49 | |||
| 42bebb6d93 | |||
| 354a0c04ee | |||
| 72bb9a33ef | |||
| 771c28f8ef | |||
|
|
e9497c3d52 | ||
| 70188f297f | |||
| e0940a1600 | |||
| 65eb6c780d | |||
| 6e9cde6b95 | |||
| 3a062eaa9c | |||
| c07acb85a2 | |||
| 1de564b917 | |||
| a2c080914a | |||
|
|
94dd00b9ca |
@@ -6,10 +6,10 @@
|
||||
## PUBLIC KEYS OR CONFIGURATION ARE OKAY TO BE PLACED HERE.
|
||||
|
||||
# SUPABASE
|
||||
NEXT_PUBLIC_SUPABASE_URL=https://oqsdacktkhmbylmzstjq.supabase.co
|
||||
NEXT_PUBLIC_SUPABASE_ANON_KEY=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6Im9xc2RhY2t0a2htYnlsbXpzdGpxIiwicm9sZSI6ImFub24iLCJpYXQiOjE3NDY1MjgxMjMsImV4cCI6MjA2MjEwNDEyM30.LdHCTWxijFmhXdnT9KVuLRAVbtSwY7OO-oLtpd8GmO0
|
||||
# NEXT_PUBLIC_SUPABASE_URL=https://oqsdacktkhmbylmzstjq.supabase.co
|
||||
# NEXT_PUBLIC_SUPABASE_ANON_KEY=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6Im9xc2RhY2t0a2htYnlsbXpzdGpxIiwicm9sZSI6ImFub24iLCJpYXQiOjE3NDY1MjgxMjMsImV4cCI6MjA2MjEwNDEyM30.LdHCTWxijFmhXdnT9KVuLRAVbtSwY7OO-oLtpd8GmO0
|
||||
|
||||
NEXT_PUBLIC_SITE_URL=https://test.medreport.ee
|
||||
# NEXT_PUBLIC_SITE_URL=https://test.medreport.ee
|
||||
|
||||
# MONTONIO
|
||||
NEXT_PUBLIC_MONTONIO_ACCESS_KEY=7da5d7fa-3383-4997-9435-46aa818f4ead
|
||||
# # MONTONIO
|
||||
# NEXT_PUBLIC_MONTONIO_ACCESS_KEY=7da5d7fa-3383-4997-9435-46aa818f4ead
|
||||
|
||||
10
.env.staging
10
.env.staging
@@ -6,10 +6,10 @@
|
||||
## PUBLIC KEYS OR CONFIGURATION ARE OKAY TO BE PLACED HERE.
|
||||
|
||||
# SUPABASE
|
||||
NEXT_PUBLIC_SUPABASE_URL=https://kaldvociniytdbbcxvqk.supabase.co
|
||||
NEXT_PUBLIC_SUPABASE_ANON_KEY=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6ImthbGR2b2Npbml5dGRiYmN4dnFrIiwicm9sZSI6ImFub24iLCJpYXQiOjE3NTYzNjQ5OTYsImV4cCI6MjA3MTk0MDk5Nn0.eixihH2KGkJZolY9FiQDicJOo2kxvXrSe6gGUCrkLo0
|
||||
# NEXT_PUBLIC_SUPABASE_URL=https://klocrucggryikaxzvxgc.supabase.co
|
||||
# NEXT_PUBLIC_SUPABASE_ANON_KEY=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6Imtsb2NydWNnZ3J5aWtheHp2eGdjIiwicm9sZSI6ImFub24iLCJpYXQiOjE3NTY5ODQ2MjgsImV4cCI6MjA3MjU2MDYyOH0.2XOQngowcymiSUZO_XEEWAWzco2uRIjwG7TAeRRLIdU
|
||||
|
||||
NEXT_PUBLIC_SITE_URL=https://test.medreport.ee
|
||||
# NEXT_PUBLIC_SITE_URL=https://test.medreport.ee
|
||||
|
||||
# MONTONIO
|
||||
NEXT_PUBLIC_MONTONIO_ACCESS_KEY=7da5d7fa-3383-4997-9435-46aa818f4ead
|
||||
# # MONTONIO
|
||||
# NEXT_PUBLIC_MONTONIO_ACCESS_KEY=7da5d7fa-3383-4997-9435-46aa818f4ead
|
||||
|
||||
16
Dockerfile
16
Dockerfile
@@ -22,12 +22,12 @@ COPY . .
|
||||
ENV NODE_ENV=production
|
||||
|
||||
RUN set -a \
|
||||
&& . .env \
|
||||
&& . .env.production \
|
||||
&& . .env.staging \
|
||||
&& set +a \
|
||||
&& node check-env.js \
|
||||
&& pnpm build
|
||||
&& . .env \
|
||||
&& . .env.production \
|
||||
&& . .env.staging \
|
||||
&& set +a \
|
||||
&& node check-env.js \
|
||||
&& pnpm build
|
||||
|
||||
|
||||
# --- Stage 2: Runtime ---
|
||||
@@ -41,13 +41,13 @@ COPY --from=builder /app ./
|
||||
RUN cp ".env.${APP_ENV}" .env.local
|
||||
|
||||
RUN npm install -g pnpm@9 \
|
||||
&& pnpm install --prod --frozen-lockfile
|
||||
&& pnpm install --prod --frozen-lockfile
|
||||
|
||||
ENV NODE_ENV=production
|
||||
|
||||
# 🔍 Optional: Log key envs for debug
|
||||
RUN echo "📄 .env contents:" && cat .env.local \
|
||||
&& echo "🔧 Current ENV available to Next.js build:" && printenv | grep -E 'SUPABASE|STRIPE|NEXT|NODE_ENV' || true
|
||||
&& echo "🔧 Current ENV available to Next.js build:" && printenv | grep -E 'SUPABASE|STRIPE|NEXT|NODE_ENV' || true
|
||||
|
||||
|
||||
EXPOSE 3000
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { NextRequest, NextResponse } from "next/server";
|
||||
import loadEnv from "../handler/load-env";
|
||||
import validateApiKey from "../handler/validate-api-key";
|
||||
import { getOrderedAnalysisElementsIds, sendOrderToMedipost } from "~/lib/services/medipost.service";
|
||||
import { getOrderedAnalysisIds, sendOrderToMedipost } from "~/lib/services/medipost.service";
|
||||
import { retrieveOrder } from "@lib/data/orders";
|
||||
import { getMedipostDispatchTries } from "~/lib/services/audit.service";
|
||||
|
||||
@@ -25,7 +25,7 @@ export const POST = async (request: NextRequest) => {
|
||||
|
||||
try {
|
||||
const medusaOrder = await retrieveOrder(medusaOrderId);
|
||||
const orderedAnalysisElements = await getOrderedAnalysisElementsIds({ medusaOrder });
|
||||
const orderedAnalysisElements = await getOrderedAnalysisIds({ medusaOrder });
|
||||
await sendOrderToMedipost({ medusaOrderId, orderedAnalysisElements });
|
||||
console.info("Successfully sent order to medipost");
|
||||
return NextResponse.json({
|
||||
|
||||
@@ -3,7 +3,7 @@ import { getAnalysisOrdersAdmin } from "~/lib/services/order.service";
|
||||
import { composeOrderTestResponseXML, sendPrivateMessageTestResponse } from "~/lib/services/medipostTest.service";
|
||||
import { retrieveOrder } from "@lib/data";
|
||||
import { getAccountAdmin } from "~/lib/services/account.service";
|
||||
import { getOrderedAnalysisElementsIds } from "~/lib/services/medipost.service";
|
||||
import { getOrderedAnalysisIds } from "~/lib/services/medipost.service";
|
||||
import loadEnv from "../handler/load-env";
|
||||
import validateApiKey from "../handler/validate-api-key";
|
||||
|
||||
@@ -24,7 +24,7 @@ export async function POST(request: NextRequest) {
|
||||
const medusaOrder = await retrieveOrder(medusaOrderId)
|
||||
|
||||
const account = await getAccountAdmin({ primaryOwnerUserId: medreportOrder.user_id });
|
||||
const orderedAnalysisElementsIds = await getOrderedAnalysisElementsIds({ medusaOrder });
|
||||
const orderedAnalysisElementsIds = await getOrderedAnalysisIds({ medusaOrder });
|
||||
|
||||
console.info(`Sending test response for order=${medusaOrderId} with ${orderedAnalysisElementsIds.length} ordered analysis elements`);
|
||||
const idsToSend = orderedAnalysisElementsIds;
|
||||
@@ -35,8 +35,8 @@ export async function POST(request: NextRequest) {
|
||||
lastName: account.last_name ?? '',
|
||||
phone: account.phone ?? '',
|
||||
},
|
||||
orderedAnalysisElementsIds: idsToSend.map(({ analysisElementId }) => analysisElementId),
|
||||
orderedAnalysesIds: [],
|
||||
orderedAnalysisElementsIds: idsToSend.map(({ analysisElementId }) => analysisElementId).filter(Boolean) as number[],
|
||||
orderedAnalysesIds: idsToSend.map(({ analysisId }) => analysisId).filter(Boolean) as number[],
|
||||
orderId: medusaOrderId,
|
||||
orderCreatedAt: new Date(medreportOrder.created_at),
|
||||
});
|
||||
|
||||
@@ -3,7 +3,7 @@ import { getOrder } from "~/lib/services/order.service";
|
||||
import { composeOrderTestResponseXML, sendPrivateMessageTestResponse } from "~/lib/services/medipostTest.service";
|
||||
import { retrieveOrder } from "@lib/data";
|
||||
import { getAccountAdmin } from "~/lib/services/account.service";
|
||||
import { createMedipostActionLog, getOrderedAnalysisElementsIds } from "~/lib/services/medipost.service";
|
||||
import { createMedipostActionLog, getOrderedAnalysisIds } from "~/lib/services/medipost.service";
|
||||
|
||||
export async function POST(request: Request) {
|
||||
// const isDev = process.env.NODE_ENV === 'development';
|
||||
@@ -11,16 +11,15 @@ export async function POST(request: Request) {
|
||||
// return NextResponse.json({ error: 'This endpoint is only available in development mode' }, { status: 403 });
|
||||
// }
|
||||
|
||||
const { medusaOrderId, maxItems = null } = await request.json();
|
||||
const { medusaOrderId } = await request.json();
|
||||
|
||||
const medusaOrder = await retrieveOrder(medusaOrderId)
|
||||
const medreportOrder = await getOrder({ medusaOrderId });
|
||||
|
||||
const account = await getAccountAdmin({ primaryOwnerUserId: medreportOrder.user_id });
|
||||
const orderedAnalysisElementsIds = await getOrderedAnalysisElementsIds({ medusaOrder });
|
||||
const orderedAnalysisElementsIds = await getOrderedAnalysisIds({ medusaOrder });
|
||||
|
||||
console.info(`Sending test response for order=${medusaOrderId} with ${orderedAnalysisElementsIds.length} (${maxItems ?? 'all'}) ordered analysis elements`);
|
||||
const idsToSend = typeof maxItems === 'number' ? orderedAnalysisElementsIds.slice(0, maxItems) : orderedAnalysisElementsIds;
|
||||
console.info(`Sending test response for order=${medusaOrderId} with ${orderedAnalysisElementsIds.length} ordered analysis elements`);
|
||||
const messageXml = await composeOrderTestResponseXML({
|
||||
person: {
|
||||
idCode: account.personal_code!,
|
||||
@@ -28,8 +27,8 @@ export async function POST(request: Request) {
|
||||
lastName: account.last_name ?? '',
|
||||
phone: account.phone ?? '',
|
||||
},
|
||||
orderedAnalysisElementsIds: idsToSend.map(({ analysisElementId }) => analysisElementId),
|
||||
orderedAnalysesIds: [],
|
||||
orderedAnalysisElementsIds: orderedAnalysisElementsIds.map(({ analysisElementId }) => analysisElementId).filter(Boolean) as number[],
|
||||
orderedAnalysesIds: orderedAnalysisElementsIds.map(({ analysisId }) => analysisId).filter(Boolean) as number[],
|
||||
orderId: medusaOrderId,
|
||||
orderCreatedAt: new Date(medreportOrder.created_at),
|
||||
});
|
||||
|
||||
@@ -8,7 +8,7 @@ import { listProductTypes } from "@lib/data/products";
|
||||
import { placeOrder, retrieveCart } from "@lib/data/cart";
|
||||
import { createI18nServerInstance } from "~/lib/i18n/i18n.server";
|
||||
import { createOrder } from '~/lib/services/order.service';
|
||||
import { getOrderedAnalysisElementsIds, sendOrderToMedipost } from '~/lib/services/medipost.service';
|
||||
import { getOrderedAnalysisIds, sendOrderToMedipost } from '~/lib/services/medipost.service';
|
||||
import { createNotificationsApi } from '@kit/notifications/api';
|
||||
import { getSupabaseServerAdminClient } from '@kit/supabase/server-admin-client';
|
||||
import { AccountWithParams } from '@kit/accounts/api';
|
||||
@@ -114,7 +114,7 @@ export async function processMontonioCallback(orderToken: string) {
|
||||
|
||||
|
||||
const medusaOrder = await placeOrder(cartId, { revalidateCacheTags: false });
|
||||
const orderedAnalysisElements = await getOrderedAnalysisElementsIds({ medusaOrder });
|
||||
const orderedAnalysisElements = await getOrderedAnalysisIds({ medusaOrder });
|
||||
const orderId = await createOrder({ medusaOrder, orderedAnalysisElements });
|
||||
|
||||
const { productTypes } = await listProductTypes();
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
"use client"
|
||||
|
||||
import { Badge, Heading, Text } from "@medusajs/ui"
|
||||
import { Badge, Text } from "@medusajs/ui"
|
||||
import { toast } from '@kit/ui/sonner';
|
||||
import React, { useActionState } from "react";
|
||||
|
||||
import { applyPromotions, submitPromotionForm } from "@lib/data/cart"
|
||||
@@ -31,11 +32,19 @@ export default function DiscountCode({ cart }: {
|
||||
|
||||
const removePromotionCode = async (code: string) => {
|
||||
const validPromotions = promotions.filter(
|
||||
(promotion) => promotion.code !== code
|
||||
(promotion) => promotion.code !== code,
|
||||
)
|
||||
|
||||
await applyPromotions(
|
||||
validPromotions.filter((p) => p.code === undefined).map((p) => p.code!)
|
||||
validPromotions.filter((p) => p.code === undefined).map((p) => p.code!),
|
||||
{
|
||||
onSuccess: () => {
|
||||
toast.success(t('cart:discountCode.removeSuccess'));
|
||||
},
|
||||
onError: () => {
|
||||
toast.error(t('cart:discountCode.removeError'));
|
||||
},
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
@@ -45,7 +54,14 @@ export default function DiscountCode({ cart }: {
|
||||
.map((p) => p.code!)
|
||||
codes.push(code.toString())
|
||||
|
||||
await applyPromotions(codes)
|
||||
await applyPromotions(codes, {
|
||||
onSuccess: () => {
|
||||
toast.success(t('cart:discountCode.addSuccess'));
|
||||
},
|
||||
onError: () => {
|
||||
toast.error(t('cart:discountCode.addError'));
|
||||
},
|
||||
});
|
||||
|
||||
form.reset()
|
||||
}
|
||||
@@ -64,7 +80,7 @@ export default function DiscountCode({ cart }: {
|
||||
<Form {...form}>
|
||||
<form
|
||||
onSubmit={form.handleSubmit((data) => addPromotionCode(data.code))}
|
||||
className="w-full mb-2 flex gap-x-2"
|
||||
className="w-full mb-2 flex gap-x-2 sm:flex-row flex-col gap-y-2"
|
||||
>
|
||||
<FormField
|
||||
name={'code'}
|
||||
@@ -87,16 +103,12 @@ export default function DiscountCode({ cart }: {
|
||||
</form>
|
||||
</Form>
|
||||
|
||||
<p className="text-sm text-muted-foreground">
|
||||
<Trans i18nKey={'cart:discountCode.subtitle'} />
|
||||
</p>
|
||||
|
||||
{promotions.length > 0 && (
|
||||
<div className="w-full flex items-center">
|
||||
<div className="flex flex-col w-full">
|
||||
<Heading className="txt-medium mb-2">
|
||||
Promotion(s) applied:
|
||||
</Heading>
|
||||
{promotions.length > 0 ? (
|
||||
<div className="w-full flex items-center mt-4">
|
||||
<div className="flex flex-col w-full gap-y-2">
|
||||
<p>
|
||||
<Trans i18nKey={'cart:discountCode.appliedCodes'} />
|
||||
</p>
|
||||
|
||||
{promotions.map((promotion) => {
|
||||
return (
|
||||
@@ -110,6 +122,7 @@ export default function DiscountCode({ cart }: {
|
||||
<Badge
|
||||
color={promotion.is_automatic ? "green" : "grey"}
|
||||
size="small"
|
||||
className="px-4"
|
||||
>
|
||||
{promotion.code}
|
||||
</Badge>{" "}
|
||||
@@ -151,7 +164,7 @@ export default function DiscountCode({ cart }: {
|
||||
>
|
||||
<Trash size={14} />
|
||||
<span className="sr-only">
|
||||
Remove discount code from order
|
||||
<Trans i18nKey={'cart:discountCode.remove'} />
|
||||
</span>
|
||||
</button>
|
||||
)}
|
||||
@@ -160,6 +173,10 @@ export default function DiscountCode({ cart }: {
|
||||
})}
|
||||
</div>
|
||||
</div>
|
||||
) : (
|
||||
<p className="text-sm text-muted-foreground">
|
||||
<Trans i18nKey={'cart:discountCode.subtitle'} />
|
||||
</p>
|
||||
)}
|
||||
</div>
|
||||
)
|
||||
|
||||
@@ -18,7 +18,7 @@ import { useTranslation } from "react-i18next";
|
||||
import { handleNavigateToPayment } from "@/lib/services/medusaCart.service";
|
||||
import AnalysisLocation from "./analysis-location";
|
||||
|
||||
const IS_DISCOUNT_SHOWN = false as boolean;
|
||||
const IS_DISCOUNT_SHOWN = true as boolean;
|
||||
|
||||
export default function Cart({
|
||||
cart,
|
||||
@@ -69,7 +69,7 @@ export default function Cart({
|
||||
|
||||
const hasCartItems = Array.isArray(cart.items) && cart.items.length > 0;
|
||||
const isLocationsShown = synlabAnalyses.length > 0;
|
||||
|
||||
|
||||
return (
|
||||
<div className="grid grid-cols-1 small:grid-cols-[1fr_360px] gap-x-40 lg:px-4">
|
||||
<div className="flex flex-col bg-white gap-y-6">
|
||||
@@ -77,28 +77,62 @@ export default function Cart({
|
||||
<CartItems cart={cart} items={ttoServiceItems} productColumnLabelKey="cart:items.ttoServices.productColumnLabel" />
|
||||
</div>
|
||||
{hasCartItems && (
|
||||
<div className="flex justify-end gap-x-4 px-6 py-4">
|
||||
<div className="mr-[36px]">
|
||||
<p className="ml-0 font-bold text-sm">
|
||||
<Trans i18nKey="cart:total" />
|
||||
</p>
|
||||
<>
|
||||
<div className="flex justify-end gap-x-4 px-6 pt-4">
|
||||
<div className="mr-[36px]">
|
||||
<p className="ml-0 font-bold text-sm text-muted-foreground">
|
||||
<Trans i18nKey="cart:subtotal" />
|
||||
</p>
|
||||
</div>
|
||||
<div className="mr-[116px]">
|
||||
<p className="text-sm">
|
||||
{formatCurrency({
|
||||
value: cart.subtotal,
|
||||
currencyCode: cart.currency_code,
|
||||
locale: language,
|
||||
})}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div className="mr-[116px]">
|
||||
<p className="text-sm">
|
||||
{formatCurrency({
|
||||
value: cart.total,
|
||||
currencyCode: cart.currency_code,
|
||||
locale: language,
|
||||
})}
|
||||
</p>
|
||||
<div className="flex justify-end gap-x-4 px-6 py-2">
|
||||
<div className="mr-[36px]">
|
||||
<p className="ml-0 font-bold text-sm text-muted-foreground">
|
||||
<Trans i18nKey="cart:promotionsTotal" />
|
||||
</p>
|
||||
</div>
|
||||
<div className="mr-[116px]">
|
||||
<p className="text-sm">
|
||||
{formatCurrency({
|
||||
value: cart.discount_total,
|
||||
currencyCode: cart.currency_code,
|
||||
locale: language,
|
||||
})}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div className="flex justify-end gap-x-4 px-6">
|
||||
<div className="mr-[36px]">
|
||||
<p className="ml-0 font-bold text-sm">
|
||||
<Trans i18nKey="cart:total" />
|
||||
</p>
|
||||
</div>
|
||||
<div className="mr-[116px]">
|
||||
<p className="text-sm">
|
||||
{formatCurrency({
|
||||
value: cart.total,
|
||||
currencyCode: cart.currency_code,
|
||||
locale: language,
|
||||
})}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</>
|
||||
)}
|
||||
|
||||
<div className="flex gap-y-6 py-8">
|
||||
<div className="flex sm:flex-row flex-col gap-y-6 py-8 gap-x-4">
|
||||
{IS_DISCOUNT_SHOWN && (
|
||||
<Card
|
||||
className="flex flex-col justify-between w-1/2"
|
||||
className="flex flex-col justify-between w-full sm:w-1/2"
|
||||
>
|
||||
<CardHeader className="pb-4">
|
||||
<h5>
|
||||
@@ -113,7 +147,7 @@ export default function Cart({
|
||||
|
||||
{isLocationsShown && (
|
||||
<Card
|
||||
className="flex flex-col justify-between w-1/2"
|
||||
className="flex flex-col justify-between w-full sm:w-1/2"
|
||||
>
|
||||
<CardHeader className="pb-4">
|
||||
<h5>
|
||||
|
||||
128
app/home/(user)/_components/dashboard-recommendations.tsx
Normal file
128
app/home/(user)/_components/dashboard-recommendations.tsx
Normal file
@@ -0,0 +1,128 @@
|
||||
'use client';
|
||||
|
||||
import Link from 'next/link';
|
||||
|
||||
import { BlendingModeIcon } from '@radix-ui/react-icons';
|
||||
import {
|
||||
Droplets,
|
||||
} from 'lucide-react';
|
||||
|
||||
import { InfoTooltip } from '@kit/shared/components/ui/info-tooltip';
|
||||
import { Button } from '@kit/ui/button';
|
||||
import {
|
||||
Card,
|
||||
CardContent,
|
||||
CardHeader,
|
||||
} from '@kit/ui/card';
|
||||
import { Trans } from '@kit/ui/trans';
|
||||
import { cn } from '@kit/ui/utils';
|
||||
|
||||
const dummyRecommendations = [
|
||||
{
|
||||
icon: <BlendingModeIcon className="size-4" />,
|
||||
color: 'bg-cyan/10 text-cyan',
|
||||
title: 'Kolesterooli kontroll',
|
||||
description: 'HDL-kolestrool',
|
||||
tooltipContent: 'Selgitus',
|
||||
price: '20,00 €',
|
||||
buttonText: 'Telli',
|
||||
href: '/home/booking',
|
||||
},
|
||||
{
|
||||
icon: <BlendingModeIcon className="size-4" />,
|
||||
color: 'bg-primary/10 text-primary',
|
||||
title: 'Kolesterooli kontroll',
|
||||
tooltipContent: 'Selgitus',
|
||||
description: 'LDL-Kolesterool',
|
||||
buttonText: 'Broneeri',
|
||||
href: '/home/booking',
|
||||
},
|
||||
{
|
||||
icon: <Droplets />,
|
||||
color: 'bg-destructive/10 text-destructive',
|
||||
title: 'Vererõhu kontroll',
|
||||
tooltipContent: 'Selgitus',
|
||||
description: 'Score-Risk 2',
|
||||
price: '20,00 €',
|
||||
buttonText: 'Telli',
|
||||
href: '/home/booking',
|
||||
},
|
||||
];
|
||||
|
||||
export default function DashboardRecommendations() {
|
||||
return (
|
||||
<Card>
|
||||
<CardHeader className="items-start">
|
||||
<h4>
|
||||
<Trans i18nKey="dashboard:recommendedForYou" />
|
||||
</h4>
|
||||
</CardHeader>
|
||||
<CardContent className="space-y-6">
|
||||
{dummyRecommendations.map(
|
||||
(
|
||||
{
|
||||
icon,
|
||||
color,
|
||||
title,
|
||||
description,
|
||||
tooltipContent,
|
||||
price,
|
||||
buttonText,
|
||||
href,
|
||||
},
|
||||
index,
|
||||
) => {
|
||||
return (
|
||||
<div
|
||||
className="flex w-full justify-between gap-3 overflow-scroll"
|
||||
key={index}
|
||||
>
|
||||
<div className="mr-4 flex min-w-fit flex-row items-center gap-4">
|
||||
<div
|
||||
className={cn(
|
||||
'flex size-8 items-center-safe justify-center-safe rounded-full text-white',
|
||||
color,
|
||||
)}
|
||||
>
|
||||
{icon}
|
||||
</div>
|
||||
<div className="min-w-fit">
|
||||
<div className="inline-flex items-center gap-1 align-baseline text-sm font-medium">
|
||||
{title}
|
||||
<InfoTooltip content={tooltipContent} />
|
||||
</div>
|
||||
<p className="text-muted-foreground text-sm">
|
||||
{description}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div className="grid w-36 min-w-fit auto-rows-fr grid-cols-2 items-center gap-4">
|
||||
<p className="text-sm font-medium"> {price}</p>
|
||||
{href ? (
|
||||
<Link href={href}>
|
||||
<Button
|
||||
size="sm"
|
||||
variant="secondary"
|
||||
className="w-full min-w-fit"
|
||||
>
|
||||
{buttonText}
|
||||
</Button>
|
||||
</Link>
|
||||
) : (
|
||||
<Button
|
||||
size="sm"
|
||||
variant="secondary"
|
||||
className="w-full min-w-fit"
|
||||
>
|
||||
{buttonText}
|
||||
</Button>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
},
|
||||
)}
|
||||
</CardContent>
|
||||
</Card>
|
||||
);
|
||||
}
|
||||
@@ -9,20 +9,17 @@ import {
|
||||
Activity,
|
||||
ChevronRight,
|
||||
Clock9,
|
||||
Droplets,
|
||||
Pill,
|
||||
Scale,
|
||||
TrendingUp,
|
||||
User,
|
||||
} from 'lucide-react';
|
||||
|
||||
import { InfoTooltip } from '@kit/shared/components/ui/info-tooltip';
|
||||
import { pathsConfig } from '@kit/shared/config';
|
||||
import { getPersonParameters } from '@kit/shared/utils';
|
||||
import { Button } from '@kit/ui/button';
|
||||
import {
|
||||
Card,
|
||||
CardContent,
|
||||
CardDescription,
|
||||
CardFooter,
|
||||
CardHeader,
|
||||
@@ -38,6 +35,7 @@ import {
|
||||
getBmiBackgroundColor,
|
||||
getBmiStatus,
|
||||
} from '~/lib/utils';
|
||||
import DashboardRecommendations from './dashboard-recommendations';
|
||||
|
||||
const getCardVariant = (isSuccess: boolean | null): CardProps['variant'] => {
|
||||
if (isSuccess === null) return 'default';
|
||||
@@ -135,37 +133,7 @@ const cards = ({
|
||||
},
|
||||
];
|
||||
|
||||
const dummyRecommendations = [
|
||||
{
|
||||
icon: <BlendingModeIcon className="size-4" />,
|
||||
color: 'bg-cyan/10 text-cyan',
|
||||
title: 'Kolesterooli kontroll',
|
||||
description: 'HDL-kolestrool',
|
||||
tooltipContent: 'Selgitus',
|
||||
price: '20,00 €',
|
||||
buttonText: 'Telli',
|
||||
href: '/home/booking',
|
||||
},
|
||||
{
|
||||
icon: <BlendingModeIcon className="size-4" />,
|
||||
color: 'bg-primary/10 text-primary',
|
||||
title: 'Kolesterooli kontroll',
|
||||
tooltipContent: 'Selgitus',
|
||||
description: 'LDL-Kolesterool',
|
||||
buttonText: 'Broneeri',
|
||||
href: '/home/booking',
|
||||
},
|
||||
{
|
||||
icon: <Droplets />,
|
||||
color: 'bg-destructive/10 text-destructive',
|
||||
title: 'Vererõhu kontroll',
|
||||
tooltipContent: 'Selgitus',
|
||||
description: 'Score-Risk 2',
|
||||
price: '20,00 €',
|
||||
buttonText: 'Telli',
|
||||
href: '/home/booking',
|
||||
},
|
||||
];
|
||||
const IS_SHOWN_RECOMMENDATIONS = false as boolean;
|
||||
|
||||
export default function Dashboard({
|
||||
account,
|
||||
@@ -232,79 +200,7 @@ export default function Dashboard({
|
||||
),
|
||||
)}
|
||||
</div>
|
||||
<Card>
|
||||
<CardHeader className="items-start">
|
||||
<h4>
|
||||
<Trans i18nKey="dashboard:recommendedForYou" />
|
||||
</h4>
|
||||
</CardHeader>
|
||||
<CardContent className="space-y-6">
|
||||
{dummyRecommendations.map(
|
||||
(
|
||||
{
|
||||
icon,
|
||||
color,
|
||||
title,
|
||||
description,
|
||||
tooltipContent,
|
||||
price,
|
||||
buttonText,
|
||||
href,
|
||||
},
|
||||
index,
|
||||
) => {
|
||||
return (
|
||||
<div
|
||||
className="flex w-full justify-between gap-3 overflow-scroll"
|
||||
key={index}
|
||||
>
|
||||
<div className="mr-4 flex min-w-fit flex-row items-center gap-4">
|
||||
<div
|
||||
className={cn(
|
||||
'flex size-8 items-center-safe justify-center-safe rounded-full text-white',
|
||||
color,
|
||||
)}
|
||||
>
|
||||
{icon}
|
||||
</div>
|
||||
<div className="min-w-fit">
|
||||
<div className="inline-flex items-center gap-1 align-baseline text-sm font-medium">
|
||||
{title}
|
||||
<InfoTooltip content={tooltipContent} />
|
||||
</div>
|
||||
<p className="text-muted-foreground text-sm">
|
||||
{description}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div className="grid w-36 min-w-fit auto-rows-fr grid-cols-2 items-center gap-4">
|
||||
<p className="text-sm font-medium"> {price}</p>
|
||||
{href ? (
|
||||
<Link href={href}>
|
||||
<Button
|
||||
size="sm"
|
||||
variant="secondary"
|
||||
className="w-full min-w-fit"
|
||||
>
|
||||
{buttonText}
|
||||
</Button>
|
||||
</Link>
|
||||
) : (
|
||||
<Button
|
||||
size="sm"
|
||||
variant="secondary"
|
||||
className="w-full min-w-fit"
|
||||
>
|
||||
{buttonText}
|
||||
</Button>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
},
|
||||
)}
|
||||
</CardContent>
|
||||
</Card>
|
||||
{IS_SHOWN_RECOMMENDATIONS && <DashboardRecommendations />}
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -105,12 +105,18 @@ export const createMedusaSyncSuccessEntry = async () => {
|
||||
});
|
||||
}
|
||||
|
||||
export async function getAnalyses({ ids }: { ids: number[] }): Promise<AnalysesWithGroupsAndElements> {
|
||||
const { data } = await getSupabaseServerAdminClient()
|
||||
export async function getAnalyses({ ids, originalIds }: { ids?: number[], originalIds?: string[] }): Promise<AnalysesWithGroupsAndElements> {
|
||||
const query = getSupabaseServerAdminClient()
|
||||
.schema('medreport')
|
||||
.from('analyses')
|
||||
.select(`*, analysis_elements(*, analysis_groups(*))`)
|
||||
.in('id', ids);
|
||||
.select(`*, analysis_elements(*, analysis_groups(*))`);
|
||||
if (Array.isArray(ids)) {
|
||||
query.in('id', ids);
|
||||
}
|
||||
if (Array.isArray(originalIds)) {
|
||||
query.in('analysis_id_original', originalIds);
|
||||
}
|
||||
const { data } = await query.throwOnError();
|
||||
|
||||
return data as unknown as AnalysesWithGroupsAndElements;
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ import {
|
||||
getClientInstitution,
|
||||
getClientPerson,
|
||||
getConfidentiality,
|
||||
getOrderEnteredPerson,
|
||||
getPais,
|
||||
getPatient,
|
||||
getProviderInstitution,
|
||||
@@ -553,14 +554,12 @@ export async function composeOrderXML({
|
||||
${getPais(USER, RECIPIENT, orderCreatedAt, orderId)}
|
||||
<Tellimus cito="EI">
|
||||
<ValisTellimuseId>${orderId}</ValisTellimuseId>
|
||||
<!--<TellijaAsutus>-->
|
||||
${getClientInstitution()}
|
||||
<!--<TeostajaAsutus>-->
|
||||
${getProviderInstitution()}
|
||||
<!--<TellijaIsik>-->
|
||||
${getClientPerson(person)}
|
||||
${getClientPerson()}
|
||||
${getOrderEnteredPerson()}
|
||||
<TellijaMarkused>${comment ?? ''}</TellijaMarkused>
|
||||
${getPatient(person)}
|
||||
${getPatient(person)}
|
||||
${getConfidentiality()}
|
||||
${specimenSection.join('')}
|
||||
${analysisSection?.join('')}
|
||||
@@ -666,7 +665,7 @@ async function syncPrivateMessage({
|
||||
unit: element.Mootyhik ?? null,
|
||||
original_response_element: element,
|
||||
analysis_name: element.UuringNimi || element.KNimetus,
|
||||
comment: element.UuringuKommentaar
|
||||
comment: element.UuringuKommentaar ?? '',
|
||||
})),
|
||||
);
|
||||
}
|
||||
@@ -715,7 +714,7 @@ export async function sendOrderToMedipost({
|
||||
orderedAnalysisElements,
|
||||
}: {
|
||||
medusaOrderId: string;
|
||||
orderedAnalysisElements: { analysisElementId: number }[];
|
||||
orderedAnalysisElements: { analysisElementId?: number; analysisId?: number }[];
|
||||
}) {
|
||||
const medreportOrder = await getOrder({ medusaOrderId });
|
||||
const account = await getAccountAdmin({ primaryOwnerUserId: medreportOrder.user_id });
|
||||
@@ -727,8 +726,8 @@ export async function sendOrderToMedipost({
|
||||
lastName: account.last_name ?? '',
|
||||
phone: account.phone ?? '',
|
||||
},
|
||||
orderedAnalysisElementsIds: orderedAnalysisElements.map(({ analysisElementId }) => analysisElementId),
|
||||
orderedAnalysesIds: [],
|
||||
orderedAnalysisElementsIds: orderedAnalysisElements.map(({ analysisElementId }) => analysisElementId).filter(Boolean) as number[],
|
||||
orderedAnalysesIds: orderedAnalysisElements.map(({ analysisId }) => analysisId).filter(Boolean) as number[],
|
||||
orderId: medusaOrderId,
|
||||
orderCreatedAt: new Date(medreportOrder.created_at),
|
||||
comment: '',
|
||||
@@ -784,12 +783,13 @@ export async function sendOrderToMedipost({
|
||||
await updateOrderStatus({ medusaOrderId, orderStatus: 'PROCESSING' });
|
||||
}
|
||||
|
||||
export async function getOrderedAnalysisElementsIds({
|
||||
export async function getOrderedAnalysisIds({
|
||||
medusaOrder,
|
||||
}: {
|
||||
medusaOrder: StoreOrder;
|
||||
}): Promise<{
|
||||
analysisElementId: number;
|
||||
analysisElementId?: number;
|
||||
analysisId?: number;
|
||||
}[]> {
|
||||
const countryCodes = await listRegions();
|
||||
const countryCode = countryCodes[0]!.countries![0]!.iso_2!;
|
||||
@@ -802,6 +802,14 @@ export async function getOrderedAnalysisElementsIds({
|
||||
return analysisElements.map(({ id }) => ({ analysisElementId: id }));
|
||||
}
|
||||
|
||||
async function getOrderedAnalyses(medusaOrder: StoreOrder) {
|
||||
const originalIds = (medusaOrder?.items ?? [])
|
||||
.map((a) => a.product?.metadata?.analysisIdOriginal)
|
||||
.filter((a) => typeof a === 'string') as string[];
|
||||
const analyses = await getAnalyses({ originalIds });
|
||||
return analyses.map(({ id }) => ({ analysisId: id }));
|
||||
}
|
||||
|
||||
async function getOrderedAnalysisPackages(medusaOrder: StoreOrder) {
|
||||
const orderedPackages = (medusaOrder?.items ?? []).filter(({ product }) => product?.handle.startsWith(ANALYSIS_PACKAGE_HANDLE_PREFIX));
|
||||
const orderedPackageIds = orderedPackages.map(({ product }) => product?.id).filter(Boolean) as string[];
|
||||
@@ -841,12 +849,13 @@ export async function getOrderedAnalysisElementsIds({
|
||||
return analysisElements.map(({ id }) => ({ analysisElementId: id }));
|
||||
}
|
||||
|
||||
const [analysisPackageElements, orderedAnalysisElements] = await Promise.all([
|
||||
const [analysisPackageElements, orderedAnalysisElements, orderedAnalyses] = await Promise.all([
|
||||
getOrderedAnalysisPackages(medusaOrder),
|
||||
getOrderedAnalysisElements(medusaOrder),
|
||||
getOrderedAnalyses(medusaOrder),
|
||||
]);
|
||||
|
||||
return [...analysisPackageElements, ...orderedAnalysisElements];
|
||||
return [...analysisPackageElements, ...orderedAnalysisElements, ...orderedAnalyses];
|
||||
}
|
||||
|
||||
export async function createMedipostActionLog({
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
import {
|
||||
getClientInstitution,
|
||||
getClientPerson,
|
||||
getOrderEnteredPerson,
|
||||
getPais,
|
||||
getPatient,
|
||||
getProviderInstitution,
|
||||
@@ -104,7 +105,8 @@ export async function composeOrderTestResponseXML({
|
||||
<ValisTellimuseId>${orderId}</ValisTellimuseId>
|
||||
${getClientInstitution({ index: 1 })}
|
||||
${getProviderInstitution({ index: 1 })}
|
||||
${getClientPerson(person)}
|
||||
${getClientPerson()}
|
||||
${getOrderEnteredPerson()}
|
||||
<TellijaMarkused>Siia tuleb tellija poolne märkus</TellijaMarkused>
|
||||
|
||||
${getPatient(person)}
|
||||
|
||||
@@ -10,7 +10,7 @@ export async function createOrder({
|
||||
orderedAnalysisElements,
|
||||
}: {
|
||||
medusaOrder: StoreOrder;
|
||||
orderedAnalysisElements: { analysisElementId: number }[];
|
||||
orderedAnalysisElements: { analysisElementId?: number; analysisId?: number }[];
|
||||
}) {
|
||||
const supabase = getSupabaseServerClient();
|
||||
|
||||
@@ -21,8 +21,8 @@ export async function createOrder({
|
||||
const orderResult = await supabase.schema('medreport')
|
||||
.from('analysis_orders')
|
||||
.insert({
|
||||
analysis_element_ids: orderedAnalysisElements.map(({ analysisElementId }) => analysisElementId),
|
||||
analysis_ids: [],
|
||||
analysis_element_ids: orderedAnalysisElements.map(({ analysisElementId }) => analysisElementId).filter(Boolean) as number[],
|
||||
analysis_ids: orderedAnalysisElements.map(({ analysisId }) => analysisId).filter(Boolean) as number[],
|
||||
status: 'QUEUED',
|
||||
user_id: user.id,
|
||||
medusa_order_id: medusaOrder.id,
|
||||
|
||||
@@ -21,70 +21,48 @@ export const getPais = (
|
||||
<Saaja>${recipient}</Saaja>
|
||||
<Aeg>${format(createdAt, DATE_TIME_FORMAT)}</Aeg>
|
||||
<SaadetisId>${orderId}</SaadetisId>
|
||||
<Email>argo@medreport.ee</Email>
|
||||
<Email>info@medreport.ee</Email>
|
||||
</Pais>`;
|
||||
};
|
||||
|
||||
export const getClientInstitution = ({ index }: { index?: number } = {}) => {
|
||||
if (isProd) {
|
||||
// return correct data
|
||||
}
|
||||
return `<Asutus tyyp="TELLIJA" ${index ? ` jarjenumber="${index}"` : ''}>
|
||||
<AsutuseId>16381793</AsutuseId>
|
||||
<AsutuseNimi>MedReport OÜ</AsutuseNimi>
|
||||
<AsutuseKood>TSU</AsutuseKood>
|
||||
<AsutuseKood>MRP</AsutuseKood>
|
||||
<Telefon>+37258871517</Telefon>
|
||||
</Asutus>`;
|
||||
};
|
||||
|
||||
export const getProviderInstitution = ({ index }: { index?: number } = {}) => {
|
||||
if (isProd) {
|
||||
// return correct data
|
||||
}
|
||||
return `<Asutus tyyp="TEOSTAJA" ${index ? ` jarjenumber="${index}"` : ''}>
|
||||
<AsutuseId>11107913</AsutuseId>
|
||||
<AsutuseNimi>Synlab HTI Tallinn</AsutuseNimi>
|
||||
<AsutuseKood>SLA</AsutuseKood>
|
||||
<AsutuseNimi>Synlab Eesti OÜ</AsutuseNimi>
|
||||
<AsutuseKood>HTI</AsutuseKood>
|
||||
<AllyksuseNimi>Synlab HTI Tallinn</AllyksuseNimi>
|
||||
<Telefon>+3723417123</Telefon>
|
||||
<Telefon>+37217123</Telefon>
|
||||
</Asutus>`;
|
||||
};
|
||||
|
||||
export const getClientPerson = ({
|
||||
idCode,
|
||||
firstName,
|
||||
lastName,
|
||||
phone,
|
||||
}: {
|
||||
idCode: string,
|
||||
firstName: string,
|
||||
lastName: string,
|
||||
phone: string,
|
||||
}) => {
|
||||
if (isProd) {
|
||||
// return correct data
|
||||
}
|
||||
export const getClientPerson = () => {
|
||||
return `<Personal tyyp="TELLIJA" jarjenumber="1">
|
||||
<PersonalOID>1.3.6.1.4.1.28284.6.2.4.9</PersonalOID>
|
||||
<PersonalKood>${idCode}</PersonalKood>
|
||||
<PersonalPerekonnaNimi>${lastName}</PersonalPerekonnaNimi>
|
||||
<PersonalEesNimi>${firstName}</PersonalEesNimi>
|
||||
${phone ? `<Telefon>${phone.startsWith('+372') ? phone : `+372${phone}`}</Telefon>` : ''}
|
||||
<PersonalKood>D07907</PersonalKood>
|
||||
<PersonalPerekonnaNimi>Eduard</PersonalPerekonnaNimi>
|
||||
<PersonalEesNimi>Tsvetkov</PersonalEesNimi>
|
||||
<Telefon>+37258131202</Telefon>
|
||||
</Personal>`;
|
||||
};
|
||||
|
||||
// export const getOrderEnteredPerson = () => {
|
||||
// if (isProd) {
|
||||
// // return correct data
|
||||
// }
|
||||
// return `<Personal tyyp="SISESTAJA" jarjenumber="1">
|
||||
// <PersonalOID>1.3.6.1.4.1.28284.6.2.4.9</PersonalOID>
|
||||
// <PersonalKood>D07907</PersonalKood>
|
||||
// <PersonalPerekonnaNimi>Eduard</PersonalPerekonnaNimi>
|
||||
// <PersonalEesNimi>Tsvetkov</PersonalEesNimi>
|
||||
// <Telefon>+37258131202</Telefon>
|
||||
// </Personal>`;
|
||||
// };
|
||||
export const getOrderEnteredPerson = () => {
|
||||
return `<Personal tyyp="SISESTAJA" jarjenumber="2">
|
||||
<PersonalOID>1.3.6.1.4.1.28284.6.2.4.9</PersonalOID>
|
||||
<PersonalKood>D07907</PersonalKood>
|
||||
<PersonalPerekonnaNimi>Eduard</PersonalPerekonnaNimi>
|
||||
<PersonalEesNimi>Tsvetkov</PersonalEesNimi>
|
||||
<Telefon>+37258131202</Telefon>
|
||||
</Personal>`;
|
||||
};
|
||||
|
||||
export const getPatient = ({
|
||||
idCode,
|
||||
|
||||
@@ -50,7 +50,7 @@ const config = {
|
||||
},
|
||||
experimental: {
|
||||
mdxRs: true,
|
||||
reactCompiler: ENABLE_REACT_COMPILER,
|
||||
reactCompiler: false,
|
||||
optimizePackageImports: [
|
||||
'recharts',
|
||||
'lucide-react',
|
||||
|
||||
@@ -87,7 +87,10 @@ export async function getOrSetCart(countryCode: string) {
|
||||
return cart;
|
||||
}
|
||||
|
||||
export async function updateCart({ id, ...data }: HttpTypes.StoreUpdateCart & { id?: string }) {
|
||||
export async function updateCart(
|
||||
{ id, ...data }: HttpTypes.StoreUpdateCart & { id?: string },
|
||||
{ onSuccess, onError }: { onSuccess: () => void, onError: () => void } = { onSuccess: () => {}, onError: () => {} },
|
||||
) {
|
||||
const cartId = id || (await getCartId());
|
||||
|
||||
if (!cartId) {
|
||||
@@ -109,9 +112,13 @@ export async function updateCart({ id, ...data }: HttpTypes.StoreUpdateCart & {
|
||||
const fulfillmentCacheTag = await getCacheTag("fulfillment");
|
||||
revalidateTag(fulfillmentCacheTag);
|
||||
|
||||
onSuccess();
|
||||
return cart;
|
||||
})
|
||||
.catch(medusaError);
|
||||
.catch((e) => {
|
||||
onError();
|
||||
return medusaError(e);
|
||||
});
|
||||
}
|
||||
|
||||
export async function addToCart({
|
||||
@@ -259,7 +266,10 @@ export async function initiatePaymentSession(
|
||||
.catch(medusaError);
|
||||
}
|
||||
|
||||
export async function applyPromotions(codes: string[]) {
|
||||
export async function applyPromotions(
|
||||
codes: string[],
|
||||
{ onSuccess, onError }: { onSuccess: () => void, onError: () => void } = { onSuccess: () => {}, onError: () => {} },
|
||||
) {
|
||||
const cartId = await getCartId();
|
||||
|
||||
if (!cartId) {
|
||||
@@ -278,8 +288,13 @@ export async function applyPromotions(codes: string[]) {
|
||||
|
||||
const fulfillmentCacheTag = await getCacheTag("fulfillment");
|
||||
revalidateTag(fulfillmentCacheTag);
|
||||
|
||||
onSuccess();
|
||||
})
|
||||
.catch(medusaError);
|
||||
.catch((e) => {
|
||||
onError();
|
||||
return medusaError(e);
|
||||
});
|
||||
}
|
||||
|
||||
export async function applyGiftCard(code: string) {
|
||||
@@ -427,7 +442,7 @@ export async function placeOrder(cartId?: string, options: { revalidateCacheTags
|
||||
} else {
|
||||
throw new Error("Cart is not an order");
|
||||
}
|
||||
|
||||
|
||||
return retrieveOrder(cartRes.order.id);
|
||||
}
|
||||
|
||||
|
||||
@@ -127,7 +127,7 @@ export async function login(_currentState: unknown, formData: FormData) {
|
||||
}
|
||||
}
|
||||
|
||||
export async function signout(countryCode: string) {
|
||||
export async function signout(countryCode?: string, shouldRedirect = true) {
|
||||
await sdk.auth.logout()
|
||||
|
||||
await removeAuthToken()
|
||||
@@ -140,7 +140,9 @@ export async function signout(countryCode: string) {
|
||||
const cartCacheTag = await getCacheTag("carts")
|
||||
revalidateTag(cartCacheTag)
|
||||
|
||||
redirect(`/${countryCode}/account`)
|
||||
if (shouldRedirect) {
|
||||
redirect(`/${countryCode!}/account`)
|
||||
}
|
||||
}
|
||||
|
||||
export async function transferCart() {
|
||||
@@ -272,7 +274,12 @@ export async function medusaLoginOrRegister(credentials: {
|
||||
password,
|
||||
});
|
||||
await setAuthToken(token as string);
|
||||
await transferCart();
|
||||
|
||||
try {
|
||||
await transferCart();
|
||||
} catch (e) {
|
||||
console.error("Failed to transfer cart", e);
|
||||
}
|
||||
|
||||
const customerCacheTag = await getCacheTag("customers");
|
||||
revalidateTag(customerCacheTag);
|
||||
@@ -307,7 +314,12 @@ export async function medusaLoginOrRegister(credentials: {
|
||||
|
||||
const customerCacheTag = await getCacheTag("customers");
|
||||
revalidateTag(customerCacheTag);
|
||||
await transferCart();
|
||||
|
||||
try {
|
||||
await transferCart();
|
||||
} catch (e) {
|
||||
console.error("Failed to transfer cart", e);
|
||||
}
|
||||
|
||||
const customer = await retrieveCustomer();
|
||||
if (!customer) {
|
||||
|
||||
@@ -14,7 +14,7 @@ export const listProducts = async ({
|
||||
regionId,
|
||||
}: {
|
||||
pageParam?: number
|
||||
queryParams?: HttpTypes.FindParams & HttpTypes.StoreProductParams & { "type_id[0]"?: string; id?: string[] }
|
||||
queryParams?: HttpTypes.FindParams & HttpTypes.StoreProductParams & { "type_id[0]"?: string; id?: string[], category_id?: string }
|
||||
countryCode?: string
|
||||
regionId?: string
|
||||
}): Promise<{
|
||||
@@ -63,7 +63,7 @@ export const listProducts = async ({
|
||||
offset,
|
||||
region_id: region?.id,
|
||||
fields:
|
||||
"*variants.calculated_price,+variants.inventory_quantity,+metadata,+tags",
|
||||
"*variants.calculated_price,+variants.inventory_quantity,+metadata,+tags,+status",
|
||||
...queryParams,
|
||||
},
|
||||
headers,
|
||||
|
||||
@@ -13,7 +13,7 @@ export function InfoTooltip({
|
||||
content,
|
||||
icon,
|
||||
}: {
|
||||
content?: string | null;
|
||||
content?: JSX.Element | string | null;
|
||||
icon?: JSX.Element;
|
||||
}) {
|
||||
if (!content) return null;
|
||||
@@ -23,7 +23,7 @@ export function InfoTooltip({
|
||||
<TooltipTrigger>
|
||||
{icon || <Info className="size-4 cursor-pointer" />}
|
||||
</TooltipTrigger>
|
||||
<TooltipContent>{content}</TooltipContent>
|
||||
<TooltipContent className='sm:max-w-[400px]'>{content}</TooltipContent>
|
||||
</Tooltip>
|
||||
</TooltipProvider>
|
||||
);
|
||||
|
||||
@@ -1,12 +1,14 @@
|
||||
import { useMutation } from '@tanstack/react-query';
|
||||
|
||||
import { useSupabase } from './use-supabase';
|
||||
import { signout } from '../../../features/medusa-storefront/src/lib/data/customer';
|
||||
|
||||
export function useSignOut() {
|
||||
const client = useSupabase();
|
||||
|
||||
return useMutation({
|
||||
mutationFn: () => {
|
||||
mutationFn: async () => {
|
||||
await signout(undefined, false);
|
||||
return client.auth.signOut();
|
||||
},
|
||||
});
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
"emptyCartMessageDescription": "Add items to your cart to continue.",
|
||||
"subtotal": "Subtotal",
|
||||
"total": "Total",
|
||||
"promotionsTotal": "Promotions total",
|
||||
"table": {
|
||||
"item": "Item",
|
||||
"quantity": "Quantity",
|
||||
@@ -24,10 +25,13 @@
|
||||
"timeoutAction": "Continue"
|
||||
},
|
||||
"discountCode": {
|
||||
"title": "Gift card or promotion code",
|
||||
"label": "Add Promotion Code(s)",
|
||||
"apply": "Apply",
|
||||
"subtitle": "If you wish, you can add a promotion code",
|
||||
"placeholder": "Enter promotion code"
|
||||
"placeholder": "Enter promotion code",
|
||||
"remove": "Remove promotion code",
|
||||
"appliedCodes": "Promotion(s) applied:"
|
||||
},
|
||||
"items": {
|
||||
"synlabAnalyses": {
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
"emptyCartMessage": "Sinu ostukorv on tühi",
|
||||
"emptyCartMessageDescription": "Lisa tooteid ostukorvi, et jätkata.",
|
||||
"subtotal": "Vahesumma",
|
||||
"promotionsTotal": "Soodustuse summa",
|
||||
"total": "Summa",
|
||||
"table": {
|
||||
"item": "Toode",
|
||||
@@ -28,7 +29,13 @@
|
||||
"label": "Lisa promo kood",
|
||||
"apply": "Rakenda",
|
||||
"subtitle": "Kui soovid, võid lisada promo koodi",
|
||||
"placeholder": "Sisesta promo kood"
|
||||
"placeholder": "Sisesta promo kood",
|
||||
"remove": "Eemalda promo kood",
|
||||
"appliedCodes": "Rakendatud sooduskoodid:",
|
||||
"removeError": "Sooduskoodi eemaldamine ebaõnnestus",
|
||||
"removeSuccess": "Sooduskood eemaldatud",
|
||||
"addError": "Sooduskoodi rakendamine ebaõnnestus",
|
||||
"addSuccess": "Sooduskood rakendatud"
|
||||
},
|
||||
"items": {
|
||||
"synlabAnalyses": {
|
||||
|
||||
Reference in New Issue
Block a user