From 3e60745a92840f03530eb8205312113ec7ddc478 Mon Sep 17 00:00:00 2001 From: Danel Kungla Date: Thu, 9 Oct 2025 17:47:59 +0300 Subject: [PATCH] improve mobile view for my orders remove otp requirement from doctor --- .../_components/cart/mobile-cart-items.tsx | 10 +- .../cart/mobile-cart-service-items.tsx | 14 +- ...bile-cart-row.tsx => mobile-table-row.tsx} | 11 +- .../(user)/_components/orders/order-block.tsx | 2 +- .../_components/orders/order-items-table.tsx | 187 +++++++++++------- .../components/personal-account-dropdown.tsx | 4 +- .../20251009174500_remove_otp_from_doctor.sql | 15 ++ 7 files changed, 154 insertions(+), 89 deletions(-) rename app/home/(user)/_components/cart/{mobile-cart-row.tsx => mobile-table-row.tsx} (68%) create mode 100644 supabase/migrations/20251009174500_remove_otp_from_doctor.sql diff --git a/app/home/(user)/_components/cart/mobile-cart-items.tsx b/app/home/(user)/_components/cart/mobile-cart-items.tsx index 9b21f86..0c26780 100644 --- a/app/home/(user)/_components/cart/mobile-cart-items.tsx +++ b/app/home/(user)/_components/cart/mobile-cart-items.tsx @@ -6,7 +6,7 @@ import { useTranslation } from 'react-i18next'; import { Table, TableBody } from '@kit/ui/shadcn/table'; -import MobileCartRow from './mobile-cart-row'; +import MobileTableRow from './mobile-table-row'; const MobileCartItems = ({ item, @@ -24,12 +24,12 @@ const MobileCartItems = ({ return ( - - - + - - - - - - + - -

- {value} -

+

{value}

); -export default MobileCartRow; +export default MobleTableRow; diff --git a/app/home/(user)/_components/orders/order-block.tsx b/app/home/(user)/_components/orders/order-block.tsx index 5eef5cb..2185e4e 100644 --- a/app/home/(user)/_components/orders/order-block.tsx +++ b/app/home/(user)/_components/orders/order-block.tsx @@ -51,7 +51,7 @@ export default function OrderBlock({ )} -
+
{analysisOrder && ( - - - - - - - - - {order.location && ( + <> +
+ + {items + .sort((a, b) => + (a.created_at ?? '') > (b.created_at ?? '') ? -1 : 1, + ) + .map((orderItem) => ( +
+ + + {order.location && ( + + )} + + + + + + {isTtoservice && order.bookingCode && ( + + )} + + +
+ ))} +
+
+ + + + - + - )} - - - - {isAnalysisOrder && } - - - - {items - .sort((a, b) => - (a.created_at ?? '') > (b.created_at ?? '') ? -1 : 1, - ) - .map((orderItem) => ( - - -

- {orderItem.product_title} -

-
- - - {formatDate(orderItem.created_at, 'dd.MM.yyyy HH:mm')} - - {order.location && ( - - {order.location} + + + + {order.location && ( + + + + )} + + + + {isAnalysisOrder && } +
+ + + {items + .sort((a, b) => + (a.created_at ?? '') > (b.created_at ?? '') ? -1 : 1, + ) + .map((orderItem) => ( + + +

+ {orderItem.product_title} +

- )} - - {isPackage ? ( - - ) : ( - - )} - - - - {isTtoservice && order.bookingCode && ( - + + {formatDate(orderItem.created_at, 'dd.MM.yyyy HH:mm')} + + {order.location && ( + + {order.location} + )} - -
- ))} -
+ + {isPackage ? ( + + ) : ( + + )} + + + + + {isTtoservice && order.bookingCode && ( + + )} + + + ))} +
+
{order?.bookingCode && order?.clinicId && ( )} - + ); } diff --git a/packages/features/accounts/src/components/personal-account-dropdown.tsx b/packages/features/accounts/src/components/personal-account-dropdown.tsx index 447a8a3..8fc2c8c 100644 --- a/packages/features/accounts/src/components/personal-account-dropdown.tsx +++ b/packages/features/accounts/src/components/personal-account-dropdown.tsx @@ -94,8 +94,8 @@ export function PersonalAccountDropdown({ const hasDoctorRole = personalAccountData?.application_role === ApplicationRoleEnum.Doctor; - return hasDoctorRole && hasTotpFactor; - }, [personalAccountData, hasTotpFactor]); + return hasDoctorRole; + }, [personalAccountData]); return ( diff --git a/supabase/migrations/20251009174500_remove_otp_from_doctor.sql b/supabase/migrations/20251009174500_remove_otp_from_doctor.sql new file mode 100644 index 0000000..77bd8f6 --- /dev/null +++ b/supabase/migrations/20251009174500_remove_otp_from_doctor.sql @@ -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; \ No newline at end of file