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
16 changes: 13 additions & 3 deletions backend/app/http/endpoints/api/panel/panelcreate.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,13 +124,13 @@ func CreatePanel(c *gin.Context) {
data.MessageId = 0

// Check panel quota
premiumTier, err := rpc.PremiumClient.GetTierByGuildId(c, guildId, false, botContext.Token, botContext.RateLimiter)
quotaTier, err := rpc.PremiumClient.GetTierByGuildId(c, guildId, false, botContext.Token, botContext.RateLimiter)
if err != nil {
_ = c.AbortWithError(http.StatusInternalServerError, app.NewError(err, "Failed to verify premium status"))
return
}

if premiumTier == premium.None {
if quotaTier == premium.None {
panels, err := dbclient.Client.Panel.GetByGuild(c, guildId)
if err != nil {
_ = c.AbortWithError(http.StatusInternalServerError, app.NewError(err, "Failed to fetch existing panels"))
Expand Down Expand Up @@ -165,11 +165,21 @@ func CreatePanel(c *gin.Context) {
data.OverflowCategoryId = nil
}

// Voting premium unlocks fields but not quota, so the tier is looked up twice.
featureTier := quotaTier
if featureTier == premium.None {
featureTier, err = rpc.PremiumClient.GetTierByGuildId(c, guildId, true, botContext.Token, botContext.RateLimiter)
if err != nil {
_ = c.AbortWithError(http.StatusInternalServerError, app.NewError(err, "Failed to verify premium status"))
return
}
}

// Do custom validation
validationContext := PanelValidationContext{
Data: data,
GuildId: guildId,
IsPremium: premiumTier > premium.None,
IsPremium: featureTier > premium.None,
BotContext: botContext,
Channels: channels,
Roles: roles,
Expand Down
51 changes: 29 additions & 22 deletions frontend/src/pages/manage/panels/create.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ const PanelsPage: FC = () => {
const queryClient = useQueryClient();
const { data: forms = [] } = useGuildForms(guildId);
const { data: premiumState = null } = useGuildPremium(guildId, false);
const { data: brandingPremium = null } = useGuildPremium(guildId, true);
const showBrandingFooter = !brandingPremium?.premium;
const { data: premiumWithVoting = null } = useGuildPremium(guildId, true);
const showBrandingFooter = !premiumWithVoting?.premium;
const { data: kbCategories = [] } = useKBCategories(guildId);
const { data: guildEmojis = [] } = useGuildEmojis(guildId, true);
const [isLoadingClone, setIsLoadingClone] = useState(!!clonePanelId);
Expand Down Expand Up @@ -464,26 +464,33 @@ const PanelsPage: FC = () => {
}
/>

<Select
label={
premiumState?.premium
? "Awaiting Response Category"
: "Awaiting Response Category (Premium)"
}
disabled={!premiumState?.premium}
options={
selectedGuild?.channels
?.filter((c) => c.type == 4)
.map((channel) => ({
label: channel.name,
key: channel.id,
})) || []
}
value={panel.pending_category || ""}
onChange={(e) =>
setPanel((prev) => (prev ? { ...prev, pending_category: e ?? undefined } : prev))
}
/>
<div>
<div className="flex items-center gap-1.5 mb-1">
<span className="text-sm text-white">Awaiting Response Category</span>
{!premiumWithVoting?.premium && (
<span title="Move tickets to a separate category while they await a user reply. Requires Premium.">
<FontAwesomeIcon icon={faCrown} className="text-amber-400 text-xs cursor-help" />
</span>
)}
</div>
<Select
label="Awaiting Response Category"
hideLabel
showNoneOption={true}
noneOptionLabel="No Awaiting Response Category"
options={
selectedGuild?.channels
?.filter((c) => c.type == 4)
.map((channel) => ({
label: channel.name,
key: channel.id,
disabled: !premiumWithVoting?.premium,
})) || []
}
value={panel.pending_category ?? null}
onChange={(e) => setPanel((prev) => (prev ? { ...prev, pending_category: e } : prev))}
/>
</div>
</div>
<div className="p-4 grid gap-4 grid-cols-1 sm:grid-cols-1 md:grid-cols-2 lg:grid-cols-3">
<Select
Expand Down
51 changes: 29 additions & 22 deletions frontend/src/pages/manage/panels/edit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ const EditPanelsPage: FC = () => {
const queryClient = useQueryClient();
const { data: forms = [] } = useGuildForms(guildId);
const { data: premiumState = null } = useGuildPremium(guildId, false);
const { data: brandingPremium = null } = useGuildPremium(guildId, true);
const showBrandingFooter = !brandingPremium?.premium;
const { data: premiumWithVoting = null } = useGuildPremium(guildId, true);
const showBrandingFooter = !premiumWithVoting?.premium;
const { data: kbCategories = [] } = useKBCategories(guildId);
const { data: guildEmojis = [] } = useGuildEmojis(guildId, true);
const { data: panelData, isLoading: isLoadingPanel } = useGuildPanel(guildId, panelId);
Expand Down Expand Up @@ -383,26 +383,33 @@ const EditPanelsPage: FC = () => {
}
/>

<Select
label={
premiumState?.premium
? "Awaiting Response Category"
: "Awaiting Response Category (Premium)"
}
disabled={!premiumState?.premium}
options={
selectedGuild?.channels
?.filter((c) => c.type == 4)
.map((channel) => ({
label: channel.name,
key: channel.id,
})) || []
}
value={panel.pending_category || ""}
onChange={(e) =>
setPanel((prev) => (prev ? { ...prev, pending_category: e ?? undefined } : prev))
}
/>
<div>
<div className="flex items-center gap-1.5 mb-1">
<span className="text-sm text-white">Awaiting Response Category</span>
{!premiumWithVoting?.premium && (
<span title="Move tickets to a separate category while they await a user reply. Requires Premium.">
<FontAwesomeIcon icon={faCrown} className="text-amber-400 text-xs cursor-help" />
</span>
)}
</div>
<Select
label="Awaiting Response Category"
hideLabel
showNoneOption={true}
noneOptionLabel="No Awaiting Response Category"
options={
selectedGuild?.channels
?.filter((c) => c.type == 4)
.map((channel) => ({
label: channel.name,
key: channel.id,
disabled: !premiumWithVoting?.premium,
})) || []
}
value={panel.pending_category ?? null}
onChange={(e) => setPanel((prev) => (prev ? { ...prev, pending_category: e } : prev))}
/>
</div>
</div>
<div className="p-4 grid gap-4 grid-cols-1 sm:grid-cols-1 md:grid-cols-2 lg:grid-cols-3">
<Select
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ export interface Panel {
has_support_hours?: boolean;
is_currently_active?: boolean;
exit_survey_form_id?: number | null;
pending_category?: string;
pending_category?: string | null;
mention_behaviour: string;
transcript_channel_id?: string;
use_threads: boolean;
Expand Down
Loading