Skip to content
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

Release #252

Merged
merged 4 commits into from
Aug 14, 2024
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
3 changes: 1 addition & 2 deletions .env.development
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
# BASE_URL='https://develop-api.fortress.d.foundation/api/v1'
BASE_URL='https://api.fortress.d.foundation/api/v1'
BASE_URL='https://develop-api.fortress.d.foundation/api/v1'
GOOGLE_CLIENT_ID='180094408893-s17eot91hbmqa5lp6gsgjglan9et20sp.apps.googleusercontent.com'
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# Fortress Web V2

An opinionated production-ready frontend boilerplate built on top of NextJS,
shipped with TypeScript, SWR, Antd, Jest, testing-library and Storybook.
Web dashboard application for managing resources and measuring performance at https://dwarves.foundation/.

## Quick Start

Expand All @@ -25,7 +24,7 @@ to see your project.
| Name | Link |
| ----------- | ----------------------------------------- |
| Development | https://develop--fortress-v2.netlify.app/ |
| Production | https://fortress-v2.netlify.app/ |
| Production | https://fortress.d.foundation/ |

## References

Expand Down
1 change: 0 additions & 1 deletion src/components/pages/projects/add/ProjectForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,6 @@ export const ProjectForm = (props: Props) => {
form={form}
name="deliveryManagers"
label="Delivery Managers"
rules={[{ required: true, message: 'Required' }]}
selectProps={{ placeholder: "Select project's delivery manager" }}
/>
</Col>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
import { Form, Modal, notification, Space } from 'antd'
import { useForm } from 'antd/lib/form/Form'
import { AsyncSelect } from 'components/common/Select'
import { client, GET_PATHS } from 'libs/apis'
import { useState } from 'react'
import { transformBankAccountDataToSelectOption } from 'utils/select'
import { getErrorMessage } from 'utils/string'

// TODO: Types
type ProjectBankAccountFormValues = Partial<any>

interface Props {
projectID: string
isOpen: boolean
initialValues: ProjectBankAccountFormValues
onClose: () => void
onAfterSubmit: () => void
}

export const EditProjectBankAccountModal = (props: Props) => {
const { projectID, isOpen, initialValues, onClose, onAfterSubmit } = props

const [form] = useForm()
const [isSubmitting, setIsSubmitting] = useState(false)

const onSubmit = async (values: ProjectBankAccountFormValues) => {
try {
setIsSubmitting(true)

// TODO: Types
await client.updateProjectGeneralInfo(projectID, {
// NOTE: We need these values to be able to reuse the updateProjectGeneralInfo function
name: initialValues.name,
importantLevel: initialValues.importantLevel,
countryID: initialValues.country?.id,
accountRating: initialValues.accountRating,
leadRating: initialValues.leadRating,
deliveryRating: initialValues.deliveryRating,
function: initialValues.function,
...values,
})

notification.success({
message: "Project's bank account updated successfully!",
})

onClose()
onAfterSubmit()
} catch (error: any) {
notification.error({
message: getErrorMessage(
error,
"Could not update project's bank account",
),
})
} finally {
setIsSubmitting(false)
}
}

return (
<Modal
open={isOpen}
onCancel={() => {
onClose()
form.resetFields()
}}
onOk={form.submit}
okButtonProps={{ loading: isSubmitting }}
destroyOnClose
title="Edit Project's Bank Account"
>
<Form form={form} onFinish={onSubmit} initialValues={initialValues}>
<Space direction="vertical" style={{ width: '100%' }}>
<Form.Item label="Bank Account" name="bankAccountID">
<AsyncSelect
swrKeys={GET_PATHS.getBankAccounts}
optionGetter={async () => {
const { data } = await client.getBankAccounts()
return data?.map(transformBankAccountDataToSelectOption) || []
}}
placeholder="Select bank account"
/>
</Form.Item>
</Space>
</Form>
</Modal>
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
import { Form, Modal, notification, Space } from 'antd'
import { useForm } from 'antd/lib/form/Form'
import { AsyncSelect } from 'components/common/Select'
import { client, GET_PATHS } from 'libs/apis'
import { useState } from 'react'
import { transformClientDataToSelectOption } from 'utils/select'
import { getErrorMessage } from 'utils/string'

// TODO: Types
type ProjectClientFormValues = Partial<any>

interface Props {
projectID: string
isOpen: boolean
initialValues: ProjectClientFormValues
onClose: () => void
onAfterSubmit: () => void
}

export const EditProjectClientModal = (props: Props) => {
const { projectID, isOpen, initialValues, onClose, onAfterSubmit } = props

const [form] = useForm()
const [isSubmitting, setIsSubmitting] = useState(false)

const onSubmit = async (values: ProjectClientFormValues) => {
try {
setIsSubmitting(true)

// TODO: Types
await client.updateProjectGeneralInfo(projectID, {
// NOTE: We need these values to be able to reuse the updateProjectGeneralInfo function
name: initialValues.name,
importantLevel: initialValues.importantLevel,
countryID: initialValues.country?.id,
accountRating: initialValues.accountRating,
leadRating: initialValues.leadRating,
deliveryRating: initialValues.deliveryRating,
function: initialValues.function,
...values,
})

notification.success({
message: "Project's client updated successfully!",
})

onClose()
onAfterSubmit()
} catch (error: any) {
notification.error({
message: getErrorMessage(error, "Could not update project's client"),
})
} finally {
setIsSubmitting(false)
}
}

return (
<Modal
open={isOpen}
onCancel={() => {
onClose()
form.resetFields()
}}
onOk={form.submit}
okButtonProps={{ loading: isSubmitting }}
destroyOnClose
title="Edit Project's Client"
>
<Form form={form} onFinish={onSubmit} initialValues={initialValues}>
<Space direction="vertical" style={{ width: '100%' }}>
<Form.Item label="Client" name="clientID">
<AsyncSelect
swrKeys={GET_PATHS.getClients}
optionGetter={async () => {
const { data } = await client.getClients()
return data?.map(transformClientDataToSelectOption) || []
}}
placeholder="Select client"
/>
</Form.Item>
</Space>
</Form>
</Modal>
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
import { Form, Modal, notification, Space } from 'antd'
import { useForm } from 'antd/lib/form/Form'
import { AsyncSelect } from 'components/common/Select'
import { client, GET_PATHS } from 'libs/apis'
import { useState } from 'react'
import { transformCompanyInfoDataToSelectOption } from 'utils/select'
import { getErrorMessage } from 'utils/string'

// TODO: Types
type ProjectCompanyInfoFormValues = Partial<any>

interface Props {
projectID: string
isOpen: boolean
initialValues: ProjectCompanyInfoFormValues
onClose: () => void
onAfterSubmit: () => void
}

export const EditProjectCompanyInfoModal = (props: Props) => {
const { projectID, isOpen, initialValues, onClose, onAfterSubmit } = props

const [form] = useForm()
const [isSubmitting, setIsSubmitting] = useState(false)

const onSubmit = async (values: ProjectCompanyInfoFormValues) => {
try {
setIsSubmitting(true)

// TODO: Types
await client.updateProjectGeneralInfo(projectID, {
// NOTE: We need these values to be able to reuse the updateProjectGeneralInfo function
name: initialValues.name,
importantLevel: initialValues.importantLevel,
countryID: initialValues.country?.id,
accountRating: initialValues.accountRating,
leadRating: initialValues.leadRating,
deliveryRating: initialValues.deliveryRating,
function: initialValues.function,
...values,
})

notification.success({
message: "Project's company info updated successfully!",
})

onClose()
onAfterSubmit()
} catch (error: any) {
notification.error({
message: getErrorMessage(
error,
"Could not update project's company info",
),
})
} finally {
setIsSubmitting(false)
}
}

return (
<Modal
open={isOpen}
onCancel={() => {
onClose()
form.resetFields()
}}
onOk={form.submit}
okButtonProps={{ loading: isSubmitting }}
destroyOnClose
title="Edit Project's Company Info"
>
<Form form={form} onFinish={onSubmit} initialValues={initialValues}>
<Space direction="vertical" style={{ width: '100%' }}>
<Form.Item label="Company Info" name="companyInfoID">
<AsyncSelect
swrKeys={GET_PATHS.getCompanyInfos}
optionGetter={async () => {
const { data } = await client.getCompanyInfos()
return data?.map(transformCompanyInfoDataToSelectOption) || []
}}
placeholder="Select company info"
/>
</Form.Item>
</Space>
</Form>
</Modal>
)
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import { Form, Input, Modal, notification, Space } from 'antd'
import { useForm } from 'antd/lib/form/Form'
import { FormAccountWithRateList } from 'components/common/FormAccountWithRateList'
import { client } from 'libs/apis'
import { useState } from 'react'
import { RequestUpdateContactInfoInput } from 'types/schema'
import { getErrorMessage } from 'utils/string'
import { FormInputList } from 'components/common/FormInputList'
import { FormAccountWithRateList } from 'components/common/FormAccountWithRateList'

type ProjectContactInfoFormValues = Partial<RequestUpdateContactInfoInput>

Expand Down Expand Up @@ -65,7 +64,7 @@ export const EditProjectContactInfoModal = (props: Props) => {
>
<Form form={form} onFinish={onSubmit} initialValues={initialValues}>
<Space direction="vertical" style={{ width: '100%' }}>
<FormInputList
{/* <FormInputList
form={form}
name="clientEmail"
label="Client Email"
Expand All @@ -75,7 +74,7 @@ export const EditProjectContactInfoModal = (props: Props) => {
]}
addButtonProps={{ children: 'Add email' }}
inputProps={{ type: 'email', placeholder: 'Enter client email' }}
/>
/> */}
<Form.Item
label="Project Email"
name="projectEmail"
Expand All @@ -97,7 +96,6 @@ export const EditProjectContactInfoModal = (props: Props) => {
form={form}
name="deliveryManagers"
label="Delivery Managers"
rules={[{ required: true, message: 'Required' }]}
selectProps={{ placeholder: "Select project's delivery manager" }}
/>
<FormAccountWithRateList
Expand Down
Loading
Loading