Compare commits
48 Commits
a68f7c7ab5
...
70d5b78ca8
| Author | SHA1 | Date | |
|---|---|---|---|
| 70d5b78ca8 | |||
| e4fcafa57c | |||
| f794a66147 | |||
| 6bdf5fbf12 | |||
| c6a1400dc7 | |||
|
|
aef772c6b1 | ||
| 2d9e6f8df3 | |||
|
|
c99beea46a | ||
|
|
bfdd1ec62a | ||
| 27689dbbff | |||
|
|
0a61371271 | ||
|
|
1acde486f2 | ||
|
|
0f2bfb74b4 | ||
|
|
2188b73f54 | ||
|
|
85c6621b7a | ||
|
|
c69a1af094 | ||
|
|
1e02cd99bc | ||
|
|
5d88121e78 | ||
|
|
2e2498577f | ||
|
|
6c3ae1eda6 | ||
|
|
5dc625c903 | ||
|
|
6c6e7a6847 | ||
|
|
c7298d2b7e | ||
| b4cdc08532 | |||
| cf9a51e64f | |||
|
|
41593be44a | ||
|
|
1275f23bb1 | ||
|
|
7817ae0448 | ||
| a520c04a02 | |||
| dc35c3d43e | |||
| 4c003b3cb5 | |||
|
|
249611886b | ||
|
|
961f726520 | ||
|
|
c50b75ce9b | ||
|
|
b59148630a | ||
|
|
3c272505d6 | ||
|
|
f0fbca832d | ||
|
|
2f470d3531 | ||
|
|
71f3aed875 | ||
|
|
3f3fbad556 | ||
|
|
d85b028bda | ||
|
|
db2ccd0f57 | ||
|
|
4bd88f1b4e | ||
|
|
cd55ddf3f8 | ||
|
|
22f7fa134b | ||
|
|
7c92b787ce | ||
|
|
422b0d5856 | ||
|
|
f7514c698e |
2
.env
2
.env
@@ -33,7 +33,7 @@ NEXT_PUBLIC_LOCALES_PATH=apps/web/public/locales
|
|||||||
NEXT_PUBLIC_ENABLE_THEME_TOGGLE=true
|
NEXT_PUBLIC_ENABLE_THEME_TOGGLE=true
|
||||||
NEXT_PUBLIC_ENABLE_PERSONAL_ACCOUNT_DELETION=true
|
NEXT_PUBLIC_ENABLE_PERSONAL_ACCOUNT_DELETION=true
|
||||||
NEXT_PUBLIC_ENABLE_PERSONAL_ACCOUNT_BILLING=false
|
NEXT_PUBLIC_ENABLE_PERSONAL_ACCOUNT_BILLING=false
|
||||||
NEXT_PUBLIC_ENABLE_TEAM_ACCOUNTS_DELETION=false
|
NEXT_PUBLIC_ENABLE_TEAM_ACCOUNTS_DELETION=true
|
||||||
NEXT_PUBLIC_ENABLE_TEAM_ACCOUNTS_BILLING=true
|
NEXT_PUBLIC_ENABLE_TEAM_ACCOUNTS_BILLING=true
|
||||||
NEXT_PUBLIC_ENABLE_TEAM_ACCOUNTS=true
|
NEXT_PUBLIC_ENABLE_TEAM_ACCOUNTS=true
|
||||||
NEXT_PUBLIC_ENABLE_TEAM_ACCOUNTS_CREATION=true
|
NEXT_PUBLIC_ENABLE_TEAM_ACCOUNTS_CREATION=true
|
||||||
|
|||||||
@@ -31,25 +31,64 @@ NODE_TLS_REJECT_UNAUTHORIZED=0
|
|||||||
MEDIPOST_URL=https://meditest.medisoft.ee:7443/Medipost/MedipostServlet
|
MEDIPOST_URL=https://meditest.medisoft.ee:7443/Medipost/MedipostServlet
|
||||||
MEDIPOST_USER=trvurgtst
|
MEDIPOST_USER=trvurgtst
|
||||||
MEDIPOST_PASSWORD=SRB48HZMV
|
MEDIPOST_PASSWORD=SRB48HZMV
|
||||||
|
MEDIPOST_RECIPIENT=syndev
|
||||||
MEDIPOST_RECIPIENT=trvurgtst
|
MEDIPOST_RECIPIENT=trvurgtst
|
||||||
MEDIPOST_MESSAGE_SENDER=trvurgtst
|
MEDIPOST_MESSAGE_SENDER=trvurgtst
|
||||||
MEDIPOST_ENABLE_DISPATCH_ON_MONTONIO_CALLBACK=true
|
MEDIPOST_ENABLE_DISPATCH_ON_MONTONIO_CALLBACK=true
|
||||||
|
|
||||||
#MEDIPOST_URL=https://medipost2.medisoft.ee:8443/Medipost/MedipostServlet
|
#MEDIPOST_URL=https://medipost2.medisoft.ee:8443/Medipost/MedipostServlet
|
||||||
#MEDIPOST_USER=medreport
|
#MEDIPOST_USER=medreport
|
||||||
#MEDIPOST_PASSWORD=
|
#MEDIPOST_PASSWORD=85MXFFDB7
|
||||||
#MEDIPOST_RECIPIENT=HTI
|
#MEDIPOST_RECIPIENT=HTI
|
||||||
#MEDIPOST_MESSAGE_SENDER=medreport
|
#MEDIPOST_MESSAGE_SENDER=medreport
|
||||||
#MEDIPOST_ENABLE_DISPATCH_ON_MONTONIO_CALLBACK=false
|
#MEDIPOST_ENABLE_DISPATCH_ON_MONTONIO_CALLBACK=false
|
||||||
|
|
||||||
# MEDUSA
|
# MEDUSA
|
||||||
|
COMPANY_BENEFITS_PAYMENT_SECRET_KEY=NzcwMzE2NmEtOThiMS0xMWYwLWI4NjYtMDMwZDQzMjFhMjExCg==
|
||||||
MEDUSA_BACKEND_URL=http://localhost:9000
|
MEDUSA_BACKEND_URL=http://localhost:9000
|
||||||
MEDUSA_BACKEND_PUBLIC_URL=http://localhost:9000
|
MEDUSA_BACKEND_PUBLIC_URL=http://localhost:9000
|
||||||
|
MEDUSA_SECRET_API_KEY=sk_b332d525212ab4078ef73fb2b8232c3beebccc4a460e2c7abf6e187a458d60cf
|
||||||
|
NEXT_PUBLIC_MEDUSA_PUBLISHABLE_KEY=pk_e23a820689a07d55aa0a0ad187268559f5d6288ecb0768ff4520516285bdef84
|
||||||
|
|
||||||
|
#MEDUSA_BACKEND_URL=https://backoffice-test.medreport.ee
|
||||||
|
#MEDUSA_BACKEND_PUBLIC_URL=https://backoffice-test.medreport.ee
|
||||||
|
#MEDUSA_SECRET_API_KEY=sk_5ac1c1c12c144cd744b6c881050d459e339ddf6a3d14eda271a0cc4f9d3812cb
|
||||||
|
#NEXT_PUBLIC_MEDUSA_PUBLISHABLE_KEY=pk_e740b9ca22b31c4b44862044f001dbcf8f46d47d40f430733d0c75bef14d2d6a
|
||||||
|
|
||||||
|
#MEDUSA_BACKEND_URL=https://backoffice.medreport.ee
|
||||||
|
#MEDUSA_BACKEND_PUBLIC_URL=https://backoffice.medreport.ee
|
||||||
|
#NEXT_PUBLIC_MEDUSA_PUBLISHABLE_KEY=pk_068d930c33fea53608a410d84a51935f6ce2ccec5bef8e0ecf75eaee602ac486
|
||||||
|
#MEDUSA_SECRET_API_KEY=sk_fdb1808fbabf62979cc46316aa997378ffbb87882883e8f5c3ee47cee39dcac5
|
||||||
|
|
||||||
|
#MEDUSA_BACKEND_URL=http://5.181.51.38:9000
|
||||||
|
#MEDUSA_BACKEND_PUBLIC_URL=http://5.181.51.38:9000
|
||||||
|
#NEXT_PUBLIC_MEDUSA_PUBLISHABLE_KEY=pk_0ec86252438b38ce18d5601f7877e4395d7e0a6afa8687dfea8d37af33015633
|
||||||
|
|
||||||
# MONTONIO
|
# MONTONIO
|
||||||
NEXT_PUBLIC_MONTONIO_ACCESS_KEY=7da5d7fa-3383-4997-9435-46aa818f4ead
|
NEXT_PUBLIC_MONTONIO_ACCESS_KEY=7da5d7fa-3383-4997-9435-46aa818f4ead
|
||||||
MONTONIO_SECRET_KEY=rNZkzwxOiH93mzkdV53AvhSsbGidrgO2Kl5lE/IT7cvo
|
MONTONIO_SECRET_KEY=rNZkzwxOiH93mzkdV53AvhSsbGidrgO2Kl5lE/IT7cvo
|
||||||
MONTONIO_API_URL=https://sandbox-stargate.montonio.com
|
MONTONIO_API_URL=https://sandbox-stargate.montonio.com
|
||||||
|
|
||||||
|
#NEXT_PUBLIC_MONTONIO_ACCESS_KEY=13e3686a-e7ad-41f6-998b-3f7d7de17654
|
||||||
|
#MONTONIO_SECRET_KEY=wTd4BZ01h80KZLMPL4mjt0RCFxKaYRSu9mMB1PQZCxnw
|
||||||
|
#MONTONIO_API_URL=https://stargate.montonio.com
|
||||||
|
|
||||||
# JOBS
|
# JOBS
|
||||||
JOBS_API_TOKEN=73ce073c-6dd4-11f0-8e75-8fee89786197
|
JOBS_API_TOKEN=73ce073c-6dd4-11f0-8e75-8fee89786197
|
||||||
|
|
||||||
|
# SUPABASE
|
||||||
|
NEXT_PUBLIC_SUPABASE_URL=https://klocrucggryikaxzvxgc.supabase.co
|
||||||
|
NEXT_PUBLIC_SUPABASE_ANON_KEY=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6Imtsb2NydWNnZ3J5aWtheHp2eGdjIiwicm9sZSI6ImFub24iLCJpYXQiOjE3NTY5ODQ2MjgsImV4cCI6MjA3MjU2MDYyOH0.2XOQngowcymiSUZO_XEEWAWzco2uRIjwG7TAeRRLIdU
|
||||||
|
SUPABASE_SERVICE_ROLE_KEY=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6Imtsb2NydWNnZ3J5aWtheHp2eGdjIiwicm9sZSI6InNlcnZpY2Vfcm9sZSIsImlhdCI6MTc1Njk4NDYyOCwiZXhwIjoyMDcyNTYwNjI4fQ.1UZR7AqSD9bOy1gtZRGhOCNoESsw2W-DoFDDsNNMwoE
|
||||||
|
|
||||||
|
#NEXT_PUBLIC_SUPABASE_URL=https://oqsdacktkhmbylmzstjq.supabase.co
|
||||||
|
#NEXT_PUBLIC_SUPABASE_ANON_KEY=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6Im9xc2RhY2t0a2htYnlsbXpzdGpxIiwicm9sZSI6ImFub24iLCJpYXQiOjE3NDY1MjgxMjMsImV4cCI6MjA2MjEwNDEyM30.LdHCTWxijFmhXdnT9KVuLRAVbtSwY7OO-oLtpd8GmO0
|
||||||
|
#SUPABASE_SERVICE_ROLE_KEY=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6Im9xc2RhY2t0a2htYnlsbXpzdGpxIiwicm9sZSI6InNlcnZpY2Vfcm9sZSIsImlhdCI6MTc0NjUyODEyMywiZXhwIjoyMDYyMTA0MTIzfQ.KVcnkZ21Pd0XkJho23dZqFHawVTLQqfvF7l2RxsELLk
|
||||||
|
|
||||||
|
NEXT_PUBLIC_SUPABASE_URL=http://5.181.51.38:54321
|
||||||
|
NEXT_PUBLIC_SUPABASE_ANON_KEY=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZS1kZW1vIiwicm9sZSI6ImFub24iLCJleHAiOjE5ODM4MTI5OTZ9.CRXP1A7WOeoJeXxjNni43kdQwgnWNReilDMblYTn_I0
|
||||||
|
SUPABASE_SERVICE_ROLE_KEY=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZS1kZW1vIiwicm9sZSI6InNlcnZpY2Vfcm9sZSIsImV4cCI6MTk4MzgxMjk5Nn0.EGIM96RAZx35lJzdJsyH-qQwv8Hdp7fsn3W0YpN81IU
|
||||||
|
|
||||||
|
### TEST.MEDREPORT.ee ###
|
||||||
|
|
||||||
|
DB_PASSWORD=imCTUreSnazWKT3u#
|
||||||
|
|||||||
@@ -6,10 +6,10 @@
|
|||||||
## PUBLIC KEYS OR CONFIGURATION ARE OKAY TO BE PLACED HERE.
|
## PUBLIC KEYS OR CONFIGURATION ARE OKAY TO BE PLACED HERE.
|
||||||
|
|
||||||
# SUPABASE
|
# SUPABASE
|
||||||
# NEXT_PUBLIC_SUPABASE_URL=https://oqsdacktkhmbylmzstjq.supabase.co
|
NEXT_PUBLIC_SUPABASE_URL=https://oqsdacktkhmbylmzstjq.supabase.co
|
||||||
# NEXT_PUBLIC_SUPABASE_ANON_KEY=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6Im9xc2RhY2t0a2htYnlsbXpzdGpxIiwicm9sZSI6ImFub24iLCJpYXQiOjE3NDY1MjgxMjMsImV4cCI6MjA2MjEwNDEyM30.LdHCTWxijFmhXdnT9KVuLRAVbtSwY7OO-oLtpd8GmO0
|
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
|
# # MONTONIO
|
||||||
# NEXT_PUBLIC_MONTONIO_ACCESS_KEY=7da5d7fa-3383-4997-9435-46aa818f4ead
|
NEXT_PUBLIC_MONTONIO_ACCESS_KEY=7da5d7fa-3383-4997-9435-46aa818f4ead
|
||||||
|
|||||||
@@ -1,12 +1,11 @@
|
|||||||
|
import { SIDEBAR_WIDTH_PROPERTY } from '@/packages/ui/src/shadcn/constants';
|
||||||
|
|
||||||
import { AppLogo } from '@kit/shared/components/app-logo';
|
import { AppLogo } from '@kit/shared/components/app-logo';
|
||||||
import { ProfileAccountDropdownContainer } from '@kit/shared/components/personal-account-dropdown-container';
|
import { ProfileAccountDropdownContainer } from '@kit/shared/components/personal-account-dropdown-container';
|
||||||
import { SIDEBAR_WIDTH_PROPERTY } from '@/packages/ui/src/shadcn/constants';
|
|
||||||
|
|
||||||
import type { UserWorkspace } from '../../home/(user)/_lib/server/load-user-workspace';
|
import type { UserWorkspace } from '../../home/(user)/_lib/server/load-user-workspace';
|
||||||
|
|
||||||
export function AdminMenuNavigation(props: {
|
export function AdminMenuNavigation(props: { workspace: UserWorkspace }) {
|
||||||
workspace: UserWorkspace;
|
|
||||||
}) {
|
|
||||||
const { accounts } = props.workspace;
|
const { accounts } = props.workspace;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -17,9 +16,7 @@ export function AdminMenuNavigation(props: {
|
|||||||
|
|
||||||
<div className="flex items-center justify-end gap-3">
|
<div className="flex items-center justify-end gap-3">
|
||||||
<div>
|
<div>
|
||||||
<ProfileAccountDropdownContainer
|
<ProfileAccountDropdownContainer accounts={accounts} />
|
||||||
accounts={accounts}
|
|
||||||
/>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -3,8 +3,8 @@ import { cache } from 'react';
|
|||||||
import { AdminAccountPage } from '@kit/admin/components/admin-account-page';
|
import { AdminAccountPage } from '@kit/admin/components/admin-account-page';
|
||||||
import { AdminGuard } from '@kit/admin/components/admin-guard';
|
import { AdminGuard } from '@kit/admin/components/admin-guard';
|
||||||
|
|
||||||
import { getAccount } from '~/lib/services/account.service';
|
|
||||||
import { withI18n } from '~/lib/i18n/with-i18n';
|
import { withI18n } from '~/lib/i18n/with-i18n';
|
||||||
|
import { getAccount } from '~/lib/services/account.service';
|
||||||
|
|
||||||
interface Params {
|
interface Params {
|
||||||
params: Promise<{
|
params: Promise<{
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import { getSupabaseServerClient } from '@kit/supabase/server-client';
|
|||||||
import { AppBreadcrumbs } from '@kit/ui/app-breadcrumbs';
|
import { AppBreadcrumbs } from '@kit/ui/app-breadcrumbs';
|
||||||
import { Button } from '@kit/ui/button';
|
import { Button } from '@kit/ui/button';
|
||||||
import { PageBody, PageHeader } from '@kit/ui/page';
|
import { PageBody, PageHeader } from '@kit/ui/page';
|
||||||
|
|
||||||
import { withI18n } from '~/lib/i18n/with-i18n';
|
import { withI18n } from '~/lib/i18n/with-i18n';
|
||||||
|
|
||||||
interface SearchParams {
|
interface SearchParams {
|
||||||
|
|||||||
@@ -5,8 +5,8 @@ import { cookies } from 'next/headers';
|
|||||||
import { Page, PageMobileNavigation, PageNavigation } from '@kit/ui/page';
|
import { Page, PageMobileNavigation, PageNavigation } from '@kit/ui/page';
|
||||||
import { SidebarProvider } from '@kit/ui/shadcn-sidebar';
|
import { SidebarProvider } from '@kit/ui/shadcn-sidebar';
|
||||||
|
|
||||||
import { AdminSidebar } from '~/admin/_components/admin-sidebar';
|
|
||||||
import { AdminMenuNavigation } from '~/admin/_components/admin-menu-navigation';
|
import { AdminMenuNavigation } from '~/admin/_components/admin-menu-navigation';
|
||||||
|
import { AdminSidebar } from '~/admin/_components/admin-sidebar';
|
||||||
import { AdminMobileNavigation } from '~/admin/_components/mobile-navigation';
|
import { AdminMobileNavigation } from '~/admin/_components/mobile-navigation';
|
||||||
|
|
||||||
import { loadUserWorkspace } from '../home/(user)/_lib/server/load-user-workspace';
|
import { loadUserWorkspace } from '../home/(user)/_lib/server/load-user-workspace';
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import { AdminDashboard } from '@kit/admin/components/admin-dashboard';
|
import { AdminDashboard } from '@kit/admin/components/admin-dashboard';
|
||||||
import { AdminGuard } from '@kit/admin/components/admin-guard';
|
import { AdminGuard } from '@kit/admin/components/admin-guard';
|
||||||
import { PageBody, PageHeader } from '@kit/ui/page';
|
import { PageBody, PageHeader } from '@kit/ui/page';
|
||||||
|
|
||||||
import { withI18n } from '~/lib/i18n/with-i18n';
|
import { withI18n } from '~/lib/i18n/with-i18n';
|
||||||
|
|
||||||
function AdminPage() {
|
function AdminPage() {
|
||||||
|
|||||||
@@ -2,10 +2,45 @@ import axios from 'axios';
|
|||||||
|
|
||||||
import { getSupabaseServerAdminClient } from '@kit/supabase/server-admin-client';
|
import { getSupabaseServerAdminClient } from '@kit/supabase/server-admin-client';
|
||||||
|
|
||||||
import type { ISearchLoadResponse } from '~/lib/types/connected-online';
|
import { logSyncResult } from '~/lib/services/audit.service';
|
||||||
|
import { SyncStatus } from '~/lib/types/audit';
|
||||||
|
import type {
|
||||||
|
ISearchLoadResponse,
|
||||||
|
P_JobTitleTranslation,
|
||||||
|
} from '~/lib/types/connected-online';
|
||||||
|
|
||||||
|
function createTranslationMap(translations: P_JobTitleTranslation[]) {
|
||||||
|
const result: Map<
|
||||||
|
number,
|
||||||
|
Map<number, { textEN: string; textRU: string; textET: string }>
|
||||||
|
> = new Map();
|
||||||
|
|
||||||
|
for (const translation of translations) {
|
||||||
|
const { ClinicID, TextET, TextEN, TextRU, SyncID } = translation;
|
||||||
|
|
||||||
|
if (!result.has(ClinicID)) {
|
||||||
|
result.set(ClinicID, new Map());
|
||||||
|
}
|
||||||
|
|
||||||
|
result.get(ClinicID)!.set(SyncID, {
|
||||||
|
textET: TextET,
|
||||||
|
textEN: TextEN,
|
||||||
|
textRU: TextRU,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
function getSpokenLanguages(spokenLanguages?: string) {
|
||||||
|
if (!spokenLanguages || !spokenLanguages.length) return [];
|
||||||
|
return spokenLanguages.split(',');
|
||||||
|
}
|
||||||
|
|
||||||
export default async function syncConnectedOnline() {
|
export default async function syncConnectedOnline() {
|
||||||
const isProd = process.env.NODE_ENV === 'production';
|
const isProd = !['test', 'localhost'].some((pathString) =>
|
||||||
|
process.env.NEXT_PUBLIC_SITE_URL?.includes(pathString),
|
||||||
|
);
|
||||||
|
|
||||||
const baseUrl = process.env.CONNECTED_ONLINE_URL;
|
const baseUrl = process.env.CONNECTED_ONLINE_URL;
|
||||||
|
|
||||||
@@ -16,14 +51,19 @@ export default async function syncConnectedOnline() {
|
|||||||
const supabase = getSupabaseServerAdminClient();
|
const supabase = getSupabaseServerAdminClient();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const response = await axios.post<{ d: string }>(`${baseUrl}/Search_Load`, {
|
const searchLoadResponse = await axios.post<{ d: string }>(
|
||||||
headers: {
|
`${baseUrl}/Search_Load`,
|
||||||
'Content-Type': 'application/json; charset=utf-8',
|
{
|
||||||
|
headers: {
|
||||||
|
'Content-Type': 'application/json; charset=utf-8',
|
||||||
|
},
|
||||||
|
param: "{'Value':'|et|-1'}", // get all available services in Estonian
|
||||||
},
|
},
|
||||||
param: "{'Value':'|et|-1'}", // get all available services in Estonian
|
);
|
||||||
});
|
|
||||||
|
|
||||||
const responseData: ISearchLoadResponse = JSON.parse(response.data.d);
|
const responseData: ISearchLoadResponse = JSON.parse(
|
||||||
|
searchLoadResponse.data.d,
|
||||||
|
);
|
||||||
|
|
||||||
if (responseData?.ErrorCode !== 0) {
|
if (responseData?.ErrorCode !== 0) {
|
||||||
throw new Error('Failed to get Connected Online data');
|
throw new Error('Failed to get Connected Online data');
|
||||||
@@ -43,18 +83,23 @@ export default async function syncConnectedOnline() {
|
|||||||
|
|
||||||
let clinics;
|
let clinics;
|
||||||
let services;
|
let services;
|
||||||
|
let serviceProviders;
|
||||||
|
let jobTitleTranslations;
|
||||||
// Filter out "Dentas Demo OÜ" in prod or only sync "Dentas Demo OÜ" in any other environment
|
// Filter out "Dentas Demo OÜ" in prod or only sync "Dentas Demo OÜ" in any other environment
|
||||||
if (isProd) {
|
const isDemoClinic = (clinicId: number) =>
|
||||||
clinics = responseData.Data.T_Lic.filter((clinic) => clinic.ID !== 2);
|
isProd ? clinicId !== 2 : clinicId === 2;
|
||||||
services = responseData.Data.T_Service.filter(
|
clinics = responseData.Data.T_Lic.filter(({ ID }) => isDemoClinic(ID));
|
||||||
(service) => service.ClinicID !== 2,
|
services = responseData.Data.T_Service.filter(({ ClinicID }) =>
|
||||||
);
|
isDemoClinic(ClinicID),
|
||||||
} else {
|
);
|
||||||
clinics = responseData.Data.T_Lic.filter((clinic) => clinic.ID === 2);
|
serviceProviders = responseData.Data.T_Doctor.filter(({ ClinicID }) =>
|
||||||
services = responseData.Data.T_Service.filter(
|
isDemoClinic(ClinicID),
|
||||||
(service) => service.ClinicID === 2,
|
);
|
||||||
);
|
jobTitleTranslations = createTranslationMap(
|
||||||
}
|
responseData.Data.P_JobTitleTranslations.filter(({ ClinicID }) =>
|
||||||
|
isDemoClinic(ClinicID),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
const mappedClinics = clinics.map((clinic) => {
|
const mappedClinics = clinics.map((clinic) => {
|
||||||
return {
|
return {
|
||||||
@@ -64,6 +109,8 @@ export default async function syncConnectedOnline() {
|
|||||||
name: clinic.Name,
|
name: clinic.Name,
|
||||||
personal_code_required: !!clinic.PersonalCodeRequired,
|
personal_code_required: !!clinic.PersonalCodeRequired,
|
||||||
phone_number: clinic.Phone || null,
|
phone_number: clinic.Phone || null,
|
||||||
|
key: clinic.Key,
|
||||||
|
address: clinic.Address,
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -71,7 +118,7 @@ export default async function syncConnectedOnline() {
|
|||||||
return {
|
return {
|
||||||
id: service.ID,
|
id: service.ID,
|
||||||
clinic_id: service.ClinicID,
|
clinic_id: service.ClinicID,
|
||||||
sync_id: service.SyncID,
|
sync_id: Number(service.SyncID),
|
||||||
name: service.Name,
|
name: service.Name,
|
||||||
description: service.Description || null,
|
description: service.Description || null,
|
||||||
price: service.Price,
|
price: service.Price,
|
||||||
@@ -87,45 +134,133 @@ export default async function syncConnectedOnline() {
|
|||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const mappedServiceProviders = serviceProviders.map((serviceProvider) => {
|
||||||
|
const jobTitleTranslation = serviceProvider.JobTitleID
|
||||||
|
? jobTitleTranslations
|
||||||
|
.get(serviceProvider.ClinicID)
|
||||||
|
?.get(serviceProvider.JobTitleID)
|
||||||
|
: null;
|
||||||
|
return {
|
||||||
|
id: serviceProvider.ID,
|
||||||
|
prefix: serviceProvider.Prefix,
|
||||||
|
name: serviceProvider.Name,
|
||||||
|
spoken_languages: getSpokenLanguages(serviceProvider.SpokenLanguages),
|
||||||
|
job_title_et: jobTitleTranslation?.textET,
|
||||||
|
job_title_en: jobTitleTranslation?.textEN,
|
||||||
|
job_title_ru: jobTitleTranslation?.textRU,
|
||||||
|
job_title_id: serviceProvider.JobTitleID,
|
||||||
|
is_deleted: !!serviceProvider.Deleted,
|
||||||
|
clinic_id: serviceProvider.ClinicID,
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
const { error: providersError } = await supabase
|
const { error: providersError } = await supabase
|
||||||
.schema('medreport')
|
.schema('medreport')
|
||||||
.from('connected_online_providers')
|
.from('connected_online_providers')
|
||||||
.upsert(mappedClinics);
|
.upsert(mappedClinics);
|
||||||
|
|
||||||
|
if (providersError) {
|
||||||
|
return logSyncResult({
|
||||||
|
operation: 'CONNECTED_ONLINE_SYNC',
|
||||||
|
comment:
|
||||||
|
'Error saving connected online providers: ' +
|
||||||
|
JSON.stringify(providersError),
|
||||||
|
status: SyncStatus.Fail,
|
||||||
|
changed_by_role: 'service_role',
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
const { error: servicesError } = await supabase
|
const { error: servicesError } = await supabase
|
||||||
.schema('medreport')
|
.schema('medreport')
|
||||||
.from('connected_online_services')
|
.from('connected_online_services')
|
||||||
.upsert(mappedServices, { onConflict: 'id', ignoreDuplicates: false });
|
.upsert(mappedServices, {
|
||||||
|
onConflict: 'id',
|
||||||
|
ignoreDuplicates: false,
|
||||||
|
});
|
||||||
|
|
||||||
if (providersError || servicesError) {
|
if (servicesError) {
|
||||||
return supabase
|
return logSyncResult({
|
||||||
.schema('audit')
|
operation: 'CONNECTED_ONLINE_SYNC',
|
||||||
.from('sync_entries')
|
comment:
|
||||||
.insert({
|
'Error saving connected online services: ' +
|
||||||
operation: 'CONNECTED_ONLINE_SYNC',
|
JSON.stringify(servicesError),
|
||||||
comment: providersError
|
status: SyncStatus.Fail,
|
||||||
? 'Error saving providers: ' + JSON.stringify(providersError)
|
changed_by_role: 'service_role',
|
||||||
: 'Error saving services: ' + JSON.stringify(servicesError),
|
});
|
||||||
status: 'FAIL',
|
|
||||||
changed_by_role: 'service_role',
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
await supabase.schema('audit').from('sync_entries').insert({
|
const { error: serviceProvidersError } = await supabase
|
||||||
|
.schema('medreport')
|
||||||
|
.from('connected_online_service_providers')
|
||||||
|
.upsert(mappedServiceProviders, {
|
||||||
|
onConflict: 'id',
|
||||||
|
ignoreDuplicates: false,
|
||||||
|
});
|
||||||
|
|
||||||
|
if (serviceProvidersError) {
|
||||||
|
return logSyncResult({
|
||||||
|
operation: 'CONNECTED_ONLINE_SYNC',
|
||||||
|
comment:
|
||||||
|
'Error saving service providers: ' +
|
||||||
|
JSON.stringify(serviceProvidersError),
|
||||||
|
status: SyncStatus.Fail,
|
||||||
|
changed_by_role: 'service_role',
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const mappedClinic of mappedClinics) {
|
||||||
|
const defaultLoadResponse = await axios.post<{ d: string }>(
|
||||||
|
`${baseUrl}/Default_Load`,
|
||||||
|
{
|
||||||
|
headers: {
|
||||||
|
'Content-Type': 'application/json; charset=utf-8',
|
||||||
|
},
|
||||||
|
param: `{'Value':'${mappedClinic.key}|et'}`,
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
const defaultLoadResponseData = JSON.parse(defaultLoadResponse.data.d);
|
||||||
|
|
||||||
|
if (defaultLoadResponseData?.ErrorCode !== 0) {
|
||||||
|
throw new Error('Failed to get Connected Online location data');
|
||||||
|
}
|
||||||
|
|
||||||
|
const clinicLocations: {
|
||||||
|
SyncID: number;
|
||||||
|
Address: string;
|
||||||
|
Name: string;
|
||||||
|
}[] = defaultLoadResponseData.Data.T_SelectableLocation;
|
||||||
|
|
||||||
|
if (clinicLocations?.length) {
|
||||||
|
const mappedLocations = clinicLocations.map(
|
||||||
|
({ SyncID, Address, Name }) => ({
|
||||||
|
address: Address,
|
||||||
|
clinic_id: mappedClinic.id,
|
||||||
|
sync_id: SyncID,
|
||||||
|
name: Name,
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
|
||||||
|
await supabase
|
||||||
|
.schema('medreport')
|
||||||
|
.from('connected_online_locations')
|
||||||
|
.insert(mappedLocations)
|
||||||
|
.throwOnError();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
await logSyncResult({
|
||||||
operation: 'CONNECTED_ONLINE_SYNC',
|
operation: 'CONNECTED_ONLINE_SYNC',
|
||||||
status: 'SUCCESS',
|
status: SyncStatus.Success,
|
||||||
changed_by_role: 'service_role',
|
changed_by_role: 'service_role',
|
||||||
});
|
});
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
await supabase
|
await logSyncResult({
|
||||||
.schema('audit')
|
operation: 'CONNECTED_ONLINE_SYNC',
|
||||||
.from('sync_entries')
|
status: SyncStatus.Fail,
|
||||||
.insert({
|
comment: JSON.stringify(e),
|
||||||
operation: 'CONNECTED_ONLINE_SYNC',
|
changed_by_role: 'service_role',
|
||||||
status: 'FAIL',
|
});
|
||||||
comment: JSON.stringify(e),
|
|
||||||
changed_by_role: 'service_role',
|
|
||||||
});
|
|
||||||
throw new Error(
|
throw new Error(
|
||||||
`Failed to sync Connected Online data, error: ${JSON.stringify(e)}`,
|
`Failed to sync Connected Online data, error: ${JSON.stringify(e)}`,
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,12 +1,20 @@
|
|||||||
|
import { redirect } from 'next/navigation';
|
||||||
|
|
||||||
import { HomeLayoutPageHeader } from '@/app/home/(user)/_components/home-page-header';
|
import { HomeLayoutPageHeader } from '@/app/home/(user)/_components/home-page-header';
|
||||||
import { loadCategory } from '@/app/home/(user)/_lib/server/load-category';
|
import { loadCategory } from '@/app/home/(user)/_lib/server/load-category';
|
||||||
|
|
||||||
|
import { pathsConfig } from '@kit/shared/config';
|
||||||
import { AppBreadcrumbs } from '@kit/ui/makerkit/app-breadcrumbs';
|
import { AppBreadcrumbs } from '@kit/ui/makerkit/app-breadcrumbs';
|
||||||
import { PageBody } from '@kit/ui/page';
|
|
||||||
import { Trans } from '@kit/ui/trans';
|
import { Trans } from '@kit/ui/trans';
|
||||||
|
|
||||||
|
import BookingContainer from '~/home/(user)/_components/booking/booking-container';
|
||||||
|
import { loadCurrentUserAccount } from '~/home/(user)/_lib/server/load-user-account';
|
||||||
import { createI18nServerInstance } from '~/lib/i18n/i18n.server';
|
import { createI18nServerInstance } from '~/lib/i18n/i18n.server';
|
||||||
import { withI18n } from '~/lib/i18n/with-i18n';
|
import { withI18n } from '~/lib/i18n/with-i18n';
|
||||||
|
import {
|
||||||
|
PageViewAction,
|
||||||
|
createPageViewLog,
|
||||||
|
} from '~/lib/services/audit/pageView.service';
|
||||||
|
|
||||||
export const generateMetadata = async () => {
|
export const generateMetadata = async () => {
|
||||||
const i18n = await createI18nServerInstance();
|
const i18n = await createI18nServerInstance();
|
||||||
@@ -17,9 +25,30 @@ export const generateMetadata = async () => {
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
async function BookingHandlePage({ params }: { params: { handle: string } }) {
|
async function BookingHandlePage({
|
||||||
const handle = await params.handle;
|
params,
|
||||||
|
}: {
|
||||||
|
params: Promise<{ handle: string }>;
|
||||||
|
}) {
|
||||||
|
const { handle } = await params;
|
||||||
const { category } = await loadCategory({ handle });
|
const { category } = await loadCategory({ handle });
|
||||||
|
const { account } = await loadCurrentUserAccount();
|
||||||
|
|
||||||
|
if (!category) {
|
||||||
|
return <div>Category not found</div>;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!account) {
|
||||||
|
return redirect(pathsConfig.auth.signIn);
|
||||||
|
}
|
||||||
|
|
||||||
|
await createPageViewLog({
|
||||||
|
accountId: account.id,
|
||||||
|
action: PageViewAction.VIEW_TTO_SERVICE_BOOKING,
|
||||||
|
extraData: {
|
||||||
|
handle,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
@@ -30,10 +59,10 @@ async function BookingHandlePage({ params }: { params: { handle: string } }) {
|
|||||||
/>
|
/>
|
||||||
<HomeLayoutPageHeader
|
<HomeLayoutPageHeader
|
||||||
title={<Trans i18nKey={'booking:title'} />}
|
title={<Trans i18nKey={'booking:title'} />}
|
||||||
description={<Trans i18nKey={'booking:description'} />}
|
description=""
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<PageBody></PageBody>
|
<BookingContainer category={category} />
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,8 +34,15 @@ export default function MontonioCallbackClient({
|
|||||||
setHasProcessed(true);
|
setHasProcessed(true);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const { orderId } = await processMontonioCallback(orderToken);
|
const result = await processMontonioCallback(orderToken);
|
||||||
router.push(`/home/order/${orderId}/confirmed`);
|
if (result.success) {
|
||||||
|
return router.push(`/home/order/${result.orderId}/confirmed`);
|
||||||
|
}
|
||||||
|
if (result.failedServiceBookings?.length) {
|
||||||
|
router.push(
|
||||||
|
`/home/cart/montonio-callback/error?reasonFailed=${result.failedServiceBookings.map(({ reason }) => reason).join(',')}`,
|
||||||
|
);
|
||||||
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Failed to place order', error);
|
console.error('Failed to place order', error);
|
||||||
router.push('/home/cart/montonio-callback/error');
|
router.push('/home/cart/montonio-callback/error');
|
||||||
|
|||||||
@@ -1,8 +1,11 @@
|
|||||||
|
import { use } from 'react';
|
||||||
|
|
||||||
import Link from 'next/link';
|
import Link from 'next/link';
|
||||||
|
|
||||||
import { createI18nServerInstance } from '@/lib/i18n/i18n.server';
|
import { createI18nServerInstance } from '@/lib/i18n/i18n.server';
|
||||||
import { PageBody, PageHeader } from '@/packages/ui/src/makerkit/page';
|
import { PageBody, PageHeader } from '@/packages/ui/src/makerkit/page';
|
||||||
|
|
||||||
|
import { toArray } from '@kit/shared/utils';
|
||||||
import { Button } from '@kit/ui/button';
|
import { Button } from '@kit/ui/button';
|
||||||
import { Alert, AlertDescription } from '@kit/ui/shadcn/alert';
|
import { Alert, AlertDescription } from '@kit/ui/shadcn/alert';
|
||||||
import { AlertTitle } from '@kit/ui/shadcn/alert';
|
import { AlertTitle } from '@kit/ui/shadcn/alert';
|
||||||
@@ -16,7 +19,15 @@ export async function generateMetadata() {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export default async function MontonioCheckoutCallbackErrorPage() {
|
export default async function MontonioCheckoutCallbackErrorPage({
|
||||||
|
searchParams,
|
||||||
|
}: {
|
||||||
|
searchParams: Promise<{ reasonFailed: string }>;
|
||||||
|
}) {
|
||||||
|
const params = await searchParams;
|
||||||
|
|
||||||
|
const failedBookingData: string[] = toArray(params.reasonFailed?.split(','));
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={'flex h-full flex-1 flex-col'}>
|
<div className={'flex h-full flex-1 flex-col'}>
|
||||||
<PageHeader title={<Trans i18nKey="cart:montonioCallback.title" />} />
|
<PageHeader title={<Trans i18nKey="cart:montonioCallback.title" />} />
|
||||||
@@ -28,9 +39,15 @@ export default async function MontonioCheckoutCallbackErrorPage() {
|
|||||||
</AlertTitle>
|
</AlertTitle>
|
||||||
|
|
||||||
<AlertDescription>
|
<AlertDescription>
|
||||||
<p>
|
{failedBookingData.length ? (
|
||||||
|
failedBookingData.map((failureReason, index) => (
|
||||||
|
<p key={index}>
|
||||||
|
<Trans i18nKey={`checkout.error.${failureReason}`} />
|
||||||
|
</p>
|
||||||
|
))
|
||||||
|
) : (
|
||||||
<Trans i18nKey={'checkout.error.description'} />
|
<Trans i18nKey={'checkout.error.description'} />
|
||||||
</p>
|
)}
|
||||||
</AlertDescription>
|
</AlertDescription>
|
||||||
</Alert>
|
</Alert>
|
||||||
|
|
||||||
|
|||||||
@@ -6,11 +6,14 @@ import { listProductTypes } from '@lib/data/products';
|
|||||||
import { Trans } from '@kit/ui/trans';
|
import { Trans } from '@kit/ui/trans';
|
||||||
|
|
||||||
import { withI18n } from '~/lib/i18n/with-i18n';
|
import { withI18n } from '~/lib/i18n/with-i18n';
|
||||||
|
import { getCartReservations } from '~/lib/services/reservation.service';
|
||||||
|
import { findProductTypeIdByHandle } from '~/lib/utils';
|
||||||
|
|
||||||
import Cart from '../../_components/cart';
|
import Cart from '../../_components/cart';
|
||||||
import CartTimer from '../../_components/cart/cart-timer';
|
import CartTimer from '../../_components/cart/cart-timer';
|
||||||
import { loadCurrentUserAccount } from '../../_lib/server/load-user-account';
|
import { loadCurrentUserAccount } from '../../_lib/server/load-user-account';
|
||||||
import { AccountBalanceService } from '@kit/accounts/services/account-balance.service';
|
import { AccountBalanceService } from '@kit/accounts/services/account-balance.service';
|
||||||
|
import { EnrichedCartItem } from '../../_components/cart/types';
|
||||||
|
|
||||||
export async function generateMetadata() {
|
export async function generateMetadata() {
|
||||||
const { t } = await createI18nServerInstance();
|
const { t } = await createI18nServerInstance();
|
||||||
@@ -37,29 +40,32 @@ async function CartPage() {
|
|||||||
|
|
||||||
const balanceSummary = await new AccountBalanceService().getBalanceSummary(account.id);
|
const balanceSummary = await new AccountBalanceService().getBalanceSummary(account.id);
|
||||||
|
|
||||||
const analysisPackagesType = productTypes.find(
|
const synlabAnalysisTypeId = findProductTypeIdByHandle(
|
||||||
({ metadata }) => metadata?.handle === 'analysis-packages',
|
productTypes,
|
||||||
|
'synlab-analysis',
|
||||||
);
|
);
|
||||||
const synlabAnalysisType = productTypes.find(
|
const analysisPackagesTypeId = findProductTypeIdByHandle(
|
||||||
({ metadata }) => metadata?.handle === 'synlab-analysis',
|
productTypes,
|
||||||
|
'analysis-packages',
|
||||||
);
|
);
|
||||||
|
|
||||||
const synlabAnalyses =
|
const synlabAnalyses =
|
||||||
analysisPackagesType && synlabAnalysisType && cart?.items
|
analysisPackagesTypeId && synlabAnalysisTypeId && cart?.items
|
||||||
? cart.items.filter((item) => {
|
? cart.items.filter((item) => {
|
||||||
const productTypeId = item.product?.type_id;
|
const productTypeId = item.product?.type_id;
|
||||||
if (!productTypeId) {
|
if (!productTypeId) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return [analysisPackagesType.id, synlabAnalysisType.id].includes(
|
return [analysisPackagesTypeId, synlabAnalysisTypeId].includes(
|
||||||
productTypeId,
|
productTypeId,
|
||||||
);
|
);
|
||||||
})
|
})
|
||||||
: [];
|
: [];
|
||||||
const ttoServiceItems =
|
|
||||||
cart?.items?.filter(
|
|
||||||
(item) => !synlabAnalyses.some((analysis) => analysis.id === item.id),
|
|
||||||
) ?? [];
|
|
||||||
|
|
||||||
|
let ttoServiceItems: EnrichedCartItem[] = [];
|
||||||
|
if (cart?.items?.length) {
|
||||||
|
ttoServiceItems = await getCartReservations(cart);
|
||||||
|
}
|
||||||
const otherItemsSorted = ttoServiceItems.sort((a, b) =>
|
const otherItemsSorted = ttoServiceItems.sort((a, b) =>
|
||||||
(a.updated_at ?? '') > (b.updated_at ?? '') ? -1 : 1,
|
(a.updated_at ?? '') > (b.updated_at ?? '') ? -1 : 1,
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -26,17 +26,7 @@ async function OrderConfirmedPage(props: {
|
|||||||
params: Promise<{ orderId: string }>;
|
params: Promise<{ orderId: string }>;
|
||||||
}) {
|
}) {
|
||||||
const params = await props.params;
|
const params = await props.params;
|
||||||
|
const medusaOrder = await retrieveOrder(params.orderId).catch(() => null);
|
||||||
const order = await getAnalysisOrder({
|
|
||||||
analysisOrderId: Number(params.orderId),
|
|
||||||
}).catch(() => null);
|
|
||||||
if (!order) {
|
|
||||||
redirect(pathsConfig.app.myOrders);
|
|
||||||
}
|
|
||||||
|
|
||||||
const medusaOrder = await retrieveOrder(order.medusa_order_id).catch(
|
|
||||||
() => null,
|
|
||||||
);
|
|
||||||
if (!medusaOrder) {
|
if (!medusaOrder) {
|
||||||
redirect(pathsConfig.app.myOrders);
|
redirect(pathsConfig.app.myOrders);
|
||||||
}
|
}
|
||||||
@@ -46,7 +36,12 @@ async function OrderConfirmedPage(props: {
|
|||||||
<PageHeader title={<Trans i18nKey="cart:order.title" />} />
|
<PageHeader title={<Trans i18nKey="cart:order.title" />} />
|
||||||
<Divider />
|
<Divider />
|
||||||
<div className="small:grid-cols-[1fr_360px] grid grid-cols-1 gap-x-40 gap-y-6 lg:px-4">
|
<div className="small:grid-cols-[1fr_360px] grid grid-cols-1 gap-x-40 gap-y-6 lg:px-4">
|
||||||
<OrderDetails order={order} />
|
<OrderDetails
|
||||||
|
order={{
|
||||||
|
id: medusaOrder.id,
|
||||||
|
created_at: medusaOrder.created_at,
|
||||||
|
}}
|
||||||
|
/>
|
||||||
<Divider />
|
<Divider />
|
||||||
<OrderItems medusaOrder={medusaOrder} />
|
<OrderItems medusaOrder={medusaOrder} />
|
||||||
<CartTotals medusaOrder={medusaOrder} />
|
<CartTotals medusaOrder={medusaOrder} />
|
||||||
|
|||||||
@@ -11,7 +11,8 @@ import { PageBody } from '@kit/ui/makerkit/page';
|
|||||||
import { Trans } from '@kit/ui/trans';
|
import { Trans } from '@kit/ui/trans';
|
||||||
|
|
||||||
import { withI18n } from '~/lib/i18n/with-i18n';
|
import { withI18n } from '~/lib/i18n/with-i18n';
|
||||||
import { getAnalysisOrders } from '~/lib/services/order.service';
|
import { getAnalysisOrders, getTtoOrders } from '~/lib/services/order.service';
|
||||||
|
import { findProductTypeIdByHandle } from '~/lib/utils';
|
||||||
import { listOrders } from '~/medusa/lib/data/orders';
|
import { listOrders } from '~/medusa/lib/data/orders';
|
||||||
|
|
||||||
import { HomeLayoutPageHeader } from '../../_components/home-page-header';
|
import { HomeLayoutPageHeader } from '../../_components/home-page-header';
|
||||||
@@ -28,19 +29,25 @@ export async function generateMetadata() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function OrdersPage() {
|
async function OrdersPage() {
|
||||||
const [medusaOrders, analysisOrders, { productTypes }] = await Promise.all([
|
const [medusaOrders, analysisOrders, ttoOrders, { productTypes }] = await Promise.all([
|
||||||
listOrders(ORDERS_LIMIT),
|
listOrders(ORDERS_LIMIT),
|
||||||
getAnalysisOrders(),
|
getAnalysisOrders(),
|
||||||
|
getTtoOrders(),
|
||||||
listProductTypes(),
|
listProductTypes(),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
if (!medusaOrders || !productTypes) {
|
if (!medusaOrders || !productTypes || !ttoOrders) {
|
||||||
redirect(pathsConfig.auth.signIn);
|
redirect(pathsConfig.auth.signIn);
|
||||||
}
|
}
|
||||||
|
|
||||||
const analysisPackagesType = productTypes.find(
|
const analysisPackagesTypeId = findProductTypeIdByHandle(
|
||||||
({ metadata }) => metadata?.handle === 'analysis-packages',
|
productTypes,
|
||||||
)!;
|
'analysis-package',
|
||||||
|
);
|
||||||
|
const ttoServiceTypeId = findProductTypeIdByHandle(
|
||||||
|
productTypes,
|
||||||
|
'tto-service',
|
||||||
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
@@ -49,34 +56,45 @@ async function OrdersPage() {
|
|||||||
description={<Trans i18nKey={'orders:description'} />}
|
description={<Trans i18nKey={'orders:description'} />}
|
||||||
/>
|
/>
|
||||||
<PageBody>
|
<PageBody>
|
||||||
{analysisOrders.map((analysisOrder) => {
|
{medusaOrders.map((medusaOrder) => {
|
||||||
const medusaOrder = medusaOrders.find(
|
const analysisOrder = analysisOrders.find(
|
||||||
({ id }) => id === analysisOrder.medusa_order_id,
|
({ medusa_order_id }) => medusa_order_id === medusaOrder.id,
|
||||||
);
|
);
|
||||||
|
|
||||||
if (!medusaOrder) {
|
if (!medusaOrder) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
const medusaOrderItems = medusaOrder.items || [];
|
const medusaOrderItems = medusaOrder.items || [];
|
||||||
const medusaOrderItemsAnalysisPackages = medusaOrderItems.filter(
|
const medusaOrderItemsAnalysisPackages = medusaOrderItems.filter(
|
||||||
(item) => item.product_type_id === analysisPackagesType?.id,
|
(item) => item.product_type_id === analysisPackagesTypeId,
|
||||||
|
);
|
||||||
|
const medusaOrderItemsTtoServices = medusaOrderItems.filter(
|
||||||
|
(item) => item.product_type_id === ttoServiceTypeId,
|
||||||
);
|
);
|
||||||
const medusaOrderItemsOther = medusaOrderItems.filter(
|
const medusaOrderItemsOther = medusaOrderItems.filter(
|
||||||
(item) => item.product_type_id !== analysisPackagesType?.id,
|
(item) =>
|
||||||
|
!item.product_type_id ||
|
||||||
|
![analysisPackagesTypeId, ttoServiceTypeId].includes(
|
||||||
|
item.product_type_id,
|
||||||
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<React.Fragment key={analysisOrder.id}>
|
<React.Fragment key={medusaOrder.id}>
|
||||||
<Divider className="my-6" />
|
<Divider className="my-6" />
|
||||||
<OrderBlock
|
<OrderBlock
|
||||||
|
medusaOrderId={medusaOrder.id}
|
||||||
analysisOrder={analysisOrder}
|
analysisOrder={analysisOrder}
|
||||||
|
medusaOrderStatus={medusaOrder.status}
|
||||||
itemsAnalysisPackage={medusaOrderItemsAnalysisPackages}
|
itemsAnalysisPackage={medusaOrderItemsAnalysisPackages}
|
||||||
|
itemsTtoService={medusaOrderItemsTtoServices}
|
||||||
itemsOther={medusaOrderItemsOther}
|
itemsOther={medusaOrderItemsOther}
|
||||||
/>
|
/>
|
||||||
</React.Fragment>
|
</React.Fragment>
|
||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
{analysisOrders.length === 0 && (
|
{analysisOrders.length === 0 && ttoOrders.length === 0 && (
|
||||||
<h5 className="mt-6">
|
<h5 className="mt-6">
|
||||||
<Trans i18nKey="orders:noOrders" />
|
<Trans i18nKey="orders:noOrders" />
|
||||||
</h5>
|
</h5>
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ import Dashboard from '../_components/dashboard';
|
|||||||
import DashboardCards from '../_components/dashboard-cards';
|
import DashboardCards from '../_components/dashboard-cards';
|
||||||
import Recommendations from '../_components/recommendations';
|
import Recommendations from '../_components/recommendations';
|
||||||
import RecommendationsSkeleton from '../_components/recommendations-skeleton';
|
import RecommendationsSkeleton from '../_components/recommendations-skeleton';
|
||||||
|
import { isValidOpenAiEnv } from '../_lib/server/is-valid-open-ai-env';
|
||||||
import { loadCurrentUserAccount } from '../_lib/server/load-user-account';
|
import { loadCurrentUserAccount } from '../_lib/server/load-user-account';
|
||||||
|
|
||||||
export const generateMetadata = async () => {
|
export const generateMetadata = async () => {
|
||||||
@@ -52,17 +53,16 @@ async function UserHomePage() {
|
|||||||
/>
|
/>
|
||||||
<PageBody>
|
<PageBody>
|
||||||
<Dashboard account={account} bmiThresholds={bmiThresholds} />
|
<Dashboard account={account} bmiThresholds={bmiThresholds} />
|
||||||
{process.env.OPENAI_API_KEY &&
|
{(await isValidOpenAiEnv()) && (
|
||||||
process.env.PROMPT_ID_ANALYSIS_RECOMMENDATIONS && (
|
<>
|
||||||
<>
|
<h4>
|
||||||
<h4>
|
<Trans i18nKey="dashboard:recommendations.title" />
|
||||||
<Trans i18nKey="dashboard:recommendations.title" />
|
</h4>
|
||||||
</h4>
|
<Suspense fallback={<RecommendationsSkeleton />}>
|
||||||
<Suspense fallback={<RecommendationsSkeleton />}>
|
<Recommendations account={account} />
|
||||||
<Recommendations account={account} />
|
</Suspense>
|
||||||
</Suspense>
|
</>
|
||||||
</>
|
)}
|
||||||
)}
|
|
||||||
</PageBody>
|
</PageBody>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
|||||||
40
app/home/(user)/_components/booking/booking-calendar.tsx
Normal file
40
app/home/(user)/_components/booking/booking-calendar.tsx
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
'use client';
|
||||||
|
|
||||||
|
import { isBefore, isSameDay } from 'date-fns';
|
||||||
|
import { uniq } from 'lodash';
|
||||||
|
|
||||||
|
import { Calendar } from '@kit/ui/shadcn/calendar';
|
||||||
|
import { Card } from '@kit/ui/shadcn/card';
|
||||||
|
import { cn } from '@kit/ui/utils';
|
||||||
|
|
||||||
|
import { useBooking } from './booking.provider';
|
||||||
|
|
||||||
|
export default function BookingCalendar() {
|
||||||
|
const { selectedDate, setSelectedDate, isLoadingTimeSlots, timeSlots } =
|
||||||
|
useBooking();
|
||||||
|
const availableDates = uniq(timeSlots?.map((timeSlot) => timeSlot.StartTime));
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Card className="mb-4">
|
||||||
|
<Calendar
|
||||||
|
mode="single"
|
||||||
|
selected={selectedDate}
|
||||||
|
onSelect={setSelectedDate}
|
||||||
|
disabled={(date) => {
|
||||||
|
const today = new Date();
|
||||||
|
today.setHours(0, 0, 0, 0);
|
||||||
|
return (
|
||||||
|
isBefore(date, today) ||
|
||||||
|
!availableDates.some((dateWithBooking) =>
|
||||||
|
isSameDay(date, dateWithBooking),
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}}
|
||||||
|
className={cn('rounded-md border', {
|
||||||
|
'pointer-events-none rounded-md border opacity-50':
|
||||||
|
isLoadingTimeSlots,
|
||||||
|
})}
|
||||||
|
/>
|
||||||
|
</Card>
|
||||||
|
);
|
||||||
|
}
|
||||||
49
app/home/(user)/_components/booking/booking-container.tsx
Normal file
49
app/home/(user)/_components/booking/booking-container.tsx
Normal file
@@ -0,0 +1,49 @@
|
|||||||
|
'use client';
|
||||||
|
|
||||||
|
import { StoreProduct } from '@medusajs/types';
|
||||||
|
|
||||||
|
import { Trans } from '@kit/ui/trans';
|
||||||
|
|
||||||
|
import { EnrichedCartItem } from '../cart/types';
|
||||||
|
import BookingCalendar from './booking-calendar';
|
||||||
|
import { BookingProvider } from './booking.provider';
|
||||||
|
import LocationSelector from './location-selector';
|
||||||
|
import ServiceSelector from './service-selector';
|
||||||
|
import TimeSlots from './time-slots';
|
||||||
|
|
||||||
|
const BookingContainer = ({
|
||||||
|
category,
|
||||||
|
cartItem,
|
||||||
|
onComplete,
|
||||||
|
}: {
|
||||||
|
category: { products: StoreProduct[]; countryCode: string };
|
||||||
|
cartItem?: EnrichedCartItem;
|
||||||
|
onComplete?: () => void;
|
||||||
|
}) => {
|
||||||
|
const products = cartItem?.product ? [cartItem.product] : category.products;
|
||||||
|
|
||||||
|
if (!cartItem || !products?.length) {
|
||||||
|
<p>
|
||||||
|
<Trans i18nKey="booking:noProducts" />
|
||||||
|
</p>;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<BookingProvider category={{ products }} service={cartItem?.product}>
|
||||||
|
<div className="xs:flex-row flex max-h-full flex-col gap-6">
|
||||||
|
<div className="flex flex-col">
|
||||||
|
<ServiceSelector products={products} />
|
||||||
|
<BookingCalendar />
|
||||||
|
<LocationSelector />
|
||||||
|
</div>
|
||||||
|
<TimeSlots
|
||||||
|
countryCode={category.countryCode}
|
||||||
|
cartItem={cartItem}
|
||||||
|
onComplete={onComplete}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</BookingProvider>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default BookingContainer;
|
||||||
77
app/home/(user)/_components/booking/booking.context.ts
Normal file
77
app/home/(user)/_components/booking/booking.context.ts
Normal file
@@ -0,0 +1,77 @@
|
|||||||
|
import { createContext } from 'react';
|
||||||
|
|
||||||
|
import { StoreProduct } from '@medusajs/types';
|
||||||
|
import { noop } from 'lodash';
|
||||||
|
|
||||||
|
import { Tables } from '@kit/supabase/database';
|
||||||
|
|
||||||
|
export type Location = Tables<
|
||||||
|
{ schema: 'medreport' },
|
||||||
|
'connected_online_locations'
|
||||||
|
>;
|
||||||
|
|
||||||
|
export type TimeSlotResponse = {
|
||||||
|
timeSlots: TimeSlot[];
|
||||||
|
locations: Location[];
|
||||||
|
};
|
||||||
|
|
||||||
|
export type TimeSlot = {
|
||||||
|
ClinicID: number;
|
||||||
|
LocationID: number;
|
||||||
|
UserID: number;
|
||||||
|
SyncUserID: number;
|
||||||
|
ServiceID: number;
|
||||||
|
HKServiceID: number;
|
||||||
|
StartTime: Date;
|
||||||
|
EndTime: Date;
|
||||||
|
PayorCode: string;
|
||||||
|
serviceProvider?: ServiceProvider;
|
||||||
|
syncedService?: SyncedService;
|
||||||
|
} & { location?: Location };
|
||||||
|
|
||||||
|
export type ServiceProvider = {
|
||||||
|
name: string;
|
||||||
|
id: number;
|
||||||
|
jobTitleEn: string | null;
|
||||||
|
jobTitleEt: string | null;
|
||||||
|
jobTitleRu: string | null;
|
||||||
|
clinicId: number;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type SyncedService = Tables<
|
||||||
|
{ schema: 'medreport' },
|
||||||
|
'connected_online_services'
|
||||||
|
> & {
|
||||||
|
providerClinic: ProviderClinic;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type ProviderClinic = Tables<
|
||||||
|
{ schema: 'medreport' },
|
||||||
|
'connected_online_providers'
|
||||||
|
> & { locations: Location[] };
|
||||||
|
|
||||||
|
const BookingContext = createContext<{
|
||||||
|
timeSlots: TimeSlot[] | null;
|
||||||
|
selectedService: StoreProduct | null;
|
||||||
|
locations: Location[] | null;
|
||||||
|
selectedLocationId: number | null;
|
||||||
|
selectedDate?: Date;
|
||||||
|
isLoadingTimeSlots?: boolean;
|
||||||
|
setSelectedService: (selectedService: StoreProduct | null) => void;
|
||||||
|
setSelectedLocationId: (selectedLocationId: number | null) => void;
|
||||||
|
updateTimeSlots: (serviceIds: number[]) => Promise<void>;
|
||||||
|
setSelectedDate: (selectedDate?: Date) => void;
|
||||||
|
}>({
|
||||||
|
timeSlots: null,
|
||||||
|
selectedService: null,
|
||||||
|
locations: null,
|
||||||
|
selectedLocationId: null,
|
||||||
|
selectedDate: new Date(),
|
||||||
|
isLoadingTimeSlots: false,
|
||||||
|
setSelectedService: (_) => _,
|
||||||
|
setSelectedLocationId: (_) => _,
|
||||||
|
updateTimeSlots: async (_) => noop(),
|
||||||
|
setSelectedDate: (_) => _,
|
||||||
|
});
|
||||||
|
|
||||||
|
export { BookingContext };
|
||||||
80
app/home/(user)/_components/booking/booking.provider.tsx
Normal file
80
app/home/(user)/_components/booking/booking.provider.tsx
Normal file
@@ -0,0 +1,80 @@
|
|||||||
|
import React, { useContext, useEffect, useState } from 'react';
|
||||||
|
|
||||||
|
import { StoreProduct } from '@medusajs/types';
|
||||||
|
|
||||||
|
import { getAvailableTimeSlotsForDisplay } from '~/lib/services/connected-online.service';
|
||||||
|
|
||||||
|
import { BookingContext, Location, TimeSlot } from './booking.context';
|
||||||
|
|
||||||
|
export function useBooking() {
|
||||||
|
const context = useContext(BookingContext);
|
||||||
|
|
||||||
|
if (!context) {
|
||||||
|
throw new Error('useBooking must be used within a BookingProvider.');
|
||||||
|
}
|
||||||
|
|
||||||
|
return context;
|
||||||
|
}
|
||||||
|
|
||||||
|
export const BookingProvider: React.FC<{
|
||||||
|
children: React.ReactElement;
|
||||||
|
category: { products: StoreProduct[] };
|
||||||
|
service?: StoreProduct;
|
||||||
|
}> = ({ children, category, service }) => {
|
||||||
|
const [selectedService, setSelectedService] = useState<StoreProduct | null>(
|
||||||
|
(service ?? category?.products?.[0]) || null,
|
||||||
|
);
|
||||||
|
const [selectedLocationId, setSelectedLocationId] = useState<number | null>(
|
||||||
|
null,
|
||||||
|
);
|
||||||
|
const [selectedDate, setSelectedDate] = useState<Date>();
|
||||||
|
const [timeSlots, setTimeSlots] = useState<TimeSlot[] | null>(null);
|
||||||
|
const [locations, setLocations] = useState<Location[] | null>(null);
|
||||||
|
const [isLoadingTimeSlots, setIsLoadingTimeSlots] = useState(false);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
const metadataServiceIds = selectedService?.metadata?.serviceIds as string;
|
||||||
|
if (metadataServiceIds) {
|
||||||
|
const json = JSON.parse(metadataServiceIds);
|
||||||
|
if (Array.isArray(json)) {
|
||||||
|
updateTimeSlots(json);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, [selectedService, selectedLocationId]);
|
||||||
|
|
||||||
|
const updateTimeSlots = async (serviceIds: number[]) => {
|
||||||
|
setIsLoadingTimeSlots(true);
|
||||||
|
try {
|
||||||
|
console.log('serviceIds', serviceIds, selectedLocationId);
|
||||||
|
const response = await getAvailableTimeSlotsForDisplay(
|
||||||
|
serviceIds,
|
||||||
|
selectedLocationId,
|
||||||
|
);
|
||||||
|
setTimeSlots(response.timeSlots);
|
||||||
|
setLocations(response.locations);
|
||||||
|
} catch (error) {
|
||||||
|
setTimeSlots(null);
|
||||||
|
} finally {
|
||||||
|
setIsLoadingTimeSlots(false);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<BookingContext.Provider
|
||||||
|
value={{
|
||||||
|
timeSlots,
|
||||||
|
locations,
|
||||||
|
selectedService,
|
||||||
|
selectedLocationId,
|
||||||
|
setSelectedLocationId,
|
||||||
|
selectedDate,
|
||||||
|
isLoadingTimeSlots,
|
||||||
|
setSelectedService,
|
||||||
|
updateTimeSlots,
|
||||||
|
setSelectedDate,
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{children}
|
||||||
|
</BookingContext.Provider>
|
||||||
|
);
|
||||||
|
};
|
||||||
55
app/home/(user)/_components/booking/location-selector.tsx
Normal file
55
app/home/(user)/_components/booking/location-selector.tsx
Normal file
@@ -0,0 +1,55 @@
|
|||||||
|
import { Label } from '@medusajs/ui';
|
||||||
|
import { useTranslation } from 'react-i18next';
|
||||||
|
|
||||||
|
import { RadioGroup, RadioGroupItem } from '@kit/ui/radio-group';
|
||||||
|
import { Card } from '@kit/ui/shadcn/card';
|
||||||
|
import { Trans } from '@kit/ui/trans';
|
||||||
|
|
||||||
|
import { useBooking } from './booking.provider';
|
||||||
|
|
||||||
|
const LocationSelector = () => {
|
||||||
|
const { t } = useTranslation();
|
||||||
|
const { selectedLocationId, setSelectedLocationId, locations } = useBooking();
|
||||||
|
|
||||||
|
const onLocationSelect = (locationId: number | string | null) => {
|
||||||
|
if (locationId === 'all') return setSelectedLocationId(null);
|
||||||
|
setSelectedLocationId(Number(locationId));
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Card className="mb-4 p-4">
|
||||||
|
<h5 className="text-semibold mb-2">
|
||||||
|
<Trans i18nKey="booking:locations" />
|
||||||
|
</h5>
|
||||||
|
<div className="flex flex-col">
|
||||||
|
<RadioGroup
|
||||||
|
className="mb-2 flex flex-col"
|
||||||
|
onValueChange={(val) => onLocationSelect(val)}
|
||||||
|
>
|
||||||
|
<div className="flex items-center gap-2">
|
||||||
|
<RadioGroupItem
|
||||||
|
value={'all'}
|
||||||
|
id={'all'}
|
||||||
|
checked={selectedLocationId === null}
|
||||||
|
/>
|
||||||
|
<Label htmlFor={'all'}>{t('booking:showAllLocations')}</Label>
|
||||||
|
</div>
|
||||||
|
{locations?.map((location) => (
|
||||||
|
<div key={location.sync_id} className="flex items-center gap-2">
|
||||||
|
<RadioGroupItem
|
||||||
|
value={location.sync_id.toString()}
|
||||||
|
id={location.sync_id.toString()}
|
||||||
|
checked={selectedLocationId === location.sync_id}
|
||||||
|
/>
|
||||||
|
<Label htmlFor={location.sync_id.toString()}>
|
||||||
|
{location.name}
|
||||||
|
</Label>
|
||||||
|
</div>
|
||||||
|
))}
|
||||||
|
</RadioGroup>
|
||||||
|
</div>
|
||||||
|
</Card>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default LocationSelector;
|
||||||
85
app/home/(user)/_components/booking/service-selector.tsx
Normal file
85
app/home/(user)/_components/booking/service-selector.tsx
Normal file
@@ -0,0 +1,85 @@
|
|||||||
|
import { useState } from 'react';
|
||||||
|
|
||||||
|
import { StoreProduct } from '@medusajs/types';
|
||||||
|
import { ChevronDown } from 'lucide-react';
|
||||||
|
|
||||||
|
import { Card } from '@kit/ui/shadcn/card';
|
||||||
|
import { Label } from '@kit/ui/shadcn/label';
|
||||||
|
import {
|
||||||
|
Popover,
|
||||||
|
PopoverContent,
|
||||||
|
PopoverTrigger,
|
||||||
|
} from '@kit/ui/shadcn/popover';
|
||||||
|
import { RadioGroup, RadioGroupItem } from '@kit/ui/shadcn/radio-group';
|
||||||
|
import { Trans } from '@kit/ui/trans';
|
||||||
|
|
||||||
|
import { useBooking } from './booking.provider';
|
||||||
|
|
||||||
|
const ServiceSelector = ({ products }: { products: StoreProduct[] }) => {
|
||||||
|
const { selectedService, setSelectedService } = useBooking();
|
||||||
|
const [collapsed, setCollapsed] = useState(false);
|
||||||
|
const [firstFourProducts] = useState<StoreProduct[]>(products?.slice(0, 4));
|
||||||
|
|
||||||
|
const onServiceSelect = async (productId: StoreProduct['id']) => {
|
||||||
|
const product = products.find((p) => p.id === productId);
|
||||||
|
setSelectedService(product ?? null);
|
||||||
|
setCollapsed(false);
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Card className="mb-4 p-4">
|
||||||
|
<h5 className="text-semibold mb-2">
|
||||||
|
<Trans i18nKey="booking:services" />
|
||||||
|
</h5>
|
||||||
|
<Popover open={collapsed} onOpenChange={setCollapsed}>
|
||||||
|
<div className="flex flex-col">
|
||||||
|
<RadioGroup
|
||||||
|
defaultValue={selectedService?.id || ''}
|
||||||
|
className="mb-2 flex flex-col"
|
||||||
|
onValueChange={onServiceSelect}
|
||||||
|
>
|
||||||
|
{firstFourProducts?.map((product) => (
|
||||||
|
<div key={product.id} className="flex items-center gap-2">
|
||||||
|
<RadioGroupItem
|
||||||
|
value={product.id}
|
||||||
|
id={product.id}
|
||||||
|
checked={selectedService?.id === product.id}
|
||||||
|
/>
|
||||||
|
<Label htmlFor={product.id}>{product.title}</Label>
|
||||||
|
</div>
|
||||||
|
))}
|
||||||
|
</RadioGroup>
|
||||||
|
{products.length > 4 && (
|
||||||
|
<PopoverTrigger asChild>
|
||||||
|
<div
|
||||||
|
onClick={() => setCollapsed((_) => !_)}
|
||||||
|
className="flex cursor-pointer items-center justify-between border-t py-1"
|
||||||
|
>
|
||||||
|
<span>
|
||||||
|
<Trans i18nKey="booking:showAll" />
|
||||||
|
</span>
|
||||||
|
<ChevronDown />
|
||||||
|
</div>
|
||||||
|
</PopoverTrigger>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
<PopoverContent sideOffset={10}>
|
||||||
|
<RadioGroup onValueChange={onServiceSelect}>
|
||||||
|
{products?.map((product) => (
|
||||||
|
<div key={product.id + '-2'} className="flex items-center gap-2">
|
||||||
|
<RadioGroupItem
|
||||||
|
value={product.id}
|
||||||
|
id={product.id + '-2'}
|
||||||
|
checked={selectedService?.id === product.id}
|
||||||
|
/>
|
||||||
|
<Label htmlFor={product.id + '-2'}>{product.title}</Label>
|
||||||
|
</div>
|
||||||
|
))}
|
||||||
|
</RadioGroup>
|
||||||
|
</PopoverContent>
|
||||||
|
</Popover>
|
||||||
|
</Card>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default ServiceSelector;
|
||||||
319
app/home/(user)/_components/booking/time-slots.tsx
Normal file
319
app/home/(user)/_components/booking/time-slots.tsx
Normal file
@@ -0,0 +1,319 @@
|
|||||||
|
import { useMemo, useState } from 'react';
|
||||||
|
|
||||||
|
import { useRouter } from 'next/navigation';
|
||||||
|
|
||||||
|
import { formatCurrency } from '@/packages/shared/src/utils';
|
||||||
|
import { addHours, isAfter, isSameDay } from 'date-fns';
|
||||||
|
import { orderBy } from 'lodash';
|
||||||
|
import { useTranslation } from 'react-i18next';
|
||||||
|
|
||||||
|
import { pathsConfig } from '@kit/shared/config';
|
||||||
|
import { formatDateAndTime } from '@kit/shared/utils';
|
||||||
|
import { Button } from '@kit/ui/shadcn/button';
|
||||||
|
import { Card } from '@kit/ui/shadcn/card';
|
||||||
|
import { toast } from '@kit/ui/sonner';
|
||||||
|
import { Trans } from '@kit/ui/trans';
|
||||||
|
import { cn } from '@kit/ui/utils';
|
||||||
|
|
||||||
|
import { updateReservationTime } from '~/lib/services/reservation.service';
|
||||||
|
|
||||||
|
import { createInitialReservationAction } from '../../_lib/server/actions';
|
||||||
|
import { EnrichedCartItem } from '../cart/types';
|
||||||
|
import { ServiceProvider, TimeSlot } from './booking.context';
|
||||||
|
import { useBooking } from './booking.provider';
|
||||||
|
|
||||||
|
const getServiceProviderTitle = (
|
||||||
|
currentLocale: string,
|
||||||
|
serviceProvider?: ServiceProvider,
|
||||||
|
) => {
|
||||||
|
if (!serviceProvider) return null;
|
||||||
|
if (currentLocale === 'en') return serviceProvider.jobTitleEn;
|
||||||
|
if (currentLocale === 'ru') return serviceProvider.jobTitleRu;
|
||||||
|
|
||||||
|
return serviceProvider.jobTitleEt;
|
||||||
|
};
|
||||||
|
|
||||||
|
const PAGE_SIZE = 7;
|
||||||
|
|
||||||
|
const TimeSlots = ({
|
||||||
|
countryCode,
|
||||||
|
cartItem,
|
||||||
|
onComplete,
|
||||||
|
}: {
|
||||||
|
countryCode: string;
|
||||||
|
cartItem?: EnrichedCartItem;
|
||||||
|
onComplete?: () => void;
|
||||||
|
}) => {
|
||||||
|
const [currentPage, setCurrentPage] = useState(1);
|
||||||
|
|
||||||
|
const {
|
||||||
|
t,
|
||||||
|
i18n: { language: currentLocale },
|
||||||
|
} = useTranslation();
|
||||||
|
|
||||||
|
const booking = useBooking();
|
||||||
|
|
||||||
|
const router = useRouter();
|
||||||
|
|
||||||
|
const selectedDate = booking.selectedDate ?? new Date();
|
||||||
|
|
||||||
|
const filteredBookings = useMemo(
|
||||||
|
() =>
|
||||||
|
orderBy(
|
||||||
|
booking?.timeSlots?.filter(({ StartTime }) => {
|
||||||
|
const firstAvailableTimeToSelect = isSameDay(selectedDate, new Date())
|
||||||
|
? addHours(new Date(), 0.5)
|
||||||
|
: selectedDate;
|
||||||
|
return isAfter(StartTime, firstAvailableTimeToSelect);
|
||||||
|
}) ?? [],
|
||||||
|
'StartTime',
|
||||||
|
'asc',
|
||||||
|
),
|
||||||
|
[booking.timeSlots, selectedDate],
|
||||||
|
);
|
||||||
|
|
||||||
|
const totalPages = Math.ceil(filteredBookings.length / PAGE_SIZE);
|
||||||
|
|
||||||
|
const paginatedBookings = useMemo(() => {
|
||||||
|
const startIndex = (currentPage - 1) * PAGE_SIZE;
|
||||||
|
const endIndex = startIndex + PAGE_SIZE;
|
||||||
|
return filteredBookings.slice(startIndex, endIndex);
|
||||||
|
}, [filteredBookings, currentPage, PAGE_SIZE]);
|
||||||
|
|
||||||
|
const handlePageChange = (page: number) => {
|
||||||
|
setCurrentPage(page);
|
||||||
|
};
|
||||||
|
|
||||||
|
const generatePageNumbers = () => {
|
||||||
|
const pages = [];
|
||||||
|
const maxVisiblePages = 5;
|
||||||
|
|
||||||
|
if (totalPages <= maxVisiblePages) {
|
||||||
|
for (let i = 1; i <= totalPages; i++) {
|
||||||
|
pages.push(i);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (currentPage <= 3) {
|
||||||
|
for (let i = 1; i <= 4; i++) {
|
||||||
|
pages.push(i);
|
||||||
|
}
|
||||||
|
pages.push('...');
|
||||||
|
pages.push(totalPages);
|
||||||
|
} else if (currentPage >= totalPages - 2) {
|
||||||
|
pages.push(1);
|
||||||
|
pages.push('...');
|
||||||
|
for (let i = totalPages - 3; i <= totalPages; i++) {
|
||||||
|
pages.push(i);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
pages.push(1);
|
||||||
|
pages.push('...');
|
||||||
|
for (let i = currentPage - 1; i <= currentPage + 1; i++) {
|
||||||
|
pages.push(i);
|
||||||
|
}
|
||||||
|
pages.push('...');
|
||||||
|
pages.push(totalPages);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return pages;
|
||||||
|
};
|
||||||
|
|
||||||
|
if (!booking?.timeSlots?.length) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
const handleBookTime = async (timeSlot: TimeSlot, comments?: string) => {
|
||||||
|
const selectedService = booking.selectedService;
|
||||||
|
|
||||||
|
const selectedVariant = selectedService?.variants?.[0];
|
||||||
|
|
||||||
|
const syncedService = timeSlot.syncedService;
|
||||||
|
if (!syncedService || !selectedVariant) {
|
||||||
|
return toast.error(t('booking:serviceNotFound'));
|
||||||
|
}
|
||||||
|
|
||||||
|
const bookTimePromise = createInitialReservationAction(
|
||||||
|
selectedVariant,
|
||||||
|
countryCode,
|
||||||
|
Number(syncedService.id),
|
||||||
|
syncedService?.clinic_id,
|
||||||
|
timeSlot.UserID,
|
||||||
|
timeSlot.SyncUserID,
|
||||||
|
timeSlot.StartTime,
|
||||||
|
booking.selectedLocationId ? booking.selectedLocationId : null,
|
||||||
|
comments,
|
||||||
|
).then(() => {
|
||||||
|
if (onComplete) {
|
||||||
|
onComplete();
|
||||||
|
}
|
||||||
|
router.push(pathsConfig.app.cart);
|
||||||
|
});
|
||||||
|
|
||||||
|
toast.promise(() => bookTimePromise, {
|
||||||
|
success: <Trans i18nKey={'booking:bookTimeSuccess'} />,
|
||||||
|
error: <Trans i18nKey={'booking:bookTimeError'} />,
|
||||||
|
loading: <Trans i18nKey={'booking:bookTimeLoading'} />,
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleChangeTime = async (
|
||||||
|
timeSlot: TimeSlot,
|
||||||
|
reservationId: number,
|
||||||
|
cartId: string,
|
||||||
|
) => {
|
||||||
|
const syncedService = timeSlot.syncedService;
|
||||||
|
if (!syncedService) {
|
||||||
|
return toast.error(t('booking:serviceNotFound'));
|
||||||
|
}
|
||||||
|
|
||||||
|
const bookTimePromise = updateReservationTime({
|
||||||
|
reservationId,
|
||||||
|
newStartTime: timeSlot.StartTime,
|
||||||
|
newServiceId: Number(syncedService.id),
|
||||||
|
newAppointmentUserId: timeSlot.UserID,
|
||||||
|
newSyncUserId: timeSlot.SyncUserID,
|
||||||
|
newLocationId: booking.selectedLocationId
|
||||||
|
? booking.selectedLocationId
|
||||||
|
: null,
|
||||||
|
cartId,
|
||||||
|
});
|
||||||
|
|
||||||
|
toast.promise(() => bookTimePromise, {
|
||||||
|
success: <Trans i18nKey={'booking:bookTimeSuccess'} />,
|
||||||
|
error: <Trans i18nKey={'booking:bookTimeError'} />,
|
||||||
|
loading: <Trans i18nKey={'booking:bookTimeLoading'} />,
|
||||||
|
});
|
||||||
|
|
||||||
|
if (onComplete) {
|
||||||
|
onComplete();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleTimeSelect = async (timeSlot: TimeSlot) => {
|
||||||
|
if (cartItem?.reservation.id) {
|
||||||
|
return handleChangeTime(
|
||||||
|
timeSlot,
|
||||||
|
cartItem.reservation.id,
|
||||||
|
cartItem.cart_id,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return handleBookTime(timeSlot);
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="flex w-full flex-col gap-4">
|
||||||
|
<div className="flex h-full w-full flex-col gap-2 overflow-auto">
|
||||||
|
{paginatedBookings.map((timeSlot, index) => {
|
||||||
|
const isEHIF = timeSlot.HKServiceID > 0;
|
||||||
|
const serviceProviderTitle = getServiceProviderTitle(
|
||||||
|
currentLocale,
|
||||||
|
timeSlot.serviceProvider,
|
||||||
|
);
|
||||||
|
const price =
|
||||||
|
booking.selectedService?.variants?.[0]?.calculated_price
|
||||||
|
?.calculated_amount ?? cartItem?.unit_price;
|
||||||
|
return (
|
||||||
|
<Card
|
||||||
|
className="xs:flex xs:justify-between grid w-full justify-center-safe gap-3 p-4"
|
||||||
|
key={index}
|
||||||
|
>
|
||||||
|
<div>
|
||||||
|
<span>{formatDateAndTime(timeSlot.StartTime.toString())}</span>
|
||||||
|
<div className="flex">
|
||||||
|
<h5
|
||||||
|
className={cn(
|
||||||
|
(serviceProviderTitle || isEHIF) &&
|
||||||
|
"after:mx-2 after:content-['·']",
|
||||||
|
)}
|
||||||
|
>
|
||||||
|
{timeSlot.serviceProvider?.name}
|
||||||
|
</h5>
|
||||||
|
{serviceProviderTitle && (
|
||||||
|
<span
|
||||||
|
className={cn(isEHIF && "after:mx-2 after:content-['·']")}
|
||||||
|
>
|
||||||
|
{serviceProviderTitle}
|
||||||
|
</span>
|
||||||
|
)}
|
||||||
|
{isEHIF && <span>{t('booking:ehifBooking')}</span>}
|
||||||
|
</div>
|
||||||
|
<div className="flex text-xs">{timeSlot.location?.address}</div>
|
||||||
|
</div>
|
||||||
|
<div className="flex-end not-last:xs:justify-center flex items-center justify-between gap-2">
|
||||||
|
<span className="text-sm font-semibold">
|
||||||
|
{formatCurrency({
|
||||||
|
currencyCode: 'EUR',
|
||||||
|
locale: 'et-EE',
|
||||||
|
value: price ?? '',
|
||||||
|
})}
|
||||||
|
</span>
|
||||||
|
<Button onClick={() => handleTimeSelect(timeSlot)} size="sm">
|
||||||
|
<Trans i18nKey="common:book" />
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
</Card>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
|
||||||
|
{!paginatedBookings.length && (
|
||||||
|
<div className="wrap text-muted-foreground flex size-full content-center-safe justify-center-safe">
|
||||||
|
<p>{t('booking:noResults')}</p>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{totalPages > 1 && (
|
||||||
|
<div className="flex items-center justify-between">
|
||||||
|
<div className="text-muted-foreground text-sm">
|
||||||
|
{t('common:pageOfPages', {
|
||||||
|
page: currentPage,
|
||||||
|
total: totalPages,
|
||||||
|
})}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="flex items-center gap-1">
|
||||||
|
<Button
|
||||||
|
variant="outline"
|
||||||
|
size="sm"
|
||||||
|
onClick={() => handlePageChange(currentPage - 1)}
|
||||||
|
disabled={currentPage === 1}
|
||||||
|
>
|
||||||
|
<Trans i18nKey="common:previous" defaultValue="Previous" />
|
||||||
|
</Button>
|
||||||
|
|
||||||
|
{generatePageNumbers().map((page, index) => (
|
||||||
|
<Button
|
||||||
|
key={index}
|
||||||
|
variant={page === currentPage ? 'default' : 'outline'}
|
||||||
|
size="sm"
|
||||||
|
onClick={() =>
|
||||||
|
typeof page === 'number' && handlePageChange(page)
|
||||||
|
}
|
||||||
|
disabled={page === '...'}
|
||||||
|
className={cn(
|
||||||
|
'min-w-[2rem]',
|
||||||
|
page === '...' && 'cursor-default hover:bg-transparent',
|
||||||
|
)}
|
||||||
|
>
|
||||||
|
{page}
|
||||||
|
</Button>
|
||||||
|
))}
|
||||||
|
|
||||||
|
<Button
|
||||||
|
variant="outline"
|
||||||
|
size="sm"
|
||||||
|
onClick={() => handlePageChange(currentPage + 1)}
|
||||||
|
disabled={currentPage === totalPages}
|
||||||
|
>
|
||||||
|
<Trans i18nKey="common:next" defaultValue="Next" />
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default TimeSlots;
|
||||||
146
app/home/(user)/_components/cart/cart-service-item.tsx
Normal file
146
app/home/(user)/_components/cart/cart-service-item.tsx
Normal file
@@ -0,0 +1,146 @@
|
|||||||
|
'use client';
|
||||||
|
|
||||||
|
import { useState } from 'react';
|
||||||
|
|
||||||
|
import { formatCurrency, formatDateAndTime } from '@/packages/shared/src/utils';
|
||||||
|
import { useTranslation } from 'react-i18next';
|
||||||
|
|
||||||
|
import { Button } from '@kit/ui/button';
|
||||||
|
import {
|
||||||
|
Dialog,
|
||||||
|
DialogContent,
|
||||||
|
DialogDescription,
|
||||||
|
DialogHeader,
|
||||||
|
DialogTitle,
|
||||||
|
} from '@kit/ui/dialog';
|
||||||
|
import { TableCell, TableRow } from '@kit/ui/table';
|
||||||
|
import { Trans } from '@kit/ui/trans';
|
||||||
|
|
||||||
|
import BookingContainer from '../booking/booking-container';
|
||||||
|
import CartItemDelete from './cart-item-delete';
|
||||||
|
import { EnrichedCartItem } from './types';
|
||||||
|
|
||||||
|
const EditCartServiceItemModal = ({
|
||||||
|
item,
|
||||||
|
onComplete,
|
||||||
|
}: {
|
||||||
|
item: EnrichedCartItem | null;
|
||||||
|
onComplete: () => void;
|
||||||
|
}) => {
|
||||||
|
if (!item) return null;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Dialog defaultOpen>
|
||||||
|
<DialogContent className="xs:max-w-[90vw] flex max-h-screen max-w-full flex-col items-center gap-4 space-y-4 overflow-y-scroll">
|
||||||
|
<DialogHeader className="items-center text-center">
|
||||||
|
<DialogTitle>
|
||||||
|
<Trans i18nKey="cart:editServiceItem.title" />
|
||||||
|
</DialogTitle>
|
||||||
|
<DialogDescription>
|
||||||
|
<Trans i18nKey="cart:editServiceItem.description" />
|
||||||
|
</DialogDescription>
|
||||||
|
</DialogHeader>
|
||||||
|
<div>
|
||||||
|
{item.product && item.reservation.countryCode ? (
|
||||||
|
<BookingContainer
|
||||||
|
category={{
|
||||||
|
products: [item.product],
|
||||||
|
countryCode: item.reservation.countryCode,
|
||||||
|
}}
|
||||||
|
cartItem={item}
|
||||||
|
onComplete={onComplete}
|
||||||
|
/>
|
||||||
|
) : (
|
||||||
|
<p>
|
||||||
|
<Trans i18nKey="booking:noProducts" />
|
||||||
|
</p>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</DialogContent>
|
||||||
|
</Dialog>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default function CartServiceItem({
|
||||||
|
item,
|
||||||
|
currencyCode,
|
||||||
|
isUnavailable,
|
||||||
|
}: {
|
||||||
|
item: EnrichedCartItem;
|
||||||
|
currencyCode: string;
|
||||||
|
isUnavailable?: boolean;
|
||||||
|
}) {
|
||||||
|
const [editingItem, setEditingItem] = useState<EnrichedCartItem | null>(null);
|
||||||
|
const {
|
||||||
|
i18n: { language },
|
||||||
|
} = useTranslation();
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<TableRow className="w-full" data-testid="product-row">
|
||||||
|
<TableCell className="w-[100%] px-4 text-left sm:px-6">
|
||||||
|
<p
|
||||||
|
className="txt-medium-plus text-ui-fg-base"
|
||||||
|
data-testid="product-title"
|
||||||
|
>
|
||||||
|
{item.product_title}
|
||||||
|
</p>
|
||||||
|
</TableCell>
|
||||||
|
|
||||||
|
<TableCell className="px-4 sm:px-6">
|
||||||
|
{formatDateAndTime(item.reservation.startTime.toString())}
|
||||||
|
</TableCell>
|
||||||
|
|
||||||
|
<TableCell className="px-4 sm:px-6">
|
||||||
|
{item.reservation.location?.address ?? '-'}
|
||||||
|
</TableCell>
|
||||||
|
|
||||||
|
<TableCell className="px-4 sm:px-6">{item.quantity}</TableCell>
|
||||||
|
|
||||||
|
<TableCell className="min-w-[80px] px-4 sm:px-6">
|
||||||
|
{formatCurrency({
|
||||||
|
value: item.unit_price,
|
||||||
|
currencyCode,
|
||||||
|
locale: language,
|
||||||
|
})}
|
||||||
|
</TableCell>
|
||||||
|
|
||||||
|
<TableCell className="min-w-[80px] px-4 text-right sm:px-6">
|
||||||
|
{formatCurrency({
|
||||||
|
value: item.total,
|
||||||
|
currencyCode,
|
||||||
|
locale: language,
|
||||||
|
})}
|
||||||
|
</TableCell>
|
||||||
|
|
||||||
|
<TableCell className="px-4 text-right sm:px-6">
|
||||||
|
<span className="flex justify-end gap-x-1">
|
||||||
|
<Button size="sm" onClick={() => setEditingItem(item)}>
|
||||||
|
<Trans i18nKey="common:change" />
|
||||||
|
</Button>
|
||||||
|
</span>
|
||||||
|
</TableCell>
|
||||||
|
|
||||||
|
<TableCell className="px-4 text-right sm:px-6">
|
||||||
|
<span className="flex w-[60px] justify-end gap-x-1">
|
||||||
|
<CartItemDelete id={item.id} />
|
||||||
|
</span>
|
||||||
|
</TableCell>
|
||||||
|
</TableRow>
|
||||||
|
{isUnavailable && (
|
||||||
|
<TableRow>
|
||||||
|
<TableCell
|
||||||
|
colSpan={8}
|
||||||
|
className="text-destructive px-4 text-left sm:px-6"
|
||||||
|
>
|
||||||
|
<Trans i18nKey="booking:timeSlotUnavailable" />
|
||||||
|
</TableCell>
|
||||||
|
</TableRow>
|
||||||
|
)}
|
||||||
|
<EditCartServiceItemModal
|
||||||
|
item={editingItem}
|
||||||
|
onComplete={() => setEditingItem(null)}
|
||||||
|
/>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
||||||
72
app/home/(user)/_components/cart/cart-service-items.tsx
Normal file
72
app/home/(user)/_components/cart/cart-service-items.tsx
Normal file
@@ -0,0 +1,72 @@
|
|||||||
|
import { StoreCart } from '@medusajs/types';
|
||||||
|
|
||||||
|
import {
|
||||||
|
Table,
|
||||||
|
TableBody,
|
||||||
|
TableHead,
|
||||||
|
TableHeader,
|
||||||
|
TableRow,
|
||||||
|
} from '@kit/ui/table';
|
||||||
|
import { Trans } from '@kit/ui/trans';
|
||||||
|
|
||||||
|
import CartServiceItem from './cart-service-item';
|
||||||
|
import { EnrichedCartItem } from './types';
|
||||||
|
|
||||||
|
export default function CartServiceItems({
|
||||||
|
cart,
|
||||||
|
items,
|
||||||
|
productColumnLabelKey,
|
||||||
|
unavailableLineItemIds,
|
||||||
|
}: {
|
||||||
|
cart: StoreCart;
|
||||||
|
items: EnrichedCartItem[];
|
||||||
|
productColumnLabelKey: string;
|
||||||
|
unavailableLineItemIds?: string[];
|
||||||
|
}) {
|
||||||
|
if (!items || items.length === 0) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Table className="border-separate rounded-lg border">
|
||||||
|
<TableHeader className="text-ui-fg-subtle txt-medium-plus">
|
||||||
|
<TableRow>
|
||||||
|
<TableHead className="px-4 sm:px-6">
|
||||||
|
<Trans i18nKey={productColumnLabelKey} />
|
||||||
|
</TableHead>
|
||||||
|
<TableHead className="px-4 sm:px-6">
|
||||||
|
<Trans i18nKey="cart:table.time" />
|
||||||
|
</TableHead>
|
||||||
|
<TableHead className="px-4 sm:px-6">
|
||||||
|
<Trans i18nKey="cart:table.location" />
|
||||||
|
</TableHead>
|
||||||
|
<TableHead className="px-4 sm:px-6">
|
||||||
|
<Trans i18nKey="cart:table.quantity" />
|
||||||
|
</TableHead>
|
||||||
|
<TableHead className="min-w-[100px] px-4 sm:px-6">
|
||||||
|
<Trans i18nKey="cart:table.price" />
|
||||||
|
</TableHead>
|
||||||
|
<TableHead className="min-w-[100px] px-4 text-right sm:px-6">
|
||||||
|
<Trans i18nKey="cart:table.total" />
|
||||||
|
</TableHead>
|
||||||
|
<TableHead className="px-4 sm:px-6"></TableHead>
|
||||||
|
<TableHead className="px-4 sm:px-6"></TableHead>
|
||||||
|
</TableRow>
|
||||||
|
</TableHeader>
|
||||||
|
<TableBody>
|
||||||
|
{items
|
||||||
|
.sort((a, b) =>
|
||||||
|
(a.created_at ?? '') > (b.created_at ?? '') ? -1 : 1,
|
||||||
|
)
|
||||||
|
.map((item) => (
|
||||||
|
<CartServiceItem
|
||||||
|
key={item.id}
|
||||||
|
item={item}
|
||||||
|
currencyCode={cart.currency_code}
|
||||||
|
isUnavailable={unavailableLineItemIds?.includes(item.id)}
|
||||||
|
/>
|
||||||
|
))}
|
||||||
|
</TableBody>
|
||||||
|
</Table>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -13,10 +13,12 @@ import { Trans } from '@kit/ui/trans';
|
|||||||
|
|
||||||
import AnalysisLocation from './analysis-location';
|
import AnalysisLocation from './analysis-location';
|
||||||
import CartItems from './cart-items';
|
import CartItems from './cart-items';
|
||||||
|
import CartServiceItems from './cart-service-items';
|
||||||
import DiscountCode from './discount-code';
|
import DiscountCode from './discount-code';
|
||||||
import { initiatePayment } from '../../_lib/server/cart-actions';
|
import { initiatePayment } from '../../_lib/server/cart-actions';
|
||||||
import { useRouter } from 'next/navigation';
|
import { useRouter } from 'next/navigation';
|
||||||
import { AccountBalanceSummary } from '@kit/accounts/services/account-balance.service';
|
import { AccountBalanceSummary } from '@kit/accounts/services/account-balance.service';
|
||||||
|
import { EnrichedCartItem } from './types';
|
||||||
|
|
||||||
const IS_DISCOUNT_SHOWN = true as boolean;
|
const IS_DISCOUNT_SHOWN = true as boolean;
|
||||||
|
|
||||||
@@ -30,7 +32,7 @@ export default function Cart({
|
|||||||
accountId: string;
|
accountId: string;
|
||||||
cart: StoreCart | null;
|
cart: StoreCart | null;
|
||||||
synlabAnalyses: StoreCartLineItem[];
|
synlabAnalyses: StoreCartLineItem[];
|
||||||
ttoServiceItems: StoreCartLineItem[];
|
ttoServiceItems: EnrichedCartItem[];
|
||||||
balanceSummary: AccountBalanceSummary | null;
|
balanceSummary: AccountBalanceSummary | null;
|
||||||
}) {
|
}) {
|
||||||
const {
|
const {
|
||||||
@@ -39,6 +41,9 @@ export default function Cart({
|
|||||||
|
|
||||||
const [isInitiatingSession, setIsInitiatingSession] = useState(false);
|
const [isInitiatingSession, setIsInitiatingSession] = useState(false);
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
|
const [unavailableLineItemIds, setUnavailableLineItemIds] =
|
||||||
|
useState<string[]>();
|
||||||
|
|
||||||
const items = cart?.items ?? [];
|
const items = cart?.items ?? [];
|
||||||
const hasCartItems = cart && Array.isArray(items) && items.length > 0;
|
const hasCartItems = cart && Array.isArray(items) && items.length > 0;
|
||||||
|
|
||||||
@@ -66,12 +71,15 @@ export default function Cart({
|
|||||||
setIsInitiatingSession(true);
|
setIsInitiatingSession(true);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const { url, isFullyPaidByBenefits, orderId } = await initiatePayment({
|
const { url, isFullyPaidByBenefits, orderId, unavailableLineItemIds } = await initiatePayment({
|
||||||
accountId,
|
accountId,
|
||||||
balanceSummary: balanceSummary!,
|
balanceSummary: balanceSummary!,
|
||||||
cart: cart!,
|
cart: cart!,
|
||||||
language,
|
language,
|
||||||
});
|
});
|
||||||
|
if (unavailableLineItemIds) {
|
||||||
|
setUnavailableLineItemIds(unavailableLineItemIds);
|
||||||
|
}
|
||||||
if (url) {
|
if (url) {
|
||||||
window.location.href = url;
|
window.location.href = url;
|
||||||
} else if (isFullyPaidByBenefits) {
|
} else if (isFullyPaidByBenefits) {
|
||||||
@@ -99,10 +107,11 @@ export default function Cart({
|
|||||||
items={synlabAnalyses}
|
items={synlabAnalyses}
|
||||||
productColumnLabelKey="cart:items.synlabAnalyses.productColumnLabel"
|
productColumnLabelKey="cart:items.synlabAnalyses.productColumnLabel"
|
||||||
/>
|
/>
|
||||||
<CartItems
|
<CartServiceItems
|
||||||
cart={cart}
|
cart={cart}
|
||||||
items={ttoServiceItems}
|
items={ttoServiceItems}
|
||||||
productColumnLabelKey="cart:items.ttoServices.productColumnLabel"
|
productColumnLabelKey="cart:items.ttoServices.productColumnLabel"
|
||||||
|
unavailableLineItemIds={unavailableLineItemIds}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
{hasCartItems && (
|
{hasCartItems && (
|
||||||
|
|||||||
@@ -1,3 +1,6 @@
|
|||||||
|
import { StoreCartLineItem } from "@medusajs/types";
|
||||||
|
import { Reservation } from "~/lib/types/reservation";
|
||||||
|
|
||||||
export interface MontonioOrderToken {
|
export interface MontonioOrderToken {
|
||||||
uuid: string;
|
uuid: string;
|
||||||
accessKey: string;
|
accessKey: string;
|
||||||
@@ -10,6 +13,12 @@ export interface MontonioOrderToken {
|
|||||||
| 'PENDING'
|
| 'PENDING'
|
||||||
| 'EXPIRED'
|
| 'EXPIRED'
|
||||||
| 'REFUNDED';
|
| 'REFUNDED';
|
||||||
|
| 'PAID'
|
||||||
|
| 'FAILED'
|
||||||
|
| 'CANCELLED'
|
||||||
|
| 'PENDING'
|
||||||
|
| 'EXPIRED'
|
||||||
|
| 'REFUNDED';
|
||||||
paymentMethod: string;
|
paymentMethod: string;
|
||||||
grandTotal: number;
|
grandTotal: number;
|
||||||
currency: string;
|
currency: string;
|
||||||
@@ -20,3 +29,10 @@ export interface MontonioOrderToken {
|
|||||||
iat: number;
|
iat: number;
|
||||||
exp: number;
|
exp: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export enum CartItemType {
|
||||||
|
analysisOrders = 'analysisOrders',
|
||||||
|
ttoServices = 'ttoServices',
|
||||||
|
}
|
||||||
|
|
||||||
|
export type EnrichedCartItem = StoreCartLineItem & { reservation: Reservation };
|
||||||
|
|||||||
@@ -103,7 +103,6 @@ export default function OrderAnalysesCards({
|
|||||||
{title}
|
{title}
|
||||||
{description && (
|
{description && (
|
||||||
<>
|
<>
|
||||||
{' '}
|
|
||||||
<InfoTooltip
|
<InfoTooltip
|
||||||
content={
|
content={
|
||||||
<div className="flex flex-col gap-2">
|
<div className="flex flex-col gap-2">
|
||||||
|
|||||||
@@ -2,16 +2,18 @@ import { formatDate } from 'date-fns';
|
|||||||
|
|
||||||
import { Trans } from '@kit/ui/trans';
|
import { Trans } from '@kit/ui/trans';
|
||||||
|
|
||||||
import type { AnalysisOrder } from '~/lib/types/analysis-order';
|
export default function OrderDetails({
|
||||||
|
order,
|
||||||
export default function OrderDetails({ order }: { order: AnalysisOrder }) {
|
}: {
|
||||||
|
order: { id: string; created_at: string | Date };
|
||||||
|
}) {
|
||||||
return (
|
return (
|
||||||
<div className="flex flex-col gap-y-2">
|
<div className="flex flex-col gap-y-2">
|
||||||
<div>
|
<div>
|
||||||
<span className="font-bold">
|
<span className="font-bold">
|
||||||
<Trans i18nKey="cart:orderConfirmed.orderNumber" />:{' '}
|
<Trans i18nKey="cart:orderConfirmed.orderNumber" />:{' '}
|
||||||
</span>
|
</span>
|
||||||
<span className="break-all">{order.medusa_order_id}</span>
|
<span className="break-all">{order.id}</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
|
|||||||
@@ -5,51 +5,77 @@ import { Eye } from 'lucide-react';
|
|||||||
|
|
||||||
import { Trans } from '@kit/ui/makerkit/trans';
|
import { Trans } from '@kit/ui/makerkit/trans';
|
||||||
|
|
||||||
import type { AnalysisOrder } from '~/lib/types/analysis-order';
|
import type { AnalysisOrder } from '~/lib/types/order';
|
||||||
|
|
||||||
import OrderItemsTable from './order-items-table';
|
import OrderItemsTable from './order-items-table';
|
||||||
|
|
||||||
export default function OrderBlock({
|
export default function OrderBlock({
|
||||||
analysisOrder,
|
analysisOrder,
|
||||||
|
medusaOrderStatus,
|
||||||
itemsAnalysisPackage,
|
itemsAnalysisPackage,
|
||||||
|
itemsTtoService,
|
||||||
itemsOther,
|
itemsOther,
|
||||||
|
medusaOrderId,
|
||||||
}: {
|
}: {
|
||||||
analysisOrder: AnalysisOrder;
|
analysisOrder?: AnalysisOrder;
|
||||||
|
medusaOrderStatus: string;
|
||||||
itemsAnalysisPackage: StoreOrderLineItem[];
|
itemsAnalysisPackage: StoreOrderLineItem[];
|
||||||
|
itemsTtoService: StoreOrderLineItem[];
|
||||||
itemsOther: StoreOrderLineItem[];
|
itemsOther: StoreOrderLineItem[];
|
||||||
|
medusaOrderId: string;
|
||||||
}) {
|
}) {
|
||||||
return (
|
return (
|
||||||
<div className="flex flex-col gap-4">
|
<div className="flex flex-col gap-4">
|
||||||
<h4>
|
<h4>
|
||||||
<Trans
|
<Trans
|
||||||
i18nKey="analysis-results:orderTitle"
|
i18nKey="analysis-results:orderTitle"
|
||||||
values={{ orderNumber: analysisOrder.medusa_order_id }}
|
values={{ orderNumber: medusaOrderId }}
|
||||||
/>
|
/>
|
||||||
{` (${analysisOrder.id})`}
|
|
||||||
</h4>
|
</h4>
|
||||||
<div className="flex gap-2">
|
{analysisOrder && (
|
||||||
<h5>
|
<div className="flex gap-2">
|
||||||
<Trans i18nKey={`orders:status.${analysisOrder.status}`} />
|
<h5>
|
||||||
</h5>
|
<Trans i18nKey={`orders:status.${analysisOrder.status}`} />
|
||||||
<Link
|
</h5>
|
||||||
href={`/home/order/${analysisOrder.id}`}
|
<Link
|
||||||
className="text-small-regular flex items-center justify-between"
|
href={`/home/order/${analysisOrder.id}`}
|
||||||
>
|
className="text-small-regular flex items-center justify-between"
|
||||||
<button className="text-ui-fg-subtle hover:text-ui-fg-base flex cursor-pointer gap-x-1">
|
>
|
||||||
<Eye />
|
<button className="text-ui-fg-subtle hover:text-ui-fg-base flex cursor-pointer gap-x-1">
|
||||||
</button>
|
<Eye />
|
||||||
</Link>
|
</button>
|
||||||
</div>
|
</Link>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
<div className="flex flex-col gap-4">
|
<div className="flex flex-col gap-4">
|
||||||
<OrderItemsTable
|
{analysisOrder && (
|
||||||
items={itemsAnalysisPackage}
|
<OrderItemsTable
|
||||||
title="orders:table.analysisPackage"
|
items={itemsAnalysisPackage}
|
||||||
analysisOrder={analysisOrder}
|
title="orders:table.analysisPackage"
|
||||||
/>
|
order={{
|
||||||
|
medusaOrderId: analysisOrder.medusa_order_id,
|
||||||
|
id: analysisOrder.id,
|
||||||
|
status: analysisOrder.status,
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
{itemsTtoService && (
|
||||||
|
<OrderItemsTable
|
||||||
|
items={itemsTtoService}
|
||||||
|
title="orders:table.ttoService"
|
||||||
|
type="ttoService"
|
||||||
|
order={{
|
||||||
|
status: medusaOrderStatus.toUpperCase(),
|
||||||
|
medusaOrderId,
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
<OrderItemsTable
|
<OrderItemsTable
|
||||||
items={itemsOther}
|
items={itemsOther}
|
||||||
title="orders:table.otherOrders"
|
title="orders:table.otherOrders"
|
||||||
analysisOrder={analysisOrder}
|
order={{
|
||||||
|
status: analysisOrder?.status,
|
||||||
|
}}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ import { useRouter } from 'next/navigation';
|
|||||||
|
|
||||||
import { StoreOrderLineItem } from '@medusajs/types';
|
import { StoreOrderLineItem } from '@medusajs/types';
|
||||||
import { formatDate } from 'date-fns';
|
import { formatDate } from 'date-fns';
|
||||||
import { Eye } from 'lucide-react';
|
|
||||||
|
|
||||||
import { pathsConfig } from '@kit/shared/config';
|
import { pathsConfig } from '@kit/shared/config';
|
||||||
import { Button } from '@kit/ui/button';
|
import { Button } from '@kit/ui/button';
|
||||||
@@ -18,18 +17,22 @@ import {
|
|||||||
} from '@kit/ui/table';
|
} from '@kit/ui/table';
|
||||||
import { Trans } from '@kit/ui/trans';
|
import { Trans } from '@kit/ui/trans';
|
||||||
|
|
||||||
import type { AnalysisOrder } from '~/lib/types/analysis-order';
|
import type { Order } from '~/lib/types/order';
|
||||||
|
|
||||||
import { logAnalysisResultsNavigateAction } from './actions';
|
import { logAnalysisResultsNavigateAction } from './actions';
|
||||||
|
|
||||||
|
export type OrderItemType = 'analysisOrder' | 'ttoService';
|
||||||
|
|
||||||
export default function OrderItemsTable({
|
export default function OrderItemsTable({
|
||||||
items,
|
items,
|
||||||
title,
|
title,
|
||||||
analysisOrder,
|
order,
|
||||||
|
type = 'analysisOrder',
|
||||||
}: {
|
}: {
|
||||||
items: StoreOrderLineItem[];
|
items: StoreOrderLineItem[];
|
||||||
title: string;
|
title: string;
|
||||||
analysisOrder: AnalysisOrder;
|
order: Order;
|
||||||
|
type?: OrderItemType;
|
||||||
}) {
|
}) {
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
|
|
||||||
@@ -37,9 +40,15 @@ export default function OrderItemsTable({
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
const openAnalysisResults = async () => {
|
const isAnalysisOrder = type === 'analysisOrder';
|
||||||
await logAnalysisResultsNavigateAction(analysisOrder.medusa_order_id);
|
|
||||||
router.push(`${pathsConfig.app.analysisResults}/${analysisOrder.id}`);
|
const openDetailedView = async () => {
|
||||||
|
if (isAnalysisOrder && order?.medusaOrderId && order?.id) {
|
||||||
|
await logAnalysisResultsNavigateAction(order.medusaOrderId);
|
||||||
|
router.push(`${pathsConfig.app.analysisResults}/${order.id}`);
|
||||||
|
} else {
|
||||||
|
router.push(`${pathsConfig.app.myOrders}/${order.medusaOrderId}`);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -55,7 +64,7 @@ export default function OrderItemsTable({
|
|||||||
<TableHead className="px-6">
|
<TableHead className="px-6">
|
||||||
<Trans i18nKey="orders:table.status" />
|
<Trans i18nKey="orders:table.status" />
|
||||||
</TableHead>
|
</TableHead>
|
||||||
<TableHead className="px-6"></TableHead>
|
{isAnalysisOrder && <TableHead className="px-6"></TableHead>}
|
||||||
</TableRow>
|
</TableRow>
|
||||||
</TableHeader>
|
</TableHeader>
|
||||||
<TableBody>
|
<TableBody>
|
||||||
@@ -76,11 +85,13 @@ export default function OrderItemsTable({
|
|||||||
</TableCell>
|
</TableCell>
|
||||||
|
|
||||||
<TableCell className="min-w-[180px] px-6">
|
<TableCell className="min-w-[180px] px-6">
|
||||||
<Trans i18nKey={`orders:status.${analysisOrder.status}`} />
|
<Trans
|
||||||
|
i18nKey={`orders:status.${type}.${order?.status ?? 'CONFIRMED'}`}
|
||||||
|
/>
|
||||||
</TableCell>
|
</TableCell>
|
||||||
|
|
||||||
<TableCell className="px-6 text-right">
|
<TableCell className="px-6 text-right">
|
||||||
<Button size="sm" onClick={openAnalysisResults}>
|
<Button size="sm" onClick={openDetailedView}>
|
||||||
<Trans i18nKey="analysis-results:view" />
|
<Trans i18nKey="analysis-results:view" />
|
||||||
</Button>
|
</Button>
|
||||||
</TableCell>
|
</TableCell>
|
||||||
|
|||||||
@@ -4,17 +4,20 @@ import React from 'react';
|
|||||||
|
|
||||||
import { redirect } from 'next/navigation';
|
import { redirect } from 'next/navigation';
|
||||||
|
|
||||||
import { createPath, pathsConfig } from '@/packages/shared/src/config';
|
import { pathsConfig } from '@/packages/shared/src/config';
|
||||||
|
import { StoreProduct } from '@medusajs/types';
|
||||||
import { ComponentInstanceIcon } from '@radix-ui/react-icons';
|
import { ComponentInstanceIcon } from '@radix-ui/react-icons';
|
||||||
|
|
||||||
import { cn } from '@kit/ui/shadcn';
|
import { cn } from '@kit/ui/shadcn';
|
||||||
import { Card, CardDescription, CardTitle } from '@kit/ui/shadcn/card';
|
import { Card, CardDescription } from '@kit/ui/shadcn/card';
|
||||||
|
|
||||||
export interface ServiceCategory {
|
export interface ServiceCategory {
|
||||||
name: string;
|
name: string;
|
||||||
handle: string;
|
handle: string;
|
||||||
color: string;
|
color: string;
|
||||||
description: string;
|
description: string;
|
||||||
|
products: StoreProduct[];
|
||||||
|
countryCode: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
const ServiceCategories = ({
|
const ServiceCategories = ({
|
||||||
|
|||||||
43
app/home/(user)/_lib/server/actions.ts
Normal file
43
app/home/(user)/_lib/server/actions.ts
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
'use server';
|
||||||
|
|
||||||
|
import { updateLineItem } from '@lib/data/cart';
|
||||||
|
import { StoreProductVariant } from '@medusajs/types';
|
||||||
|
|
||||||
|
import { handleAddToCart } from '~/lib/services/medusaCart.service';
|
||||||
|
import { createInitialReservation } from '~/lib/services/reservation.service';
|
||||||
|
|
||||||
|
export async function createInitialReservationAction(
|
||||||
|
selectedVariant: Pick<StoreProductVariant, 'id'>,
|
||||||
|
countryCode: string,
|
||||||
|
serviceId: number,
|
||||||
|
clinicId: number,
|
||||||
|
appointmentUserId: number,
|
||||||
|
syncUserId: number,
|
||||||
|
startTime: Date,
|
||||||
|
locationId: number | null,
|
||||||
|
comments?: string,
|
||||||
|
) {
|
||||||
|
const { addedItem } = await handleAddToCart({
|
||||||
|
selectedVariant,
|
||||||
|
countryCode,
|
||||||
|
});
|
||||||
|
|
||||||
|
if (addedItem) {
|
||||||
|
const reservation = await createInitialReservation({
|
||||||
|
serviceId,
|
||||||
|
clinicId,
|
||||||
|
appointmentUserId,
|
||||||
|
syncUserID: syncUserId,
|
||||||
|
startTime,
|
||||||
|
medusaLineItemId: addedItem.id,
|
||||||
|
locationId,
|
||||||
|
comments,
|
||||||
|
});
|
||||||
|
|
||||||
|
await updateLineItem({
|
||||||
|
lineId: addedItem.id,
|
||||||
|
quantity: addedItem.quantity,
|
||||||
|
metadata: { connectedOnlineReservationId: reservation.id },
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -17,6 +17,9 @@ import { AccountWithParams } from "@/packages/features/accounts/src/types/accoun
|
|||||||
import { createI18nServerInstance } from "~/lib/i18n/i18n.server";
|
import { createI18nServerInstance } from "~/lib/i18n/i18n.server";
|
||||||
import { getSupabaseServerAdminClient } from "@/packages/supabase/src/clients/server-admin-client";
|
import { getSupabaseServerAdminClient } from "@/packages/supabase/src/clients/server-admin-client";
|
||||||
import { createNotificationsApi } from "@/packages/features/notifications/src/server/api";
|
import { createNotificationsApi } from "@/packages/features/notifications/src/server/api";
|
||||||
|
import { FailureReason } from '~/lib/types/connected-online';
|
||||||
|
import { getOrderedTtoServices } from '~/lib/services/reservation.service';
|
||||||
|
import { bookAppointment } from '~/lib/services/connected-online.service';
|
||||||
|
|
||||||
const ANALYSIS_PACKAGES_TYPE_HANDLE = 'analysis-packages';
|
const ANALYSIS_PACKAGES_TYPE_HANDLE = 'analysis-packages';
|
||||||
const ANALYSIS_TYPE_HANDLE = 'synlab-analysis';
|
const ANALYSIS_TYPE_HANDLE = 'synlab-analysis';
|
||||||
@@ -77,14 +80,14 @@ export const initiatePayment = async ({
|
|||||||
if (!montonioPaymentSessionId) {
|
if (!montonioPaymentSessionId) {
|
||||||
throw new Error('Montonio payment session ID is missing');
|
throw new Error('Montonio payment session ID is missing');
|
||||||
}
|
}
|
||||||
const url = await handleNavigateToPayment({
|
const props = await handleNavigateToPayment({
|
||||||
language,
|
language,
|
||||||
paymentSessionId: montonioPaymentSessionId,
|
paymentSessionId: montonioPaymentSessionId,
|
||||||
amount: totalByMontonio,
|
amount: totalByMontonio,
|
||||||
currencyCode: cart.currency_code,
|
currencyCode: cart.currency_code,
|
||||||
cartId: cart.id,
|
cartId: cart.id,
|
||||||
});
|
});
|
||||||
return { url };
|
return { ...props, isFullyPaidByBenefits };
|
||||||
} else {
|
} else {
|
||||||
// place order if all paid already
|
// place order if all paid already
|
||||||
const { orderId } = await handlePlaceOrder({ cart });
|
const { orderId } = await handlePlaceOrder({ cart });
|
||||||
@@ -109,13 +112,13 @@ export const initiatePayment = async ({
|
|||||||
if (!webhookResponse.ok) {
|
if (!webhookResponse.ok) {
|
||||||
throw new Error('Failed to send company benefits webhook');
|
throw new Error('Failed to send company benefits webhook');
|
||||||
}
|
}
|
||||||
return { isFullyPaidByBenefits, orderId };
|
return { isFullyPaidByBenefits, orderId, unavailableLineItemIds: [] };
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error initiating payment', error);
|
console.error('Error initiating payment', error);
|
||||||
}
|
}
|
||||||
|
|
||||||
return { url: null }
|
return { url: null, isFullyPaidByBenefits: false, orderId: null, unavailableLineItemIds: [] };
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function handlePlaceOrder({
|
export async function handlePlaceOrder({
|
||||||
@@ -136,6 +139,8 @@ export async function handlePlaceOrder({
|
|||||||
medusaOrder,
|
medusaOrder,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const orderContainsSynlabItems = !!orderedAnalysisElements?.length;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const existingAnalysisOrder = await getAnalysisOrder({
|
const existingAnalysisOrder = await getAnalysisOrder({
|
||||||
medusaOrderId: medusaOrder.id,
|
medusaOrderId: medusaOrder.id,
|
||||||
@@ -148,15 +153,38 @@ export async function handlePlaceOrder({
|
|||||||
// ignored
|
// ignored
|
||||||
}
|
}
|
||||||
|
|
||||||
const orderId = await createAnalysisOrder({
|
let orderId: number | undefined = undefined;
|
||||||
medusaOrder,
|
if (orderContainsSynlabItems) {
|
||||||
orderedAnalysisElements,
|
orderId = await createAnalysisOrder({
|
||||||
});
|
medusaOrder,
|
||||||
|
orderedAnalysisElements,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
const orderResult = await getOrderResultParameters(medusaOrder);
|
const orderResult = await getOrderResultParameters(medusaOrder);
|
||||||
|
|
||||||
const { medusaOrderId, email, analysisPackageOrder, analysisItemsOrder } =
|
const { medusaOrderId, email, analysisPackageOrder, analysisItemsOrder } =
|
||||||
orderResult;
|
orderResult;
|
||||||
|
|
||||||
|
const orderedTtoServices = await getOrderedTtoServices({ medusaOrder });
|
||||||
|
let bookServiceResults: {
|
||||||
|
success: boolean;
|
||||||
|
reason?: FailureReason;
|
||||||
|
serviceId?: number;
|
||||||
|
}[] = [];
|
||||||
|
if (orderedTtoServices?.length) {
|
||||||
|
const bookingPromises = orderedTtoServices.map((service) =>
|
||||||
|
bookAppointment(
|
||||||
|
service.service_id,
|
||||||
|
service.clinic_id,
|
||||||
|
service.service_user_id,
|
||||||
|
service.sync_user_id,
|
||||||
|
service.start_time,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
bookServiceResults = await Promise.all(bookingPromises);
|
||||||
|
}
|
||||||
|
|
||||||
if (email) {
|
if (email) {
|
||||||
if (analysisPackageOrder) {
|
if (analysisPackageOrder) {
|
||||||
await sendAnalysisPackageOrderEmail({
|
await sendAnalysisPackageOrderEmail({
|
||||||
@@ -184,6 +212,17 @@ export async function handlePlaceOrder({
|
|||||||
await sendOrderToMedipost({ medusaOrderId, orderedAnalysisElements });
|
await sendOrderToMedipost({ medusaOrderId, orderedAnalysisElements });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (bookServiceResults.some(({ success }) => success === false)) {
|
||||||
|
const failedServiceBookings = bookServiceResults.filter(
|
||||||
|
({ success }) => success === false,
|
||||||
|
);
|
||||||
|
return {
|
||||||
|
success: false,
|
||||||
|
failedServiceBookings,
|
||||||
|
orderId,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
return { success: true, orderId };
|
return { success: true, orderId };
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Failed to place order', error);
|
console.error('Failed to place order', error);
|
||||||
|
|||||||
12
app/home/(user)/_lib/server/is-valid-open-ai-env.ts
Normal file
12
app/home/(user)/_lib/server/is-valid-open-ai-env.ts
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
import OpenAI from 'openai';
|
||||||
|
|
||||||
|
export const isValidOpenAiEnv = async () => {
|
||||||
|
try {
|
||||||
|
const client = new OpenAI();
|
||||||
|
await client.models.list();
|
||||||
|
return true;
|
||||||
|
} catch (e) {
|
||||||
|
console.log('No openAI env');
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -45,10 +45,6 @@ async function analysesLoader() {
|
|||||||
})
|
})
|
||||||
: null;
|
: null;
|
||||||
|
|
||||||
const serviceCategories = productCategories.filter(
|
|
||||||
({ parent_category }) => parent_category?.handle === 'tto-categories',
|
|
||||||
);
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
analyses:
|
analyses:
|
||||||
categoryProducts?.response.products
|
categoryProducts?.response.products
|
||||||
|
|||||||
@@ -1,20 +1,30 @@
|
|||||||
import { cache } from 'react';
|
import { cache } from 'react';
|
||||||
|
|
||||||
import { getProductCategories } from '@lib/data';
|
import { getProductCategories, listProducts } from '@lib/data';
|
||||||
|
|
||||||
import { ServiceCategory } from '../../_components/service-categories';
|
import { loadCountryCodes } from './load-analyses';
|
||||||
|
|
||||||
async function categoryLoader({
|
|
||||||
handle,
|
|
||||||
}: {
|
|
||||||
handle: string;
|
|
||||||
}): Promise<{ category: ServiceCategory | null }> {
|
|
||||||
const response = await getProductCategories({
|
|
||||||
handle,
|
|
||||||
fields: '*products, is_active, metadata',
|
|
||||||
});
|
|
||||||
|
|
||||||
|
async function categoryLoader({ handle }: { handle: string }) {
|
||||||
|
const [response, countryCodes] = await Promise.all([
|
||||||
|
getProductCategories({
|
||||||
|
handle,
|
||||||
|
limit: 1,
|
||||||
|
}),
|
||||||
|
loadCountryCodes(),
|
||||||
|
]);
|
||||||
const category = response.product_categories[0];
|
const category = response.product_categories[0];
|
||||||
|
const countryCode = countryCodes[0]!;
|
||||||
|
|
||||||
|
if (!response.product_categories?.[0]?.id) {
|
||||||
|
return { category: null };
|
||||||
|
}
|
||||||
|
|
||||||
|
const {
|
||||||
|
response: { products: categoryProducts },
|
||||||
|
} = await listProducts({
|
||||||
|
countryCode,
|
||||||
|
queryParams: { limit: 100, category_id: response.product_categories[0].id },
|
||||||
|
});
|
||||||
|
|
||||||
return {
|
return {
|
||||||
category: {
|
category: {
|
||||||
@@ -25,6 +35,8 @@ async function categoryLoader({
|
|||||||
description: category?.description || '',
|
description: category?.description || '',
|
||||||
handle: category?.handle || '',
|
handle: category?.handle || '',
|
||||||
name: category?.name || '',
|
name: category?.name || '',
|
||||||
|
countryCode,
|
||||||
|
products: categoryProducts,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,38 +10,36 @@ async function ttoServicesLoader() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
const heroCategories = response.product_categories?.filter(
|
const heroCategories = response.product_categories?.filter(
|
||||||
({ parent_category, is_active, metadata }) =>
|
({ parent_category, metadata }) =>
|
||||||
parent_category?.handle === 'tto-categories' &&
|
parent_category?.handle === 'tto-categories' && metadata?.isHero,
|
||||||
is_active &&
|
|
||||||
metadata?.isHero,
|
|
||||||
);
|
);
|
||||||
|
|
||||||
const ttoCategories = response.product_categories?.filter(
|
const ttoCategories = response.product_categories?.filter(
|
||||||
({ parent_category, is_active, metadata }) =>
|
({ parent_category, metadata }) =>
|
||||||
parent_category?.handle === 'tto-categories' &&
|
parent_category?.handle === 'tto-categories' && !metadata?.isHero,
|
||||||
is_active &&
|
|
||||||
!metadata?.isHero,
|
|
||||||
);
|
);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
heroCategories:
|
heroCategories:
|
||||||
heroCategories.map<ServiceCategory>(
|
heroCategories.map<Omit<ServiceCategory, 'countryCode'>>(
|
||||||
({ name, handle, metadata, description }) => ({
|
({ name, handle, metadata, description, products }) => ({
|
||||||
name,
|
name,
|
||||||
handle,
|
handle,
|
||||||
color:
|
color:
|
||||||
typeof metadata?.color === 'string' ? metadata.color : 'primary',
|
typeof metadata?.color === 'string' ? metadata.color : 'primary',
|
||||||
description,
|
description,
|
||||||
|
products: products ?? [],
|
||||||
}),
|
}),
|
||||||
) ?? [],
|
) ?? [],
|
||||||
ttoCategories:
|
ttoCategories:
|
||||||
ttoCategories.map<ServiceCategory>(
|
ttoCategories.map<Omit<ServiceCategory, 'countryCode'>>(
|
||||||
({ name, handle, metadata, description }) => ({
|
({ name, handle, metadata, description, products }) => ({
|
||||||
name,
|
name,
|
||||||
handle,
|
handle,
|
||||||
color:
|
color:
|
||||||
typeof metadata?.color === 'string' ? metadata.color : 'primary',
|
typeof metadata?.color === 'string' ? metadata.color : 'primary',
|
||||||
description,
|
description,
|
||||||
|
products: products ?? [],
|
||||||
}),
|
}),
|
||||||
) ?? [],
|
) ?? [],
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
|
|
||||||
import { formatCurrency } from '@/packages/shared/src/utils';
|
import { formatCurrency } from '@/packages/shared/src/utils';
|
||||||
import { PiggyBankIcon } from 'lucide-react';
|
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
|
|
||||||
import { Card, CardTitle } from '@kit/ui/card';
|
import { Card, CardTitle } from '@kit/ui/card';
|
||||||
import { cn } from '@kit/ui/lib/utils';
|
import { cn } from '@kit/ui/lib/utils';
|
||||||
import { Trans } from '@kit/ui/trans';
|
import { Trans } from '@kit/ui/trans';
|
||||||
|
|
||||||
|
import { TeamAccountBenefitExpensesOverview } from '../_lib/server/load-team-account-benefit-expenses-overview';
|
||||||
import { AccountBenefitStatistics } from '../_lib/server/load-team-account-benefit-statistics';
|
import { AccountBenefitStatistics } from '../_lib/server/load-team-account-benefit-statistics';
|
||||||
|
|
||||||
const StatisticsCard = ({ children }: { children: React.ReactNode }) => {
|
const StatisticsCard = ({ children }: { children: React.ReactNode }) => {
|
||||||
@@ -38,8 +38,10 @@ const StatisticsValue = ({ children }: { children: React.ReactNode }) => {
|
|||||||
|
|
||||||
const TeamAccountBenefitStatistics = ({
|
const TeamAccountBenefitStatistics = ({
|
||||||
accountBenefitStatistics,
|
accountBenefitStatistics,
|
||||||
|
expensesOverview,
|
||||||
}: {
|
}: {
|
||||||
accountBenefitStatistics: AccountBenefitStatistics;
|
accountBenefitStatistics: AccountBenefitStatistics;
|
||||||
|
expensesOverview: TeamAccountBenefitExpensesOverview;
|
||||||
}) => {
|
}) => {
|
||||||
const {
|
const {
|
||||||
i18n: { language },
|
i18n: { language },
|
||||||
@@ -47,25 +49,16 @@ const TeamAccountBenefitStatistics = ({
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="flex h-full w-full flex-col gap-2 sm:flex-row">
|
<div className="flex h-full w-full flex-col gap-2 sm:flex-row">
|
||||||
<Card className="relative flex flex-row">
|
<div className="grid flex-2 grid-cols-2 gap-2 sm:grid-cols-3 sm:grid-rows-2">
|
||||||
<div className="p-6">
|
<StatisticsCard>
|
||||||
<div className="flex h-16 w-16 items-center justify-center rounded-full bg-orange-100">
|
<StatisticsCardTitle className="text-lg font-bold">
|
||||||
<PiggyBankIcon className="h-[32px] w-[32px] stroke-orange-400 stroke-2" />
|
<Trans i18nKey="teams:benefitStatistics.budget.membersCount" />
|
||||||
</div>
|
|
||||||
<StatisticsCardTitle className="mt-4 text-xl font-bold">
|
|
||||||
<Trans i18nKey="teams:benefitStatistics.budget.volume" />
|
|
||||||
</StatisticsCardTitle>
|
</StatisticsCardTitle>
|
||||||
<StatisticsValue>
|
<StatisticsValue>
|
||||||
{formatCurrency({
|
{accountBenefitStatistics.companyAccountsCount}
|
||||||
value: accountBenefitStatistics.periodTotal,
|
|
||||||
locale: language,
|
|
||||||
currencyCode: 'EUR',
|
|
||||||
})}
|
|
||||||
</StatisticsValue>
|
</StatisticsValue>
|
||||||
</div>
|
</StatisticsCard>
|
||||||
</Card>
|
|
||||||
|
|
||||||
<div className="grid flex-2 grid-cols-2 gap-2 sm:grid-cols-3 sm:grid-rows-2">
|
|
||||||
<StatisticsCard>
|
<StatisticsCard>
|
||||||
<StatisticsCardTitle className="text-lg font-bold">
|
<StatisticsCardTitle className="text-lg font-bold">
|
||||||
<Trans i18nKey="teams:benefitStatistics.data.totalSum" />
|
<Trans i18nKey="teams:benefitStatistics.data.totalSum" />
|
||||||
@@ -79,11 +72,30 @@ const TeamAccountBenefitStatistics = ({
|
|||||||
</StatisticsValue>
|
</StatisticsValue>
|
||||||
</StatisticsCard>
|
</StatisticsCard>
|
||||||
|
|
||||||
|
<StatisticsCard>
|
||||||
|
<StatisticsCardTitle className="text-lg font-bold">
|
||||||
|
<Trans i18nKey="teams:benefitStatistics.data.currentMonthUsageTotal" />
|
||||||
|
</StatisticsCardTitle>
|
||||||
|
<StatisticsValue>
|
||||||
|
{formatCurrency({
|
||||||
|
value: expensesOverview.currentMonthUsageTotal,
|
||||||
|
locale: language,
|
||||||
|
currencyCode: 'EUR',
|
||||||
|
})}
|
||||||
|
</StatisticsValue>
|
||||||
|
</StatisticsCard>
|
||||||
|
|
||||||
<StatisticsCard>
|
<StatisticsCard>
|
||||||
<StatisticsCardTitle>
|
<StatisticsCardTitle>
|
||||||
<Trans i18nKey="teams:benefitStatistics.data.analysis" />
|
<Trans i18nKey="teams:benefitStatistics.data.analysis" />
|
||||||
</StatisticsCardTitle>
|
</StatisticsCardTitle>
|
||||||
<StatisticsValue>{accountBenefitStatistics.orders.analysesSum} €</StatisticsValue>
|
<StatisticsValue>
|
||||||
|
{formatCurrency({
|
||||||
|
value: accountBenefitStatistics.orders.analysesSum,
|
||||||
|
locale: language,
|
||||||
|
currencyCode: 'EUR',
|
||||||
|
})}
|
||||||
|
</StatisticsValue>
|
||||||
<StatisticsDescription>
|
<StatisticsDescription>
|
||||||
<Trans
|
<Trans
|
||||||
i18nKey="teams:benefitStatistics.data.reservations"
|
i18nKey="teams:benefitStatistics.data.reservations"
|
||||||
@@ -106,7 +118,9 @@ const TeamAccountBenefitStatistics = ({
|
|||||||
<StatisticsDescription>
|
<StatisticsDescription>
|
||||||
<Trans
|
<Trans
|
||||||
i18nKey="teams:benefitStatistics.data.analysisPackagesCount"
|
i18nKey="teams:benefitStatistics.data.analysisPackagesCount"
|
||||||
values={{ value: accountBenefitStatistics.orders.analysisPackagesCount }}
|
values={{
|
||||||
|
value: accountBenefitStatistics.orders.analysisPackagesCount,
|
||||||
|
}}
|
||||||
/>
|
/>
|
||||||
</StatisticsDescription>
|
</StatisticsDescription>
|
||||||
</StatisticsCard>
|
</StatisticsCard>
|
||||||
|
|||||||
@@ -52,7 +52,6 @@ function SidebarContainer(props: {
|
|||||||
<SidebarContent>
|
<SidebarContent>
|
||||||
<SidebarNavigation config={config} />
|
<SidebarNavigation config={config} />
|
||||||
</SidebarContent>
|
</SidebarContent>
|
||||||
|
|
||||||
</Sidebar>
|
</Sidebar>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ import { AccountBenefitStatistics } from '../_lib/server/load-team-account-benef
|
|||||||
import TeamAccountBenefitStatistics from './team-account-benefit-statistics';
|
import TeamAccountBenefitStatistics from './team-account-benefit-statistics';
|
||||||
import TeamAccountHealthDetails from './team-account-health-details';
|
import TeamAccountHealthDetails from './team-account-health-details';
|
||||||
import type { Account, AccountParams, BmiThresholds } from '@/packages/features/accounts/src/types/accounts';
|
import type { Account, AccountParams, BmiThresholds } from '@/packages/features/accounts/src/types/accounts';
|
||||||
|
import { TeamAccountBenefitExpensesOverview } from '../_lib/server/load-team-account-benefit-expenses-overview';
|
||||||
|
|
||||||
export interface TeamAccountStatisticsProps {
|
export interface TeamAccountStatisticsProps {
|
||||||
teamAccount: Account;
|
teamAccount: Account;
|
||||||
@@ -27,6 +28,7 @@ export interface TeamAccountStatisticsProps {
|
|||||||
bmiThresholds: Omit<BmiThresholds, 'id'>[];
|
bmiThresholds: Omit<BmiThresholds, 'id'>[];
|
||||||
members: Database['medreport']['Functions']['get_account_members']['Returns'];
|
members: Database['medreport']['Functions']['get_account_members']['Returns'];
|
||||||
accountBenefitStatistics: AccountBenefitStatistics;
|
accountBenefitStatistics: AccountBenefitStatistics;
|
||||||
|
expensesOverview: TeamAccountBenefitExpensesOverview;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function TeamAccountStatistics({
|
export default function TeamAccountStatistics({
|
||||||
@@ -35,6 +37,7 @@ export default function TeamAccountStatistics({
|
|||||||
bmiThresholds,
|
bmiThresholds,
|
||||||
members,
|
members,
|
||||||
accountBenefitStatistics,
|
accountBenefitStatistics,
|
||||||
|
expensesOverview,
|
||||||
}: TeamAccountStatisticsProps) {
|
}: TeamAccountStatisticsProps) {
|
||||||
const currentDate = new Date();
|
const currentDate = new Date();
|
||||||
const [date, setDate] = useState<DateRange | undefined>({
|
const [date, setDate] = useState<DateRange | undefined>({
|
||||||
@@ -50,7 +53,7 @@ export default function TeamAccountStatistics({
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<div className="mt-4 flex items-center justify-between">
|
<div className="mt-4 flex flex-col gap-4 sm:gap-0 sm:flex-row items-center justify-between">
|
||||||
<h4 className="font-bold">
|
<h4 className="font-bold">
|
||||||
<Trans
|
<Trans
|
||||||
i18nKey={'teams:home.headerTitle'}
|
i18nKey={'teams:home.headerTitle'}
|
||||||
@@ -75,7 +78,7 @@ export default function TeamAccountStatistics({
|
|||||||
'animate-in fade-in flex flex-col space-y-4 pb-36 duration-500'
|
'animate-in fade-in flex flex-col space-y-4 pb-36 duration-500'
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
<TeamAccountBenefitStatistics accountBenefitStatistics={accountBenefitStatistics} />
|
<TeamAccountBenefitStatistics accountBenefitStatistics={accountBenefitStatistics} expensesOverview={expensesOverview} />
|
||||||
|
|
||||||
<h5 className="mt-4 mb-2">
|
<h5 className="mt-4 mb-2">
|
||||||
<Trans i18nKey="teams:home.healthDetails" />
|
<Trans i18nKey="teams:home.healthDetails" />
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ export const loadCompanyPersonalAccountsBalanceEntries = async ({
|
|||||||
const { count, data: accountMemberships } = await supabase
|
const { count, data: accountMemberships } = await supabase
|
||||||
.schema('medreport')
|
.schema('medreport')
|
||||||
.from('accounts_memberships')
|
.from('accounts_memberships')
|
||||||
.select('user_id')
|
.select('user_id', { count: 'exact' })
|
||||||
.eq('account_id', accountId)
|
.eq('account_id', accountId)
|
||||||
.throwOnError();
|
.throwOnError();
|
||||||
|
|
||||||
|
|||||||
@@ -30,7 +30,9 @@ const HealthBenefitFields = () => {
|
|||||||
<Select {...field} onValueChange={field.onChange}>
|
<Select {...field} onValueChange={field.onChange}>
|
||||||
<SelectTrigger>
|
<SelectTrigger>
|
||||||
<SelectValue
|
<SelectValue
|
||||||
placeholder={<Trans i18nKey="common:formField:occurrence" />}
|
placeholder={
|
||||||
|
<Trans i18nKey="common:formField:occurrence" />
|
||||||
|
}
|
||||||
/>
|
/>
|
||||||
</SelectTrigger>
|
</SelectTrigger>
|
||||||
|
|
||||||
|
|||||||
@@ -55,7 +55,9 @@ async function TeamAccountMembersPage({ params }: TeamAccountMembersPageProps) {
|
|||||||
<>
|
<>
|
||||||
<TeamAccountLayoutPageHeader
|
<TeamAccountLayoutPageHeader
|
||||||
title={<Trans i18nKey={'common:routes.companyMembers'} />}
|
title={<Trans i18nKey={'common:routes.companyMembers'} />}
|
||||||
description={<AppBreadcrumbs values={{ [account.slug]: account.name }}/>}
|
description={
|
||||||
|
<AppBreadcrumbs values={{ [account.slug]: account.name }} />
|
||||||
|
}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<PageBody>
|
<PageBody>
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ import {
|
|||||||
|
|
||||||
import { Dashboard } from './_components/dashboard';
|
import { Dashboard } from './_components/dashboard';
|
||||||
import { loadAccountBenefitStatistics } from './_lib/server/load-team-account-benefit-statistics';
|
import { loadAccountBenefitStatistics } from './_lib/server/load-team-account-benefit-statistics';
|
||||||
|
import { loadTeamAccountBenefitExpensesOverview } from './_lib/server/load-team-account-benefit-expenses-overview';
|
||||||
|
|
||||||
interface TeamAccountHomePageProps {
|
interface TeamAccountHomePageProps {
|
||||||
params: Promise<{ account: string }>;
|
params: Promise<{ account: string }>;
|
||||||
@@ -41,6 +42,10 @@ function TeamAccountHomePage({ params }: TeamAccountHomePageProps) {
|
|||||||
const { memberParams, members } = use(teamAccountsApi.getMembers(account));
|
const { memberParams, members } = use(teamAccountsApi.getMembers(account));
|
||||||
const bmiThresholds = use(userAnalysesApi.fetchBmiThresholds());
|
const bmiThresholds = use(userAnalysesApi.fetchBmiThresholds());
|
||||||
const accountBenefitStatistics = use(loadAccountBenefitStatistics(teamAccount.id));
|
const accountBenefitStatistics = use(loadAccountBenefitStatistics(teamAccount.id));
|
||||||
|
const expensesOverview = use(loadTeamAccountBenefitExpensesOverview({
|
||||||
|
companyId: teamAccount.id,
|
||||||
|
employeeCount: members.length,
|
||||||
|
}));
|
||||||
|
|
||||||
use(
|
use(
|
||||||
createPageViewLog({
|
createPageViewLog({
|
||||||
@@ -57,6 +62,7 @@ function TeamAccountHomePage({ params }: TeamAccountHomePageProps) {
|
|||||||
bmiThresholds={bmiThresholds}
|
bmiThresholds={bmiThresholds}
|
||||||
members={members}
|
members={members}
|
||||||
accountBenefitStatistics={accountBenefitStatistics}
|
accountBenefitStatistics={accountBenefitStatistics}
|
||||||
|
expensesOverview={expensesOverview}
|
||||||
/>
|
/>
|
||||||
</PageBody>
|
</PageBody>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -48,7 +48,9 @@ async function TeamAccountSettingsPage(props: TeamAccountSettingsPageProps) {
|
|||||||
<>
|
<>
|
||||||
<TeamAccountLayoutPageHeader
|
<TeamAccountLayoutPageHeader
|
||||||
title={<Trans i18nKey={'teams:settings.pageTitle'} />}
|
title={<Trans i18nKey={'teams:settings.pageTitle'} />}
|
||||||
description={<AppBreadcrumbs values={{ [account.slug]: account.name }} />}
|
description={
|
||||||
|
<AppBreadcrumbs values={{ [account.slug]: account.name }} />
|
||||||
|
}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<PageBody>
|
<PageBody>
|
||||||
|
|||||||
@@ -1,14 +1,13 @@
|
|||||||
'use server';
|
'use server';
|
||||||
|
|
||||||
import { RequestStatus } from '@/lib/types/audit';
|
import { RequestStatus, SyncStatus } from '@/lib/types/audit';
|
||||||
import { ConnectedOnlineMethodName } from '@/lib/types/connected-online';
|
import { ConnectedOnlineMethodName } from '@/lib/types/connected-online';
|
||||||
import { ExternalApi } from '@/lib/types/external';
|
import { ExternalApi } from '@/lib/types/external';
|
||||||
import { MedipostAction } from '@/lib/types/medipost';
|
import { MedipostAction } from '@/lib/types/medipost';
|
||||||
import { getSupabaseServerAdminClient } from '@/packages/supabase/src/clients/server-admin-client';
|
import { getSupabaseServerAdminClient } from '@/packages/supabase/src/clients/server-admin-client';
|
||||||
import { getSupabaseServerClient } from '@/packages/supabase/src/clients/server-client';
|
|
||||||
|
|
||||||
export default async function logRequestResult(
|
export default async function logRequestResult(
|
||||||
/* personalCode: string, */ requestApi: keyof typeof ExternalApi,
|
requestApi: keyof typeof ExternalApi,
|
||||||
requestApiMethod: `${ConnectedOnlineMethodName}` | `${MedipostAction}`,
|
requestApiMethod: `${ConnectedOnlineMethodName}` | `${MedipostAction}`,
|
||||||
status: RequestStatus,
|
status: RequestStatus,
|
||||||
comment?: string,
|
comment?: string,
|
||||||
@@ -16,11 +15,10 @@ export default async function logRequestResult(
|
|||||||
serviceId?: number,
|
serviceId?: number,
|
||||||
serviceProviderId?: number,
|
serviceProviderId?: number,
|
||||||
) {
|
) {
|
||||||
const { error } = await getSupabaseServerClient()
|
const { error } = await getSupabaseServerAdminClient()
|
||||||
.schema('audit')
|
.schema('audit')
|
||||||
.from('request_entries')
|
.from('request_entries')
|
||||||
.insert({
|
.insert({
|
||||||
/* personal_code: personalCode, */
|
|
||||||
request_api: requestApi,
|
request_api: requestApi,
|
||||||
request_api_method: requestApiMethod,
|
request_api_method: requestApiMethod,
|
||||||
requested_start_date: startTime,
|
requested_start_date: startTime,
|
||||||
@@ -69,3 +67,29 @@ export async function getMedipostDispatchTries(medusaOrderId: string) {
|
|||||||
|
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function logSyncResult({
|
||||||
|
operation,
|
||||||
|
comment,
|
||||||
|
status,
|
||||||
|
changed_by_role,
|
||||||
|
}: {
|
||||||
|
operation: string;
|
||||||
|
comment?: string;
|
||||||
|
status: SyncStatus;
|
||||||
|
changed_by_role: string;
|
||||||
|
}) {
|
||||||
|
const { error } = await getSupabaseServerAdminClient()
|
||||||
|
.schema('audit')
|
||||||
|
.from('sync_entries')
|
||||||
|
.insert({
|
||||||
|
operation,
|
||||||
|
comment,
|
||||||
|
status,
|
||||||
|
changed_by_role,
|
||||||
|
});
|
||||||
|
|
||||||
|
if (error) {
|
||||||
|
throw new Error('Failed to insert log entry, error: ' + error.message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
40
lib/services/audit/cartEntries.ts
Normal file
40
lib/services/audit/cartEntries.ts
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
import { getSupabaseServerClient } from '@kit/supabase/server-client';
|
||||||
|
|
||||||
|
export const createCartEntriesLog = async ({
|
||||||
|
operation,
|
||||||
|
accountId,
|
||||||
|
cartId,
|
||||||
|
variantId,
|
||||||
|
comment,
|
||||||
|
}: {
|
||||||
|
operation: string;
|
||||||
|
accountId: string;
|
||||||
|
cartId: string;
|
||||||
|
variantId?: string;
|
||||||
|
comment?: string;
|
||||||
|
}) => {
|
||||||
|
try {
|
||||||
|
const supabase = getSupabaseServerClient();
|
||||||
|
|
||||||
|
const {
|
||||||
|
data: { user },
|
||||||
|
error: userError,
|
||||||
|
} = await supabase.auth.getUser();
|
||||||
|
|
||||||
|
if (userError || !user) {
|
||||||
|
console.error('No authenticated user found; skipping audit insert');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
return supabase.schema('audit').from('cart_entries').insert({
|
||||||
|
operation,
|
||||||
|
account_id: accountId,
|
||||||
|
cart_id: cartId,
|
||||||
|
changed_by: user.id,
|
||||||
|
variant_id: variantId,
|
||||||
|
comment,
|
||||||
|
});
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Failed to insert doctor page view log', error);
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -6,6 +6,7 @@ export enum PageViewAction {
|
|||||||
REGISTRATION_SUCCESS = 'REGISTRATION_SUCCESS',
|
REGISTRATION_SUCCESS = 'REGISTRATION_SUCCESS',
|
||||||
VIEW_ORDER_ANALYSIS = 'VIEW_ORDER_ANALYSIS',
|
VIEW_ORDER_ANALYSIS = 'VIEW_ORDER_ANALYSIS',
|
||||||
VIEW_TEAM_ACCOUNT_DASHBOARD = 'VIEW_TEAM_ACCOUNT_DASHBOARD',
|
VIEW_TEAM_ACCOUNT_DASHBOARD = 'VIEW_TEAM_ACCOUNT_DASHBOARD',
|
||||||
|
VIEW_TTO_SERVICE_BOOKING = 'VIEW_TTO_SERVICE_BOOKING',
|
||||||
}
|
}
|
||||||
|
|
||||||
export const createPageViewLog = async ({
|
export const createPageViewLog = async ({
|
||||||
@@ -37,6 +38,7 @@ export const createPageViewLog = async ({
|
|||||||
account_id: accountId,
|
account_id: accountId,
|
||||||
action,
|
action,
|
||||||
changed_by: user.id,
|
changed_by: user.id,
|
||||||
|
extra_data: extraData,
|
||||||
})
|
})
|
||||||
.throwOnError();
|
.throwOnError();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|||||||
@@ -7,19 +7,30 @@ import {
|
|||||||
BookTimeResponse,
|
BookTimeResponse,
|
||||||
ConfirmedLoadResponse,
|
ConfirmedLoadResponse,
|
||||||
ConnectedOnlineMethodName,
|
ConnectedOnlineMethodName,
|
||||||
|
FailureReason,
|
||||||
} from '@/lib/types/connected-online';
|
} from '@/lib/types/connected-online';
|
||||||
import { ExternalApi } from '@/lib/types/external';
|
import { ExternalApi } from '@/lib/types/external';
|
||||||
import { Tables } from '@/packages/supabase/src/database.types';
|
import { Tables } from '@/packages/supabase/src/database.types';
|
||||||
import { createClient } from '@/utils/supabase/server';
|
|
||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
|
import { uniq, uniqBy } from 'lodash';
|
||||||
|
|
||||||
|
import { renderBookTimeFailedEmail } from '@kit/email-templates';
|
||||||
|
import { getLogger } from '@kit/shared/logger';
|
||||||
|
import { getSupabaseServerClient } from '@kit/supabase/server-client';
|
||||||
|
|
||||||
|
import { TimeSlotResponse } from '~/home/(user)/_components/booking/booking.context';
|
||||||
|
|
||||||
|
import { sendEmailFromTemplate } from './mailer.service';
|
||||||
|
|
||||||
export async function getAvailableAppointmentsForService(
|
export async function getAvailableAppointmentsForService(
|
||||||
serviceId: number,
|
serviceId: number,
|
||||||
|
key: string,
|
||||||
|
locationId: number | null,
|
||||||
startTime?: Date,
|
startTime?: Date,
|
||||||
|
maxDays?: number,
|
||||||
) {
|
) {
|
||||||
try {
|
try {
|
||||||
const showTimesFrom = startTime ? { StartTime: startTime } : {};
|
const start = startTime ? { StartTime: startTime } : {};
|
||||||
|
|
||||||
const response = await axios.post(
|
const response = await axios.post(
|
||||||
`${process.env.CONNECTED_ONLINE_URL!}/${ConnectedOnlineMethodName.GetAvailabilities}`,
|
`${process.env.CONNECTED_ONLINE_URL!}/${ConnectedOnlineMethodName.GetAvailabilities}`,
|
||||||
{
|
{
|
||||||
@@ -28,9 +39,11 @@ export async function getAvailableAppointmentsForService(
|
|||||||
},
|
},
|
||||||
param: JSON.stringify({
|
param: JSON.stringify({
|
||||||
ServiceID: serviceId,
|
ServiceID: serviceId,
|
||||||
Key: '7T624nlu',
|
Key: key,
|
||||||
Lang: 'et',
|
Lang: 'et',
|
||||||
...showTimesFrom,
|
MaxDays: maxDays ?? 120,
|
||||||
|
LocationId: locationId ?? -1,
|
||||||
|
...start,
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
@@ -80,157 +93,210 @@ export async function getAvailableAppointmentsForService(
|
|||||||
}
|
}
|
||||||
|
|
||||||
export async function bookAppointment(
|
export async function bookAppointment(
|
||||||
serviceSyncId: number,
|
serviceId: number,
|
||||||
clinicId: number,
|
clinicId: number,
|
||||||
appointmentUserId: number,
|
appointmentUserId: number,
|
||||||
syncUserID: number,
|
syncUserID: number,
|
||||||
startTime: string,
|
startTime: string,
|
||||||
locationId = 0,
|
|
||||||
comments = '',
|
comments = '',
|
||||||
isEarlierTimeRequested = false,
|
|
||||||
earlierTimeRequestComment = '',
|
|
||||||
) {
|
) {
|
||||||
const supabase = await createClient();
|
const logger = await getLogger();
|
||||||
|
const supabase = getSupabaseServerClient();
|
||||||
|
|
||||||
|
let reason = FailureReason.BOOKING_FAILED;
|
||||||
try {
|
try {
|
||||||
const {
|
const {
|
||||||
data: { user },
|
data: { user },
|
||||||
} = await supabase.auth.getUser();
|
} = await supabase.auth.getUser();
|
||||||
|
|
||||||
|
logger.info(
|
||||||
|
`Booking time slot ${JSON.stringify({ serviceId, clinicId, startTime, userId: user?.id })}`,
|
||||||
|
);
|
||||||
|
|
||||||
if (!user?.id) {
|
if (!user?.id) {
|
||||||
throw new Error('User not authenticated');
|
throw new Error('User not authenticated');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const formattedStartTime = startTime.replace('T', ' ');
|
||||||
|
|
||||||
const [
|
const [
|
||||||
{ data: dbClinic, error: clinicError },
|
{ data: dbClinic, error: clinicError },
|
||||||
{ data: dbService, error: serviceError },
|
{ data: dbService, error: serviceError },
|
||||||
|
{ data: account, error: accountError },
|
||||||
|
{ data: dbReservation, error: dbReservationError },
|
||||||
] = await Promise.all([
|
] = await Promise.all([
|
||||||
supabase
|
supabase
|
||||||
.schema('medreport')
|
.schema('medreport')
|
||||||
.from('connected_online_providers')
|
.from('connected_online_providers')
|
||||||
.select('*')
|
.select('*')
|
||||||
.eq('id', clinicId)
|
.eq('id', clinicId)
|
||||||
.limit(1),
|
.single(),
|
||||||
supabase
|
supabase
|
||||||
.schema('medreport')
|
.schema('medreport')
|
||||||
.from('connected_online_services')
|
.from('connected_online_services')
|
||||||
.select('*')
|
.select('*')
|
||||||
.eq('sync_id', serviceSyncId)
|
.eq('id', serviceId)
|
||||||
.eq('clinic_id', clinicId)
|
.eq('clinic_id', clinicId)
|
||||||
.limit(1),
|
.single(),
|
||||||
|
supabase
|
||||||
|
.schema('medreport')
|
||||||
|
.from('accounts')
|
||||||
|
.select('name, last_name, personal_code, phone, email')
|
||||||
|
.eq('is_personal_account', true)
|
||||||
|
.eq('primary_owner_user_id', user.id)
|
||||||
|
.single(),
|
||||||
|
supabase
|
||||||
|
.schema('medreport')
|
||||||
|
.from('connected_online_reservation')
|
||||||
|
.select('id')
|
||||||
|
.eq('clinic_id', clinicId)
|
||||||
|
.eq('service_id', serviceId)
|
||||||
|
.eq('start_time', formattedStartTime)
|
||||||
|
.eq('user_id', user.id)
|
||||||
|
.eq('status', 'PENDING')
|
||||||
|
.single(),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
if (!dbClinic?.length || !dbService?.length) {
|
if (!dbClinic || !dbService) {
|
||||||
return logRequestResult(
|
const errorMessage = dbClinic
|
||||||
ExternalApi.ConnectedOnline,
|
? `Could not find clinic with id ${clinicId}, error: ${JSON.stringify(clinicError)}`
|
||||||
ConnectedOnlineMethodName.BookTime,
|
: `Could not find service with sync id ${serviceId} and clinic id ${clinicId}, error: ${JSON.stringify(serviceError)}`;
|
||||||
RequestStatus.Fail,
|
logger.error(errorMessage);
|
||||||
dbClinic?.length
|
|
||||||
? `Could not find clinic with id ${clinicId}, error: ${JSON.stringify(clinicError)}`
|
throw new Error(errorMessage);
|
||||||
: `Could not find service with sync id ${serviceSyncId} and clinic id ${clinicId}, error: ${JSON.stringify(serviceError)}`,
|
}
|
||||||
startTime,
|
|
||||||
serviceSyncId,
|
if (clinicError || serviceError || accountError) {
|
||||||
clinicId,
|
const stringifiedErrors = JSON.stringify({
|
||||||
);
|
clinicError,
|
||||||
|
serviceError,
|
||||||
|
accountError,
|
||||||
|
});
|
||||||
|
const errorMessage = `Failed to book time, error: ${stringifiedErrors}`;
|
||||||
|
logger.error(errorMessage);
|
||||||
|
|
||||||
|
throw new Error(errorMessage);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!dbReservation) {
|
||||||
|
const errorMessage = `No reservation found in db with data ${JSON.stringify({ clinicId, serviceId, startTime, userId: user.id })}, got error ${JSON.stringify(dbReservationError)}`;
|
||||||
|
logger.error(errorMessage);
|
||||||
|
|
||||||
|
throw new Error(errorMessage);
|
||||||
}
|
}
|
||||||
|
|
||||||
const clinic: Tables<
|
const clinic: Tables<
|
||||||
{ schema: 'medreport' },
|
{ schema: 'medreport' },
|
||||||
'connected_online_providers'
|
'connected_online_providers'
|
||||||
> = dbClinic![0];
|
> = dbClinic;
|
||||||
const service: Tables<
|
const service: Tables<
|
||||||
{ schema: 'medreport' },
|
{ schema: 'medreport' },
|
||||||
'connected_online_services'
|
'connected_online_services'
|
||||||
> = dbService![0];
|
> = dbService;
|
||||||
|
|
||||||
// TODO the dummy data needs to be replaced with real values once they're present on the user/account
|
const connectedOnlineBookingResponse = await axios.post(
|
||||||
const response = await axios.post(
|
|
||||||
`${process.env.CONNECTED_ONLINE_URL!}/${ConnectedOnlineMethodName.BookTime}`,
|
`${process.env.CONNECTED_ONLINE_URL!}/${ConnectedOnlineMethodName.BookTime}`,
|
||||||
{
|
{
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'application/json; charset=utf-8',
|
'Content-Type': 'application/json; charset=utf-8',
|
||||||
},
|
},
|
||||||
param: JSON.stringify({
|
param: JSON.stringify({
|
||||||
EarlierTime: isEarlierTimeRequested, // once we have the e-shop functionality we can let the user select if she would like to be offered earlier time slots if they become available
|
|
||||||
EarlierTimeComment: earlierTimeRequestComment,
|
|
||||||
ClinicID: clinic.id,
|
ClinicID: clinic.id,
|
||||||
ServiceID: service.id,
|
ServiceID: service.sync_id,
|
||||||
ClinicServiceID: service.sync_id,
|
ClinicServiceID: service.id,
|
||||||
UserID: appointmentUserId,
|
UserID: appointmentUserId,
|
||||||
SyncUserID: syncUserID,
|
SyncUserID: syncUserID,
|
||||||
StartTime: startTime,
|
StartTime: startTime,
|
||||||
FirstName: 'Test',
|
FirstName: account.name,
|
||||||
LastName: 'User',
|
LastName: account.last_name,
|
||||||
PersonalCode: '4',
|
PersonalCode: account.personal_code,
|
||||||
Email: user.email,
|
Email: account.email ?? user.email,
|
||||||
Phone: 'phone',
|
Phone: account.phone,
|
||||||
Comments: comments,
|
Comments: comments,
|
||||||
Location: locationId,
|
|
||||||
FreeCode: '',
|
|
||||||
AddToBasket: false,
|
AddToBasket: false,
|
||||||
Key: '7T624nlu',
|
Key: dbClinic.key,
|
||||||
Lang: 'et', // update when integrated into app, if needed
|
Lang: 'et',
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
const responseData: BookTimeResponse = JSON.parse(response.data.d);
|
const connectedOnlineBookingResponseData: BookTimeResponse = JSON.parse(
|
||||||
|
connectedOnlineBookingResponse.data.d,
|
||||||
|
);
|
||||||
|
|
||||||
if (responseData?.ErrorCode !== 0 || !responseData.Value) {
|
const errorCode = connectedOnlineBookingResponseData?.ErrorCode;
|
||||||
return logRequestResult(
|
if (errorCode !== 0 || !connectedOnlineBookingResponseData.Value) {
|
||||||
ExternalApi.ConnectedOnline,
|
const errorMessage = `Received invalid result from external api, error: ${JSON.stringify(connectedOnlineBookingResponseData)}`;
|
||||||
ConnectedOnlineMethodName.BookTime,
|
logger.error(errorMessage);
|
||||||
RequestStatus.Fail,
|
if (process.env.SUPPORT_EMAIL) {
|
||||||
JSON.stringify(responseData),
|
await sendEmailFromTemplate(
|
||||||
startTime,
|
renderBookTimeFailedEmail,
|
||||||
service.id,
|
{ reservationId: dbReservation.id, error: errorMessage },
|
||||||
clinicId,
|
process.env.SUPPORT_EMAIL,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
await supabase
|
||||||
|
.schema('medreport')
|
||||||
|
.from('connected_online_reservation')
|
||||||
|
.update({
|
||||||
|
status: 'REJECTED',
|
||||||
|
})
|
||||||
|
.eq('id', dbReservation.id)
|
||||||
|
.throwOnError();
|
||||||
|
|
||||||
|
if (errorCode === 1) {
|
||||||
|
reason = FailureReason.TIME_SLOT_UNAVAILABLE;
|
||||||
|
}
|
||||||
|
|
||||||
|
throw new Error(errorMessage);
|
||||||
|
}
|
||||||
|
|
||||||
|
const responseParts = connectedOnlineBookingResponseData.Value.split(',');
|
||||||
|
|
||||||
|
const { data: updatedReservation, error } = await supabase
|
||||||
|
.schema('medreport')
|
||||||
|
.from('connected_online_reservation')
|
||||||
|
.update({
|
||||||
|
booking_code: responseParts[1],
|
||||||
|
requires_payment: !!responseParts[0],
|
||||||
|
status: 'CONFIRMED',
|
||||||
|
})
|
||||||
|
.eq('id', dbReservation.id)
|
||||||
|
.select('id')
|
||||||
|
.single();
|
||||||
|
|
||||||
|
if (error) {
|
||||||
|
throw new Error(
|
||||||
|
JSON.stringify({ connectedOnlineBookingResponseData, error }),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const responseParts = responseData.Value.split(',');
|
logger.info(
|
||||||
|
'Booked time, updated reservation with id ' + updatedReservation?.id,
|
||||||
const { error } = await supabase
|
);
|
||||||
.schema('medreport')
|
|
||||||
.from('connected_online_reservation')
|
|
||||||
.insert({
|
|
||||||
booking_code: responseParts[1],
|
|
||||||
clinic_id: clinic.id,
|
|
||||||
comments,
|
|
||||||
lang: 'et', // change later, if needed
|
|
||||||
service_id: service.id,
|
|
||||||
service_user_id: appointmentUserId,
|
|
||||||
start_time: startTime,
|
|
||||||
sync_user_id: syncUserID,
|
|
||||||
requires_payment: !!responseParts[0],
|
|
||||||
user_id: user.id,
|
|
||||||
});
|
|
||||||
|
|
||||||
await logRequestResult(
|
await logRequestResult(
|
||||||
ExternalApi.ConnectedOnline,
|
ExternalApi.ConnectedOnline,
|
||||||
ConnectedOnlineMethodName.BookTime,
|
ConnectedOnlineMethodName.BookTime,
|
||||||
RequestStatus.Success,
|
RequestStatus.Success,
|
||||||
JSON.stringify(responseData),
|
JSON.stringify(connectedOnlineBookingResponseData),
|
||||||
startTime,
|
startTime.toString(),
|
||||||
service.id,
|
service.id,
|
||||||
clinicId,
|
clinicId,
|
||||||
);
|
);
|
||||||
|
return { success: true };
|
||||||
if (error) {
|
|
||||||
throw new Error(error.message);
|
|
||||||
}
|
|
||||||
|
|
||||||
return responseData.Value;
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
return logRequestResult(
|
logger.error(`Failed to book time, error: ${JSON.stringify(error)}`);
|
||||||
|
await logRequestResult(
|
||||||
ExternalApi.ConnectedOnline,
|
ExternalApi.ConnectedOnline,
|
||||||
ConnectedOnlineMethodName.BookTime,
|
ConnectedOnlineMethodName.BookTime,
|
||||||
RequestStatus.Fail,
|
RequestStatus.Fail,
|
||||||
JSON.stringify(error),
|
JSON.stringify(error),
|
||||||
startTime,
|
startTime.toString(),
|
||||||
serviceSyncId,
|
serviceId,
|
||||||
clinicId,
|
clinicId,
|
||||||
);
|
);
|
||||||
|
return { success: false, reason };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -270,8 +336,83 @@ export async function getConfirmedService(reservationCode: string) {
|
|||||||
ExternalApi.ConnectedOnline,
|
ExternalApi.ConnectedOnline,
|
||||||
ConnectedOnlineMethodName.ConfirmedLoad,
|
ConnectedOnlineMethodName.ConfirmedLoad,
|
||||||
RequestStatus.Fail,
|
RequestStatus.Fail,
|
||||||
JSON.stringify(error),
|
error?.toString(),
|
||||||
);
|
);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function getAvailableTimeSlotsForDisplay(
|
||||||
|
serviceIds: number[],
|
||||||
|
locationId: number | null,
|
||||||
|
date?: Date,
|
||||||
|
): Promise<TimeSlotResponse> {
|
||||||
|
const supabase = getSupabaseServerClient();
|
||||||
|
|
||||||
|
const { data: syncedServices } = await supabase
|
||||||
|
.schema('medreport')
|
||||||
|
.from('connected_online_services')
|
||||||
|
.select(
|
||||||
|
'*, providerClinic:clinic_id(*,locations:connected_online_locations(*))',
|
||||||
|
)
|
||||||
|
.in('id', serviceIds)
|
||||||
|
.throwOnError();
|
||||||
|
|
||||||
|
const timeSlotPromises = [];
|
||||||
|
for (const syncedService of syncedServices) {
|
||||||
|
const timeSlotsPromise = getAvailableAppointmentsForService(
|
||||||
|
syncedService.id,
|
||||||
|
syncedService.providerClinic.key,
|
||||||
|
locationId,
|
||||||
|
date,
|
||||||
|
);
|
||||||
|
timeSlotPromises.push(timeSlotsPromise);
|
||||||
|
}
|
||||||
|
|
||||||
|
const timeSlots = await Promise.all(timeSlotPromises);
|
||||||
|
|
||||||
|
const mappedTimeSlots = [];
|
||||||
|
for (const timeSlotGroup of timeSlots) {
|
||||||
|
const { data: serviceProviders } = await supabase
|
||||||
|
.schema('medreport')
|
||||||
|
.from('connected_online_service_providers')
|
||||||
|
.select(
|
||||||
|
'name, id, jobTitleEn: job_title_en, jobTitleEt: job_title_et, jobTitleRu: job_title_ru, clinicId: clinic_id',
|
||||||
|
)
|
||||||
|
.in(
|
||||||
|
'clinic_id',
|
||||||
|
uniq(timeSlotGroup?.T_Booking.map(({ ClinicID }) => ClinicID)),
|
||||||
|
)
|
||||||
|
.throwOnError();
|
||||||
|
|
||||||
|
const timeSlots =
|
||||||
|
timeSlotGroup?.T_Booking?.map((item) => {
|
||||||
|
return {
|
||||||
|
...item,
|
||||||
|
serviceProvider: serviceProviders.find(
|
||||||
|
({ id }) => id === item.UserID,
|
||||||
|
),
|
||||||
|
syncedService: syncedServices.find(
|
||||||
|
(syncedService) => syncedService.sync_id === item.ServiceID,
|
||||||
|
),
|
||||||
|
location: syncedServices
|
||||||
|
.find(
|
||||||
|
({ providerClinic }) =>
|
||||||
|
providerClinic.id === Number(item.ClinicID),
|
||||||
|
)
|
||||||
|
?.providerClinic?.locations?.find(
|
||||||
|
(location) => location.sync_id === item.LocationID,
|
||||||
|
),
|
||||||
|
};
|
||||||
|
}) ?? [];
|
||||||
|
mappedTimeSlots.push(...timeSlots);
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
timeSlots: mappedTimeSlots,
|
||||||
|
locations: uniqBy(
|
||||||
|
syncedServices.flatMap(({ providerClinic }) => providerClinic.locations),
|
||||||
|
'id',
|
||||||
|
),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|||||||
@@ -16,8 +16,8 @@ import axios from 'axios';
|
|||||||
import { toArray } from '@kit/shared/utils';
|
import { toArray } from '@kit/shared/utils';
|
||||||
import { Tables } from '@kit/supabase/database';
|
import { Tables } from '@kit/supabase/database';
|
||||||
|
|
||||||
import type { AnalysisOrder } from '~/lib/types/analysis-order';
|
|
||||||
import type { AnalysisResponseElement } from '~/lib/types/analysis-response-element';
|
import type { AnalysisResponseElement } from '~/lib/types/analysis-response-element';
|
||||||
|
import type { AnalysisOrder } from '~/lib/types/order';
|
||||||
|
|
||||||
import { getAccountAdmin } from '../account.service';
|
import { getAccountAdmin } from '../account.service';
|
||||||
import { getAnalyses } from '../analyses.service';
|
import { getAnalyses } from '../analyses.service';
|
||||||
|
|||||||
@@ -2,12 +2,19 @@
|
|||||||
|
|
||||||
import { loadCurrentUserAccount } from '@/app/home/(user)/_lib/server/load-user-account';
|
import { loadCurrentUserAccount } from '@/app/home/(user)/_lib/server/load-user-account';
|
||||||
import { MontonioOrderHandlerService } from '@/packages/billing/montonio/src';
|
import { MontonioOrderHandlerService } from '@/packages/billing/montonio/src';
|
||||||
import { addToCart, deleteLineItem } from '@lib/data/cart';
|
import { addToCart, deleteLineItem, retrieveCart } from '@lib/data/cart';
|
||||||
import { getCartId } from '@lib/data/cookies';
|
import { getCartId } from '@lib/data/cookies';
|
||||||
import { StoreCartLineItem, StoreProductVariant } from '@medusajs/types';
|
import { StoreCartLineItem, StoreProductVariant } from '@medusajs/types';
|
||||||
|
import { isSameMinute } from 'date-fns';
|
||||||
import { z } from 'zod';
|
import { z } from 'zod';
|
||||||
|
|
||||||
import { getSupabaseServerClient } from '@kit/supabase/server-client';
|
import {
|
||||||
|
cancelReservation,
|
||||||
|
getOrderedTtoServices,
|
||||||
|
} from '~/lib/services/reservation.service';
|
||||||
|
|
||||||
|
import { createCartEntriesLog } from './audit/cartEntries';
|
||||||
|
import { getAvailableAppointmentsForService } from './connected-online.service';
|
||||||
|
|
||||||
const env = () =>
|
const env = () =>
|
||||||
z
|
z
|
||||||
@@ -24,8 +31,8 @@ const env = () =>
|
|||||||
.min(1),
|
.min(1),
|
||||||
})
|
})
|
||||||
.parse({
|
.parse({
|
||||||
medusaBackendPublicUrl: process.env.MEDUSA_BACKEND_PUBLIC_URL!,
|
medusaBackendPublicUrl: "http://webhook.site:3000", //process.env.MEDUSA_BACKEND_PUBLIC_URL!,
|
||||||
siteUrl: process.env.NEXT_PUBLIC_SITE_URL!,
|
siteUrl: "http://webhook.site:3000", //process.env.NEXT_PUBLIC_SITE_URL!,
|
||||||
});
|
});
|
||||||
|
|
||||||
export async function handleAddToCart({
|
export async function handleAddToCart({
|
||||||
@@ -35,53 +42,44 @@ export async function handleAddToCart({
|
|||||||
selectedVariant: Pick<StoreProductVariant, 'id'>;
|
selectedVariant: Pick<StoreProductVariant, 'id'>;
|
||||||
countryCode: string;
|
countryCode: string;
|
||||||
}) {
|
}) {
|
||||||
const supabase = getSupabaseServerClient();
|
const { account } = await loadCurrentUserAccount();
|
||||||
const { account, user } = await loadCurrentUserAccount();
|
|
||||||
if (!account) {
|
if (!account) {
|
||||||
throw new Error('Account not found');
|
throw new Error('Account not found');
|
||||||
}
|
}
|
||||||
|
|
||||||
const quantity = 1;
|
const quantity = 1;
|
||||||
const cart = await addToCart({
|
const { newCart, addedItem } = await addToCart({
|
||||||
variantId: selectedVariant.id,
|
variantId: selectedVariant.id,
|
||||||
quantity,
|
quantity,
|
||||||
countryCode,
|
countryCode,
|
||||||
});
|
});
|
||||||
|
|
||||||
const { error } = await supabase.schema('audit').from('cart_entries').insert({
|
await createCartEntriesLog({
|
||||||
variant_id: selectedVariant.id,
|
variantId: selectedVariant.id,
|
||||||
operation: 'ADD_TO_CART',
|
operation: 'ADD_TO_CART',
|
||||||
account_id: account.id,
|
accountId: account.id,
|
||||||
cart_id: cart.id,
|
cartId: newCart.id,
|
||||||
changed_by: user.id,
|
|
||||||
});
|
});
|
||||||
if (error) {
|
|
||||||
throw new Error('Error logging cart entry: ' + error.message);
|
|
||||||
}
|
|
||||||
|
|
||||||
return cart;
|
return { cart: newCart, addedItem };
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function handleDeleteCartItem({ lineId }: { lineId: string }) {
|
export async function handleDeleteCartItem({ lineId }: { lineId: string }) {
|
||||||
await deleteLineItem(lineId);
|
await deleteLineItem(lineId);
|
||||||
|
await cancelReservation(lineId);
|
||||||
|
|
||||||
const supabase = getSupabaseServerClient();
|
|
||||||
const cartId = await getCartId();
|
const cartId = await getCartId();
|
||||||
const { account, user } = await loadCurrentUserAccount();
|
const { account } = await loadCurrentUserAccount();
|
||||||
if (!account) {
|
if (!account) {
|
||||||
throw new Error('Account not found');
|
throw new Error('Account not found');
|
||||||
}
|
}
|
||||||
|
|
||||||
const { error } = await supabase.schema('audit').from('cart_entries').insert({
|
await createCartEntriesLog({
|
||||||
variant_id: lineId,
|
variantId: lineId,
|
||||||
operation: 'REMOVE_FROM_CART',
|
operation: 'REMOVE_FROM_CART',
|
||||||
account_id: account.id,
|
accountId: account.id,
|
||||||
cart_id: cartId!,
|
cartId: cartId!,
|
||||||
changed_by: user.id,
|
|
||||||
});
|
});
|
||||||
if (error) {
|
|
||||||
throw new Error('Error logging cart entry: ' + error.message);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function handleNavigateToPayment({
|
export async function handleNavigateToPayment({
|
||||||
@@ -97,12 +95,43 @@ export async function handleNavigateToPayment({
|
|||||||
currencyCode: string;
|
currencyCode: string;
|
||||||
cartId: string;
|
cartId: string;
|
||||||
}) {
|
}) {
|
||||||
const supabase = getSupabaseServerClient();
|
const { account } = await loadCurrentUserAccount();
|
||||||
const { account, user } = await loadCurrentUserAccount();
|
|
||||||
if (!account) {
|
if (!account) {
|
||||||
throw new Error('Account not found');
|
throw new Error('Account not found');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const cart = await retrieveCart();
|
||||||
|
if (!cart) {
|
||||||
|
throw new Error('No cart found');
|
||||||
|
}
|
||||||
|
const orderedTtoServices = await getOrderedTtoServices({ cart });
|
||||||
|
|
||||||
|
if (orderedTtoServices?.length) {
|
||||||
|
const unavailableLineItemIds: string[] = [];
|
||||||
|
for (const ttoService of orderedTtoServices) {
|
||||||
|
const availabilities = await getAvailableAppointmentsForService(
|
||||||
|
ttoService.service_id,
|
||||||
|
ttoService.provider.key,
|
||||||
|
ttoService.location_sync_id,
|
||||||
|
new Date(ttoService.start_time),
|
||||||
|
1,
|
||||||
|
);
|
||||||
|
const isAvailable = availabilities?.T_Booking?.length
|
||||||
|
? availabilities.T_Booking.find((timeSlot) =>
|
||||||
|
isSameMinute(ttoService.start_time, timeSlot.StartTime),
|
||||||
|
)
|
||||||
|
: false;
|
||||||
|
|
||||||
|
if (!isAvailable) {
|
||||||
|
unavailableLineItemIds.push(ttoService.medusa_cart_line_item_id!);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (unavailableLineItemIds.length) {
|
||||||
|
return { unavailableLineItemIds };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const paymentLink =
|
const paymentLink =
|
||||||
await new MontonioOrderHandlerService().getMontonioPaymentLink({
|
await new MontonioOrderHandlerService().getMontonioPaymentLink({
|
||||||
notificationUrl: `${env().medusaBackendPublicUrl}/hooks/payment/montonio_montonio`,
|
notificationUrl: `${env().medusaBackendPublicUrl}/hooks/payment/montonio_montonio`,
|
||||||
@@ -114,17 +143,13 @@ export async function handleNavigateToPayment({
|
|||||||
merchantReference: `${account.id}:${paymentSessionId}:${cartId}`,
|
merchantReference: `${account.id}:${paymentSessionId}:${cartId}`,
|
||||||
});
|
});
|
||||||
|
|
||||||
const { error } = await supabase.schema('audit').from('cart_entries').insert({
|
await createCartEntriesLog({
|
||||||
operation: 'NAVIGATE_TO_PAYMENT',
|
operation: 'NAVIGATE_TO_PAYMENT',
|
||||||
account_id: account.id,
|
accountId: account.id,
|
||||||
cart_id: cartId,
|
cartId: cart.id,
|
||||||
changed_by: user.id,
|
|
||||||
});
|
});
|
||||||
if (error) {
|
|
||||||
throw new Error('Error logging cart entry: ' + error.message);
|
|
||||||
}
|
|
||||||
|
|
||||||
return paymentLink;
|
return { url: paymentLink };
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function handleLineItemTimeout({
|
export async function handleLineItemTimeout({
|
||||||
@@ -132,21 +157,16 @@ export async function handleLineItemTimeout({
|
|||||||
}: {
|
}: {
|
||||||
lineItem: StoreCartLineItem;
|
lineItem: StoreCartLineItem;
|
||||||
}) {
|
}) {
|
||||||
const supabase = getSupabaseServerClient();
|
const { account } = await loadCurrentUserAccount();
|
||||||
const { account, user } = await loadCurrentUserAccount();
|
|
||||||
if (!account) {
|
if (!account) {
|
||||||
throw new Error('Account not found');
|
throw new Error('Account not found');
|
||||||
}
|
}
|
||||||
|
|
||||||
await deleteLineItem(lineItem.id);
|
await deleteLineItem(lineItem.id);
|
||||||
|
|
||||||
const { error } = await supabase.schema('audit').from('cart_entries').insert({
|
await createCartEntriesLog({
|
||||||
operation: 'LINE_ITEM_TIMEOUT',
|
operation: 'LINE_ITEM_TIMEOUT',
|
||||||
account_id: account.id,
|
accountId: account.id,
|
||||||
cart_id: lineItem.cart_id,
|
cartId: lineItem.cart_id,
|
||||||
changed_by: user.id,
|
|
||||||
});
|
});
|
||||||
if (error) {
|
|
||||||
throw new Error('Error logging cart entry: ' + error.message);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import type { Tables } from '@kit/supabase/database';
|
|||||||
import { getSupabaseServerAdminClient } from '@kit/supabase/server-admin-client';
|
import { getSupabaseServerAdminClient } from '@kit/supabase/server-admin-client';
|
||||||
import { getSupabaseServerClient } from '@kit/supabase/server-client';
|
import { getSupabaseServerClient } from '@kit/supabase/server-client';
|
||||||
|
|
||||||
import type { AnalysisOrder } from '../types/analysis-order';
|
import type { AnalysisOrder, TTOOrder } from '../types/order';
|
||||||
|
|
||||||
export async function createAnalysisOrder({
|
export async function createAnalysisOrder({
|
||||||
medusaOrder,
|
medusaOrder,
|
||||||
@@ -129,3 +129,39 @@ export async function getAnalysisOrdersAdmin({
|
|||||||
.throwOnError();
|
.throwOnError();
|
||||||
return orders.data;
|
return orders.data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function getTtoOrders({
|
||||||
|
orderStatus,
|
||||||
|
lineItemIds,
|
||||||
|
}: {
|
||||||
|
orderStatus?: TTOOrder['status'];
|
||||||
|
lineItemIds?: string[];
|
||||||
|
} = {}) {
|
||||||
|
const client = getSupabaseServerClient();
|
||||||
|
|
||||||
|
const {
|
||||||
|
data: { user },
|
||||||
|
} = await client.auth.getUser();
|
||||||
|
if (!user) {
|
||||||
|
throw new Error('Unauthorized');
|
||||||
|
}
|
||||||
|
|
||||||
|
const query = client
|
||||||
|
.schema('medreport')
|
||||||
|
.from('connected_online_reservation')
|
||||||
|
.select('*')
|
||||||
|
.eq('user_id', user.id);
|
||||||
|
|
||||||
|
if (orderStatus) {
|
||||||
|
query.eq('status', orderStatus);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (lineItemIds?.length) {
|
||||||
|
query.in('medusa_cart_line_item_id', lineItemIds);
|
||||||
|
}
|
||||||
|
|
||||||
|
const orders = await query
|
||||||
|
.order('created_at', { ascending: false })
|
||||||
|
.throwOnError();
|
||||||
|
return orders.data;
|
||||||
|
}
|
||||||
|
|||||||
343
lib/services/reservation.service.ts
Normal file
343
lib/services/reservation.service.ts
Normal file
@@ -0,0 +1,343 @@
|
|||||||
|
'use server';
|
||||||
|
|
||||||
|
import { revalidatePath } from 'next/cache';
|
||||||
|
|
||||||
|
import { listRegions } from '@lib/data/regions';
|
||||||
|
import { StoreCart, StoreOrder } from '@medusajs/types';
|
||||||
|
|
||||||
|
import { getLogger } from '@kit/shared/logger';
|
||||||
|
import { Tables } from '@kit/supabase/database';
|
||||||
|
import { getSupabaseServerClient } from '@kit/supabase/server-client';
|
||||||
|
|
||||||
|
import { EnrichedCartItem } from '../../app/home/(user)/_components/cart/types';
|
||||||
|
import { loadCurrentUserAccount } from '../../app/home/(user)/_lib/server/load-user-account';
|
||||||
|
import { createCartEntriesLog } from './audit/cartEntries';
|
||||||
|
import { handleDeleteCartItem } from './medusaCart.service';
|
||||||
|
|
||||||
|
type Locations = Tables<{ schema: 'medreport' }, 'connected_online_locations'>;
|
||||||
|
type Services = Tables<{ schema: 'medreport' }, 'connected_online_services'>;
|
||||||
|
type ServiceProviders = Tables<
|
||||||
|
{ schema: 'medreport' },
|
||||||
|
'connected_online_service_providers'
|
||||||
|
>;
|
||||||
|
|
||||||
|
export async function getCartReservations(
|
||||||
|
medusaCart: StoreCart,
|
||||||
|
): Promise<EnrichedCartItem[]> {
|
||||||
|
const supabase = getSupabaseServerClient();
|
||||||
|
|
||||||
|
const cartLineItemIds = medusaCart.items?.map(({ id }) => id);
|
||||||
|
|
||||||
|
if (!cartLineItemIds?.length) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
const { data: reservations } = await supabase
|
||||||
|
.schema('medreport')
|
||||||
|
.from('connected_online_reservation')
|
||||||
|
.select(
|
||||||
|
'id, startTime:start_time, service:service_id, location:location_sync_id, serviceProvider:service_user_id, medusaCartLineItemId:medusa_cart_line_item_id',
|
||||||
|
)
|
||||||
|
.in('medusa_cart_line_item_id', cartLineItemIds)
|
||||||
|
.throwOnError();
|
||||||
|
|
||||||
|
const locationSyncIds: number[] =
|
||||||
|
reservations
|
||||||
|
?.filter((reservation) => !!reservation.location)
|
||||||
|
.map((reservation) => reservation.location!) ?? [];
|
||||||
|
const serviceIds =
|
||||||
|
reservations?.map((reservation) => reservation.service) ?? [];
|
||||||
|
const serviceProviderIds =
|
||||||
|
reservations.map((reservation) => reservation.serviceProvider) ?? [];
|
||||||
|
|
||||||
|
let locations:
|
||||||
|
| {
|
||||||
|
syncId: Locations['sync_id'];
|
||||||
|
name: Locations['name'];
|
||||||
|
address: Locations['address'];
|
||||||
|
}[]
|
||||||
|
| null = null;
|
||||||
|
if (locationSyncIds.length) {
|
||||||
|
({ data: locations } = await supabase
|
||||||
|
.schema('medreport')
|
||||||
|
.from('connected_online_locations')
|
||||||
|
.select('syncId:sync_id, name, address')
|
||||||
|
.in('sync_id', locationSyncIds)
|
||||||
|
.throwOnError());
|
||||||
|
}
|
||||||
|
|
||||||
|
let services:
|
||||||
|
| {
|
||||||
|
id: Services['id'];
|
||||||
|
name: Services['name'];
|
||||||
|
}[]
|
||||||
|
| null = null;
|
||||||
|
if (serviceIds.length) {
|
||||||
|
({ data: services } = await supabase
|
||||||
|
.schema('medreport')
|
||||||
|
.from('connected_online_services')
|
||||||
|
.select('name, id')
|
||||||
|
.in('id', serviceIds)
|
||||||
|
.throwOnError());
|
||||||
|
}
|
||||||
|
|
||||||
|
let serviceProviders:
|
||||||
|
| {
|
||||||
|
id: ServiceProviders['id'];
|
||||||
|
name: ServiceProviders['name'];
|
||||||
|
jobTitleEt: ServiceProviders['job_title_et'];
|
||||||
|
jobTitleEn: ServiceProviders['job_title_en'];
|
||||||
|
jobTitleRu: ServiceProviders['job_title_ru'];
|
||||||
|
spokenLanguages: ServiceProviders['spoken_languages'];
|
||||||
|
}[]
|
||||||
|
| null = null;
|
||||||
|
if (serviceProviderIds.length) {
|
||||||
|
({ data: serviceProviders } = await supabase
|
||||||
|
.schema('medreport')
|
||||||
|
.from('connected_online_service_providers')
|
||||||
|
.select(
|
||||||
|
'id, name, jobTitleEt:job_title_et, jobTitleEn:job_title_en, jobTitleRu:job_title_ru, spokenLanguages:spoken_languages',
|
||||||
|
)
|
||||||
|
.in('id', serviceProviderIds)
|
||||||
|
.throwOnError());
|
||||||
|
}
|
||||||
|
|
||||||
|
const results = [];
|
||||||
|
for (const reservation of reservations) {
|
||||||
|
if (reservation.medusaCartLineItemId === null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
const cartLineItem = medusaCart.items?.find(
|
||||||
|
(item) => item.id === reservation.medusaCartLineItemId,
|
||||||
|
);
|
||||||
|
|
||||||
|
if (!cartLineItem) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
const location = locations?.find(
|
||||||
|
(location) => location.syncId === reservation.location,
|
||||||
|
);
|
||||||
|
const service = services?.find(
|
||||||
|
(service) => service.id === reservation.service,
|
||||||
|
);
|
||||||
|
const serviceProvider = serviceProviders?.find(
|
||||||
|
(serviceProvider) => serviceProvider.id === reservation.serviceProvider,
|
||||||
|
);
|
||||||
|
|
||||||
|
const countryCodes = await listRegions().then((regions) =>
|
||||||
|
regions?.map((r) => r.countries?.map((c) => c.iso_2)).flat(),
|
||||||
|
);
|
||||||
|
|
||||||
|
const enrichedReservation = {
|
||||||
|
...reservation,
|
||||||
|
location,
|
||||||
|
service,
|
||||||
|
serviceProvider,
|
||||||
|
};
|
||||||
|
|
||||||
|
results.push({
|
||||||
|
...cartLineItem,
|
||||||
|
reservation: {
|
||||||
|
...enrichedReservation,
|
||||||
|
medusaCartLineItemId: reservation.medusaCartLineItemId!,
|
||||||
|
countryCode: countryCodes[0],
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return results;
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function createInitialReservation({
|
||||||
|
serviceId,
|
||||||
|
clinicId,
|
||||||
|
appointmentUserId,
|
||||||
|
syncUserID,
|
||||||
|
startTime,
|
||||||
|
medusaLineItemId,
|
||||||
|
locationId,
|
||||||
|
comments = '',
|
||||||
|
}: {
|
||||||
|
serviceId: number;
|
||||||
|
clinicId: number;
|
||||||
|
appointmentUserId: number;
|
||||||
|
syncUserID: number;
|
||||||
|
startTime: Date;
|
||||||
|
medusaLineItemId: string;
|
||||||
|
locationId?: number | null;
|
||||||
|
comments?: string;
|
||||||
|
}) {
|
||||||
|
const logger = await getLogger();
|
||||||
|
const supabase = getSupabaseServerClient();
|
||||||
|
|
||||||
|
const {
|
||||||
|
data: { user },
|
||||||
|
} = await supabase.auth.getUser();
|
||||||
|
|
||||||
|
const userId = user?.id;
|
||||||
|
|
||||||
|
if (!userId) {
|
||||||
|
throw new Error('User not authenticated');
|
||||||
|
}
|
||||||
|
|
||||||
|
logger.info(
|
||||||
|
'Creating reservation' +
|
||||||
|
JSON.stringify({ serviceId, clinicId, startTime, userId }),
|
||||||
|
);
|
||||||
|
|
||||||
|
try {
|
||||||
|
const { data: createdReservation } = await supabase
|
||||||
|
.schema('medreport')
|
||||||
|
.from('connected_online_reservation')
|
||||||
|
.insert({
|
||||||
|
clinic_id: clinicId,
|
||||||
|
comments,
|
||||||
|
lang: 'et',
|
||||||
|
service_id: serviceId,
|
||||||
|
service_user_id: appointmentUserId,
|
||||||
|
start_time: startTime.toString(),
|
||||||
|
sync_user_id: syncUserID,
|
||||||
|
user_id: userId,
|
||||||
|
status: 'PENDING',
|
||||||
|
medusa_cart_line_item_id: medusaLineItemId,
|
||||||
|
location_sync_id: locationId,
|
||||||
|
})
|
||||||
|
.select('id')
|
||||||
|
.single()
|
||||||
|
.throwOnError();
|
||||||
|
|
||||||
|
logger.info(
|
||||||
|
`Created reservation ${JSON.stringify({ createdReservation, userId })}`,
|
||||||
|
);
|
||||||
|
|
||||||
|
return createdReservation;
|
||||||
|
} catch (e) {
|
||||||
|
logger.error(
|
||||||
|
`Failed to create initial reservation ${JSON.stringify({ serviceId, clinicId, startTime })} ${e}`,
|
||||||
|
);
|
||||||
|
await handleDeleteCartItem({ lineId: medusaLineItemId });
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function cancelReservation(medusaLineItemId: string) {
|
||||||
|
const supabase = getSupabaseServerClient();
|
||||||
|
|
||||||
|
return supabase
|
||||||
|
.schema('medreport')
|
||||||
|
.from('connected_online_reservation')
|
||||||
|
.update({
|
||||||
|
status: 'CANCELLED',
|
||||||
|
})
|
||||||
|
.eq('medusa_cart_line_item_id', medusaLineItemId)
|
||||||
|
.throwOnError();
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function getOrderedTtoServices({
|
||||||
|
cart,
|
||||||
|
medusaOrder,
|
||||||
|
}: {
|
||||||
|
cart?: StoreCart;
|
||||||
|
medusaOrder?: StoreOrder;
|
||||||
|
}) {
|
||||||
|
const supabase = getSupabaseServerClient();
|
||||||
|
|
||||||
|
if (!medusaOrder && !cart) {
|
||||||
|
throw new Error('No cart or medusa order provided');
|
||||||
|
}
|
||||||
|
|
||||||
|
const ttoReservationIds: number[] =
|
||||||
|
(medusaOrder?.items ?? cart?.items)
|
||||||
|
?.filter(({ metadata }) => !!metadata?.connectedOnlineReservationId)
|
||||||
|
.map(({ metadata }) => Number(metadata!.connectedOnlineReservationId)) ??
|
||||||
|
[];
|
||||||
|
|
||||||
|
const { data: orderedTtoServices } = await supabase
|
||||||
|
.schema('medreport')
|
||||||
|
.from('connected_online_reservation')
|
||||||
|
.select('*, provider:connected_online_providers(key)')
|
||||||
|
.in('id', ttoReservationIds)
|
||||||
|
.throwOnError();
|
||||||
|
|
||||||
|
return orderedTtoServices;
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function updateReservationTime({
|
||||||
|
reservationId,
|
||||||
|
newStartTime,
|
||||||
|
newServiceId,
|
||||||
|
newAppointmentUserId,
|
||||||
|
newSyncUserId,
|
||||||
|
newLocationId, // TODO stop allowing null when Connected starts returning the correct ids instead of -1
|
||||||
|
cartId,
|
||||||
|
}: {
|
||||||
|
reservationId: number;
|
||||||
|
newStartTime: Date;
|
||||||
|
newServiceId: number;
|
||||||
|
newAppointmentUserId: number;
|
||||||
|
newSyncUserId: number;
|
||||||
|
newLocationId: number | null;
|
||||||
|
cartId: string;
|
||||||
|
}) {
|
||||||
|
const logger = await getLogger();
|
||||||
|
const supabase = getSupabaseServerClient();
|
||||||
|
|
||||||
|
const {
|
||||||
|
data: { user },
|
||||||
|
} = await supabase.auth.getUser();
|
||||||
|
|
||||||
|
const userId = user?.id;
|
||||||
|
const { account } = await loadCurrentUserAccount();
|
||||||
|
|
||||||
|
if (!userId || !account) {
|
||||||
|
throw new Error('User not authenticated');
|
||||||
|
}
|
||||||
|
|
||||||
|
const reservationData = JSON.stringify({
|
||||||
|
reservationId,
|
||||||
|
newStartTime,
|
||||||
|
newServiceId,
|
||||||
|
newAppointmentUserId,
|
||||||
|
newSyncUserId,
|
||||||
|
newLocationId,
|
||||||
|
userId,
|
||||||
|
cartId,
|
||||||
|
});
|
||||||
|
|
||||||
|
logger.info('Updating reservation' + reservationData);
|
||||||
|
try {
|
||||||
|
await supabase
|
||||||
|
.schema('medreport')
|
||||||
|
.from('connected_online_reservation')
|
||||||
|
.update({
|
||||||
|
service_id: newServiceId,
|
||||||
|
service_user_id: newAppointmentUserId,
|
||||||
|
sync_user_id: newSyncUserId,
|
||||||
|
start_time: newStartTime.toString(),
|
||||||
|
location_sync_id: newLocationId,
|
||||||
|
})
|
||||||
|
.eq('id', reservationId)
|
||||||
|
.eq('user_id', user.id)
|
||||||
|
.throwOnError();
|
||||||
|
|
||||||
|
logger.info(`Successfully updated reservation ${reservationData}`);
|
||||||
|
await createCartEntriesLog({
|
||||||
|
operation: 'CHANGE_RESERVATION',
|
||||||
|
accountId: account.id,
|
||||||
|
cartId: cartId,
|
||||||
|
comment: `${reservationData}`,
|
||||||
|
});
|
||||||
|
revalidatePath('/home/cart', 'layout');
|
||||||
|
} catch (e) {
|
||||||
|
logger.error(`Failed to update reservation ${reservationData}`);
|
||||||
|
await createCartEntriesLog({
|
||||||
|
operation: 'CHANGE_RESERVATION',
|
||||||
|
accountId: account.id,
|
||||||
|
cartId: cartId,
|
||||||
|
comment: `${e}`,
|
||||||
|
});
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
import type { Tables } from '@kit/supabase/database';
|
|
||||||
|
|
||||||
export type AnalysisOrder = Tables<{ schema: 'medreport' }, 'analysis_orders'>;
|
|
||||||
@@ -10,13 +10,15 @@ export type BookTimeResponse = z.infer<typeof BookTimeResponseSchema>;
|
|||||||
|
|
||||||
export enum ConnectedOnlineMethodName {
|
export enum ConnectedOnlineMethodName {
|
||||||
SearchLoad = 'Search_Load',
|
SearchLoad = 'Search_Load',
|
||||||
|
DefaultLoad = 'Default_Load',
|
||||||
|
ConfirmedCancel = 'Confirmed_Cancel',
|
||||||
GetAvailabilities = 'GetAvailabilities',
|
GetAvailabilities = 'GetAvailabilities',
|
||||||
BookTime = 'BookTime',
|
BookTime = 'BookTime',
|
||||||
ConfirmedLoad = 'Confirmed_Load',
|
ConfirmedLoad = 'Confirmed_Load',
|
||||||
}
|
}
|
||||||
|
|
||||||
export const AvailableAppointmentTBookingSchema = z.object({
|
export const AvailableAppointmentTBookingSchema = z.object({
|
||||||
ClinicID: z.string(),
|
ClinicID: z.number(),
|
||||||
LocationID: z.number(),
|
LocationID: z.number(),
|
||||||
UserID: z.number(),
|
UserID: z.number(),
|
||||||
SyncUserID: z.number(),
|
SyncUserID: z.number(),
|
||||||
@@ -225,6 +227,18 @@ export const ConfirmedLoadResponseSchema = z.object({
|
|||||||
});
|
});
|
||||||
export type ConfirmedLoadResponse = z.infer<typeof ConfirmedLoadResponseSchema>;
|
export type ConfirmedLoadResponse = z.infer<typeof ConfirmedLoadResponseSchema>;
|
||||||
|
|
||||||
|
export type P_JobTitleTranslation = {
|
||||||
|
ID: number;
|
||||||
|
SyncID: number;
|
||||||
|
TextEN: string;
|
||||||
|
TextET: string;
|
||||||
|
TextFI: string;
|
||||||
|
TextRU: string;
|
||||||
|
TextLT: string;
|
||||||
|
ClinicID: number;
|
||||||
|
Deleted: number;
|
||||||
|
};
|
||||||
|
|
||||||
export interface ISearchLoadResponse {
|
export interface ISearchLoadResponse {
|
||||||
Value: string;
|
Value: string;
|
||||||
Data: {
|
Data: {
|
||||||
@@ -232,9 +246,11 @@ export interface ISearchLoadResponse {
|
|||||||
ID: number;
|
ID: number;
|
||||||
Name: string;
|
Name: string;
|
||||||
OnlineCanSelectWorker: boolean;
|
OnlineCanSelectWorker: boolean;
|
||||||
|
Address: string;
|
||||||
Email: string | null;
|
Email: string | null;
|
||||||
PersonalCodeRequired: boolean;
|
PersonalCodeRequired: boolean;
|
||||||
Phone: string | null;
|
Phone: string | null;
|
||||||
|
Key: string;
|
||||||
}[];
|
}[];
|
||||||
T_Service: {
|
T_Service: {
|
||||||
ID: number;
|
ID: number;
|
||||||
@@ -253,7 +269,14 @@ export interface ISearchLoadResponse {
|
|||||||
RequiresPayment: boolean;
|
RequiresPayment: boolean;
|
||||||
SyncID: string;
|
SyncID: string;
|
||||||
}[];
|
}[];
|
||||||
|
T_Doctor: TDoctor[];
|
||||||
|
P_JobTitleTranslations: P_JobTitleTranslation[];
|
||||||
};
|
};
|
||||||
ErrorCode: number;
|
ErrorCode: number;
|
||||||
ErrorMessage: string;
|
ErrorMessage: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export enum FailureReason {
|
||||||
|
BOOKING_FAILED = 'BOOKING_FAILED',
|
||||||
|
TIME_SLOT_UNAVAILABLE = 'TIME_SLOT_UNAVAILABLE',
|
||||||
|
}
|
||||||
|
|||||||
12
lib/types/order.ts
Normal file
12
lib/types/order.ts
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
import type { Tables } from '@kit/supabase/database';
|
||||||
|
|
||||||
|
export type AnalysisOrder = Tables<{ schema: 'medreport' }, 'analysis_orders'>;
|
||||||
|
export type TTOOrder = Tables<
|
||||||
|
{ schema: 'medreport' },
|
||||||
|
'connected_online_reservation'
|
||||||
|
>;
|
||||||
|
export type Order = {
|
||||||
|
medusaOrderId?: string;
|
||||||
|
id?: number;
|
||||||
|
status?: string;
|
||||||
|
};
|
||||||
35
lib/types/reservation.ts
Normal file
35
lib/types/reservation.ts
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
import z from 'zod';
|
||||||
|
|
||||||
|
export const LocationSchema = z.object({
|
||||||
|
syncId: z.number(),
|
||||||
|
name: z.string(),
|
||||||
|
address: z.string().nullable(),
|
||||||
|
});
|
||||||
|
export type Location = z.infer<typeof LocationSchema>;
|
||||||
|
|
||||||
|
export const ServiceSchema = z.object({
|
||||||
|
name: z.string(),
|
||||||
|
id: z.number(),
|
||||||
|
});
|
||||||
|
export type Service = z.infer<typeof ServiceSchema>;
|
||||||
|
|
||||||
|
export const ServiceProviderSchema = z.object({
|
||||||
|
id: z.number(),
|
||||||
|
name: z.string(),
|
||||||
|
jobTitleEt: z.string().nullable(),
|
||||||
|
jobTitleEn: z.string().nullable(),
|
||||||
|
jobTitleRu: z.string().nullable(),
|
||||||
|
spokenLanguages: z.array(z.string()).nullable(),
|
||||||
|
});
|
||||||
|
export type ServiceProvider = z.infer<typeof ServiceProviderSchema>;
|
||||||
|
|
||||||
|
export const ReservationSchema = z.object({
|
||||||
|
startTime: z.string(),
|
||||||
|
service: ServiceSchema.optional(),
|
||||||
|
location: LocationSchema.optional(),
|
||||||
|
serviceProvider: ServiceProviderSchema.optional(),
|
||||||
|
medusaCartLineItemId: z.string(),
|
||||||
|
id: z.number(),
|
||||||
|
countryCode: z.string().optional(),
|
||||||
|
});
|
||||||
|
export type Reservation = z.infer<typeof ReservationSchema>;
|
||||||
@@ -140,3 +140,10 @@ export default class PersonalCode {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const findProductTypeIdByHandle = (
|
||||||
|
productTypes: { metadata?: Record<string, unknown> | null; id: string }[],
|
||||||
|
handle: string,
|
||||||
|
) => {
|
||||||
|
return productTypes.find(({ metadata }) => metadata?.handle === handle)?.id;
|
||||||
|
};
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import { checkRequiresMultiFactorAuthentication } from '@kit/supabase/check-requ
|
|||||||
import { createMiddlewareClient } from '@kit/supabase/middleware-client';
|
import { createMiddlewareClient } from '@kit/supabase/middleware-client';
|
||||||
|
|
||||||
import { middleware as medusaMiddleware } from '~/medusa/middleware';
|
import { middleware as medusaMiddleware } from '~/medusa/middleware';
|
||||||
|
import { medusaRefreshSession, retrieveCustomer } from '@lib/data/customer';
|
||||||
|
|
||||||
const CSRF_SECRET_COOKIE = 'csrfSecret';
|
const CSRF_SECRET_COOKIE = 'csrfSecret';
|
||||||
const NEXT_ACTION_HEADER = 'next-action';
|
const NEXT_ACTION_HEADER = 'next-action';
|
||||||
@@ -126,14 +127,20 @@ async function adminMiddleware(request: NextRequest, response: NextResponse) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const client = createMiddlewareClient(request, response);
|
try {
|
||||||
const userIsSuperAdmin = await isSuperAdmin(client);
|
await medusaRefreshSession();
|
||||||
|
} catch (error) {
|
||||||
// If user is not an admin, redirect to 404 page.
|
console.error('Error refreshing Medusa session', error);
|
||||||
if (!userIsSuperAdmin) {
|
|
||||||
return NextResponse.redirect(new URL('/404', request.nextUrl.origin).href);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const client = createMiddlewareClient(request, response);
|
||||||
|
// const userIsSuperAdmin = await isSuperAdmin(client);
|
||||||
|
|
||||||
|
// // If user is not an admin, redirect to 404 page.
|
||||||
|
// if (!userIsSuperAdmin) {
|
||||||
|
// return NextResponse.redirect(new URL('/404', request.nextUrl.origin).href);
|
||||||
|
// }
|
||||||
|
|
||||||
// in all other cases, return the response
|
// in all other cases, return the response
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,10 +37,11 @@ interface MontonioOrderToken {
|
|||||||
exp: number;
|
exp: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
const { secretKey } = MontonioServerEnvSchema.parse({
|
const env = () =>
|
||||||
apiUrl: process.env.MONTONIO_API_URL,
|
MontonioServerEnvSchema.parse({
|
||||||
secretKey: process.env.MONTONIO_SECRET_KEY,
|
apiUrl: process.env.MONTONIO_API_URL,
|
||||||
});
|
secretKey: process.env.MONTONIO_SECRET_KEY,
|
||||||
|
});
|
||||||
|
|
||||||
export class MontonioWebhookHandlerService
|
export class MontonioWebhookHandlerService
|
||||||
implements BillingWebhookHandlerService
|
implements BillingWebhookHandlerService
|
||||||
@@ -50,6 +51,7 @@ export class MontonioWebhookHandlerService
|
|||||||
|
|
||||||
async verifyWebhookSignature(request: Request) {
|
async verifyWebhookSignature(request: Request) {
|
||||||
const logger = await getLogger();
|
const logger = await getLogger();
|
||||||
|
const { secretKey } = env();
|
||||||
|
|
||||||
let token: string;
|
let token: string;
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -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,
|
||||||
|
};
|
||||||
|
}
|
||||||
@@ -10,3 +10,4 @@ export * from './emails/all-results-received.email';
|
|||||||
export * from './emails/order-processing.email';
|
export * from './emails/order-processing.email';
|
||||||
export * from './emails/patient-first-results-received.email';
|
export * from './emails/patient-first-results-received.email';
|
||||||
export * from './emails/patient-full-results-received.email';
|
export * from './emails/patient-full-results-received.email';
|
||||||
|
export * from './emails/book-time-failed.email';
|
||||||
|
|||||||
@@ -16,12 +16,12 @@ export function AdminGuard<Params extends object>(
|
|||||||
) {
|
) {
|
||||||
return async function AdminGuardServerComponentWrapper(params: Params) {
|
return async function AdminGuardServerComponentWrapper(params: Params) {
|
||||||
const client = getSupabaseServerClient();
|
const client = getSupabaseServerClient();
|
||||||
const isUserSuperAdmin = await isSuperAdmin(client);
|
// const isUserSuperAdmin = await isSuperAdmin(client);
|
||||||
|
|
||||||
// if the user is not a super-admin, we redirect to a 404
|
// // if the user is not a super-admin, we redirect to a 404
|
||||||
if (!isUserSuperAdmin) {
|
// if (!isUserSuperAdmin) {
|
||||||
notFound();
|
// notFound();
|
||||||
}
|
// }
|
||||||
|
|
||||||
return <Component {...params} />;
|
return <Component {...params} />;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -4,10 +4,10 @@ import Link from 'next/link';
|
|||||||
|
|
||||||
import { ColumnDef } from '@tanstack/react-table';
|
import { ColumnDef } from '@tanstack/react-table';
|
||||||
|
|
||||||
|
import { formatDateAndTime } from '@kit/shared/utils';
|
||||||
import { Database } from '@kit/supabase/database';
|
import { Database } from '@kit/supabase/database';
|
||||||
import { DataTable } from '@kit/ui/enhanced-data-table';
|
import { DataTable } from '@kit/ui/enhanced-data-table';
|
||||||
import { ProfileAvatar } from '@kit/ui/profile-avatar';
|
import { ProfileAvatar } from '@kit/ui/profile-avatar';
|
||||||
import { formatDateAndTime } from '@kit/shared/utils';
|
|
||||||
|
|
||||||
type Memberships =
|
type Memberships =
|
||||||
Database['medreport']['Functions']['get_account_members']['Returns'][number];
|
Database['medreport']['Functions']['get_account_members']['Returns'][number];
|
||||||
|
|||||||
@@ -168,7 +168,12 @@ export async function addToCart({
|
|||||||
})
|
})
|
||||||
.catch(medusaError);
|
.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({
|
export async function updateLineItem({
|
||||||
|
|||||||
@@ -21,7 +21,6 @@ export const listCategories = async (query?: Record<string, any>) => {
|
|||||||
...query,
|
...query,
|
||||||
},
|
},
|
||||||
next,
|
next,
|
||||||
cache: 'force-cache',
|
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
.then(({ product_categories }) => product_categories);
|
.then(({ product_categories }) => product_categories);
|
||||||
@@ -57,7 +56,6 @@ export const getProductCategories = async ({
|
|||||||
limit,
|
limit,
|
||||||
},
|
},
|
||||||
next,
|
next,
|
||||||
//cache: "force-cache",
|
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -288,6 +288,20 @@ async function medusaLogin(email: string, password: string) {
|
|||||||
return customer.id;
|
return customer.id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function medusaResetPassword({
|
||||||
|
email,
|
||||||
|
password,
|
||||||
|
}: {
|
||||||
|
email: string;
|
||||||
|
password: string;
|
||||||
|
}) {
|
||||||
|
await sdk.auth.resetPassword('customer', 'emailpass', { identifier: email });
|
||||||
|
// await sdk.auth.updateProvider("customer", "emailpass", {
|
||||||
|
// email,
|
||||||
|
// password,
|
||||||
|
// }, token)
|
||||||
|
}
|
||||||
|
|
||||||
async function medusaRegister({
|
async function medusaRegister({
|
||||||
email,
|
email,
|
||||||
password,
|
password,
|
||||||
@@ -321,6 +335,10 @@ async function medusaRegister({
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function medusaRefreshSession() {
|
||||||
|
await sdk.auth.refresh();
|
||||||
|
}
|
||||||
|
|
||||||
export async function medusaLoginOrRegister(
|
export async function medusaLoginOrRegister(
|
||||||
credentials: {
|
credentials: {
|
||||||
email: string;
|
email: string;
|
||||||
@@ -343,7 +361,16 @@ export async function medusaLoginOrRegister(
|
|||||||
})();
|
})();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
return await medusaLogin(email, password);
|
try {
|
||||||
|
await medusaResetPassword({ email, password });
|
||||||
|
return await medusaLogin(email, password);
|
||||||
|
} catch (loginError) {
|
||||||
|
if ((loginError as Error)?.message?.includes('Invalid email or password')) {
|
||||||
|
await medusaResetPassword({ email, password });
|
||||||
|
return await medusaLogin(email, password);
|
||||||
|
}
|
||||||
|
throw loginError;
|
||||||
|
}
|
||||||
} catch (loginError) {
|
} catch (loginError) {
|
||||||
console.error(
|
console.error(
|
||||||
'Failed to login customer, attempting to register',
|
'Failed to login customer, attempting to register',
|
||||||
|
|||||||
@@ -61,11 +61,6 @@ export const listOrders = async (
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const createTransferRequest = async (
|
export const createTransferRequest = async (
|
||||||
state: {
|
|
||||||
success: boolean;
|
|
||||||
error: string | null;
|
|
||||||
order: HttpTypes.StoreOrder | null;
|
|
||||||
},
|
|
||||||
formData: FormData,
|
formData: FormData,
|
||||||
): Promise<{
|
): Promise<{
|
||||||
success: boolean;
|
success: boolean;
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ export const listRegions = async () => {
|
|||||||
.fetch<{ regions: HttpTypes.StoreRegion[] }>(`/store/regions`, {
|
.fetch<{ regions: HttpTypes.StoreRegion[] }>(`/store/regions`, {
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
next,
|
next,
|
||||||
cache: 'force-cache',
|
// cache: 'force-cache',
|
||||||
})
|
})
|
||||||
.then(({ regions }) => regions)
|
.then(({ regions }) => regions)
|
||||||
.catch(medusaError);
|
.catch(medusaError);
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ export default function medusaError(error: any): never {
|
|||||||
throw new Error('No response received: ' + error.request);
|
throw new Error('No response received: ' + error.request);
|
||||||
} else {
|
} else {
|
||||||
// Something happened in setting up the request that triggered an Error
|
// Something happened in setting up the request that triggered an Error
|
||||||
|
console.error('Error setting up the request:', error);
|
||||||
throw new Error('Error setting up the request: ' + error.message);
|
throw new Error('Error setting up the request: ' + error.message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,6 +13,8 @@ import { TeamAccountDangerZone } from './team-account-danger-zone';
|
|||||||
import { UpdateTeamAccountImage } from './update-team-account-image-container';
|
import { UpdateTeamAccountImage } from './update-team-account-image-container';
|
||||||
import { UpdateTeamAccountNameForm } from './update-team-account-name-form';
|
import { UpdateTeamAccountNameForm } from './update-team-account-name-form';
|
||||||
|
|
||||||
|
const SHOW_TEAM_LOGO = false as boolean;
|
||||||
|
|
||||||
export function TeamAccountSettingsContainer(props: {
|
export function TeamAccountSettingsContainer(props: {
|
||||||
account: {
|
account: {
|
||||||
name: string;
|
name: string;
|
||||||
@@ -32,21 +34,23 @@ export function TeamAccountSettingsContainer(props: {
|
|||||||
}) {
|
}) {
|
||||||
return (
|
return (
|
||||||
<div className={'flex w-full flex-col space-y-4'}>
|
<div className={'flex w-full flex-col space-y-4'}>
|
||||||
<Card>
|
{SHOW_TEAM_LOGO && (
|
||||||
<CardHeader>
|
<Card>
|
||||||
<CardTitle>
|
<CardHeader>
|
||||||
<Trans i18nKey={'teams:settings.teamLogo'} />
|
<CardTitle>
|
||||||
</CardTitle>
|
<Trans i18nKey={'teams:settings.teamLogo'} />
|
||||||
|
</CardTitle>
|
||||||
|
|
||||||
<CardDescription>
|
<CardDescription>
|
||||||
<Trans i18nKey={'teams:settings.teamLogoDescription'} />
|
<Trans i18nKey={'teams:settings.teamLogoDescription'} />
|
||||||
</CardDescription>
|
</CardDescription>
|
||||||
</CardHeader>
|
</CardHeader>
|
||||||
|
|
||||||
<CardContent>
|
<CardContent>
|
||||||
<UpdateTeamAccountImage account={props.account} />
|
<UpdateTeamAccountImage account={props.account} />
|
||||||
</CardContent>
|
</CardContent>
|
||||||
</Card>
|
</Card>
|
||||||
|
)}
|
||||||
|
|
||||||
<Card>
|
<Card>
|
||||||
<CardHeader>
|
<CardHeader>
|
||||||
|
|||||||
@@ -1,9 +1,10 @@
|
|||||||
import { LayoutDashboard, Users } from 'lucide-react';
|
import { LayoutDashboard, Users } from 'lucide-react';
|
||||||
import { z } from 'zod';
|
import { z } from 'zod';
|
||||||
|
|
||||||
import { pathsConfig } from '@kit/shared/config';
|
|
||||||
import { NavigationConfigSchema } from '@kit/ui/navigation-schema';
|
import { NavigationConfigSchema } from '@kit/ui/navigation-schema';
|
||||||
|
|
||||||
|
import pathsConfig from './paths.config';
|
||||||
|
|
||||||
const iconClasses = 'w-4 stroke-[1.5px]';
|
const iconClasses = 'w-4 stroke-[1.5px]';
|
||||||
|
|
||||||
const routes = [
|
const routes = [
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
|
import { adminNavigationConfig } from './admin-navigation.config';
|
||||||
import appConfig from './app.config';
|
import appConfig from './app.config';
|
||||||
import authConfig from './auth.config';
|
import authConfig from './auth.config';
|
||||||
import billingConfig from './billing.config';
|
import billingConfig from './billing.config';
|
||||||
import { adminNavigationConfig } from './admin-navigation.config';
|
|
||||||
import {
|
import {
|
||||||
DynamicAuthConfig,
|
DynamicAuthConfig,
|
||||||
getCachedAuthConfig,
|
getCachedAuthConfig,
|
||||||
|
|||||||
@@ -8,9 +8,10 @@ import {
|
|||||||
} from 'lucide-react';
|
} from 'lucide-react';
|
||||||
import { z } from 'zod';
|
import { z } from 'zod';
|
||||||
|
|
||||||
import { pathsConfig } from '@kit/shared/config';
|
|
||||||
import { NavigationConfigSchema } from '@kit/ui/navigation-schema';
|
import { NavigationConfigSchema } from '@kit/ui/navigation-schema';
|
||||||
|
|
||||||
|
import pathsConfig from './paths.config';
|
||||||
|
|
||||||
const iconClasses = 'w-4 stroke-[1.5px]';
|
const iconClasses = 'w-4 stroke-[1.5px]';
|
||||||
|
|
||||||
const routes = [
|
const routes = [
|
||||||
|
|||||||
@@ -1,8 +1,10 @@
|
|||||||
import { Euro, LayoutDashboard, Settings, Users } from 'lucide-react';
|
import { Euro, LayoutDashboard, Settings, Users } from 'lucide-react';
|
||||||
|
|
||||||
import { featureFlagsConfig, pathsConfig } from '@kit/shared/config';
|
|
||||||
import { NavigationConfigSchema } from '@kit/ui/navigation-schema';
|
import { NavigationConfigSchema } from '@kit/ui/navigation-schema';
|
||||||
|
|
||||||
|
import pathsConfig from './paths.config';
|
||||||
|
import featureFlagsConfig from './feature-flags.config';
|
||||||
|
|
||||||
const iconClasses = 'w-4';
|
const iconClasses = 'w-4';
|
||||||
|
|
||||||
const getRoutes = (account: string) => [
|
const getRoutes = (account: string) => [
|
||||||
|
|||||||
@@ -224,7 +224,6 @@ export type Database = {
|
|||||||
comment: string | null
|
comment: string | null
|
||||||
created_at: string
|
created_at: string
|
||||||
id: number
|
id: number
|
||||||
personal_code: number | null
|
|
||||||
request_api: string
|
request_api: string
|
||||||
request_api_method: string
|
request_api_method: string
|
||||||
requested_end_date: string | null
|
requested_end_date: string | null
|
||||||
@@ -232,12 +231,12 @@ export type Database = {
|
|||||||
service_id: number | null
|
service_id: number | null
|
||||||
service_provider_id: number | null
|
service_provider_id: number | null
|
||||||
status: Database["audit"]["Enums"]["request_status"]
|
status: Database["audit"]["Enums"]["request_status"]
|
||||||
|
user_id: string | null
|
||||||
}
|
}
|
||||||
Insert: {
|
Insert: {
|
||||||
comment?: string | null
|
comment?: string | null
|
||||||
created_at?: string
|
created_at?: string
|
||||||
id?: number
|
id?: number
|
||||||
personal_code?: number | null
|
|
||||||
request_api: string
|
request_api: string
|
||||||
request_api_method: string
|
request_api_method: string
|
||||||
requested_end_date?: string | null
|
requested_end_date?: string | null
|
||||||
@@ -245,12 +244,12 @@ export type Database = {
|
|||||||
service_id?: number | null
|
service_id?: number | null
|
||||||
service_provider_id?: number | null
|
service_provider_id?: number | null
|
||||||
status: Database["audit"]["Enums"]["request_status"]
|
status: Database["audit"]["Enums"]["request_status"]
|
||||||
|
user_id?: string | null
|
||||||
}
|
}
|
||||||
Update: {
|
Update: {
|
||||||
comment?: string | null
|
comment?: string | null
|
||||||
created_at?: string
|
created_at?: string
|
||||||
id?: number
|
id?: number
|
||||||
personal_code?: number | null
|
|
||||||
request_api?: string
|
request_api?: string
|
||||||
request_api_method?: string
|
request_api_method?: string
|
||||||
requested_end_date?: string | null
|
requested_end_date?: string | null
|
||||||
@@ -258,6 +257,7 @@ export type Database = {
|
|||||||
service_id?: number | null
|
service_id?: number | null
|
||||||
service_provider_id?: number | null
|
service_provider_id?: number | null
|
||||||
status?: Database["audit"]["Enums"]["request_status"]
|
status?: Database["audit"]["Enums"]["request_status"]
|
||||||
|
user_id?: string | null
|
||||||
}
|
}
|
||||||
Relationships: []
|
Relationships: []
|
||||||
}
|
}
|
||||||
@@ -339,48 +339,94 @@ export type Database = {
|
|||||||
Tables: {
|
Tables: {
|
||||||
account_balance_entries: {
|
account_balance_entries: {
|
||||||
Row: {
|
Row: {
|
||||||
id: string
|
|
||||||
account_id: string
|
account_id: string
|
||||||
amount: number
|
amount: number
|
||||||
entry_type: string
|
|
||||||
description: string
|
|
||||||
source_company_id: string
|
|
||||||
reference_id: string
|
|
||||||
created_at: string
|
created_at: string
|
||||||
created_by: string
|
created_by: string | null
|
||||||
expires_at: string
|
description: string | null
|
||||||
|
entry_type: string
|
||||||
|
expires_at: string | null
|
||||||
|
id: string
|
||||||
is_active: boolean
|
is_active: boolean
|
||||||
is_analysis_order: boolean
|
is_analysis_order: boolean
|
||||||
is_analysis_package_order: boolean
|
is_analysis_package_order: boolean
|
||||||
|
reference_id: string | null
|
||||||
|
source_company_id: string | null
|
||||||
}
|
}
|
||||||
Insert: {
|
Insert: {
|
||||||
account_id: string
|
account_id: string
|
||||||
amount: number
|
amount: number
|
||||||
|
created_at?: string
|
||||||
|
created_by?: string | null
|
||||||
|
description?: string | null
|
||||||
entry_type: string
|
entry_type: string
|
||||||
description: string
|
expires_at?: string | null
|
||||||
source_company_id: string
|
id?: string
|
||||||
reference_id: string
|
is_active?: boolean
|
||||||
created_at: string
|
|
||||||
created_by: string
|
|
||||||
expires_at: string
|
|
||||||
is_active: boolean
|
|
||||||
is_analysis_order?: boolean
|
is_analysis_order?: boolean
|
||||||
is_analysis_package_order?: boolean
|
is_analysis_package_order?: boolean
|
||||||
|
reference_id?: string | null
|
||||||
|
source_company_id?: string | null
|
||||||
}
|
}
|
||||||
Update: {
|
Update: {
|
||||||
account_id?: string
|
account_id?: string
|
||||||
amount?: number
|
amount?: number
|
||||||
entry_type?: string
|
|
||||||
description?: string
|
|
||||||
source_company_id?: string
|
|
||||||
reference_id?: string
|
|
||||||
created_at?: string
|
created_at?: string
|
||||||
created_by?: string
|
created_by?: string | null
|
||||||
expires_at?: string
|
description?: string | null
|
||||||
|
entry_type?: string
|
||||||
|
expires_at?: string | null
|
||||||
|
id?: string
|
||||||
is_active?: boolean
|
is_active?: boolean
|
||||||
is_analysis_order?: boolean
|
is_analysis_order?: boolean
|
||||||
is_analysis_package_order?: boolean
|
is_analysis_package_order?: 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: {
|
account_params: {
|
||||||
Row: {
|
Row: {
|
||||||
@@ -886,6 +932,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: {
|
billing_customers: {
|
||||||
Row: {
|
Row: {
|
||||||
account_id: string
|
account_id: string
|
||||||
@@ -1102,32 +1206,76 @@ export type Database = {
|
|||||||
}
|
}
|
||||||
Relationships: []
|
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: {
|
connected_online_providers: {
|
||||||
Row: {
|
Row: {
|
||||||
|
address: string
|
||||||
can_select_worker: boolean
|
can_select_worker: boolean
|
||||||
created_at: string
|
created_at: string
|
||||||
email: string | null
|
email: string | null
|
||||||
id: number
|
id: number
|
||||||
|
key: string
|
||||||
name: string
|
name: string
|
||||||
personal_code_required: boolean
|
personal_code_required: boolean
|
||||||
phone_number: string | null
|
phone_number: string | null
|
||||||
updated_at: string | null
|
updated_at: string | null
|
||||||
}
|
}
|
||||||
Insert: {
|
Insert: {
|
||||||
|
address?: string
|
||||||
can_select_worker: boolean
|
can_select_worker: boolean
|
||||||
created_at?: string
|
created_at?: string
|
||||||
email?: string | null
|
email?: string | null
|
||||||
id: number
|
id: number
|
||||||
|
key: string
|
||||||
name: string
|
name: string
|
||||||
personal_code_required: boolean
|
personal_code_required: boolean
|
||||||
phone_number?: string | null
|
phone_number?: string | null
|
||||||
updated_at?: string | null
|
updated_at?: string | null
|
||||||
}
|
}
|
||||||
Update: {
|
Update: {
|
||||||
|
address?: string
|
||||||
can_select_worker?: boolean
|
can_select_worker?: boolean
|
||||||
created_at?: string
|
created_at?: string
|
||||||
email?: string | null
|
email?: string | null
|
||||||
id?: number
|
id?: number
|
||||||
|
key?: string
|
||||||
name?: string
|
name?: string
|
||||||
personal_code_required?: boolean
|
personal_code_required?: boolean
|
||||||
phone_number?: string | null
|
phone_number?: string | null
|
||||||
@@ -1137,54 +1285,131 @@ export type Database = {
|
|||||||
}
|
}
|
||||||
connected_online_reservation: {
|
connected_online_reservation: {
|
||||||
Row: {
|
Row: {
|
||||||
booking_code: string
|
booking_code: string | null
|
||||||
clinic_id: number
|
clinic_id: number
|
||||||
comments: string | null
|
comments: string | null
|
||||||
created_at: string
|
created_at: string
|
||||||
discount_code: string | null
|
discount_code: string | null
|
||||||
id: number
|
id: number
|
||||||
lang: string
|
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_id: number
|
||||||
service_user_id: number | null
|
service_user_id: number
|
||||||
start_time: string
|
start_time: string
|
||||||
|
status: Database["medreport"]["Enums"]["connected_online_order_status"]
|
||||||
sync_user_id: number
|
sync_user_id: number
|
||||||
updated_at: string | null
|
updated_at: string | null
|
||||||
user_id: string
|
user_id: string
|
||||||
}
|
}
|
||||||
Insert: {
|
Insert: {
|
||||||
booking_code: string
|
booking_code?: string | null
|
||||||
clinic_id: number
|
clinic_id: number
|
||||||
comments?: string | null
|
comments?: string | null
|
||||||
created_at?: string
|
created_at?: string
|
||||||
discount_code?: string | null
|
discount_code?: string | null
|
||||||
id?: number
|
id?: number
|
||||||
lang: string
|
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_id: number
|
||||||
service_user_id?: number | null
|
service_user_id: number
|
||||||
start_time: string
|
start_time: string
|
||||||
|
status: Database["medreport"]["Enums"]["connected_online_order_status"]
|
||||||
sync_user_id: number
|
sync_user_id: number
|
||||||
updated_at?: string | null
|
updated_at?: string | null
|
||||||
user_id: string
|
user_id: string
|
||||||
}
|
}
|
||||||
Update: {
|
Update: {
|
||||||
booking_code?: string
|
booking_code?: string | null
|
||||||
clinic_id?: number
|
clinic_id?: number
|
||||||
comments?: string | null
|
comments?: string | null
|
||||||
created_at?: string
|
created_at?: string
|
||||||
discount_code?: string | null
|
discount_code?: string | null
|
||||||
id?: number
|
id?: number
|
||||||
lang?: string
|
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_id?: number
|
||||||
service_user_id?: number | null
|
service_user_id?: number
|
||||||
start_time?: string
|
start_time?: string
|
||||||
|
status?: Database["medreport"]["Enums"]["connected_online_order_status"]
|
||||||
sync_user_id?: number
|
sync_user_id?: number
|
||||||
updated_at?: string | null
|
updated_at?: string | null
|
||||||
user_id?: string
|
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: {
|
connected_online_services: {
|
||||||
Row: {
|
Row: {
|
||||||
@@ -1203,7 +1428,7 @@ export type Database = {
|
|||||||
price: number
|
price: number
|
||||||
price_periods: string | null
|
price_periods: string | null
|
||||||
requires_payment: boolean
|
requires_payment: boolean
|
||||||
sync_id: string
|
sync_id: number
|
||||||
updated_at: string | null
|
updated_at: string | null
|
||||||
}
|
}
|
||||||
Insert: {
|
Insert: {
|
||||||
@@ -1222,7 +1447,7 @@ export type Database = {
|
|||||||
price: number
|
price: number
|
||||||
price_periods?: string | null
|
price_periods?: string | null
|
||||||
requires_payment: boolean
|
requires_payment: boolean
|
||||||
sync_id: string
|
sync_id: number
|
||||||
updated_at?: string | null
|
updated_at?: string | null
|
||||||
}
|
}
|
||||||
Update: {
|
Update: {
|
||||||
@@ -1241,7 +1466,7 @@ export type Database = {
|
|||||||
price?: number
|
price?: number
|
||||||
price_periods?: string | null
|
price_periods?: string | null
|
||||||
requires_payment?: boolean
|
requires_payment?: boolean
|
||||||
sync_id?: string
|
sync_id?: number
|
||||||
updated_at?: string | null
|
updated_at?: string | null
|
||||||
}
|
}
|
||||||
Relationships: [
|
Relationships: [
|
||||||
@@ -1976,10 +2201,23 @@ export type Database = {
|
|||||||
}
|
}
|
||||||
Returns: Database["medreport"]["Tables"]["invitations"]["Row"][]
|
Returns: Database["medreport"]["Tables"]["invitations"]["Row"][]
|
||||||
}
|
}
|
||||||
|
calculate_next_distribution_date: {
|
||||||
|
Args: { p_current_date?: string; p_occurrence: string }
|
||||||
|
Returns: string
|
||||||
|
}
|
||||||
can_action_account_member: {
|
can_action_account_member: {
|
||||||
Args: { target_team_account_id: string; target_user_id: string }
|
Args: { target_team_account_id: string; target_user_id: string }
|
||||||
Returns: boolean
|
Returns: boolean
|
||||||
}
|
}
|
||||||
|
consume_account_balance: {
|
||||||
|
Args: {
|
||||||
|
p_account_id: string
|
||||||
|
p_amount: number
|
||||||
|
p_description: string
|
||||||
|
p_reference_id?: string
|
||||||
|
}
|
||||||
|
Returns: boolean
|
||||||
|
}
|
||||||
create_invitation: {
|
create_invitation: {
|
||||||
Args: { account_id: string; email: string; role: string }
|
Args: { account_id: string; email: string; role: string }
|
||||||
Returns: {
|
Returns: {
|
||||||
@@ -2033,6 +2271,18 @@ export type Database = {
|
|||||||
updated_by: string | null
|
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: {
|
get_account_invitations: {
|
||||||
Args: { account_slug: string }
|
Args: { account_slug: string }
|
||||||
Returns: {
|
Returns: {
|
||||||
@@ -2203,8 +2453,8 @@ export type Database = {
|
|||||||
Returns: boolean
|
Returns: boolean
|
||||||
}
|
}
|
||||||
process_periodic_benefit_distributions: {
|
process_periodic_benefit_distributions: {
|
||||||
Args: {}
|
Args: Record<PropertyKey, never>
|
||||||
Returns: void
|
Returns: undefined
|
||||||
}
|
}
|
||||||
revoke_nonce: {
|
revoke_nonce: {
|
||||||
Args: { p_id: string; p_reason?: string }
|
Args: { p_id: string; p_reason?: string }
|
||||||
@@ -2230,6 +2480,10 @@ export type Database = {
|
|||||||
Args: { new_owner_id: string; target_account_id: string }
|
Args: { new_owner_id: string; target_account_id: string }
|
||||||
Returns: undefined
|
Returns: undefined
|
||||||
}
|
}
|
||||||
|
trigger_benefit_distribution: {
|
||||||
|
Args: { p_company_id: string }
|
||||||
|
Returns: undefined
|
||||||
|
}
|
||||||
update_account: {
|
update_account: {
|
||||||
Args:
|
Args:
|
||||||
| {
|
| {
|
||||||
@@ -2269,6 +2523,14 @@ export type Database = {
|
|||||||
user_id: string
|
user_id: string
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
upsert_benefit_distribution_schedule: {
|
||||||
|
Args: {
|
||||||
|
p_benefit_amount: number
|
||||||
|
p_benefit_occurrence: string
|
||||||
|
p_company_id: string
|
||||||
|
}
|
||||||
|
Returns: undefined
|
||||||
|
}
|
||||||
upsert_order: {
|
upsert_order: {
|
||||||
Args: {
|
Args: {
|
||||||
billing_provider: Database["medreport"]["Enums"]["billing_provider"]
|
billing_provider: Database["medreport"]["Enums"]["billing_provider"]
|
||||||
@@ -2358,6 +2620,11 @@ export type Database = {
|
|||||||
| "invites.manage"
|
| "invites.manage"
|
||||||
application_role: "user" | "doctor" | "super_admin"
|
application_role: "user" | "doctor" | "super_admin"
|
||||||
billing_provider: "stripe" | "lemon-squeezy" | "paddle" | "montonio"
|
billing_provider: "stripe" | "lemon-squeezy" | "paddle" | "montonio"
|
||||||
|
connected_online_order_status:
|
||||||
|
| "PENDING"
|
||||||
|
| "CONFIRMED"
|
||||||
|
| "REJECTED"
|
||||||
|
| "CANCELLED"
|
||||||
locale: "en" | "et" | "ru"
|
locale: "en" | "et" | "ru"
|
||||||
notification_channel: "in_app" | "email"
|
notification_channel: "in_app" | "email"
|
||||||
notification_type: "info" | "warning" | "error"
|
notification_type: "info" | "warning" | "error"
|
||||||
@@ -8275,6 +8542,12 @@ export const Constants = {
|
|||||||
],
|
],
|
||||||
application_role: ["user", "doctor", "super_admin"],
|
application_role: ["user", "doctor", "super_admin"],
|
||||||
billing_provider: ["stripe", "lemon-squeezy", "paddle", "montonio"],
|
billing_provider: ["stripe", "lemon-squeezy", "paddle", "montonio"],
|
||||||
|
connected_online_order_status: [
|
||||||
|
"PENDING",
|
||||||
|
"CONFIRMED",
|
||||||
|
"REJECTED",
|
||||||
|
"CANCELLED",
|
||||||
|
],
|
||||||
locale: ["en", "et", "ru"],
|
locale: ["en", "et", "ru"],
|
||||||
notification_channel: ["in_app", "email"],
|
notification_channel: ["in_app", "email"],
|
||||||
notification_type: ["info", "warning", "error"],
|
notification_type: ["info", "warning", "error"],
|
||||||
|
|||||||
@@ -34,11 +34,11 @@ function Calendar({
|
|||||||
nav_button_previous: 'absolute left-1',
|
nav_button_previous: 'absolute left-1',
|
||||||
nav_button_next: 'absolute right-1',
|
nav_button_next: 'absolute right-1',
|
||||||
table: 'w-full border-collapse space-y-1',
|
table: 'w-full border-collapse space-y-1',
|
||||||
head_row: 'flex',
|
head_row: 'flex justify-evenly',
|
||||||
head_cell:
|
head_cell:
|
||||||
'text-muted-foreground rounded-md w-9 font-normal text-[0.8rem]',
|
'text-muted-foreground rounded-md w-9 font-normal text-[0.8rem]',
|
||||||
row: 'flex w-full mt-2',
|
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-r-md focus-within:relative focus-within:z-20',
|
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(
|
day: cn(
|
||||||
buttonVariants({ variant: 'ghost' }),
|
buttonVariants({ variant: 'ghost' }),
|
||||||
'h-9 w-9 p-0 font-normal aria-selected:opacity-100',
|
'h-9 w-9 p-0 font-normal aria-selected:opacity-100',
|
||||||
|
|||||||
@@ -41,11 +41,9 @@ const CardHeader: React.FC<React.HTMLAttributes<HTMLDivElement>> = ({
|
|||||||
);
|
);
|
||||||
CardHeader.displayName = 'CardHeader';
|
CardHeader.displayName = 'CardHeader';
|
||||||
|
|
||||||
const CardTitle: React.FC<React.HTMLAttributes<HTMLHeadingElement> & { size?: 'h3' | 'h4' | 'h5' }> = ({
|
const CardTitle: React.FC<
|
||||||
className,
|
React.HTMLAttributes<HTMLHeadingElement> & { size?: 'h3' | 'h4' | 'h5' }
|
||||||
size = 'h3',
|
> = ({ className, size = 'h3', ...props }) => {
|
||||||
...props
|
|
||||||
}) => {
|
|
||||||
const Component = size;
|
const Component = size;
|
||||||
return (
|
return (
|
||||||
<Component
|
<Component
|
||||||
|
|||||||
@@ -25,12 +25,12 @@ const RadioGroupItem: React.FC<
|
|||||||
return (
|
return (
|
||||||
<RadioGroupPrimitive.Item
|
<RadioGroupPrimitive.Item
|
||||||
className={cn(
|
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,
|
className,
|
||||||
)}
|
)}
|
||||||
{...props}
|
{...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" />
|
<CheckIcon className="fill-primary h-3.5 w-3.5" />
|
||||||
</RadioGroupPrimitive.Indicator>
|
</RadioGroupPrimitive.Indicator>
|
||||||
</RadioGroupPrimitive.Item>
|
</RadioGroupPrimitive.Item>
|
||||||
|
|||||||
10982
pnpm-lock.yaml
generated
10982
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
@@ -4,5 +4,17 @@
|
|||||||
"analysisPackages": {
|
"analysisPackages": {
|
||||||
"title": "Analysis packages",
|
"title": "Analysis packages",
|
||||||
"description": "Get to know the personal analysis packages and order"
|
"description": "Get to know the personal analysis packages and order"
|
||||||
}
|
},
|
||||||
|
"noCategories": "Service list not found, please try again later",
|
||||||
|
"noResults": "No available times on the selected dates",
|
||||||
|
"services": "Services",
|
||||||
|
"locations": "Locations",
|
||||||
|
"showAll": "Show all",
|
||||||
|
"showAllLocations": "Show all locations",
|
||||||
|
"bookTimeSuccess": "Time selected",
|
||||||
|
"bookTimeError": "Failed to select time",
|
||||||
|
"bookTimeLoading": "Selecting time...",
|
||||||
|
"serviceNotFound": "Service not found",
|
||||||
|
"noProducts": "No products found",
|
||||||
|
"timeSlotUnavailable": "Service availability has changed, please select a new time"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,14 +7,18 @@
|
|||||||
"item": "Item",
|
"item": "Item",
|
||||||
"quantity": "Quantity",
|
"quantity": "Quantity",
|
||||||
"price": "Price",
|
"price": "Price",
|
||||||
"total": "Total"
|
"total": "Total",
|
||||||
|
"time": "Time",
|
||||||
|
"location": "Location"
|
||||||
},
|
},
|
||||||
"checkout": {
|
"checkout": {
|
||||||
"goToCheckout": "Go to checkout",
|
"goToCheckout": "Go to checkout",
|
||||||
"goToDashboard": "Continue",
|
"goToDashboard": "Continue",
|
||||||
"error": {
|
"error": {
|
||||||
"title": "Something went wrong",
|
"title": "Something went wrong",
|
||||||
"description": "Please try again later."
|
"description": "Please try again later.",
|
||||||
|
"BOOKING_FAILED": "Service error, please try again later.",
|
||||||
|
"TIME_SLOT_UNAVAILABLE": "The selected time is not available."
|
||||||
},
|
},
|
||||||
"timeLeft": "Time left {{timeLeft}}",
|
"timeLeft": "Time left {{timeLeft}}",
|
||||||
"timeoutTitle": "Reservation expired",
|
"timeoutTitle": "Reservation expired",
|
||||||
@@ -86,5 +90,9 @@
|
|||||||
"title": "Location for analysis",
|
"title": "Location for analysis",
|
||||||
"description": "If you are unable to go to the lab to collect the sample, you can go to any other suitable collection point.",
|
"description": "If you are unable to go to the lab to collect the sample, you can go to any other suitable collection point.",
|
||||||
"locationSelect": "Select location"
|
"locationSelect": "Select location"
|
||||||
|
},
|
||||||
|
"editServiceItem": {
|
||||||
|
"title": "Edit booking",
|
||||||
|
"description": "Edit booking details"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -148,5 +148,7 @@
|
|||||||
"language": "Language",
|
"language": "Language",
|
||||||
"yes": "Yes",
|
"yes": "Yes",
|
||||||
"no": "No",
|
"no": "No",
|
||||||
"preferNotToAnswer": "Prefer not to answer"
|
"preferNotToAnswer": "Prefer not to answer",
|
||||||
|
"book": "Book",
|
||||||
|
"change": "Change"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,12 +9,27 @@
|
|||||||
"status": "Status"
|
"status": "Status"
|
||||||
},
|
},
|
||||||
"status": {
|
"status": {
|
||||||
"QUEUED": "Waiting to send to lab",
|
"QUEUED": "Queued",
|
||||||
"PROCESSING": "Waiting for results",
|
"PROCESSING": "Processing",
|
||||||
"PARTIAL_ANALYSIS_RESPONSE": "Partial analysis response",
|
"PARTIAL_ANALYSIS_RESPONSE": "Partial results",
|
||||||
"FULL_ANALYSIS_RESPONSE": "All analysis responses received, waiting for doctor response",
|
"FULL_ANALYSIS_RESPONSE": "All results received",
|
||||||
"COMPLETED": "Completed",
|
"COMPLETED": "Confirmed",
|
||||||
"REJECTED": "Rejected",
|
"REJECTED": "Rejected",
|
||||||
"CANCELLED": "Cancelled"
|
"CANCELLED": "Cancelled",
|
||||||
|
"analysisOrder": {
|
||||||
|
"QUEUED": "Queued",
|
||||||
|
"PROCESSING": "Sent to Synlab",
|
||||||
|
"PARTIAL_ANALYSIS_RESPONSE": "Partial results",
|
||||||
|
"FULL_ANALYSIS_RESPONSE": "All results received, awaiting doctor's summary",
|
||||||
|
"COMPLETED": "Confirmed",
|
||||||
|
"REJECTED": "Rejected",
|
||||||
|
"CANCELLED": "Cancelled"
|
||||||
|
},
|
||||||
|
"ttoService": {
|
||||||
|
"PENDING": "Started",
|
||||||
|
"CONFIRMED": "Confirmed",
|
||||||
|
"REJECTED": "Rejected",
|
||||||
|
"CANCELLED": "Cancelled"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,7 +28,8 @@
|
|||||||
"budget": {
|
"budget": {
|
||||||
"title": "Company Health Account Balance",
|
"title": "Company Health Account Balance",
|
||||||
"balance": "Budget Balance {{balance}}",
|
"balance": "Budget Balance {{balance}}",
|
||||||
"volume": "Budget Volume"
|
"volume": "Budget Volume",
|
||||||
|
"membersCount": "Members Count"
|
||||||
},
|
},
|
||||||
"data": {
|
"data": {
|
||||||
"reservations": "{{value}} services",
|
"reservations": "{{value}} services",
|
||||||
@@ -38,7 +39,8 @@
|
|||||||
"analysisPackages": "Health Analysis Packages",
|
"analysisPackages": "Health Analysis Packages",
|
||||||
"analysisPackagesCount": "{{value}} service usage",
|
"analysisPackagesCount": "{{value}} service usage",
|
||||||
"totalSum": "Total Sum",
|
"totalSum": "Total Sum",
|
||||||
"eclinic": "E-Clinic"
|
"eclinic": "E-Clinic",
|
||||||
|
"currentMonthUsageTotal": "Current Month Usage"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"healthDetails": {
|
"healthDetails": {
|
||||||
|
|||||||
@@ -5,5 +5,16 @@
|
|||||||
"title": "Analüüside paketid",
|
"title": "Analüüside paketid",
|
||||||
"description": "Tutvu personaalsete analüüsi pakettidega ja telli"
|
"description": "Tutvu personaalsete analüüsi pakettidega ja telli"
|
||||||
},
|
},
|
||||||
"noCategories": "Teenuste loetelu ei leitud, proovi hiljem uuesti"
|
"noCategories": "Teenuste loetelu ei leitud, proovi hiljem uuesti",
|
||||||
|
"noResults": "Valitud kuupäevadel ei ole vabu aegu",
|
||||||
|
"services": "Teenused",
|
||||||
|
"locations": "Asutused",
|
||||||
|
"showAll": "Kuva kõik",
|
||||||
|
"showAllLocations": "Näita kõiki asutusi",
|
||||||
|
"bookTimeSuccess": "Aeg valitud",
|
||||||
|
"bookTimeError": "Aega ei õnnestunud valida",
|
||||||
|
"bookTimeLoading": "Aega valitakse...",
|
||||||
|
"serviceNotFound": "Teenust ei leitud",
|
||||||
|
"noProducts": "Tooteid ei leitud",
|
||||||
|
"timeSlotUnavailable": "Teenuse saadavus muutus, palun vali uus aeg"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,14 +7,18 @@
|
|||||||
"item": "Toode",
|
"item": "Toode",
|
||||||
"quantity": "Kogus",
|
"quantity": "Kogus",
|
||||||
"price": "Hind",
|
"price": "Hind",
|
||||||
"total": "Summa"
|
"total": "Summa",
|
||||||
|
"time": "Aeg",
|
||||||
|
"location": "Asukoht"
|
||||||
},
|
},
|
||||||
"checkout": {
|
"checkout": {
|
||||||
"goToCheckout": "Vormista ost",
|
"goToCheckout": "Vormista ost",
|
||||||
"goToDashboard": "Jätkan",
|
"goToDashboard": "Jätkan",
|
||||||
"error": {
|
"error": {
|
||||||
"title": "Midagi läks valesti",
|
"title": "Midagi läks valesti",
|
||||||
"description": "Palun proovi hiljem uuesti."
|
"description": "Palun proovi hiljem uuesti.",
|
||||||
|
"BOOKING_FAILED": "Teenuse tõrge, proovi hiljem uuesti.",
|
||||||
|
"TIME_SLOT_UNAVAILABLE": "Valitud aeg ei ole saadaval."
|
||||||
},
|
},
|
||||||
"timeLeft": "Aega jäänud {{timeLeft}}",
|
"timeLeft": "Aega jäänud {{timeLeft}}",
|
||||||
"timeoutTitle": "Broneering aegus",
|
"timeoutTitle": "Broneering aegus",
|
||||||
@@ -86,5 +90,9 @@
|
|||||||
"title": "Asukoht analüüside andmiseks",
|
"title": "Asukoht analüüside andmiseks",
|
||||||
"description": "Kui Teil ei ole võimalik valitud asukohta minna analüüse andma, siis võite minna Teile sobivasse verevõtupunkti.",
|
"description": "Kui Teil ei ole võimalik valitud asukohta minna analüüse andma, siis võite minna Teile sobivasse verevõtupunkti.",
|
||||||
"locationSelect": "Vali asukoht"
|
"locationSelect": "Vali asukoht"
|
||||||
|
},
|
||||||
|
"editServiceItem": {
|
||||||
|
"title": "Muuda broneeringut",
|
||||||
|
"description": "Muuda broneeringu andmeid"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -148,5 +148,7 @@
|
|||||||
"language": "Keel",
|
"language": "Keel",
|
||||||
"yes": "Jah",
|
"yes": "Jah",
|
||||||
"no": "Ei",
|
"no": "Ei",
|
||||||
"preferNotToAnswer": "Eelistan mitte vastata"
|
"preferNotToAnswer": "Eelistan mitte vastata",
|
||||||
|
"book": "Broneeri",
|
||||||
|
"change": "Muuda"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,17 +4,33 @@
|
|||||||
"noOrders": "Tellimusi ei leitud",
|
"noOrders": "Tellimusi ei leitud",
|
||||||
"table": {
|
"table": {
|
||||||
"analysisPackage": "Analüüsi pakett",
|
"analysisPackage": "Analüüsi pakett",
|
||||||
|
"ttoService": "Broneering",
|
||||||
"otherOrders": "Tellimus",
|
"otherOrders": "Tellimus",
|
||||||
"createdAt": "Tellitud",
|
"createdAt": "Tellitud",
|
||||||
"status": "Olek"
|
"status": "Olek"
|
||||||
},
|
},
|
||||||
"status": {
|
"status": {
|
||||||
"QUEUED": "Esitatud",
|
"QUEUED": "Esitatud",
|
||||||
"PROCESSING": "Synlabile edastatud",
|
"PROCESSING": "Edastatud",
|
||||||
"PARTIAL_ANALYSIS_RESPONSE": "Osalised tulemused",
|
"PARTIAL_ANALYSIS_RESPONSE": "Osalised tulemused",
|
||||||
"FULL_ANALYSIS_RESPONSE": "Kõik tulemused käes, ootab arsti kokkuvõtet",
|
"FULL_ANALYSIS_RESPONSE": "Kõik tulemused käes",
|
||||||
"COMPLETED": "Kinnitatud",
|
"COMPLETED": "Kinnitatud",
|
||||||
"REJECTED": "Tagastatud",
|
"REJECTED": "Tagastatud",
|
||||||
"CANCELLED": "Tühistatud"
|
"CANCELLED": "Tühistatud",
|
||||||
|
"analysisOrder": {
|
||||||
|
"QUEUED": "Esitatud",
|
||||||
|
"PROCESSING": "Synlabile edastatud",
|
||||||
|
"PARTIAL_ANALYSIS_RESPONSE": "Osalised tulemused",
|
||||||
|
"FULL_ANALYSIS_RESPONSE": "Kõik tulemused käes, ootab arsti kokkuvõtet",
|
||||||
|
"COMPLETED": "Kinnitatud",
|
||||||
|
"REJECTED": "Tagastatud",
|
||||||
|
"CANCELLED": "Tühistatud"
|
||||||
|
},
|
||||||
|
"ttoService": {
|
||||||
|
"PENDING": "Laekumise ootel",
|
||||||
|
"CONFIRMED": "Kinnitatud",
|
||||||
|
"REJECTED": "Tagasi lükatud",
|
||||||
|
"CANCELLED": "Tühistatud"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,17 +28,19 @@
|
|||||||
"budget": {
|
"budget": {
|
||||||
"title": "Ettevõtte Tervisekassa seis",
|
"title": "Ettevõtte Tervisekassa seis",
|
||||||
"balance": "Eelarve jääk {{balance}}",
|
"balance": "Eelarve jääk {{balance}}",
|
||||||
"volume": "Eelarve maht"
|
"volume": "Eelarve maht",
|
||||||
|
"membersCount": "Töötajate arv"
|
||||||
},
|
},
|
||||||
"data": {
|
"data": {
|
||||||
"reservations": "{{value}} teenust",
|
"reservations": "{{value}} tellimus(t)",
|
||||||
"analysis": "Analüüsid",
|
"analysis": "Analüüsid",
|
||||||
"doctorsAndSpecialists": "Eriarstid ja spetsialistid",
|
"doctorsAndSpecialists": "Eriarstid ja spetsialistid",
|
||||||
"researches": "Uuringud",
|
"researches": "Uuringud",
|
||||||
"analysisPackages": "Terviseuuringute paketid",
|
"analysisPackages": "Terviseuuringute paketid",
|
||||||
"analysisPackagesCount": "{{value}} teenuse kasutust",
|
"analysisPackagesCount": "{{value}} tellimus(t)",
|
||||||
"totalSum": "Tellitud teenuste summa",
|
"totalSum": "Tellitud teenuste summa",
|
||||||
"eclinic": "Digikliinik"
|
"eclinic": "Digikliinik",
|
||||||
|
"currentMonthUsageTotal": "Kasutatud eelarve"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"healthDetails": {
|
"healthDetails": {
|
||||||
|
|||||||
@@ -5,5 +5,16 @@
|
|||||||
"title": "Пакеты анализов",
|
"title": "Пакеты анализов",
|
||||||
"description": "Ознакомьтесь с персональными пакетами анализов и закажите"
|
"description": "Ознакомьтесь с персональными пакетами анализов и закажите"
|
||||||
},
|
},
|
||||||
"noCategories": "Список услуг не найден, попробуйте позже"
|
"noCategories": "Список услуг не найден, попробуйте позже",
|
||||||
|
"noResults": "На выбранные даты нет свободного времени",
|
||||||
|
"services": "Услуги",
|
||||||
|
"locations": "Учреждения",
|
||||||
|
"showAll": "Показать все",
|
||||||
|
"showAllLocations": "Показать все учреждения",
|
||||||
|
"bookTimeSuccess": "Время выбрано",
|
||||||
|
"bookTimeError": "Не удалось выбрать время",
|
||||||
|
"bookTimeLoading": "Выбор времени...",
|
||||||
|
"serviceNotFound": "Услуга не найдена",
|
||||||
|
"noProducts": "Товары не найдены",
|
||||||
|
"timeSlotUnavailable": "Доступность услуги изменилась, пожалуйста, выберите другое время"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,14 +7,18 @@
|
|||||||
"item": "Товар",
|
"item": "Товар",
|
||||||
"quantity": "Количество",
|
"quantity": "Количество",
|
||||||
"price": "Цена",
|
"price": "Цена",
|
||||||
"total": "Сумма"
|
"total": "Сумма",
|
||||||
|
"time": "Время",
|
||||||
|
"location": "Местоположение"
|
||||||
},
|
},
|
||||||
"checkout": {
|
"checkout": {
|
||||||
"goToCheckout": "Оформить заказ",
|
"goToCheckout": "Оформить заказ",
|
||||||
"goToDashboard": "Продолжить",
|
"goToDashboard": "Продолжить",
|
||||||
"error": {
|
"error": {
|
||||||
"title": "Что-то пошло не так",
|
"title": "Что-то пошло не так",
|
||||||
"description": "Пожалуйста, попробуйте позже."
|
"description": "Пожалуйста, попробуйте позже.",
|
||||||
|
"BOOKING_FAILED": "Ошибка сервиса, попробуйте позже.",
|
||||||
|
"TIME_SLOT_UNAVAILABLE": "Выбранное время недоступно."
|
||||||
},
|
},
|
||||||
"timeLeft": "Осталось времени {{timeLeft}}",
|
"timeLeft": "Осталось времени {{timeLeft}}",
|
||||||
"timeoutTitle": "Бронирование истекло",
|
"timeoutTitle": "Бронирование истекло",
|
||||||
@@ -86,5 +90,9 @@
|
|||||||
"title": "Местоположение для сдачи анализов",
|
"title": "Местоположение для сдачи анализов",
|
||||||
"description": "Если у вас нет возможности прийти в выбранное место для сдачи анализов, вы можете посетить любой удобный для вас пункт забора крови.",
|
"description": "Если у вас нет возможности прийти в выбранное место для сдачи анализов, вы можете посетить любой удобный для вас пункт забора крови.",
|
||||||
"locationSelect": "Выберите местоположение"
|
"locationSelect": "Выберите местоположение"
|
||||||
|
},
|
||||||
|
"editServiceItem": {
|
||||||
|
"title": "Изменить бронирование",
|
||||||
|
"description": "Изменить данные бронирования"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,11 +10,26 @@
|
|||||||
},
|
},
|
||||||
"status": {
|
"status": {
|
||||||
"QUEUED": "Отправлено",
|
"QUEUED": "Отправлено",
|
||||||
"PROCESSING": "Передано в Synlab",
|
"PROCESSING": "В обработке",
|
||||||
"PARTIAL_ANALYSIS_RESPONSE": "Частичные результаты",
|
"PARTIAL_ANALYSIS_RESPONSE": "Частичные результаты",
|
||||||
"FULL_ANALYSIS_RESPONSE": "Все результаты получены, ожидается заключение врача",
|
"FULL_ANALYSIS_RESPONSE": "Все результаты получены",
|
||||||
"COMPLETED": "Подтверждено",
|
"COMPLETED": "Подтверждено",
|
||||||
"REJECTED": "Возвращено",
|
"REJECTED": "Отклонено",
|
||||||
"CANCELLED": "Отменено"
|
"CANCELLED": "Отменено",
|
||||||
|
"analysisOrder": {
|
||||||
|
"QUEUED": "Отправлено",
|
||||||
|
"PROCESSING": "Отправлено в Synlab",
|
||||||
|
"PARTIAL_ANALYSIS_RESPONSE": "Частичные результаты",
|
||||||
|
"FULL_ANALYSIS_RESPONSE": "Все результаты получены, ожидается заключение врача",
|
||||||
|
"COMPLETED": "Подтверждено",
|
||||||
|
"REJECTED": "Отклонено",
|
||||||
|
"CANCELLED": "Отменено"
|
||||||
|
},
|
||||||
|
"ttoService": {
|
||||||
|
"PENDING": "Начато",
|
||||||
|
"CONFIRMED": "Подтверждено",
|
||||||
|
"REJECTED": "Отклонено",
|
||||||
|
"CANCELLED": "Отменено"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,7 +28,8 @@
|
|||||||
"budget": {
|
"budget": {
|
||||||
"title": "Баланс Tervisekassa компании",
|
"title": "Баланс Tervisekassa компании",
|
||||||
"balance": "Остаток бюджета {{balance}}",
|
"balance": "Остаток бюджета {{balance}}",
|
||||||
"volume": "Объем бюджета"
|
"volume": "Объем бюджета",
|
||||||
|
"membersCount": "Количество сотрудников"
|
||||||
},
|
},
|
||||||
"data": {
|
"data": {
|
||||||
"reservations": "{{value}} услуги",
|
"reservations": "{{value}} услуги",
|
||||||
@@ -38,7 +39,8 @@
|
|||||||
"analysisPackages": "Пакеты медицинских исследований",
|
"analysisPackages": "Пакеты медицинских исследований",
|
||||||
"analysisPackagesCount": "{{value}} использование услуг",
|
"analysisPackagesCount": "{{value}} использование услуг",
|
||||||
"totalSum": "Сумма услуг",
|
"totalSum": "Сумма услуг",
|
||||||
"eclinic": "Дигиклиника"
|
"eclinic": "Дигиклиника",
|
||||||
|
"currentMonthUsageTotal": "Текущее использование бюджета"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"healthDetails": {
|
"healthDetails": {
|
||||||
|
|||||||
36
pwgen.js
Normal file
36
pwgen.js
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
async function generateDeterministicPassword(
|
||||||
|
email,
|
||||||
|
userId,
|
||||||
|
) {
|
||||||
|
// Use the user ID or email as the base for deterministic generation
|
||||||
|
const baseString = userId || email;
|
||||||
|
const secret = 'ODEwMGNiMmUtOGMxYS0xMWYwLWJlZDYtYTM3YzYyMWY0NGEzCg==';
|
||||||
|
|
||||||
|
// Create a deterministic password using HMAC
|
||||||
|
const encoder = new TextEncoder();
|
||||||
|
const keyData = encoder.encode(secret);
|
||||||
|
const messageData = encoder.encode(baseString);
|
||||||
|
|
||||||
|
// Import key for HMAC
|
||||||
|
const key = await crypto.subtle.importKey(
|
||||||
|
'raw',
|
||||||
|
keyData,
|
||||||
|
{ name: 'HMAC', hash: 'SHA-256' },
|
||||||
|
false,
|
||||||
|
['sign'],
|
||||||
|
);
|
||||||
|
// Generate HMAC
|
||||||
|
const signature = await crypto.subtle.sign('HMAC', key, messageData);
|
||||||
|
// Convert to base64 and make it a valid password
|
||||||
|
const hashArray = Array.from(new Uint8Array(signature));
|
||||||
|
const hashHex = hashArray
|
||||||
|
.map((b) => b.toString(16).padStart(2, '0'))
|
||||||
|
.join('');
|
||||||
|
// Take first 24 characters and add some complexity
|
||||||
|
const basePassword = hashHex.substring(0, 24);
|
||||||
|
// Add some required complexity for Medusa (uppercase, lowercase, numbers, symbols)
|
||||||
|
return `Mk${basePassword}9!`;
|
||||||
|
}
|
||||||
|
|
||||||
|
generateDeterministicPassword('', '3835d1f2-10a8-44be-85fe-d6d8d3c31848').then((result) => console.log('one:', result));
|
||||||
|
generateDeterministicPassword('ee37408020410@medreport.ee', '').then((result) => console.log('two:', result));
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
select
|
||||||
|
cron.schedule(
|
||||||
|
'sync-connected-online-every-night', -- Unique job name
|
||||||
|
'0 1 * * *', -- Cron schedule: every night at 04:00 (GMT +3)
|
||||||
|
$$
|
||||||
|
select
|
||||||
|
net.http_post(
|
||||||
|
url := 'https://test.medreport.ee/api/job/sync-connected-online',
|
||||||
|
headers := jsonb_build_object(
|
||||||
|
'x-jobs-api-key', 'fd26ec26-70ed-11f0-9e95-431ac3b15a84'
|
||||||
|
)
|
||||||
|
) as request_id;
|
||||||
|
$$
|
||||||
|
);
|
||||||
11
supabase/migrations/20250908092531_add_clinic_key.sql
Normal file
11
supabase/migrations/20250908092531_add_clinic_key.sql
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
ALTER TABLE medreport.connected_online_providers ADD COLUMN key text not null DEFAULT ''; -- avoid conflict with already existing data, will be filled on next sync
|
||||||
|
ALTER TABLE medreport.connected_online_providers
|
||||||
|
ALTER key DROP DEFAULT;
|
||||||
|
|
||||||
|
ALTER TABLE medreport.connected_online_providers ADD COLUMN address text not null DEFAULT '';
|
||||||
|
ALTER TABLE medreport.connected_online_providers
|
||||||
|
ALTER key DROP DEFAULT;
|
||||||
|
|
||||||
|
ALTER TABLE medreport.connected_online_services
|
||||||
|
ALTER COLUMN sync_id TYPE bigint
|
||||||
|
USING sync_id::bigint;
|
||||||
@@ -0,0 +1,60 @@
|
|||||||
|
create table "medreport"."connected_online_service_providers" (
|
||||||
|
"id" bigint not null primary key,
|
||||||
|
"name" text not null,
|
||||||
|
"spoken_languages" text[],
|
||||||
|
"prefix" text,
|
||||||
|
"job_title_et" text,
|
||||||
|
"job_title_en" text,
|
||||||
|
"job_title_ru" text,
|
||||||
|
"clinic_id" bigint not null REFERENCES medreport.connected_online_providers(id),
|
||||||
|
"job_title_id" bigint,
|
||||||
|
"is_deleted" boolean,
|
||||||
|
"created_at" timestamp with time zone not null default now(),
|
||||||
|
"updated_at" timestamp without time zone default now()
|
||||||
|
);
|
||||||
|
|
||||||
|
ALTER TABLE audit.request_entries
|
||||||
|
DROP COLUMN personal_code;
|
||||||
|
|
||||||
|
ALTER TABLE audit.request_entries ADD COLUMN user_id uuid default auth.uid();
|
||||||
|
|
||||||
|
create policy "insert_own"
|
||||||
|
on "audit"."request_entries"
|
||||||
|
as permissive
|
||||||
|
for insert
|
||||||
|
to authenticated
|
||||||
|
with check ((( SELECT auth.uid() AS uid) = user_id));
|
||||||
|
|
||||||
|
alter table "medreport"."connected_online_service_providers" enable row level security;
|
||||||
|
|
||||||
|
create policy "service_role_all"
|
||||||
|
on "medreport"."connected_online_service_providers"
|
||||||
|
as permissive
|
||||||
|
for all
|
||||||
|
to service_role
|
||||||
|
using (true);
|
||||||
|
|
||||||
|
|
||||||
|
grant delete on table "medreport"."connected_online_service_providers" to "service_role";
|
||||||
|
|
||||||
|
grant insert on table "medreport"."connected_online_service_providers" to "service_role";
|
||||||
|
|
||||||
|
grant references on table "medreport"."connected_online_service_providers" to "service_role";
|
||||||
|
|
||||||
|
grant select on table "medreport"."connected_online_service_providers" to "service_role";
|
||||||
|
|
||||||
|
grant trigger on table "medreport"."connected_online_service_providers" to "service_role";
|
||||||
|
|
||||||
|
grant truncate on table "medreport"."connected_online_service_providers" to "service_role";
|
||||||
|
|
||||||
|
grant update on table "medreport"."connected_online_service_providers" to "service_role";
|
||||||
|
|
||||||
|
grant select on table "medreport"."connected_online_service_providers" to "authenticated";
|
||||||
|
|
||||||
|
|
||||||
|
create policy "authenticated_select"
|
||||||
|
on "medreport"."connected_online_service_providers"
|
||||||
|
as permissive
|
||||||
|
for select
|
||||||
|
to authenticated
|
||||||
|
using (true);
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
ALTER TABLE medreport.connected_online_reservation
|
||||||
|
ADD COLUMN medusa_cart_line_item_id TEXT references public.cart_line_item(id);
|
||||||
|
|
||||||
|
ALTER TABLE medreport.connected_online_reservation
|
||||||
|
ADD COLUMN location_sync_id bigint;
|
||||||
|
|
||||||
|
create type medreport.connected_online_order_status as enum ('PENDING', 'CONFIRMED', 'REJECTED', 'CANCELLED');
|
||||||
|
|
||||||
|
ALTER TABLE medreport.connected_online_reservation
|
||||||
|
ADD COLUMN status medreport.connected_online_order_status not null;
|
||||||
|
|
||||||
|
ALTER TABLE medreport.connected_online_reservation ALTER COLUMN booking_code DROP NOT NULL;
|
||||||
|
ALTER TABLE medreport.connected_online_reservation ALTER COLUMN requires_payment DROP NOT NULL;
|
||||||
|
ALTER TABLE medreport.connected_online_reservation ALTER COLUMN service_user_id SET NOT NULL;
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user