Skip to content

Commit

Permalink
Fix change requests.
Browse files Browse the repository at this point in the history
  • Loading branch information
Maksym Pryhoda committed Aug 17, 2023
1 parent 5005a1a commit 89195fd
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/modules/offer/dto/editing/offer-id.input.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ import { Field, InputType } from '@nestjs/graphql';

@InputType()
export class OfferIdInput {
@Field()
@Field(() => String)
offerId: string;
}
2 changes: 1 addition & 1 deletion src/modules/offer/dto/editing/offer-request-id.input.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ import { Field, InputType } from '@nestjs/graphql';

@InputType()
export class OfferRequestIdInput {
@Field()
@Field(() => String)
offerRequestId: string;
}
3 changes: 2 additions & 1 deletion src/modules/offer/dto/offers/offers-subsribption.input.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { Field, InputType } from '@nestjs/graphql';

import { OfferRoleInput } from '../offer/offer-role.input';
import { MaybeType } from 'src/modules/common/common.types';

@InputType()
export class OfferSubscriptionInput extends OfferRoleInput {
@Field(() => [String], { nullable: true })
offerIds?: string[];
offerIds?: MaybeType<string[]>;
}
2 changes: 1 addition & 1 deletion src/modules/offer/dto/offers/offers.args.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@ export class OfferArgs extends IntersectionType(
filter?: MaybeType<OffersFilterInput>;

@Field(() => [OffersOrderInput], { nullable: true })
ordersBy?: OffersOrderInput[];
ordersBy?: MaybeType<OffersOrderInput[]>;
}
3 changes: 2 additions & 1 deletion src/modules/offer/services/buyer-offer.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { FirebaseService } from 'src/modules/firebase/firebase.service';

import { OfferService } from './offer.service';
import { OfferIdInput } from '../dto/editing/offer-id.input';
import { OfferStatus } from '../dto/offer/offer-status.enum';

@Injectable()
export class BuyerOfferService {
Expand Down Expand Up @@ -61,7 +62,7 @@ export class BuyerOfferService {

const offerRef = database.ref(FirebaseDatabasePath.OFFERS).child(offerId);

await offerRef.child('status').set('accepted');
await offerRef.child('status').set(OfferStatus.ACCEPTED);

return true;
}
Expand Down
5 changes: 4 additions & 1 deletion src/modules/offer/services/offer.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,10 @@ export class OfferService {

// * we don't need to filter by id, as we did it in forEach loop above
nodes = filterOffers({ offers: nodes, filter });
nodes = this.offerSorter.sort(nodes, ordersBy, null);

if (ordersBy) {
nodes = this.offerSorter.sort(nodes, ordersBy, null);
}

const total = nodes.length;
nodes = paginate({ nodes, limit, offset });
Expand Down
10 changes: 8 additions & 2 deletions src/modules/offer/services/seller-offer.service.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Injectable } from '@nestjs/common';
import omit from 'lodash/omit';

import { FirebaseDatabasePath } from 'src/modules/firebase/firebase.constants';
import { FirebaseService } from 'src/modules/firebase/firebase.service';
Expand All @@ -13,7 +14,7 @@ import { WorkTimeDto } from '../dto/offer/work-time.dto';
import { OfferService } from './offer.service';
import { OfferDto } from '../dto/offer/offer.dto';
import { OfferInput } from '../dto/creation/offer.input';
import { hydrateOffer } from '../offer.utils/prepopulate-offer.util';
import { hydrateOffer } from '../offer.utils/hydrate-offer.util';
import { AcceptanceGuardInput } from '../dto/creation/acceptance-guard.input';
import { getChangedQuestions } from '../offer.utils/get-changes.util';
import { unpauseJob } from '../offer.utils/unpause-job.uitl';
Expand Down Expand Up @@ -273,7 +274,12 @@ export class SellerOfferService {
id: createdOfferRef.key,
});

await createdOfferRef.set(OfferDto.adapter.toInternal(offerHydrated));
const offerWithoutId = omit(
OfferDto.adapter.toInternal(offerHydrated),
'id',
);

await createdOfferRef.set(offerWithoutId);

return offerHydrated;
}
Expand Down

0 comments on commit 89195fd

Please sign in to comment.