Move submission edit load outside Apollo flow
@@ -116,28 +116,6 @@ export const CfpForm: React.SFC<Props> = ({
variables: {
conference: conferenceCode,
},
- onCompleted(data) {
- if (submission) {
- formState.setField("type", submission!.type.id);
- formState.setField("title", submission!.title);
- formState.setField("elevatorPitch", submission!.elevatorPitch);
- formState.setField("topic", submission!.topic.id);
- formState.setField("length", submission!.duration.id);
- formState.setField("audienceLevel", submission!.audienceLevel.id);
- formState.setField(
- "languages",
- submission!.languages.map((l) => l.code),
- );
- formState.setField("abstract", submission!.abstract);
- formState.setField("notes", submission!.notes);
- formState.setField(
- "tags",
- submission!.tags.map((t) => t.id),
- );
- formState.setField("speakerLevel", submission!.speakerLevel);
- formState.setField("previousTalkVideo", submission!.previousTalkVideo);
- }
- },
});
const submitSubmission = async (e: React.FormEvent<HTMLFormElement>) => {
@@ -184,6 +162,29 @@ export const CfpForm: React.SFC<Props> = ({
}
}, [formState.values.type]);
+ useEffect(() => {
+ if (!conferenceLoading && submission) {
+ formState.setField("type", submission!.type.id);
+ formState.setField("title", submission!.title);
+ formState.setField("elevatorPitch", submission!.elevatorPitch);
+ formState.setField("topic", submission!.topic.id);
+ formState.setField("length", submission!.duration.id);
+ formState.setField("audienceLevel", submission!.audienceLevel.id);
+ formState.setField(
+ "languages",
+ submission!.languages.map((l) => l.code),
+ );
+ formState.setField("abstract", submission!.abstract);
+ formState.setField("notes", submission!.notes);
+ formState.setField(
+ "tags",
+ submission!.tags.map((t) => t.id),
+ );
+ formState.setField("speakerLevel", submission!.speakerLevel);
+ formState.setField("previousTalkVideo", submission!.previousTalkVideo);
+ }
+ }, [conferenceLoading]);
+
if (conferenceLoading) {
return (
<Alert variant="info">
