From 2fdb934ec9aef5a9203d5fadd615f2debba34702 Mon Sep 17 00:00:00 2001 From: user Date: Mon, 20 Oct 2025 21:46:26 +0300 Subject: [PATCH] big boi refactor to customer inof from passenger info --- .gitignore | 4 - .../src/lib/domains/account/data/entities.ts | 1 - .../domains/account/data/inbox.repository.ts | 137 ---- .../lib/domains/account/data/repository.ts | 186 ------ .../lib/domains/account/domain/controller.ts | 39 -- .../src/lib/domains/account/domain/router.ts | 43 -- apps/admin/src/lib/domains/account/utils.ts | 10 - .../account/view/accounts-list-modal.svelte | 77 --- .../account/view/accounts-table.svelte | 130 ---- .../account/view/accounts.vm.svelte.ts | 145 ---- .../domains/account/view/email-details.svelte | 160 ----- .../domains/account/view/emails-list.svelte | 39 -- .../src/lib/domains/customerinfo/data.ts | 1 + .../lib/domains/customerinfo/repository.ts | 1 + .../src/lib/domains/customerinfo/router.ts | 47 ++ .../src/lib/domains/customerinfo/usecases.ts | 1 + .../view/cinfo-card.svelte} | 0 .../view/customer-details-card.svelte | 57 ++ .../view/customerinfo-table.svelte} | 59 +- .../view/customerinfo.vm.svelte.ts | 10 + .../src/lib/domains/order/data/repository.ts | 15 +- .../domains/passengerinfo/data/entities.ts | 1 - .../domains/passengerinfo/data/repository.ts | 89 --- .../passengerinfo/domain/controller.ts | 19 - .../view/passengerinfo.vm.svelte.ts | 10 - .../view/payment-details-card.svelte | 43 -- .../domains/product/view/product-list.svelte | 4 +- apps/admin/src/lib/trpc/router/index.ts | 4 +- .../src/routes/(main)/data/+page.server.ts | 8 +- .../admin/src/routes/(main)/data/+page.svelte | 6 +- .../routes/(main)/data/[uid]/+page.server.ts | 10 +- .../src/routes/(main)/data/[uid]/+page.svelte | 60 +- apps/frontend/package.json | 1 - .../src/lib/domains/ckflow/data/repository.ts | 18 +- .../src/lib/domains/ckflow/domain/router.ts | 28 +- .../src/lib/domains/ckflow/domain/usecases.ts | 9 +- .../domains/ckflow/view/ckflow.vm.svelte.ts | 36 +- .../view/create/create.order.vm.svelte.ts | 20 +- .../domains/passengerinfo/data/repository.ts | 8 +- .../view/passenger-pii-form.svelte | 8 +- .../view/passenger.info.vm.svelte.ts | 28 +- .../ticket/data/amadeusapi.data.source.ts | 618 ------------------ .../billing-details-form.svelte | 5 +- .../billing.details.vm.svelte.ts | 22 +- bun.lock | 19 - packages/db/schema/index.ts | 60 +- .../logic/domains/airport/data/entities.ts | 12 - .../logic/domains/ckflow/data/entities.ts | 10 +- packages/logic/domains/customerinfo/data.ts | 46 ++ .../logic/domains/customerinfo/repository.ts | 300 +++++++++ .../logic/domains/customerinfo/usecases.ts | 42 ++ packages/logic/domains/order/data/entities.ts | 24 +- .../domains/passengerinfo/data/entities.ts | 40 +- 53 files changed, 702 insertions(+), 2068 deletions(-) delete mode 100644 apps/admin/src/lib/domains/account/data/entities.ts delete mode 100644 apps/admin/src/lib/domains/account/data/inbox.repository.ts delete mode 100644 apps/admin/src/lib/domains/account/data/repository.ts delete mode 100644 apps/admin/src/lib/domains/account/domain/controller.ts delete mode 100644 apps/admin/src/lib/domains/account/domain/router.ts delete mode 100644 apps/admin/src/lib/domains/account/utils.ts delete mode 100644 apps/admin/src/lib/domains/account/view/accounts-list-modal.svelte delete mode 100644 apps/admin/src/lib/domains/account/view/accounts-table.svelte delete mode 100644 apps/admin/src/lib/domains/account/view/accounts.vm.svelte.ts delete mode 100644 apps/admin/src/lib/domains/account/view/email-details.svelte delete mode 100644 apps/admin/src/lib/domains/account/view/emails-list.svelte create mode 100644 apps/admin/src/lib/domains/customerinfo/data.ts create mode 100644 apps/admin/src/lib/domains/customerinfo/repository.ts create mode 100644 apps/admin/src/lib/domains/customerinfo/router.ts create mode 100644 apps/admin/src/lib/domains/customerinfo/usecases.ts rename apps/admin/src/lib/domains/{passengerinfo/view/pinfo-card.svelte => customerinfo/view/cinfo-card.svelte} (100%) create mode 100644 apps/admin/src/lib/domains/customerinfo/view/customer-details-card.svelte rename apps/admin/src/lib/domains/{passengerinfo/view/passengerinfo-table.svelte => customerinfo/view/customerinfo-table.svelte} (79%) create mode 100644 apps/admin/src/lib/domains/customerinfo/view/customerinfo.vm.svelte.ts delete mode 100644 apps/admin/src/lib/domains/passengerinfo/data/entities.ts delete mode 100644 apps/admin/src/lib/domains/passengerinfo/data/repository.ts delete mode 100644 apps/admin/src/lib/domains/passengerinfo/domain/controller.ts delete mode 100644 apps/admin/src/lib/domains/passengerinfo/view/passengerinfo.vm.svelte.ts delete mode 100644 apps/admin/src/lib/domains/passengerinfo/view/payment-details-card.svelte delete mode 100644 apps/frontend/src/lib/domains/ticket/data/amadeusapi.data.source.ts delete mode 100644 packages/logic/domains/airport/data/entities.ts create mode 100644 packages/logic/domains/customerinfo/data.ts create mode 100644 packages/logic/domains/customerinfo/repository.ts create mode 100644 packages/logic/domains/customerinfo/usecases.ts diff --git a/.gitignore b/.gitignore index d1595be..36c28e3 100644 --- a/.gitignore +++ b/.gitignore @@ -14,10 +14,6 @@ __pycache__ ot_res.json out.json payload.json -skin.json -skyscanner.json -skyscanner.har -skyscanner-airport-search.har screenshots/*.jpeg screenshots/*.png diff --git a/apps/admin/src/lib/domains/account/data/entities.ts b/apps/admin/src/lib/domains/account/data/entities.ts deleted file mode 100644 index 470bae4..0000000 --- a/apps/admin/src/lib/domains/account/data/entities.ts +++ /dev/null @@ -1 +0,0 @@ -export * from "@pkg/logic/domains/account/data/entities"; diff --git a/apps/admin/src/lib/domains/account/data/inbox.repository.ts b/apps/admin/src/lib/domains/account/data/inbox.repository.ts deleted file mode 100644 index fbceff0..0000000 --- a/apps/admin/src/lib/domains/account/data/inbox.repository.ts +++ /dev/null @@ -1,137 +0,0 @@ -import { and, eq, inArray, notInArray, type Database } from "@pkg/db"; -import { inbox } from "@pkg/db/schema"; -import { ERROR_CODES, type Result } from "@pkg/result"; -import { inboxModel, type InboxModel } from "./entities"; -import { getError, Logger } from "@pkg/logger"; - -export class AccountInboxRepository { - db: Database; - - constructor(db: Database) { - this.db = db; - } - - async getAccountInbox( - accountId: number, - ignoreIds: number[] = [], - ): Promise> { - let condition: any = eq(inbox.emailAccountId, accountId); - if (ignoreIds.length > 0) { - condition = and(condition, notInArray(inbox.id, ignoreIds)); - } - - const queryRes = await this.db.query.inbox.findMany({ - where: condition, - }); - - const out = [] as InboxModel[]; - - for (const row of queryRes) { - const sParsed = inboxModel.safeParse(row); - if (sParsed.success) { - out.push(sParsed.data); - continue; - } - return { - error: getError( - { - code: ERROR_CODES.INTERNAL_SERVER_ERROR, - message: - "An error occured while fetching inbox for account", - userHint: "Please try again later, or contact us", - detail: "An error occured while fetching inbox for account", - actionable: false, - }, - sParsed.error.errors, - ), - }; - } - - return { data: out }; - } - - // checks which of these are already present in the db - async findEmailsAlreadyPresent( - emailIds: string[], - ): Promise> { - const found = await this.db.query.inbox.findMany({ - where: inArray(inbox.emailId, emailIds), - columns: { emailId: true }, - }); - return { data: found.map((e) => e.emailId) }; - } - - async insertMessages( - accountId: number, - messages: InboxModel[], - ): Promise> { - try { - const alreadyPresent = await this.findEmailsAlreadyPresent( - messages.map((e) => e.emailId), - ); - if (!alreadyPresent.data) { - return { error: alreadyPresent.error }; - } - const payload = messages - .filter((e) => !alreadyPresent.data?.includes(e.emailId)) - .map((m) => { - return { - emailId: m.emailId, - - from: m.from, - to: m.to, - cc: m.cc, - subject: m.subject, - body: m.body, - attachments: m.attachments, - - emailAccountId: accountId, - - dated: new Date(m.dated), - - createdAt: new Date(), - updatedAt: new Date(), - }; - }); - if (payload.length === 0) { - Logger.info( - `No msgs to insert for acc:${accountId} (${alreadyPresent.data.length} already present)`, - ); - return { data: [] }; - } - - Logger.info( - `Inserting ${messages.length} msgs for acc:${accountId} (${alreadyPresent.data.length} already present)`, - ); - const out = await this.db - .insert(inbox) - .values(payload) - .returning({ id: inbox.id }) - .execute(); - - return { data: out.map((e) => e.id) }; - } catch (e) { - return { - error: getError( - { - code: ERROR_CODES.INTERNAL_SERVER_ERROR, - message: - "An error occured while inserting messages for account", - userHint: "Please try again later, or contact us", - detail: "An error occured while inserting messages for account", - actionable: false, - }, - e, - ), - }; - } - } - - async getInboxMessagesCount(accountId: number): Promise> { - const res = await this.db.query.inbox.findMany({ - where: eq(inbox.emailAccountId, accountId), - columns: { id: true }, - }); - return { data: res ? res.length : 0 }; - } -} diff --git a/apps/admin/src/lib/domains/account/data/repository.ts b/apps/admin/src/lib/domains/account/data/repository.ts deleted file mode 100644 index d6227dd..0000000 --- a/apps/admin/src/lib/domains/account/data/repository.ts +++ /dev/null @@ -1,186 +0,0 @@ -import { eq, type Database } from "@pkg/db"; -import { - emailAccountFullModel, - emailAccountModel, - type EmailAccount, - type EmailAccountFull, -} from "./entities"; -import { ERROR_CODES, type Result } from "@pkg/result"; -import { Logger } from "@pkg/logger"; -import { getError } from "@pkg/logger"; -import { emailAccount } from "@pkg/db/schema"; - -export class AccountsRepository { - db: Database; - constructor(db: Database) { - this.db = db; - } - - async listAllEmailAccounts(): Promise> { - try { - const out = await this.db.query.emailAccount.findMany(); - Logger.info(out); - const parsed = [] as EmailAccount[]; - for (const each of out) { - const pRes = emailAccountModel.safeParse(each); - if (pRes.error) { - return { - error: getError( - { - code: ERROR_CODES.INTERNAL_SERVER_ERROR, - message: - "An error occured while listing email accounts", - userHint: "Please try again later", - actionable: false, - detail: "An error occured while listing email accounts", - }, - pRes.error.errors, - ), - }; - } - parsed.push(pRes.data); - } - return { data: parsed }; - } catch (e) { - return { - error: getError( - { - code: ERROR_CODES.INTERNAL_SERVER_ERROR, - message: "An error occured while listing email accounts", - userHint: "Please try again later", - actionable: false, - detail: "An error occured while listing email accounts", - }, - e, - ), - }; - } - } - - async getEmailAccount(id: number): Promise> { - try { - const out = await this.db.query.emailAccount.findFirst({ - where: eq(emailAccount.id, id), - }); - if (!out) { - Logger.error("Failed to get email account"); - Logger.debug(out); - return { - error: getError({ - code: ERROR_CODES.INTERNAL_SERVER_ERROR, - message: "Failed to get email account", - userHint: "Please try again", - detail: "Failed to get email account", - }), - }; - } - const pRes = emailAccountModel.safeParse(out); - if (pRes.error) { - return { - error: getError( - { - code: ERROR_CODES.INTERNAL_SERVER_ERROR, - message: "Failed to get email account", - userHint: "Please try again", - detail: "Failed to get email account", - }, - pRes.error, - ), - }; - } - return { data: pRes.data }; - } catch (e) { - return { - error: getError( - { - code: ERROR_CODES.INTERNAL_SERVER_ERROR, - message: "An error occured while getting email account", - userHint: "Please try again later", - actionable: false, - detail: "An error occured while getting email account", - }, - e, - ), - }; - } - } - - async getEmailAccountWithPassword( - id: number, - ): Promise> { - try { - const out = await this.db.query.emailAccount.findFirst({ - where: eq(emailAccount.id, id), - }); - if (!out) { - Logger.error("Failed to get email account"); - Logger.debug(out); - return { - error: getError({ - code: ERROR_CODES.INTERNAL_SERVER_ERROR, - message: "Failed to get email account", - userHint: "Please try again", - detail: "Failed to get email account", - }), - }; - } - const pRes = emailAccountFullModel.safeParse(out); - if (pRes.error) { - return { - error: getError( - { - code: ERROR_CODES.INTERNAL_SERVER_ERROR, - message: "Failed to get email account", - userHint: "Please try again", - detail: "Failed to get email account", - }, - pRes.error, - ), - }; - } - return { data: pRes.data }; - } catch (e) { - return { - error: getError( - { - code: ERROR_CODES.INTERNAL_SERVER_ERROR, - message: "An error occured while getting email account", - userHint: "Please try again later", - actionable: false, - detail: "An error occured while getting email account", - }, - e, - ), - }; - } - } - - // selector is either an email or an id - async updateLastActiveCheckAt(selector: number | string, ts: string) { - Logger.info(`Updating last active check at for ${selector}`); - try { - await this.db - .update(emailAccount) - .set({ lastActiveCheckAt: new Date(ts) }) - .where( - typeof selector === "string" - ? eq(emailAccount.email, selector) - : eq(emailAccount.id, selector), - ) - .execute(); - } catch (e) { - return { - error: getError( - { - message: "Failed to update last active check at", - code: ERROR_CODES.DATABASE_ERROR, - detail: "A database error occured while updating last active check at", - userHint: "Please try again later", - actionable: false, - }, - e, - ), - }; - } - } -} diff --git a/apps/admin/src/lib/domains/account/domain/controller.ts b/apps/admin/src/lib/domains/account/domain/controller.ts deleted file mode 100644 index 661e9c4..0000000 --- a/apps/admin/src/lib/domains/account/domain/controller.ts +++ /dev/null @@ -1,39 +0,0 @@ -import type { AccountInboxRepository } from "../data/inbox.repository"; -import type { AccountsRepository } from "../data/repository"; -import { type InboxModel } from "../data/entities"; -import { type Result } from "@pkg/result"; - -export class AccountsController { - repo: AccountsRepository; - inboxRepo: AccountInboxRepository; - - constructor(repo: AccountsRepository, inboxRepo: AccountInboxRepository) { - this.repo = repo; - this.inboxRepo = inboxRepo; - } - - async listAllEmailAccounts() { - return this.repo.listAllEmailAccounts(); - } - - async getEmailAccount(id: number) { - return this.repo.getEmailAccount(id); - } - - async getAccountInbox(accountId: number, ignoreIds: number[]) { - return this.inboxRepo.getAccountInbox(accountId); - } - - async checkAccountActiveStatus( - id: number, - ): Promise> { - return { data: { ok: false, ts: new Date().toISOString() } }; - } - - async refreshInbox( - accountId: number, - params?: any, - ): Promise> { - return { data: [] }; - } -} diff --git a/apps/admin/src/lib/domains/account/domain/router.ts b/apps/admin/src/lib/domains/account/domain/router.ts deleted file mode 100644 index cfa4c78..0000000 --- a/apps/admin/src/lib/domains/account/domain/router.ts +++ /dev/null @@ -1,43 +0,0 @@ -import { createTRPCRouter, protectedProcedure } from "$lib/trpc/t"; -import { db } from "@pkg/db"; -import { AccountsRepository } from "../data/repository"; -import { AccountsController } from "./controller"; -import { AccountInboxRepository } from "../data/inbox.repository"; -import { z } from "zod"; - -function getEAC() { - return new AccountsController( - new AccountsRepository(db), - new AccountInboxRepository(db), - ); -} - -export const emailAccountsRouter = createTRPCRouter({ - listAllEmailAccounts: protectedProcedure.query(async ({ ctx }) => { - return getEAC().listAllEmailAccounts(); - }), - - getEmailAccount: protectedProcedure - .input(z.object({ id: z.number() })) - .query(async ({ input }) => { - return getEAC().getEmailAccount(input.id); - }), - - checkAccountActiveStatus: protectedProcedure - .input(z.object({ id: z.number() })) - .query(async ({ input }) => { - return getEAC().checkAccountActiveStatus(input.id); - }), - - getAccountInbox: protectedProcedure - .input(z.object({ id: z.number(), ignoreIds: z.array(z.number()) })) - .query(async ({ input }) => { - return getEAC().getAccountInbox(input.id, input.ignoreIds); - }), - - refreshInbox: protectedProcedure - .input(z.object({ id: z.number() })) - .mutation(async ({ input }) => { - return getEAC().refreshInbox(input.id); - }), -}); diff --git a/apps/admin/src/lib/domains/account/utils.ts b/apps/admin/src/lib/domains/account/utils.ts deleted file mode 100644 index 77bf133..0000000 --- a/apps/admin/src/lib/domains/account/utils.ts +++ /dev/null @@ -1,10 +0,0 @@ -export function parseFrom(from: string) { - const match = from.match(/"(.*?)"\s*<(.+?)>/); - if (match) { - return { name: match[1], email: match[2] }; - } else { - // Handle cases where the name might be missing - const emailOnly = from.match(/<(.+?)>/); - return { name: null, email: emailOnly ? emailOnly[1] : from }; - } -} diff --git a/apps/admin/src/lib/domains/account/view/accounts-list-modal.svelte b/apps/admin/src/lib/domains/account/view/accounts-list-modal.svelte deleted file mode 100644 index 44ed48e..0000000 --- a/apps/admin/src/lib/domains/account/view/accounts-list-modal.svelte +++ /dev/null @@ -1,77 +0,0 @@ - - - - - - - - Agents' Email Accounts - -
- {#each accountsVM.accounts as acc} - {@const isCheckingFor = - accountsVM.checkingForId === acc.id && - accountsVM.checkingAccountActiveStatus} -
-
-

{acc.email}

-
- {#if !isCheckingFor} -

- Last Checked For Activity : - {acc.lastActiveCheckAt - ? new Date( - acc.lastActiveCheckAt, - ).toLocaleString() - : "Never"} -

- {:else} -

checking...

- {/if} -
-
- -
-
- - {acc.used ? "Not used" : "Used"} - -
- - -
-
- {/each} -
-
-
diff --git a/apps/admin/src/lib/domains/account/view/accounts-table.svelte b/apps/admin/src/lib/domains/account/view/accounts-table.svelte deleted file mode 100644 index abd6199..0000000 --- a/apps/admin/src/lib/domains/account/view/accounts-table.svelte +++ /dev/null @@ -1,130 +0,0 @@ - - -{#if data.length > 0} - { - table.nextPage(); - }} - onPreviousPageClick={() => { - table.previousPage(); - }} - currPage={pagination.pageIndex + 1} - totalPages={pageCount} - filterFieldDisabled={false} - query={passengerInfoVM.query} - hasData={data.length > 0} - onQueryChange={(q) => { - passengerInfoVM.query = q; - debouncedSearch(); - }} - filterFieldPlaceholder="Search users..." - /> -{:else} -
- No Orders found -
-{/if} diff --git a/apps/admin/src/lib/domains/account/view/accounts.vm.svelte.ts b/apps/admin/src/lib/domains/account/view/accounts.vm.svelte.ts deleted file mode 100644 index d7bea5c..0000000 --- a/apps/admin/src/lib/domains/account/view/accounts.vm.svelte.ts +++ /dev/null @@ -1,145 +0,0 @@ -import { trpcApiStore } from "$lib/stores/api"; -import { get } from "svelte/store"; -import { type InboxModel, type EmailAccount } from "../data/entities"; -import { toast } from "svelte-sonner"; - -export class AccountsViewModel { - accounts = $state([] as EmailAccount[]); - - chosenAccountId = $state(undefined); - - accountInbox = $state([]); - fetchingInbox = $state(false); - chosenMessageId = $state(undefined); - - showAccountsList = $state(false); - checkingAccountActiveStatus = $state(false); - checkingForId = $state(undefined); - - loading = $state(false); - query = $state(""); - - async fetchAccounts() { - const api = get(trpcApiStore); - if (!api) { - return toast("Api not initialized", { - description: "Try refreshing the page", - }); - } - this.loading = true; - const result = await api.emailAccounts.listAllEmailAccounts.query(); - this.loading = false; - if (result.error) { - return toast.error(result.error.message, { - description: result.error.userHint, - }); - } - if (!!result.data) { - this.accounts = result.data; - } - } - - async checkAccountsActiveStatus(id: number) { - const api = get(trpcApiStore); - if (!api) { - return toast("Api not initialized", { - description: "Try refreshing the page", - }); - } - this.checkingAccountActiveStatus = true; - this.checkingForId = id; - const result = await api.emailAccounts.checkAccountActiveStatus.query({ - id, - }); - this.checkingAccountActiveStatus = false; - this.checkingForId = undefined; - console.log(result); - if (result.error) { - return toast.error(result.error.message, { - description: result.error.userHint, - }); - } - if (!!result.data && !!result.data.ok) { - for (let i = 0; i < this.accounts.length; i++) { - if (this.accounts[i].id === id) { - this.accounts[i].lastActiveCheckAt = result.data.ts; - break; - } - } - } - } - - async fetchInbox() { - const api = get(trpcApiStore); - if (!api) { - return toast("Api not initialized", { - description: "Try refreshing the page", - }); - } - this.loading = true; - if (!this.chosenAccountId) { - return toast.error("No account selected", { - description: "Please select an account to perform action", - }); - } - const result = await api.emailAccounts.getAccountInbox.query({ - id: this.chosenAccountId, - ignoreIds: this.accountInbox.map((i) => i.id), - }); - this.loading = false; - console.log(result); - if (result.error) { - return toast.error(result.error.message, { - description: result.error.userHint, - }); - } - if (!!result.data) { - this.upsertMessages(result.data, true); - } - } - - async refreshInbox() { - const api = get(trpcApiStore); - if (!api) { - return toast("Api not initialized", { - description: "Try refreshing the page", - }); - } - if (!this.chosenAccountId) { - return toast.error("No account selected", { - description: "Please select an account to perform action", - }); - } - this.fetchingInbox = true; - const result = await api.emailAccounts.refreshInbox.mutate({ - id: this.chosenAccountId, - }); - this.fetchingInbox = false; - if (result.error) { - return toast.error(result.error.message, { - description: result.error.userHint, - }); - } - if (result.data) { - this.upsertMessages(result.data); - } - } - - private upsertMessages(messages: InboxModel[], reset = false) { - if (reset) { - this.accountInbox = messages; - return; - } - - for (const message of messages) { - const existing = this.accountInbox.find((m) => m.id === message.id); - if (existing) { - Object.assign(existing, message); - } else { - this.accountInbox.push(message); - } - } - } -} - -export const accountsVM = new AccountsViewModel(); diff --git a/apps/admin/src/lib/domains/account/view/email-details.svelte b/apps/admin/src/lib/domains/account/view/email-details.svelte deleted file mode 100644 index 1fddc98..0000000 --- a/apps/admin/src/lib/domains/account/view/email-details.svelte +++ /dev/null @@ -1,160 +0,0 @@ - - -{#if message} -
- -
-
- - - {parsedFrom.name?.slice(0, 2).toUpperCase() ?? - parsedFrom.email?.slice(0, 2).toUpperCase() ?? - "U"} - - - -
-
-
- - {parsedFrom.name} - - - - {parsedFrom.email} - -
- -

{message.subject}

- - {#if message.to} -
- To: - {message.to} -
- {/if} - - {#if message.cc} -
- CC: - {message.cc} -
- {/if} -
- -
- - {new Date(message.dated).toLocaleString()} - -
-
-
- - {#if message.attachments && message.attachments.length > 0} -
-

Attachments:

-
- {#each message.attachments as attachment} -
- {attachment.filename} -
- {/each} -
-
- {/if} -
- - -
- -
-
-{:else} -
- -
-

No message selected

-
-
-
-{/if} diff --git a/apps/admin/src/lib/domains/account/view/emails-list.svelte b/apps/admin/src/lib/domains/account/view/emails-list.svelte deleted file mode 100644 index b715079..0000000 --- a/apps/admin/src/lib/domains/account/view/emails-list.svelte +++ /dev/null @@ -1,39 +0,0 @@ - - -{#each accountsVM.accountInbox.toReversed() as each, idx} - {@const parsed = parseFrom(each.from)} - -{/each} diff --git a/apps/admin/src/lib/domains/customerinfo/data.ts b/apps/admin/src/lib/domains/customerinfo/data.ts new file mode 100644 index 0000000..a0f64fd --- /dev/null +++ b/apps/admin/src/lib/domains/customerinfo/data.ts @@ -0,0 +1 @@ +export * from "@pkg/logic/domains/customerinfo/data"; diff --git a/apps/admin/src/lib/domains/customerinfo/repository.ts b/apps/admin/src/lib/domains/customerinfo/repository.ts new file mode 100644 index 0000000..b8207a9 --- /dev/null +++ b/apps/admin/src/lib/domains/customerinfo/repository.ts @@ -0,0 +1 @@ +export * from "@pkg/logic/domains/customerinfo/repository"; diff --git a/apps/admin/src/lib/domains/customerinfo/router.ts b/apps/admin/src/lib/domains/customerinfo/router.ts new file mode 100644 index 0000000..a9ea1fe --- /dev/null +++ b/apps/admin/src/lib/domains/customerinfo/router.ts @@ -0,0 +1,47 @@ +import { protectedProcedure } from "$lib/server/trpc/t"; +import { createTRPCRouter } from "$lib/trpc/t"; +import { z } from "zod"; +import { createCustomerInfoPayload, updateCustomerInfoPayload } from "./data"; +import { getCustomerInfoUseCases } from "./usecases"; + +export const customerInfoRouter = createTRPCRouter({ + getAllCustomerInfo: protectedProcedure.query(async ({}) => { + const controller = getCustomerInfoUseCases(); + return controller.getAllCustomerInfo(); + }), + + getCustomerInfoById: protectedProcedure + .input(z.object({ id: z.number() })) + .query(async ({ input }) => { + const controller = getCustomerInfoUseCases(); + return controller.getCustomerInfoById(input.id); + }), + + getCustomerInfoByOrderId: protectedProcedure + .input(z.object({ orderId: z.number() })) + .query(async ({ input }) => { + const controller = getCustomerInfoUseCases(); + return controller.getCustomerInfoByOrderId(input.orderId); + }), + + createCustomerInfo: protectedProcedure + .input(createCustomerInfoPayload) + .mutation(async ({ input }) => { + const controller = getCustomerInfoUseCases(); + return controller.createCustomerInfo(input); + }), + + updateCustomerInfo: protectedProcedure + .input(updateCustomerInfoPayload) + .mutation(async ({ input }) => { + const controller = getCustomerInfoUseCases(); + return controller.updateCustomerInfo(input); + }), + + deleteCustomerInfo: protectedProcedure + .input(z.object({ id: z.number() })) + .mutation(async ({ input }) => { + const controller = getCustomerInfoUseCases(); + return controller.deleteCustomerInfo(input.id); + }), +}); diff --git a/apps/admin/src/lib/domains/customerinfo/usecases.ts b/apps/admin/src/lib/domains/customerinfo/usecases.ts new file mode 100644 index 0000000..29e3df0 --- /dev/null +++ b/apps/admin/src/lib/domains/customerinfo/usecases.ts @@ -0,0 +1 @@ +export * from "@pkg/logic/domains/customerinfo/usecases"; diff --git a/apps/admin/src/lib/domains/passengerinfo/view/pinfo-card.svelte b/apps/admin/src/lib/domains/customerinfo/view/cinfo-card.svelte similarity index 100% rename from apps/admin/src/lib/domains/passengerinfo/view/pinfo-card.svelte rename to apps/admin/src/lib/domains/customerinfo/view/cinfo-card.svelte diff --git a/apps/admin/src/lib/domains/customerinfo/view/customer-details-card.svelte b/apps/admin/src/lib/domains/customerinfo/view/customer-details-card.svelte new file mode 100644 index 0000000..cad5ceb --- /dev/null +++ b/apps/admin/src/lib/domains/customerinfo/view/customer-details-card.svelte @@ -0,0 +1,57 @@ + + + +
+
+ Full Name +

+ {customerInfo.firstName} + {#if customerInfo.middleName} + {customerInfo.middleName} + {/if} + {customerInfo.lastName} +

+
+
+ Email +

{customerInfo.email}

+
+
+ Phone Number +

{customerInfo.phoneCountryCode} {customerInfo.phoneNumber}

+
+
+ City +

{customerInfo.city}

+
+
+ State +

{customerInfo.state}

+
+
+ Country +

{customerInfo.country}

+
+
+ Zip Code +

{customerInfo.zipCode}

+
+
+ Address +

{customerInfo.address}

+ {#if customerInfo.address2} +

{customerInfo.address2}

+ {/if} +
+
+
diff --git a/apps/admin/src/lib/domains/passengerinfo/view/passengerinfo-table.svelte b/apps/admin/src/lib/domains/customerinfo/view/customerinfo-table.svelte similarity index 79% rename from apps/admin/src/lib/domains/passengerinfo/view/passengerinfo-table.svelte rename to apps/admin/src/lib/domains/customerinfo/view/customerinfo-table.svelte index 004e9a6..a2eef3a 100644 --- a/apps/admin/src/lib/domains/passengerinfo/view/passengerinfo-table.svelte +++ b/apps/admin/src/lib/domains/customerinfo/view/customerinfo-table.svelte @@ -1,29 +1,29 @@ - -{#if paymentDetails} - -
-
- Cardholder Name -

{paymentDetails.cardholderName}

-
-
- Card Number -

- {#if showFullDetails} - {paymentDetails.cardNumber} - {:else} - •••• •••• •••• {paymentDetails.cardNumber.slice(-4)} - {/if} -

-
-
- Expiry -

{paymentDetails.expiry}

-
- {#if showFullDetails} -
- CVV -

{paymentDetails.cvv}

-
- {/if} -
-
-{/if} diff --git a/apps/admin/src/lib/domains/product/view/product-list.svelte b/apps/admin/src/lib/domains/product/view/product-list.svelte index 3047529..d58f425 100644 --- a/apps/admin/src/lib/domains/product/view/product-list.svelte +++ b/apps/admin/src/lib/domains/product/view/product-list.svelte @@ -117,7 +117,9 @@
{product.title}
-
+
{product.description}
diff --git a/apps/admin/src/lib/trpc/router/index.ts b/apps/admin/src/lib/trpc/router/index.ts index 045bbc5..713fdea 100644 --- a/apps/admin/src/lib/trpc/router/index.ts +++ b/apps/admin/src/lib/trpc/router/index.ts @@ -1,7 +1,7 @@ -import { emailAccountsRouter } from "$lib/domains/account/domain/router"; import { authRouter } from "$lib/domains/auth/domain/router"; import { ckflowRouter } from "$lib/domains/ckflow/router"; import { couponRouter } from "$lib/domains/coupon/router"; +import { customerInfoRouter } from "$lib/domains/customerinfo/router"; import { orderRouter } from "$lib/domains/order/domain/router"; import { productRouter } from "$lib/domains/product/router"; import { userRouter } from "$lib/domains/user/domain/router"; @@ -11,10 +11,10 @@ export const router = createTRPCRouter({ auth: authRouter, user: userRouter, order: orderRouter, - emailAccounts: emailAccountsRouter, ckflow: ckflowRouter, coupon: couponRouter, product: productRouter, + customerInfo: customerInfoRouter, }); export type Router = typeof router; diff --git a/apps/admin/src/routes/(main)/data/+page.server.ts b/apps/admin/src/routes/(main)/data/+page.server.ts index 99d1fc6..54c653d 100644 --- a/apps/admin/src/routes/(main)/data/+page.server.ts +++ b/apps/admin/src/routes/(main)/data/+page.server.ts @@ -1,15 +1,13 @@ +import { getCustomerInfoUseCases } from "$lib/domains/customerinfo/usecases"; import { redirect } from "@sveltejs/kit"; import type { PageServerLoad } from "./$types"; -import { PassengerInfoController } from "$lib/domains/passengerinfo/domain/controller"; -import { PassengerInfoRepository } from "$lib/domains/passengerinfo/data/repository"; -import { db } from "@pkg/db"; export const load: PageServerLoad = async ({ locals }) => { const sess = locals.session; if (!sess) { return redirect(302, "/auth/login"); } - const pc = new PassengerInfoController(new PassengerInfoRepository(db)); - const res = await pc.listAllPassengerInfos(); + const cu = getCustomerInfoUseCases(); + const res = await cu.getAllCustomerInfo(); return { data: res.data ?? [], error: res.error }; }; diff --git a/apps/admin/src/routes/(main)/data/+page.svelte b/apps/admin/src/routes/(main)/data/+page.svelte index 3217c48..5a33b4e 100644 --- a/apps/admin/src/routes/(main)/data/+page.svelte +++ b/apps/admin/src/routes/(main)/data/+page.svelte @@ -1,11 +1,11 @@