Merge pull request 'deploy to production' (#74) from staging into production
Reviewed-on: #74
This commit is contained in:
		
						commit
						e3bf777622
					
				| 
						 | 
					@ -102,7 +102,14 @@ export default function BidModal({
 | 
				
			||||||
      const { url, max_price, plus_price } = values;
 | 
					      const { url, max_price, plus_price } = values;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      setLoading(true);
 | 
					      setLoading(true);
 | 
				
			||||||
      const result = await createBid({ url, max_price, plus_price } as IBid);
 | 
					
 | 
				
			||||||
 | 
					      const metadata = valuesToMetadata(values as IBid & Record<string, any>);
 | 
				
			||||||
 | 
					      const result = await createBid({
 | 
				
			||||||
 | 
					        url,
 | 
				
			||||||
 | 
					        max_price,
 | 
				
			||||||
 | 
					        plus_price,
 | 
				
			||||||
 | 
					        metadata,
 | 
				
			||||||
 | 
					      } as IBid);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      setLoading(false);
 | 
					      setLoading(false);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -166,6 +173,27 @@ export default function BidModal({
 | 
				
			||||||
      "early_tracking_seconds_sandbox",
 | 
					      "early_tracking_seconds_sandbox",
 | 
				
			||||||
    ];
 | 
					    ];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    if (!values?.metadata) {
 | 
				
			||||||
 | 
					      const mode_key = values.mode_key;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      if (!mode_key) return [];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      const newValues = Object.entries(values)
 | 
				
			||||||
 | 
					        .map(([key, value]) => {
 | 
				
			||||||
 | 
					          if (keys.includes(key)) {
 | 
				
			||||||
 | 
					            return {
 | 
				
			||||||
 | 
					              key_name: key,
 | 
				
			||||||
 | 
					              value,
 | 
				
			||||||
 | 
					            } as IMetadata;
 | 
				
			||||||
 | 
					          }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					          return null;
 | 
				
			||||||
 | 
					        })
 | 
				
			||||||
 | 
					        .filter((i) => i !== null);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      return newValues;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (values.metadata.length <= 0) {
 | 
					    if (values.metadata.length <= 0) {
 | 
				
			||||||
      return keys.map((item) => {
 | 
					      return keys.map((item) => {
 | 
				
			||||||
        return {
 | 
					        return {
 | 
				
			||||||
| 
						 | 
					@ -203,8 +231,12 @@ export default function BidModal({
 | 
				
			||||||
  }, [props.opened]);
 | 
					  }, [props.opened]);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  useEffect(() => {
 | 
					  useEffect(() => {
 | 
				
			||||||
 | 
					    if (!data && !form.values.mode_key) {
 | 
				
			||||||
 | 
					      form.setValues({ mode_key: "live" });
 | 
				
			||||||
 | 
					    } else {
 | 
				
			||||||
      const values = mappingValues(["mode_key"]);
 | 
					      const values = mappingValues(["mode_key"]);
 | 
				
			||||||
      form.setValues(values);
 | 
					      form.setValues(values);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    prevData.current = data;
 | 
					    prevData.current = data;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -226,7 +258,6 @@ export default function BidModal({
 | 
				
			||||||
        onSubmit={form.onSubmit(handleSubmit)}
 | 
					        onSubmit={form.onSubmit(handleSubmit)}
 | 
				
			||||||
        className="grid grid-cols-2 gap-2.5"
 | 
					        className="grid grid-cols-2 gap-2.5"
 | 
				
			||||||
      >
 | 
					      >
 | 
				
			||||||
        {!!data && (
 | 
					 | 
				
			||||||
        <Select
 | 
					        <Select
 | 
				
			||||||
          className="col-span-2"
 | 
					          className="col-span-2"
 | 
				
			||||||
          label="Mode"
 | 
					          label="Mode"
 | 
				
			||||||
| 
						 | 
					@ -239,7 +270,6 @@ export default function BidModal({
 | 
				
			||||||
          allowDeselect={false}
 | 
					          allowDeselect={false}
 | 
				
			||||||
          {...form.getInputProps("mode_key")}
 | 
					          {...form.getInputProps("mode_key")}
 | 
				
			||||||
        />
 | 
					        />
 | 
				
			||||||
        )}
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
        {data && data.name && (
 | 
					        {data && data.name && (
 | 
				
			||||||
          <TextInput
 | 
					          <TextInput
 | 
				
			||||||
| 
						 | 
					@ -274,7 +304,6 @@ export default function BidModal({
 | 
				
			||||||
          {...form.getInputProps("quantity")}
 | 
					          {...form.getInputProps("quantity")}
 | 
				
			||||||
        />
 | 
					        />
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        {!!data && (
 | 
					 | 
				
			||||||
        <NumberInput
 | 
					        <NumberInput
 | 
				
			||||||
          description="Note: that only integer minutes are accepted."
 | 
					          description="Note: that only integer minutes are accepted."
 | 
				
			||||||
          className="col-span-1"
 | 
					          className="col-span-1"
 | 
				
			||||||
| 
						 | 
					@ -289,9 +318,7 @@ export default function BidModal({
 | 
				
			||||||
            `arrival_offset_seconds_${form.getValues()["mode_key"]}`
 | 
					            `arrival_offset_seconds_${form.getValues()["mode_key"]}`
 | 
				
			||||||
          )}
 | 
					          )}
 | 
				
			||||||
        />
 | 
					        />
 | 
				
			||||||
        )}
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
        {!!data && (
 | 
					 | 
				
			||||||
        <NumberInput
 | 
					        <NumberInput
 | 
				
			||||||
          description="Note: that only integer minutes are accepted."
 | 
					          description="Note: that only integer minutes are accepted."
 | 
				
			||||||
          className="col-span-1"
 | 
					          className="col-span-1"
 | 
				
			||||||
| 
						 | 
					@ -306,7 +333,6 @@ export default function BidModal({
 | 
				
			||||||
            `early_tracking_seconds_${form.getValues()["mode_key"]}`
 | 
					            `early_tracking_seconds_${form.getValues()["mode_key"]}`
 | 
				
			||||||
          )}
 | 
					          )}
 | 
				
			||||||
        />
 | 
					        />
 | 
				
			||||||
        )}
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
        <Button
 | 
					        <Button
 | 
				
			||||||
          //   disabled={_.isEqual(form.values, prevData.current)}
 | 
					          //   disabled={_.isEqual(form.values, prevData.current)}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -95,10 +95,6 @@ export default function ResponseDemoModal({
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
  };
 | 
					  };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  useEffect(() => {
 | 
					 | 
				
			||||||
    console.log({ responseDemo });
 | 
					 | 
				
			||||||
  }, [responseDemo]);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  return (
 | 
					  return (
 | 
				
			||||||
    <Modal
 | 
					    <Modal
 | 
				
			||||||
      classNames={{
 | 
					      classNames={{
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,5 +1,6 @@
 | 
				
			||||||
import { Optional } from '@nestjs/common';
 | 
					import { Optional } from '@nestjs/common';
 | 
				
			||||||
import {
 | 
					import {
 | 
				
			||||||
 | 
					  IsArray,
 | 
				
			||||||
  IsBoolean,
 | 
					  IsBoolean,
 | 
				
			||||||
  IsNumber,
 | 
					  IsNumber,
 | 
				
			||||||
  IsOptional,
 | 
					  IsOptional,
 | 
				
			||||||
| 
						 | 
					@ -21,4 +22,8 @@ export class CreateBidDto {
 | 
				
			||||||
  @IsNumber()
 | 
					  @IsNumber()
 | 
				
			||||||
  @IsOptional()
 | 
					  @IsOptional()
 | 
				
			||||||
  plus_price: number;
 | 
					  plus_price: number;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  @IsArray()
 | 
				
			||||||
 | 
					  @IsOptional()
 | 
				
			||||||
 | 
					  metadata: Record<string, any>[];
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -125,7 +125,27 @@ export class BidsService {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    const webBid = await this.webBidsService.createByUrl(data.url);
 | 
					    const webBid = await this.webBidsService.createByUrl(data.url);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    const metadata = BidMetadata.DEFAULT_META_DATA(webBid);
 | 
					    let metadata = BidMetadata.DEFAULT_META_DATA(webBid);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    if (data.metadata) {
 | 
				
			||||||
 | 
					      metadata = metadata.map((item) => {
 | 
				
			||||||
 | 
					        const reqData = data.metadata.find(
 | 
				
			||||||
 | 
					          (i) => i?.key_name === item.key_name,
 | 
				
			||||||
 | 
					        );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if (!reqData) return { ...item };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        return {
 | 
				
			||||||
 | 
					          ...item,
 | 
				
			||||||
 | 
					          value:
 | 
				
			||||||
 | 
					            item.key_name === BidMetadata.MODE_KEY
 | 
				
			||||||
 | 
					              ? JSON.stringify(reqData.value)
 | 
				
			||||||
 | 
					              : reqData.value <= 0
 | 
				
			||||||
 | 
					                ? item.value
 | 
				
			||||||
 | 
					                : String(reqData.value),
 | 
				
			||||||
 | 
					        };
 | 
				
			||||||
 | 
					      });
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    const result = await this.bidsRepo.save({
 | 
					    const result = await this.bidsRepo.save({
 | 
				
			||||||
      ...data,
 | 
					      ...data,
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue