Prettier.
This commit is contained in:
parent
b42971703f
commit
14acdc3e83
@ -28,7 +28,7 @@ export class RecipePageContent {
|
||||
const recipe = this.recipeView().recipe;
|
||||
return {
|
||||
queryKey: ['recipe-main-images', recipe.owner.username, recipe.slug],
|
||||
queryFn: () => this.imageService.getImage(recipe.mainImage?.url)
|
||||
queryFn: () => this.imageService.getImage(recipe.mainImage?.url),
|
||||
};
|
||||
});
|
||||
|
||||
|
||||
@ -76,7 +76,10 @@ export class RecipeUploadPage implements OnInit {
|
||||
.subscribe();
|
||||
}
|
||||
|
||||
private async switchModel(model: RecipeUploadClientModel, switchStep: boolean | RecipeUploadStep = false): Promise<void> {
|
||||
private async switchModel(
|
||||
model: RecipeUploadClientModel,
|
||||
switchStep: boolean | RecipeUploadStep = false,
|
||||
): Promise<void> {
|
||||
this.model.set(model);
|
||||
this.includeInfer.set(!!model.draft?.lastInference);
|
||||
if (switchStep === true) {
|
||||
@ -140,7 +143,7 @@ export class RecipeUploadPage implements OnInit {
|
||||
const model = await this.recipeDraftService.updateDraft(this.model().draft!.id, {
|
||||
title,
|
||||
slug,
|
||||
rawText
|
||||
rawText,
|
||||
});
|
||||
await this.switchModel(model, RecipeUploadStep.REVIEW);
|
||||
}
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
export type EnterRecipeDataEvent = EnterRecipeDataSubmitEvent
|
||||
export type EnterRecipeDataEvent = EnterRecipeDataSubmitEvent;
|
||||
|
||||
export interface EnterRecipeDataSubmitEvent {
|
||||
_type: 'submit';
|
||||
@ -6,5 +6,5 @@ export interface EnterRecipeDataSubmitEvent {
|
||||
title: string;
|
||||
slug: string;
|
||||
rawText: string;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@ -5,7 +5,8 @@ import {
|
||||
inject,
|
||||
Injector,
|
||||
input,
|
||||
OnInit, output,
|
||||
OnInit,
|
||||
output,
|
||||
runInInjectionContext,
|
||||
viewChild,
|
||||
} from '@angular/core';
|
||||
@ -73,8 +74,8 @@ export class EnterRecipeData implements OnInit {
|
||||
data: {
|
||||
title: title!,
|
||||
slug: slug!,
|
||||
rawText: text!
|
||||
}
|
||||
})
|
||||
rawText: text!,
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@ -3,21 +3,20 @@ import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { Review } from './review';
|
||||
|
||||
describe('Review', () => {
|
||||
let component: Review;
|
||||
let fixture: ComponentFixture<Review>;
|
||||
let component: Review;
|
||||
let fixture: ComponentFixture<Review>;
|
||||
|
||||
beforeEach(async () => {
|
||||
await TestBed.configureTestingModule({
|
||||
imports: [Review]
|
||||
})
|
||||
.compileComponents();
|
||||
beforeEach(async () => {
|
||||
await TestBed.configureTestingModule({
|
||||
imports: [Review],
|
||||
}).compileComponents();
|
||||
|
||||
fixture = TestBed.createComponent(Review);
|
||||
component = fixture.componentInstance;
|
||||
await fixture.whenStable();
|
||||
});
|
||||
fixture = TestBed.createComponent(Review);
|
||||
component = fixture.componentInstance;
|
||||
await fixture.whenStable();
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
||||
|
||||
@ -3,20 +3,16 @@ import { RecipeDraftViewModel } from '../../../../shared/models/RecipeDraftView.
|
||||
import { MatButton } from '@angular/material/button';
|
||||
|
||||
@Component({
|
||||
selector: 'app-review',
|
||||
imports: [
|
||||
MatButton
|
||||
],
|
||||
templateUrl: './review.html',
|
||||
styleUrl: './review.css',
|
||||
selector: 'app-review',
|
||||
imports: [MatButton],
|
||||
templateUrl: './review.html',
|
||||
styleUrl: './review.css',
|
||||
})
|
||||
export class Review {
|
||||
|
||||
public readonly draft = input.required<RecipeDraftViewModel>();
|
||||
public readonly publish = output<void>();
|
||||
|
||||
protected onPublish(): void {
|
||||
this.publish.emit();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -2,5 +2,5 @@ export enum RecipeUploadStep {
|
||||
START,
|
||||
INFER,
|
||||
ENTER_DATA,
|
||||
REVIEW
|
||||
REVIEW,
|
||||
}
|
||||
|
||||
@ -31,7 +31,7 @@ export class RecipeCard {
|
||||
const recipe = this.recipe();
|
||||
return {
|
||||
queryKey: ['recipe-main-images', recipe.owner.username, recipe.slug],
|
||||
queryFn: () => this.imageService.getImage(recipe.mainImage?.url)
|
||||
queryFn: () => this.imageService.getImage(recipe.mainImage?.url),
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
@ -72,32 +72,30 @@ export class RecipeDraftService {
|
||||
);
|
||||
}
|
||||
|
||||
public updateDraft(id: string, data: {
|
||||
title?: string | null;
|
||||
slug?: string | null;
|
||||
rawText?: string | null;
|
||||
}): Promise<RecipeUploadClientModel> {
|
||||
public updateDraft(
|
||||
id: string,
|
||||
data: {
|
||||
title?: string | null;
|
||||
slug?: string | null;
|
||||
rawText?: string | null;
|
||||
},
|
||||
): Promise<RecipeUploadClientModel> {
|
||||
return firstValueFrom(
|
||||
this.http.put<WithStringDates<RecipeDraftViewModel>>(
|
||||
this.endpointService.getUrl('recipeDrafts', [id]),
|
||||
data
|
||||
)
|
||||
this.http
|
||||
.put<WithStringDates<RecipeDraftViewModel>>(this.endpointService.getUrl('recipeDrafts', [id]), data)
|
||||
.pipe(
|
||||
map(rawView => this.hydrateView(rawView)),
|
||||
map(draft => ({
|
||||
map((rawView) => this.hydrateView(rawView)),
|
||||
map((draft) => ({
|
||||
draft,
|
||||
inProgressStep: RecipeUploadStep.ENTER_DATA,
|
||||
}))
|
||||
)
|
||||
})),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
public publish(id: string): Promise<Recipe> {
|
||||
return firstValueFrom(
|
||||
this.http.post<Recipe>(
|
||||
this.endpointService.getUrl('recipeDrafts', [id, 'publish']),
|
||||
null
|
||||
)
|
||||
this.http.post<Recipe>(this.endpointService.getUrl('recipeDrafts', [id, 'publish']), null),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user