improve mobile view for my orders

remove otp requirement from doctor
This commit is contained in:
Danel Kungla
2025-10-09 17:47:59 +03:00
parent 963d2c6a01
commit 3e60745a92
7 changed files with 154 additions and 89 deletions

View File

@@ -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 &&

View File

@@ -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 &&

View File

@@ -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;

View File

@@ -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}

View File

@@ -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,7 +61,60 @@ export default function OrderItemsTable({
}; };
return ( return (
<Table className="border-separate rounded-lg border"> <>
<Table className="border-separate rounded-lg border p-2 sm:hidden">
<TableBody>
{items
.sort((a, b) =>
(a.created_at ?? '') > (b.created_at ?? '') ? -1 : 1,
)
.map((orderItem) => (
<div key={`${orderItem.id}-mobile`}>
<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"> <TableHeader className="text-ui-fg-subtle txt-medium-plus">
<TableRow> <TableRow>
<TableHead className="px-6"> <TableHead className="px-6">
@@ -130,6 +184,7 @@ export default function OrderItemsTable({
</TableRow> </TableRow>
))} ))}
</TableBody> </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> </>
); );
} }

View File

@@ -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>

View File

@@ -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;