-
Notifications
You must be signed in to change notification settings - Fork 89
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: submit review * fix: remove comment * fix: recommended settings
- Loading branch information
Showing
4 changed files
with
69 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { AppContext } from "../mod.ts"; | ||
import { ResponseWriteReview, WriteReview } from "../utils/types.ts"; | ||
import { logger } from "@deco/deco/o11y"; | ||
|
||
export interface Props { | ||
/** | ||
* @title Product SKU | ||
*/ | ||
sku: string; | ||
review: WriteReview; | ||
} | ||
|
||
export default async function action(props: Props, _req: Request, ctx: AppContext): Promise<ResponseWriteReview | null> { | ||
|
||
const { customer, api } = ctx | ||
const { review, sku } = props | ||
|
||
try { | ||
const response = await api[`POST /:customer/:sku/review`]({ | ||
sku: sku, | ||
customer, | ||
}, { | ||
body: { | ||
...review, | ||
}, | ||
}).then((r) => r.json()) | ||
return await response | ||
} catch (error) { | ||
const errorObj = error as { name: string; message: string }; | ||
logger.error(`{ errorName: ${errorObj.name}, | ||
errorMessage: ${errorObj.message} }`); | ||
return null | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters