mirror of
https://github.com/rzmk/learnhouse.git
synced 2025-12-19 04:19:25 +00:00
feat: use Next.js on demand revalidation
This commit is contained in:
parent
86e4ec64b5
commit
cc6cc52ba5
7 changed files with 39 additions and 10 deletions
|
|
@ -1,4 +1,4 @@
|
|||
import FormLayout, { ButtonBlack, Flex, FormField, FormLabel, Input, Textarea } from '@components/UI/Form/Form'
|
||||
import FormLayout, { ButtonBlack, Flex, FormField, FormLabel, Input, Textarea } from '@components/UI/Form/Form'
|
||||
import * as Form from '@radix-ui/react-form'
|
||||
import { getAPIUrl, getUriWithOrg } from '@services/config/config';
|
||||
import { FormMessage } from "@radix-ui/react-form";
|
||||
|
|
@ -7,6 +7,7 @@ import { getOrganizationContextInfo } from '@services/organizations/orgs';
|
|||
import React, { useState } from 'react'
|
||||
import { BarLoader } from 'react-spinners'
|
||||
import { mutate } from 'swr';
|
||||
import { revalidateTags } from '@services/utils/ts/requests';
|
||||
|
||||
function CreateCourseModal({ closeModal, orgslug }: any) {
|
||||
const [isSubmitting, setIsSubmitting] = useState(false);
|
||||
|
|
@ -19,7 +20,7 @@ function CreateCourseModal({ closeModal, orgslug }: any) {
|
|||
|
||||
|
||||
const getOrgMetadata = async () => {
|
||||
const org = await getOrganizationContextInfo(orgslug);
|
||||
const org = await getOrganizationContextInfo(orgslug, { revalidate: 360, tags: ['organizations'] });
|
||||
setOrgId(org.org_id);
|
||||
}
|
||||
|
||||
|
|
@ -40,7 +41,7 @@ function CreateCourseModal({ closeModal, orgslug }: any) {
|
|||
e.preventDefault();
|
||||
setIsSubmitting(true);
|
||||
let status = await createNewCourse(orgId, { name, description }, thumbnail);
|
||||
mutate(`${getAPIUrl()}courses/org_slug/${orgslug}/page/1/limit/10`);
|
||||
revalidateTags(['courses']);
|
||||
setIsSubmitting(false);
|
||||
|
||||
if (status.org_id == orgId) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue