Skip to content

Commit

Permalink
updated filemapper, prettified all code
Browse files Browse the repository at this point in the history
  • Loading branch information
D-Unit committed Nov 20, 2024
1 parent f2fb031 commit 1708ded
Show file tree
Hide file tree
Showing 94 changed files with 3,948 additions and 3,251 deletions.
50 changes: 27 additions & 23 deletions apps/4tu/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,11 @@ import {
UserSubmissions,
SignInCallback,
} from "@dans-framework/user-auth";
import { RepoAdvisor, RepoBar, NoRepoSelected } from '@dans-framework/repo-advisor';
import {
RepoAdvisor,
RepoBar,
NoRepoSelected,
} from "@dans-framework/repo-advisor";
import { Generic, type Page } from "@dans-framework/pages";

// Load config variables
Expand All @@ -27,16 +31,16 @@ import { AnimatePresence, motion } from "framer-motion";

const App = () => {
const { i18n } = useTranslation();
const [ repoConfig, setRepoConfig ] = useState<FormConfig>();
const configIsSet = repoConfig?.hasOwnProperty('form') || false;
const [repoConfig, setRepoConfig] = useState<FormConfig>();
const configIsSet = repoConfig?.hasOwnProperty("form") || false;
return (
<AuthWrapper authProvider={authProvider}>
<ThemeWrapper theme={theme} siteTitle={siteTitle}>
<BrowserRouter>
{/* Suspense to make sure languages can load first */}
<Suspense>
<AnimatePresence>
{ configIsSet &&
{configIsSet && (
<motion.div
initial={{ opacity: 0, y: -10 }}
animate={{ opacity: 1, y: 0 }}
Expand All @@ -45,14 +49,14 @@ const App = () => {
>
<RepoBar repo={repoConfig?.displayName} />
</motion.div>
}
)}
</AnimatePresence>
</Suspense>
<LanguageBar
languages={languages}
changeLanguage={i18n.changeLanguage}
/>
<MenuBar
<MenuBar
pages={pages}
userSettings={configIsSet}
userSubmissions={configIsSet}
Expand All @@ -75,9 +79,8 @@ const App = () => {
<UserSettings
target={repoConfig.targetCredentials}
depositSlug=""
/> :
<NoRepoSelected advisorLocation="/" />
}
/>
: <NoRepoSelected advisorLocation="/" />}
</AuthRoute>
}
/>
Expand All @@ -86,9 +89,8 @@ const App = () => {
element={
<AuthRoute>
{repoConfig ?
<UserSubmissions depositSlug="" /> :
<NoRepoSelected advisorLocation="/" />
}
<UserSubmissions depositSlug="" />
: <NoRepoSelected advisorLocation="/" />}
</AuthRoute>
}
/>
Expand All @@ -102,13 +104,16 @@ const App = () => {
page.template === "deposit" ?
<AuthRoute>
{repoConfig ?
<Deposit config={repoConfig} page={page} /> :
<NoRepoSelected advisorLocation="/" />
}
<Deposit config={repoConfig} page={page} />
: <NoRepoSelected advisorLocation="/" />}
</AuthRoute>
: page.template === "advisor" ?
<AuthRoute>
<RepoAdvisor page={page} setRepoConfig={setRepoConfig} depositLocation="/deposit" />
<RepoAdvisor
page={page}
setRepoConfig={setRepoConfig}
depositLocation="/deposit"
/>
</AuthRoute>
: <Generic {...page} />
}
Expand All @@ -122,16 +127,15 @@ const App = () => {
element={
<AuthRoute>
{repoConfig ?
<Deposit
config={repoConfig}
page={{
<Deposit
config={repoConfig}
page={{
name: "Deposit",
id: "deposit",
inMenu: true,
}}
/> :
<NoRepoSelected advisorLocation="/" />
}
}}
/>
: <NoRepoSelected advisorLocation="/" />}
</AuthRoute>
}
/>
Expand Down
2 changes: 1 addition & 1 deletion apps/4tu/src/config/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ const authProvider = {
loadUserInfo: true,
};

export default authProvider;
export default authProvider;
80 changes: 40 additions & 40 deletions apps/4tu/src/config/i18n.ts
Original file line number Diff line number Diff line change
@@ -1,40 +1,40 @@
import i18n from "i18next";
import { initReactI18next } from "react-i18next";
import languages from "./languages";
import LanguageDetector from "i18next-browser-languagedetector";
import { i18n as i18nLayout } from "@dans-framework/layout";
import { i18n as i18nDeposit } from "@dans-framework/deposit";
import { i18n as i18nAuth } from "@dans-framework/user-auth";
import { i18n as i18nRepo } from "@dans-framework/repo-advisor";

// this is the main language provider for all subcomponents/libraries
i18n
.use(LanguageDetector)
.use(initReactI18next)
.init({
debug: import.meta.env.DEV,
supportedLngs: languages,
detection: {
order: ["cookie", "localStorage"],
lookupCookie: "i18next",
lookupLocalStorage: "i18nextLng",
caches: ["localStorage", "cookie"],
},
fallbackLng: "en",
interpolation: {
escapeValue: false,
},
react: {
useSuspense: true,
},
});

// make sure to import languages for the components that need it
i18n.on("languageChanged", (lng) => {
i18nLayout.changeLanguage(lng);
i18nDeposit.changeLanguage(lng);
i18nAuth.changeLanguage(lng);
i18nRepo.changeLanguage(lng);
});

export default i18n;
import i18n from "i18next";
import { initReactI18next } from "react-i18next";
import languages from "./languages";
import LanguageDetector from "i18next-browser-languagedetector";
import { i18n as i18nLayout } from "@dans-framework/layout";
import { i18n as i18nDeposit } from "@dans-framework/deposit";
import { i18n as i18nAuth } from "@dans-framework/user-auth";
import { i18n as i18nRepo } from "@dans-framework/repo-advisor";

// this is the main language provider for all subcomponents/libraries
i18n
.use(LanguageDetector)
.use(initReactI18next)
.init({
debug: import.meta.env.DEV,
supportedLngs: languages,
detection: {
order: ["cookie", "localStorage"],
lookupCookie: "i18next",
lookupLocalStorage: "i18nextLng",
caches: ["localStorage", "cookie"],
},
fallbackLng: "en",
interpolation: {
escapeValue: false,
},
react: {
useSuspense: true,
},
});

// make sure to import languages for the components that need it
i18n.on("languageChanged", (lng) => {
i18nLayout.changeLanguage(lng);
i18nDeposit.changeLanguage(lng);
i18nAuth.changeLanguage(lng);
i18nRepo.changeLanguage(lng);
});

export default i18n;
10 changes: 5 additions & 5 deletions apps/4tu/src/config/languages.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { Language } from "@dans-framework/utils";

const languages: Language[] = ["en", "nl"];

export default languages;
import type { Language } from "@dans-framework/utils";

const languages: Language[] = ["en", "nl"];

export default languages;
66 changes: 33 additions & 33 deletions apps/4tu/src/config/pages.ts
Original file line number Diff line number Diff line change
@@ -1,33 +1,33 @@
import type { Page } from "@dans-framework/pages";

const depositPage: Page = {
id: "deposit",
name: {
en: "Deposit",
nl: "Deponeren",
},
slug: "deposit",
template: "deposit",
inMenu: true,
menuTitle: {
en: "Deposit",
nl: "Deponeren",
},
};

const advisorPage: Page = {
id: "advisor",
name: {
en: "Repository selector",
nl: "Repository selector",
},
slug: "/",
template: "advisor",
inMenu: true,
menuTitle: {
en: "Repository selector",
nl: "Repository selector",
},
};

export default [ advisorPage, depositPage ];
import type { Page } from "@dans-framework/pages";

const depositPage: Page = {
id: "deposit",
name: {
en: "Deposit",
nl: "Deponeren",
},
slug: "deposit",
template: "deposit",
inMenu: true,
menuTitle: {
en: "Deposit",
nl: "Deponeren",
},
};

const advisorPage: Page = {
id: "advisor",
name: {
en: "Repository selector",
nl: "Repository selector",
},
slug: "/",
template: "advisor",
inMenu: true,
menuTitle: {
en: "Repository selector",
nl: "Repository selector",
},
};

export default [advisorPage, depositPage];
Loading

0 comments on commit 1708ded

Please sign in to comment.