improve mobile view for my orders
remove otp requirement from doctor
This commit is contained in:
@@ -6,7 +6,7 @@ import { useTranslation } from 'react-i18next';
|
|||||||
|
|
||||||
import { Table, TableBody } from '@kit/ui/shadcn/table';
|
import { Table, TableBody } from '@kit/ui/shadcn/table';
|
||||||
|
|
||||||
import MobileCartRow from './mobile-cart-row';
|
import MobileTableRow from './mobile-table-row';
|
||||||
|
|
||||||
const MobileCartItems = ({
|
const MobileCartItems = ({
|
||||||
item,
|
item,
|
||||||
@@ -24,12 +24,12 @@ const MobileCartItems = ({
|
|||||||
return (
|
return (
|
||||||
<Table className="border-separate rounded-lg border p-2">
|
<Table className="border-separate rounded-lg border p-2">
|
||||||
<TableBody>
|
<TableBody>
|
||||||
<MobileCartRow
|
<MobileTableRow
|
||||||
titleKey={productColumnLabelKey}
|
titleKey={productColumnLabelKey}
|
||||||
value={item.product_title}
|
value={item.product_title}
|
||||||
/>
|
/>
|
||||||
<MobileCartRow titleKey="cart:table.time" value={item.quantity} />
|
<MobileTableRow titleKey="cart:table.time" value={item.quantity} />
|
||||||
<MobileCartRow
|
<MobileTableRow
|
||||||
titleKey="cart:table.price"
|
titleKey="cart:table.price"
|
||||||
value={formatCurrency({
|
value={formatCurrency({
|
||||||
value: item.unit_price,
|
value: item.unit_price,
|
||||||
@@ -37,7 +37,7 @@ const MobileCartItems = ({
|
|||||||
locale: language,
|
locale: language,
|
||||||
})}
|
})}
|
||||||
/>
|
/>
|
||||||
<MobileCartRow
|
<MobileTableRow
|
||||||
titleKey="cart:table.total"
|
titleKey="cart:table.total"
|
||||||
value={
|
value={
|
||||||
item.total &&
|
item.total &&
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import { Button } from '@kit/ui/shadcn/button';
|
|||||||
import { Table, TableBody, TableCell, TableRow } from '@kit/ui/shadcn/table';
|
import { Table, TableBody, TableCell, TableRow } from '@kit/ui/shadcn/table';
|
||||||
|
|
||||||
import CartItemDelete from './cart-item-delete';
|
import CartItemDelete from './cart-item-delete';
|
||||||
import MobileCartRow from './mobile-cart-row';
|
import MobileTableRow from './mobile-table-row';
|
||||||
import { EnrichedCartItem } from './types';
|
import { EnrichedCartItem } from './types';
|
||||||
|
|
||||||
const MobileCartServiceItems = ({
|
const MobileCartServiceItems = ({
|
||||||
@@ -31,20 +31,20 @@ const MobileCartServiceItems = ({
|
|||||||
return (
|
return (
|
||||||
<Table className="border-separate rounded-lg border p-2">
|
<Table className="border-separate rounded-lg border p-2">
|
||||||
<TableBody>
|
<TableBody>
|
||||||
<MobileCartRow
|
<MobileTableRow
|
||||||
titleKey={productColumnLabelKey}
|
titleKey={productColumnLabelKey}
|
||||||
value={item.product_title}
|
value={item.product_title}
|
||||||
/>
|
/>
|
||||||
<MobileCartRow
|
<MobileTableRow
|
||||||
titleKey="cart:table.time"
|
titleKey="cart:table.time"
|
||||||
value={formatDateAndTime(item.reservation.startTime.toString())}
|
value={formatDateAndTime(item.reservation.startTime.toString())}
|
||||||
/>
|
/>
|
||||||
<MobileCartRow
|
<MobileTableRow
|
||||||
titleKey="cart:table.location"
|
titleKey="cart:table.location"
|
||||||
value={item.reservation.location?.address ?? '-'}
|
value={item.reservation.location?.address ?? '-'}
|
||||||
/>
|
/>
|
||||||
<MobileCartRow titleKey="cart:table.quantity" value={item.quantity} />
|
<MobileTableRow titleKey="cart:table.quantity" value={item.quantity} />
|
||||||
<MobileCartRow
|
<MobileTableRow
|
||||||
titleKey="cart:table.price"
|
titleKey="cart:table.price"
|
||||||
value={formatCurrency({
|
value={formatCurrency({
|
||||||
value: item.unit_price,
|
value: item.unit_price,
|
||||||
@@ -52,7 +52,7 @@ const MobileCartServiceItems = ({
|
|||||||
locale: language,
|
locale: language,
|
||||||
})}
|
})}
|
||||||
/>
|
/>
|
||||||
<MobileCartRow
|
<MobileTableRow
|
||||||
titleKey="cart:table.total"
|
titleKey="cart:table.total"
|
||||||
value={
|
value={
|
||||||
item.total &&
|
item.total &&
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import React from 'react';
|
|||||||
import { Trans } from '@kit/ui/makerkit/trans';
|
import { Trans } from '@kit/ui/makerkit/trans';
|
||||||
import { TableCell, TableHead, TableRow } from '@kit/ui/shadcn/table';
|
import { TableCell, TableHead, TableRow } from '@kit/ui/shadcn/table';
|
||||||
|
|
||||||
const MobileCartRow = ({
|
const MobleTableRow = ({
|
||||||
titleKey,
|
titleKey,
|
||||||
value,
|
value,
|
||||||
}: {
|
}: {
|
||||||
@@ -16,14 +16,9 @@ const MobileCartRow = ({
|
|||||||
</TableHead>
|
</TableHead>
|
||||||
|
|
||||||
<TableCell className="p-0 text-right">
|
<TableCell className="p-0 text-right">
|
||||||
<p
|
<p className="txt-medium-plus text-ui-fg-base">{value}</p>
|
||||||
className="txt-medium-plus text-ui-fg-base"
|
|
||||||
data-testid="product-title"
|
|
||||||
>
|
|
||||||
{value}
|
|
||||||
</p>
|
|
||||||
</TableCell>
|
</TableCell>
|
||||||
</TableRow>
|
</TableRow>
|
||||||
);
|
);
|
||||||
|
|
||||||
export default MobileCartRow;
|
export default MobleTableRow;
|
||||||
@@ -51,7 +51,7 @@ export default function OrderBlock({
|
|||||||
</Link>
|
</Link>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
<div className="flex flex-col gap-4">
|
<div className="flex flex-col sm:gap-4">
|
||||||
{analysisOrder && (
|
{analysisOrder && (
|
||||||
<OrderItemsTable
|
<OrderItemsTable
|
||||||
items={itemsAnalysisPackage}
|
items={itemsAnalysisPackage}
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ import { Trans } from '@kit/ui/trans';
|
|||||||
import type { Order } from '~/lib/types/order';
|
import type { Order } from '~/lib/types/order';
|
||||||
|
|
||||||
import { cancelTtoBooking } from '../../_lib/server/actions';
|
import { cancelTtoBooking } from '../../_lib/server/actions';
|
||||||
|
import MobileTableRow from '../cart/mobile-table-row';
|
||||||
import { logAnalysisResultsNavigateAction } from './actions';
|
import { logAnalysisResultsNavigateAction } from './actions';
|
||||||
|
|
||||||
export type OrderItemType = 'analysisOrder' | 'ttoService';
|
export type OrderItemType = 'analysisOrder' | 'ttoService';
|
||||||
@@ -60,76 +61,130 @@ export default function OrderItemsTable({
|
|||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Table className="border-separate rounded-lg border">
|
<>
|
||||||
<TableHeader className="text-ui-fg-subtle txt-medium-plus">
|
<Table className="border-separate rounded-lg border p-2 sm:hidden">
|
||||||
<TableRow>
|
<TableBody>
|
||||||
<TableHead className="px-6">
|
{items
|
||||||
<Trans i18nKey={title} />
|
.sort((a, b) =>
|
||||||
</TableHead>
|
(a.created_at ?? '') > (b.created_at ?? '') ? -1 : 1,
|
||||||
<TableHead className="px-6">
|
)
|
||||||
<Trans i18nKey="orders:table.createdAt" />
|
.map((orderItem) => (
|
||||||
</TableHead>
|
<div key={`${orderItem.id}-mobile`}>
|
||||||
{order.location && (
|
<MobileTableRow
|
||||||
|
titleKey={title}
|
||||||
|
value={orderItem.product_title || ''}
|
||||||
|
/>
|
||||||
|
<MobileTableRow
|
||||||
|
titleKey="orders:table.createdAt"
|
||||||
|
value={formatDate(orderItem.created_at, 'dd.MM.yyyy HH:mm')}
|
||||||
|
/>
|
||||||
|
{order.location && (
|
||||||
|
<MobileTableRow
|
||||||
|
titleKey="orders:table.location"
|
||||||
|
value={order.location}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
<MobileTableRow
|
||||||
|
titleKey="orders:table.status"
|
||||||
|
value={
|
||||||
|
isPackage
|
||||||
|
? `orders:status.analysisPackageOrder.${order?.status ?? 'CONFIRMED'}`
|
||||||
|
: `orders:status.${type}.${order?.status ?? 'CONFIRMED'}`
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
<TableRow>
|
||||||
|
<TableCell />
|
||||||
|
<TableCell className="flex w-full items-center justify-end p-0 pt-2">
|
||||||
|
<Button size="sm" onClick={openDetailedView}>
|
||||||
|
<Trans i18nKey="analysis-results:view" />
|
||||||
|
</Button>
|
||||||
|
{isTtoservice && order.bookingCode && (
|
||||||
|
<Button
|
||||||
|
size="sm"
|
||||||
|
className="bg-warning/90 hover:bg-warning"
|
||||||
|
onClick={() => setIsConfirmOpen(true)}
|
||||||
|
>
|
||||||
|
<Trans i18nKey="analysis-results:cancel" />
|
||||||
|
</Button>
|
||||||
|
)}
|
||||||
|
</TableCell>
|
||||||
|
</TableRow>
|
||||||
|
</div>
|
||||||
|
))}
|
||||||
|
</TableBody>
|
||||||
|
</Table>
|
||||||
|
|
||||||
|
<Table className="hidden border-separate rounded-lg border sm:block">
|
||||||
|
<TableHeader className="text-ui-fg-subtle txt-medium-plus">
|
||||||
|
<TableRow>
|
||||||
<TableHead className="px-6">
|
<TableHead className="px-6">
|
||||||
<Trans i18nKey="orders:table.location" />
|
<Trans i18nKey={title} />
|
||||||
</TableHead>
|
</TableHead>
|
||||||
)}
|
<TableHead className="px-6">
|
||||||
<TableHead className="px-6">
|
<Trans i18nKey="orders:table.createdAt" />
|
||||||
<Trans i18nKey="orders:table.status" />
|
</TableHead>
|
||||||
</TableHead>
|
{order.location && (
|
||||||
{isAnalysisOrder && <TableHead className="px-6"></TableHead>}
|
<TableHead className="px-6">
|
||||||
</TableRow>
|
<Trans i18nKey="orders:table.location" />
|
||||||
</TableHeader>
|
</TableHead>
|
||||||
<TableBody>
|
)}
|
||||||
{items
|
<TableHead className="px-6">
|
||||||
.sort((a, b) =>
|
<Trans i18nKey="orders:table.status" />
|
||||||
(a.created_at ?? '') > (b.created_at ?? '') ? -1 : 1,
|
</TableHead>
|
||||||
)
|
{isAnalysisOrder && <TableHead className="px-6"></TableHead>}
|
||||||
.map((orderItem) => (
|
</TableRow>
|
||||||
<TableRow className="w-full" key={orderItem.id}>
|
</TableHeader>
|
||||||
<TableCell className="w-[100%] px-6 text-left">
|
<TableBody>
|
||||||
<p className="txt-medium-plus text-ui-fg-base">
|
{items
|
||||||
{orderItem.product_title}
|
.sort((a, b) =>
|
||||||
</p>
|
(a.created_at ?? '') > (b.created_at ?? '') ? -1 : 1,
|
||||||
</TableCell>
|
)
|
||||||
|
.map((orderItem) => (
|
||||||
<TableCell className="px-6 whitespace-nowrap">
|
<TableRow className="w-full" key={orderItem.id}>
|
||||||
{formatDate(orderItem.created_at, 'dd.MM.yyyy HH:mm')}
|
<TableCell className="w-[100%] px-6 text-left">
|
||||||
</TableCell>
|
<p className="txt-medium-plus text-ui-fg-base">
|
||||||
{order.location && (
|
{orderItem.product_title}
|
||||||
<TableCell className="min-w-[180px] px-6">
|
</p>
|
||||||
{order.location}
|
|
||||||
</TableCell>
|
</TableCell>
|
||||||
)}
|
|
||||||
<TableCell className="min-w-[180px] px-6">
|
|
||||||
{isPackage ? (
|
|
||||||
<Trans
|
|
||||||
i18nKey={`orders:status.analysisPackageOrder.${order?.status ?? 'CONFIRMED'}`}
|
|
||||||
/>
|
|
||||||
) : (
|
|
||||||
<Trans
|
|
||||||
i18nKey={`orders:status.${type}.${order?.status ?? 'CONFIRMED'}`}
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
</TableCell>
|
|
||||||
|
|
||||||
<TableCell className="px-6 text-right">
|
<TableCell className="px-6 whitespace-nowrap">
|
||||||
<Button size="sm" onClick={openDetailedView}>
|
{formatDate(orderItem.created_at, 'dd.MM.yyyy HH:mm')}
|
||||||
<Trans i18nKey="analysis-results:view" />
|
</TableCell>
|
||||||
</Button>
|
{order.location && (
|
||||||
{isTtoservice && order.bookingCode && (
|
<TableCell className="min-w-[180px] px-6">
|
||||||
<Button
|
{order.location}
|
||||||
size="sm"
|
</TableCell>
|
||||||
className="bg-warning/90 hover:bg-warning mt-2 w-full"
|
|
||||||
onClick={() => setIsConfirmOpen(true)}
|
|
||||||
>
|
|
||||||
<Trans i18nKey="analysis-results:cancel" />
|
|
||||||
</Button>
|
|
||||||
)}
|
)}
|
||||||
</TableCell>
|
<TableCell className="min-w-[180px] px-6">
|
||||||
</TableRow>
|
{isPackage ? (
|
||||||
))}
|
<Trans
|
||||||
</TableBody>
|
i18nKey={`orders:status.analysisPackageOrder.${order?.status ?? 'CONFIRMED'}`}
|
||||||
|
/>
|
||||||
|
) : (
|
||||||
|
<Trans
|
||||||
|
i18nKey={`orders:status.${type}.${order?.status ?? 'CONFIRMED'}`}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
</TableCell>
|
||||||
|
|
||||||
|
<TableCell className="px-6 text-right">
|
||||||
|
<Button size="sm" onClick={openDetailedView}>
|
||||||
|
<Trans i18nKey="analysis-results:view" />
|
||||||
|
</Button>
|
||||||
|
{isTtoservice && order.bookingCode && (
|
||||||
|
<Button
|
||||||
|
size="sm"
|
||||||
|
className="bg-warning/90 hover:bg-warning mt-2 w-full"
|
||||||
|
onClick={() => setIsConfirmOpen(true)}
|
||||||
|
>
|
||||||
|
<Trans i18nKey="analysis-results:cancel" />
|
||||||
|
</Button>
|
||||||
|
)}
|
||||||
|
</TableCell>
|
||||||
|
</TableRow>
|
||||||
|
))}
|
||||||
|
</TableBody>
|
||||||
|
</Table>
|
||||||
{order?.bookingCode && order?.clinicId && (
|
{order?.bookingCode && order?.clinicId && (
|
||||||
<ConfirmationModal
|
<ConfirmationModal
|
||||||
isOpen={isConfirmOpen}
|
isOpen={isConfirmOpen}
|
||||||
@@ -141,6 +196,6 @@ export default function OrderItemsTable({
|
|||||||
descriptionKey="orders:confirmBookingCancel.description"
|
descriptionKey="orders:confirmBookingCancel.description"
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
</Table>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -94,8 +94,8 @@ export function PersonalAccountDropdown({
|
|||||||
const hasDoctorRole =
|
const hasDoctorRole =
|
||||||
personalAccountData?.application_role === ApplicationRoleEnum.Doctor;
|
personalAccountData?.application_role === ApplicationRoleEnum.Doctor;
|
||||||
|
|
||||||
return hasDoctorRole && hasTotpFactor;
|
return hasDoctorRole;
|
||||||
}, [personalAccountData, hasTotpFactor]);
|
}, [personalAccountData]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<DropdownMenu>
|
<DropdownMenu>
|
||||||
|
|||||||
@@ -0,0 +1,15 @@
|
|||||||
|
CREATE OR REPLACE FUNCTION medreport.is_doctor()
|
||||||
|
RETURNS BOOLEAN
|
||||||
|
LANGUAGE plpgsql
|
||||||
|
SECURITY DEFINER
|
||||||
|
AS $$
|
||||||
|
BEGIN
|
||||||
|
RETURN EXISTS (
|
||||||
|
SELECT 1
|
||||||
|
FROM medreport.accounts
|
||||||
|
WHERE primary_owner_user_id = auth.uid()
|
||||||
|
AND application_role = 'doctor'
|
||||||
|
);
|
||||||
|
END;
|
||||||
|
$$;
|
||||||
|
grant execute on function medreport.is_doctor() to authenticated;
|
||||||
Reference in New Issue
Block a user