, priceString].join('');\n case Currency.VND:\n return [priceString, 'VND'].join(' ');\n case Currency.YEN:\n return ['¥', priceString].join('');\n case Currency.SUSD:\n return ['S
, priceString].join('');\n }\n};\n\nexport const getDiscountMessage = (\n country: Country,\n currency: Currency,\n discountedPrice: number\n) =\u003E {\n const formattedPrice = formatPriceByCurrency(discountedPrice, currency);\n\n switch (country) {\n case Country.VIETNAM:\n return `The price has been discounted by ${formattedPrice} because you come from Vietnam.`;\n case Country.JAPAN:\n return `We have discounted the price by ${formattedPrice} thanks to the support from Japan's government.`;\n default:\n return `It's lucky that you come from ${country}, because we're running a program that discounts the price by ${discountedPrice}.`;\n }\n};\n","id":"4a18c795-6be1-42f5-8216-c7c6cdce4865","is_binary":false,"title":"price.ts","sha":null,"inserted_at":"2022-11-17T07:21:15","updated_at":"2024-06-01T01:19:29","upload_id":null,"shortid":"q6Om3","source_id":"4af8f1b4-4611-46ff-9d67-6fce2b9a86ab","directory_shortid":"gL4P9"},{"code":"import React from 'react';\r\n\r\nimport { getDiscountMessage, formatPriceByCurrency } from '..\u002Fservices\u002Fprice';\r\nimport { Country, Currency } from '..\u002Ftypes';\r\n\r\nimport styles from '.\u002FPricingCardBody.module.css';\r\n\r\ninterface PricingCardBodyProps {\r\n price: number;\r\n currency: Currency;\r\n country?: Country;\r\n}\r\n\r\nconst PricingCardBody: React.FC\u003CPricingCardBodyProps\u003E = ({\r\n price,\r\n currency,\r\n country\r\n}) =\u003E {\r\n const discountedRatio =\r\n country === Country.VIETNAM ? 0.4 : country === Country.JAPAN ? 0.2 : 0;\r\n const isDiscounted = discountedRatio \u003E 0;\r\n const finalPrice = price * (1 - discountedRatio);\r\n const discountedPrice = price - finalPrice;\r\n\r\n return (\r\n \u003Cdiv className={styles.body}\u003E\r\n \u003Ch1\u003E{formatPriceByCurrency(finalPrice, currency)}\u003C\u002Fh1\u003E\r\n {isDiscounted && country && (\r\n \u003Cdiv className={styles.discount}\u003E\r\n {getDiscountMessage(country, currency, discountedPrice)}\r\n \u003C\u002Fdiv\u003E\r\n )}\r\n \u003Cp\u003ELearn the essential skills for modern fullstack app development.\u003C\u002Fp\u003E\r\n \u003Cbutton className={styles.buyButton}\u003EGet started\u003C\u002Fbutton\u003E\r\n \u003C\u002Fdiv\u003E\r\n );\r\n};\r\n\r\nexport default PricingCardBody;\r\n","id":"87bb6145-ba42-44e7-83af-87eec0dff6d6","is_binary":false,"title":"PricingCardBody.tsx","sha":null,"inserted_at":"2022-11-10T14:29:00","updated_at":"2024-06-01T01:20:09","upload_id":null,"shortid":"71EAr","source_id":"4af8f1b4-4611-46ff-9d67-6fce2b9a86ab","directory_shortid":"lVp41"}],"preview_secret":null,"screenshot_url":"https:\u002F\u002Fscreenshots.codesandbox.io\u002Fh59r02\u002F174.png","draft":false,"team":{"id":"81111bd7-0891-4c3b-82b3-deff3f8cf523","name":"huy-ta","settings":{"ai_consent":{"public_sandboxes":false,"private_sandboxes":false}},"subscription_type":null,"avatar_url":"https:\u002F\u002Favatars1.githubusercontent.com\u002Fu\u002F24670327?v=4"},"settings":{"ai_consent":null},"permissions":{"prevent_sandbox_export":false,"prevent_sandbox_leaving":false},"ai_consent":false,"original_git":null,"tags":[],"alias":"react-strategy-pattern-problem-h59r02","pr_number":null,"view_count":299219,"inserted_at":"2022-11-10T14:19:25","original_git_commit_sha":null,"updated_at":"2024-06-01T01:22:29","title":"React Strategy Pattern (Problem)","restrictions":{"free_plan_editing_restricted":false,"live_sessions_restricted":true},"external_resources":[],"entry":"src\u002Findex.js","source_id":"4af8f1b4-4611-46ff-9d67-6fce2b9a86ab","author":{"id":"89be0091-3b9b-4657-aaa5-873c1687cdc0","name":"Will T.","username":"will-t","avatar_url":"https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F24670327?v=4","personal_workspace_id":"81111bd7-0891-4c3b-82b3-deff3f8cf523","subscription_plan":null,"subscription_since":null},"forked_template":{"id":"a49eb2ed-5233-4480-a2ca-794626c4e1e3","title":"React (TS)","color":"#61DAFB","v2":false,"url":null,"published":false,"icon_url":null,"official":false},"id":"h59r02","v2":false,"always_on":false,"like_count":0,"is_frozen":false,"restricted":false,"directories":[{"id":"15085fdf-ae77-45c1-a015-ca8b36328d9f","title":"public","inserted_at":"2022-11-10T14:19:25","updated_at":"2018-12-18T10:31:20","shortid":"rgkK4","source_id":"4af8f1b4-4611-46ff-9d67-6fce2b9a86ab","directory_shortid":null},{"id":"0840a270-d681-4a5a-a9a2-750745139c94","title":"src","inserted_at":"2022-11-10T14:19:25","updated_at":"2018-12-18T10:31:20","shortid":"GXOoy","source_id":"4af8f1b4-4611-46ff-9d67-6fce2b9a86ab","directory_shortid":null},{"id":"58380d15-749a-4375-b012-fbc16976b6a1","title":".codesandbox","inserted_at":"2022-11-10T14:19:25","updated_at":"2020-11-11T14:56:45","shortid":"HyBho_YKP","source_id":"4af8f1b4-4611-46ff-9d67-6fce2b9a86ab","directory_shortid":null},{"id":"cf392ce6-d521-4860-9715-b204c6a1296d","title":"components","inserted_at":"2022-11-10T14:19:41","updated_at":"2022-11-10T14:19:41","shortid":"lVp41","source_id":"4af8f1b4-4611-46ff-9d67-6fce2b9a86ab","directory_shortid":"GXOoy"},{"id":"21d1fe0b-95ea-4cf3-8330-cd3e98126545","title":"types","inserted_at":"2022-11-10T14:50:01","updated_at":"2022-11-10T14:50:01","shortid":"rvKvp","source_id":"4af8f1b4-4611-46ff-9d67-6fce2b9a86ab","directory_shortid":"GXOoy"},{"id":"ea0f2fa0-13e8-4864-86bf-702fe4cb408b","title":"services","inserted_at":"2022-11-17T07:21:10","updated_at":"2024-06-01T01:18:54","shortid":"gL4P9","source_id":"4af8f1b4-4611-46ff-9d67-6fce2b9a86ab","directory_shortid":"GXOoy"}],"user_liked":false,"npm_dependencies":{"react":"16.0.0","react-dom":"16.0.0"},"owned":false,"git":null};