Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions apps/bot/src/features/core/utils.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export const capitalizeFirstLetter = (val: string) => {
return String(val).charAt(0).toUpperCase() + String(val).slice(1);
};
74 changes: 26 additions & 48 deletions apps/bot/src/features/workout/workout.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,19 @@ import { HevyWorkout } from "@/features/hevy/hevy.types";
import { sendActivity } from "../liveActivity/liveActivity.service";
import { handleDiscordAPIError } from "../discord/error.service";
import { prisma, ShareReason, WorkoutFormat } from "@repo/db";
import { capitalizeFirstLetter } from "../core/utils";

export const AVAILABLE_AUTO_SHARE_FORMATS: WorkoutFormat[] = [
WorkoutFormat.line,
WorkoutFormat.compact,
WorkoutFormat.standard,
];

export const AVAILABLE_USER_SHARABLE_FORMATS: WorkoutFormat[] = [
WorkoutFormat.compact,
WorkoutFormat.standard,
];

const generateButtonCustomIdSuffix = (workout: HevyWorkout, extra: string) =>
`${workout.short_id}-${new Date().toISOString()}-${extra}`;

Expand All @@ -45,53 +51,25 @@ const sharableWorkoutEphemeralOptions = async (
components: [
workoutComponent,
new ContainerBuilder().addActionRowComponents(
new ActionRowBuilder<ButtonBuilder>().setComponents([
new ButtonKit()
.setLabel("Compact")
.setDisabled(format == "compact")
.setStyle(ButtonStyle.Secondary)
.setCustomId(`changeWorkoutFormat--compact--${customIdSuffix}`)
.onClick(
(i, c) =>
handleMessageClick(
i as unknown as ButtonInteraction,
c,
workout,
originalInteraction,
),
{ once: true, time: 60_000 },
),
new ButtonKit()
.setLabel(`Standard`)
.setCustomId(`changeWorkoutFormat--standard--${customIdSuffix}`)
.setDisabled(format == "standard")
.setStyle(ButtonStyle.Secondary)
.onClick(
(i, c) =>
handleMessageClick(
i as unknown as ButtonInteraction,
c,
workout,
originalInteraction,
),
{ once: true, time: 60_000 },
),
// new ButtonKit()
// .setLabel("Detailed")
// .setDisabled(format == "detailed")
// .setStyle(ButtonStyle.Secondary)
// .setCustomId(`changeWorkoutFormat--detailed--${customIdSuffix}`)
// .onClick(
// (i, c) =>
// handleMessageClick(
// i as unknown as ButtonInteraction,
// c,
// workout,
// originalInteraction,
// ),
// { once: true, time: 60_000 },
// ),
]),
new ActionRowBuilder<ButtonBuilder>().setComponents(
AVAILABLE_USER_SHARABLE_FORMATS.map((f) =>
new ButtonKit()
.setLabel(capitalizeFirstLetter(f))
.setDisabled(format == f)
.setStyle(ButtonStyle.Secondary)
.setCustomId(`changeWorkoutFormat--${f}--${customIdSuffix}`)
.onClick(
(i, c) =>
handleMessageClick(
i as unknown as ButtonInteraction,
c,
workout,
originalInteraction,
),
{ once: true, time: 60_000 },
),
),
),
),
new ActionRowBuilder<ButtonBuilder>().setComponents([
new ButtonKit()
Expand Down Expand Up @@ -249,7 +227,7 @@ const handleMessageClick = async (
}
}
} else if (interaction.customId.startsWith("changeWorkoutFormat")) {
if (["simple", "standard", "detailed"].includes(desiredFormat)) {
if (AVAILABLE_USER_SHARABLE_FORMATS.includes(desiredFormat)) {
await changeWorkoutFormat(
interaction as unknown as ButtonInteraction,
workout,
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
},
"packageManager": "npm@8.5.0",
"scripts": {
"bot:start": "turbo start --filter=bot --env-mode=loose",
"bot:dev": "turbo dev --filter=bot --env-mode=loose",
"bot:start": "dotenv-run -r ./.env turbo start --filter=bot --env-mode=loose",
"bot:dev": "dotenv-run -r ./.env turbo dev --filter=bot --env-mode=loose",
"build": "turbo run build --env-mode=loose --summarize",
"db:migrate:deploy": "turbo run db:migrate:deploy --env-mode=loose",
"db:migrate:dev": "turbo run db:migrate:dev --env-mode=loose",
Expand Down
4 changes: 3 additions & 1 deletion turbo.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@
"$schema": "https://turborepo.com/schema.json",
"ui": "tui",
"globalDependencies": [".env"],
"envMode": "loose",
"tasks": {
"build": {
"dependsOn": ["^build"],
"inputs": ["$TURBO_DEFAULT$", ".env*"],
"inputs": ["$TURBO_DEFAULT$", ".env"],
"outputs": ["dist/**", ".next/**", "!.next/cache/**"]
},
"check-types": {
Expand All @@ -28,6 +29,7 @@
},
"dev": {
"cache": false,
"inputs": ["$TURBO_DEFAULT$", ".env"],
"persistent": true
},
"start": {
Expand Down