Skip to content
Merged

test #716

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 35 additions & 11 deletions apps/client/edb/module-federation.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,40 @@ const loose: SharedLibraryConfig = {
requiredVersion: false,
};

const looseSingletonPackages = new Set([
'@carbon/styles',
'@eDB/client-admin',
'@eDB/shared-env',
'@edb/shared-types',
'@edb/shared-ui',
'@edb/util-common',
'@edb/util-user-params',
'@fortawesome/angular-fontawesome',
'@microsoft/signalr',
'@tanstack/angular-query-experimental',
'@tanstack/query-core',
'carbon-components',
'carbon-components-angular',
'chart.js',
'ng2-charts',
]);

const targetConfiguration =
process.env.NX_TASK_TARGET_CONFIGURATION ??
process.env.NODE_ENV ??
'development';

const adminRemoteEntry =
process.env.MFE_EDB_ADMIN_REMOTE_ENTRY ??
(targetConfiguration === 'production'
? 'https://app.eliasdebock.com/admin/remoteEntry.mjs'
: targetConfiguration === 'staging'
? 'https://app.staging.eliasdebock.com/admin/remoteEntry.mjs'
: 'http://localhost:4300/remoteEntry.mjs');

export default {
name: 'edb',
remotes: ['mfe-edb-admin'],
remotes: [['mfe-edb-admin', adminRemoteEntry]],
exposes: {},

shared: (pkg?: string) => {
Expand All @@ -46,20 +77,13 @@ export default {

// 4. Your shared libs / UI kits – loose singleton
if (
pkg === '@edb/shared-ui' ||
pkg === '@edb/shared-types' ||
pkg === 'carbon-components-angular' ||
pkg === 'carbon-components' ||
pkg === '@carbon/styles' ||
pkg === '@tanstack/angular-query-experimental' ||
pkg === '@tanstack/query-core' ||
pkg === 'chart.js' ||
pkg === 'ng2-charts'
looseSingletonPackages.has(pkg) ||
pkg.startsWith('carbon-components-angular/')
) {
return loose;
}

// 5. Everything else – do not share
// 5. Everything else – do not share.
return false;
},
} satisfies ModuleFederationConfig;
14 changes: 13 additions & 1 deletion apps/client/edb/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,19 @@
"port": 4200,
"staticFilePath": "dist/apps/client/edb/browser",
"spa": true
}
},
"configurations": {
"development": {
"buildTarget": "edb:build:development"
},
"staging": {
"buildTarget": "edb:build:staging"
},
"production": {
"buildTarget": "edb:build:production"
}
},
"defaultConfiguration": "development"
}
}
}
29 changes: 20 additions & 9 deletions apps/client/mfe-edb-admin/module-federation.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,24 @@ const loose: SharedLibraryConfig = {
requiredVersion: false,
};

const looseSingletonPackages = new Set([
'@carbon/styles',
'@eDB/client-admin',
'@eDB/shared-env',
'@edb/shared-types',
'@edb/shared-ui',
'@edb/util-common',
'@edb/util-user-params',
'@fortawesome/angular-fontawesome',
'@microsoft/signalr',
'@tanstack/angular-query-experimental',
'@tanstack/query-core',
'carbon-components',
'carbon-components-angular',
'chart.js',
'ng2-charts',
]);

export default {
name: 'mfe-edb-admin',

Expand Down Expand Up @@ -48,15 +66,8 @@ export default {

// 4. Your shared libs / UI kits – loose singleton
if (
pkg === '@edb/shared-ui' ||
pkg === '@edb/shared-types' ||
pkg === 'carbon-components-angular' ||
pkg === 'carbon-components' ||
pkg === '@carbon/styles' ||
pkg === '@tanstack/angular-query-experimental' ||
pkg === '@tanstack/query-core' ||
pkg === 'chart.js' ||
pkg === 'ng2-charts'
looseSingletonPackages.has(pkg) ||
pkg.startsWith('carbon-components-angular/')
) {
return loose;
}
Expand Down
14 changes: 13 additions & 1 deletion apps/client/mfe-edb-admin/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,16 @@
}
},
"staging": {
"optimization": true,
"optimization": {
"scripts": true,
"styles": {
"minify": true,
"inlineCritical": false
},
"fonts": {
"inline": false
}
},
"sourceMap": false,
"outputHashing": "all",
"namedChunks": true,
Expand Down Expand Up @@ -158,6 +167,9 @@
"development": {
"buildTarget": "mfe-edb-admin:build:development"
},
"staging": {
"buildTarget": "mfe-edb-admin:build:staging"
},
"production": {
"buildTarget": "mfe-edb-admin:build:production"
}
Expand Down
16 changes: 13 additions & 3 deletions apps/client/mfe-edb-admin/src/app/app.component.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,20 @@
// import { Component } from '@angular/core';
// import { RouterOutlet } from '@angular/router';

// @Component({
// // Dev-only host shell... In prod the remote is loaded via module federation routes.
// selector: 'app-admin-root',
// template: `<router-outlet />`,
// imports: [RouterOutlet],
// })
// export class AppComponent {}

import { Component } from '@angular/core';
import { RouterOutlet } from '@angular/router';

@Component({
// Dev-only host shell... In prod the remote is loaded via module federation routes.
selector: 'app-admin-root',
template: `<router-outlet />`,
imports: [RouterOutlet],
template: ``,
imports: [],
})
export class AppComponent {}
2 changes: 1 addition & 1 deletion apps/client/mfe-edb-admin/src/main.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
// import('./bootstrap').catch((err) => console.error(err));
// apps/client/mfe-edb-admin/src/main.ts
// apps/client/mfe-edb-admin/src/main.ts.
import('./bootstrap').catch((err) => console.error(err));
2 changes: 1 addition & 1 deletion apps/server/admin-api/Mapping/MappingProfile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public MappingProfile()
)
.ForMember(
dest => dest.UserEmail,
opt => opt.Ignore() // Or use a placeholder since email isn't available locally
opt => opt.MapFrom(_ => string.Empty)
)
.ForMember(
dest => dest.SubscriptionDate,
Expand Down
4 changes: 3 additions & 1 deletion apps/server/platform-api/appsettings.Development.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@
"CatalogApplications": {
"ClaraUrl": "https://clara.eliasdebock.com",
"NemesisUrl": "https://nemesis.eliasdebock.com",
"PropertyManagerUrl": "https://property.eliasdebock.com"
"PropertyManagerUrl": "https://property.eliasdebock.com",
"SmostrAdminUrl": "https://admin.smostr.com",
"SmostrShopUrl": "https://shop.smostr.com"
}
}
4 changes: 3 additions & 1 deletion apps/server/platform-api/appsettings.Staging.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
"CatalogApplications": {
"ClaraUrl": "https://clara.eliasdebock.com",
"NemesisUrl": "https://nemesis.eliasdebock.com",
"PropertyManagerUrl": "https://property.eliasdebock.com"
"PropertyManagerUrl": "https://property.eliasdebock.com",
"SmostrAdminUrl": "https://admin.smostr.com",
"SmostrShopUrl": "https://shop.smostr.com"
}
}
4 changes: 3 additions & 1 deletion apps/server/platform-api/appsettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
"CatalogApplications": {
"ClaraUrl": "https://clara.eliasdebock.com",
"NemesisUrl": "https://nemesis.eliasdebock.com",
"PropertyManagerUrl": "https://property.eliasdebock.com"
"PropertyManagerUrl": "https://property.eliasdebock.com",
"SmostrAdminUrl": "https://admin.smostr.com",
"SmostrShopUrl": "https://shop.smostr.com"
}
}
2 changes: 1 addition & 1 deletion apps/server/webshop-api/.env.production
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ SCOUT_DRIVER=meilisearch
MEILISEARCH_HOST=http://meilisearch-prod.search.svc.cluster.local:7700

CHECKOUT_SUCCESS_URL=https://app.eliasdebock.com/webshop/checkout/success?session_id={CHECKOUT_SESSION_ID}
CHECKOUT_CANCEL_URL=https://app.eliasdebock.com/webshop/checkout/cancel
CHECKOUT_CANCEL_URL=https://app.eliasdebock.com/webshop/checkout
2 changes: 1 addition & 1 deletion apps/server/webshop-api/.env.staging
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ SCOUT_DRIVER=meilisearch
MEILISEARCH_HOST=http://meilisearch-staging.search.svc.cluster.local:7700

CHECKOUT_SUCCESS_URL=https://app.staging.eliasdebock.com/webshop/checkout/success?session_id={CHECKOUT_SESSION_ID}
CHECKOUT_CANCEL_URL=https://app.staging.eliasdebock.com/webshop/checkout/cancel
CHECKOUT_CANCEL_URL=https://app.staging.eliasdebock.com/webshop/checkout
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
use App\Services\Messaging\AmqpPublisher;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Log;
use Stripe\Exception\ApiErrorException;

class CheckoutController extends Controller
{
Expand Down Expand Up @@ -64,30 +65,48 @@ public function createCheckoutSession(Request $request): JsonResponse
// Save shipping data in cache for webhook
Cache::put("checkout_user_{$userId}", $shipping, now()->addMinutes(30));

// Create Stripe session
Stripe::setApiKey(config('services.stripe.secret'));
$stripeSecret = config('services.stripe.secret');
if (!$stripeSecret) {
return response()->json(['error' => 'Stripe secret is not configured'], 500);
}

$successUrl = config('services.checkout.success_url');
$cancelUrl = config('services.checkout.cancel_url');

$session = Session::create([
'payment_method_types' => ['card'],
'line_items' => [[
'price_data' => [
'currency' => 'eur',
'product_data' => [
'name' => 'Book Order',
Stripe::setApiKey($stripeSecret);

try {
$session = Session::create([
'payment_method_types' => ['card'],
'line_items' => [[
'price_data' => [
'currency' => 'eur',
'product_data' => [
'name' => 'Book Order',
],
'unit_amount' => (int) ($amount * 100),
],
'unit_amount' => (int) ($amount * 100),
'quantity' => 1,
]],
'mode' => 'payment',
'customer_email' => $shipping['email'],
'metadata' => [
'user_id' => $userId,
],
'quantity' => 1,
]],
'mode' => 'payment',
'customer_email' => $shipping['email'],
'metadata' => [
'success_url' => $successUrl,
'cancel_url' => $cancelUrl,
]);
} catch (ApiErrorException $e) {
Log::error('Stripe checkout session creation failed', [
'user_id' => $userId,
],
'success_url' => env('CHECKOUT_SUCCESS_URL'),
'cancel_url' => env('CHECKOUT_CANCEL_URL'),
'error' => $e->getMessage(),
]);

]);
return response()->json([
'error' => 'Could not create checkout session',
'details' => $e->getMessage(),
], 502);
}

return response()->json(['url' => $session->url]);
}
Expand Down
12 changes: 12 additions & 0 deletions apps/server/webshop-api/config/services.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,16 @@
'secret' => env('STRIPE_SECRET'),
],

'checkout' => [
'frontend_url' => rtrim(env('FRONTEND_URL', 'http://localhost:4200'), '/'),
'success_url' => env(
'CHECKOUT_SUCCESS_URL',
rtrim(env('FRONTEND_URL', 'http://localhost:4200'), '/') . '/webshop/checkout/success?session_id={CHECKOUT_SESSION_ID}'
),
'cancel_url' => env(
'CHECKOUT_CANCEL_URL',
rtrim(env('FRONTEND_URL', 'http://localhost:4200'), '/') . '/webshop/checkout'
),
],

];
1 change: 1 addition & 0 deletions libs/client/edb/data-access/client-books/src/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
export * from './lib/client';
export * from './lib/wishlist.service';
9 changes: 6 additions & 3 deletions libs/client/edb/data-access/client-books/src/lib/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,13 @@ export class BooksService {
const status = this.bookParamService.statusSignal();
const sort = this.bookParamService.sortSignal();

// Build common query params
let params = new HttpParams().set('status', status || 'available');
// Build common query params. "all" means no filter for that field.
let params = new HttpParams();

if (genre) {
if (status && status !== 'all') {
params = params.set('status', status);
}
if (genre && genre !== 'all') {
params = params.set('genre', genre);
}
if (search) {
Expand Down
Loading
Loading