Skip to content

Commit

Permalink
Merge branch 'f/device-identification' into next
Browse files Browse the repository at this point in the history
  • Loading branch information
conradbekondo committed Feb 3, 2025
2 parents e933e9d + 9563498 commit e56d5d5
Show file tree
Hide file tree
Showing 30 changed files with 419 additions and 128 deletions.
2 changes: 1 addition & 1 deletion lib/models/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export const AccessTokenClaimsSchema = z.object({
name: z.string(),
image: z.string().optional(),
tokenId: z.string().uuid(),
aud: z.string(),
aud: z.string().optional(),
exp: z.number()
});

Expand Down
52 changes: 37 additions & 15 deletions lib/models/wallet.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,43 @@
import { z } from "zod";

export const WalletTransferSchema = z.object({
id: z.string(),
from: z.string().uuid().nullable(),
to: z.string().uuid(),
amount: z.number(),
status: z.enum(['pending', 'cancelled', 'complete']),
type: z.enum(['funding', 'reward', 'withdrawal']),
date: z.date(),
payment: z.object({
id: z.string().uuid(),
currency: z.string(),
amount: z.number(),
status: z.enum(['pending', 'cancelled', 'complete'])
}).nullable()
burst: z.union([z.string(), z.date()]).pipe(z.coerce.date()),
creditAllocationId: z.string().uuid().nullable(),
creditAllocation: z
.object({
allocated: z.union([z.string(), z.number()]).pipe(z.coerce.number()),
status: z.string(),
})
.nullable(),
credits: z.union([z.string(), z.number()]).pipe(z.coerce.number()),
notes: z.string().nullable(),
paymentTransaction: z
.object({
status: z.string(),
amount: z.union([z.string(), z.number()]).pipe(z.coerce.number()),
currency: z.string(),
})
.nullable(),
paymentTransactionId: z.string().nullable(),
recordedAt: z.union([z.string(), z.date()]).pipe(z.coerce.date()),
status: z.string(),
transaction: z.string().uuid(),
type: z.string(),
});

export const WalletTransferGroupSchema = z.object({
burst: z.union([z.string(), z.date()]).pipe(z.coerce.date()),
fundingRewardsRatio: z
.union([z.string(), z.number()])
.pipe(z.coerce.number()),
owner: z.union([z.string(), z.number()]).pipe(z.coerce.number()),
transferredCredits: z.union([z.string(), z.number()]).pipe(z.coerce.number()),
wallet: z.string().uuid(),
transfers: z.array(WalletTransferSchema),
});



export const WalletBalanceSchema = z.object({
balance: z.union([z.string(), z.number()]).pipe(z.coerce.number()),
ownerId: z.number(),
Expand All @@ -29,8 +51,8 @@ export const BalancesSchema = z.object({

export const WalletTransfersResponseSchema = z.object({
total: z.number(),
data: z.array(WalletTransferSchema)
})
groups: z.array(WalletTransferGroupSchema),
});

export type WalletBalanceInfo = z.infer<typeof WalletBalanceSchema>;
export type WalletTransfer = z.infer<typeof WalletTransferSchema>;
Expand Down
5 changes: 0 additions & 5 deletions netlify.toml
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
[[redirects]]
from = "/api/*"
to = "${API_ORIGIN}/:splat"
status = 301

[context.branch-deploy]
command = "pnpm build --configuration staging"

Expand Down
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"version": "0.1.0",
"scripts": {
"ng": "ng",
"start": "ng serve --proxy-config proxy.conf.json",
"start": "ng serve",
"build": "ng build",
"watch": "ng build --watch --configuration development",
"test": "ng test",
Expand All @@ -20,6 +20,7 @@
"@angular/platform-browser": "^19.1.1",
"@angular/platform-browser-dynamic": "^19.1.1",
"@angular/router": "^19.1.1",
"@aws-crypto/sha256-js": "^5.2.0",
"@ngxs/devtools-plugin": "^19.0.0",
"@ngxs/logger-plugin": "^19.0.0",
"@ngxs/router-plugin": "^19.0.0",
Expand All @@ -37,6 +38,7 @@
"tailwindcss-primeui": "^0.3.4",
"tslib": "^2.8.1",
"zod": "^3.24.1",
"zod-validation-error": "^3.4.0",
"zone.js": "~0.15.0"
},
"devDependencies": {
Expand Down
78 changes: 78 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 0 additions & 10 deletions proxy.conf.json

This file was deleted.

1 change: 1 addition & 0 deletions public/recaptcha-api.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 0 additions & 26 deletions scripts/seed.ts

This file was deleted.

5 changes: 5 additions & 0 deletions src/app/app.routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ import { NotFoundComponent } from './pages/not-found/not-found.component';
const signedInGuard = authGuard('/auth/login');

export const appRoutes: Routes = [
{
path: 'analytics',
title: 'Analytics',
loadComponent: () => import('./pages/analytics/analytics.component').then(m => m.AnalyticsComponent)
},
{
path: 'auth',
loadChildren: () => import('./auth.routes').then(m => m.authRoutes)
Expand Down
3 changes: 2 additions & 1 deletion src/app/components/campaign-form/campaign-form.component.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { HttpClient, HttpErrorResponse } from "@angular/common/http";
import { Component, inject, output, signal } from "@angular/core";
import { FormControl, FormGroup, ReactiveFormsModule, Validators } from "@angular/forms";
import { environment } from "@env/environment.development";
import { Button } from "primeng/button";
import { Fluid } from "primeng/fluid";
import { InputText } from "primeng/inputtext";
Expand Down Expand Up @@ -30,7 +31,7 @@ export class CampaignFormComponent {
onCreateCampaignButtonClicked() {
this.submitting.set(true);
const val = this.form.value;
this.http.post('/api/campaign', val).subscribe({
this.http.post(`${environment.apiOrigin}/campaign`, val).subscribe({
error: (error: HttpErrorResponse) => {
this.submitting.set(false);
this.onErrored.emit(error.error ?? error);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { Component, computed, inject, input, model, ResourceRef } from '@angular
import { rxResource } from '@angular/core/rxjs-interop';
import { RouterLink } from '@angular/router';
import { PublicationFormComponent } from '@app/components/publication-form';
import { environment } from '@env/environment.development';
import { Campaign, CampaignPublication } from '@lib/models/campaign';
import { WalletBalanceResponse } from '@lib/models/wallet';
import { Button } from 'primeng/button';
Expand Down Expand Up @@ -39,10 +40,10 @@ export class CampaignPublications {
readonly showNewPublicationModal = model(false);
readonly publications: ResourceRef<CampaignPublication[]> = rxResource({
request: () => this.campaign()?.id,
loader: ({ request }) => request ? this.http.get<CampaignPublication[]>(`/api/campaign/publications/${request}`) : of([])
loader: ({ request }) => request ? this.http.get<CampaignPublication[]>(`${environment.apiOrigin}/campaign/publications/${request}`) : of([])
});
private readonly walletBalances = rxResource({
loader: () => this.http.get<WalletBalanceResponse>('/api/wallet/balances')
loader: () => this.http.get<WalletBalanceResponse>(environment.apiOrigin + '/wallet/balances')
});
readonly availableFundingCredits = computed(() => {
return this.walletBalances.value()?.funding?.balance ?? 0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@
label: uploading() ? 'Uploading' : 'Upload file',
loading: uploading(),
disabled: uploading()
}" chooseIcon="pi pi-upload" mode="basic" auto url="/api/blob" name="file"
}" chooseIcon="pi pi-upload" mode="basic" auto url="{{origin}}/blob" name="file"
accept="image/*,video/*" maxFileSize="6291456" (onError)="onUploadFailed($event)"

Check notice on line 189 in src/app/components/campaign-settings/campaign-settings.component.html

View workflow job for this annotation

GitHub Actions / Qodana for JS

Undefined binding

Event onError is not emitted by any applicable directives nor by <p-fileupload> element
(onSend)="onBeforeUpload()" (onUpload)="onAttachmentFileUploaded($event)" />

Check notice on line 190 in src/app/components/campaign-settings/campaign-settings.component.html

View workflow job for this annotation

GitHub Actions / Qodana for JS

Undefined binding

Event onUpload is not emitted by any applicable directives nor by <p-fileupload> element

Check notice on line 190 in src/app/components/campaign-settings/campaign-settings.component.html

View workflow job for this annotation

GitHub Actions / Qodana for JS

Undefined binding

Event onSend is not emitted by any applicable directives nor by <p-fileupload> element
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { rxResource, takeUntilDestroyed } from '@angular/core/rxjs-interop';
import { AbstractControl, FormArray, FormControl, FormGroup, ReactiveFormsModule, Validators } from '@angular/forms';
import { PhoneDirective } from '@app/directives/phone.directive';
import { phoneValidator } from '@app/util/phone-valiator';
import { environment } from '@env/environment.development';
import { Campaign } from '@lib/models/campaign';
import { Category } from '@lib/models/category';
import { CountryData } from '@lib/models/country-data';
Expand Down Expand Up @@ -96,10 +97,10 @@ export class CampaignSettings {
readonly error = output<Error>();
readonly campaign = input<Campaign>();
readonly categories = rxResource({
loader: () => this.http.get<Category[]>('/api/categories')
loader: () => this.http.get<Category[]>(environment.apiOrigin + '/categories')
});
readonly countries = rxResource({
loader: () => this.http.get<CountryData[]>('/api/countries')
loader: () => this.http.get<CountryData[]>(environment.apiOrigin + '/countries')
});
readonly form = new FormGroup({
general: new FormGroup({
Expand All @@ -119,6 +120,10 @@ export class CampaignSettings {
media: new FormArray<FormControl<string>>([])
});

get origin() {
return environment.apiOrigin;
}

get emails() {
return this.form.controls.linksAndContacts.controls.emails;
}
Expand Down Expand Up @@ -363,7 +368,7 @@ export class CampaignSettings {
...this.modifiedLinksAndContactsOutput
};

this.http.patch(`/api/campaign/${this.campaign()?.id}`, request).subscribe({
this.http.patch(`${environment.apiOrigin}/campaign/${this.campaign()?.id}`, request).subscribe({
error: (error: HttpErrorResponse) => {
this.ms.add({
severity: 'error',
Expand Down Expand Up @@ -415,7 +420,7 @@ export class CampaignSettings {

private doDeleteCampaign() {
this.deleting.set(true);
this.http.delete(`/api/campaign/${this.campaign()?.id}`).subscribe({
this.http.delete(`${environment.apiOrigin}/campaign/${this.campaign()?.id}`).subscribe({
error: (error: HttpErrorResponse) => {
this.deleting.set(false);
this.error.emit(error?.error ?? error);
Expand Down
Loading

0 comments on commit e56d5d5

Please sign in to comment.