forked from elliotBraem/efizzybot
-
Notifications
You must be signed in to change notification settings - Fork 7
feat: new feed edit #198
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
Merged
Merged
feat: new feed edit #198
Changes from 3 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
a86f088
feat: update the feed editor
itexpert120 59cf4bc
feat: improve performance, and fix bugs
itexpert120 61c4f31
feat: revert local development change
itexpert120 91f16d2
add routegen to pretttier ignore
itexpert120 4664c4a
fix: resolve code rabbit comments
itexpert120 bc40369
fix some nitpick comments
itexpert120 6d20a33
fix prettier and build config
itexpert120 c7c558d
merge staging
elliotBraem 6c08527
Merge branch 'staging' into feat/new-feed-edit
elliotBraem 9f043b7
formats
elliotBraem 0668035
Merge branch 'staging' of https://github.com/PotLock/curatedotfun int…
elliotBraem bb6a927
merge
elliotBraem File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,60 @@ | ||
| import type { FeedConfig } from "@curatedotfun/types"; | ||
| import { Button } from "../ui/button"; | ||
| import { Loading } from "../ui/loading"; | ||
|
|
||
| interface EditFeedActionsProps { | ||
| currentConfig: FeedConfig | null; | ||
| onSaveChanges: () => Promise<void>; | ||
| onDeleteFeed: () => Promise<void>; | ||
| updateFeedMutation: { | ||
| isPending: boolean; | ||
| }; | ||
| deleteFeedMutation: { | ||
| isPending: boolean; | ||
| }; | ||
| } | ||
|
|
||
| export function EditFeedActions({ | ||
| onSaveChanges, | ||
| onDeleteFeed, | ||
| updateFeedMutation, | ||
| deleteFeedMutation, | ||
| }: EditFeedActionsProps) { | ||
| return ( | ||
| <div className="bg-white p-6 border border-gray-200 rounded-lg"> | ||
| <div className="flex flex-col sm:flex-row gap-4 pt-2"> | ||
| <Button | ||
| onClick={onSaveChanges} | ||
| disabled={updateFeedMutation.isPending} | ||
| className="flex-1 sm:flex-none" | ||
| size="lg" | ||
| > | ||
| {updateFeedMutation.isPending ? ( | ||
| <> | ||
| <Loading /> | ||
| <span className="ml-2">Saving...</span> | ||
| </> | ||
| ) : ( | ||
| "Save Changes" | ||
| )} | ||
| </Button> | ||
| <Button | ||
| variant="destructive" | ||
| onClick={onDeleteFeed} | ||
| disabled={deleteFeedMutation.isPending} | ||
| className="flex-1 sm:flex-none" | ||
| size="lg" | ||
| > | ||
| {deleteFeedMutation.isPending ? ( | ||
| <> | ||
| <Loading /> | ||
| <span className="ml-2">Deleting...</span> | ||
| </> | ||
| ) : ( | ||
| "Delete Feed" | ||
| )} | ||
| </Button> | ||
| </div> | ||
| </div> | ||
| ); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,86 @@ | ||
| import type { FeedConfig } from "@curatedotfun/types"; | ||
| import { useState, useRef } from "react"; | ||
| import { JsonEditor } from "../content-progress/JsonEditor"; | ||
| import { Button } from "../ui/button"; | ||
| import { Label } from "../ui/label"; | ||
| import { EditFeedForm, type EditFeedFormRef } from "./EditFeedForm"; | ||
|
|
||
| interface EditFeedConfigSectionProps { | ||
| jsonString: string; | ||
| currentConfig: FeedConfig | null; | ||
| onJsonChange: (newJsonString: string) => void; | ||
| onConfigChange: (config: FeedConfig) => void; | ||
| } | ||
|
|
||
| export function EditFeedConfigSection({ | ||
| jsonString, | ||
| currentConfig, | ||
| onJsonChange, | ||
| onConfigChange, | ||
| }: EditFeedConfigSectionProps) { | ||
| const [isJsonMode, setIsJsonMode] = useState(false); | ||
| const formRef = useRef<EditFeedFormRef>(null); | ||
|
|
||
| const handleConfigChange = (config: FeedConfig) => { | ||
| onConfigChange(config); | ||
| // Also update the JSON string to keep them in sync | ||
| onJsonChange(JSON.stringify(config, null, 2)); | ||
| }; | ||
|
|
||
| const handleSwitchToFormMode = () => { | ||
| setIsJsonMode(false); | ||
| // Trigger form update after switching to form mode | ||
| setTimeout(() => { | ||
| formRef.current?.updateFromConfig(); | ||
| }, 0); | ||
| }; | ||
|
|
||
| return ( | ||
| <div className="bg-white p-6 border border-gray-200 rounded-lg"> | ||
| <div className="space-y-6"> | ||
| <div className="flex items-center justify-between"> | ||
| <div className="space-y-2"> | ||
| <h2 className="text-xl font-semibold">Feed Configuration</h2> | ||
| <p className="text-gray-600"> | ||
| {isJsonMode | ||
| ? "Edit the JSON configuration directly to fine-tune your feed settings" | ||
| : "Use the form below to easily configure your feed settings"} | ||
| </p> | ||
| </div> | ||
| <div className="flex gap-2"> | ||
| <Button | ||
| variant={!isJsonMode ? "default" : "outline"} | ||
| size="sm" | ||
| onClick={handleSwitchToFormMode} | ||
| > | ||
| Form View | ||
| </Button> | ||
| <Button | ||
| variant={isJsonMode ? "default" : "outline"} | ||
| size="sm" | ||
| onClick={() => setIsJsonMode(true)} | ||
| > | ||
| JSON View | ||
| </Button> | ||
| </div> | ||
| </div> | ||
|
|
||
| {isJsonMode ? ( | ||
| <div className="space-y-2"> | ||
| <Label>Feed Configuration (JSON)</Label> | ||
| <JsonEditor | ||
| jsonContent={jsonString} | ||
| onContentChange={onJsonChange} | ||
| /> | ||
| </div> | ||
| ) : ( | ||
| <EditFeedForm | ||
| ref={formRef} | ||
| currentConfig={currentConfig} | ||
| onConfigChange={handleConfigChange} | ||
| /> | ||
| )} | ||
| </div> | ||
| </div> | ||
| ); | ||
| } | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.