MED-129 + MED-103: add shopping cart functionality for TTO services

MED-129 + MED-103: add shopping cart functionality for TTO services
This commit is contained in:
danelkungla
2025-09-24 18:49:10 +03:00
committed by GitHub
73 changed files with 11169 additions and 3079 deletions

View File

@@ -0,0 +1,61 @@
import {
Body,
Head,
Html,
Preview,
Tailwind,
Text,
render,
} from '@react-email/components';
import { BodyStyle } from '../components/body-style';
import { EmailContent } from '../components/content';
import { EmailHeader } from '../components/header';
import { EmailHeading } from '../components/heading';
import { EmailWrapper } from '../components/wrapper';
export async function renderBookTimeFailedEmail({
reservationId,
error,
}: {
reservationId: number;
error: string;
}) {
const subject = 'Aja broneerimine ei õnnestunud';
const html = await render(
<Html>
<Head>
<BodyStyle />
</Head>
<Preview>{subject}</Preview>
<Tailwind>
<Body>
<EmailWrapper>
<EmailContent>
<EmailHeader>
<EmailHeading>{subject}</EmailHeading>
</EmailHeader>
<Text className="text-[16px] leading-[24px] text-[#242424]">
Tere
</Text>
<Text>
Broneeringu {reservationId} Connected Online'i saatmine ei
õnnestunud, kliendile tuleb teha tagasimakse.
</Text>
<Text>Saadud error: {error}</Text>
</EmailContent>
</EmailWrapper>
</Body>
</Tailwind>
</Html>,
);
return {
html,
subject,
};
}

View File

@@ -10,3 +10,4 @@ export * from './emails/all-results-received.email';
export * from './emails/order-processing.email';
export * from './emails/patient-first-results-received.email';
export * from './emails/patient-full-results-received.email';
export * from './emails/book-time-failed.email';

View File

@@ -4,10 +4,10 @@ import Link from 'next/link';
import { ColumnDef } from '@tanstack/react-table';
import { formatDateAndTime } from '@kit/shared/utils';
import { Database } from '@kit/supabase/database';
import { DataTable } from '@kit/ui/enhanced-data-table';
import { ProfileAvatar } from '@kit/ui/profile-avatar';
import { formatDateAndTime } from '@kit/shared/utils';
type Memberships =
Database['medreport']['Functions']['get_account_members']['Returns'][number];

View File

@@ -168,7 +168,12 @@ export async function addToCart({
})
.catch(medusaError);
return cart;
const newCart = await getOrSetCart(countryCode);
const addedItem = newCart.items?.filter(
(item) => !cart.items?.some((oldCartItem) => oldCartItem.id === item.id),
)?.[0];
return { newCart, addedItem };
}
export async function updateLineItem({

View File

@@ -21,7 +21,6 @@ export const listCategories = async (query?: Record<string, any>) => {
...query,
},
next,
cache: 'force-cache',
},
)
.then(({ product_categories }) => product_categories);
@@ -57,7 +56,6 @@ export const getProductCategories = async ({
limit,
},
next,
//cache: "force-cache",
},
);
};

View File

@@ -15,7 +15,7 @@ export const listRegions = async () => {
.fetch<{ regions: HttpTypes.StoreRegion[] }>(`/store/regions`, {
method: 'GET',
next,
cache: 'force-cache',
// cache: 'force-cache',
})
.then(({ regions }) => regions)
.catch(medusaError);

View File

@@ -1,7 +1,7 @@
import { adminNavigationConfig } from './admin-navigation.config';
import appConfig from './app.config';
import authConfig from './auth.config';
import billingConfig from './billing.config';
import { adminNavigationConfig } from './admin-navigation.config';
import {
DynamicAuthConfig,
getCachedAuthConfig,

View File

@@ -224,7 +224,6 @@ export type Database = {
comment: string | null
created_at: string
id: number
personal_code: number | null
request_api: string
request_api_method: string
requested_end_date: string | null
@@ -232,12 +231,12 @@ export type Database = {
service_id: number | null
service_provider_id: number | null
status: Database["audit"]["Enums"]["request_status"]
user_id: string | null
}
Insert: {
comment?: string | null
created_at?: string
id?: number
personal_code?: number | null
request_api: string
request_api_method: string
requested_end_date?: string | null
@@ -245,12 +244,12 @@ export type Database = {
service_id?: number | null
service_provider_id?: number | null
status: Database["audit"]["Enums"]["request_status"]
user_id?: string | null
}
Update: {
comment?: string | null
created_at?: string
id?: number
personal_code?: number | null
request_api?: string
request_api_method?: string
requested_end_date?: string | null
@@ -258,6 +257,7 @@ export type Database = {
service_id?: number | null
service_provider_id?: number | null
status?: Database["audit"]["Enums"]["request_status"]
user_id?: string | null
}
Relationships: []
}
@@ -337,6 +337,91 @@ export type Database = {
}
medreport: {
Tables: {
account_balance_entries: {
Row: {
account_id: string
amount: number
created_at: string
created_by: string | null
description: string | null
entry_type: string
expires_at: string | null
id: string
is_active: boolean
reference_id: string | null
source_company_id: string | null
}
Insert: {
account_id: string
amount: number
created_at?: string
created_by?: string | null
description?: string | null
entry_type: string
expires_at?: string | null
id?: string
is_active?: boolean
reference_id?: string | null
source_company_id?: string | null
}
Update: {
account_id?: string
amount?: number
created_at?: string
created_by?: string | null
description?: string | null
entry_type?: string
expires_at?: string | null
id?: string
is_active?: boolean
reference_id?: string | null
source_company_id?: string | null
}
Relationships: [
{
foreignKeyName: "account_balance_entries_account_id_fkey"
columns: ["account_id"]
isOneToOne: false
referencedRelation: "accounts"
referencedColumns: ["id"]
},
{
foreignKeyName: "account_balance_entries_account_id_fkey"
columns: ["account_id"]
isOneToOne: false
referencedRelation: "user_account_workspace"
referencedColumns: ["id"]
},
{
foreignKeyName: "account_balance_entries_account_id_fkey"
columns: ["account_id"]
isOneToOne: false
referencedRelation: "user_accounts"
referencedColumns: ["id"]
},
{
foreignKeyName: "account_balance_entries_source_company_id_fkey"
columns: ["source_company_id"]
isOneToOne: false
referencedRelation: "accounts"
referencedColumns: ["id"]
},
{
foreignKeyName: "account_balance_entries_source_company_id_fkey"
columns: ["source_company_id"]
isOneToOne: false
referencedRelation: "user_account_workspace"
referencedColumns: ["id"]
},
{
foreignKeyName: "account_balance_entries_source_company_id_fkey"
columns: ["source_company_id"]
isOneToOne: false
referencedRelation: "user_accounts"
referencedColumns: ["id"]
},
]
}
account_params: {
Row: {
account_id: string
@@ -841,6 +926,64 @@ export type Database = {
},
]
}
benefit_distribution_schedule: {
Row: {
benefit_amount: number
benefit_occurrence: string
company_id: string
created_at: string
id: string
is_active: boolean
last_distributed_at: string | null
next_distribution_at: string
updated_at: string
}
Insert: {
benefit_amount: number
benefit_occurrence: string
company_id: string
created_at?: string
id?: string
is_active?: boolean
last_distributed_at?: string | null
next_distribution_at: string
updated_at?: string
}
Update: {
benefit_amount?: number
benefit_occurrence?: string
company_id?: string
created_at?: string
id?: string
is_active?: boolean
last_distributed_at?: string | null
next_distribution_at?: string
updated_at?: string
}
Relationships: [
{
foreignKeyName: "benefit_distribution_schedule_company_id_fkey"
columns: ["company_id"]
isOneToOne: false
referencedRelation: "accounts"
referencedColumns: ["id"]
},
{
foreignKeyName: "benefit_distribution_schedule_company_id_fkey"
columns: ["company_id"]
isOneToOne: false
referencedRelation: "user_account_workspace"
referencedColumns: ["id"]
},
{
foreignKeyName: "benefit_distribution_schedule_company_id_fkey"
columns: ["company_id"]
isOneToOne: false
referencedRelation: "user_accounts"
referencedColumns: ["id"]
},
]
}
billing_customers: {
Row: {
account_id: string
@@ -1057,32 +1200,76 @@ export type Database = {
}
Relationships: []
}
connected_online_locations: {
Row: {
address: string | null
clinic_id: number
created_at: string
id: number
name: string
sync_id: number
updated_at: string | null
}
Insert: {
address?: string | null
clinic_id: number
created_at?: string
id?: number
name: string
sync_id: number
updated_at?: string | null
}
Update: {
address?: string | null
clinic_id?: number
created_at?: string
id?: number
name?: string
sync_id?: number
updated_at?: string | null
}
Relationships: [
{
foreignKeyName: "connected_online_locations_clinic_id_fkey"
columns: ["clinic_id"]
isOneToOne: false
referencedRelation: "connected_online_providers"
referencedColumns: ["id"]
},
]
}
connected_online_providers: {
Row: {
address: string
can_select_worker: boolean
created_at: string
email: string | null
id: number
key: string
name: string
personal_code_required: boolean
phone_number: string | null
updated_at: string | null
}
Insert: {
address?: string
can_select_worker: boolean
created_at?: string
email?: string | null
id: number
key: string
name: string
personal_code_required: boolean
phone_number?: string | null
updated_at?: string | null
}
Update: {
address?: string
can_select_worker?: boolean
created_at?: string
email?: string | null
id?: number
key?: string
name?: string
personal_code_required?: boolean
phone_number?: string | null
@@ -1092,54 +1279,131 @@ export type Database = {
}
connected_online_reservation: {
Row: {
booking_code: string
booking_code: string | null
clinic_id: number
comments: string | null
created_at: string
discount_code: string | null
id: number
lang: string
requires_payment: boolean
location_sync_id: number | null
medusa_cart_line_item_id: string | null
requires_payment: boolean | null
service_id: number
service_user_id: number | null
service_user_id: number
start_time: string
status: Database["medreport"]["Enums"]["connected_online_order_status"]
sync_user_id: number
updated_at: string | null
user_id: string
}
Insert: {
booking_code: string
booking_code?: string | null
clinic_id: number
comments?: string | null
created_at?: string
discount_code?: string | null
id?: number
lang: string
requires_payment: boolean
location_sync_id?: number | null
medusa_cart_line_item_id?: string | null
requires_payment?: boolean | null
service_id: number
service_user_id?: number | null
service_user_id: number
start_time: string
status: Database["medreport"]["Enums"]["connected_online_order_status"]
sync_user_id: number
updated_at?: string | null
user_id: string
}
Update: {
booking_code?: string
booking_code?: string | null
clinic_id?: number
comments?: string | null
created_at?: string
discount_code?: string | null
id?: number
lang?: string
requires_payment?: boolean
location_sync_id?: number | null
medusa_cart_line_item_id?: string | null
requires_payment?: boolean | null
service_id?: number
service_user_id?: number | null
service_user_id?: number
start_time?: string
status?: Database["medreport"]["Enums"]["connected_online_order_status"]
sync_user_id?: number
updated_at?: string | null
user_id?: string
}
Relationships: []
Relationships: [
{
foreignKeyName: "fk_reservation_clinic"
columns: ["clinic_id"]
isOneToOne: false
referencedRelation: "connected_online_providers"
referencedColumns: ["id"]
},
{
foreignKeyName: "fk_reservation_service"
columns: ["service_id"]
isOneToOne: false
referencedRelation: "connected_online_services"
referencedColumns: ["id"]
},
]
}
connected_online_service_providers: {
Row: {
clinic_id: number
created_at: string
id: number
is_deleted: boolean | null
job_title_en: string | null
job_title_et: string | null
job_title_id: number | null
job_title_ru: string | null
name: string
prefix: string | null
spoken_languages: string[] | null
updated_at: string | null
}
Insert: {
clinic_id: number
created_at?: string
id: number
is_deleted?: boolean | null
job_title_en?: string | null
job_title_et?: string | null
job_title_id?: number | null
job_title_ru?: string | null
name: string
prefix?: string | null
spoken_languages?: string[] | null
updated_at?: string | null
}
Update: {
clinic_id?: number
created_at?: string
id?: number
is_deleted?: boolean | null
job_title_en?: string | null
job_title_et?: string | null
job_title_id?: number | null
job_title_ru?: string | null
name?: string
prefix?: string | null
spoken_languages?: string[] | null
updated_at?: string | null
}
Relationships: [
{
foreignKeyName: "connected_online_service_providers_clinic_id_fkey"
columns: ["clinic_id"]
isOneToOne: false
referencedRelation: "connected_online_providers"
referencedColumns: ["id"]
},
]
}
connected_online_services: {
Row: {
@@ -1158,7 +1422,7 @@ export type Database = {
price: number
price_periods: string | null
requires_payment: boolean
sync_id: string
sync_id: number
updated_at: string | null
}
Insert: {
@@ -1177,7 +1441,7 @@ export type Database = {
price: number
price_periods?: string | null
requires_payment: boolean
sync_id: string
sync_id: number
updated_at?: string | null
}
Update: {
@@ -1196,7 +1460,7 @@ export type Database = {
price?: number
price_periods?: string | null
requires_payment?: boolean
sync_id?: string
sync_id?: number
updated_at?: string | null
}
Relationships: [
@@ -1931,10 +2195,23 @@ export type Database = {
}
Returns: Database["medreport"]["Tables"]["invitations"]["Row"][]
}
calculate_next_distribution_date: {
Args: { p_current_date?: string; p_occurrence: string }
Returns: string
}
can_action_account_member: {
Args: { target_team_account_id: string; target_user_id: string }
Returns: boolean
}
consume_account_balance: {
Args: {
p_account_id: string
p_amount: number
p_description: string
p_reference_id?: string
}
Returns: boolean
}
create_invitation: {
Args: { account_id: string; email: string; role: string }
Returns: {
@@ -1988,6 +2265,18 @@ export type Database = {
updated_by: string | null
}
}
distribute_health_benefits: {
Args: {
p_benefit_amount: number
p_benefit_occurrence?: string
p_company_id: string
}
Returns: undefined
}
get_account_balance: {
Args: { p_account_id: string }
Returns: number
}
get_account_invitations: {
Args: { account_slug: string }
Returns: {
@@ -2148,6 +2437,10 @@ export type Database = {
Args: { medusa_order_id: string }
Returns: boolean
}
process_periodic_benefit_distributions: {
Args: Record<PropertyKey, never>
Returns: undefined
}
revoke_nonce: {
Args: { p_id: string; p_reason?: string }
Returns: boolean
@@ -2172,6 +2465,10 @@ export type Database = {
Args: { new_owner_id: string; target_account_id: string }
Returns: undefined
}
trigger_benefit_distribution: {
Args: { p_company_id: string }
Returns: undefined
}
update_account: {
Args:
| {
@@ -2211,6 +2508,14 @@ export type Database = {
user_id: string
}
}
upsert_benefit_distribution_schedule: {
Args: {
p_benefit_amount: number
p_benefit_occurrence: string
p_company_id: string
}
Returns: undefined
}
upsert_order: {
Args: {
billing_provider: Database["medreport"]["Enums"]["billing_provider"]
@@ -2300,6 +2605,11 @@ export type Database = {
| "invites.manage"
application_role: "user" | "doctor" | "super_admin"
billing_provider: "stripe" | "lemon-squeezy" | "paddle" | "montonio"
connected_online_order_status:
| "PENDING"
| "CONFIRMED"
| "REJECTED"
| "CANCELLED"
locale: "en" | "et" | "ru"
notification_channel: "in_app" | "email"
notification_type: "info" | "warning" | "error"
@@ -8217,6 +8527,12 @@ export const Constants = {
],
application_role: ["user", "doctor", "super_admin"],
billing_provider: ["stripe", "lemon-squeezy", "paddle", "montonio"],
connected_online_order_status: [
"PENDING",
"CONFIRMED",
"REJECTED",
"CANCELLED",
],
locale: ["en", "et", "ru"],
notification_channel: ["in_app", "email"],
notification_type: ["info", "warning", "error"],

View File

@@ -34,11 +34,11 @@ function Calendar({
nav_button_previous: 'absolute left-1',
nav_button_next: 'absolute right-1',
table: 'w-full border-collapse space-y-1',
head_row: 'flex',
head_row: 'flex justify-evenly',
head_cell:
'text-muted-foreground rounded-md w-9 font-normal text-[0.8rem]',
row: 'flex w-full mt-2',
cell: 'text-center text-sm p-0 relative [&:has([aria-selected])]:bg-accent first:[&:has([aria-selected])]:rounded-l-md last:[&:has([aria-selected])]:rounded-r-md focus-within:relative focus-within:z-20',
row: 'flex w-full mt-2 justify-evenly',
cell: 'text-center text-sm p-0 relative [&:has([aria-selected])]:bg-accent first:[&:has([aria-selected])]:rounded-l-md last:[&:has([aria-selected])]:rounded-md focus-within:relative focus-within:z-20',
day: cn(
buttonVariants({ variant: 'ghost' }),
'h-9 w-9 p-0 font-normal aria-selected:opacity-100',

View File

@@ -41,11 +41,9 @@ const CardHeader: React.FC<React.HTMLAttributes<HTMLDivElement>> = ({
);
CardHeader.displayName = 'CardHeader';
const CardTitle: React.FC<React.HTMLAttributes<HTMLHeadingElement> & { size?: 'h3' | 'h4' | 'h5' }> = ({
className,
size = 'h3',
...props
}) => {
const CardTitle: React.FC<
React.HTMLAttributes<HTMLHeadingElement> & { size?: 'h3' | 'h4' | 'h5' }
> = ({ className, size = 'h3', ...props }) => {
const Component = size;
return (
<Component

View File

@@ -25,12 +25,12 @@ const RadioGroupItem: React.FC<
return (
<RadioGroupPrimitive.Item
className={cn(
'border-primary text-primary focus-visible:ring-ring aspect-square h-4 w-4 rounded-full border shadow-xs focus:outline-hidden focus-visible:ring-1 disabled:cursor-not-allowed disabled:opacity-50',
'border-primary focus-visible:ring-ring aspect-square h-4 w-4 rounded-full border text-white shadow-xs focus:outline-hidden focus-visible:ring-1 disabled:cursor-not-allowed disabled:opacity-50',
className,
)}
{...props}
>
<RadioGroupPrimitive.Indicator className="flex items-center justify-center">
<RadioGroupPrimitive.Indicator className="bg-primary flex items-center justify-center rounded-full">
<CheckIcon className="fill-primary h-3.5 w-3.5" />
</RadioGroupPrimitive.Indicator>
</RadioGroupPrimitive.Item>