-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
495af86
commit efe1284
Showing
7 changed files
with
162 additions
and
13 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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,40 @@ | ||
import { useMyProject } from 'hooks/my-projects'; | ||
import { NextPage } from 'next' | ||
import { useRouter } from 'next/router' | ||
import React from 'react' | ||
import MetaTags from 'containers/meta-tags'; | ||
import ProtectedRoute from 'hoc/protectedRoute'; | ||
import NewProjectLayout from 'pages/my-projects/new/layout'; | ||
import ProjectForm from 'containers/my-projects/sidebar/form'; | ||
|
||
// export const getServerSideProps = getReduxStateFromQuery(); | ||
|
||
const TITLE_TEXT = 'FORA Projects | FORA supported regenerative agriculture projects'; | ||
const DESCRIPTION_TEXT = | ||
'Stay up-to-date on the what, who, and where of the funding and strategies of FORA members for synergistic collaboration in support of your work.'; | ||
const IMAGE_URL = `${process.env.NEXT_PUBLIC_BASE_PATH}images/meta/projects.jpg`; | ||
|
||
|
||
const EditProject: NextPage = () => { | ||
const {query} = useRouter(); | ||
const {id: projectId} = query; | ||
const {data: myProjectData} = useMyProject(`${projectId}`); | ||
|
||
return ( | ||
<ProtectedRoute> | ||
<div> | ||
<MetaTags | ||
title={TITLE_TEXT} | ||
description={DESCRIPTION_TEXT} | ||
type="website" | ||
imageURL={IMAGE_URL} | ||
/> | ||
<NewProjectLayout> | ||
<ProjectForm mode='create' initialData={myProjectData} projectId={projectId as string} /> | ||
</NewProjectLayout> | ||
</div> | ||
</ProtectedRoute> | ||
) | ||
} | ||
|
||
export default EditProject |
This file contains 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
This file contains 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
This file contains 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,75 @@ | ||
import { createSlice, PayloadAction } from '@reduxjs/toolkit'; | ||
import { HYDRATE } from 'next-redux-wrapper'; | ||
import { STORE_WRAPPER } from 'store'; | ||
import qs from 'query-string'; | ||
|
||
export interface ProjectFormState { | ||
draftProject: { | ||
name: string; | ||
description: string; | ||
logo: File | null; | ||
contact_first_name: string; | ||
contact_last_name: string; | ||
website: string; | ||
country_id: number | null; | ||
state_id: number | null; | ||
city: string; | ||
leadership_demographics_other: string; | ||
recipient_legal_status: string; | ||
leadership_demographics: string[]; | ||
} | ||
} | ||
|
||
const initialState: ProjectFormState = { | ||
draftProject:{ | ||
name: '', | ||
description: '', | ||
logo: null, | ||
contact_first_name: '', | ||
contact_last_name: '', | ||
website: '', | ||
country_id: null, | ||
state_id: null, | ||
city: '', | ||
leadership_demographics_other: '', | ||
recipient_legal_status: '', | ||
leadership_demographics: [], | ||
} | ||
|
||
}; | ||
|
||
const slice = createSlice({ | ||
name: '/createProjectForm', | ||
initialState, | ||
reducers: { | ||
// updateField: <K extends keyof ProjectFormState>( | ||
// state: ProjectFormState, | ||
// action: PayloadAction<{ field: K; value: ProjectFormState[K] }> | ||
// ) => { | ||
// state[action.payload.field] = action.payload.value; | ||
// }, | ||
// setForm: (state, action: PayloadAction<ProjectFormState>) => { | ||
// return action.payload; | ||
// }, | ||
|
||
updateDraft: (state, action: PayloadAction<Partial<ProjectFormState['draftProject']>>) => { | ||
state.draftProject = { ...state.draftProject, ...action.payload }; | ||
}, | ||
|
||
clearDraft: (state) => { | ||
state.draftProject = initialState.draftProject; | ||
} | ||
}, | ||
extraReducers: { | ||
[HYDRATE]: (state, action) => { | ||
return { | ||
...state, | ||
...action.payload['/createProjectForm'], | ||
}; | ||
}, | ||
}, | ||
}); | ||
|
||
export const { updateDraft, clearDraft } = slice.actions; | ||
|
||
export default slice.reducer; |