Skip to content

Commit

Permalink
Merge branch 'staging' of github.com:dOrgTech/homebase-app into deleg…
Browse files Browse the repository at this point in the history
…ation-changes
  • Loading branch information
Man-Jain committed Sep 19, 2023
2 parents 6a12f48 + 754801b commit d71180d
Show file tree
Hide file tree
Showing 3 changed files with 132 additions and 102 deletions.
26 changes: 23 additions & 3 deletions src/modules/explorer/components/ProposalActionsDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ import { ProposalAction, ProposalFormLambda } from "modules/explorer/components/
import { useDAO } from "services/services/dao/hooks/useDAO"
import { ProposalCreatorModal } from "modules/lite/explorer/pages/CreateProposal/ProposalCreatorModal"
import { useIsProposalButtonDisabled } from "services/contracts/baseDAO/hooks/useCycleInfo"
import { useIsMember } from "modules/lite/explorer/hooks/useIsMember"
import { useTezos } from "services/beacon/hooks/useTezos"

type RecursivePartial<T> = {
[P in keyof T]?: RecursivePartial<T[P]>
Expand Down Expand Up @@ -125,6 +127,8 @@ export const ProposalActionsDialog: React.FC<Props> = ({ open, handleClose }) =>
const [openLiteProposal, setOpenLiteProposal] = useState(false)
const liteDAOId = data?.liteDAOData?._id
const shouldDisable = useIsProposalButtonDisabled(daoId)
const { network, account } = useTezos()
const isMember = useIsMember(network, data?.liteDAOData?.tokenAddress || "", account)

const handleOpenCustomProposalModal = (key: ProposalAction) => {
setProposalAction(key)
Expand Down Expand Up @@ -167,20 +171,36 @@ export const ProposalActionsDialog: React.FC<Props> = ({ open, handleClose }) =>
<Grid key={index} item xs={isMobileSmall ? 12 : 4}>
<OptionContainer
onClick={() =>
elem.id === "off-chain"
elem.id === "off-chain" && isMember
? handleLiteProposal()
: elem.id === "off-chain" && !isMember
? null
: !shouldDisable
? elem.isLambda
? handleOpenCustomProposalModal(elem.id)
: handleOpenSupportedExecuteProposalModal(elem.id)
: null
}
>
<ActionText color={shouldDisable && elem.id !== "off-chain" ? "textSecondary" : "textPrimary"}>
<ActionText
color={
shouldDisable && elem.id !== "off-chain"
? "textSecondary"
: elem.id === "off-chain" && !isMember
? "textSecondary"
: "textPrimary"
}
>
{elem.name}
</ActionText>
<ActionDescriptionText
color={shouldDisable && elem.id !== "off-chain" ? "textSecondary" : "textPrimary"}
color={
shouldDisable && elem.id !== "off-chain"
? "textSecondary"
: elem.id === "off-chain" && !isMember
? "textSecondary"
: "textPrimary"
}
>
{elem.description}{" "}
</ActionDescriptionText>
Expand Down
198 changes: 108 additions & 90 deletions src/modules/lite/explorer/pages/CreateProposal/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,11 @@ export const ProposalForm = ({

{isMobileSmall ? (
<TimeContainerMobile direction="row">
<Grid item container direction="row" xs={12}>
<Typography color="textPrimary" style={{ fontSize: 16 }}>
Set Poll Duration
</Typography>
</Grid>
<TimeBox item>
<Field
style={{ margin: "auto" }}
Expand Down Expand Up @@ -443,99 +448,112 @@ export const ProposalForm = ({
</ProposalContainer>

{!isMobileSmall ? (
<TimeContainer container item direction={"row"} style={{ gap: 10 }} xs={12} md={4} lg={4}>
<TimeBox item>
<Field
style={{ margin: "auto" }}
id="outlined-basic"
name="endTimeDays"
type="number"
placeholder="DD"
component={CustomFormikTextField}
inputProps={{ min: 0 }}
onClick={() => {
if (getIn(values, "endTimeDays") === 0) {
setFieldValue("endTimeDays", "")
setFieldTouched("endTimeDays")
}
}}
onChange={(newValue: any) => {
if (newValue.target.value === "") {
setFieldValue("endTimeDays", null)
} else {
setFieldValue("endTimeDays", parseInt(newValue.target.value, 10))
}
}}
/>
</TimeBox>
<TimeBox item>
<Field
style={{ margin: "auto" }}
id="outlined-basic"
name="endTimeHours"
type="number"
placeholder="HH"
component={CustomFormikTextField}
inputProps={{ min: 0 }}
onClick={() => {
if (getIn(values, "endTimeHours") === 0) {
setFieldValue("endTimeHours", "")
}
}}
onChange={(newValue: any) => {
if (newValue.target.value === "") {
setFieldValue("endTimeHours", null)
} else {
setFieldValue("endTimeHours", parseInt(newValue.target.value, 10))
}
}}
/>
</TimeBox>

<TimeBox item>
<Field
style={{ margin: "auto" }}
id="outlined-basic"
name="endTimeMinutes"
type="number"
placeholder="MM"
component={CustomFormikTextField}
inputProps={{ min: 0 }}
onClick={() => {
if (getIn(values, "endTimeMinutes") === 0) {
setFieldValue("endTimeMinutes", "")
}
}}
onChange={(newValue: any) => {
if (newValue.target.value === "") {
setFieldValue("endTimeMinutes", null)
} else {
setFieldValue("endTimeMinutes", parseInt(newValue.target.value, 10))
}
}}
/>
</TimeBox>
{getIn(values, "endTimeDays") !== null &&
getIn(values, "endTimeHours") !== null &&
getIn(values, "endTimeMinutes") !== null &&
!hasErrors ? (
<Grid container direction="row" style={{ marginTop: -70 }}>
<Typography color="textPrimary" variant={"body2"}>
End date:
</Typography>
<Typography color="secondary" variant="body2" style={{ marginLeft: 10 }}>
{" "}
{dayjs(Number(finalDate)).format("MM/DD/YYYY h:mm A")}
</Typography>
<>
<TimeContainer
container
item
direction={"row"}
style={{ gap: 10, flexBasis: "20% !important;" }}
xs={12}
md={4}
lg={4}
>
<Grid item container direction="row" xs={12}>
<Typography color="textPrimary">Set Poll Duration</Typography>
</Grid>
) : null}
<TimeBox item>
<Field
style={{ margin: "auto" }}
id="outlined-basic"
name="endTimeDays"
type="number"
placeholder="DD"
component={CustomFormikTextField}
inputProps={{ min: 0 }}
onClick={() => {
if (getIn(values, "endTimeDays") === 0) {
setFieldValue("endTimeDays", "")
setFieldTouched("endTimeDays")
}
}}
onChange={(newValue: any) => {
if (newValue.target.value === "") {
setFieldValue("endTimeDays", null)
} else {
setFieldValue("endTimeDays", parseInt(newValue.target.value, 10))
}
}}
/>
</TimeBox>
<TimeBox item>
<Field
style={{ margin: "auto" }}
id="outlined-basic"
name="endTimeHours"
type="number"
placeholder="HH"
component={CustomFormikTextField}
inputProps={{ min: 0 }}
onClick={() => {
if (getIn(values, "endTimeHours") === 0) {
setFieldValue("endTimeHours", "")
}
}}
onChange={(newValue: any) => {
if (newValue.target.value === "") {
setFieldValue("endTimeHours", null)
} else {
setFieldValue("endTimeHours", parseInt(newValue.target.value, 10))
}
}}
/>
</TimeBox>

<Grid container direction="row" style={{ marginTop: -80 }}>
{errors?.endTimeDays && touched.endTimeDays ? (
<ErrorTextTime>{errors.endTimeDays}</ErrorTextTime>
<TimeBox item>
<Field
style={{ margin: "auto" }}
id="outlined-basic"
name="endTimeMinutes"
type="number"
placeholder="MM"
component={CustomFormikTextField}
inputProps={{ min: 0 }}
onClick={() => {
if (getIn(values, "endTimeMinutes") === 0) {
setFieldValue("endTimeMinutes", "")
}
}}
onChange={(newValue: any) => {
if (newValue.target.value === "") {
setFieldValue("endTimeMinutes", null)
} else {
setFieldValue("endTimeMinutes", parseInt(newValue.target.value, 10))
}
}}
/>
</TimeBox>
{getIn(values, "endTimeDays") !== null &&
getIn(values, "endTimeHours") !== null &&
getIn(values, "endTimeMinutes") !== null &&
!hasErrors ? (
<Grid container direction="row" style={{ marginTop: 0 }}>
<Typography color="textPrimary" variant={"body2"}>
End date:
</Typography>
<Typography color="secondary" variant="body2" style={{ marginLeft: 10 }}>
{" "}
{dayjs(Number(finalDate)).format("MM/DD/YYYY h:mm A")}
</Typography>
</Grid>
) : null}
</Grid>
</TimeContainer>

<Grid container direction="row" style={{ marginTop: -80 }}>
{errors?.endTimeDays && touched.endTimeDays ? (
<ErrorTextTime>{errors.endTimeDays}</ErrorTextTime>
) : null}
</Grid>
</TimeContainer>
</>
) : null}
</Grid>
</Grid>
Expand Down
10 changes: 1 addition & 9 deletions src/services/services/lite/lite-services.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,11 @@
import { client, client_v2 } from "../graphql"
import { Community, DAOListItem, DAOXTZTransferDTO, FetchedDAO, FetchedProposal, FetchedProposals } from "../types"
import {
GET_DAOS_QUERY,
GET_DAOS_QUERY_V2,
GET_DAO_QUERY,
GET_PROPOSALS_QUERY,
GET_PROPOSAL_QUERY,
GET_XTZ_TRANSFERS
} from "../dao/queries"
import { GET_DAO_QUERY, GET_PROPOSALS_QUERY, GET_PROPOSAL_QUERY, GET_XTZ_TRANSFERS } from "../dao/queries"
import { LambdaProposal, Proposal } from "../dao/mappers/proposal/types"
import dayjs from "dayjs"
import { BaseDAO } from "../../contracts/baseDAO"
import axios from "axios"
import { EnvKey, getEnv } from "services/config"
import { getTokenMetadata } from "services/bakingBad/tokenBalances"
import { Network } from "services/beacon"

interface GetDAODTO {
Expand Down

0 comments on commit d71180d

Please sign in to comment.