-
Notifications
You must be signed in to change notification settings - Fork 168
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix: New banner step when editing a quest #1060
Changes from 1 commit
2bf5111
0a0ffb8
2121b86
4368dab
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,67 @@ | ||||||||||||||||||||||||||||||||
import React, { FunctionComponent } from "react"; | ||||||||||||||||||||||||||||||||
import TextInput from "../textInput"; | ||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||
type BannerStepProps = { | ||||||||||||||||||||||||||||||||
handleTasksInputChange: ( | ||||||||||||||||||||||||||||||||
e: React.ChangeEvent<HTMLInputElement>, | ||||||||||||||||||||||||||||||||
index: number | ||||||||||||||||||||||||||||||||
) => void; | ||||||||||||||||||||||||||||||||
step: StepMap; | ||||||||||||||||||||||||||||||||
index: number; | ||||||||||||||||||||||||||||||||
}; | ||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||
const BannerStep: FunctionComponent<BannerStepProps> = ({ | ||||||||||||||||||||||||||||||||
handleTasksInputChange, | ||||||||||||||||||||||||||||||||
step, | ||||||||||||||||||||||||||||||||
index, | ||||||||||||||||||||||||||||||||
}) => { | ||||||||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Consider defaulting to a fallback when If -const BannerStep: FunctionComponent<BannerStepProps> = ({
- handleTasksInputChange,
- step,
- index,
-}) => {
+const BannerStep: FunctionComponent<BannerStepProps> = (props) => {
+ const { handleTasksInputChange, step, index } = props;
+ const banner = step?.data?.banner || {
+ tag: "",
+ title: "",
+ description: "",
+ cta: "",
+ href: "",
+ image: ""
+ };
return (
<div className="flex flex-col gap-4 pt-2"> 📝 Committable suggestion
Suggested change
|
||||||||||||||||||||||||||||||||
return ( | ||||||||||||||||||||||||||||||||
<div className="flex flex-col gap-4 pt-2"> | ||||||||||||||||||||||||||||||||
<TextInput | ||||||||||||||||||||||||||||||||
onChange={(e) => handleTasksInputChange(e, index)} | ||||||||||||||||||||||||||||||||
value={step.data.banner.tag} | ||||||||||||||||||||||||||||||||
name="tag" | ||||||||||||||||||||||||||||||||
label="Tag" | ||||||||||||||||||||||||||||||||
placeholder="Optional" | ||||||||||||||||||||||||||||||||
/> | ||||||||||||||||||||||||||||||||
<TextInput | ||||||||||||||||||||||||||||||||
onChange={(e) => handleTasksInputChange(e, index)} | ||||||||||||||||||||||||||||||||
value={step.data.banner.title} | ||||||||||||||||||||||||||||||||
name="title" | ||||||||||||||||||||||||||||||||
label="Title" | ||||||||||||||||||||||||||||||||
placeholder="Title" | ||||||||||||||||||||||||||||||||
/> | ||||||||||||||||||||||||||||||||
<TextInput | ||||||||||||||||||||||||||||||||
onChange={(e) => handleTasksInputChange(e, index)} | ||||||||||||||||||||||||||||||||
value={step.data.banner.description} | ||||||||||||||||||||||||||||||||
name="description" | ||||||||||||||||||||||||||||||||
label="Description" | ||||||||||||||||||||||||||||||||
placeholder="Description" | ||||||||||||||||||||||||||||||||
multiline={4} | ||||||||||||||||||||||||||||||||
/> | ||||||||||||||||||||||||||||||||
<TextInput | ||||||||||||||||||||||||||||||||
onChange={(e) => handleTasksInputChange(e, index)} | ||||||||||||||||||||||||||||||||
value={step.data.banner.cta} | ||||||||||||||||||||||||||||||||
name="cta" | ||||||||||||||||||||||||||||||||
label="CTA (Call to Action)" | ||||||||||||||||||||||||||||||||
placeholder="Call to Action" | ||||||||||||||||||||||||||||||||
/> | ||||||||||||||||||||||||||||||||
<TextInput | ||||||||||||||||||||||||||||||||
onChange={(e) => handleTasksInputChange(e, index)} | ||||||||||||||||||||||||||||||||
value={step.data.banner.href} | ||||||||||||||||||||||||||||||||
name="href" | ||||||||||||||||||||||||||||||||
label="CTA Link" | ||||||||||||||||||||||||||||||||
placeholder="https://example.com" | ||||||||||||||||||||||||||||||||
/> | ||||||||||||||||||||||||||||||||
<TextInput | ||||||||||||||||||||||||||||||||
onChange={(e) => handleTasksInputChange(e, index)} | ||||||||||||||||||||||||||||||||
value={step.data.banner.image} | ||||||||||||||||||||||||||||||||
name="image" | ||||||||||||||||||||||||||||||||
label="Image URL" | ||||||||||||||||||||||||||||||||
placeholder="/karnot/endurBanner.webp" | ||||||||||||||||||||||||||||||||
/> | ||||||||||||||||||||||||||||||||
</div> | ||||||||||||||||||||||||||||||||
); | ||||||||||||||||||||||||||||||||
}; | ||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||
export default BannerStep; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Codebase verification
Add explicit import for
StepMap
type and resolve ambiguous type definitionThe
StepMap
type is not imported in bannerStep.tsx, and there are two different definitions in the codebase:types/frontTypes.d.ts
: Base type definitionapp/admin/quests/dashboard/[questId]/page.tsx
: Extended type withid
fieldAdd an explicit import from
types/frontTypes.d.ts
to ensure type consistency and prevent potential type mismatches.🔗 Analysis chain
Verify the
StepMap
type import.It's unclear how
StepMap
is declared or imported; ensure that this type is properly defined or imported to avoid potential “cannot find nameStepMap
” errors.🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
Length of output: 155
Script:
Length of output: 1859