Skip to content

Commit

Permalink
updated
Browse files Browse the repository at this point in the history
  • Loading branch information
ap-justin committed Oct 3, 2024
1 parent b6c956f commit 5a94248
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 33 deletions.
27 changes: 1 addition & 26 deletions src/pages/Funds/CreateFund/CreateFund.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { yupResolver } from "@hookform/resolvers/yup";
import { ControlledImgEditor as ImgEditor } from "components/ImgEditor";
import Prompt from "components/Prompt";
import { LockedSplitSlider } from "components/donation";
import {
NativeCheckField as CheckField,
NativeField as Field,
Expand Down Expand Up @@ -49,17 +48,12 @@ export default withAuth(function CreateFund() {
settings: {
from: "fund",
allowBgTip: true,
liquidSplit: 50,
},
targetType: "smart",
},
});
const { field: banner } = useController({ control, name: "banner" });
const { field: logo } = useController({ control, name: "logo" });
const { field: liquidSplitPct } = useController({
control,
name: "settings.liquidSplit",
});
const { field: members } = useController({
control,
name: "members",
Expand All @@ -69,9 +63,6 @@ export default withAuth(function CreateFund() {
name: "targetType",
});

//keep track of what user previously set
//revert to it when endow is no longer 1
const customSplitRef = useRef(50);
const customAllowBgTipRef = useRef(true);
const endowReqRef = useRef<string>();

Expand Down Expand Up @@ -105,7 +96,6 @@ export default withAuth(function CreateFund() {
members: fv.members.map((m) => m.id),
featured: fv.featured,
settings: {
liquidSplitPct: fv.settings.liquidSplit,
allowBgTip: fv.settings.allowBgTip,
},
target:
Expand Down Expand Up @@ -182,7 +172,6 @@ export default withAuth(function CreateFund() {
endowReqRef.current = undefined;
return setValue("settings", {
from: "fund",
liquidSplit: customSplitRef.current,
allowBgTip: customAllowBgTipRef.current,
});
}
Expand All @@ -193,7 +182,7 @@ export default withAuth(function CreateFund() {
const endowReq = getEndow(
{
id: opt.id,
fields: ["hide_bg_tip", "splitLiqPct", "name"],
fields: ["hide_bg_tip", "name"],
},
true
);
Expand All @@ -208,7 +197,6 @@ export default withAuth(function CreateFund() {
setValue("settings", {
from: endow.name,
allowBgTip: !endow.hide_bg_tip,
liquidSplit: endow.splitLiqPct ?? 50,
});
} catch (err) {
logger.error(err);
Expand Down Expand Up @@ -299,19 +287,6 @@ export default withAuth(function CreateFund() {
`${withPossesive(settings.from)} config has been applied`}
</p>

<label className="block mb-4 mt-10 font-medium text-base">
Define default split value:
</label>
<LockedSplitSlider
disabled={settings.from !== "fund"}
value={100 - liquidSplitPct.value}
onChange={(lockedPct) => {
const liq = 100 - lockedPct;
liquidSplitPct.onChange(liq);
customSplitRef.current = liq;
}}
/>

<CheckField
{...register("settings.allowBgTip")}
disabled={settings.from !== "fund"}
Expand Down
1 change: 0 additions & 1 deletion src/pages/Funds/CreateFund/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ export interface FundMember {
export interface Settings {
/** endowname or fund */
from: string;
liquidSplit: number;
allowBgTip: boolean;
}

Expand Down
7 changes: 3 additions & 4 deletions src/pages/Funds/CreateFund/useEndow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { useLazyProfileQuery } from "services/aws/aws";
import type { Endowment } from "types/aws";
import type { FundMember } from "./types";

export type Endow = Pick<Endowment, "splitLiqPct" | "hide_bg_tip" | "name">;
export type Endow = Pick<Endowment, "hide_bg_tip" | "name">;

export function useEndow(
members: FundMember[],
Expand All @@ -24,15 +24,14 @@ export function useEndow(
getEndow(
{
id: numId,
fields: ["hide_bg_tip", "splitLiqPct", "name"],
fields: ["hide_bg_tip", "name"],
},
true
)
.unwrap()
.then(({ hide_bg_tip, splitLiqPct, name }) => {
.then(({ hide_bg_tip, name }) => {
onEndowSet({
hide_bg_tip,
splitLiqPct,
name,
});
});
Expand Down
2 changes: 0 additions & 2 deletions src/types/aws/ap/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -247,8 +247,6 @@ export interface Fund {
featured: boolean;
active: boolean;
settings: {
/** 1 - 100 */
liquidSplitPct: number;
allowBgTip: boolean;
};
/** iso */
Expand Down

0 comments on commit 5a94248

Please sign in to comment.