File size: 4,186 Bytes
01fcadf
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
---

import SettingsCard from "@components/settings/SettingsCard.astro";

import Toast from "@components/toasts/Toast.svelte";

import ToastWrapper from "@components/toasts/ToastWrapper.svelte";

import Layout from "@layouts/Layout.astro";

import SettingsLayout from "@layouts/SettingsLayout.astro";

import SettingsSection from "@layouts/SettingsSection.astro";

import { getLangFromUrl, useTranslations } from "../../../i18n/utils";



const origin = Astro.url.origin;

const lang = getLangFromUrl(Astro.url);

const t = useTranslations(lang);

export function getStaticPaths() {

    const STATIC_PATHS = [{ params: { lang: "en_US" } }, { params: { lang: "jp" } }];

    return STATIC_PATHS;

}

export const prerender = true;

---



<Layout title="Settings">

  <SettingsLayout title="Miscellaneous">

  <SettingsSection title="Misc" subtitle="All of our miscellaneous settings">

    <div class="w-full h-full flex flex-col items-center justify-center flex-wrap md:flex-row md:items-start md:justify-start gap-4">

        <SettingsCard 

            title="Language"

            description="Choose your language"

            input={{input:false}}

            button={{name: 'Change Language', id: 'setlang'}}

            select={{

                select: true,

                name: 'lang',

                options: [

                    {name: 'English', value: 'en_US', disabled: false},

                    {name: 'Japanese', value: 'jp', disabled: false},

                ]

            }}

            both={{enabled: false}}

        />

        <SettingsCard

            title="Proxy Catalog"

            description="Whether or not to proxy the Catalog"

            input={{input: false}}

            button={{name: 'Set', id: 'setmp' }}

            select={{

                select: true,

                name: 'mp',

                options: [

                    {name: 'False', value: 'false', disabled: false},

                    {name: 'True', value: 'true', disabled: false}

                ]

                }}

                both={{enabled: false}}

            />

        <SettingsCard

            title="Catalog URL"

            description="Change which marketplace your using"

            input={{

                input: true,

                required: true,

                placeholder: `${origin}/api/catalog-assets`

            }}

            button={{name: 'Change', id: 'setcataloghostname' }}

            select={{select: false}}

            both={{enabled: false}}

        />

    </SettingsSection>

  </SettingsLayout>

  <ToastWrapper client:load>

    <Toast toastProp={{

            toastType: 'success',

            text: 'Catalog is now proxied',

            class: 'mpMessage'

        }}

    client:load />

    <Toast toastProp={{

        toastType: 'success',

        text: 'Catalog URL set!',

        class: 'cataloghostnameSuccess'

        }}

    client:load />

    <Toast toastProp={{

        toastType: 'error',

        text: "Catalog doesn't exist!",

        class: 'cataloghosnameError'

      }}

    client:load/>

  </ToastWrapper>

<script>

    import { toast } from "@utils/toast.ts";

    import { settings, Settings as SettingsEnum } from "@utils/settings/index";

    import { pageLoad } from "@utils/events";

    import { navigate } from "astro:transitions/client";

    function setup() {

        const lang = JSON.parse(localStorage.getItem('selectedLanguage') as string) || JSON.parse('{"value": "en_US"}');

        const languageVal = document.getElementById('lang') as HTMLSelectElement;

        languageVal!.value = lang.value;

    }

    pageLoad(() => {

        setup();

        const languageChange = document.getElementById('setlang') as HTMLButtonElement;

        const languageVal = document.getElementById('lang') as HTMLSelectElement;

        languageChange?.addEventListener('click', () => {

            const language = {value: languageVal.value}

            localStorage.setItem("selectedLanguage", JSON.stringify(language));

            navigate(`${window.location.origin}/${languageVal.value}/settings/misc`)

        });

    })

</script>