Changeset 5ce5904 for pages


Ignore:
Timestamp:
12/20/25 04:04:03 (7 months ago)
Author:
Tome <gjorgievtome@…>
Branches:
main
Children:
ee1fa4e
Parents:
c4dd17d
Message:

update telefunc

Location:
pages
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • pages/+Layout.telefunc.ts

    rc4dd17d r5ce5904  
    44
    55export async function getAuthenticationState() {
    6     const c = getAuthState();
     6    const context = getAuthState();
    77
    8     return c;
     8    return context;
    99}
    1010
    11 export async function getPopupAllComponents({ componentType, q, limit }
    12                                             : { componentType?: string; q?: string; limit?: number }) {
     11export async function getPopupAllComponents({ componentType, limit, q }
     12                                            : { componentType?: string; limit?: number; q?: string }) {
    1313    const c = ctx();
    1414
    15     // getAllComponents
     15    const components = await drizzleQueries.getAllComponents(c.db, limit, q, componentType);
     16
     17    return components;
     18}
     19
     20export async function getPopupComponentDetails({ componentId }
     21                                           : { componentId: number }) {
     22    const context = ctx();
     23
     24    if(!Number.isInteger(componentId) || componentId <= 0) throw Abort();
     25
     26    const componentDetails = await drizzleQueries.getComponentDetails(context.db, componentId);
     27
     28    if(!componentDetails) throw Abort();
     29
     30    return componentDetails;
     31}
     32
     33export async function getPopupSuggestComponent({ link, description, componentType }
     34                                               : { link: string; description: string; componentType: string }) {
     35    const { c, userId } = requireUser()
     36
     37    const newSuggestionId = await drizzleQueries.addComponentSuggestion(c.db, userId, link, description, componentType);
     38
     39    if(!newSuggestionId) throw Abort();
     40
     41    return newSuggestionId;
    1642}
    1743
     
    3864export async function getPopupBuildDetails({ buildId }
    3965                                           : { buildId: number }) {
    40     const context = ctx();
     66    const context = getAuthState();
    4167
    4268    if(!Number.isInteger(buildId) || buildId <= 0) throw Abort();
    4369
    44     const buildDetails = await drizzleQueries.getBuildDetails(context.db, buildId);
     70    const buildDetails = await drizzleQueries.getBuildDetails(context.db, buildId, context.userId ?? undefined);
    4571
    4672    if(!buildDetails) throw Abort();
     
    6591
    6692    if (!Number.isInteger(buildId) || buildId <= 0) throw Abort();
     93
     94    if (!Number.isInteger(value) || value < 1 || value > 5) throw Abort();
    6795
    6896    const result = await drizzleQueries.setBuildRating(c.db, userId, buildId, value);
  • pages/dashboard/admin/adminDashboard.telefunc.ts

    rc4dd17d r5ce5904  
    1212    const pendingBuilds = await drizzleQueries.getPendingBuilds(c.db);
    1313    const userBuilds = await drizzleQueries.getUserBuilds(c.db, userId);
    14     // const componentSuggestions = await drizzleQueries.getComponentSuggestions(c.db);
     14    const componentSuggestions = await drizzleQueries.getComponentSuggestions(c.db);
    1515
    1616    return {
     
    1818        pendingBuilds,
    1919        userBuilds,
    20         // componentSuggestions
     20        componentSuggestions
    2121    };
    2222}
     
    4040
    4141
    42     // setComponentSuggestionStatus
     42    if(!Number.isInteger(suggestionId) || suggestionId <= 0) throw Abort();
     43
     44    const result = await drizzleQueries.setComponentSuggestionStatus(c.db, suggestionId, userId, status, adminComment);
     45
     46    if (!result) throw Abort();
     47
     48    return { success: true };
    4349}
Note: See TracChangeset for help on using the changeset viewer.