Skip to content

Commit

Permalink
2062 converted objects to interpolated strings (#2138)
Browse files Browse the repository at this point in the history
Co-authored-by: Michael Collins <[email protected]>
Co-authored-by: Atmosfearful <[email protected]>
  • Loading branch information
3 people authored Feb 16, 2024
1 parent 49c7190 commit a43cf82
Show file tree
Hide file tree
Showing 19 changed files with 50 additions and 198 deletions.
19 changes: 5 additions & 14 deletions carbonmark/components/CreateListing/Form/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -82,17 +82,11 @@ export const CreateListingForm: FC<Props> = (props) => {
...register("amount", {
required: {
value: true,
message: t({
id: "user.listing.form.input.totalAmountToSell.required",
message: "Total Amount to Sell is required",
}),
message: t`Total Amount to Sell is required`,
},
min: {
value: 1,
message: t({
id: "user.listing.form.input.totalAmountToSell.minimum",
message: "The minimum amount to sell is 1 Tonne",
}),
message: t`The minimum amount to sell is 1 Tonne`,
},
max: {
value: Number(selectedAsset.amount),
Expand Down Expand Up @@ -127,12 +121,9 @@ export const CreateListingForm: FC<Props> = (props) => {
},
min: {
value: 0.1,
message: t({
id: "user.listing.form.input.singleUnitPrice.minimum",
message: `The minimum price per tonne is ${MINIMUM_TONNE_PRICE.toLocaleString(
locale
)}`,
}),
message: t`The minimum price per tonne is ${MINIMUM_TONNE_PRICE.toLocaleString(
locale
)}`,
},
}),
}}
Expand Down
20 changes: 4 additions & 16 deletions carbonmark/components/Layout/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,24 +48,12 @@ export const Layout: FC<Props> = (props: Props) => {
{renderModal &&
renderModal({
errors: getConnectErrorStrings(),
torusText: t({
message: "social or email",
id: "connectModal.torus",
}),
walletText: t({
message: "connect a wallet",
id: "connectModal.wallet",
}),
torusText: t`social or email`,
walletText: t`connect a wallet`,
titles: {
connect: t`Login`,
loading: t({
id: "connect_modal.connecting",
message: "Connecting...",
}),
error: t({
id: "connect_modal.error_title",
message: "Connection Error",
}),
loading: t`Connecting...`,
error: t`Connection Error`,
},
})}
</>
Expand Down
24 changes: 5 additions & 19 deletions carbonmark/components/pages/Portfolio/Retire/RetireForm/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -275,10 +275,7 @@ export const RetireForm = (props: RetireFormProps) => {
max: retirement.maxQuantity.toString(),
onChange: (event) =>
handleRetirementChange("quantity", event),
placeholder: t({
id: "offset.offset_quantity",
message: "Enter quantity to offset",
}),
placeholder: t`Enter quantity to offset`,
value: retirement.quantity,
}}
label={"quantity"}
Expand Down Expand Up @@ -306,10 +303,7 @@ export const RetireForm = (props: RetireFormProps) => {
type: "text",
onChange: (event) =>
handleRetirementChange("beneficiaryName", event),
placeholder: t({
id: "offset.retirement_beneficiary_name",
message: "Beneficiary Name",
}),
placeholder: t`Beneficiary Name`,
value: retirement.beneficiaryName,
}}
label={"beneficiaryName"}
Expand All @@ -323,9 +317,7 @@ export const RetireForm = (props: RetireFormProps) => {
type: "text",
onChange: (event) =>
handleRetirementChange("beneficiaryAddress", event),
placeholder: t({
message: "Beneficiary wallet address (optional)",
}),
placeholder: t`Beneficiary wallet address (optional)`,
value: retirement.beneficiaryAddress,
}}
label={"beneficiaryAddress"}
Expand Down Expand Up @@ -363,10 +355,7 @@ export const RetireForm = (props: RetireFormProps) => {
rows: 6,
onChange: (event) =>
handleRetirementChange("retirementMessage", event),
placeholder: t({
id: "offset.retirement_retirement_message",
message: "Retirement Message",
}),
placeholder: t`Retirement Message`,
value: retirement.retirementMessage,
}}
label={""}
Expand Down Expand Up @@ -396,10 +385,7 @@ export const RetireForm = (props: RetireFormProps) => {
<div className={styles.buttonRow}>
<div className={styles.buttonContainer}>
<CarbonmarkButton
label={t({
id: "retire.submit_button",
message: "Retire Carbon",
})}
label={t`Retire Carbon`}
onClick={() => setRetireModalOpen(true)}
className={styles.submitButton}
disabled={!readyForRetireModal}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,12 +102,7 @@ export const PurchaseForm: FC<Props> = (props) => {
setInputValues(values);
} catch (e) {
console.error(e);
setErrorMessage(
t({
id: "purchase.loading.allowance.error",
message: "something went wrong loading the allowance",
})
);
setErrorMessage(t`something went wrong loading the allowance`);
} finally {
setIsLoadingAllowance(false);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,28 +59,19 @@ export const PurchaseInputs: FC<Props> = (props) => {
<InputField
id="amount"
inputProps={{
placeholder: t({
id: "purchase.input.amount.placeholder",
message: "Tonnes",
}),
placeholder: t`Tonnes`,
type: "number",
min: 1,
max: Number(props.listing.leftToSell),
...register("amount", {
onChange: () => clearErrors("price"),
required: {
value: true,
message: t({
id: "purchase.input.amount.required",
message: "Amount is required",
}),
message: t`Amount is required`,
},
min: {
value: 1,
message: t({
id: "purchase.input.amount.minimum",
message: "The minimum amount to buy is 1 Tonne",
}),
message: t`The minimum amount to buy is 1 Tonne`,
},
max: {
value: Number(props.listing.leftToSell),
Expand Down Expand Up @@ -166,17 +157,11 @@ export const PurchaseInputs: FC<Props> = (props) => {
...register("price", {
required: {
value: true,
message: t({
id: "purchase.input.price.required",
message: "Price is required",
}),
message: t`Price is required`,
},
max: {
value: Number(props.balance || "0"),
message: t({
id: "purchase.input.price.maxAmount",
message: "You exceeded your available amount of tokens",
}),
message: t`You exceeded your available amount of tokens`,
},
}),
}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,17 +80,7 @@ export const PurchaseModal: FC<Props> = (props) => {
const { networkLabel } = useWeb3();
return (
<Modal
title={
!props.isProcessing
? t({
id: "purchase.transaction.modal.title.confirm",
message: "Confirm Purchase",
})
: t({
id: "purchase.transaction.modal.title.processing",
message: "Processing Purchase",
})
}
title={!props.isProcessing ? t`Confirm Purchase` : t`Processing Purchase`}
showModal={props.showModal}
onToggleModal={props.onModalClose}
>
Expand Down
20 changes: 4 additions & 16 deletions carbonmark/components/pages/Resources/ResourcesList/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -159,19 +159,13 @@ export const ResourcesList: FC<Props> = (props) => {
<InputField
id="search"
inputProps={{
placeholder: t({
id: "resources.form.input.search.placeholder",
message: "Search...",
}),
placeholder: t`Search...`,
type: "search",
autoComplete: "off",
className: styles.searchInput,
...register("search"),
}}
label={t({
id: "resources.form.input.search.label",
message: "Search",
})}
label={t`Search`}
hideLabel
/>
<ButtonPrimary
Expand All @@ -197,10 +191,7 @@ export const ResourcesList: FC<Props> = (props) => {
...register("sortedBy"),
}}
hideLabel
label={t({
id: "resources.form.input.sort_by.label",
message: "Sort by",
})}
label={t`Sort by`}
/>
<Text t="body1">
<Trans id="shared.resources.sort_by.header">Sort by:</Trans>
Expand Down Expand Up @@ -271,10 +262,7 @@ export const ResourcesList: FC<Props> = (props) => {
</div>

<Modal
title={t({
id: "resources.mobile_modal.title",
message: "Sort By",
})}
title={t`Sort By`}
showModal={showMobileModal}
onToggleModal={() => setShowMobileModal((prev) => !prev)}
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ interface Props {

const getSelectedSortyByLabel = (sortBy: string) =>
(!!sortBy && getSortedByQueries().find((q) => q.value === sortBy)?.label) ||
t({ id: "resources.form.input.sort_by.select", message: "Select" });
t`Select`;

export const SortyByDropDown: FC<Props> = (props) => {
const sortedBy = useWatch({ name: "sortedBy", control: props.control });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,7 @@ export const BeneficiaryDetails: FC<Props> = (props) => {
<Text t="h4" className={styles.beneficiaryAddress}>
{carbonmarkUser?.handle ||
props.beneficiary ||
t({
id: "retirement.single.beneficiary.placeholder",
message: "No beneficiary name provided",
})}
t`No beneficiary name provided`}
</Text>
<A
className={styles.profileLink}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,10 +132,7 @@ export const ProjectDetails: FC<Props> = (props) => {
target="_blank"
variant="transparent"
rel="noopener noreferrer"
label={t({
id: "retirement.single.view_on_polygon_scan",
message: "View on Polygonscan",
})}
label={t`View on Polygonscan`}
href={`https://polygonscan.com/tx/${props.retirement?.retire.hash}`}
/>
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,7 @@ export const TransactionDetails: FC<Props> = (props) => (
</Text>
<Text>
{props.retirement.retire.beneficiaryAddress.id ||
t({
id: "retirement.single.beneficiary.address.placeholder",
message: "No beneficiary address available",
})}
t`No beneficiary address available`}
</Text>
</div>
<div className={styles.textGroup}>
Expand All @@ -50,11 +47,7 @@ export const TransactionDetails: FC<Props> = (props) => (
</Trans>
</Text>
<Text className={styles.transactionId}>
{props.retirement.retire?.hash ||
t({
id: "retirement.single.transaction_id.placeholder",
message: "No transaction id available",
})}
{props.retirement.retire?.hash || t`No transaction id available`}
</Text>
</div>
<div className={styles.gridLayout}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,10 +125,7 @@ export const SingleRetirementPage: NextPage<SingleRetirementPageProps> = ({
id: "retirement.head.metaTitle",
message: `${retiree} retired ${formattedAmount} Tonnes of carbon`,
})}
metaDescription={t({
id: "retirement.head.metaDescription",
message: "Transparent, on-chain offsets powered by Carbonmark.",
})}
metaDescription={t`Transparent, on-chain offsets powered by Carbonmark.`}
canonicalUrl={props.canonicalUrl}
/>
<Navigation activePage="Home" />
Expand Down
6 changes: 1 addition & 5 deletions carbonmark/components/pages/Retirements/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,7 @@ export const RetirementPage: NextPage<Props> = (props) => {
nameserviceDomain || concattedAddress
}`,
})}
metaDescription={t({
id: "shared.head.description",
message:
"Drive climate action and earn rewards with a carbon-backed digital currency.",
})}
metaDescription={t`Drive climate action and earn rewards with a carbon-backed digital currency.`}
canonicalUrl={props.canonicalUrl || undefined}
/>
<Navigation activePage="Home" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,17 +105,11 @@ export const EditListing: FC<Props> = (props) => {
...register("newQuantity", {
required: {
value: true,
message: t({
id: "user.listing.edit.input.quantity.required",
message: "Quantity is required",
}),
message: t`Quantity is required`,
},
min: {
value: 1,
message: t({
id: "user.listing.edit.input.quantity.minimum",
message: "The minimum quantity to sell is 1 tonne",
}),
message: t`The minimum quantity to sell is 1 tonne`,
},
max: {
value: Number(totalAvailableQuantity),
Expand All @@ -139,27 +133,18 @@ export const EditListing: FC<Props> = (props) => {
id="price"
label={t`New Unit Price (USDC)`}
inputProps={{
placeholder: t({
id: "user.edit.form.edit.price.placeholder",
message: "USDC per ton",
}),
placeholder: t`USDC per ton`,
type: "number",
...register("newSingleUnitPrice", {
required: {
value: true,
message: t({
id: "user.listing.form.input.singleUnitPrice.required",
message: "Single Price is required",
}),
message: t`Single Price is required`,
},
min: {
value: MINIMUM_TONNE_PRICE,
message: t({
id: "user.listing.form.input.singleUnitPrice.minimum",
message: `The minimum price per tonne is ${MINIMUM_TONNE_PRICE.toLocaleString(
locale
)}`,
}),
message: t`The minimum price per tonne is ${MINIMUM_TONNE_PRICE.toLocaleString(
locale
)}`,
},
pattern: {
value: /^\d+(\.\d{1,6})?$/,
Expand Down
Loading

0 comments on commit a43cf82

Please sign in to comment.